Bugfix for tracker#: 2985599
- Added better management of UDP broadcast thread when user toggles on/off network slots.
This commit is contained in:
parent
4e12d8dbcf
commit
a5aba5cc66
|
@ -208,32 +208,42 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||
|
||||
if(buttonReturn.mouseClick(x,y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
||||
}
|
||||
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
closeUnusedSlots();
|
||||
soundRenderer.playFx(coreData.getClickSoundC());
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// Send the game settings to each client if we have at least one networked client
|
||||
if( hasNetworkGameSettings() == true &&
|
||||
needToSetChangedGameSettings == true)
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
serverInterface->setGameSettings(&gameSettings,true);
|
||||
|
||||
needToSetChangedGameSettings = false;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
||||
if(bOkToStart == true)
|
||||
{
|
||||
program->setState(new Game(program, &gameSettings));
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else if(listBoxMap.mouseClick(x, y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", mapFiles[listBoxMap.getSelectedItemIndex()].c_str());
|
||||
|
@ -329,6 +339,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
}
|
||||
}
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
||||
|
|
|
@ -181,6 +181,7 @@ protected:
|
|||
|
||||
BroadCastSocketThread *broadCastThread;
|
||||
void startBroadCastThread();
|
||||
bool isBroadCastThreadRunning();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1250,7 +1250,7 @@ void ServerSocket::stopBroadCastThread() {
|
|||
break;
|
||||
}
|
||||
sleep(100);
|
||||
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__);
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -1272,6 +1272,16 @@ void ServerSocket::startBroadCastThread() {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
bool ServerSocket::isBroadCastThreadRunning() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
bool isThreadRunning = (broadCastThread != NULL && broadCastThread->getRunningStatus() == true);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] isThreadRunning = %d\n",__FILE__,__FUNCTION__,__LINE__,isThreadRunning);
|
||||
|
||||
return isThreadRunning;
|
||||
}
|
||||
|
||||
void ServerSocket::bind(int port)
|
||||
{
|
||||
//sockaddr structure
|
||||
|
@ -1302,7 +1312,14 @@ void ServerSocket::listen(int connectionQueueSize)
|
|||
throwException(szBuf);
|
||||
}
|
||||
|
||||
startBroadCastThread();
|
||||
if(connectionQueueSize > 0) {
|
||||
if(isBroadCastThreadRunning() == false) {
|
||||
startBroadCastThread();
|
||||
}
|
||||
}
|
||||
else {
|
||||
stopBroadCastThread();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue