diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-04-15 09:25:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-15 09:25:43 +0200 |
commit | a9aad4d0616e798a8e61ac2a30dc31efd53b8c65 (patch) | |
tree | 73a9c207ad7557bcaa433cc8d6769ebbce0fba27 /src/clientenvironment.cpp | |
parent | b1e6c2a9b8f10254c027fe227811fc300bae2048 (diff) | |
download | minetest-a9aad4d0616e798a8e61ac2a30dc31efd53b8c65.tar.gz minetest-a9aad4d0616e798a8e61ac2a30dc31efd53b8c65.tar.bz2 minetest-a9aad4d0616e798a8e61ac2a30dc31efd53b8c65.zip |
Partial damage cheat fix: node damages server side (#4981)
* Damage cheat fix: server side
* Lava/Node damages overtime server side
* lava hurt interval is only for old protocol
Diffstat (limited to 'src/clientenvironment.cpp')
-rw-r--r-- | src/clientenvironment.cpp | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/src/clientenvironment.cpp b/src/clientenvironment.cpp index 94c8e0dcb..4a8bbb066 100644 --- a/src/clientenvironment.cpp +++ b/src/clientenvironment.cpp @@ -252,37 +252,31 @@ void ClientEnvironment::step(float dtime) m_script->environment_step(dtime); } - /* - A quick draft of lava damage - */ - if(m_lava_hurt_interval.step(dtime, 1.0)) - { - v3f pf = lplayer->getPosition(); - - // Feet, middle and head - v3s16 p1 = floatToInt(pf + v3f(0, BS*0.1, 0), BS); - MapNode n1 = m_map->getNodeNoEx(p1); - v3s16 p2 = floatToInt(pf + v3f(0, BS*0.8, 0), BS); - MapNode n2 = m_map->getNodeNoEx(p2); - v3s16 p3 = floatToInt(pf + v3f(0, BS*1.6, 0), BS); - MapNode n3 = m_map->getNodeNoEx(p3); - - u32 damage_per_second = 0; - damage_per_second = MYMAX(damage_per_second, - m_client->ndef()->get(n1).damage_per_second); - damage_per_second = MYMAX(damage_per_second, - m_client->ndef()->get(n2).damage_per_second); - damage_per_second = MYMAX(damage_per_second, - m_client->ndef()->get(n3).damage_per_second); - - if(damage_per_second != 0) - { - damageLocalPlayer(damage_per_second, true); - } - } - // Protocol v29 make this behaviour obsolete if (getGameDef()->getProtoVersion() < 29) { + if (m_lava_hurt_interval.step(dtime, 1.0)) { + v3f pf = lplayer->getPosition(); + + // Feet, middle and head + v3s16 p1 = floatToInt(pf + v3f(0, BS * 0.1, 0), BS); + MapNode n1 = m_map->getNodeNoEx(p1); + v3s16 p2 = floatToInt(pf + v3f(0, BS * 0.8, 0), BS); + MapNode n2 = m_map->getNodeNoEx(p2); + v3s16 p3 = floatToInt(pf + v3f(0, BS * 1.6, 0), BS); + MapNode n3 = m_map->getNodeNoEx(p3); + + u32 damage_per_second = 0; + damage_per_second = MYMAX(damage_per_second, + m_client->ndef()->get(n1).damage_per_second); + damage_per_second = MYMAX(damage_per_second, + m_client->ndef()->get(n2).damage_per_second); + damage_per_second = MYMAX(damage_per_second, + m_client->ndef()->get(n3).damage_per_second); + + if (damage_per_second != 0) + damageLocalPlayer(damage_per_second, true); + } + /* Drowning */ |