* new function in networking to send to all gameservers only

* broadcast user stats with gameservers only
This commit is contained in:
otavepto 2024-03-31 21:17:20 +02:00 committed by otavepto
parent e6ebe6fb6b
commit e143a6dd82
3 changed files with 19 additions and 2 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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",