- attempt to fix masterserver losing publish setting and/or open network slot
- attempt to fix high cpu usage on masterserver (and clients) when waiting for others during the start of a network game
This commit is contained in:
parent
252080b3b0
commit
8050e25538
|
@ -375,7 +375,8 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
|
||||||
listBoxPublishServer.init(50, networkPos, 100);
|
listBoxPublishServer.init(50, networkPos, 100);
|
||||||
listBoxPublishServer.pushBackItem(lang.get("Yes"));
|
listBoxPublishServer.pushBackItem(lang.get("Yes"));
|
||||||
listBoxPublishServer.pushBackItem(lang.get("No"));
|
listBoxPublishServer.pushBackItem(lang.get("No"));
|
||||||
if(openNetworkSlots && parentMenuState!=pLanGame) {
|
if(this->masterserverMode == true ||
|
||||||
|
(openNetworkSlots == true && parentMenuState != pLanGame)) {
|
||||||
listBoxPublishServer.setSelectedItemIndex(0);
|
listBoxPublishServer.setSelectedItemIndex(0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1999,7 +2000,9 @@ void MenuStateCustomGame::update() {
|
||||||
mainMessageBoxState=1;
|
mainMessageBoxState=1;
|
||||||
showMessageBox( masterServererErrorToShow, lang.get("ErrorFromMasterserver"), false);
|
showMessageBox( masterServererErrorToShow, lang.get("ErrorFromMasterserver"), false);
|
||||||
|
|
||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
if(this->masterserverMode == false) {
|
||||||
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
ServerInterface* serverInterface= NetworkManager::getInstance().getServerInterface();
|
||||||
serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0);
|
serverInterface->setPublishEnabled(listBoxPublishServer.getSelectedItemIndex() == 0);
|
||||||
|
@ -2153,7 +2156,8 @@ void MenuStateCustomGame::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork || listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
|
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork ||
|
||||||
|
listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
|
||||||
hasOneNetworkSlotOpen=true;
|
hasOneNetworkSlotOpen=true;
|
||||||
|
|
||||||
if(serverInterface->getSlot(i) != NULL &&
|
if(serverInterface->getSlot(i) != NULL &&
|
||||||
|
@ -2353,13 +2357,26 @@ void MenuStateCustomGame::update() {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) chrono.start();
|
||||||
|
|
||||||
if(hasOneNetworkSlotOpen) {
|
if(this->masterserverMode == true || hasOneNetworkSlotOpen == true) {
|
||||||
//listBoxPublishServer.setSelectedItemIndex(0);
|
if(this->masterserverMode == true) {
|
||||||
|
listBoxPublishServer.setSelectedItemIndex(0);
|
||||||
|
}
|
||||||
listBoxPublishServer.setEditable(true);
|
listBoxPublishServer.setEditable(true);
|
||||||
//listBoxEnableServerControlledAI.setEditable(true);
|
//listBoxEnableServerControlledAI.setEditable(true);
|
||||||
|
|
||||||
|
// Masterserver always needs one network slot
|
||||||
|
if(this->masterserverMode == true && hasOneNetworkSlotOpen == false) {
|
||||||
|
for(int i= 0; i < mapInfo.players; ++i) {
|
||||||
|
if(listBoxControls[i].getSelectedItemIndex() != ctNetwork &&
|
||||||
|
listBoxControls[i].getSelectedItemIndex() != ctNetworkUnassigned) {
|
||||||
|
listBoxControls[i].setSelectedItemIndex(ctNetwork);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateNetworkSlots();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
listBoxPublishServer.setSelectedItemIndex(1);
|
listBoxPublishServer.setSelectedItemIndex(1);
|
||||||
listBoxPublishServer.setEditable(false);
|
listBoxPublishServer.setEditable(false);
|
||||||
|
|
||||||
|
|
|
@ -694,11 +694,21 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
int64 lastMillisCheck = 0;
|
int64 lastMillisCheck = 0;
|
||||||
|
|
||||||
|
uint64 waitLoopIterationCount = 0;
|
||||||
|
const uint64 MAX_LOOP_COUNT_BEFORE_SLEEP = 300;
|
||||||
|
|
||||||
//wait until we get a ready message from the server
|
//wait until we get a ready message from the server
|
||||||
while(true) {
|
while(true) {
|
||||||
// FOR TESTING ONLY - delay to see the client count up while waiting
|
// FOR TESTING ONLY - delay to see the client count up while waiting
|
||||||
//sleep(2000);
|
//sleep(2000);
|
||||||
|
|
||||||
|
waitLoopIterationCount++;
|
||||||
|
if(waitLoopIterationCount > 0 && waitLoopIterationCount % MAX_LOOP_COUNT_BEFORE_SLEEP == 0) {
|
||||||
|
sleep(1);
|
||||||
|
waitLoopIterationCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(isConnected() == false) {
|
if(isConnected() == false) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
|
|
@ -1175,7 +1175,14 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Lang &lang= Lang::getInstance();
|
Lang &lang= Lang::getInstance();
|
||||||
|
uint64 waitLoopIterationCount = 0;
|
||||||
|
const uint64 MAX_LOOP_COUNT_BEFORE_SLEEP = 300;
|
||||||
while(exitServer == false && allReady == false && logger.getCancelLoading() == false) {
|
while(exitServer == false && allReady == false && logger.getCancelLoading() == false) {
|
||||||
|
waitLoopIterationCount++;
|
||||||
|
if(waitLoopIterationCount > 0 && waitLoopIterationCount % MAX_LOOP_COUNT_BEFORE_SLEEP == 0) {
|
||||||
|
sleep(1);
|
||||||
|
waitLoopIterationCount = 0;
|
||||||
|
}
|
||||||
vector<string> waitingForHosts;
|
vector<string> waitingForHosts;
|
||||||
allReady= true;
|
allReady= true;
|
||||||
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user