aboutsummaryrefslogtreecommitdiff
path: root/src/crplayer.cc
diff options
context:
space:
mode:
authorfusion32 <marcopuzziello@gmail.com>2026-06-01 01:52:28 -0300
committerfusion32 <marcopuzziello@gmail.com>2026-06-01 01:54:15 -0300
commita8d26b6ce32066812fd46ac88804048d38218db3 (patch)
tree110d57955cc898e6d1f1ce33697ecfeaef74f02f /src/crplayer.cc
parente2ba7cd29617ae05087ad3d25c55a2eb8ce607a3 (diff)
downloadgame-a8d26b6ce32066812fd46ac88804048d38218db3.tar.gz
game-a8d26b6ce32066812fd46ac88804048d38218db3.zip
fix player state desync on login (#59)
Diffstat (limited to 'src/crplayer.cc')
-rw-r--r--src/crplayer.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/crplayer.cc b/src/crplayer.cc
index 8878bda..86b0c47 100644
--- a/src/crplayer.cc
+++ b/src/crplayer.cc
@@ -205,7 +205,7 @@ TPlayer::TPlayer(TConnection *Connection, uint32 CharacterID):
SendAmbiente(Connection);
AnnounceChangedCreature(CharacterID, CREATURE_LIGHT_CHANGED);
SendPlayerSkills(Connection);
- this->CheckState();
+ this->SyncState();
this->SendBuddies();
if(PlayerData->LastLoginTime != 0){
@@ -750,7 +750,6 @@ void TPlayer::TakeOver(TConnection *Connection){
strcpy(this->Guild, PlayerData->Guild);
strcpy(this->Rank, PlayerData->Rank);
strcpy(this->Title, PlayerData->Title);
- this->OldState = 0;
this->CheckOutfit();
this->ClearRequest();
@@ -770,7 +769,7 @@ void TPlayer::TakeOver(TConnection *Connection){
SendAmbiente(Connection);
SendPlayerData(Connection);
SendPlayerSkills(Connection);
- this->CheckState();
+ this->SyncState();
this->SendBuddies();
}
@@ -1254,6 +1253,16 @@ void TPlayer::CheckState(void){
}
}
+void TPlayer::SyncState(void){
+ // NOTE(fusion): This is only called after a new connection is established,
+ // when we know that the current client state is ZERO but `OldState` may not.
+ // It'll typically be the case in `TPlayer::TakeOver` but can also happen
+ // in the player constructor if `TPlayer::CheckState` is called from within
+ // any helper function before `TConnection::EnterGame` (see `BeginSendData`).
+ this->OldState = 0;
+ this->CheckState();
+}
+
void TPlayer::AddBuddy(const char *Name){
if(Name == NULL){
error("TPlayer::AddBuddy: Name ist NULL.\n");