diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2021-08-21 20:04:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-21 20:04:04 +0200 |
commit | 0c1e9603db32b4281974fdd8b8e3b505148be47e (patch) | |
tree | 376b6f04d1c27388fbb453694827976a9a6d39a0 /src/network | |
parent | a72d13064fcbddaf332c7d53e6f34b74d8781586 (diff) | |
download | minetest-0c1e9603db32b4281974fdd8b8e3b505148be47e.tar.gz minetest-0c1e9603db32b4281974fdd8b8e3b505148be47e.tar.bz2 minetest-0c1e9603db32b4281974fdd8b8e3b505148be47e.zip |
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
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/clientpackethandler.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 50f497959..a631a3178 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -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; |