From 4cb3e04c88baf12cb10d4073690bbcf6e222657e Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 11 Apr 2016 11:25:08 +0200 Subject: [PATCH] Small optimizations --- deps/protobuf | 2 +- src/Components/Modules/ConnectProtocol.cpp | 2 -- src/Components/Modules/Console.cpp | 4 +--- src/Components/Modules/Discovery.cpp | 2 -- src/Components/Modules/FileSystem.cpp | 2 +- src/Components/Modules/IPCPipe.cpp | 4 +--- src/Components/Modules/Node.cpp | 2 -- src/Components/Modules/Party.cpp | 4 ++-- src/Game/Functions.hpp | 28 +++++++++++----------- src/STDInclude.hpp | 3 +++ 10 files changed, 23 insertions(+), 30 deletions(-) diff --git a/deps/protobuf b/deps/protobuf index 667f4a62..3ffbdd71 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit 667f4a6282f9d7e7edb0acc8758e384b17a0359d +Subproject commit 3ffbdd712f0413ce4964d626c5e10533f1f74893 diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 97e47660..5eddf37e 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -1,7 +1,5 @@ #include "STDInclude.hpp" -using namespace std::literals; - namespace Components { ConnectProtocol::Container ConnectProtocol::ConnectContainer = { false, false, "" }; diff --git a/src/Components/Modules/Console.cpp b/src/Components/Modules/Console.cpp index 06674e69..3bf57cde 100644 --- a/src/Components/Modules/Console.cpp +++ b/src/Components/Modules/Console.cpp @@ -1,7 +1,5 @@ #include "STDInclude.hpp" -using namespace std::literals; - namespace Components { WINDOW* Console::OutputWindow; @@ -322,7 +320,7 @@ namespace Components { while (true) { - Sleep(5000); + std::this_thread::sleep_for(5s); } } diff --git a/src/Components/Modules/Discovery.cpp b/src/Components/Modules/Discovery.cpp index 364ad81f..75937f19 100644 --- a/src/Components/Modules/Discovery.cpp +++ b/src/Components/Modules/Discovery.cpp @@ -1,7 +1,5 @@ #include "STDInclude.hpp" -using namespace std::literals; - namespace Components { Discovery::Container Discovery::DiscoveryContainer = { false, false, nullptr }; diff --git a/src/Components/Modules/FileSystem.cpp b/src/Components/Modules/FileSystem.cpp index 1718a07f..da7d33e9 100644 --- a/src/Components/Modules/FileSystem.cpp +++ b/src/Components/Modules/FileSystem.cpp @@ -93,7 +93,7 @@ namespace Components void FileSystem::DeleteFile(std::string folder, std::string file) { char path[MAX_PATH] = { 0 }; - Game::FS_BuildPathToFile(Dvar::Var("fs_basepath").Get(),reinterpret_cast(0x63D0BB8), Utils::VA("%s/%s", folder.data(), file.data()), reinterpret_cast(&path)); + Game::FS_BuildPathToFile(Dvar::Var("fs_basepath").Get(), reinterpret_cast(0x63D0BB8), Utils::VA("%s/%s", folder.data(), file.data()), reinterpret_cast(&path)); Game::FS_Remove(path); } diff --git a/src/Components/Modules/IPCPipe.cpp b/src/Components/Modules/IPCPipe.cpp index 533ec8c2..2f0ad7b5 100644 --- a/src/Components/Modules/IPCPipe.cpp +++ b/src/Components/Modules/IPCPipe.cpp @@ -1,7 +1,5 @@ #include "STDInclude.hpp" -using namespace std::literals; - namespace Components { Pipe* IPCPipe::ServerPipe = 0; @@ -36,7 +34,7 @@ namespace Components { Logger::Print("Attempting to reconnect to the pipe.\n"); this->ReconnectAttempt++; - Sleep(500); + std::this_thread::sleep_for(500ms); return this->Connect(name); } diff --git a/src/Components/Modules/Node.cpp b/src/Components/Modules/Node.cpp index 5052e920..f3eb0dc5 100644 --- a/src/Components/Modules/Node.cpp +++ b/src/Components/Modules/Node.cpp @@ -1,7 +1,5 @@ #include "STDInclude.hpp" -using namespace std::literals; - namespace Components { Utils::Cryptography::ECDSA::Key Node::SignatureKey; diff --git a/src/Components/Modules/Party.cpp b/src/Components/Modules/Party.cpp index 93ef8c89..df65f424 100644 --- a/src/Components/Modules/Party.cpp +++ b/src/Components/Modules/Party.cpp @@ -373,8 +373,8 @@ namespace Components Game::Menus_CloseAll(Game::uiContext); - char xnaddr[32]; - Game::CL_ConnectFromParty(0, xnaddr, *address.Get(), 0, 0, info.Get("mapname").data(), info.Get("gametype").data()); + Game::_XSESSION_INFO hostInfo; + Game::CL_ConnectFromParty(0, &hostInfo, *address.Get(), 0, 0, info.Get("mapname").data(), info.Get("gametype").data()); } } else diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 5992d9ec..4e5c7d6a 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -15,7 +15,7 @@ namespace Game typedef int(__cdecl * CL_IsCgameInitialized_t)(); extern CL_IsCgameInitialized_t CL_IsCgameInitialized; - typedef void(__cdecl * CL_ConnectFromParty_t)(int controller, void*, netadr_t adr, int, int, const char*, const char*); + typedef void(__cdecl * CL_ConnectFromParty_t)(int controllerIndex, _XSESSION_INFO *hostInfo, netadr_t addr, int numPublicSlots, int numPrivateSlots, const char *mapname, const char *gametype); extern CL_ConnectFromParty_t CL_ConnectFromParty; typedef void(__cdecl * Cmd_AddCommand_t)(const char* name, void(*callback), cmd_function_t* data, char); @@ -24,22 +24,22 @@ namespace Game typedef void(__cdecl * Cmd_AddServerCommand_t)(const char* name, void(*callback), cmd_function_t* data); extern Cmd_AddServerCommand_t Cmd_AddServerCommand; - typedef void(__cdecl * Cmd_ExecuteSingleCommand_t)(int controller, int a2, const char* cmd); + typedef void(__cdecl * Cmd_ExecuteSingleCommand_t)(int localClientNum, int controllerIndex, const char* cmd); extern Cmd_ExecuteSingleCommand_t Cmd_ExecuteSingleCommand; typedef void(__cdecl * Com_Error_t)(int type, char* message, ...); extern Com_Error_t Com_Error; - typedef void(__cdecl * Com_Printf_t)(int, const char*, ...); + typedef void(__cdecl * Com_Printf_t)(int channel, const char *fmt, ...); extern Com_Printf_t Com_Printf; - typedef void(__cdecl * Com_PrintMessage_t)(int, const char*, char); + typedef void(__cdecl * Com_PrintMessage_t)(int channel, const char *msg, int error); extern Com_PrintMessage_t Com_PrintMessage; - typedef int(__cdecl * Com_Milliseconds_t)(void); + typedef int(__cdecl * Com_Milliseconds_t)(); extern Com_Milliseconds_t Com_Milliseconds; - typedef char* (__cdecl * Com_ParseExt_t)(const char**); + typedef char* (__cdecl * Com_ParseExt_t)(const char **data_p); extern Com_ParseExt_t Com_ParseExt; typedef void(__cdecl * DB_EnumXAssets_t)(XAssetType type, void(*)(XAssetHeader, void *), void* userdata, bool overrides); @@ -48,7 +48,7 @@ namespace Game typedef XAssetHeader (__cdecl * DB_FindXAssetHeader_t)(XAssetType type, const char* name); extern DB_FindXAssetHeader_t DB_FindXAssetHeader; - typedef const char* (__cdecl * DB_GetXAssetNameHandler_t)(Game::XAssetHeader* asset); + typedef const char* (__cdecl * DB_GetXAssetNameHandler_t)(XAssetHeader* asset); extern DB_GetXAssetNameHandler_t* DB_GetXAssetNameHandlers; typedef int(__cdecl * DB_GetXAssetSizeHandler_t)(); @@ -148,7 +148,7 @@ namespace Game typedef int(__cdecl * FS_Remove_t)(char *); extern FS_Remove_t FS_Remove; - typedef int(__cdecl * FS_Restart_t)(int a1, int a2); + typedef int(__cdecl * FS_Restart_t)(int localClientNum, int checksumFeed); extern FS_Restart_t FS_Restart; typedef int(__cdecl * FS_BuildPathToFile_t)(const char*, const char*, const char*, char**); @@ -191,7 +191,7 @@ namespace Game typedef __int64(__cdecl * MSG_ReadInt64_t)(msg_t* msg); extern MSG_ReadInt64_t MSG_ReadInt64; - typedef char* (__cdecl * MSG_ReadString_t)(msg_t*); + typedef char* (__cdecl * MSG_ReadString_t)(msg_t* msg); extern MSG_ReadString_t MSG_ReadString; typedef int(__cdecl * MSG_ReadByte_t)(msg_t* msg); @@ -200,10 +200,10 @@ namespace Game typedef void(__cdecl * MSG_WriteByte_t)(msg_t* msg, unsigned char c); extern MSG_WriteByte_t MSG_WriteByte; - typedef void(__cdecl * MSG_WriteData_t)(msg_t* msg, char*, size_t); + typedef void(__cdecl * MSG_WriteData_t)(msg_t *buf, const void *data, int length); extern MSG_WriteData_t MSG_WriteData; - typedef void(__cdecl * MSG_WriteLong_t)(msg_t* msg, int); + typedef void(__cdecl * MSG_WriteLong_t)(msg_t *msg, int c); extern MSG_WriteLong_t MSG_WriteLong; typedef int(__cdecl * MSG_WriteBitsCompress_t)(bool trainHuffman, const char *from, char *to, int size); @@ -212,13 +212,13 @@ namespace Game typedef const char* (__cdecl * NET_AdrToString_t)(netadr_t adr); extern NET_AdrToString_t NET_AdrToString; - typedef bool(__cdecl * NET_CompareAdr_t)(netadr_t, netadr_t); + typedef bool(__cdecl * NET_CompareAdr_t)(netadr_t a, netadr_t b); extern NET_CompareAdr_t NET_CompareAdr; - typedef bool(__cdecl * NET_IsLocalAddress_t)(netadr_t); + typedef bool(__cdecl * NET_IsLocalAddress_t)(netadr_t adr); extern NET_IsLocalAddress_t NET_IsLocalAddress; - typedef bool(__cdecl * NET_StringToAdr_t)(const char*, netadr_t*); + typedef bool(__cdecl * NET_StringToAdr_t)(const char *s, netadr_t *a); extern NET_StringToAdr_t NET_StringToAdr; typedef void(__cdecl* NET_OutOfBandPrint_t)(netsrc_t sock, netadr_t adr, const char *data); diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index f86ae5a3..d9726e0c 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -101,6 +101,9 @@ #pragma comment(lib, "Wininet.lib") #pragma comment(lib, "shlwapi.lib") +// Enable additional literals +using namespace std::literals; + #endif // Revision number