From cd1557ecf2e8cb313bd1cb4de6fdd1954928a3db Mon Sep 17 00:00:00 2001 From: maxsupermanhd Date: Sun, 6 Oct 2024 19:22:46 +0300 Subject: [PATCH] more logic fixes to admin actions, log them too --- src/multiint.cpp | 49 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/src/multiint.cpp b/src/multiint.cpp index 673156b2bbd..efa8940ee7d 100644 --- a/src/multiint.cpp +++ b/src/multiint.cpp @@ -2519,18 +2519,20 @@ bool recvTeamRequest(NETQUEUE queue) return false; } - if (senderHasLobbyCommandAdminPrivs(queue.index)) + if (locked.teams && !senderHasLobbyCommandAdminPrivs(queue.index)) { - sendRoomSystemMessage(astringf("Admin %s changed team of player [%d] %s to %d", - NetPlay.players[queue.index].name, - NetPlay.players[player].position, - NetPlay.players[player].name, - team).c_str()); + return false; } - if (locked.teams && !senderHasLobbyCommandAdminPrivs(queue.index)) + if (senderHasLobbyCommandAdminPrivs(queue.index) && (queue.index != player || locked.teams)) { - return false; + const char* msg = astringf("Admin %s changed team of player [%d] %s to %d", + NetPlay.players[queue.index].name, + NetPlay.players[player].position, + NetPlay.players[player].name, + team).c_str(); + sendRoomSystemMessage(msg); + debug(LOG_INFO, "%s", msg); } if (!alliancesSetTeamsBeforeGame(game.alliance)) @@ -2776,7 +2778,7 @@ bool recvFactionRequest(NETQUEUE queue) return false; } - if (whosResponsible(player) != queue.index) + if (whosResponsible(player) != queue.index && !senderHasLobbyCommandAdminPrivs(queue.index)) { HandleBadParam("NET_FACTIONREQUEST given incorrect params.", player, queue.index); return false; @@ -2789,6 +2791,17 @@ bool recvFactionRequest(NETQUEUE queue) return false; } + if (senderHasLobbyCommandAdminPrivs(queue.index) && queue.index != player) + { + const char* msg = astringf("Admin %s changed faction of player [%d] %s to %d", + NetPlay.players[queue.index].name, + NetPlay.players[player].position, + NetPlay.players[player].name, + faction).c_str(); + sendRoomSystemMessage(msg); + debug(LOG_INFO, "%s", msg); + } + resetReadyStatus(false, true); NetPlay.players[player].faction = newFactionId.value(); @@ -2820,13 +2833,15 @@ bool recvColourRequest(NETQUEUE queue) return false; } - if (senderHasLobbyCommandAdminPrivs(queue.index)) + if (senderHasLobbyCommandAdminPrivs(queue.index) && (queue.index != player)) { - sendRoomSystemMessage(astringf("Admin %s changed color of player [%d] %s to %d", + const char* msg = astringf("Admin %s changed color of player [%d] %s to %d", NetPlay.players[queue.index].name, NetPlay.players[player].position, NetPlay.players[player].name, - col).c_str()); + col).c_str(); + sendRoomSystemMessage(msg); + debug(LOG_INFO, "%s", msg); } resetReadyStatus(false, true); @@ -2859,18 +2874,20 @@ bool recvPositionRequest(NETQUEUE queue) return false; } - if (locked.position) + if (locked.position && !senderHasLobbyCommandAdminPrivs(queue.index)) { return false; } - if (senderHasLobbyCommandAdminPrivs(queue.index)) + if (senderHasLobbyCommandAdminPrivs(queue.index) && (queue.index != player || (locked.position))) { - sendRoomSystemMessage(astringf("Admin %s changed position of player [%d] %s to %d", + const char* msg = astringf("Admin %s changed position of player [%d] %s to %d", NetPlay.players[queue.index].name, NetPlay.players[player].position, NetPlay.players[player].name, - position).c_str()); + position).c_str(); + sendRoomSystemMessage(msg); + debug(LOG_INFO, "%s", msg); } resetReadyStatus(false);