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();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
|
||||||
if(buttonReturn.mouseClick(x,y)){
|
if(buttonReturn.mouseClick(x,y)){
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
mainMenu->setState(new MenuStateNewGame(program, mainMenu));
|
||||||
}
|
}
|
||||||
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
else if(buttonPlayNow.mouseClick(x,y) && buttonPlayNow.getEnabled()) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
closeUnusedSlots();
|
closeUnusedSlots();
|
||||||
soundRenderer.playFx(coreData.getClickSoundC());
|
soundRenderer.playFx(coreData.getClickSoundC());
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
loadGameSettings(&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
|
// Send the game settings to each client if we have at least one networked client
|
||||||
if( hasNetworkGameSettings() == true &&
|
if( hasNetworkGameSettings() == true &&
|
||||||
needToSetChangedGameSettings == true)
|
needToSetChangedGameSettings == true)
|
||||||
{
|
{
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
serverInterface->setGameSettings(&gameSettings,true);
|
serverInterface->setGameSettings(&gameSettings,true);
|
||||||
|
|
||||||
needToSetChangedGameSettings = false;
|
needToSetChangedGameSettings = false;
|
||||||
lastSetChangedGameSettings = time(NULL);
|
lastSetChangedGameSettings = time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
||||||
if(bOkToStart == true)
|
if(bOkToStart == true)
|
||||||
{
|
{
|
||||||
program->setState(new Game(program, &gameSettings));
|
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)){
|
else if(listBoxMap.mouseClick(x, y)){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n", mapFiles[listBoxMap.getSelectedItemIndex()].c_str());
|
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){
|
void MenuStateCustomGame::mouseMove(int x, int y, const MouseState *ms){
|
||||||
|
|
|
@ -181,6 +181,7 @@ protected:
|
||||||
|
|
||||||
BroadCastSocketThread *broadCastThread;
|
BroadCastSocketThread *broadCastThread;
|
||||||
void startBroadCastThread();
|
void startBroadCastThread();
|
||||||
|
bool isBroadCastThreadRunning();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1250,7 +1250,7 @@ void ServerSocket::stopBroadCastThread() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sleep(100);
|
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__);
|
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__);
|
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)
|
void ServerSocket::bind(int port)
|
||||||
{
|
{
|
||||||
//sockaddr structure
|
//sockaddr structure
|
||||||
|
@ -1302,7 +1312,14 @@ void ServerSocket::listen(int connectionQueueSize)
|
||||||
throwException(szBuf);
|
throwException(szBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
startBroadCastThread();
|
if(connectionQueueSize > 0) {
|
||||||
|
if(isBroadCastThreadRunning() == false) {
|
||||||
|
startBroadCastThread();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stopBroadCastThread();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue