1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Breath cheat fix: server side

Breath is now handled server side. Changing this behaviour required some modifications to core:

* Ignore TOSERVER_BREATH package, marking it as obsolete
* Clients doesn't send the breath to server anymore
* Use PlayerSAO pointer instead of peer_id in Server::SendPlayerBreath to prevent a useless lookup (little perf gain)
* drop a useless static_cast in emergePlayer
This commit is contained in:
Loic Blot 2017-01-01 16:13:01 +01:00
parent a1346c916e
commit 52ba1f867e
13 changed files with 107 additions and 113 deletions

View file

@ -1076,8 +1076,7 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
}
m_clients.unlock();
RemotePlayer *player =
static_cast<RemotePlayer*>(m_env->getPlayer(playername.c_str()));
RemotePlayer *player = m_env->getPlayer(playername.c_str());
// If failed, cancel
if ((playersao == NULL) || (player == NULL)) {
@ -1113,7 +1112,7 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
SendPlayerHPOrDie(playersao);
// Send Breath
SendPlayerBreath(peer_id);
SendPlayerBreath(playersao);
// Show death screen if necessary
if (playersao->isDead())
@ -1857,14 +1856,13 @@ void Server::SendPlayerHP(u16 peer_id)
playersao->m_messages_out.push(aom);
}
void Server::SendPlayerBreath(u16 peer_id)
void Server::SendPlayerBreath(PlayerSAO *sao)
{
DSTACK(FUNCTION_NAME);
PlayerSAO *playersao = getPlayerSAO(peer_id);
assert(playersao);
assert(sao);
m_script->player_event(playersao, "breath_changed");
SendBreath(peer_id, playersao->getBreath());
m_script->player_event(sao, "breath_changed");
SendBreath(sao->getPeerID(), sao->getBreath());
}
void Server::SendMovePlayer(u16 peer_id)
@ -2565,7 +2563,6 @@ void Server::RespawnPlayer(u16 peer_id)
}
SendPlayerHP(peer_id);
SendPlayerBreath(peer_id);
}