allow gameserver to send data as soon as possible via immediate_gameserver_stats.txt

This commit is contained in:
otavepto 2024-03-31 23:19:04 +02:00 committed by otavepto
parent 2f5b0a4bea
commit e31f030d55
5 changed files with 29 additions and 3 deletions

View File

@ -252,6 +252,8 @@ public:
// don't share stats and achievements with the game server // don't share stats and achievements with the game server
bool disable_sharing_stats_with_gameserver = false; bool disable_sharing_stats_with_gameserver = false;
// send user stats/achievements as soon as possible instead of caching them
bool immediate_gameserver_stats = false;
//overlay //overlay
bool disable_overlay = false; bool disable_overlay = false;

View File

@ -1240,6 +1240,7 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
bool disable_leaderboards_create_unknown = false; bool disable_leaderboards_create_unknown = false;
bool share_leaderboards_over_network = false; bool share_leaderboards_over_network = false;
bool disable_sharing_stats_with_gameserver = false; bool disable_sharing_stats_with_gameserver = false;
bool immediate_gameserver_stats = false;
bool use_gc_token = false; bool use_gc_token = false;
bool enable_new_app_ticket = false; bool enable_new_app_ticket = false;
int build_id = 10; int build_id = 10;
@ -1291,6 +1292,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
share_leaderboards_over_network = true; share_leaderboards_over_network = true;
} else if (p == "disable_sharing_stats_with_gameserver.txt") { } else if (p == "disable_sharing_stats_with_gameserver.txt") {
disable_sharing_stats_with_gameserver = true; disable_sharing_stats_with_gameserver = true;
} else if (p == "immediate_gameserver_stats.txt") {
immediate_gameserver_stats = true;
} else if (p == "achievements_bypass.txt") { } else if (p == "achievements_bypass.txt") {
achievement_bypass = true; achievement_bypass = true;
} else if (p == "is_beta_branch.txt") { } else if (p == "is_beta_branch.txt") {
@ -1380,6 +1383,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
settings_client->disable_sharing_stats_with_gameserver = disable_sharing_stats_with_gameserver; settings_client->disable_sharing_stats_with_gameserver = disable_sharing_stats_with_gameserver;
settings_server->disable_sharing_stats_with_gameserver = disable_sharing_stats_with_gameserver; settings_server->disable_sharing_stats_with_gameserver = disable_sharing_stats_with_gameserver;
settings_client->immediate_gameserver_stats = immediate_gameserver_stats;
settings_server->immediate_gameserver_stats = immediate_gameserver_stats;
settings_client->enable_new_app_ticket = enable_new_app_ticket; settings_client->enable_new_app_ticket = enable_new_app_ticket;
settings_server->enable_new_app_ticket = enable_new_app_ticket; settings_server->enable_new_app_ticket = enable_new_app_ticket;

View File

@ -218,6 +218,9 @@ bool Steam_GameServerStats::SetUserStat( CSteamID steamIDUser, const char *pchNa
stat->dirty = true; stat->dirty = true;
stat->stat.set_value_int(nData); stat->stat.set_value_int(nData);
if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats();
return true; return true;
} }
@ -236,6 +239,9 @@ bool Steam_GameServerStats::SetUserStat( CSteamID steamIDUser, const char *pchNa
stat->dirty = true; stat->dirty = true;
stat->stat.set_value_float(fData); // we set the float field in case it's float or avg stat->stat.set_value_float(fData); // we set the float field in case it's float or avg
if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats();
return true; return true;
} }
@ -266,6 +272,8 @@ bool Steam_GameServerStats::UpdateUserAvgRateStat( CSteamID steamIDUser, const c
avg_info->set_session_length(dSessionLength); avg_info->set_session_length(dSessionLength);
stat->stat.set_allocated_value_avg(avg_info); stat->stat.set_allocated_value_avg(avg_info);
if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats();
return true; return true;
} }
@ -284,6 +292,9 @@ bool Steam_GameServerStats::SetUserAchievement( CSteamID steamIDUser, const char
ach->dirty = true; ach->dirty = true;
ach->ach.set_achieved(true); ach->ach.set_achieved(true);
if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats();
return true; return true;
} }
@ -301,6 +312,9 @@ bool Steam_GameServerStats::ClearUserAchievement( CSteamID steamIDUser, const ch
ach->dirty = true; ach->dirty = true;
ach->ach.set_achieved(false); ach->ach.set_achieved(false);
if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats();
return true; return true;
} }
@ -314,7 +328,7 @@ bool Steam_GameServerStats::ClearUserAchievement( CSteamID steamIDUser, const ch
STEAM_CALL_RESULT( GSStatsStored_t ) STEAM_CALL_RESULT( GSStatsStored_t )
SteamAPICall_t Steam_GameServerStats::StoreUserStats( CSteamID steamIDUser ) SteamAPICall_t Steam_GameServerStats::StoreUserStats( CSteamID steamIDUser )
{ {
// it's not necessary to send all data here // it's not necessary to send all data here, we already do that in run_callback() and on each API function call (immediate mode)
PRINT_DEBUG("Steam_GameServerStats::StoreUserStats\n"); PRINT_DEBUG("Steam_GameServerStats::StoreUserStats\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
if (settings->disable_sharing_stats_with_gameserver) { if (settings->disable_sharing_stats_with_gameserver) {

View File

@ -554,9 +554,13 @@ Check the example file in the `steam_settings` folder
## Sharing stats and achievements with game servers: ## Sharing stats and achievements with game servers:
By default the emu will share stats with game servers, you can disable this option by adding the config file `disable_sharing_stats_with_gameserver.txt` inside your `steam_settings` folder, this also disables the interface `ISteamGameServerStats`. By default the emu will mutually share stats with game servers, you can disable this behavior by adding the config file `disable_sharing_stats_with_gameserver.txt` inside your `steam_settings` folder, this also disables the interface `ISteamGameServerStats`.
Check the example file in the `steam_settings` folder Game servers will not immediately send user stats/achievements whey they're changed,
they'll wait for the next call to `Steam_RunCallbacks()`.
You can make the server eager to send its updated data by creating the config file `immediate_gameserver_stats.txt` inside your `steam_settings` folder.
Check the example files in the `steam_settings` folder
--- ---

View File

@ -0,0 +1 @@
Rename this file to immediate_gameserver_stats.txt to make the gameserver send user stats/achievements as soon as possible instead of caching them.