Replace hasElementOfType with protocol version

This commit is contained in:
cx384 2024-02-01 17:44:52 +01:00
parent 26b6c42ed7
commit 195b7494d7
2 changed files with 3 additions and 10 deletions

View File

@ -371,20 +371,13 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
elems.insert(it, e);
}
// Legacy (Remove this when version 5.8.0 and older is not supported anymore.)
// If a new client connects to a sever version 5.8.0 and older some HUD elements
// are not hard coded in the client code anymore, but handled in builtin.
// So the client must add them again.
// Hotbar
if ((player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE) && !hasElementOfType(HUD_ELEM_HOTBAR)) {
// Add builtin hotbar if the server doesn't send it.
if (client->getProtoVersion() < 44 && (player->hud_flags & HUD_FLAG_HOTBAR_VISIBLE)) {
HudElement hotbar{HUD_ELEM_HOTBAR, v2f(0.5, 1), "", v2f(), "", 0 , 0, 0, v2f(-0.5, -1),
v2f(0, -4), v3f(), v2s32(), 0, "", 0};
elems.push_back(&hotbar);
}
// End of legacy support code.
for (HudElement *e : elems) {
v2s32 pos(floor(e->pos.X * (float) m_screensize.X + 0.5),

View File

@ -222,7 +222,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
PROTOCOL VERSION 44:
AO_CMD_SET_BONE_POSITION extended
Add TOCLIENT_MOVE_PLAYER_REL
Move default minimap from client-side C++ to server-side builtin Lua
Move default minimap and hotbar from client-side C++ to server-side builtin Lua
[scheduled bump for 5.9.0]
*/