aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorsapier <Sapier at GMX dot net>2014-05-25 14:34:32 +0200
committersapier <Sapier at GMX dot net>2014-05-31 22:32:44 +0200
commitd76b8c6e7ca96b33b706ef42a8e301531c592fea (patch)
treea59d14f8f3010363faf596cb0acdfddd5d105ac0 /src/server.cpp
parent5bd2aea663945d467744749579a1812f2e47bde7 (diff)
downloadminetest-d76b8c6e7ca96b33b706ef42a8e301531c592fea.tar.gz
minetest-d76b8c6e7ca96b33b706ef42a8e301531c592fea.tar.bz2
minetest-d76b8c6e7ca96b33b706ef42a8e301531c592fea.zip
Small cleanup of hud add/remove code
Diffstat (limited to 'src/server.cpp')
-rw-r--r--src/server.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 612192d79..29fb18112 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -4560,24 +4560,25 @@ bool Server::showFormspec(const char *playername, const std::string &formspec, c
u32 Server::hudAdd(Player *player, HudElement *form) {
if (!player)
return -1;
-
- u32 id = player->getFreeHudID();
- if (id < player->hud.size())
- player->hud[id] = form;
- else
- player->hud.push_back(form);
+ u32 id = player->addHud(form);
+
SendHUDAdd(player->peer_id, id, form);
+
return id;
}
bool Server::hudRemove(Player *player, u32 id) {
- if (!player || id >= player->hud.size() || !player->hud[id])
+ if (!player)
return false;
- delete player->hud[id];
- player->hud[id] = NULL;
+ HudElement* todel = player->removeHud(id);
+
+ if (!todel)
+ return false;
+ delete todel;
+
SendHUDRemove(player->peer_id, id);
return true;
}
@@ -5047,7 +5048,7 @@ PlayerSAO* Server::emergePlayer(const char *name, u16 peer_id)
isSingleplayer());
/* Clean up old HUD elements from previous sessions */
- player->hud.clear();
+ player->clearHud();
/* Add object to environment */
m_env->addActiveObject(playersao);