Ticket #3552: t3552_prevent_commands_for_others_in_rated_games_v1.patch
File t3552_prevent_commands_for_others_in_rated_games_v1.patch, 1.6 KB (added by , 8 years ago) |
---|
-
source/network/NetServer.cpp
24 24 #include "NetSession.h" 25 25 #include "NetStats.h" 26 26 #include "NetTurnManager.h" 27 27 28 28 #include "lib/external_libraries/enet.h" 29 #include "lobby/IXmppClient.h" 29 30 #include "ps/CLogger.h" 30 31 #include "ps/ConfigDB.h" 31 32 #include "scriptinterface/ScriptInterface.h" 32 33 #include "scriptinterface/ScriptRuntime.h" 33 34 #include "simulation2/Simulation2.h" … … bool CNetServerWorker::OnInGame(void* co 881 882 CNetMessage* message = (CNetMessage*)event->GetParamRef(); 882 883 if (message->GetType() == (uint)NMT_SIMULATION_COMMAND) 883 884 { 884 885 CSimulationMessage* simMessage = static_cast<CSimulationMessage*> (message); 885 886 887 // Clients may not send commands on behalf of others in rated games 888 if (g_rankedGame && server.m_PlayerAssignments[session->GetGUID()].m_PlayerID != simMessage->m_Player) 889 return true; 890 886 891 // Send it back to all clients immediately 887 892 server.Broadcast(simMessage); 888 893 889 894 // Save all the received commands 890 895 if (server.m_SavedCommands.size() < simMessage->m_Turn + 1) 891 896 server.m_SavedCommands.resize(simMessage->m_Turn + 1); 892 897 server.m_SavedCommands[simMessage->m_Turn].push_back(*simMessage); 893 898 894 // TODO: we should do some validation of ownership (clients can't send commands on behalf of opposing players)895 896 899 // TODO: we shouldn't send the message back to the client that first sent it 897 900 } 898 901 else if (message->GetType() == (uint)NMT_SYNC_CHECK) 899 902 { 900 903 CSyncCheckMessage* syncMessage = static_cast<CSyncCheckMessage*> (message);