summaryrefslogtreecommitdiff
path: root/src/player.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/player.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/player.cpp')
-rw-r--r--src/player.cpp46
1 files changed, 39 insertions, 7 deletions
diff --git a/src/player.cpp b/src/player.cpp
index 8ad6ff241..4dadf26d0 100644
--- a/src/player.cpp
+++ b/src/player.cpp
@@ -216,19 +216,18 @@ void Player::deSerialize(std::istream &is, std::string playername)
setPosition(args.getV3F("position"));
try{
hp = args.getS32("hp");
- }catch(SettingNotFoundException &e){
+ }catch(SettingNotFoundException &e) {
hp = 20;
}
try{
m_breath = args.getS32("breath");
- }catch(SettingNotFoundException &e){
+ }catch(SettingNotFoundException &e) {
m_breath = 11;
}
inventory.deSerialize(is);
- if(inventory.getList("craftpreview") == NULL)
- {
+ if(inventory.getList("craftpreview") == NULL) {
// Convert players without craftpreview
inventory.addList("craftpreview", 1);
@@ -246,14 +245,47 @@ void Player::deSerialize(std::istream &is, std::string playername)
checkModified();
}
-/*
- RemotePlayer
-*/
+u32 Player::addHud(HudElement *toadd)
+{
+ u32 id = getFreeHudID();
+ if (id < hud.size())
+ hud[id] = toadd;
+ else
+ hud.push_back(toadd);
+ return id;
+}
+HudElement* Player::getHud(u32 id)
+{
+ if (id < hud.size())
+ return hud[id];
+ return NULL;
+}
+HudElement* Player::removeHud(u32 id)
+{
+ HudElement* retval = NULL;
+ if (id < hud.size()) {
+ retval = hud[id];
+ hud[id] = NULL;
+ }
+ return retval;
+}
+
+void Player::clearHud()
+{
+ while(!hud.empty()) {
+ delete hud.back();
+ hud.pop_back();
+ }
+}
+
+/*
+ RemotePlayer
+*/
void RemotePlayer::setPosition(const v3f &position)
{
Player::setPosition(position);