diff options
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/server.cpp b/src/server.cpp index 7fad623c2..d5e505190 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3616,6 +3616,8 @@ void Server::SendHUDAdd(u16 peer_id, u32 id, HudElement *form) writeU32(os, form->number); writeU32(os, form->item); writeU32(os, form->dir); + writeV2F1000(os, form->align); + writeV2F1000(os, form->offset); // Make data buffer std::string s = os.str(); @@ -3650,6 +3652,8 @@ void Server::SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value switch (stat) { case HUD_STAT_POS: case HUD_STAT_SCALE: + case HUD_STAT_ALIGN: + case HUD_STAT_OFFSET: writeV2F1000(os, *(v2f *)value); break; case HUD_STAT_NAME: @@ -3671,6 +3675,22 @@ void Server::SendHUDChange(u16 peer_id, u32 id, HudElementStat stat, void *value m_con.Send(peer_id, 0, data, true); } +void Server::SendHUDSetFlags(u16 peer_id, u32 flags, u32 mask) +{ + std::ostringstream os(std::ios_base::binary); + + // Write command + writeU16(os, TOCLIENT_HUD_SET_FLAGS); + writeU32(os, flags); + writeU32(os, mask); + + // Make data buffer + std::string s = os.str(); + SharedBuffer<u8> data((u8 *)s.c_str(), s.size()); + // Send as reliable + m_con.Send(peer_id, 0, data, true); +} + void Server::BroadcastChatMessage(const std::wstring &message) { for(std::map<u16, RemoteClient*>::iterator @@ -4602,12 +4622,15 @@ void Server::saveConfig() g_settings->updateConfigFile(m_path_config.c_str()); } -void Server::notifyPlayer(const char *name, const std::wstring msg) +void Server::notifyPlayer(const char *name, const std::wstring msg, const bool prepend = true) { Player *player = m_env->getPlayer(name); if(!player) return; - SendChatMessage(player->peer_id, std::wstring(L"Server: -!- ")+msg); + if (prepend) + SendChatMessage(player->peer_id, std::wstring(L"Server -!- ")+msg); + else + SendChatMessage(player->peer_id, msg); } bool Server::showFormspec(const char *playername, const std::string &formspec, const std::string &formname) @@ -4657,6 +4680,14 @@ bool Server::hudChange(Player *player, u32 id, HudElementStat stat, void *data) return true; } +bool Server::hudSetFlags(Player *player, u32 flags, u32 mask) { + if (!player) + return false; + + SendHUDSetFlags(player->peer_id, flags, mask); + return true; +} + void Server::notifyPlayers(const std::wstring msg) { BroadcastChatMessage(msg); |