mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-28 03:14:15 +08:00
add an option to allow the game to change unknown stats
This commit is contained in:
parent
b67cb48f38
commit
de03379602
@ -229,6 +229,9 @@ public:
|
||||
// can use GC token for generation
|
||||
bool use_gc_token = false;
|
||||
|
||||
// allow stats not defined by the user?
|
||||
bool allow_unknown_stats = false;
|
||||
|
||||
// bypass to make SetAchievement() always return true, prevent some games from breaking
|
||||
bool achievement_bypass = false;
|
||||
|
||||
@ -352,7 +355,7 @@ public:
|
||||
|
||||
//stats
|
||||
const std::map<std::string, Stat_config>& getStats() const;
|
||||
void setStatDefiniton(const std::string &name, const struct Stat_config &stat_config);
|
||||
std::map<std::string, Stat_config>::const_iterator setStatDefiniton(const std::string &name, const struct Stat_config &stat_config);
|
||||
|
||||
//images
|
||||
int add_image(const std::string &data, uint32 width, uint32 height);
|
||||
|
@ -344,9 +344,10 @@ const std::map<std::string, Stat_config>& Settings::getStats() const
|
||||
return stats;
|
||||
}
|
||||
|
||||
void Settings::setStatDefiniton(const std::string &name, const struct Stat_config &stat_config)
|
||||
std::map<std::string, Stat_config>::const_iterator Settings::setStatDefiniton(const std::string &name, const struct Stat_config &stat_config)
|
||||
{
|
||||
stats[common_helpers::ascii_to_lowercase(name)] = stat_config;
|
||||
auto ins_it = stats.insert_or_assign(common_helpers::ascii_to_lowercase(name), stat_config);
|
||||
return ins_it.first;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1287,6 +1287,9 @@ static void parse_simple_features(class Settings *settings_client, class Setting
|
||||
settings_client->disable_leaderboards_create_unknown = ini.GetBoolValue("main::general", "disable_leaderboards_create_unknown", settings_client->disable_leaderboards_create_unknown);
|
||||
settings_server->disable_leaderboards_create_unknown = ini.GetBoolValue("main::general", "disable_leaderboards_create_unknown", settings_server->disable_leaderboards_create_unknown);
|
||||
|
||||
settings_client->allow_unknown_stats = ini.GetBoolValue("main::general", "allow_unknown_stats", settings_client->allow_unknown_stats);
|
||||
settings_server->allow_unknown_stats = ini.GetBoolValue("main::general", "allow_unknown_stats", settings_server->allow_unknown_stats);
|
||||
|
||||
settings_client->immediate_gameserver_stats = ini.GetBoolValue("main::general", "immediate_gameserver_stats", settings_client->immediate_gameserver_stats);
|
||||
settings_server->immediate_gameserver_stats = ini.GetBoolValue("main::general", "immediate_gameserver_stats", settings_server->immediate_gameserver_stats);
|
||||
|
||||
|
@ -433,6 +433,13 @@ Steam_User_Stats::InternalSetResult<int32> Steam_User_Stats::set_stat_internal(
|
||||
|
||||
const auto &stats_config = settings->getStats();
|
||||
auto stats_data = stats_config.find(stat_name);
|
||||
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
|
||||
Stat_config cfg{};
|
||||
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_INT;
|
||||
cfg.default_value_int = 0;
|
||||
stats_data = settings->setStatDefiniton(stat_name, cfg);
|
||||
}
|
||||
|
||||
if (stats_config.end() == stats_data) return result;
|
||||
if (stats_data->second.type != GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return result;
|
||||
|
||||
@ -480,6 +487,13 @@ Steam_User_Stats::InternalSetResult<std::pair<GameServerStats_Messages::StatInfo
|
||||
|
||||
const auto &stats_config = settings->getStats();
|
||||
auto stats_data = stats_config.find(stat_name);
|
||||
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
|
||||
Stat_config cfg{};
|
||||
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_FLOAT;
|
||||
cfg.default_value_float = 0;
|
||||
stats_data = settings->setStatDefiniton(stat_name, cfg);
|
||||
}
|
||||
|
||||
if (stats_config.end() == stats_data) return result;
|
||||
if (stats_data->second.type == GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return result;
|
||||
|
||||
@ -528,6 +542,13 @@ Steam_User_Stats::InternalSetResult<std::pair<GameServerStats_Messages::StatInfo
|
||||
|
||||
const auto &stats_config = settings->getStats();
|
||||
auto stats_data = stats_config.find(stat_name);
|
||||
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
|
||||
Stat_config cfg{};
|
||||
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_AVGRATE;
|
||||
cfg.default_value_float = 0;
|
||||
stats_data = settings->setStatDefiniton(stat_name, cfg);
|
||||
}
|
||||
|
||||
if (stats_config.end() == stats_data) return result;
|
||||
if (stats_data->second.type == GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return result;
|
||||
|
||||
@ -822,6 +843,13 @@ bool Steam_User_Stats::GetStat( const char *pchName, int32 *pData )
|
||||
|
||||
const auto &stats_config = settings->getStats();
|
||||
auto stats_data = stats_config.find(stat_name);
|
||||
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
|
||||
Stat_config cfg{};
|
||||
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_INT;
|
||||
cfg.default_value_int = 0;
|
||||
stats_data = settings->setStatDefiniton(stat_name, cfg);
|
||||
}
|
||||
|
||||
if (stats_config.end() == stats_data) return false;
|
||||
if (stats_data->second.type != GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return false;
|
||||
|
||||
@ -854,6 +882,13 @@ bool Steam_User_Stats::GetStat( const char *pchName, float *pData )
|
||||
|
||||
const auto &stats_config = settings->getStats();
|
||||
auto stats_data = stats_config.find(stat_name);
|
||||
if (stats_config.end() == stats_data && settings->allow_unknown_stats) {
|
||||
Stat_config cfg{};
|
||||
cfg.type = GameServerStats_Messages::StatInfo::STAT_TYPE_FLOAT;
|
||||
cfg.default_value_float = 0;
|
||||
stats_data = settings->setStatDefiniton(stat_name, cfg);
|
||||
}
|
||||
|
||||
if (stats_config.end() == stats_data) return false;
|
||||
if (stats_data->second.type == GameServerStats_Messages::StatInfo::STAT_TYPE_INT) return false;
|
||||
|
||||
|
@ -14,6 +14,10 @@ enable_account_avatar=0
|
||||
# prevent Steam_User_Stats::FindLeaderboard() from always succeeding and creating the unknown leaderboard
|
||||
# not recommended to disable this
|
||||
disable_leaderboards_create_unknown=0
|
||||
# the emu will only save/update stats defined by the user, unknown stats requested or updated by the game will be rejected
|
||||
# set this to 1 to allow unknown stats
|
||||
# default=0
|
||||
allow_unknown_stats=0
|
||||
# synchronize user stats/achievements with game servers as soon as possible instead of caching them until the next call to `Steam_RunCallbacks()`
|
||||
# not recommended
|
||||
immediate_gameserver_stats=0
|
||||
|
Loading…
x
Reference in New Issue
Block a user