mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Netplay: Sync codes
Adds a tickbox to the server's window to syncronize codes. Codes are temporarily sent to each client and are used for the duration of the session. Saves the "sync codes" tickbox as per PR Netplay: Properly save hosting settings #7483
This commit is contained in:

committed by
Pierre Bourdon

parent
0140009114
commit
469f29350f
@ -83,6 +83,7 @@ enum
|
||||
// General lock. Protects codes list and internal log.
|
||||
static std::mutex s_lock;
|
||||
static std::vector<ARCode> s_active_codes;
|
||||
static std::vector<ARCode> s_synced_codes;
|
||||
static std::vector<std::string> s_internal_log;
|
||||
static std::atomic<bool> s_use_internal_log{false};
|
||||
// pointer to the code currently being run, (used by log messages that include the code name)
|
||||
@ -123,6 +124,37 @@ void ApplyCodes(const std::vector<ARCode>& codes)
|
||||
s_active_codes.shrink_to_fit();
|
||||
}
|
||||
|
||||
void SetSyncedCodesAsActive()
|
||||
{
|
||||
s_active_codes.clear();
|
||||
s_active_codes.reserve(s_synced_codes.size());
|
||||
s_active_codes = s_synced_codes;
|
||||
}
|
||||
|
||||
void UpdateSyncedCodes(const std::vector<ARCode>& codes)
|
||||
{
|
||||
s_synced_codes.clear();
|
||||
s_synced_codes.reserve(codes.size());
|
||||
std::copy_if(codes.begin(), codes.end(), std::back_inserter(s_synced_codes),
|
||||
[](const ARCode& code) { return code.active; });
|
||||
s_synced_codes.shrink_to_fit();
|
||||
}
|
||||
|
||||
std::vector<ARCode> ApplyAndReturnCodes(const std::vector<ARCode>& codes)
|
||||
{
|
||||
if (SConfig::GetInstance().bEnableCheats)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(s_lock);
|
||||
s_disable_logging = false;
|
||||
s_active_codes.clear();
|
||||
std::copy_if(codes.begin(), codes.end(), std::back_inserter(s_active_codes),
|
||||
[](const ARCode& code) { return code.active; });
|
||||
}
|
||||
s_active_codes.shrink_to_fit();
|
||||
|
||||
return s_active_codes;
|
||||
}
|
||||
|
||||
void AddCode(ARCode code)
|
||||
{
|
||||
if (!SConfig::GetInstance().bEnableCheats)
|
||||
|
Reference in New Issue
Block a user