mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Send Player HP when setHP (or a setHP caller) is called instead of looping and testing the state change.
This commit is contained in:
parent
056e8f7839
commit
64ff966bae
6 changed files with 54 additions and 42 deletions
|
@ -604,17 +604,6 @@ void Server::AsyncRunStep(bool initial_step)
|
|||
if(playersao == NULL)
|
||||
continue;
|
||||
|
||||
/*
|
||||
Handle player HPs (die if hp=0)
|
||||
*/
|
||||
if(playersao->m_hp_not_sent && g_settings->getBool("enable_damage"))
|
||||
{
|
||||
if(playersao->getHP() == 0)
|
||||
DiePlayer(*i);
|
||||
else
|
||||
SendPlayerHP(*i);
|
||||
}
|
||||
|
||||
/*
|
||||
Send player breath if changed
|
||||
*/
|
||||
|
@ -1889,7 +1878,6 @@ void Server::SendPlayerHP(u16 peer_id)
|
|||
DSTACK(__FUNCTION_NAME);
|
||||
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
||||
assert(playersao);
|
||||
playersao->m_hp_not_sent = false;
|
||||
SendHP(peer_id, playersao->getHP());
|
||||
m_script->player_event(playersao,"health_changed");
|
||||
|
||||
|
@ -2588,9 +2576,9 @@ void Server::DiePlayer(u16 peer_id)
|
|||
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
||||
assert(playersao);
|
||||
|
||||
infostream<<"Server::DiePlayer(): Player "
|
||||
<<playersao->getPlayer()->getName()
|
||||
<<" dies"<<std::endl;
|
||||
infostream << "Server::DiePlayer(): Player "
|
||||
<< playersao->getPlayer()->getName()
|
||||
<< " dies" << std::endl;
|
||||
|
||||
playersao->setHP(0);
|
||||
|
||||
|
@ -2608,13 +2596,15 @@ void Server::RespawnPlayer(u16 peer_id)
|
|||
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
||||
assert(playersao);
|
||||
|
||||
infostream<<"Server::RespawnPlayer(): Player "
|
||||
<<playersao->getPlayer()->getName()
|
||||
<<" respawns"<<std::endl;
|
||||
infostream << "Server::RespawnPlayer(): Player "
|
||||
<< playersao->getPlayer()->getName()
|
||||
<< " respawns" << std::endl;
|
||||
|
||||
playersao->setHP(PLAYER_MAX_HP);
|
||||
playersao->setBreath(PLAYER_MAX_BREATH);
|
||||
|
||||
SendPlayerHP(peer_id);
|
||||
|
||||
bool repositioned = m_script->on_respawnplayer(playersao);
|
||||
if(!repositioned){
|
||||
v3f pos = findSpawnPos(m_env->getServerMap());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue