Remove redundant on_dieplayer calls
This commit is contained in:
parent
1d69a23ba4
commit
3f1adb49ae
@ -828,7 +828,6 @@ void Server::handleCommand_Damage(NetworkPacket* pkt)
|
|||||||
|
|
||||||
PlayerHPChangeReason reason(PlayerHPChangeReason::FALL);
|
PlayerHPChangeReason reason(PlayerHPChangeReason::FALL);
|
||||||
playersao->setHP((s32)playersao->getHP() - (s32)damage, reason);
|
playersao->setHP((s32)playersao->getHP() - (s32)damage, reason);
|
||||||
SendPlayerHPOrDie(playersao, reason);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1113,9 +1112,6 @@ void Server::handleCommand_Interact(NetworkPacket *pkt)
|
|||||||
float time_from_last_punch =
|
float time_from_last_punch =
|
||||||
playersao->resetTimeFromLastPunch();
|
playersao->resetTimeFromLastPunch();
|
||||||
|
|
||||||
u16 src_original_hp = pointed_object->getHP();
|
|
||||||
u16 dst_origin_hp = playersao->getHP();
|
|
||||||
|
|
||||||
u16 wear = pointed_object->punch(dir, &toolcap, playersao,
|
u16 wear = pointed_object->punch(dir, &toolcap, playersao,
|
||||||
time_from_last_punch);
|
time_from_last_punch);
|
||||||
|
|
||||||
@ -1125,18 +1121,6 @@ void Server::handleCommand_Interact(NetworkPacket *pkt)
|
|||||||
if (changed)
|
if (changed)
|
||||||
playersao->setWieldedItem(selected_item);
|
playersao->setWieldedItem(selected_item);
|
||||||
|
|
||||||
// If the object is a player and its HP changed
|
|
||||||
if (src_original_hp != pointed_object->getHP() &&
|
|
||||||
pointed_object->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
|
|
||||||
SendPlayerHPOrDie((PlayerSAO *)pointed_object,
|
|
||||||
PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, playersao));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the puncher is a player and its HP changed
|
|
||||||
if (dst_origin_hp != playersao->getHP())
|
|
||||||
SendPlayerHPOrDie(playersao,
|
|
||||||
PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, pointed_object));
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} // action == INTERACT_START_DIGGING
|
} // action == INTERACT_START_DIGGING
|
||||||
|
|
||||||
|
@ -200,8 +200,6 @@ void read_object_properties(lua_State *L, int index,
|
|||||||
if (prop->hp_max < sao->getHP()) {
|
if (prop->hp_max < sao->getHP()) {
|
||||||
PlayerHPChangeReason reason(PlayerHPChangeReason::SET_HP);
|
PlayerHPChangeReason reason(PlayerHPChangeReason::SET_HP);
|
||||||
sao->setHP(prop->hp_max, reason);
|
sao->setHP(prop->hp_max, reason);
|
||||||
if (sao->getType() == ACTIVEOBJECT_TYPE_PLAYER)
|
|
||||||
sao->getEnv()->getGameDef()->SendPlayerHPOrDie((PlayerSAO *)sao, reason);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,27 +172,11 @@ int ObjectRef::l_punch(lua_State *L)
|
|||||||
float time_from_last_punch = readParam<float>(L, 3, 1000000.0f);
|
float time_from_last_punch = readParam<float>(L, 3, 1000000.0f);
|
||||||
ToolCapabilities toolcap = read_tool_capabilities(L, 4);
|
ToolCapabilities toolcap = read_tool_capabilities(L, 4);
|
||||||
v3f dir = readParam<v3f>(L, 5, sao->getBasePosition() - puncher->getBasePosition());
|
v3f dir = readParam<v3f>(L, 5, sao->getBasePosition() - puncher->getBasePosition());
|
||||||
|
|
||||||
dir.normalize();
|
dir.normalize();
|
||||||
u16 src_original_hp = sao->getHP();
|
|
||||||
u16 dst_origin_hp = puncher->getHP();
|
|
||||||
|
|
||||||
u16 wear = sao->punch(dir, &toolcap, puncher, time_from_last_punch);
|
u16 wear = sao->punch(dir, &toolcap, puncher, time_from_last_punch);
|
||||||
lua_pushnumber(L, wear);
|
lua_pushnumber(L, wear);
|
||||||
|
|
||||||
// If the punched is a player, and its HP changed
|
|
||||||
if (src_original_hp != sao->getHP() &&
|
|
||||||
sao->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
|
|
||||||
getServer(L)->SendPlayerHPOrDie((PlayerSAO *)sao,
|
|
||||||
PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, puncher));
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the puncher is a player, and its HP changed
|
|
||||||
if (dst_origin_hp != puncher->getHP() &&
|
|
||||||
puncher->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
|
|
||||||
getServer(L)->SendPlayerHPOrDie((PlayerSAO *)puncher,
|
|
||||||
PlayerHPChangeReason(PlayerHPChangeReason::PLAYER_PUNCH, sao));
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,8 +222,6 @@ int ObjectRef::l_set_hp(lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sao->setHP(hp, reason);
|
sao->setHP(hp, reason);
|
||||||
if (sao->getType() == ACTIVEOBJECT_TYPE_PLAYER)
|
|
||||||
getServer(L)->SendPlayerHPOrDie((PlayerSAO *)sao, reason);
|
|
||||||
if (reason.hasLuaReference())
|
if (reason.hasLuaReference())
|
||||||
luaL_unref(L, LUA_REGISTRYINDEX, reason.lua_reference);
|
luaL_unref(L, LUA_REGISTRYINDEX, reason.lua_reference);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1079,8 +1079,7 @@ PlayerSAO* Server::StageTwoClientInit(session_t peer_id)
|
|||||||
if (playersao->isDead())
|
if (playersao->isDead())
|
||||||
SendDeathscreen(peer_id, false, v3f(0,0,0));
|
SendDeathscreen(peer_id, false, v3f(0,0,0));
|
||||||
else
|
else
|
||||||
SendPlayerHPOrDie(playersao,
|
SendPlayerHP(peer_id);
|
||||||
PlayerHPChangeReason(PlayerHPChangeReason::SET_HP));
|
|
||||||
|
|
||||||
// Send Breath
|
// Send Breath
|
||||||
SendPlayerBreath(playersao);
|
SendPlayerBreath(playersao);
|
||||||
|
@ -167,7 +167,6 @@ void PlayerSAO::step(float dtime, bool send_recommended)
|
|||||||
if (m_breath == 0) {
|
if (m_breath == 0) {
|
||||||
PlayerHPChangeReason reason(PlayerHPChangeReason::DROWNING);
|
PlayerHPChangeReason reason(PlayerHPChangeReason::DROWNING);
|
||||||
setHP(m_hp - c.drowning, reason);
|
setHP(m_hp - c.drowning, reason);
|
||||||
m_env->getGameDef()->SendPlayerHPOrDie(this, reason);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -216,7 +215,6 @@ void PlayerSAO::step(float dtime, bool send_recommended)
|
|||||||
s32 newhp = (s32)m_hp - (s32)damage_per_second;
|
s32 newhp = (s32)m_hp - (s32)damage_per_second;
|
||||||
PlayerHPChangeReason reason(PlayerHPChangeReason::NODE_DAMAGE, nodename);
|
PlayerHPChangeReason reason(PlayerHPChangeReason::NODE_DAMAGE, nodename);
|
||||||
setHP(newhp, reason);
|
setHP(newhp, reason);
|
||||||
m_env->getGameDef()->SendPlayerHPOrDie(this, reason);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,6 +489,8 @@ void PlayerSAO::setHP(s32 hp, const PlayerHPChangeReason &reason)
|
|||||||
// Update properties on death
|
// Update properties on death
|
||||||
if ((hp == 0) != (oldhp == 0))
|
if ((hp == 0) != (oldhp == 0))
|
||||||
m_properties_sent = false;
|
m_properties_sent = false;
|
||||||
|
|
||||||
|
m_env->getGameDef()->SendPlayerHPOrDie(this, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerSAO::setBreath(const u16 breath, bool send)
|
void PlayerSAO::setBreath(const u16 breath, bool send)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user