From 01ec6e3c4d46e27adbec8b0f5e3149f6adebeb67 Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 3 Dec 2019 16:02:51 +0800 Subject: [PATCH] Add server addon checker --- src/network/protocols/server_lobby.cpp | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/network/protocols/server_lobby.cpp b/src/network/protocols/server_lobby.cpp index 4e2fe5acb..7509f1524 100644 --- a/src/network/protocols/server_lobby.cpp +++ b/src/network/protocols/server_lobby.cpp @@ -5000,6 +5000,39 @@ void ServerLobby::handleServerCommand(Event* event, STKPeer* peer) const peer->sendPacket(chat, true/*reliable*/); delete chat; } + else if (argv[0] == "serverhasaddon") + { + NetworkString* chat = getNetworkString(); + chat->addUInt8(LE_CHAT); + chat->setSynchronous(true); + if (argv.size() != 2) + { + chat->encodeString16( + L"Usage: /serverhasaddon [addon_identity]"); + } + else + { + std::set total_addons; + total_addons.insert(m_addon_kts.first.begin(), m_addon_kts.first.end()); + total_addons.insert(m_addon_kts.second.begin(), m_addon_kts.second.end()); + total_addons.insert(m_addon_arenas.begin(), m_addon_arenas.end()); + total_addons.insert(m_addon_soccers.begin(), m_addon_soccers.end()); + std::string addon_id_test = Addon::createAddonId(argv[1]); + bool found = total_addons.find(addon_id_test) != total_addons.end(); + if (found) + { + chat->encodeString16((std::string + ("Server has addon ") + argv[1]).c_str()); + } + else + { + chat->encodeString16((std::string + ("Server has no addon ") + argv[1]).c_str()); + } + } + peer->sendPacket(chat, true/*reliable*/); + delete chat; + } else { NetworkString* chat = getNetworkString();