diff --git a/client/NetPacksClient.cpp b/client/NetPacksClient.cpp index 5d618b8c1..c4113e154 100644 --- a/client/NetPacksClient.cpp +++ b/client/NetPacksClient.cpp @@ -818,7 +818,11 @@ void YourTurn::applyCl(CClient *cl) void SaveGameClient::applyCl(CClient *cl) { const auto stem = FileInfo::GetPathStem(fname); - CResourceHandler::get("local")->createResource(stem.to_string() + ".vcgm1"); + if(!CResourceHandler::get("local")->createResource(stem.to_string() + ".vcgm1")) + { + logNetwork->error("Failed to create resource %s", stem.to_string() + ".vcgm1"); + return; + } try { diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 69d796ec6..994017869 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -5014,6 +5014,55 @@ void CGameHandler::playerMessage(PlayerColor player, const std::string &message, std::vector cheat; boost::split(cheat, message, boost::is_any_of(" ")); + + bool isHost = false; + for(auto & c : connections[player]) + if(lobby->isClientHost(c->connectionID)) + isHost = true; + + if(isHost && cheat.size() >= 2 && cheat[0] == "game") + { + if(cheat[1] == "exit" || cheat[1] == "quit" || cheat[1] == "end") + { + SystemMessage temp_message("game was terminated"); + sendAndApply(&temp_message); + lobby->state = EServerState::SHUTDOWN; + return; + } + if(cheat.size() == 3 && cheat[1] == "save") + { + save("Saves/" + cheat[2]); + SystemMessage temp_message("game saved as " + cheat[2]); + sendAndApply(&temp_message); + return; + } + if(cheat.size() == 3 && cheat[1] == "kick") + { + auto playername = cheat[2]; + PlayerColor playerToKick(PlayerColor::CANNOT_DETERMINE); + if(std::all_of(playername.begin(), playername.end(), ::isdigit)) + playerToKick = PlayerColor(std::stoi(playername)); + else + { + for(auto & c : connections) + { + if(c.first.getStr(false) == playername) + playerToKick = c.first; + } + } + + if(playerToKick != PlayerColor::CANNOT_DETERMINE) + { + PlayerCheated pc; + pc.player = playerToKick; + pc.losingCheatCode = true; + sendAndApply(&pc); + checkVictoryLossConditionsForPlayer(playerToKick); + } + return; + } + } + int obj = 0; if (cheat.size() == 2) {