From e31f030d557306124dfff41c8add6f779db5eb9b Mon Sep 17 00:00:00 2001 From: otavepto Date: Sun, 31 Mar 2024 23:19:04 +0200 Subject: [PATCH] allow gameserver to send data as soon as possible via `immediate_gameserver_stats.txt` --- dll/dll/settings.h | 2 ++ dll/settings_parser.cpp | 5 +++++ dll/steam_gameserverstats.cpp | 16 +++++++++++++++- post_build/README.release.md | 8 ++++++-- .../immediate_gameserver_stats.EXAMPLE.txt | 1 + 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 post_build/steam_settings.EXAMPLE/immediate_gameserver_stats.EXAMPLE.txt diff --git a/dll/dll/settings.h b/dll/dll/settings.h index 2c4abd6c..0a5402d9 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -252,6 +252,8 @@ public: // don't share stats and achievements with the game server 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 bool disable_overlay = false; diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index c7d7f172..abeb13d5 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -1240,6 +1240,7 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s bool disable_leaderboards_create_unknown = false; bool share_leaderboards_over_network = false; bool disable_sharing_stats_with_gameserver = false; + bool immediate_gameserver_stats = false; bool use_gc_token = false; bool enable_new_app_ticket = false; int build_id = 10; @@ -1291,6 +1292,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s share_leaderboards_over_network = true; } else if (p == "disable_sharing_stats_with_gameserver.txt") { disable_sharing_stats_with_gameserver = true; + } else if (p == "immediate_gameserver_stats.txt") { + immediate_gameserver_stats = true; } else if (p == "achievements_bypass.txt") { achievement_bypass = true; } 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_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_server->enable_new_app_ticket = enable_new_app_ticket; diff --git a/dll/steam_gameserverstats.cpp b/dll/steam_gameserverstats.cpp index e69c5466..3eda64d6 100644 --- a/dll/steam_gameserverstats.cpp +++ b/dll/steam_gameserverstats.cpp @@ -218,6 +218,9 @@ bool Steam_GameServerStats::SetUserStat( CSteamID steamIDUser, const char *pchNa stat->dirty = true; stat->stat.set_value_int(nData); + + if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats(); + return true; } @@ -236,6 +239,9 @@ bool Steam_GameServerStats::SetUserStat( CSteamID steamIDUser, const char *pchNa stat->dirty = true; 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; } @@ -266,6 +272,8 @@ bool Steam_GameServerStats::UpdateUserAvgRateStat( CSteamID steamIDUser, const c avg_info->set_session_length(dSessionLength); stat->stat.set_allocated_value_avg(avg_info); + if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats(); + return true; } @@ -284,6 +292,9 @@ bool Steam_GameServerStats::SetUserAchievement( CSteamID steamIDUser, const char ach->dirty = true; ach->ach.set_achieved(true); + + if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats(); + return true; } @@ -301,6 +312,9 @@ bool Steam_GameServerStats::ClearUserAchievement( CSteamID steamIDUser, const ch ach->dirty = true; ach->ach.set_achieved(false); + + if (settings->immediate_gameserver_stats) collect_and_send_updated_user_stats(); + return true; } @@ -314,7 +328,7 @@ bool Steam_GameServerStats::ClearUserAchievement( CSteamID steamIDUser, const ch STEAM_CALL_RESULT( GSStatsStored_t ) 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"); std::lock_guard lock(global_mutex); if (settings->disable_sharing_stats_with_gameserver) { diff --git a/post_build/README.release.md b/post_build/README.release.md index 02f7f8b4..653014ce 100644 --- a/post_build/README.release.md +++ b/post_build/README.release.md @@ -554,9 +554,13 @@ Check the example file in the `steam_settings` folder ## 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 --- diff --git a/post_build/steam_settings.EXAMPLE/immediate_gameserver_stats.EXAMPLE.txt b/post_build/steam_settings.EXAMPLE/immediate_gameserver_stats.EXAMPLE.txt new file mode 100644 index 00000000..61517b14 --- /dev/null +++ b/post_build/steam_settings.EXAMPLE/immediate_gameserver_stats.EXAMPLE.txt @@ -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. \ No newline at end of file