Skip to content

Commit

Permalink
Don't call a player event without having player to do a event for
Browse files Browse the repository at this point in the history
  • Loading branch information
sapier authored and sapier committed Aug 21, 2014
1 parent a4c987b commit 2a5c88b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/script/cpp_api/s_env.cpp
Expand Up @@ -61,6 +61,9 @@ void ScriptApiEnv::environment_Step(float dtime)
void ScriptApiEnv::player_event(ServerActiveObject* player, std::string type)
{
SCRIPTAPI_PRECHECKHEADER

if (player == NULL)
return;

// Get minetest.registered_playerevents
lua_getglobal(L, "minetest");
Expand Down
7 changes: 6 additions & 1 deletion src/server.cpp
Expand Up @@ -4580,8 +4580,13 @@ bool Server::hudSetFlags(Player *player, u32 flags, u32 mask) {

SendHUDSetFlags(player->peer_id, flags, mask);
player->hud_flags = flags;

PlayerSAO* playersao = player->getPlayerSAO();

if (playersao == NULL)
return false;

m_script->player_event(player->getPlayerSAO(),"hud_changed");
m_script->player_event(playersao, "hud_changed");
return true;
}

Expand Down

0 comments on commit 2a5c88b

Please sign in to comment.