mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 15:11:20 +02:00
- better stability of menu navigation and threads
This commit is contained in:
@@ -60,7 +60,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
currentTechName_factionPreview="";
|
currentTechName_factionPreview="";
|
||||||
currentFactionName_factionPreview="";
|
currentFactionName_factionPreview="";
|
||||||
mapPreviewTexture=NULL;
|
mapPreviewTexture=NULL;
|
||||||
|
|
||||||
|
|
||||||
publishToMasterserverThread = NULL;
|
publishToMasterserverThread = NULL;
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
@@ -69,7 +69,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
defaultPlayerName = config.getString("NetPlayerName",Socket::getHostName().c_str());
|
defaultPlayerName = config.getString("NetPlayerName",Socket::getHostName().c_str());
|
||||||
enableFactionTexturePreview = config.getBool("FactionPreview","true");
|
enableFactionTexturePreview = config.getBool("FactionPreview","true");
|
||||||
enableMapPreview = config.getBool("MapPreview","true");
|
enableMapPreview = config.getBool("MapPreview","true");
|
||||||
|
|
||||||
showFullConsole=false;
|
showFullConsole=false;
|
||||||
|
|
||||||
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
mainMessageBox.registerGraphicComponent(containerName,"mainMessageBox");
|
||||||
@@ -133,7 +133,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
int networkHeadPos=700;
|
int networkHeadPos=700;
|
||||||
int networkPos=networkHeadPos-labelOffset;
|
int networkPos=networkHeadPos-labelOffset;
|
||||||
int xoffset=10;
|
int xoffset=10;
|
||||||
|
|
||||||
//map listBox
|
//map listBox
|
||||||
// put them all in a set, to weed out duplicates (gbm & mgm with same name)
|
// put them all in a set, to weed out duplicates (gbm & mgm with same name)
|
||||||
// will also ensure they are alphabetically listed (rather than how the OS provides them)
|
// will also ensure they are alphabetically listed (rather than how the OS provides them)
|
||||||
@@ -144,17 +144,17 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
findAll(config.getPathListForType(ptMaps), "*.mgm", results, true, false);
|
findAll(config.getPathListForType(ptMaps), "*.mgm", results, true, false);
|
||||||
copy(results.begin(), results.end(), std::inserter(allMaps, allMaps.begin()));
|
copy(results.begin(), results.end(), std::inserter(allMaps, allMaps.begin()));
|
||||||
results.clear();
|
results.clear();
|
||||||
|
|
||||||
if (allMaps.empty()) {
|
if (allMaps.empty()) {
|
||||||
throw runtime_error("No maps were found!");
|
throw runtime_error("No maps were found!");
|
||||||
}
|
}
|
||||||
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
|
copy(allMaps.begin(), allMaps.end(), std::back_inserter(results));
|
||||||
mapFiles = results;
|
mapFiles = results;
|
||||||
|
|
||||||
copy(mapFiles.begin(), mapFiles.end(), std::back_inserter(playerSortedMaps[0]));
|
copy(mapFiles.begin(), mapFiles.end(), std::back_inserter(playerSortedMaps[0]));
|
||||||
copy(playerSortedMaps[0].begin(), playerSortedMaps[0].end(), std::back_inserter(formattedPlayerSortedMaps[0]));
|
copy(playerSortedMaps[0].begin(), playerSortedMaps[0].end(), std::back_inserter(formattedPlayerSortedMaps[0]));
|
||||||
std::for_each(formattedPlayerSortedMaps[0].begin(), formattedPlayerSortedMaps[0].end(), FormatString());
|
std::for_each(formattedPlayerSortedMaps[0].begin(), formattedPlayerSortedMaps[0].end(), FormatString());
|
||||||
|
|
||||||
for ( int i = 0 ; i<mapFiles.size(); i++ )
|
for ( int i = 0 ; i<mapFiles.size(); i++ )
|
||||||
{// fetch info and put map in right list
|
{// fetch info and put map in right list
|
||||||
loadMapInfo(Map::getMapPath(mapFiles.at(i),"",false), &mapInfo, false);
|
loadMapInfo(Map::getMapPath(mapFiles.at(i),"",false), &mapInfo, false);
|
||||||
@@ -193,7 +193,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
|
|
||||||
labelMapInfo.registerGraphicComponent(containerName,"labelMapInfo");
|
labelMapInfo.registerGraphicComponent(containerName,"labelMapInfo");
|
||||||
labelMapInfo.init(xoffset+100, mapPos-labelOffset, 200, 40);
|
labelMapInfo.init(xoffset+100, mapPos-labelOffset, 200, 40);
|
||||||
|
|
||||||
// MapFilter
|
// MapFilter
|
||||||
labelMapFilter.registerGraphicComponent(containerName,"labelMapFilter");
|
labelMapFilter.registerGraphicComponent(containerName,"labelMapFilter");
|
||||||
labelMapFilter.init(xoffset+310, mapHeadPos);
|
labelMapFilter.init(xoffset+310, mapHeadPos);
|
||||||
@@ -206,7 +206,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
listBoxMapFilter.pushBackItem(intToStr(i));
|
listBoxMapFilter.pushBackItem(intToStr(i));
|
||||||
}
|
}
|
||||||
listBoxMapFilter.setSelectedItemIndex(0);
|
listBoxMapFilter.setSelectedItemIndex(0);
|
||||||
|
|
||||||
//tileset listBox
|
//tileset listBox
|
||||||
findDirs(config.getPathListForType(ptTilesets), results);
|
findDirs(config.getPathListForType(ptTilesets), results);
|
||||||
if (results.empty()) {
|
if (results.empty()) {
|
||||||
@@ -222,7 +222,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
labelTileset.registerGraphicComponent(containerName,"labelTileset");
|
labelTileset.registerGraphicComponent(containerName,"labelTileset");
|
||||||
labelTileset.init(xoffset+460, mapHeadPos);
|
labelTileset.init(xoffset+460, mapHeadPos);
|
||||||
labelTileset.setText(lang.get("Tileset"));
|
labelTileset.setText(lang.get("Tileset"));
|
||||||
|
|
||||||
|
|
||||||
//tech Tree listBox
|
//tech Tree listBox
|
||||||
findDirs(config.getPathListForType(ptTechs), results);
|
findDirs(config.getPathListForType(ptTechs), results);
|
||||||
@@ -250,7 +250,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
listBoxAllowObservers.pushBackItem(lang.get("No"));
|
listBoxAllowObservers.pushBackItem(lang.get("No"));
|
||||||
listBoxAllowObservers.pushBackItem(lang.get("Yes"));
|
listBoxAllowObservers.pushBackItem(lang.get("Yes"));
|
||||||
listBoxAllowObservers.setSelectedItemIndex(0);
|
listBoxAllowObservers.setSelectedItemIndex(0);
|
||||||
|
|
||||||
// fog - o - war
|
// fog - o - war
|
||||||
// @350 ? 300 ?
|
// @350 ? 300 ?
|
||||||
labelFogOfWar.registerGraphicComponent(containerName,"labelFogOfWar");
|
labelFogOfWar.registerGraphicComponent(containerName,"labelFogOfWar");
|
||||||
@@ -262,7 +262,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
listBoxFogOfWar.pushBackItem(lang.get("Yes"));
|
listBoxFogOfWar.pushBackItem(lang.get("Yes"));
|
||||||
listBoxFogOfWar.pushBackItem(lang.get("No"));
|
listBoxFogOfWar.pushBackItem(lang.get("No"));
|
||||||
listBoxFogOfWar.setSelectedItemIndex(0);
|
listBoxFogOfWar.setSelectedItemIndex(0);
|
||||||
|
|
||||||
// View Map At End Of Game
|
// View Map At End Of Game
|
||||||
labelEnableObserverMode.registerGraphicComponent(containerName,"labelEnableObserverMode");
|
labelEnableObserverMode.registerGraphicComponent(containerName,"labelEnableObserverMode");
|
||||||
labelEnableObserverMode.init(xoffset+460, aHeadPos, 80);
|
labelEnableObserverMode.init(xoffset+460, aHeadPos, 80);
|
||||||
@@ -358,13 +358,13 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
|
|
||||||
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
|
labelPlayerNames[i].registerGraphicComponent(containerName,"labelPlayerNames" + intToStr(i));
|
||||||
labelPlayerNames[i].init(xoffset+50,setupPos-30-i*rowHeight);
|
labelPlayerNames[i].init(xoffset+50,setupPos-30-i*rowHeight);
|
||||||
|
|
||||||
listBoxControls[i].registerGraphicComponent(containerName,"listBoxControls" + intToStr(i));
|
listBoxControls[i].registerGraphicComponent(containerName,"listBoxControls" + intToStr(i));
|
||||||
listBoxControls[i].init(xoffset+210, setupPos-30-i*rowHeight);
|
listBoxControls[i].init(xoffset+210, setupPos-30-i*rowHeight);
|
||||||
|
|
||||||
listBoxRMultiplier[i].registerGraphicComponent(containerName,"listBoxRMultiplier" + intToStr(i));
|
listBoxRMultiplier[i].registerGraphicComponent(containerName,"listBoxRMultiplier" + intToStr(i));
|
||||||
listBoxRMultiplier[i].init(xoffset+350, setupPos-30-i*rowHeight,70);
|
listBoxRMultiplier[i].init(xoffset+350, setupPos-30-i*rowHeight,70);
|
||||||
|
|
||||||
listBoxFactions[i].registerGraphicComponent(containerName,"listBoxFactions" + intToStr(i));
|
listBoxFactions[i].registerGraphicComponent(containerName,"listBoxFactions" + intToStr(i));
|
||||||
listBoxFactions[i].init(xoffset+430, setupPos-30-i*rowHeight, 150);
|
listBoxFactions[i].init(xoffset+430, setupPos-30-i*rowHeight, 150);
|
||||||
|
|
||||||
@@ -378,11 +378,11 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
labelControl.registerGraphicComponent(containerName,"labelControl");
|
labelControl.registerGraphicComponent(containerName,"labelControl");
|
||||||
labelControl.init(xoffset+210, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
labelControl.init(xoffset+210, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||||
labelControl.setText(lang.get("Control"));
|
labelControl.setText(lang.get("Control"));
|
||||||
|
|
||||||
labelRMultiplier.registerGraphicComponent(containerName,"labelRMultiplier");
|
labelRMultiplier.registerGraphicComponent(containerName,"labelRMultiplier");
|
||||||
labelRMultiplier.init(xoffset+350, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
labelRMultiplier.init(xoffset+350, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||||
//labelRMultiplier.setText(lang.get("RMultiplier"));
|
//labelRMultiplier.setText(lang.get("RMultiplier"));
|
||||||
|
|
||||||
labelFaction.registerGraphicComponent(containerName,"labelFaction");
|
labelFaction.registerGraphicComponent(containerName,"labelFaction");
|
||||||
labelFaction.init(xoffset+430, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
labelFaction.init(xoffset+430, setupPos, GraphicListBox::defW, GraphicListBox::defH, true);
|
||||||
labelFaction.setText(lang.get("Faction"));
|
labelFaction.setText(lang.get("Faction"));
|
||||||
@@ -390,12 +390,12 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
labelTeam.registerGraphicComponent(containerName,"labelTeam");
|
labelTeam.registerGraphicComponent(containerName,"labelTeam");
|
||||||
labelTeam.init(xoffset+590, setupPos, 50, GraphicListBox::defH, true);
|
labelTeam.init(xoffset+590, setupPos, 50, GraphicListBox::defH, true);
|
||||||
labelTeam.setText(lang.get("Team"));
|
labelTeam.setText(lang.get("Team"));
|
||||||
|
|
||||||
labelControl.setFont(CoreData::getInstance().getMenuFontBig());
|
labelControl.setFont(CoreData::getInstance().getMenuFontBig());
|
||||||
labelRMultiplier.setFont(CoreData::getInstance().getMenuFontBig());
|
labelRMultiplier.setFont(CoreData::getInstance().getMenuFontBig());
|
||||||
labelFaction.setFont(CoreData::getInstance().getMenuFontBig());
|
labelFaction.setFont(CoreData::getInstance().getMenuFontBig());
|
||||||
labelTeam.setFont(CoreData::getInstance().getMenuFontBig());
|
labelTeam.setFont(CoreData::getInstance().getMenuFontBig());
|
||||||
|
|
||||||
//texts
|
//texts
|
||||||
buttonReturn.setText(lang.get("Return"));
|
buttonReturn.setText(lang.get("Return"));
|
||||||
buttonPlayNow.setText(lang.get("PlayNow"));
|
buttonPlayNow.setText(lang.get("PlayNow"));
|
||||||
@@ -408,11 +408,11 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
controlItems.push_back(lang.get("CpuMega"));
|
controlItems.push_back(lang.get("CpuMega"));
|
||||||
controlItems.push_back(lang.get("Network"));
|
controlItems.push_back(lang.get("Network"));
|
||||||
controlItems.push_back(lang.get("Human"));
|
controlItems.push_back(lang.get("Human"));
|
||||||
|
|
||||||
for(int i=0; i<45; ++i){
|
for(int i=0; i<45; ++i){
|
||||||
rMultiplier.push_back(floatToStr(0.5f+0.1f*i,1));
|
rMultiplier.push_back(floatToStr(0.5f+0.1f*i,1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config.getBool("EnableNetworkCpu","false") == true) {
|
if(config.getBool("EnableNetworkCpu","false") == true) {
|
||||||
controlItems.push_back(lang.get("NetworkCpuEasy"));
|
controlItems.push_back(lang.get("NetworkCpuEasy"));
|
||||||
controlItems.push_back(lang.get("NetworkCpu"));
|
controlItems.push_back(lang.get("NetworkCpu"));
|
||||||
@@ -459,7 +459,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
|
|
||||||
|
|
||||||
labelEnableObserverMode.setText(lang.get("EnableObserverMode"));
|
labelEnableObserverMode.setText(lang.get("EnableObserverMode"));
|
||||||
|
|
||||||
|
|
||||||
loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo, true);
|
loadMapInfo(Map::getMapPath(getCurrentMapFile()), &mapInfo, true);
|
||||||
|
|
||||||
@@ -498,7 +498,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||||||
|
|
||||||
// write hint to console:
|
// write hint to console:
|
||||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
|
|
||||||
console.addLine(lang.get("To switch off music press")+" - \""+configKeys.getCharKey("ToggleMusic")+"\"");
|
console.addLine(lang.get("To switch off music press")+" - \""+configKeys.getCharKey("ToggleMusic")+"\"");
|
||||||
|
|
||||||
//chatManager.init(&console, world.getThisTeamIndex());
|
//chatManager.init(&console, world.getThisTeamIndex());
|
||||||
@@ -520,24 +520,31 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
|||||||
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(publishToMasterserverThreadInDeletion == false) {
|
if(publishToMasterserverThreadInDeletion == false) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
MutexSafeWrapper safeMutexPtr(&publishToMasterserverThreadPtrChangeAccessor);
|
MutexSafeWrapper safeMutexPtr(&publishToMasterserverThreadPtrChangeAccessor);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
if(publishToMasterserverThread != NULL) {
|
if(publishToMasterserverThread != NULL) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
needToBroadcastServerSettings = false;
|
needToBroadcastServerSettings = false;
|
||||||
needToRepublishToMasterserver = false;
|
needToRepublishToMasterserver = false;
|
||||||
|
|
||||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
publishToMasterserverThread = NULL;
|
|
||||||
publishToMasterserverThreadInDeletion = false;
|
publishToMasterserverThreadInDeletion = false;
|
||||||
safeMutexPtr.ReleaseLock();
|
safeMutexPtr.ReleaseLock();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
safeMutexPtr.ReleaseLock();
|
safeMutexPtr.ReleaseLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -562,8 +569,9 @@ void MenuStateCustomGame::returnToParentMenu(){
|
|||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
publishToMasterserverThread = NULL;
|
|
||||||
publishToMasterserverThreadInDeletion = false;
|
publishToMasterserverThreadInDeletion = false;
|
||||||
safeMutexPtr.ReleaseLock();
|
safeMutexPtr.ReleaseLock();
|
||||||
|
|
||||||
@@ -614,8 +622,9 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
publishToMasterserverThread = NULL;
|
|
||||||
publishToMasterserverThreadInDeletion = false;
|
publishToMasterserverThreadInDeletion = false;
|
||||||
safeMutexPtr.ReleaseLock();
|
safeMutexPtr.ReleaseLock();
|
||||||
|
|
||||||
@@ -724,7 +733,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
*/
|
*/
|
||||||
else if(listBoxTileset.mouseClick(x, y)){
|
else if(listBoxTileset.mouseClick(x, y)){
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
|
|
||||||
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
if(listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||||
needToRepublishToMasterserver = true;
|
needToRepublishToMasterserver = true;
|
||||||
}
|
}
|
||||||
@@ -804,13 +813,13 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
else {
|
else {
|
||||||
for(int i=0; i<mapInfo.players; ++i) {
|
for(int i=0; i<mapInfo.players; ++i) {
|
||||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||||
|
|
||||||
if (listBoxAdvanced.getSelectedItemIndex() == 1) {
|
if (listBoxAdvanced.getSelectedItemIndex() == 1) {
|
||||||
// set multiplier
|
// set multiplier
|
||||||
if(listBoxRMultiplier[i].mouseClick(x, y)) {
|
if(listBoxRMultiplier[i].mouseClick(x, y)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure thet only 1 human player is present
|
//ensure thet only 1 human player is present
|
||||||
if(listBoxControls[i].mouseClick(x, y)) {
|
if(listBoxControls[i].mouseClick(x, y)) {
|
||||||
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__);
|
||||||
@@ -964,7 +973,7 @@ void MenuStateCustomGame::RestoreLastGameSettings() {
|
|||||||
|
|
||||||
loadGameSettings(&gameSettings);
|
loadGameSettings(&gameSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
serverInterface->setGameSettings(&gameSettings,false);
|
serverInterface->setGameSettings(&gameSettings,false);
|
||||||
|
|
||||||
@@ -1127,8 +1136,9 @@ void MenuStateCustomGame::PlayNow() {
|
|||||||
if(publishToMasterserverThread != NULL &&
|
if(publishToMasterserverThread != NULL &&
|
||||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||||
delete publishToMasterserverThread;
|
delete publishToMasterserverThread;
|
||||||
|
publishToMasterserverThread = NULL;
|
||||||
}
|
}
|
||||||
publishToMasterserverThread = NULL;
|
|
||||||
publishToMasterserverThreadInDeletion = false;
|
publishToMasterserverThreadInDeletion = false;
|
||||||
safeMutexPtr.ReleaseLock();
|
safeMutexPtr.ReleaseLock();
|
||||||
|
|
||||||
@@ -1261,11 +1271,11 @@ void MenuStateCustomGame::render() {
|
|||||||
renderer.renderLabel(&labelPlayerNames[i]);
|
renderer.renderLabel(&labelPlayerNames[i]);
|
||||||
|
|
||||||
renderer.renderListBox(&listBoxControls[i]);
|
renderer.renderListBox(&listBoxControls[i]);
|
||||||
|
|
||||||
if(listBoxControls[i].getSelectedItemIndex()!=ctClosed){
|
if(listBoxControls[i].getSelectedItemIndex()!=ctClosed){
|
||||||
if(listBoxRMultiplier[i].getEnabled() && (listBoxAdvanced.getSelectedItemIndex() == 1)){
|
if(listBoxRMultiplier[i].getEnabled() && (listBoxAdvanced.getSelectedItemIndex() == 1)){
|
||||||
renderer.renderListBox(&listBoxRMultiplier[i]);
|
renderer.renderListBox(&listBoxRMultiplier[i]);
|
||||||
}
|
}
|
||||||
renderer.renderListBox(&listBoxFactions[i]);
|
renderer.renderListBox(&listBoxFactions[i]);
|
||||||
renderer.renderListBox(&listBoxTeams[i]);
|
renderer.renderListBox(&listBoxTeams[i]);
|
||||||
renderer.renderLabel(&labelNetStatus[i]);
|
renderer.renderLabel(&labelNetStatus[i]);
|
||||||
@@ -1294,13 +1304,13 @@ void MenuStateCustomGame::render() {
|
|||||||
renderer.renderLabel(&labelTeam);
|
renderer.renderLabel(&labelTeam);
|
||||||
renderer.renderLabel(&labelMapInfo);
|
renderer.renderLabel(&labelMapInfo);
|
||||||
renderer.renderLabel(&labelAdvanced);
|
renderer.renderLabel(&labelAdvanced);
|
||||||
|
|
||||||
renderer.renderListBox(&listBoxMap);
|
renderer.renderListBox(&listBoxMap);
|
||||||
renderer.renderListBox(&listBoxTileset);
|
renderer.renderListBox(&listBoxTileset);
|
||||||
renderer.renderListBox(&listBoxMapFilter);
|
renderer.renderListBox(&listBoxMapFilter);
|
||||||
renderer.renderListBox(&listBoxTechTree);
|
renderer.renderListBox(&listBoxTechTree);
|
||||||
renderer.renderListBox(&listBoxAdvanced);
|
renderer.renderListBox(&listBoxAdvanced);
|
||||||
|
|
||||||
|
|
||||||
if(listBoxPublishServer.getEditable())
|
if(listBoxPublishServer.getEditable())
|
||||||
{
|
{
|
||||||
@@ -1339,7 +1349,7 @@ void MenuStateCustomGame::render() {
|
|||||||
renderer.renderMapPreview(&mapPreview, renderAll, 10, 350);
|
renderer.renderMapPreview(&mapPreview, renderAll, 10, 350);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.renderChatManager(&chatManager);
|
renderer.renderChatManager(&chatManager);
|
||||||
renderer.renderConsole(&console,showFullConsole,true);
|
renderer.renderConsole(&console,showFullConsole,true);
|
||||||
}
|
}
|
||||||
@@ -1383,7 +1393,7 @@ void MenuStateCustomGame::update() {
|
|||||||
bool hasOneNetworkSlotOpen = false;
|
bool hasOneNetworkSlotOpen = false;
|
||||||
int currentConnectionCount=0;
|
int currentConnectionCount=0;
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
|
|
||||||
bool masterServerErr = showMasterserverError;
|
bool masterServerErr = showMasterserverError;
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
@@ -1411,7 +1421,7 @@ void MenuStateCustomGame::update() {
|
|||||||
mainMessageBoxState=1;
|
mainMessageBoxState=1;
|
||||||
showMessageBox( generalErrorToShow, "Error", false);
|
showMessageBox( generalErrorToShow, "Error", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 0) chrono.start();
|
||||||
|
|
||||||
@@ -1427,7 +1437,7 @@ void MenuStateCustomGame::update() {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] switchSetupRequests[i]->getToFactionIndex() = %d\n",__FILE__,__FUNCTION__,__LINE__,switchSetupRequests[i]->getToFactionIndex());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] switchSetupRequests[i]->getToFactionIndex() = %d\n",__FILE__,__FUNCTION__,__LINE__,switchSetupRequests[i]->getToFactionIndex());
|
||||||
//printf("switchSetupRequests[i]->getSelectedFactionName()=%s\n",switchSetupRequests[i]->getSelectedFactionName().c_str());
|
//printf("switchSetupRequests[i]->getSelectedFactionName()=%s\n",switchSetupRequests[i]->getSelectedFactionName().c_str());
|
||||||
//printf("switchSetupRequests[i]->getToTeam()=%d\n",switchSetupRequests[i]->getToTeam());
|
//printf("switchSetupRequests[i]->getToTeam()=%d\n",switchSetupRequests[i]->getToTeam());
|
||||||
|
|
||||||
if(switchSetupRequests[i]->getToFactionIndex() != -1) {
|
if(switchSetupRequests[i]->getToFactionIndex() != -1) {
|
||||||
int newFactionIdx = switchSetupRequests[i]->getToFactionIndex();
|
int newFactionIdx = switchSetupRequests[i]->getToFactionIndex();
|
||||||
/*
|
/*
|
||||||
@@ -1493,7 +1503,7 @@ void MenuStateCustomGame::update() {
|
|||||||
switchSetupRequests[i]=NULL;
|
switchSetupRequests[i]=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 0) chrono.start();
|
||||||
|
|
||||||
@@ -1507,7 +1517,7 @@ void MenuStateCustomGame::update() {
|
|||||||
|
|
||||||
ConnectionSlot* connectionSlot= serverInterface->getSlot(i);
|
ConnectionSlot* connectionSlot= serverInterface->getSlot(i);
|
||||||
//assert(connectionSlot!=NULL);
|
//assert(connectionSlot!=NULL);
|
||||||
|
|
||||||
//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__);
|
||||||
|
|
||||||
hasOneNetworkSlotOpen=true;
|
hasOneNetworkSlotOpen=true;
|
||||||
@@ -1667,7 +1677,7 @@ void MenuStateCustomGame::update() {
|
|||||||
serverInterface->setGameSettings(&gameSettings,false);
|
serverInterface->setGameSettings(&gameSettings,false);
|
||||||
needToSetChangedGameSettings = false;
|
needToSetChangedGameSettings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(chrono.getMillis() > 0) chrono.start();
|
if(chrono.getMillis() > 0) chrono.start();
|
||||||
|
|
||||||
@@ -1684,7 +1694,7 @@ void MenuStateCustomGame::update() {
|
|||||||
listBoxPublishServer.setEditable(false);
|
listBoxPublishServer.setEditable(false);
|
||||||
//listBoxEnableServerControlledAI.setEditable(false);
|
//listBoxEnableServerControlledAI.setEditable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool republishToMaster = (difftime(time(NULL),lastMasterserverPublishing) >= 5);
|
bool republishToMaster = (difftime(time(NULL),lastMasterserverPublishing) >= 5);
|
||||||
|
|
||||||
if(republishToMaster == true) {
|
if(republishToMaster == true) {
|
||||||
@@ -1707,7 +1717,7 @@ void MenuStateCustomGame::update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool broadCastSettings = (difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
bool broadCastSettings = (difftime(time(NULL),lastSetChangedGameSettings) >= 2);
|
||||||
|
|
||||||
if(broadCastSettings == true) {
|
if(broadCastSettings == true) {
|
||||||
needToBroadcastServerSettings=true;
|
needToBroadcastServerSettings=true;
|
||||||
}
|
}
|
||||||
@@ -1815,13 +1825,13 @@ void MenuStateCustomGame::publishToMasterserver()
|
|||||||
if((connectionSlot!=NULL) && (connectionSlot->isConnected()))
|
if((connectionSlot!=NULL) && (connectionSlot->isConnected()))
|
||||||
{
|
{
|
||||||
slotCountConnectedPlayers++;
|
slotCountConnectedPlayers++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(listBoxControls[i].getSelectedItemIndex() == ctHuman)
|
else if(listBoxControls[i].getSelectedItemIndex() == ctHuman)
|
||||||
{
|
{
|
||||||
slotCountHumans++;
|
slotCountHumans++;
|
||||||
slotCountConnectedPlayers++;
|
slotCountConnectedPlayers++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//?status=waiting&system=linux&info=titus
|
//?status=waiting&system=linux&info=titus
|
||||||
@@ -1877,6 +1887,11 @@ void MenuStateCustomGame::simpleTask() {
|
|||||||
bool needPing = (difftime(time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval);
|
bool needPing = (difftime(time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
if( publishToMasterserverThread == NULL ||
|
||||||
|
publishToMasterserverThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(republish == true) {
|
if(republish == true) {
|
||||||
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__);
|
||||||
|
|
||||||
@@ -1898,7 +1913,7 @@ void MenuStateCustomGame::simpleTask() {
|
|||||||
|
|
||||||
std::string serverInfo = SystemFlags::getHTTP(request,handle);
|
std::string serverInfo = SystemFlags::getHTTP(request,handle);
|
||||||
SystemFlags::cleanupHTTP(&handle);
|
SystemFlags::cleanupHTTP(&handle);
|
||||||
|
|
||||||
//printf("the result is:\n'%s'\n",serverInfo.c_str());
|
//printf("the result is:\n'%s'\n",serverInfo.c_str());
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the result is:\n'%s'\n",__FILE__,__FUNCTION__,__LINE__,serverInfo.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] the result is:\n'%s'\n",__FILE__,__FUNCTION__,__LINE__,serverInfo.c_str());
|
||||||
|
|
||||||
@@ -1911,6 +1926,11 @@ void MenuStateCustomGame::simpleTask() {
|
|||||||
|
|
||||||
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( publishToMasterserverThread == NULL ||
|
||||||
|
publishToMasterserverThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(broadCastSettings) {
|
if(broadCastSettings) {
|
||||||
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__);
|
||||||
|
|
||||||
@@ -1938,6 +1958,11 @@ void MenuStateCustomGame::simpleTask() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( publishToMasterserverThread == NULL ||
|
||||||
|
publishToMasterserverThread->getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(needPing == true) {
|
if(needPing == true) {
|
||||||
lastNetworkPing = time(NULL);
|
lastNetworkPing = time(NULL);
|
||||||
|
|
||||||
@@ -2107,7 +2132,7 @@ void MenuStateCustomGame::saveGameSettingsToFile(std::string fileName) {
|
|||||||
//ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
//ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
|
|
||||||
saveGameFile << "Description=" << gameSettings.getDescription() << std::endl;
|
saveGameFile << "Description=" << gameSettings.getDescription() << std::endl;
|
||||||
|
|
||||||
saveGameFile << "MapFilterIndex=" << gameSettings.getMapFilterIndex() << std::endl;
|
saveGameFile << "MapFilterIndex=" << gameSettings.getMapFilterIndex() << std::endl;
|
||||||
saveGameFile << "Map=" << gameSettings.getMap() << std::endl;
|
saveGameFile << "Map=" << gameSettings.getMap() << std::endl;
|
||||||
saveGameFile << "Tileset=" << gameSettings.getTileset() << std::endl;
|
saveGameFile << "Tileset=" << gameSettings.getTileset() << std::endl;
|
||||||
@@ -2175,7 +2200,7 @@ GameSettings MenuStateCustomGame::loadGameSettingsFromFile(std::string fileName)
|
|||||||
gameSettings.setDefaultVictoryConditions(properties.getBool("DefaultVictoryConditions"));
|
gameSettings.setDefaultVictoryConditions(properties.getBool("DefaultVictoryConditions"));
|
||||||
gameSettings.setFogOfWar(properties.getBool("FogOfWar"));
|
gameSettings.setFogOfWar(properties.getBool("FogOfWar"));
|
||||||
listBoxAdvanced.setSelectedItemIndex(properties.getInt("AdvancedIndex","0"));
|
listBoxAdvanced.setSelectedItemIndex(properties.getInt("AdvancedIndex","0"));
|
||||||
|
|
||||||
gameSettings.setAllowObservers(properties.getBool("AllowObservers","false"));
|
gameSettings.setAllowObservers(properties.getBool("AllowObservers","false"));
|
||||||
|
|
||||||
gameSettings.setEnableObserverModeAtEndGame(properties.getBool("EnableObserverModeAtEndGame"));
|
gameSettings.setEnableObserverModeAtEndGame(properties.getBool("EnableObserverModeAtEndGame"));
|
||||||
@@ -2583,7 +2608,7 @@ void MenuStateCustomGame::keyDown(char key) {
|
|||||||
else if(key == configKeys.getCharKey("ToggleMusic")) {
|
else if(key == configKeys.getCharKey("ToggleMusic")) {
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
|
||||||
float configVolume = (config.getInt("SoundVolumeMusic") / 100.f);
|
float configVolume = (config.getInt("SoundVolumeMusic") / 100.f);
|
||||||
float currentVolume = CoreData::getInstance().getMenuMusic()->getVolume();
|
float currentVolume = CoreData::getInstance().getMenuMusic()->getVolume();
|
||||||
if(currentVolume > 0) {
|
if(currentVolume > 0) {
|
||||||
@@ -2669,7 +2694,7 @@ void MenuStateCustomGame::switchToNextMapGroup(const int direction){
|
|||||||
// if there are no maps for the current selection we switch to next selection
|
// if there are no maps for the current selection we switch to next selection
|
||||||
while(formattedPlayerSortedMaps[i].empty()){
|
while(formattedPlayerSortedMaps[i].empty()){
|
||||||
i=i+direction;
|
i=i+direction;
|
||||||
if(i>GameConstants::maxPlayers){
|
if(i>GameConstants::maxPlayers){
|
||||||
i=0;
|
i=0;
|
||||||
}
|
}
|
||||||
if(i<0){
|
if(i<0){
|
||||||
|
@@ -142,7 +142,7 @@ bool BaseThread::shutdownAndWait() {
|
|||||||
|
|
||||||
int maxWaitSeconds = 7;
|
int maxWaitSeconds = 7;
|
||||||
if(pThread->canShutdown() == false) {
|
if(pThread->canShutdown() == false) {
|
||||||
maxWaitSeconds = 3;
|
maxWaitSeconds = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= maxWaitSeconds; ) {
|
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= maxWaitSeconds; ) {
|
||||||
|
Reference in New Issue
Block a user