Skip to content

Commit ce8a9ed

Browse files
committedApr 11, 2015
Fix a rare crash case un SendPlayerHP
If the player is disconnected while Lua API is doing a l_punch call, for example, the playersao is NULL and the server crash. Fix it.
1 parent 0a41326 commit ce8a9ed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

Diff for: ‎src/server.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,11 @@ void Server::SendPlayerHP(u16 peer_id)
18021802
{
18031803
DSTACK(__FUNCTION_NAME);
18041804
PlayerSAO *playersao = getPlayerSAO(peer_id);
1805-
assert(playersao);
1805+
// In some rare case, if the player is disconnected
1806+
// while Lua call l_punch, for example, this can be NULL
1807+
if (!playersao)
1808+
return;
1809+
18061810
SendHP(peer_id, playersao->getHP());
18071811
m_script->player_event(playersao,"health_changed");
18081812

0 commit comments

Comments
 (0)
Please sign in to comment.