Ticket #2676: 2676-patch-v2.patch
File 2676-patch-v2.patch, 1.5 KB (added by , 8 years ago) |
---|
-
source/network/NetServer.cpp
883 883 { 884 884 CSimulationMessage* simMessage = static_cast<CSimulationMessage*> (message); 885 885 886 // Ignore messages sent by one player on behalf of another player 887 // unless cheating is enabled 888 bool cheatsEnabled = false; 889 ScriptInterface& scriptInterface = server.GetScriptInterface(); 890 JSContext* cx = scriptInterface.GetContext(); 891 JSAutoRequest rq(cx); 892 JS::RootedValue settings(cx); 893 scriptInterface.GetProperty(server.m_GameAttributes.get(), "settings", &settings); 894 if (scriptInterface.HasProperty(settings, "CheatsEnabled")) 895 scriptInterface.GetProperty(settings, "CheatsEnabled", cheatsEnabled); 896 897 PlayerAssignmentMap::iterator it = server.m_PlayerAssignments.find(session->GetGUID()); 898 if (!cheatsEnabled && (it == server.m_PlayerAssignments.end() || it->second.m_PlayerID != simMessage->m_Player)) 899 return true; 900 886 901 // Send it back to all clients immediately 887 902 server.Broadcast(simMessage); 888 903 … … 891 906 server.m_SavedCommands.resize(simMessage->m_Turn + 1); 892 907 server.m_SavedCommands[simMessage->m_Turn].push_back(*simMessage); 893 908 894 // TODO: we should do some validation of ownership (clients can't send commands on behalf of opposing players)895 896 909 // TODO: we shouldn't send the message back to the client that first sent it 897 910 } 898 911 else if (message->GetType() == (uint)NMT_SYNC_CHECK)