return m_csm_noderange_limit;
}
+ inline std::unordered_map<u32, u32> &getHUDTranslationMap()
+ {
+ return m_hud_server_to_client;
+ }
+
bool joinModChannel(const std::string &channel);
bool leaveModChannel(const std::string &channel);
bool sendModChannelMessage(const std::string &channel, const std::string &message);
void Game::handleClientEvent_HudAdd(ClientEvent *event, CameraOrientation *cam)
{
LocalPlayer *player = client->getEnv().getLocalPlayer();
+ auto hud_server_to_client = client->getHUDTranslationMap();
- u32 id = event->hudadd.id;
-
- HudElement *e = player->getHud(id);
-
- if (e != NULL) {
+ u32 server_id = event->hudadd.server_id;
+ // ignore if we already have a HUD with that ID
+ auto i = hud_server_to_client.find(server_id);
+ if (i != hud_server_to_client.end()) {
delete event->hudadd.pos;
delete event->hudadd.name;
delete event->hudadd.scale;
return;
}
- e = new HudElement;
+ HudElement *e = new HudElement;
e->type = (HudElementType)event->hudadd.type;
e->pos = *event->hudadd.pos;
e->name = *event->hudadd.name;
e->offset = *event->hudadd.offset;
e->world_pos = *event->hudadd.world_pos;
e->size = *event->hudadd.size;
-
- u32 new_id = player->addHud(e);
- //if this isn't true our huds aren't consistent
- sanity_check(new_id == id);
+ hud_server_to_client[server_id] = player->addHud(e);
delete event->hudadd.pos;
delete event->hudadd.name;
try {
*pkt >> size;
} catch(SerializationError &e) {};
- u32 client_id = getEnv().getLocalPlayer()->getFreeHudID();
- m_hud_server_to_client[server_id] = client_id;
ClientEvent *event = new ClientEvent();
event->type = CE_HUDADD;
- event->hudadd.id = client_id;
+ event->hudadd.server_id = server_id;
event->hudadd.type = type;
event->hudadd.pos = new v2f(pos);
event->hudadd.name = new std::string(name);
*pkt >> server_id;
- std::unordered_map<u32, u32>::const_iterator i = m_hud_server_to_client.find(server_id);
+ auto i = m_hud_server_to_client.find(server_id);
if (i != m_hud_server_to_client.end()) {
int client_id = i->second;
m_hud_server_to_client.erase(i);