Ver Fonte

Set matches that never reached gameplay state to 'cancelled' state

Ivan Savenko há 1 ano atrás
pai
commit
89d091a386
3 ficheiros alterados com 21 adições e 9 exclusões
  1. 1 1
      Mods/vcmi/config/vcmi/english.json
  2. 10 4
      lobby/LobbyDatabase.cpp
  3. 10 4
      lobby/LobbyServer.cpp

+ 1 - 1
Mods/vcmi/config/vcmi/english.json

@@ -82,7 +82,7 @@
 	"vcmi.lobby.header.rooms" : "Game Rooms - %d",
 	"vcmi.lobby.header.channels" : "Chat Channels",
 	"vcmi.lobby.header.chat.global" : "Global Game Chat - %s", // %s -> language name
-	"vcmi.lobby.header.chat.match" : "Previous game chat from %s", // %s -> game start date & time
+	"vcmi.lobby.header.chat.match" : "Chat from previous game on %s", // %s -> game start date & time
 	"vcmi.lobby.header.chat.player" : "Private chat with %s", // %s -> nickname of another player
 	"vcmi.lobby.header.history" : "Your Previous Games",
 	"vcmi.lobby.header.players" : "Players Online - %d",

+ 10 - 4
lobby/LobbyDatabase.cpp

@@ -90,14 +90,20 @@ void LobbyDatabase::clearOldData()
 	)";
 
 	//FIXME: set different status for rooms that never reached in game state
-	static const std::string removeActiveRooms = R"(
+	static const std::string removeActiveLobbyRooms = R"(
+		UPDATE gameRooms
+		SET status = 4
+		WHERE status IN (0,1,2)
+	)";
+	static const std::string removeActiveGameRooms = R"(
 		UPDATE gameRooms
 		SET status = 5
-		WHERE status <> 5
+		WHERE status = 3
 	)";
 
 	database->prepare(removeActiveAccounts)->execute();
-	database->prepare(removeActiveRooms)->execute();
+	database->prepare(removeActiveLobbyRooms)->execute();
+	database->prepare(removeActiveGameRooms)->execute();
 }
 
 void LobbyDatabase::prepareStatements()
@@ -209,7 +215,7 @@ void LobbyDatabase::prepareStatements()
 		FROM gameRoomPlayers grp
 		LEFT JOIN gameRooms gr ON gr.roomID = grp.roomID
 		LEFT JOIN accounts a ON gr.hostAccountID = a.accountID
-		WHERE grp.accountID = ? AND status IN (4,5)
+		WHERE grp.accountID = ? AND status = 5
 		ORDER BY secondsElapsed ASC
 	)");
 

+ 10 - 4
lobby/LobbyServer.cpp

@@ -283,11 +283,17 @@ void LobbyServer::onDisconnected(const NetworkConnectionPtr & connection, const
 	if(activeGameRooms.count(connection))
 	{
 		std::string gameRoomID = activeGameRooms.at(connection);
-		database->setGameRoomStatus(gameRoomID, LobbyRoomState::CLOSED);
 
-		for(const auto & accountConnection : activeAccounts)
-			if (database->isPlayerInGameRoom(accountConnection.second, gameRoomID))
-				sendMatchesHistory(accountConnection.first);
+		if (database->getGameRoomStatus(gameRoomID) == LobbyRoomState::BUSY)
+		{
+			database->setGameRoomStatus(gameRoomID, LobbyRoomState::CLOSED);
+			for(const auto & accountConnection : activeAccounts)
+				if (database->isPlayerInGameRoom(accountConnection.second, gameRoomID))
+					sendMatchesHistory(accountConnection.first);
+		}
+		else
+			database->setGameRoomStatus(gameRoomID, LobbyRoomState::CANCELLED);
+
 		activeGameRooms.erase(connection);
 	}