diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index 012c7008..3aade0dd 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -230,12 +230,10 @@ namespace Components Game::XAssetHeader AssetHandler::FindOriginalAsset(Game::XAssetType type, const char* filename) { - Game::XAssetHeader header = { 0 }; - bool OriginalState = AssetHandler::BypassState; AssetHandler::BypassState = true; - header = Game::DB_FindXAssetHeader(type, filename); + Game::XAssetHeader header = Game::DB_FindXAssetHeader(type, filename); if(!OriginalState) AssetHandler::BypassState = false; return header; diff --git a/src/Components/Modules/ConnectProtocol.cpp b/src/Components/Modules/ConnectProtocol.cpp index 7c41d6f3..088b0775 100644 --- a/src/Components/Modules/ConnectProtocol.cpp +++ b/src/Components/Modules/ConnectProtocol.cpp @@ -28,7 +28,6 @@ namespace Components char ownPth[MAX_PATH] = { 0 }; char workdir[MAX_PATH] = { 0 }; - char regred[MAX_PATH] = { 0 }; DWORD dwsize = MAX_PATH; HMODULE hModule = GetModuleHandle(NULL); @@ -67,6 +66,8 @@ namespace Components LONG openRes = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Classes\\iw4x\\shell\\open\\command", 0, KEY_ALL_ACCESS, &hKey); if (openRes == ERROR_SUCCESS) { + char regred[MAX_PATH] = { 0 }; + // Check if the game has been moved. openRes = RegQueryValueEx(hKey, 0, 0, 0, reinterpret_cast(regred), &dwsize); if (openRes == ERROR_SUCCESS) diff --git a/src/Components/Modules/Maps.cpp b/src/Components/Modules/Maps.cpp index eb3b7ccf..036b9a86 100644 --- a/src/Components/Modules/Maps.cpp +++ b/src/Components/Modules/Maps.cpp @@ -92,7 +92,7 @@ namespace Components { std::regex _(expression); } - catch (std::exception e) + catch (const std::exception e) { MessageBoxA(0, Utils::VA("Invalid regular expression: %s", expression.data()), "Warning", MB_ICONEXCLAMATION); return; diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 9d463dc9..6728b283 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -126,8 +126,6 @@ namespace Components } Game::pc_token_t token; - Game::keywordHash_t *key; - if (!Game::PC_ReadTokenHandle(handle, &token) || token.string[0] != '{') { Utils::Memory::Free(menu->items); @@ -152,7 +150,7 @@ namespace Components int idx = Menus::KeywordHash(token.string); - key = Game::menuParseKeywordHash[idx]; + Game::keywordHash_t* key = Game::menuParseKeywordHash[idx]; if (!key) { @@ -186,9 +184,6 @@ namespace Components if (Menus::IsValidSourceHandle(handle)) { - // Sanitize event name - std::string menuName = menu; - while (true) { ZeroMemory(&token, sizeof(token)); @@ -320,36 +315,32 @@ namespace Components { if (!Menus::IsValidSourceHandle(handle)) return; - Game::script_t *script; - Game::token_t *token; - Game::define_t *define; - Game::indent_t *indent; Game::source_t *source = Game::sourceFiles[handle]; while (source->scriptstack) { - script = source->scriptstack; + Game::script_t* script = source->scriptstack; source->scriptstack = source->scriptstack->next; Game::FreeMemory(script); } while (source->tokens) { - token = source->tokens; + Game::token_t* token = source->tokens; source->tokens = source->tokens->next; Game::FreeMemory(token); } while (source->defines) { - define = source->defines; + Game::define_t* define = source->defines; source->defines = source->defines->next; Game::FreeMemory(define); } while (source->indentstack) { - indent = source->indentstack; + Game::indent_t* indent = source->indentstack; source->indentstack = source->indentstack->next; Utils::Memory::Free(indent); } diff --git a/src/Components/Modules/Network.hpp b/src/Components/Modules/Network.hpp index b3fb7da0..29339df3 100644 --- a/src/Components/Modules/Network.hpp +++ b/src/Components/Modules/Network.hpp @@ -10,7 +10,7 @@ namespace Components Address(std::string addrString); Address(Game::netadr_t addr) : address(addr) {} Address(Game::netadr_t* addr) : Address(*addr) {} - Address(const Address& obj) { this->address = obj.address; }; + Address(const Address& obj) : address(obj.address) {}; bool operator!=(const Address &obj) { return !(*this == obj); }; bool operator==(const Address &obj); diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index f70106ae..41113e41 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -3,7 +3,7 @@ namespace Components { - ZoneBuilder::Zone::Zone(std::string name) : DataMap("zone_source/" + name + ".csv"), ZoneName(name), IndexStart(0), + ZoneBuilder::Zone::Zone(std::string name) : DataMap("zone_source/" + name + ".csv"), ZoneName(name), IndexStart(0), Branding { 0 }, // Reserve 100MB by default. // That's totally fine, as the dedi doesn't load images and therefore doesn't need much memory. @@ -307,9 +307,9 @@ namespace Components void ZoneBuilder::Zone::AddBranding() { char* data = "FastFile built using iw4x IW4 ZoneTool!"; - branding = { ZoneBuilder::Zone::ZoneName.data(), (int)strlen(data), 0, data }; + ZoneBuilder::Zone::Branding = { ZoneBuilder::Zone::ZoneName.data(), (int)strlen(data), 0, data }; - Game::XAssetHeader header = { &branding }; + Game::XAssetHeader header = { &Branding }; Game::XAsset brandingAsset = { Game::XAssetType::ASSET_TYPE_RAWFILE, header }; ZoneBuilder::Zone::LoadedAssets.push_back(brandingAsset); } diff --git a/src/Components/Modules/ZoneBuilder.hpp b/src/Components/Modules/ZoneBuilder.hpp index a78153d1..7d4c6cdf 100644 --- a/src/Components/Modules/ZoneBuilder.hpp +++ b/src/Components/Modules/ZoneBuilder.hpp @@ -65,7 +65,7 @@ namespace Components std::map RenameMap[Game::XAssetType::ASSET_TYPE_COUNT]; std::map PointerMap; - Game::RawFile branding; + Game::RawFile Branding; }; ZoneBuilder(); diff --git a/src/STDInclude.hpp b/src/STDInclude.hpp index 68613666..5b992a16 100644 --- a/src/STDInclude.hpp +++ b/src/STDInclude.hpp @@ -48,7 +48,7 @@ #define ASIO_STANDALONE #include #include -#include +//#include #include #pragma warning(pop) diff --git a/src/Steam/Interfaces/SteamMatchmaking.cpp b/src/Steam/Interfaces/SteamMatchmaking.cpp index b6e250dc..d432ea24 100644 --- a/src/Steam/Interfaces/SteamMatchmaking.cpp +++ b/src/Steam/Interfaces/SteamMatchmaking.cpp @@ -51,7 +51,7 @@ namespace Steam unsigned __int64 Matchmaking::CreateLobby(int eLobbyType, int cMaxMembers) { uint64_t result = Callbacks::RegisterCall(); - LobbyCreated* retvals = new LobbyCreated; + LobbyCreated* retvals = ::Utils::Memory::AllocateArray(); SteamID id; id.AccountID = 1337132; @@ -72,7 +72,7 @@ namespace Steam unsigned __int64 Matchmaking::JoinLobby(SteamID steamIDLobby) { uint64_t result = Callbacks::RegisterCall(); - LobbyEnter* retvals = new LobbyEnter; + LobbyEnter* retvals = ::Utils::Memory::AllocateArray(); retvals->m_bLocked = false; retvals->m_EChatRoomEnterResponse = 1; retvals->m_rgfChatPermissions = 0xFFFFFFFF; diff --git a/src/Steam/Steam.cpp b/src/Steam/Steam.cpp index ae284988..edc52e47 100644 --- a/src/Steam/Steam.cpp +++ b/src/Steam/Steam.cpp @@ -61,7 +61,7 @@ namespace Steam if (result.data) { - delete[] result.data; + ::Utils::Memory::Free(result.data); } } @@ -77,9 +77,9 @@ namespace Steam if (!Overlay) { HKEY hRegKey; - char steamPath[MAX_PATH] = { 0 }; if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &hRegKey) == ERROR_SUCCESS) { + char steamPath[MAX_PATH] = { 0 }; DWORD dwLength = sizeof(steamPath); RegQueryValueExA(hRegKey, "InstallPath", NULL, NULL, reinterpret_cast(steamPath), &dwLength); RegCloseKey(hRegKey); diff --git a/src/Utils/Hooking.hpp b/src/Utils/Hooking.hpp index 5b1533c3..bf5e1d10 100644 --- a/src/Utils/Hooking.hpp +++ b/src/Utils/Hooking.hpp @@ -8,7 +8,7 @@ namespace Utils class Hook { public: - Hook() : Place(nullptr), Stub(nullptr), Initialized(false), Installed(false), UseJump(false), Protection(0) { ZeroMemory(Hook::Buffer, sizeof(Hook::Buffer)); } + Hook() : Place(nullptr), Stub(nullptr), Initialized(false), Installed(false), Original(0), UseJump(false), Protection(0) { ZeroMemory(Hook::Buffer, sizeof(Hook::Buffer)); } Hook(void* place, void* stub, bool useJump = true) : Hook() { Hook::Initialize(place, stub, useJump); } Hook(DWORD place, void* stub, bool useJump = true) : Hook(reinterpret_cast(place), stub, useJump) {} Hook(DWORD place, DWORD stub, bool useJump = true) : Hook(reinterpret_cast(place), reinterpret_cast(stub), useJump) {} diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp index 88e4d421..efef095d 100644 --- a/src/Utils/Utils.hpp +++ b/src/Utils/Utils.hpp @@ -24,8 +24,8 @@ namespace Utils { public: InfoString() {}; - InfoString(std::string buffer) :InfoString() { this->Parse(buffer); }; - InfoString(const InfoString &obj) { this->KeyValuePairs = obj.KeyValuePairs; }; + InfoString(std::string buffer) : InfoString() { this->Parse(buffer); }; + InfoString(const InfoString &obj) : KeyValuePairs(obj.KeyValuePairs) {}; void Set(std::string key, std::string value); std::string Get(std::string key);