aboutsummaryrefslogtreecommitdiff
path: root/src/player.cpp
diff options
context:
space:
mode:
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);