1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +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

@ -499,9 +499,10 @@ void Client::step(float dtime)
m_client_event_queue.push(event);
}
}
else if(event.type == CEE_PLAYER_BREATH) {
u16 breath = event.player_breath.amount;
sendBreath(breath);
// Protocol v29 or greater obsoleted this event
else if (event.type == CEE_PLAYER_BREATH && m_proto_ver < 29) {
u16 breath = event.player_breath.amount;
sendBreath(breath);
}
}
@ -1270,6 +1271,10 @@ void Client::sendBreath(u16 breath)
{
DSTACK(FUNCTION_NAME);
// Protocol v29 make this obsolete
if (m_proto_ver >= 29)
return;
NetworkPacket pkt(TOSERVER_BREATH, sizeof(u16));
pkt << breath;
Send(&pkt);