Skip to content

Instantly share code, notes, and snippets.

@sapier
Created August 21, 2014 15:20
Show Gist options
  • Save sapier/de28cd52166453ce7e54 to your computer and use it in GitHub Desktop.
Save sapier/de28cd52166453ce7e54 to your computer and use it in GitHub Desktop.
diff --git a/src/script/cpp_api/s_env.cpp b/src/script/cpp_api/s_env.cpp
index 9ac9302..8d00178 100644
--- a/src/script/cpp_api/s_env.cpp
+++ b/src/script/cpp_api/s_env.cpp
@@ -62,6 +62,9 @@ void ScriptApiEnv::player_event(ServerActiveObject* player, std::string type)
{
SCRIPTAPI_PRECHECKHEADER
+ if (player == NULL)
+ return;
+
// Get minetest.registered_playerevents
lua_getglobal(L, "minetest");
lua_getfield(L, -1, "registered_playerevents");
diff --git a/src/server.cpp b/src/server.cpp
index 40857f8..bf5d3c4 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -4581,7 +4581,12 @@ bool Server::hudSetFlags(Player *player, u32 flags, u32 mask) {
SendHUDSetFlags(player->peer_id, flags, mask);
player->hud_flags = flags;
- m_script->player_event(player->getPlayerSAO(),"hud_changed");
+ PlayerSAO* playersao = player->getPlayerSAO();
+
+ if (!playersao)
+ return false;
+
+ m_script->player_event(playersao, "hud_changed");
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment