mirror of
https://github.com/glest/glest-source.git
synced 2025-02-25 20:22:31 +01:00
- don't allow game to start and show a message if network player connected and on an unassigned slot
This commit is contained in:
parent
3ff146e3f3
commit
3b8d07fc8d
@ -153,7 +153,13 @@ static void cleanupProcessObjects() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
SystemFlags::Close();
|
||||
XmlIo::getInstance().cleanup();
|
||||
|
||||
printf("running threads = %lu\n",Thread::getThreadList().size());
|
||||
time_t elapsed = time(NULL);
|
||||
for(;Thread::getThreadList().size() > 0 &&
|
||||
difftime(time(NULL),elapsed) <= 10;) {
|
||||
//sleep(0);
|
||||
}
|
||||
|
||||
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
|
||||
//deleteMapValues(crcPlayerTextureCache.begin(),crcPlayerTextureCache.end());
|
||||
@ -163,13 +169,6 @@ static void cleanupProcessObjects() {
|
||||
//deleteMapValues(crcFactionPreviewTextureCache.begin(),crcFactionPreviewTextureCache.end());
|
||||
crcFactionPreviewTextureCache.clear();
|
||||
|
||||
printf("running threads = %lu\n",Thread::getThreadList().size());
|
||||
time_t elapsed = time(NULL);
|
||||
for(;Thread::getThreadList().size() > 0 &&
|
||||
difftime(time(NULL),elapsed) <= 10;) {
|
||||
//sleep(0);
|
||||
}
|
||||
|
||||
std::map<string, vector<FileReader<Pixmap2D> const * >* > &list2d = FileReader<Pixmap2D>::getFileReadersMap();
|
||||
//printf("list2d = %lu\n",list2d.size());
|
||||
deleteMapValues(list2d.begin(),list2d.end());
|
||||
@ -177,6 +176,8 @@ static void cleanupProcessObjects() {
|
||||
//printf("list3d = %lu\n",list3d.size());
|
||||
deleteMapValues(list3d.begin(),list3d.end());
|
||||
|
||||
XmlIo::getInstance().cleanup();
|
||||
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
||||
|
||||
|
@ -782,13 +782,18 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
if(clientInterface->isConnected() == true) {
|
||||
int myCurrentIndex= -1;
|
||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {// find my current index by looking at editable listBoxes
|
||||
if(listBoxFactions[i].getEditable() && clientInterface->getGameSettings()->getThisFactionIndex() == i) {
|
||||
if(listBoxFactions[i].getEditable() &&
|
||||
clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) == i) {
|
||||
myCurrentIndex= i;
|
||||
}
|
||||
}
|
||||
|
||||
//printf("myCurrentIndex = %d thisFactionIndex = %d\n",myCurrentIndex,clientInterface->getGameSettings()->getThisFactionIndex());
|
||||
|
||||
if(myCurrentIndex != -1)
|
||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
||||
if(listBoxFactions[i].getEditable() && clientInterface->getGameSettings()->getThisFactionIndex() == i) {
|
||||
if(listBoxFactions[i].getEditable() &&
|
||||
clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) == i) {
|
||||
if(listBoxFactions[i].mouseClick(x, y)) {
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||
@ -808,7 +813,8 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(listBoxTeams[i].getEditable() && clientInterface->getGameSettings()->getThisFactionIndex() == i) {
|
||||
if(listBoxTeams[i].getEditable() &&
|
||||
clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) == i) {
|
||||
if(listBoxTeams[i].mouseClick(x, y)){
|
||||
soundRenderer.playFx(coreData.getClickSoundA());
|
||||
if(clientInterface->isConnected()){
|
||||
@ -827,8 +833,12 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if((listBoxControls[i].getSelectedItemIndex() == ctNetwork) && (labelNetStatus[i].getText()
|
||||
== GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)){
|
||||
//if(grabSlotButton[i].mouseClick(x, y)) {
|
||||
// printf("Send slot switch request for slot = %d, myCurrentIndex = %d name [%s] control = %d\n",i,myCurrentIndex,labelNetStatus[i].getText().c_str(),listBoxControls[i].getSelectedItemIndex());
|
||||
//}
|
||||
|
||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork &&
|
||||
labelNetStatus[i].getText() == GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME) {
|
||||
if(grabSlotButton[i].mouseClick(x, y)) {
|
||||
//printf("Send slot switch request for slot = %d, myCurrentIndex = %d\n",i,myCurrentIndex);
|
||||
|
||||
@ -838,6 +848,8 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] sending a switchSlot request from %d to %d\n",__FILE__,__FUNCTION__,__LINE__,clientInterface->getGameSettings()->getThisFactionIndex(),i);
|
||||
|
||||
//printf("Switch slot from %d to %d\n",myCurrentIndex,i);
|
||||
|
||||
clientInterface->sendSwitchSetupRequest(
|
||||
listBoxFactions[myCurrentIndex].getSelectedItem(),
|
||||
myCurrentIndex,
|
||||
@ -1195,7 +1207,7 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
||||
//ensure thet only 1 human player is present
|
||||
int oldSelectedIndex = listBoxControls[i].getSelectedItemIndex();
|
||||
if(clientInterface != NULL && clientInterface->getGameSettings() != NULL &&
|
||||
clientInterface->getGameSettings()->getThisFactionIndex() != i &&
|
||||
clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) != i &&
|
||||
listBoxControls[i].mouseClick(x, y)) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
@ -1289,7 +1301,8 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
else if(clientInterface->getGameSettings()->getThisFactionIndex() != i && listBoxFactions[i].mouseClick(x, y)) {
|
||||
else if(clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) != i &&
|
||||
listBoxFactions[i].mouseClick(x, y)) {
|
||||
// Disallow CPU players to be observers
|
||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME) &&
|
||||
(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
||||
@ -1310,7 +1323,8 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
||||
|
||||
broadCastGameSettingsToMasterserver();
|
||||
}
|
||||
else if(clientInterface->getGameSettings()->getThisFactionIndex() != i && listBoxTeams[i].mouseClick(x, y)) {
|
||||
else if(clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) != i &&
|
||||
listBoxTeams[i].mouseClick(x, y)) {
|
||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] != formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||
//lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||
|
@ -1292,6 +1292,40 @@ void MenuStateCustomGame::PlayNow(bool saveGame) {
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure we have no dangling network players
|
||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
|
||||
mainMessageBoxState=1;
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("NetworkSlotUnassignedErrorUI") == true) {
|
||||
sprintf(szMsg,lang.get("NetworkSlotUnassignedErrorUI").c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Cannot start game.\nSome player(s) are not in a network game slot!");
|
||||
}
|
||||
|
||||
showMessageBox(szMsg, "", false);
|
||||
|
||||
const vector<string> languageList = serverInterface->getGameSettings()->getUniqueNetworkPlayerLanguages();
|
||||
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
||||
char szMsg[1024]="";
|
||||
if(lang.hasString("NetworkSlotUnassignedError",languageList[j]) == true) {
|
||||
sprintf(szMsg,lang.get("NetworkSlotUnassignedError").c_str());
|
||||
}
|
||||
else {
|
||||
sprintf(szMsg,"Cannot start game, some player(s) are not in a network game slot!");
|
||||
}
|
||||
|
||||
serverInterface->sendTextMessage(szMsg,-1, true,languageList[j]);
|
||||
}
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(dataSynchCheckOk == false) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
mainMessageBoxState=1;
|
||||
@ -1610,7 +1644,7 @@ void MenuStateCustomGame::switchSetupForSlots(SwitchSetupRequest **switchSetupRe
|
||||
ServerInterface *& serverInterface, int startIndex, int endIndex, bool onlyNetworkUnassigned) {
|
||||
for(int i= startIndex; i < endIndex; ++i) {
|
||||
if(switchSetupRequests[i] != NULL) {
|
||||
//printf("Switch slot = %d\n",i);
|
||||
//printf("Switch slot = %d control = %d newIndex = %d currentindex = %d\n",i,listBoxControls[i].getSelectedItemIndex(),switchSetupRequests[i]->getToFactionIndex(),switchSetupRequests[i]->getCurrentFactionIndex());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] switchSetupRequests[i]->getSwitchFlags() = %d\n",__FILE__,__FUNCTION__,__LINE__,switchSetupRequests[i]->getSwitchFlags());
|
||||
|
||||
|
@ -209,6 +209,10 @@ void FTPServerThread::execute() {
|
||||
ftpCreateAccount("lister", "", "./", FTP_ACC_LS);
|
||||
ftpCreateAccount("admin", "xxx", "./", FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR);
|
||||
*/
|
||||
if(getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
ftpStart(portNumber);
|
||||
while(this->getQuitStatus() == false) {
|
||||
ftpExecute();
|
||||
|
Loading…
x
Reference in New Issue
Block a user