summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2026-01-24 15:36:29 -0500
committerGitHub <noreply@github.com>2026-01-24 15:36:29 -0500
commit533fd18d8a88ecc8c8956cc53ca2bab8a771412e (patch)
tree0e5e4bc5860ef332830331333bd8957f270ead21 /Source
parent38566eb1d36c850dd3f26061751b1b43e42a42c0 (diff)
parentb135537d65bca9ec7ad419e2c8be64a0b4bcee2a (diff)
Merge pull request #14303 from Sintendo/game-ini
Core: Pass game ID as string_view
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/AchievementManager.cpp28
-rw-r--r--Source/Core/Core/AchievementManager.h39
-rw-r--r--Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp18
-rw-r--r--Source/Core/Core/ConfigLoaders/GameConfigLoader.h4
-rw-r--r--Source/Core/Core/ConfigManager.cpp13
-rw-r--r--Source/Core/Core/ConfigManager.h11
-rw-r--r--Source/Core/Core/NetPlayServer.cpp8
-rw-r--r--Source/Core/Core/NetPlayServer.h5
8 files changed, 48 insertions, 78 deletions
diff --git a/Source/Core/Core/AchievementManager.cpp b/Source/Core/Core/AchievementManager.cpp
index 1062a02140..57530ec900 100644
--- a/Source/Core/Core/AchievementManager.cpp
+++ b/Source/Core/Core/AchievementManager.cpp
@@ -12,13 +12,13 @@
#include <rcheevos/include/rc_api_info.h>
-#include "Common/Assert.h"
#include "Common/BitUtils.h"
#include "Common/CommonPaths.h"
#include "Common/Config/Config.h"
#include "Common/FileUtil.h"
+#include "Common/HttpRequest.h"
#include "Common/IOFile.h"
-#include "Common/Image.h"
+#include "Common/JsonUtil.h"
#include "Common/Logging/Log.h"
#include "Common/ScopeGuard.h"
#include "Common/StringUtil.h"
@@ -33,7 +33,6 @@
#include "Core/GeckoCode.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/VideoInterface.h"
-#include "Core/Host.h"
#include "Core/PatchEngine.h"
#include "Core/PowerPC/MMU.h"
#include "Core/System.h"
@@ -414,7 +413,7 @@ bool AchievementManager::IsHardcoreModeActive() const
}
template <typename T>
-void AchievementManager::FilterApprovedIni(std::vector<T>& codes, const std::string& game_id,
+void AchievementManager::FilterApprovedIni(std::vector<T>& codes, std::string_view game_id,
u16 revision) const
{
if (codes.empty())
@@ -443,7 +442,7 @@ void AchievementManager::FilterApprovedIni(std::vector<T>& codes, const std::str
}
template <typename T>
-bool AchievementManager::ShouldCodeBeActivated(const T& code, const std::string& game_id,
+bool AchievementManager::ShouldCodeBeActivated(const T& code, std::string_view game_id,
u16 revision) const
{
if (!code.enabled)
@@ -470,8 +469,7 @@ bool AchievementManager::ShouldCodeBeActivated(const T& code, const std::string&
}
template <typename T>
-bool AchievementManager::IsApprovedCode(const T& code, const std::string& game_id,
- u16 revision) const
+bool AchievementManager::IsApprovedCode(const T& code, std::string_view game_id, u16 revision) const
{
// Approved codes list failed to hash
if (!m_ini_root->is<picojson::value::object>())
@@ -536,42 +534,42 @@ Common::SHA1::Digest AchievementManager::GetCodeHash(const ActionReplay::ARCode&
}
void AchievementManager::FilterApprovedPatches(std::vector<PatchEngine::Patch>& patches,
- const std::string& game_id, u16 revision) const
+ std::string_view game_id, u16 revision) const
{
FilterApprovedIni(patches, game_id, revision);
}
void AchievementManager::FilterApprovedGeckoCodes(std::vector<Gecko::GeckoCode>& codes,
- const std::string& game_id, u16 revision) const
+ std::string_view game_id, u16 revision) const
{
FilterApprovedIni(codes, game_id, revision);
}
void AchievementManager::FilterApprovedARCodes(std::vector<ActionReplay::ARCode>& codes,
- const std::string& game_id, u16 revision) const
+ std::string_view game_id, u16 revision) const
{
FilterApprovedIni(codes, game_id, revision);
}
bool AchievementManager::ShouldGeckoCodeBeActivated(const Gecko::GeckoCode& code,
- const std::string& game_id, u16 revision) const
+ std::string_view game_id, u16 revision) const
{
return ShouldCodeBeActivated(code, game_id, revision);
}
bool AchievementManager::ShouldARCodeBeActivated(const ActionReplay::ARCode& code,
- const std::string& game_id, u16 revision) const
+ std::string_view game_id, u16 revision) const
{
return ShouldCodeBeActivated(code, game_id, revision);
}
-bool AchievementManager::IsApprovedGeckoCode(const Gecko::GeckoCode& code,
- const std::string& game_id, u16 revision) const
+bool AchievementManager::IsApprovedGeckoCode(const Gecko::GeckoCode& code, std::string_view game_id,
+ u16 revision) const
{
return IsApprovedCode(code, game_id, revision);
}
bool AchievementManager::IsApprovedARCode(const ActionReplay::ARCode& code,
- const std::string& game_id, u16 revision) const
+ std::string_view game_id, u16 revision) const
{
return IsApprovedCode(code, game_id, revision);
}
diff --git a/Source/Core/Core/AchievementManager.h b/Source/Core/Core/AchievementManager.h
index 337f12fd08..b616dded44 100644
--- a/Source/Core/Core/AchievementManager.h
+++ b/Source/Core/Core/AchievementManager.h
@@ -9,17 +9,17 @@
#include <chrono>
#include <ctime>
#include <functional>
-#include <map>
#include <memory>
#include <mutex>
#include <set>
#include <string>
#include <string_view>
-#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <vector>
+#include <picojson.h>
+
#include <rcheevos/include/rc_api_runtime.h>
#include <rcheevos/include/rc_api_user.h>
#include <rcheevos/include/rc_client.h>
@@ -28,10 +28,7 @@
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
-#include "Common/Event.h"
#include "Common/HookableEvent.h"
-#include "Common/HttpRequest.h"
-#include "Common/JsonUtil.h"
#include "Common/Lazy.h"
#include "Common/WorkQueueThread.h"
#include "DiscIO/Volume.h"
@@ -43,7 +40,6 @@
namespace Core
{
-class CPUThreadGuard;
class System;
} // namespace Core
@@ -77,9 +73,6 @@ public:
using RichPresence = std::array<char, RP_SIZE>;
using Badge = VideoCommon::CustomTextureData::ArraySlice::Level;
static constexpr size_t MAX_DISPLAYED_LBOARDS = 4;
- // This is hardcoded to 24MiB because rcheevos currently hardcodes it to 24MiB.
- static constexpr u32 MEM1_SIZE = 0x01800000;
- static constexpr u32 MEM2_START = 0x10000000;
static constexpr std::string_view DEFAULT_PLAYER_BADGE_FILENAME = "achievements_player.png";
static constexpr std::string_view DEFAULT_GAME_BADGE_FILENAME = "achievements_game.png";
@@ -144,19 +137,19 @@ public:
std::recursive_mutex& GetLock();
bool IsHardcoreModeActive() const;
- void FilterApprovedPatches(std::vector<PatchEngine::Patch>& patches, const std::string& game_id,
+ void FilterApprovedPatches(std::vector<PatchEngine::Patch>& patches, std::string_view game_id,
u16 revision) const;
- void FilterApprovedGeckoCodes(std::vector<Gecko::GeckoCode>& codes, const std::string& game_id,
+ void FilterApprovedGeckoCodes(std::vector<Gecko::GeckoCode>& codes, std::string_view game_id,
u16 revision) const;
- void FilterApprovedARCodes(std::vector<ActionReplay::ARCode>& codes, const std::string& game_id,
+ void FilterApprovedARCodes(std::vector<ActionReplay::ARCode>& codes, std::string_view game_id,
u16 revision) const;
- bool ShouldGeckoCodeBeActivated(const Gecko::GeckoCode& code, const std::string& game_id,
+ bool ShouldGeckoCodeBeActivated(const Gecko::GeckoCode& code, std::string_view game_id,
u16 revision) const;
- bool ShouldARCodeBeActivated(const ActionReplay::ARCode& code, const std::string& game_id,
+ bool ShouldARCodeBeActivated(const ActionReplay::ARCode& code, std::string_view game_id,
u16 revision) const;
- bool IsApprovedGeckoCode(const Gecko::GeckoCode& code, const std::string& game_id,
+ bool IsApprovedGeckoCode(const Gecko::GeckoCode& code, std::string_view game_id,
u16 revision) const;
- bool IsApprovedARCode(const ActionReplay::ARCode& code, const std::string& game_id,
+ bool IsApprovedARCode(const ActionReplay::ARCode& code, std::string_view game_id,
u16 revision) const;
void SetSpectatorMode();
@@ -223,11 +216,11 @@ private:
void SetHardcoreMode();
template <typename T>
- void FilterApprovedIni(std::vector<T>& codes, const std::string& game_id, u16 revision) const;
+ void FilterApprovedIni(std::vector<T>& codes, std::string_view game_id, u16 revision) const;
template <typename T>
- bool ShouldCodeBeActivated(const T& code, const std::string& game_id, u16 revision) const;
+ bool ShouldCodeBeActivated(const T& code, std::string_view game_id, u16 revision) const;
template <typename T>
- bool IsApprovedCode(const T& code, const std::string& game_id, u16 revision) const;
+ bool IsApprovedCode(const T& code, std::string_view game_id, u16 revision) const;
Common::SHA1::Digest GetCodeHash(const PatchEngine::Patch& patch) const;
Common::SHA1::Digest GetCodeHash(const Gecko::GeckoCode& code) const;
Common::SHA1::Digest GetCodeHash(const ActionReplay::ARCode& code) const;
@@ -326,14 +319,14 @@ public:
constexpr bool IsHardcoreModeActive() { return false; }
- constexpr bool ShouldGeckoCodeBeActivated(const Gecko::GeckoCode& code,
- const std::string& game_id, u16 revision)
+ constexpr bool ShouldGeckoCodeBeActivated(const Gecko::GeckoCode& code, std::string_view game_id,
+ u16 revision)
{
return code.enabled;
}
- constexpr bool ShouldARCodeBeActivated(const ActionReplay::ARCode& code,
- const std::string& game_id, u16 revision)
+ constexpr bool ShouldARCodeBeActivated(const ActionReplay::ARCode& code, std::string_view game_id,
+ u16 revision)
{
return code.enabled;
}
diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp
index a922a9ec38..d086d4d9db 100644
--- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp
+++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.cpp
@@ -3,13 +3,12 @@
#include "Core/ConfigLoaders/GameConfigLoader.h"
-#include <algorithm>
#include <array>
-#include <list>
#include <map>
#include <optional>
#include <sstream>
#include <string>
+#include <string_view>
#include <tuple>
#include <utility>
#include <vector>
@@ -22,7 +21,6 @@
#include "Common/IniFile.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
-#include "Common/StringUtil.h"
#include "Core/Config/MainSettings.h"
#include "Core/Config/SYSCONFSettings.h"
@@ -32,7 +30,7 @@
namespace ConfigLoaders
{
// Returns all possible filenames in ascending order of priority
-std::vector<std::string> GetGameIniFilenames(const std::string& id, std::optional<u16> revision)
+std::vector<std::string> GetGameIniFilenames(std::string_view id, std::optional<u16> revision)
{
std::vector<std::string> filenames;
@@ -44,18 +42,18 @@ std::vector<std::string> GetGameIniFilenames(const std::string& id, std::optiona
if (id.length() == 6)
{
// INIs that match the system code (unique for each Virtual Console system)
- filenames.push_back(id.substr(0, 1) + ".ini");
+ filenames.push_back(fmt::format("{}.ini", id.substr(0, 1)));
// INIs that match all regions
- filenames.push_back(id.substr(0, 3) + ".ini");
+ filenames.push_back(fmt::format("{}.ini", id.substr(0, 3)));
}
// Regular INIs
- filenames.push_back(id + ".ini");
+ filenames.push_back(fmt::format("{}.ini", id));
// INIs with specific revisions
if (revision)
- filenames.push_back(id + fmt::format("r{}", *revision) + ".ini");
+ filenames.push_back(fmt::format("{}r{}.ini", id, *revision));
return filenames;
}
@@ -313,7 +311,7 @@ void INIGameConfigLayerLoader::Save(Config::Layer* layer)
// Try to save to the revision specific INI first, if it exists.
const std::string gameini_with_rev =
- File::GetUserPath(D_GAMESETTINGS_IDX) + m_id + fmt::format("r{}", m_revision) + ".ini";
+ fmt::format("{}{}r{}.ini", File::GetUserPath(D_GAMESETTINGS_IDX), m_id, m_revision);
if (File::Exists(gameini_with_rev))
{
ini.Save(gameini_with_rev);
@@ -322,7 +320,7 @@ void INIGameConfigLayerLoader::Save(Config::Layer* layer)
// Otherwise, save to the game INI. We don't try any INI broader than that because it will
// likely cause issues with cheat codes and game patches.
- const std::string gameini = File::GetUserPath(D_GAMESETTINGS_IDX) + m_id + ".ini";
+ const std::string gameini = fmt::format("{}{}.ini", File::GetUserPath(D_GAMESETTINGS_IDX), m_id);
ini.Save(gameini);
}
diff --git a/Source/Core/Core/ConfigLoaders/GameConfigLoader.h b/Source/Core/Core/ConfigLoaders/GameConfigLoader.h
index 78f849b4fe..b907fe2836 100644
--- a/Source/Core/Core/ConfigLoaders/GameConfigLoader.h
+++ b/Source/Core/Core/ConfigLoaders/GameConfigLoader.h
@@ -3,10 +3,10 @@
#pragma once
-#include <cstring>
#include <memory>
#include <optional>
#include <string>
+#include <string_view>
#include <vector>
#include "Common/CommonTypes.h"
@@ -18,7 +18,7 @@ class ConfigLayerLoader;
namespace ConfigLoaders
{
-std::vector<std::string> GetGameIniFilenames(const std::string& id, std::optional<u16> revision);
+std::vector<std::string> GetGameIniFilenames(std::string_view id, std::optional<u16> revision);
std::unique_ptr<Config::ConfigLayerLoader> GenerateGlobalGameConfigLoader(const std::string& id,
u16 revision);
diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp
index b2e682c42f..4268b41481 100644
--- a/Source/Core/Core/ConfigManager.cpp
+++ b/Source/Core/Core/ConfigManager.cpp
@@ -4,11 +4,9 @@
#include "Core/ConfigManager.h"
#include <algorithm>
-#include <climits>
#include <memory>
#include <mutex>
#include <optional>
-#include <sstream>
#include <string>
#include <string_view>
#include <variant>
@@ -19,7 +17,6 @@
#include "AudioCommon/AudioCommon.h"
-#include "Common/Assert.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
@@ -27,13 +24,10 @@
#include "Common/IniFile.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
-#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
-#include "Common/Version.h"
#include "Core/AchievementManager.h"
#include "Core/Boot/Boot.h"
-#include "Core/CommonTitles.h"
#include "Core/Config/DefaultLocale.h"
#include "Core/Config/MainSettings.h"
#include "Core/Config/SYSCONFSettings.h"
@@ -54,7 +48,6 @@
#include "Core/IOS/ES/Formats.h"
#include "Core/PatchEngine.h"
#include "Core/PowerPC/PPCSymbolDB.h"
-#include "Core/PowerPC/PowerPC.h"
#include "Core/System.h"
#include "Core/TitleDatabase.h"
#include "Core/WC24PatchEngine.h"
@@ -536,7 +529,7 @@ Common::IniFile SConfig::LoadGameIni() const
return LoadGameIni(GetGameID(), m_revision);
}
-Common::IniFile SConfig::LoadDefaultGameIni(const std::string& id, std::optional<u16> revision)
+Common::IniFile SConfig::LoadDefaultGameIni(std::string_view id, std::optional<u16> revision)
{
Common::IniFile game_ini;
for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision))
@@ -544,7 +537,7 @@ Common::IniFile SConfig::LoadDefaultGameIni(const std::string& id, std::optional
return game_ini;
}
-Common::IniFile SConfig::LoadLocalGameIni(const std::string& id, std::optional<u16> revision)
+Common::IniFile SConfig::LoadLocalGameIni(std::string_view id, std::optional<u16> revision)
{
Common::IniFile game_ini;
for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision))
@@ -552,7 +545,7 @@ Common::IniFile SConfig::LoadLocalGameIni(const std::string& id, std::optional<u
return game_ini;
}
-Common::IniFile SConfig::LoadGameIni(const std::string& id, std::optional<u16> revision)
+Common::IniFile SConfig::LoadGameIni(std::string_view id, std::optional<u16> revision)
{
Common::IniFile game_ini;
for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(id, revision))
diff --git a/Source/Core/Core/ConfigManager.h b/Source/Core/Core/ConfigManager.h
index 4cb78d88b8..b2e27892b9 100644
--- a/Source/Core/Core/ConfigManager.h
+++ b/Source/Core/Core/ConfigManager.h
@@ -3,16 +3,11 @@
#pragma once
-#include <limits>
#include <mutex>
#include <optional>
-#include <set>
#include <string>
#include <string_view>
-#include <utility>
-#include <vector>
-#include "Common/Common.h"
#include "Common/CommonTypes.h"
namespace Common
@@ -97,9 +92,9 @@ struct SConfig
Common::IniFile LoadLocalGameIni() const;
Common::IniFile LoadGameIni() const;
- static Common::IniFile LoadDefaultGameIni(const std::string& id, std::optional<u16> revision);
- static Common::IniFile LoadLocalGameIni(const std::string& id, std::optional<u16> revision);
- static Common::IniFile LoadGameIni(const std::string& id, std::optional<u16> revision);
+ static Common::IniFile LoadDefaultGameIni(std::string_view id, std::optional<u16> revision);
+ static Common::IniFile LoadLocalGameIni(std::string_view id, std::optional<u16> revision);
+ static Common::IniFile LoadGameIni(std::string_view id, std::optional<u16> revision);
SConfig(const SConfig&) = delete;
SConfig& operator=(const SConfig&) = delete;
diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp
index 9f432486e2..006f699c08 100644
--- a/Source/Core/Core/NetPlayServer.cpp
+++ b/Source/Core/Core/NetPlayServer.cpp
@@ -12,8 +12,8 @@
#include <optional>
#include <ranges>
#include <string>
+#include <string_view>
#include <thread>
-#include <type_traits>
#include <unordered_set>
#include <utility>
#include <vector>
@@ -51,13 +51,10 @@
#endif
#include "Core/HW/GCMemcard/GCMemcard.h"
#include "Core/HW/GCMemcard/GCMemcardDirectory.h"
-#include "Core/HW/GCMemcard/GCMemcardRaw.h"
#include "Core/HW/Sram.h"
#include "Core/HW/WiiSave.h"
#include "Core/HW/WiiSaveStructs.h"
#include "Core/HW/WiimoteEmu/DesiredWiimoteState.h"
-#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
-#include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "Core/IOS/ES/ES.h"
#include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/IOS.h"
@@ -69,7 +66,6 @@
#include "DiscIO/Enums.h"
#include "DiscIO/RiivolutionPatcher.h"
-#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
#include "InputCommon/GCPadStatus.h"
#include "InputCommon/InputConfig.h"
@@ -2061,7 +2057,7 @@ bool NetPlayServer::SyncCodes()
}
// Find all INI files
- const auto game_id = game->GetGameID();
+ const std::string_view game_id = game->GetGameID();
const auto revision = game->GetRevision();
Common::IniFile globalIni;
for (const std::string& filename : ConfigLoaders::GetGameIniFilenames(game_id, revision))
diff --git a/Source/Core/Core/NetPlayServer.h b/Source/Core/Core/NetPlayServer.h
index da32b64d4b..168a273074 100644
--- a/Source/Core/Core/NetPlayServer.h
+++ b/Source/Core/Core/NetPlayServer.h
@@ -6,11 +6,9 @@
#include <SFML/Network/Packet.hpp>
#include <map>
-#include <memory>
#include <mutex>
#include <optional>
-#include <queue>
-#include <sstream>
+#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
@@ -23,7 +21,6 @@
#include "Common/TraversalClient.h"
#include "Core/NetPlayProto.h"
#include "Core/SyncIdentifier.h"
-#include "InputCommon/GCPadStatus.h"
#include "UICommon/NetPlayIndex.h"
namespace NetPlay