summaryrefslogtreecommitdiff
path: root/src/content_sao.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2017-09-15 12:18:47 +0200
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-09-15 12:18:47 +0200
commitedbc533414b0ba991a82f8003d90924e1dc60d95 (patch)
tree9fe4c04bc35f345e9a62f1358fa5e0ad324938e9 /src/content_sao.cpp
parent7640749d68b87a62868840d34a665101861ca9c0 (diff)
downloadminetest-edbc533414b0ba991a82f8003d90924e1dc60d95.tar.gz
minetest-edbc533414b0ba991a82f8003d90924e1dc60d95.tar.bz2
minetest-edbc533414b0ba991a82f8003d90924e1dc60d95.zip
Customizeable max breath for players (#6411)
* Customizeable maximal breath for players
Diffstat (limited to 'src/content_sao.cpp')
-rw-r--r--src/content_sao.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index ece921472..2a2384b3d 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -797,6 +797,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
assert(m_peer_id != 0); // pre-condition
m_prop.hp_max = PLAYER_MAX_HP_DEFAULT;
+ m_prop.breath_max = PLAYER_MAX_BREATH_DEFAULT;
m_prop.physical = false;
m_prop.weight = 75;
m_prop.collisionbox = aabb3f(-0.3f, 0.0f, -0.3f, 0.3f, 1.77f, 0.3f);
@@ -817,6 +818,7 @@ PlayerSAO::PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, u16 peer_id
m_prop.stepheight = PLAYER_DEFAULT_STEPHEIGHT * BS;
m_prop.can_zoom = true;
m_hp = m_prop.hp_max;
+ m_breath = m_prop.breath_max;
}
PlayerSAO::~PlayerSAO()
@@ -943,7 +945,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
MapNode n = m_env->getMap().getNodeNoEx(p);
const ContentFeatures &c = m_env->getGameDef()->ndef()->get(n);
// If player is alive & no drowning, breath
- if (m_hp > 0 && m_breath < PLAYER_MAX_BREATH && c.drowning == 0)
+ if (m_hp > 0 && m_breath < m_prop.breath_max && c.drowning == 0)
setBreath(m_breath + 1);
}
@@ -1274,7 +1276,7 @@ void PlayerSAO::setBreath(const u16 breath, bool send)
if (m_player && breath != m_breath)
m_player->setDirty(true);
- m_breath = MYMIN(breath, PLAYER_MAX_BREATH);
+ m_breath = MYMIN(breath, m_prop.breath_max);
if (send)
m_env->getGameDef()->SendPlayerBreath(this);