From e143a6dd82f2d9866c298f48b1eaff460db2aac8 Mon Sep 17 00:00:00 2001 From: otavepto Date: Sun, 31 Mar 2024 21:17:20 +0200 Subject: [PATCH] * new function in networking to send to all gameservers only * broadcast user stats with gameservers only --- dll/dll/network.h | 3 +++ dll/network.cpp | 14 ++++++++++++++ dll/steam_user_stats.cpp | 4 ++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dll/dll/network.h b/dll/dll/network.h index 62453e91..e3ab7466 100644 --- a/dll/dll/network.h +++ b/dll/dll/network.h @@ -140,6 +140,9 @@ public: // send to all users whose account type is Individual, no need to call set_dest_id(), this is done automatically bool sendToAllIndividuals(Common_Message *msg, bool reliable); + // send to all users whose account type is GameServer, no need to call set_dest_id(), this is done automatically + bool sendToAllGameservers(Common_Message *msg, bool reliable); + // send to all active/current connections, no need to call set_dest_id(), this is done automatically bool sendToAll(Common_Message *msg, bool reliable); diff --git a/dll/network.cpp b/dll/network.cpp index 9ad63630..04fe0a99 100644 --- a/dll/network.cpp +++ b/dll/network.cpp @@ -1262,6 +1262,20 @@ bool Networking::sendToAllIndividuals(Common_Message *msg, bool reliable) return true; } +bool Networking::sendToAllGameservers(Common_Message *msg, bool reliable) +{ + for (auto &conn: connections) { + for (auto &steam_id : conn.ids) { + if (steam_id.BGameServerAccount()) { + msg->set_dest_id(steam_id.ConvertToUint64()); + sendTo(msg, reliable, &conn); + } + } + } + + return true; +} + bool Networking::sendToAll(Common_Message *msg, bool reliable) { for (auto &conn: connections) { diff --git a/dll/steam_user_stats.cpp b/dll/steam_user_stats.cpp index a21c45a6..5a8f0074 100644 --- a/dll/steam_user_stats.cpp +++ b/dll/steam_user_stats.cpp @@ -1676,8 +1676,8 @@ void Steam_User_Stats::send_updated_stats() // set_allocated_xxx() takes ownership of the allocated object, no need to delete msg.set_allocated_gameserver_stats_messages(gameserverstats_msg); msg.set_source_id(settings->get_local_steam_id().ConvertToUint64()); - // here we send to all users on the network because we don't know the server steamid - network->sendToAll(&msg, true); + // here we send to all gameservers on the network because we don't know the server steamid + network->sendToAllGameservers(&msg, true); PRINT_DEBUG( "Steam_User_Stats::send_updated_stats sent updated stats: %zu stats, %zu achievements\n",