From d8e1822c7002c1536822c975d97fd125d39fc9c5 Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Sun, 3 Jan 2016 14:54:35 +0100 Subject: [PATCH 1/6] premake: fix oldRevNumber if a version.hpp in an old format exists. --- premake5.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/premake5.lua b/premake5.lua index ecb9eb8b..9c6d8e2f 100644 --- a/premake5.lua +++ b/premake5.lua @@ -25,6 +25,10 @@ newaction { if oldVersionHeader ~=nil then local oldVersionHeaderContent = assert(oldVersionHeader:read('*a')) oldRevNumber = string.match(oldVersionHeaderContent, "#define REVISION (%d+)") + if oldRevNumber = nil then + -- old version.hpp format? + oldRevNumber = "(none)" + end end -- generate version.hpp with a revision number if not equal From 03e5adfdaffccd50900c120a5b424b36bcb1960c Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Sun, 3 Jan 2016 14:57:24 +0100 Subject: [PATCH 2/6] premake5: Fix typo. --- premake5.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/premake5.lua b/premake5.lua index 9c6d8e2f..a8c1d4b2 100644 --- a/premake5.lua +++ b/premake5.lua @@ -25,7 +25,7 @@ newaction { if oldVersionHeader ~=nil then local oldVersionHeaderContent = assert(oldVersionHeader:read('*a')) oldRevNumber = string.match(oldVersionHeaderContent, "#define REVISION (%d+)") - if oldRevNumber = nil then + if oldRevNumber == nil then -- old version.hpp format? oldRevNumber = "(none)" end From ca5d823efdbac625902fd7dc434bc4b3467b8a1e Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 3 Jan 2016 15:14:44 +0100 Subject: [PATCH 3/6] Split playlist data (+fixed issue) TODO: Test with sensitive connections and unstable network drives. --- src/Components/Modules/Network.cpp | 25 ++++++++++- src/Components/Modules/Network.hpp | 6 +++ src/Components/Modules/Party.cpp | 16 ++++++- src/Components/Modules/Party.hpp | 1 + src/Components/Modules/Playlist.cpp | 60 +++++++++++++++++++++++++-- src/Components/Modules/Playlist.hpp | 3 +- src/Components/Modules/QuickPatch.cpp | 3 +- src/Game/Functions.cpp | 8 ++++ src/Game/Functions.hpp | 4 ++ 9 files changed, 118 insertions(+), 8 deletions(-) diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index 01d25a9e..969b6291 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -53,6 +53,23 @@ namespace Components Network::Send(Game::netsrc_t::NS_CLIENT, target, data); } + void Network::SendRaw(Game::netsrc_t type, Address target, std::string data) + { + DWORD header = 0xFFFFFFFF; + + std::string rawData; + rawData.append(reinterpret_cast(&header), 4); + rawData.append(data.begin(), data.end()); + rawData.append("\0", 1); + + Game::OOBPrintRaw(type, *target.Get(), rawData.data(), rawData.size()); + } + + void Network::SendRaw(Address target, std::string data) + { + Network::SendRaw(Game::netsrc_t::NS_CLIENT, target, data); + } + int Network::PacketInterceptionHandler(const char* packet) { // Check if custom handler exists @@ -74,7 +91,13 @@ namespace Components if (Network::PacketHandlers.find(Network::SelectedPacket) != Network::PacketHandlers.end()) { size_t offset = Network::SelectedPacket.size() + 4 + 1; - Network::PacketHandlers[Network::SelectedPacket](from, std::string(msg->data + offset, msg->cursize - offset)); + + std::string data(msg->data + offset, msg->cursize - offset); + + // Remove trailing 0x00 byte + if (data.size() && !data[data.size() - 1]) data.pop_back(); + + Network::PacketHandlers[Network::SelectedPacket](from, data); } else { diff --git a/src/Components/Modules/Network.hpp b/src/Components/Modules/Network.hpp index 544dbcbf..3a8517f5 100644 --- a/src/Components/Modules/Network.hpp +++ b/src/Components/Modules/Network.hpp @@ -35,9 +35,15 @@ namespace Components const char* GetName() { return "Network"; }; static void Handle(std::string packet, Callback callback); + + // Only non-binary data static void Send(Address target, std::string data); static void Send(Game::netsrc_t type, Address target, std::string data); + // Allows sending binary data + static void SendRaw(Address target, std::string data); + static void SendRaw(Game::netsrc_t type, Address target, std::string data); + private: static std::string SelectedPacket; static std::map PacketHandlers; diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index 3e4778b7..74e5fa16 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -97,6 +97,14 @@ namespace Components if (Party::LobbyMap.size() <= 1) Game::Steam_JoinLobby(id, 0); } + void Party::PlaylistError(std::string error) + { + Party::Container.Valid = false; + Party::Container.AwaitingPlaylist = false; + + Party::ConnectError(error); + } + DWORD Party::UIDvarIntStub(char* dvar) { if (!_stricmp(dvar, "onlinegame")) @@ -313,6 +321,13 @@ namespace Components Party::Container.RequestTime = Game::Com_Milliseconds(); Party::Container.AwaitingPlaylist = true; Network::Send(address, "getplaylist\n"); + + // This is not a safe method + // TODO: Fix actual error! + if (Game::CL_IsCgameInitialized()) + { + Command::Execute("disconnect", true); + } } else if (matchType == 2) // Match { @@ -326,7 +341,6 @@ namespace Components } else { - Dvar::Var("xblive_privatematch").Set(1); Game::Menus_CloseAll(Game::uiContext); char xnaddr[32]; diff --git a/src/Components/Modules/Party.hpp b/src/Components/Modules/Party.hpp index 352a7a2b..77be6e04 100644 --- a/src/Components/Modules/Party.hpp +++ b/src/Components/Modules/Party.hpp @@ -14,6 +14,7 @@ namespace Components static bool PlaylistAwaiting(); static void PlaylistContinue(); + static void PlaylistError(std::string error); private: struct JoinContainer diff --git a/src/Components/Modules/Playlist.cpp b/src/Components/Modules/Playlist.cpp index 6071fb50..87d6eda6 100644 --- a/src/Components/Modules/Playlist.cpp +++ b/src/Components/Modules/Playlist.cpp @@ -3,6 +3,7 @@ namespace Components { std::string Playlist::CurrentPlaylistBuffer; + std::string Playlist::ReceivedPlaylistBuffer; void Playlist::LoadPlaylist() { @@ -33,7 +34,23 @@ namespace Components void Playlist::PlaylistRequest(Network::Address address, std::string data) { Logger::Print("Received playlist request, sending currently stored buffer.\n"); - Network::Send(address, std::string("playlistresponse\n") + Playlist::CurrentPlaylistBuffer); + + // Split playlist data + unsigned int maxBytes = Playlist::CurrentPlaylistBuffer.size(); + + for (unsigned int i = 0; i < maxBytes; i += 2000) + { + unsigned int sendBytes = min(2000, maxBytes - i); + unsigned int sentBytes = i + sendBytes; + + std::string data; + data.append(reinterpret_cast(&sentBytes), 4); // Sent bytes + data.append(reinterpret_cast(&maxBytes), 4); // Max bytes + + data.append(Playlist::CurrentPlaylistBuffer.data() + i, sendBytes); + + Network::SendRaw(address, std::string("playlistresponse\n") + data); + } } void Playlist::PlaylistReponse(Network::Address address, std::string data) @@ -42,9 +59,43 @@ namespace Components { if (address == Party::Target()) { - Logger::Print("Received playlist response, loading and continuing connection.\n"); - Game::Live_ParsePlaylists(data.data()); - Party::PlaylistContinue(); + if (data.size() <= 8) + { + Party::PlaylistError(Utils::VA("Received playlist response, but it is invalid.")); + Playlist::ReceivedPlaylistBuffer.clear(); + return; + } + else + { + unsigned int sentBytes = *(unsigned int*)(data.data() + 0); + unsigned int maxBytes = *(unsigned int*)(data.data() + 4); + + // Clear current buffer, if we receive a new packet + if (data.size() - 8 == sentBytes) Playlist::ReceivedPlaylistBuffer.clear(); + + // Append received data + Playlist::ReceivedPlaylistBuffer.append(data.data() + 8, data.size() - 8); + + if (Playlist::ReceivedPlaylistBuffer.size() != sentBytes) + { + Party::PlaylistError(Utils::VA("Received playlist data, but it seems invalid: %d != %d", sentBytes, Playlist::ReceivedPlaylistBuffer.size())); + Playlist::ReceivedPlaylistBuffer.clear(); + return; + } + else + { + Logger::Print("Received playlist data: %d/%d (%d%%)\n", sentBytes, maxBytes, ((100 * sentBytes) / maxBytes)); + } + + if (Playlist::ReceivedPlaylistBuffer.size() == maxBytes) + { + Logger::Print("Received playlist response, loading and continuing connection.\n"); + Game::Live_ParsePlaylists(Playlist::ReceivedPlaylistBuffer.data()); + Party::PlaylistContinue(); + + Playlist::ReceivedPlaylistBuffer.clear(); + } + } } else { @@ -99,5 +150,6 @@ namespace Components Playlist::~Playlist() { Playlist::CurrentPlaylistBuffer.clear(); + Playlist::ReceivedPlaylistBuffer.clear(); } } diff --git a/src/Components/Modules/Playlist.hpp b/src/Components/Modules/Playlist.hpp index 68ed320e..969eb9f5 100644 --- a/src/Components/Modules/Playlist.hpp +++ b/src/Components/Modules/Playlist.hpp @@ -11,9 +11,10 @@ namespace Components static void LoadPlaylist(); + static std::string ReceivedPlaylistBuffer; + private: static std::string CurrentPlaylistBuffer; - static DWORD StorePlaylistStub(const char** buffer); static void PlaylistRequest(Network::Address address, std::string data); diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 1af63a13..cedd8b4b 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -70,8 +70,9 @@ namespace Components // splash logo Utils::Hook::Set(0x475F9E, "data/images/splash.bmp"); - // Numeric ping + // Numerical ping (cg_scoreboardPingText 1) Utils::Hook::Set(0x45888E, 1); + Utils::Hook::Set(0x45888C, Game::dvar_flag::DVAR_FLAG_CHEAT); // increase font sizes for chat on higher resolutions static float float13 = 13.0f; diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index e9d0634f..b6f7b486 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -74,6 +74,7 @@ namespace Game LocalizeMapString_t LocalizeMapString = (LocalizeMapString_t)0x44BB30; sendOOB_t OOBPrint = (sendOOB_t)0x4AEF00; + sendOOBRaw_t OOBPrintRawData = (sendOOBRaw_t)0x60FDC0; PC_ReadToken_t PC_ReadToken = (PC_ReadToken_t)0x4ACCD0; PC_ReadTokenHandle_t PC_ReadTokenHandle = (PC_ReadTokenHandle_t)0x4D2060; @@ -151,6 +152,13 @@ namespace Game OOBPrint(type, *adr, *(adr + 1), *(adr + 2), 0xFFFFFFFF, *(adr + 4), message); } + void OOBPrintRaw(int type, netadr_t netadr, const char* message, size_t length) + { + int* adr = (int*)&netadr; + + OOBPrintRawData(type, length, message, *adr, *(adr + 1), *(adr + 2), 0xFFFFFFFF, *(adr + 4)); + } + const char* UI_LocalizeMapName(const char* mapName) { for (int i = 0; i < *arenaCount; i++) diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index de74e544..63a53441 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -169,6 +169,9 @@ namespace Game typedef void(__cdecl* sendOOB_t)(int, int, int, int, int, int, const char*); extern sendOOB_t OOBPrint; + typedef void(__cdecl* sendOOBRaw_t)(int, size_t, const char*, int, int, int, int, int); + extern sendOOBRaw_t OOBPrintRawData; + typedef int(__cdecl * PC_ReadToken_t)(source_t*, token_t*); extern PC_ReadToken_t PC_ReadToken; @@ -244,6 +247,7 @@ namespace Game void* ReallocateAssetPool(XAssetType type, unsigned int newSize); void Menu_FreeItemMemory(Game::itemDef_t* item); void OOBPrintT(int type, netadr_t netadr, const char* message); + void OOBPrintRaw(int type, netadr_t netadr, const char* message, size_t length); const char* UI_LocalizeMapName(const char* mapName); const char* UI_LocalizeGameType(const char* gameType); } From 3c3eba82443175f475c43d932aaf797e17a75644 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 3 Jan 2016 15:44:51 +0100 Subject: [PATCH 4/6] --- src/Components/Modules/Localization.cpp | 25 +++++++++++++++++++++---- src/Components/Modules/Localization.hpp | 3 +++ src/Game/Functions.cpp | 2 ++ src/Game/Functions.hpp | 3 +++ 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index aee6539e..fbf7d63d 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -29,10 +29,31 @@ namespace Components return key; } + void __stdcall Localization::SetStringStub(const char* key, const char* value, bool isEnglish) + { + Localization::Set(key, value); + } + + DWORD Localization::SELoadLanguageStub() + { + //'official' iw4m localized strings + Game::SE_Load("localizedstrings/iw4m.str", 0); + + return Utils::Hook::Call(0x629E20)(); + } + Localization::Localization() { + // Resolving hook Utils::Hook(0x629B90, Localization::Get, HOOK_JUMP).Install()->Quick(); + // Set loading entry point + Utils::Hook(0x41D859, Localization::SELoadLanguageStub, HOOK_CALL).Install()->Quick(); + + // Overwrite SetString + Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).Install()->Quick(); + + // TODO: Get rid of those! Localization::Set("MENU_SEARCHINGFORGAMES_100MS", ""); Localization::Set("MP_SEARCHING_FOR_PLAYER", "Waiting"); Localization::Set("MENU_WAITING_FOR_MORE_PLAYERS_TEAMS", "Waiting for more players to balance teams"); @@ -59,10 +80,6 @@ namespace Components Localization::Set("PLATFORM_REFRESH_LIST", "Refresh List ^0- ^3F5"); Localization::Set("PLATFORM_REFRESH_LIST_CAPS", "REFRESH LIST ^0- ^3F5"); - // Don't perform non-english localization here, do it in fastfiles instead - //Localization::Set("MP_SEARCHING_FOR_PLAYER", "Warte"); - //Localization::Set("MENU_WAITING_FOR_MORE_PLAYERS_TEAMS", "Auf weitere Spieler zum Teamausgleich warten"); - Localization::UseLocalization = Dvar::Register("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings"); } diff --git a/src/Components/Modules/Localization.hpp b/src/Components/Modules/Localization.hpp index 50caaa44..013c62c3 100644 --- a/src/Components/Modules/Localization.hpp +++ b/src/Components/Modules/Localization.hpp @@ -13,5 +13,8 @@ namespace Components private: static std::map LocalizeMap; static Dvar::Var UseLocalization; + + static void __stdcall SetStringStub(const char* key, const char* value, bool isEnglish); + static DWORD SELoadLanguageStub(); }; } diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index b6f7b486..feba05d8 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -76,6 +76,8 @@ namespace Game sendOOB_t OOBPrint = (sendOOB_t)0x4AEF00; sendOOBRaw_t OOBPrintRawData = (sendOOBRaw_t)0x60FDC0; + SE_Load_t SE_Load = (SE_Load_t)0x502A30; + PC_ReadToken_t PC_ReadToken = (PC_ReadToken_t)0x4ACCD0; PC_ReadTokenHandle_t PC_ReadTokenHandle = (PC_ReadTokenHandle_t)0x4D2060; PC_SourceError_t PC_SourceError = (PC_SourceError_t)0x467A00; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 63a53441..6d83c1c3 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -172,6 +172,9 @@ namespace Game typedef void(__cdecl* sendOOBRaw_t)(int, size_t, const char*, int, int, int, int, int); extern sendOOBRaw_t OOBPrintRawData; + typedef char* (__cdecl * SE_Load_t)(char* file, int Unk); + extern SE_Load_t SE_Load; + typedef int(__cdecl * PC_ReadToken_t)(source_t*, token_t*); extern PC_ReadToken_t PC_ReadToken; From 0bbcff083b4c74c383d14c5aa1ddef5c2b012bb6 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 3 Jan 2016 18:07:23 +0100 Subject: [PATCH 5/6] Reduce playlist packet size. TODO: Implement! --- src/Components/Modules/Playlist.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Components/Modules/Playlist.cpp b/src/Components/Modules/Playlist.cpp index 87d6eda6..138dc36a 100644 --- a/src/Components/Modules/Playlist.cpp +++ b/src/Components/Modules/Playlist.cpp @@ -36,11 +36,12 @@ namespace Components Logger::Print("Received playlist request, sending currently stored buffer.\n"); // Split playlist data + int maxPacketSize = 1000; unsigned int maxBytes = Playlist::CurrentPlaylistBuffer.size(); - for (unsigned int i = 0; i < maxBytes; i += 2000) + for (unsigned int i = 0; i < maxBytes; i += maxPacketSize) { - unsigned int sendBytes = min(2000, maxBytes - i); + unsigned int sendBytes = min(maxPacketSize, maxBytes - i); unsigned int sentBytes = i + sendBytes; std::string data; From b514b9fb9d733a584f23a942e4dd0bbe3820b24a Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 3 Jan 2016 19:28:47 +0100 Subject: [PATCH 6/6] Servercount and discovery tests. --- src/Components/Loader.cpp | 1 + src/Components/Loader.hpp | 1 + src/Components/Modules/Discovery.cpp | 24 ++++++++++++++++++ src/Components/Modules/Discovery.hpp | 10 ++++++++ src/Components/Modules/Network.cpp | 36 +++++++++++++++++++++++++-- src/Components/Modules/Network.hpp | 7 ++++++ src/Components/Modules/Party.cpp | 2 ++ src/Components/Modules/Playlist.cpp | 2 +- src/Components/Modules/ServerList.cpp | 3 +++ 9 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 src/Components/Modules/Discovery.cpp create mode 100644 src/Components/Modules/Discovery.hpp diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index 3b7d2c46..65882eea 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -27,6 +27,7 @@ namespace Components Loader::Register(new UIFeeder()); Loader::Register(new UIScript()); Loader::Register(new FastFiles()); + Loader::Register(new Discovery()); Loader::Register(new Materials()); Loader::Register(new FileSystem()); Loader::Register(new QuickPatch()); diff --git a/src/Components/Loader.hpp b/src/Components/Loader.hpp index 6928fd3e..db1292ad 100644 --- a/src/Components/Loader.hpp +++ b/src/Components/Loader.hpp @@ -38,6 +38,7 @@ namespace Components #include "Modules\UIFeeder.hpp" #include "Modules\UIScript.hpp" #include "Modules\Dedicated.hpp" +#include "Modules\Discovery.hpp" #include "Modules\FastFiles.hpp" #include "Modules\Materials.hpp" #include "Modules\Singleton.hpp" diff --git a/src/Components/Modules/Discovery.cpp b/src/Components/Modules/Discovery.cpp new file mode 100644 index 00000000..2b82cd93 --- /dev/null +++ b/src/Components/Modules/Discovery.cpp @@ -0,0 +1,24 @@ +#include "..\..\STDInclude.hpp" +#include + +namespace Components +{ + Discovery::Discovery() + { + Command::Add("bcast", [] (Command::Params params) + { + std::async([]() + { + int start = Game::Com_Milliseconds(); + OutputDebugStringA("Start!"); + Network::BroadcastAll("getinfo xxx\n"); + OutputDebugStringA(Utils::VA("End: %d", Game::Com_Milliseconds() - start)); + }); + }); + } + + Discovery::~Discovery() + { + + } +} diff --git a/src/Components/Modules/Discovery.hpp b/src/Components/Modules/Discovery.hpp new file mode 100644 index 00000000..504b8c9e --- /dev/null +++ b/src/Components/Modules/Discovery.hpp @@ -0,0 +1,10 @@ +namespace Components +{ + class Discovery : public Component + { + public: + Discovery(); + ~Discovery(); + const char* GetName() { return "Discovery"; }; + }; +} diff --git a/src/Components/Modules/Network.cpp b/src/Components/Modules/Network.cpp index 969b6291..8e8565a0 100644 --- a/src/Components/Modules/Network.cpp +++ b/src/Components/Modules/Network.cpp @@ -15,11 +15,11 @@ namespace Components } void Network::Address::SetPort(unsigned short port) { - this->address.port = port; + this->address.port = htons(port); }; unsigned short Network::Address::GetPort() { - return this->address.port; + return ntohs(this->address.port); } void Network::Address::SetIP(DWORD ip) { @@ -29,6 +29,14 @@ namespace Components { return *(DWORD*)this->address.ip; } + void Network::Address::SetType(Game::netadrtype_t type) + { + this->address.type = type; + } + Game::netadrtype_t Network::Address::GetType() + { + return this->address.type; + } Game::netadr_t* Network::Address::Get() { return &this->address; @@ -70,6 +78,30 @@ namespace Components Network::SendRaw(Game::netsrc_t::NS_CLIENT, target, data); } + void Network::Broadcast(unsigned short port, std::string data) + { + Address target; + + target.SetPort(port); + target.SetIP(INADDR_BROADCAST); + target.SetType(Game::netadrtype_t::NA_BROADCAST); + + Network::SendRaw(Game::netsrc_t::NS_CLIENT, target, data); + } + + void Network::BroadcastRange(unsigned int min, unsigned int max, std::string data) + { + for (unsigned int i = min; i < max; i++) + { + Network::Broadcast((unsigned short)(i & 0xFFFF), data); + } + } + + void Network::BroadcastAll(std::string data) + { + Network::BroadcastRange(100, 65536, data); + } + int Network::PacketInterceptionHandler(const char* packet) { // Check if custom handler exists diff --git a/src/Components/Modules/Network.hpp b/src/Components/Modules/Network.hpp index 3a8517f5..9aae8068 100644 --- a/src/Components/Modules/Network.hpp +++ b/src/Components/Modules/Network.hpp @@ -20,6 +20,9 @@ namespace Components void SetIP(DWORD ip); DWORD GetIP(); + void SetType(Game::netadrtype_t type); + Game::netadrtype_t GetType(); + Game::netadr_t* Get(); const char* GetString(); @@ -44,6 +47,10 @@ namespace Components static void SendRaw(Address target, std::string data); static void SendRaw(Game::netsrc_t type, Address target, std::string data); + static void Broadcast(unsigned short port, std::string data); + static void BroadcastRange(unsigned int min, unsigned int max, std::string data); + static void BroadcastAll(std::string data); + private: static std::string SelectedPacket; static std::map PacketHandlers; diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index 74e5fa16..1ea43f1c 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -228,6 +228,7 @@ namespace Components // Basic info handler Network::Handle("getInfo", [] (Network::Address address, std::string data) { + OutputDebugStringA(Utils::VA("Received inforequest from: %s", address.GetString())); int clientCount = 0; int maxclientCount = *Game::svs_numclients; @@ -294,6 +295,7 @@ namespace Components Network::Handle("infoResponse", [] (Network::Address address, std::string data) { + OutputDebugStringA(Utils::VA("Received inforesponse from: %s", address.GetString())); Utils::InfoString info(data); // Handle connection diff --git a/src/Components/Modules/Playlist.cpp b/src/Components/Modules/Playlist.cpp index 138dc36a..32dd57f2 100644 --- a/src/Components/Modules/Playlist.cpp +++ b/src/Components/Modules/Playlist.cpp @@ -36,7 +36,7 @@ namespace Components Logger::Print("Received playlist request, sending currently stored buffer.\n"); // Split playlist data - int maxPacketSize = 1000; + unsigned int maxPacketSize = 1000; unsigned int maxBytes = Playlist::CurrentPlaylistBuffer.size(); for (unsigned int i = 0; i < maxBytes; i += maxPacketSize) diff --git a/src/Components/Modules/ServerList.cpp b/src/Components/Modules/ServerList.cpp index a042c14c..35b05773 100644 --- a/src/Components/Modules/ServerList.cpp +++ b/src/Components/Modules/ServerList.cpp @@ -247,6 +247,7 @@ namespace Components // Display in the menu, like in COD4 //Logger::Print("Sent %d/%d\n", ServerList::RefreshContainer.SentCount, ServerList::RefreshContainer.SendCount); + Localization::Set("MPUI_SERVERQUERIED", Utils::VA("Queried: %d/%d", ServerList::RefreshContainer.SentCount, ServerList::RefreshContainer.SendCount)); if (SendServers <= 0) break; } @@ -259,6 +260,8 @@ namespace Components ServerList::OnlineList.clear(); ServerList::VisibleList.clear(); + Localization::Set("MPUI_SERVERQUERIED", "Queried: 0/0"); + Network::Handle("getServersResponse", [] (Network::Address address, std::string data) { if (ServerList::RefreshContainer.Host != address) return; // Only parse from host we sent to