mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 07:39:26 +01:00
Add Gecko Code Whitelist Approval
This commit is contained in:
parent
78f3448e27
commit
13a1956cfa
@ -28,6 +28,7 @@
|
|||||||
#include "Core/Config/FreeLookSettings.h"
|
#include "Core/Config/FreeLookSettings.h"
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
|
#include "Core/GeckoCode.h"
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
#include "Core/HW/VideoInterface.h"
|
#include "Core/HW/VideoInterface.h"
|
||||||
#include "Core/PatchEngine.h"
|
#include "Core/PatchEngine.h"
|
||||||
@ -461,12 +462,36 @@ Common::SHA1::Digest AchievementManager::GetCodeHash(const PatchEngine::Patch& p
|
|||||||
return context->Finish();
|
return context->Finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Common::SHA1::Digest AchievementManager::GetCodeHash(const Gecko::GeckoCode& code) const
|
||||||
|
{
|
||||||
|
auto context = Common::SHA1::CreateContext();
|
||||||
|
context->Update(Common::BitCastToArray<u8>(static_cast<u64>(code.codes.size())));
|
||||||
|
for (const auto& entry : code.codes)
|
||||||
|
{
|
||||||
|
context->Update(Common::BitCastToArray<u8>(entry.address));
|
||||||
|
context->Update(Common::BitCastToArray<u8>(entry.data));
|
||||||
|
}
|
||||||
|
return context->Finish();
|
||||||
|
}
|
||||||
|
|
||||||
void AchievementManager::FilterApprovedPatches(std::vector<PatchEngine::Patch>& patches,
|
void AchievementManager::FilterApprovedPatches(std::vector<PatchEngine::Patch>& patches,
|
||||||
const std::string& game_ini_id) const
|
const std::string& game_ini_id) const
|
||||||
{
|
{
|
||||||
FilterApprovedIni(patches, game_ini_id);
|
FilterApprovedIni(patches, game_ini_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AchievementManager::FilterApprovedGeckoCodes(std::vector<Gecko::GeckoCode>& codes,
|
||||||
|
const std::string& game_ini_id) const
|
||||||
|
{
|
||||||
|
FilterApprovedIni(codes, game_ini_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AchievementManager::CheckApprovedGeckoCode(const Gecko::GeckoCode& code,
|
||||||
|
const std::string& game_ini_id) const
|
||||||
|
{
|
||||||
|
return CheckApprovedCode(code, game_ini_id);
|
||||||
|
}
|
||||||
|
|
||||||
void AchievementManager::SetSpectatorMode()
|
void AchievementManager::SetSpectatorMode()
|
||||||
{
|
{
|
||||||
rc_client_set_spectator_mode_enabled(m_client, Config::Get(Config::RA_SPECTATOR_ENABLED));
|
rc_client_set_spectator_mode_enabled(m_client, Config::Get(Config::RA_SPECTATOR_ENABLED));
|
||||||
|
@ -45,6 +45,11 @@ namespace PatchEngine
|
|||||||
struct Patch;
|
struct Patch;
|
||||||
} // namespace PatchEngine
|
} // namespace PatchEngine
|
||||||
|
|
||||||
|
namespace Gecko
|
||||||
|
{
|
||||||
|
class GeckoCode;
|
||||||
|
} // namespace Gecko
|
||||||
|
|
||||||
class AchievementManager
|
class AchievementManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -125,8 +130,13 @@ public:
|
|||||||
void SetHardcoreMode();
|
void SetHardcoreMode();
|
||||||
bool IsHardcoreModeActive() const;
|
bool IsHardcoreModeActive() const;
|
||||||
void SetGameIniId(const std::string& game_ini_id) { m_game_ini_id = game_ini_id; }
|
void SetGameIniId(const std::string& game_ini_id) { m_game_ini_id = game_ini_id; }
|
||||||
|
|
||||||
void FilterApprovedPatches(std::vector<PatchEngine::Patch>& patches,
|
void FilterApprovedPatches(std::vector<PatchEngine::Patch>& patches,
|
||||||
const std::string& game_ini_id) const;
|
const std::string& game_ini_id) const;
|
||||||
|
void FilterApprovedGeckoCodes(std::vector<Gecko::GeckoCode>& codes,
|
||||||
|
const std::string& game_ini_id) const;
|
||||||
|
bool CheckApprovedGeckoCode(const Gecko::GeckoCode& code, const std::string& game_ini_id) const;
|
||||||
|
|
||||||
void SetSpectatorMode();
|
void SetSpectatorMode();
|
||||||
std::string_view GetPlayerDisplayName() const;
|
std::string_view GetPlayerDisplayName() const;
|
||||||
u32 GetPlayerScore() const;
|
u32 GetPlayerScore() const;
|
||||||
@ -186,6 +196,7 @@ private:
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
bool CheckApprovedCode(const T& code, const std::string& game_ini_id) const;
|
bool CheckApprovedCode(const T& code, const std::string& game_ini_id) const;
|
||||||
Common::SHA1::Digest GetCodeHash(const PatchEngine::Patch& patch) const;
|
Common::SHA1::Digest GetCodeHash(const PatchEngine::Patch& patch) const;
|
||||||
|
Common::SHA1::Digest GetCodeHash(const Gecko::GeckoCode& code) const;
|
||||||
|
|
||||||
static void LeaderboardEntriesCallback(int result, const char* error_message,
|
static void LeaderboardEntriesCallback(int result, const char* error_message,
|
||||||
rc_client_leaderboard_entry_list_t* list,
|
rc_client_leaderboard_entry_list_t* list,
|
||||||
@ -271,6 +282,12 @@ public:
|
|||||||
|
|
||||||
constexpr bool IsHardcoreModeActive() { return false; }
|
constexpr bool IsHardcoreModeActive() { return false; }
|
||||||
|
|
||||||
|
constexpr bool CheckApprovedGeckoCode(const Gecko::GeckoCode& code,
|
||||||
|
const std::string& game_ini_id)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
constexpr void LoadGame(const std::string&, const DiscIO::Volume*) {}
|
constexpr void LoadGame(const std::string&, const DiscIO::Volume*) {}
|
||||||
|
|
||||||
constexpr void SetBackgroundExecutionAllowed(bool allowed) {}
|
constexpr void SetBackgroundExecutionAllowed(bool allowed) {}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "Common/Config/Config.h"
|
#include "Common/Config/Config.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
|
|
||||||
|
#include "Core/AchievementManager.h"
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/Host.h"
|
#include "Core/Host.h"
|
||||||
@ -49,7 +50,7 @@ static std::vector<GeckoCode> s_active_codes;
|
|||||||
static std::vector<GeckoCode> s_synced_codes;
|
static std::vector<GeckoCode> s_synced_codes;
|
||||||
static std::mutex s_active_codes_lock;
|
static std::mutex s_active_codes_lock;
|
||||||
|
|
||||||
void SetActiveCodes(std::span<const GeckoCode> gcodes)
|
void SetActiveCodes(std::span<const GeckoCode> gcodes, const std::string& game_id)
|
||||||
{
|
{
|
||||||
std::lock_guard lk(s_active_codes_lock);
|
std::lock_guard lk(s_active_codes_lock);
|
||||||
|
|
||||||
@ -57,8 +58,12 @@ void SetActiveCodes(std::span<const GeckoCode> gcodes)
|
|||||||
if (Config::AreCheatsEnabled())
|
if (Config::AreCheatsEnabled())
|
||||||
{
|
{
|
||||||
s_active_codes.reserve(gcodes.size());
|
s_active_codes.reserve(gcodes.size());
|
||||||
|
|
||||||
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
|
std::copy_if(gcodes.begin(), gcodes.end(), std::back_inserter(s_active_codes),
|
||||||
[](const GeckoCode& code) { return code.enabled; });
|
[&game_id](const GeckoCode& code) {
|
||||||
|
return code.enabled &&
|
||||||
|
AchievementManager::GetInstance().CheckApprovedGeckoCode(code, game_id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
s_active_codes.shrink_to_fit();
|
s_active_codes.shrink_to_fit();
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ constexpr u32 HLE_TRAMPOLINE_ADDRESS = INSTALLER_END_ADDRESS - 4;
|
|||||||
// preserve the emulation performance.
|
// preserve the emulation performance.
|
||||||
constexpr u32 MAGIC_GAMEID = 0xD01F1BAD;
|
constexpr u32 MAGIC_GAMEID = 0xD01F1BAD;
|
||||||
|
|
||||||
void SetActiveCodes(std::span<const GeckoCode> gcodes);
|
void SetActiveCodes(std::span<const GeckoCode> gcodes, const std::string& game_id);
|
||||||
void SetSyncedCodesAsActive();
|
void SetSyncedCodesAsActive();
|
||||||
void UpdateSyncedCodes(std::span<const GeckoCode> gcodes);
|
void UpdateSyncedCodes(std::span<const GeckoCode> gcodes);
|
||||||
std::vector<GeckoCode> SetAndReturnActiveCodes(std::span<const GeckoCode> gcodes);
|
std::vector<GeckoCode> SetAndReturnActiveCodes(std::span<const GeckoCode> gcodes);
|
||||||
|
@ -2070,13 +2070,18 @@ bool NetPlayServer::SyncCodes()
|
|||||||
}
|
}
|
||||||
// Sync Gecko Codes
|
// Sync Gecko Codes
|
||||||
{
|
{
|
||||||
|
std::vector<Gecko::GeckoCode> codes = Gecko::LoadCodes(globalIni, localIni);
|
||||||
|
|
||||||
|
#ifdef USE_RETRO_ACHIEVEMENTS
|
||||||
|
AchievementManager::GetInstance().FilterApprovedGeckoCodes(codes, game_id);
|
||||||
|
#endif // USE_RETRO_ACHIEVEMENTS
|
||||||
|
|
||||||
// Create a Gecko Code Vector with just the active codes
|
// Create a Gecko Code Vector with just the active codes
|
||||||
std::vector<Gecko::GeckoCode> s_active_codes =
|
std::vector<Gecko::GeckoCode> active_codes = Gecko::SetAndReturnActiveCodes(codes);
|
||||||
Gecko::SetAndReturnActiveCodes(Gecko::LoadCodes(globalIni, localIni));
|
|
||||||
|
|
||||||
// Determine Codelist Size
|
// Determine Codelist Size
|
||||||
u16 codelines = 0;
|
u16 codelines = 0;
|
||||||
for (const Gecko::GeckoCode& active_code : s_active_codes)
|
for (const Gecko::GeckoCode& active_code : active_codes)
|
||||||
{
|
{
|
||||||
INFO_LOG_FMT(NETPLAY, "Indexing {}", active_code.name);
|
INFO_LOG_FMT(NETPLAY, "Indexing {}", active_code.name);
|
||||||
for (const Gecko::GeckoCode::Code& code : active_code.codes)
|
for (const Gecko::GeckoCode::Code& code : active_code.codes)
|
||||||
@ -2104,7 +2109,7 @@ bool NetPlayServer::SyncCodes()
|
|||||||
pac << MessageID::SyncCodes;
|
pac << MessageID::SyncCodes;
|
||||||
pac << SyncCodeID::GeckoData;
|
pac << SyncCodeID::GeckoData;
|
||||||
// Iterate through the active code vector and send each codeline
|
// Iterate through the active code vector and send each codeline
|
||||||
for (const Gecko::GeckoCode& active_code : s_active_codes)
|
for (const Gecko::GeckoCode& active_code : active_codes)
|
||||||
{
|
{
|
||||||
INFO_LOG_FMT(NETPLAY, "Sending {}", active_code.name);
|
INFO_LOG_FMT(NETPLAY, "Sending {}", active_code.name);
|
||||||
for (const Gecko::GeckoCode::Code& code : active_code.codes)
|
for (const Gecko::GeckoCode::Code& code : active_code.codes)
|
||||||
|
@ -197,7 +197,7 @@ void LoadPatches()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Gecko::SetActiveCodes(Gecko::LoadCodes(globalIni, localIni));
|
Gecko::SetActiveCodes(Gecko::LoadCodes(globalIni, localIni), sconfig.GetGameID());
|
||||||
ActionReplay::LoadAndApplyCodes(globalIni, localIni);
|
ActionReplay::LoadAndApplyCodes(globalIni, localIni);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,7 @@ void GeckoCodeWidget::OnItemChanged(QListWidgetItem* item)
|
|||||||
m_gecko_codes[index].enabled = (item->checkState() == Qt::Checked);
|
m_gecko_codes[index].enabled = (item->checkState() == Qt::Checked);
|
||||||
|
|
||||||
if (!m_restart_required)
|
if (!m_restart_required)
|
||||||
Gecko::SetActiveCodes(m_gecko_codes);
|
Gecko::SetActiveCodes(m_gecko_codes, m_game_id);
|
||||||
|
|
||||||
SaveCodes();
|
SaveCodes();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user