Skip to content

Commit

Permalink
Deleting a player while it's in a guild cause the server to crash. (I…
Browse files Browse the repository at this point in the history
…ssue Sphereserver#971).

When a player is deleted, the ClearPlayer method is called before the character destructor, in this method the m_pPlayer property is set to null and this cause the Guild_Resign method (found in the character destructor) to fail and not deleting the player from the guild.

So i just moved the Guild_Resign method from the destructor to the ClearPlayer method.
  • Loading branch information
drk84 committed Dec 3, 2022
1 parent 4e8041e commit 236a02c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3094,4 +3094,6 @@ 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
- Fix: Deleting a player while it's in a guild cause the server to crash. (Issue #971).
11 changes: 7 additions & 4 deletions src/game/chars/CChar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,11 @@ CChar::~CChar()
m_pParty->RemoveMember( GetUID(), GetUID() );
m_pParty = nullptr;
}
Guild_Resign(MEMORY_GUILD);
Guild_Resign(MEMORY_TOWN);
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)

//Guild_Resign(MEMORY_GUILD); Moved to ClearPlayer Method otherwise this method will fail because the m_pPlayer property is already set to null.
//Guild_Resign(MEMORY_TOWN); Moved to ClearPlayer Method otherwise this method will fail because the m_pPlayer property is already set to null.

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 +565,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 236a02c

Please sign in to comment.