1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

HUD: Reject and warn on invalid stat types (#11548)

This comes into play on older servers which do not know the "stat" type.
Warnings are only logged once to avoid spam within globalstep callbacks
This commit is contained in:
SmallJoker 2021-08-21 20:04:04 +02:00 committed by GitHub
parent a72d13064f
commit 0c1e9603db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 86 additions and 44 deletions

View file

@ -1119,17 +1119,29 @@ void Client::handleCommand_HudChange(NetworkPacket* pkt)
*pkt >> server_id >> stat;
if (stat == HUD_STAT_POS || stat == HUD_STAT_SCALE ||
stat == HUD_STAT_ALIGN || stat == HUD_STAT_OFFSET)
*pkt >> v2fdata;
else if (stat == HUD_STAT_NAME || stat == HUD_STAT_TEXT || stat == HUD_STAT_TEXT2)
*pkt >> sdata;
else if (stat == HUD_STAT_WORLD_POS)
*pkt >> v3fdata;
else if (stat == HUD_STAT_SIZE)
*pkt >> v2s32data;
else
*pkt >> intdata;
// Keep in sync with:server.cpp -> SendHUDChange
switch ((HudElementStat)stat) {
case HUD_STAT_POS:
case HUD_STAT_SCALE:
case HUD_STAT_ALIGN:
case HUD_STAT_OFFSET:
*pkt >> v2fdata;
break;
case HUD_STAT_NAME:
case HUD_STAT_TEXT:
case HUD_STAT_TEXT2:
*pkt >> sdata;
break;
case HUD_STAT_WORLD_POS:
*pkt >> v3fdata;
break;
case HUD_STAT_SIZE:
*pkt >> v2s32data;
break;
default:
*pkt >> intdata;
break;
}
ClientEvent *event = new ClientEvent();
event->type = CE_HUDCHANGE;