mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-30 02:53:20 +00:00
Merge pull request #14303 from Sintendo/game-ini
Core: Pass game ID as string_view
This commit is contained in:
commit
533fd18d8a
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user