- added some bugfixes related to timing ans corrupt state in network and regular game menus

This commit is contained in:
Mark Vejvoda
2010-05-13 21:47:14 +00:00
parent 036cc5e0f3
commit a585a6663f
3 changed files with 20 additions and 4 deletions

View File

@@ -219,6 +219,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
} }
MenuStateCustomGame::~MenuStateCustomGame() { MenuStateCustomGame::~MenuStateCustomGame() {
needToBroadcastServerSettings = false;
needToRepublishToMasterserver = false;
BaseThread::shutdownAndWait(publishToMasterserverThread); BaseThread::shutdownAndWait(publishToMasterserverThread);
delete publishToMasterserverThread; delete publishToMasterserverThread;
publishToMasterserverThread = NULL; publishToMasterserverThread = NULL;
@@ -245,6 +247,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
} }
*/ */
needToBroadcastServerSettings = false;
needToRepublishToMasterserver = false;
BaseThread::shutdownAndWait(publishToMasterserverThread); BaseThread::shutdownAndWait(publishToMasterserverThread);
mainMenu->setState(new MenuStateNewGame(program, mainMenu)); mainMenu->setState(new MenuStateNewGame(program, mainMenu));
} }
@@ -284,6 +288,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
publishToMasterserver(); publishToMasterserver();
simpleTask(); simpleTask();
} }
needToBroadcastServerSettings = false;
needToRepublishToMasterserver = false;
BaseThread::shutdownAndWait(publishToMasterserverThread); BaseThread::shutdownAndWait(publishToMasterserverThread);
program->setState(new Game(program, &gameSettings)); program->setState(new Game(program, &gameSettings));
} }

View File

@@ -49,6 +49,8 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
Config &config= Config::getInstance(); Config &config= Config::getInstance();
NetworkManager &networkManager= NetworkManager::getInstance(); NetworkManager &networkManager= NetworkManager::getInstance();
networkManager.end(); networkManager.end();
networkManager.init(nrClient);
abortAutoFind = false;
serversSavedFile = serverFileName; serversSavedFile = serverFileName;
if(getGameReadWritePath() != "") { if(getGameReadWritePath() != "") {
@@ -114,7 +116,6 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
labelInfo.init(330, 370); labelInfo.init(330, 370);
labelInfo.setText(""); labelInfo.setText("");
networkManager.init(nrClient);
connected= false; connected= false;
playerIndex= -1; playerIndex= -1;
@@ -132,14 +133,15 @@ MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool
chatManager.init(&console, -1); chatManager.init(&console, -1);
} }
MenuStateJoinGame::~MenuStateJoinGame() { MenuStateJoinGame::~MenuStateJoinGame() {
NetworkManager &networkManager= NetworkManager::getInstance(); abortAutoFind = true;
ClientInterface* clientInterface= networkManager.getClientInterface();
clientInterface->stopServerDiscovery();
} }
void MenuStateJoinGame::DiscoveredServers(std::vector<string> serverList) { void MenuStateJoinGame::DiscoveredServers(std::vector<string> serverList) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(abortAutoFind == true) {
return;
}
// Testing multi-server // Testing multi-server
//serverList.push_back("test1"); //serverList.push_back("test1");
//serverList.push_back("test2"); //serverList.push_back("test2");
@@ -205,6 +207,8 @@ void MenuStateJoinGame::mouseClick(int x, int y, MouseButton mouseButton)
{ {
soundRenderer.playFx(coreData.getClickSoundA()); soundRenderer.playFx(coreData.getClickSoundA());
clientInterface->stopServerDiscovery();
if(clientInterface->getSocket() != NULL) if(clientInterface->getSocket() != NULL)
{ {
if(clientInterface->isConnected() == true) if(clientInterface->isConnected() == true)
@@ -214,6 +218,7 @@ void MenuStateJoinGame::mouseClick(int x, int y, MouseButton mouseButton)
} }
clientInterface->close(); clientInterface->close();
} }
abortAutoFind = true;
mainMenu->setState(new MenuStateRoot(program, mainMenu)); mainMenu->setState(new MenuStateRoot(program, mainMenu));
} }
@@ -417,6 +422,8 @@ void MenuStateJoinGame::update()
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - B\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - B\n",__FILE__,__FUNCTION__);
abortAutoFind = true;
clientInterface->stopServerDiscovery();
program->setState(new Game(program, clientInterface->getGameSettings())); program->setState(new Game(program, clientInterface->getGameSettings()));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - C\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - C\n",__FILE__,__FUNCTION__);
@@ -508,6 +515,8 @@ void MenuStateJoinGame::connectToServer()
config.setString("ServerIp", serverIp.getString()); config.setString("ServerIp", serverIp.getString());
config.save(); config.save();
abortAutoFind = true;
clientInterface->stopServerDiscovery();
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu)); mainMenu->setState(new MenuStateConnectedGame(program, mainMenu));
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__);

View File

@@ -59,6 +59,7 @@ private:
ChatManager chatManager; ChatManager chatManager;
string serversSavedFile; string serversSavedFile;
bool abortAutoFind;
public: public:
MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool connect= false, Ip serverIp= Ip()); MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool connect= false, Ip serverIp= Ip());