[ISO] Follow the c++20 standard
This commit is contained in:
parent
2f0884bd1c
commit
6c76136c5c
@ -206,7 +206,7 @@ workspace "iw4x"
|
||||
configurations {"Debug", "Release"}
|
||||
|
||||
language "C++"
|
||||
cppdialect "C++17"
|
||||
cppdialect "C++20"
|
||||
|
||||
architecture "x86"
|
||||
platforms "Win32"
|
||||
|
@ -23,7 +23,7 @@ namespace Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (AssetHandler::AssetInterfaces.find(iAsset->getType()) != AssetHandler::AssetInterfaces.end())
|
||||
if (AssetHandler::AssetInterfaces.contains(iAsset->getType()))
|
||||
{
|
||||
Logger::Print("Duplicate asset interface: %s\n", Game::DB_GetXAssetTypeName(iAsset->getType()));
|
||||
delete AssetHandler::AssetInterfaces[iAsset->getType()];
|
||||
@ -58,7 +58,7 @@ namespace Components
|
||||
// Allow call DB_FindXAssetHeader within the hook
|
||||
AssetHandler::SetBypassState(true);
|
||||
|
||||
if (AssetHandler::TypeCallbacks.find(type) != AssetHandler::TypeCallbacks.end())
|
||||
if (AssetHandler::TypeCallbacks.contains(type))
|
||||
{
|
||||
header = AssetHandler::TypeCallbacks[type](type, filename);
|
||||
}
|
||||
@ -329,17 +329,17 @@ namespace Components
|
||||
{
|
||||
void* pointer = (*Game::g_streamBlocks)[offset->getUnpackedBlock()].data + offset->getUnpackedOffset();
|
||||
|
||||
if (AssetHandler::Relocations.find(pointer) != AssetHandler::Relocations.end())
|
||||
if (AssetHandler::Relocations.contains(pointer))
|
||||
{
|
||||
pointer = AssetHandler::Relocations[pointer];
|
||||
}
|
||||
|
||||
offset->pointer = *reinterpret_cast<void**>(pointer);
|
||||
offset->pointer = *static_cast<void**>(pointer);
|
||||
}
|
||||
|
||||
void AssetHandler::ZoneSave(Game::XAsset asset, ZoneBuilder::Zone* builder)
|
||||
{
|
||||
if (AssetHandler::AssetInterfaces.find(asset.type) != AssetHandler::AssetInterfaces.end())
|
||||
if (AssetHandler::AssetInterfaces.contains(asset.type))
|
||||
{
|
||||
AssetHandler::AssetInterfaces[asset.type]->save(asset.header, builder);
|
||||
}
|
||||
@ -351,7 +351,7 @@ namespace Components
|
||||
|
||||
void AssetHandler::ZoneMark(Game::XAsset asset, ZoneBuilder::Zone* builder)
|
||||
{
|
||||
if (AssetHandler::AssetInterfaces.find(asset.type) != AssetHandler::AssetInterfaces.end())
|
||||
if (AssetHandler::AssetInterfaces.contains(asset.type))
|
||||
{
|
||||
AssetHandler::AssetInterfaces[asset.type]->mark(asset.header, builder);
|
||||
}
|
||||
@ -375,7 +375,7 @@ namespace Components
|
||||
return { entry->second };
|
||||
}
|
||||
|
||||
if (AssetHandler::AssetInterfaces.find(type) != AssetHandler::AssetInterfaces.end())
|
||||
if (AssetHandler::AssetInterfaces.contains(type))
|
||||
{
|
||||
AssetHandler::AssetInterfaces[type]->load(&header, filename, builder);
|
||||
|
||||
|
@ -243,7 +243,8 @@ namespace Assets
|
||||
{
|
||||
Components::Logger::Print("No replacement found for material %s with techset %s\n", asset->info.name, asset->techniqueSet->name);
|
||||
std::string techName = asset->techniqueSet->name;
|
||||
if (techSetCorrespondance.find(techName) != techSetCorrespondance.end()) {
|
||||
if (techSetCorrespondance.contains(techName))
|
||||
{
|
||||
auto iw4TechSetName = techSetCorrespondance[techName];
|
||||
Game::XAssetEntry* iw4TechSet = Game::DB_FindXAssetEntry(Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET, iw4TechSetName.data());
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace Components
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lock(Chat::AccessMutex);
|
||||
if (Chat::MuteList.find(Game::svs_clients[player->s.number].steamID) != Chat::MuteList.end())
|
||||
if (Chat::MuteList.contains(Game::svs_clients[player->s.number].steamID))
|
||||
{
|
||||
lock.unlock();
|
||||
Chat::SendChat = false;
|
||||
@ -217,7 +217,7 @@ namespace Components
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(Chat::AccessMutex);
|
||||
|
||||
if (Chat::MuteList.find(client->steamID) == Chat::MuteList.end())
|
||||
if (!Chat::MuteList.contains(client->steamID))
|
||||
{
|
||||
Chat::MuteList.insert(client->steamID);
|
||||
lock.unlock();
|
||||
|
@ -64,7 +64,7 @@ namespace Components
|
||||
{
|
||||
const auto command = Utils::String::ToLower(name);
|
||||
|
||||
if (Command::FunctionMap.find(command) == Command::FunctionMap.end())
|
||||
if (!Command::FunctionMap.contains(command))
|
||||
{
|
||||
Command::AddRaw(name, Command::MainCallback);
|
||||
}
|
||||
@ -87,7 +87,7 @@ namespace Components
|
||||
|
||||
const auto command = Utils::String::ToLower(name);
|
||||
|
||||
if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end())
|
||||
if (!Command::FunctionMapSV.contains(command))
|
||||
{
|
||||
Command::AddRawSV(name, Command::MainCallbackSV);
|
||||
|
||||
|
@ -190,10 +190,10 @@ namespace Components
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _(Friends::Mutex);
|
||||
|
||||
const unsigned int modId = *reinterpret_cast<unsigned int*>("IW4x") | 0x80000000;
|
||||
const auto modId = *reinterpret_cast<const unsigned int*>("IW4x") | 0x80000000;
|
||||
|
||||
// Split up the list
|
||||
for (auto entry : Friends::FriendsList)
|
||||
for (const auto& entry : Friends::FriendsList)
|
||||
{
|
||||
Steam::FriendGameInfo info;
|
||||
if (Steam::Proxy::SteamFriends->GetFriendGamePlayed(entry.userId, &info) && info.m_gameID.modID == modId)
|
||||
|
@ -161,7 +161,7 @@ namespace Components
|
||||
|
||||
if (bResult && cbBytes)
|
||||
{
|
||||
if (pipe->packetCallbacks.find(pipe->packet.command) != pipe->packetCallbacks.end())
|
||||
if (pipe->packetCallbacks.contains(pipe->packet.command))
|
||||
{
|
||||
pipe->packetCallbacks[pipe->packet.command](pipe->packet.buffer);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ namespace Components
|
||||
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
|
||||
Utils::Memory::Allocator* allocator = Utils::Memory::GetAllocator();
|
||||
|
||||
if (Localization::LocalizeMap.find(key) != Localization::LocalizeMap.end())
|
||||
if (Localization::LocalizeMap.contains(key))
|
||||
{
|
||||
Game::LocalizeEntry* entry = Localization::LocalizeMap[key];
|
||||
|
||||
@ -52,11 +52,11 @@ namespace Components
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
|
||||
|
||||
if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end())
|
||||
if (Localization::TempLocalizeMap.contains(key))
|
||||
{
|
||||
entry = Localization::TempLocalizeMap[key];
|
||||
}
|
||||
else if (Localization::LocalizeMap.find(key) != Localization::LocalizeMap.end())
|
||||
else if (Localization::LocalizeMap.contains(key))
|
||||
{
|
||||
entry = Localization::LocalizeMap[key];
|
||||
}
|
||||
@ -80,7 +80,7 @@ namespace Components
|
||||
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
|
||||
Utils::Memory::Allocator* allocator = Utils::Memory::GetAllocator();
|
||||
|
||||
if (Localization::TempLocalizeMap.find(key) != Localization::TempLocalizeMap.end())
|
||||
if (Localization::TempLocalizeMap.contains(key))
|
||||
{
|
||||
Game::LocalizeEntry* entry = Localization::TempLocalizeMap[key];
|
||||
if (entry->value) allocator->free(entry->value);
|
||||
@ -256,11 +256,11 @@ namespace Components
|
||||
Game::XAssetHeader header = { nullptr };
|
||||
std::lock_guard<std::recursive_mutex> _(Localization::LocalizeMutex);
|
||||
|
||||
if (Localization::TempLocalizeMap.find(filename) != Localization::TempLocalizeMap.end())
|
||||
if (Localization::TempLocalizeMap.contains(filename))
|
||||
{
|
||||
header.localize = Localization::TempLocalizeMap[filename];
|
||||
}
|
||||
else if (Localization::LocalizeMap.find(filename) != Localization::LocalizeMap.end())
|
||||
else if (Localization::LocalizeMap.contains(filename))
|
||||
{
|
||||
header.localize = Localization::LocalizeMap[filename];
|
||||
}
|
||||
|
@ -920,7 +920,7 @@ namespace Components
|
||||
{
|
||||
std::string name = gameWorld->dpvs.smodelDrawInsts[i].model->name;
|
||||
|
||||
if (models.find(name) == models.end()) models[name] = 1;
|
||||
if (!models.contains(name)) models[name] = 1;
|
||||
else models[name]++;
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ namespace Components
|
||||
Game::XSurface* tempSurfaces = allocator.allocateArray<Game::XSurface>(modelSurfs->numsurfs);
|
||||
char* surfaceData = reinterpret_cast<char*>(modelSurfs->surfs);
|
||||
|
||||
if (ModelSurfs::AllocMap.find(modelSurfs->name) != ModelSurfs::AllocMap.end())
|
||||
if (ModelSurfs::AllocMap.contains(modelSurfs->name))
|
||||
{
|
||||
Game::CModelAllocData* allocData = ModelSurfs::AllocMap[modelSurfs->name];
|
||||
|
||||
@ -210,7 +210,7 @@ namespace Components
|
||||
|
||||
if (hasCustomSurface && !ModelSurfs::AllocMap.empty())
|
||||
{
|
||||
auto allocData = ModelSurfs::AllocMap.find(header.modelSurfs->name);
|
||||
const auto allocData = ModelSurfs::AllocMap.find(header.modelSurfs->name);
|
||||
if (allocData != ModelSurfs::AllocMap.end())
|
||||
{
|
||||
Utils::Memory::FreeAlign(allocData->second->indexBuffer);
|
||||
|
@ -39,7 +39,7 @@ namespace Components
|
||||
|
||||
const char* Party::GetLobbyInfo(SteamID lobby, const std::string& key)
|
||||
{
|
||||
if (Party::LobbyMap.find(lobby.bits) != Party::LobbyMap.end())
|
||||
if (Party::LobbyMap.contains(lobby.bits))
|
||||
{
|
||||
Network::Address address = Party::LobbyMap[lobby.bits];
|
||||
|
||||
@ -58,9 +58,10 @@ namespace Components
|
||||
|
||||
void Party::RemoveLobby(SteamID lobby)
|
||||
{
|
||||
if (Party::LobbyMap.find(lobby.bits) != Party::LobbyMap.end())
|
||||
const auto got = Party::LobbyMap.find(lobby.bits);
|
||||
if (got != Party::LobbyMap.end())
|
||||
{
|
||||
Party::LobbyMap.erase(Party::LobbyMap.find(lobby.bits));
|
||||
Party::LobbyMap.erase(got);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ namespace Components
|
||||
|
||||
void Script::GetReplacedPos(const char* pos)
|
||||
{
|
||||
if (Script::ReplacedFunctions.find(pos) != Script::ReplacedFunctions.end())
|
||||
if (Script::ReplacedFunctions.contains(pos))
|
||||
{
|
||||
Script::ReplacedPos = Script::ReplacedFunctions[pos];
|
||||
}
|
||||
@ -475,7 +475,7 @@ namespace Components
|
||||
return;
|
||||
}
|
||||
|
||||
if (Script::ReplacedFunctions.find(what) != Script::ReplacedFunctions.end())
|
||||
if (Script::ReplacedFunctions.contains(what))
|
||||
{
|
||||
Logger::Print("Warning: ReplacedFunctions already contains codePosValue for a function\n");
|
||||
}
|
||||
@ -667,7 +667,7 @@ namespace Components
|
||||
return;
|
||||
}
|
||||
|
||||
Game::Scr_AddBool(static_cast<int>(Script::ScriptStorage.count(key))); // Until C++17
|
||||
Game::Scr_AddInt(static_cast<int>(Script::ScriptStorage.count(key)));
|
||||
});
|
||||
|
||||
Script::AddFunction("StorageClear", [] // gsc: StorageClear();
|
||||
|
@ -64,7 +64,7 @@ namespace Components
|
||||
|
||||
std::string filename = Utils::String::ToLower(_filename);
|
||||
|
||||
if (StringTable::StringTableMap.find(filename) != StringTable::StringTableMap.end())
|
||||
if (StringTable::StringTableMap.contains(filename))
|
||||
{
|
||||
header.stringTable = StringTable::StringTableMap[filename];
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ namespace Components
|
||||
// No need to patch version 155
|
||||
if (newData[i].version == 155) continue;
|
||||
|
||||
if (patchDefinitions.find(newData[i].version) != patchDefinitions.end())
|
||||
if (patchDefinitions.contains(newData[i].version))
|
||||
{
|
||||
auto patchData = patchDefinitions[newData[i].version];
|
||||
auto otherData = otherPatchDefinitions[newData[i].version];
|
||||
|
@ -12,7 +12,7 @@ namespace Components
|
||||
|
||||
const char* UIFeeder::GetItemText()
|
||||
{
|
||||
if (UIFeeder::Feeders.find(UIFeeder::Current.feeder) != UIFeeder::Feeders.end())
|
||||
if (UIFeeder::Feeders.contains(UIFeeder::Current.feeder))
|
||||
{
|
||||
return UIFeeder::Feeders[UIFeeder::Current.feeder].getItemText(UIFeeder::Current.index, UIFeeder::Current.column);
|
||||
}
|
||||
@ -22,7 +22,7 @@ namespace Components
|
||||
|
||||
unsigned int UIFeeder::GetItemCount()
|
||||
{
|
||||
if (UIFeeder::Feeders.find(UIFeeder::Current.feeder) != UIFeeder::Feeders.end())
|
||||
if (UIFeeder::Feeders.contains(UIFeeder::Current.feeder))
|
||||
{
|
||||
return UIFeeder::Feeders[UIFeeder::Current.feeder].getItemCount();
|
||||
}
|
||||
@ -313,7 +313,7 @@ namespace Components
|
||||
|
||||
void UIFeeder::ApplyMap(UIScript::Token)
|
||||
{
|
||||
std::string mapname = Dvar::Var("ui_map_name").get<std::string>();
|
||||
const auto mapname = Dvar::Var("ui_map_name").get<std::string>();
|
||||
|
||||
Dvar::Var("ui_mapname").set(mapname);
|
||||
Utils::Hook::Call<void(const char*)>(0x503B50)(mapname.data()); // Party_SetDisplayMapName
|
||||
@ -321,7 +321,7 @@ namespace Components
|
||||
|
||||
void UIFeeder::ApplyInitialMap(UIScript::Token)
|
||||
{
|
||||
std::string mapname = Dvar::Var("ui_mapname").get<std::string>();
|
||||
const auto mapname = Dvar::Var("ui_mapname").get<std::string>();
|
||||
|
||||
Game::UI_UpdateArenas();
|
||||
Game::UI_SortArenas();
|
||||
|
@ -55,7 +55,7 @@ namespace Components
|
||||
|
||||
bool UIScript::RunMenuScript(const char* name, const char** args)
|
||||
{
|
||||
if (UIScript::UIScripts.find(name) != UIScript::UIScripts.end())
|
||||
if (UIScript::UIScripts.contains(name))
|
||||
{
|
||||
UIScript::UIScripts[name](UIScript::Token(args));
|
||||
return true;
|
||||
|
@ -530,7 +530,7 @@ namespace Components
|
||||
// Check if the given pointer has already been mapped
|
||||
bool ZoneBuilder::Zone::hasPointer(const void* pointer)
|
||||
{
|
||||
return (this->pointerMap.find(pointer) != this->pointerMap.end());
|
||||
return this->pointerMap.contains(pointer);
|
||||
}
|
||||
|
||||
// Get stored offset for given file pointer
|
||||
@ -644,7 +644,7 @@ namespace Components
|
||||
{
|
||||
if (type < Game::XAssetType::ASSET_TYPE_COUNT && type >= 0)
|
||||
{
|
||||
if (this->renameMap[type].find(asset) != this->renameMap[type].end())
|
||||
if (this->renameMap[type].contains(asset))
|
||||
{
|
||||
return this->renameMap[type][asset];
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ namespace Steam
|
||||
|
||||
std::pair<void*, uint16_t> Interface::getMethod(const std::string& method)
|
||||
{
|
||||
if(this->methodCache.find(method) != this->methodCache.end())
|
||||
if(this->methodCache.contains(method))
|
||||
{
|
||||
return this->methodCache[method];
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ namespace Steam
|
||||
|
||||
for (auto result : results)
|
||||
{
|
||||
if (Callbacks::ResultHandlers.find(result.call) != Callbacks::ResultHandlers.end())
|
||||
if (Callbacks::ResultHandlers.contains(result.call))
|
||||
{
|
||||
Callbacks::ResultHandlers[result.call]->Run(result.data, false, result.call);
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace Utils
|
||||
{
|
||||
for (auto& entity : this->entities)
|
||||
{
|
||||
if (entity.find("classname") != entity.end())
|
||||
if (entity.contains("classname"))
|
||||
{
|
||||
if (entity["classname"] == "misc_turret"s)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ namespace Utils
|
||||
|
||||
bool isPointerMapped(void* ptr)
|
||||
{
|
||||
return this->ptrMap.find(ptr) != this->ptrMap.end();
|
||||
return this->ptrMap.contains(ptr);
|
||||
}
|
||||
|
||||
template <typename T> T* getPointer(void* oldPtr)
|
||||
|
Loading…
Reference in New Issue
Block a user