Skip to content

Commit

Permalink
Fix: Deleting a player while it's in a guild cause the server to cras…
Browse files Browse the repository at this point in the history
…h. (Issue Sphereserver#971).

When a player is deleted the ClearPlayer method is called and this set the m_pPlayer property to null. When a deleted player is inside a guild, the Guild_Resign method will fail because this method relies upon the m_pPlayer to succeed (and the destructor is called after ClearPlayer).

So i just moved the Guild_Resign method in the ClearPlayer before the m_pPlayer property is set to null.
  • Loading branch information
drk84 committed Dec 3, 2022
1 parent da6fa6a commit 4ad8671
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3094,4 +3094,7 @@ Notes:
- Changed: AR (the old armour value) property can be displayed up to 65k. (Issue #968)
- Changed: The DAM property (for both characters and weapons) can be displayed up to 65k. (Issue #967)
- Added: t_armor_bone typedef (value 305). If you want to use it you need to add it in the core/defs_types_hardcoded.scp file under the typedef section. (Issue #890)


03-12-2022, Drk84
03-12-2022, Drk84
- Fix: Deleting a player while it's in a guild cause the server to crash. (Issue #971).
7 changes: 4 additions & 3 deletions src/game/chars/CChar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ CChar::~CChar()
m_pParty->RemoveMember( GetUID(), GetUID() );
m_pParty = nullptr;
}
Guild_Resign(MEMORY_GUILD);
Guild_Resign(MEMORY_TOWN);
//Guild_Resign(MEMORY_GUILD); Moved to the ClearPlayer method otherwise it will cause a server crash because the deleted player will still be found in the guild list.
//Guild_Resign(MEMORY_TOWN); Moved to the ClearPlayer method otherwise it will cause a server crash because the deleted player will still be found in the guild list.
Attacker_RemoveChar(); // Removing me from enemy's attacker list (I asume that if he is on my list, I'm on his one and no one have me on their list if I dont have them)
if (m_pNPC)
NPC_PetClearOwners(); // Clear follower slots on pet owner
Expand Down Expand Up @@ -563,7 +563,8 @@ void CChar::ClearPlayer()

pAccount->DetachChar(this); // unlink me from my account.
}

Guild_Resign(MEMORY_GUILD);
Guild_Resign(MEMORY_TOWN);
delete m_pPlayer;
m_pPlayer = nullptr;
}
Expand Down

0 comments on commit 4ad8671

Please sign in to comment.