- threading bugfixes from the client join menu

This commit is contained in:
Mark Vejvoda 2010-06-22 15:03:57 +00:00
parent 6560ba73dc
commit a05760d2a4
3 changed files with 16 additions and 12 deletions

View File

@ -45,13 +45,14 @@ const string MenuStateJoinGame::serverFileName= "servers.ini";
MenuStateJoinGame::MenuStateJoinGame(Program *program, MainMenu *mainMenu, bool connect, Ip serverIp):
MenuState(program, mainMenu, "join-game")
{
abortAutoFind = false;
autoConnectToServer = false;
Lang &lang= Lang::getInstance();
Config &config= Config::getInstance();
NetworkManager &networkManager= NetworkManager::getInstance();
networkManager.end();
networkManager.init(nrClient);
abortAutoFind = false;
serversSavedFile = serverFileName;
if(getGameReadWritePath() != "") {
serversSavedFile = getGameReadWritePath() + serversSavedFile;
@ -147,6 +148,7 @@ void MenuStateJoinGame::DiscoveredServers(std::vector<string> serverList) {
//serverList.push_back("test2");
//
autoConnectToServer = false;
buttonAutoFindServers.setEnabled(true);
if(serverList.size() > 0) {
string bestIPMatch = "";
@ -167,7 +169,7 @@ void MenuStateJoinGame::DiscoveredServers(std::vector<string> serverList) {
listBoxFoundServers.setItems(serverList);
}
else {
connectToServer();
autoConnectToServer = true;
}
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -431,6 +433,10 @@ void MenuStateJoinGame::update()
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
else if(autoConnectToServer == true) {
autoConnectToServer = false;
connectToServer();
}
if(clientInterface->getLaunchGame()) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - D\n",__FILE__,__FUNCTION__);
}

View File

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

View File

@ -1202,11 +1202,9 @@ void ClientSocket::stopBroadCastClientThread() {
if(broadCastClientThread != NULL) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
BaseThread::shutdownAndWait(broadCastClientThread);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete broadCastClientThread;
broadCastClientThread = NULL;
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
@ -1446,14 +1444,15 @@ void BroadCastClientSocketThread::execute() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
setRunningStatus(false);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"Broadcast Client thread is exiting\n");
// Here we callback into the implementer class
if(discoveredServersCB != NULL) {
discoveredServersCB->DiscoveredServers(foundServers);
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"Broadcast Client thread is exiting\n");
setRunningStatus(false);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
@ -1482,11 +1481,9 @@ void ServerSocket::stopBroadCastThread() {
if(broadCastThread != NULL) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
BaseThread::shutdownAndWait(broadCastThread);
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete broadCastThread;
broadCastThread = NULL;
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
}
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);