Browse Source

Server: add GAMEPLAY_STARTING state (#450)

Fixes issue 2962.
Karlis Senko 7 years ago
parent
commit
965b33d16a
3 changed files with 6 additions and 1 deletions
  1. 1 1
      server/CVCMIServer.cpp
  2. 1 0
      server/CVCMIServer.h
  3. 4 0
      server/NetPacksLobbyServer.cpp

+ 1 - 1
server/CVCMIServer.cpp

@@ -176,7 +176,7 @@ void CVCMIServer::run()
 		}
 	}
 
-	while(state == EServerState::LOBBY)
+	while(state == EServerState::LOBBY || state == EServerState::GAMEPLAY_STARTING)
 		boost::this_thread::sleep(boost::posix_time::milliseconds(50));
 
 	logNetwork->info("Thread handling connections ended");

+ 1 - 0
server/CVCMIServer.h

@@ -32,6 +32,7 @@ class CBaseForGHApply;
 enum class EServerState : ui8
 {
 	LOBBY,
+	GAMEPLAY_STARTING,
 	GAMEPLAY,
 	GAMEPLAY_ENDED,
 	SHUTDOWN

+ 4 - 0
server/NetPacksLobbyServer.cpp

@@ -115,6 +115,9 @@ bool LobbyChatMessage::checkClientPermissions(CVCMIServer * srv) const
 
 bool LobbySetMap::applyOnServer(CVCMIServer * srv)
 {
+	if(srv->state != EServerState::LOBBY)
+		return false;
+
 	srv->updateStartInfoOnMapChange(mapInfo, mapGenOpts);
 	return true;
 }
@@ -172,6 +175,7 @@ bool LobbyStartGame::applyOnServer(CVCMIServer * srv)
 		return false;
 	}
 	// Server will prepare gamestate and we announce StartInfo to clients
+	srv->state = EServerState::GAMEPLAY_STARTING;
 	srv->prepareToStartGame();
 	initializedStartInfo = std::make_shared<StartInfo>(*srv->gh->getStartInfo(true));
 	return true;