- headless admin cannot start unless min authenticated players are connected

This commit is contained in:
Mark Vejvoda
2013-01-11 23:48:57 +00:00
parent 3df1df6155
commit 0f34a886c6
3 changed files with 7 additions and 4 deletions

View File

@@ -850,7 +850,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
int minHeadLessPlayersRequired = Config::getInstance().getInt("MinHeadlessPlayersRequired","2"); int minHeadLessPlayersRequired = Config::getInstance().getInt("MinHeadlessPlayersRequired","2");
if(networkMessageLaunch.getMessageType() == nmtLaunch && if(networkMessageLaunch.getMessageType() == nmtLaunch &&
this->serverInterface->getConnectedSlotCount() < minHeadLessPlayersRequired) { this->serverInterface->getConnectedSlotCount(true) < minHeadLessPlayersRequired) {
Lang &lang= Lang::getInstance(); Lang &lang= Lang::getInstance();
const vector<string> languageList = this->serverInterface->getGameSettings()->getUniqueNetworkPlayerLanguages(); const vector<string> languageList = this->serverInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
for(unsigned int i = 0; i < languageList.size(); ++i) { for(unsigned int i = 0; i < languageList.size(); ++i) {

View File

@@ -563,12 +563,15 @@ int ServerInterface::getSlotCount() {
return slotCount; return slotCount;
} }
int ServerInterface::getConnectedSlotCount() { int ServerInterface::getConnectedSlotCount(bool authenticated) {
int connectedSlotCount = 0; int connectedSlotCount = 0;
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i)); MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
if(slots[i] != NULL && slots[i]->isConnected() == true) { if(slots[i] != NULL && slots[i]->isConnected() == true) {
++connectedSlotCount; if(authenticated == false ||
(authenticated == true && slots[i]->getConnectHasHandshaked() == true)) {
++connectedSlotCount;
}
} }
} }
return connectedSlotCount; return connectedSlotCount;

View File

@@ -145,7 +145,7 @@ public:
void removeSlot(int playerIndex, int lockedSlotIndex = -1); void removeSlot(int playerIndex, int lockedSlotIndex = -1);
ConnectionSlot *getSlot(int playerIndex); ConnectionSlot *getSlot(int playerIndex);
int getSlotCount(); int getSlotCount();
int getConnectedSlotCount(); int getConnectedSlotCount(bool authenticated);
int getOpenSlotCount(); int getOpenSlotCount();
bool launchGame(const GameSettings *gameSettings); bool launchGame(const GameSettings *gameSettings);