mirror of
https://github.com/glest/glest-source.git
synced 2025-08-18 14:11:15 +02: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:
@@ -153,7 +153,13 @@ static void cleanupProcessObjects() {
|
|||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
SystemFlags::Close();
|
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);
|
std::map<int,Texture2D *> &crcPlayerTextureCache = CacheManager::getCachedItem< std::map<int,Texture2D *> >(GameConstants::playerTextureCacheLookupKey);
|
||||||
//deleteMapValues(crcPlayerTextureCache.begin(),crcPlayerTextureCache.end());
|
//deleteMapValues(crcPlayerTextureCache.begin(),crcPlayerTextureCache.end());
|
||||||
@@ -163,13 +169,6 @@ static void cleanupProcessObjects() {
|
|||||||
//deleteMapValues(crcFactionPreviewTextureCache.begin(),crcFactionPreviewTextureCache.end());
|
//deleteMapValues(crcFactionPreviewTextureCache.begin(),crcFactionPreviewTextureCache.end());
|
||||||
crcFactionPreviewTextureCache.clear();
|
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();
|
std::map<string, vector<FileReader<Pixmap2D> const * >* > &list2d = FileReader<Pixmap2D>::getFileReadersMap();
|
||||||
//printf("list2d = %lu\n",list2d.size());
|
//printf("list2d = %lu\n",list2d.size());
|
||||||
deleteMapValues(list2d.begin(),list2d.end());
|
deleteMapValues(list2d.begin(),list2d.end());
|
||||||
@@ -177,6 +176,8 @@ static void cleanupProcessObjects() {
|
|||||||
//printf("list3d = %lu\n",list3d.size());
|
//printf("list3d = %lu\n",list3d.size());
|
||||||
deleteMapValues(list3d.begin(),list3d.end());
|
deleteMapValues(list3d.begin(),list3d.end());
|
||||||
|
|
||||||
|
XmlIo::getInstance().cleanup();
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
||||||
|
|
||||||
|
@@ -782,13 +782,18 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
if(clientInterface->isConnected() == true) {
|
if(clientInterface->isConnected() == true) {
|
||||||
int myCurrentIndex= -1;
|
int myCurrentIndex= -1;
|
||||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {// find my current index by looking at editable listBoxes
|
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;
|
myCurrentIndex= i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("myCurrentIndex = %d thisFactionIndex = %d\n",myCurrentIndex,clientInterface->getGameSettings()->getThisFactionIndex());
|
||||||
|
|
||||||
if(myCurrentIndex != -1)
|
if(myCurrentIndex != -1)
|
||||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
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)) {
|
if(listBoxFactions[i].mouseClick(x, y)) {
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
ClientInterface* clientInterface= NetworkManager::getInstance().getClientInterface();
|
||||||
@@ -808,7 +813,8 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
break;
|
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)){
|
if(listBoxTeams[i].mouseClick(x, y)){
|
||||||
soundRenderer.playFx(coreData.getClickSoundA());
|
soundRenderer.playFx(coreData.getClickSoundA());
|
||||||
if(clientInterface->isConnected()){
|
if(clientInterface->isConnected()){
|
||||||
@@ -827,8 +833,12 @@ void MenuStateConnectedGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((listBoxControls[i].getSelectedItemIndex() == ctNetwork) && (labelNetStatus[i].getText()
|
//if(grabSlotButton[i].mouseClick(x, y)) {
|
||||||
== GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME)){
|
// 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)) {
|
if(grabSlotButton[i].mouseClick(x, y)) {
|
||||||
//printf("Send slot switch request for slot = %d, myCurrentIndex = %d\n",i,myCurrentIndex);
|
//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);
|
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(
|
clientInterface->sendSwitchSetupRequest(
|
||||||
listBoxFactions[myCurrentIndex].getSelectedItem(),
|
listBoxFactions[myCurrentIndex].getSelectedItem(),
|
||||||
myCurrentIndex,
|
myCurrentIndex,
|
||||||
@@ -1195,7 +1207,7 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||||||
//ensure thet only 1 human player is present
|
//ensure thet only 1 human player is present
|
||||||
int oldSelectedIndex = listBoxControls[i].getSelectedItemIndex();
|
int oldSelectedIndex = listBoxControls[i].getSelectedItemIndex();
|
||||||
if(clientInterface != NULL && clientInterface->getGameSettings() != NULL &&
|
if(clientInterface != NULL && clientInterface->getGameSettings() != NULL &&
|
||||||
clientInterface->getGameSettings()->getThisFactionIndex() != i &&
|
clientInterface->getGameSettings()->getStartLocationIndex(clientInterface->getGameSettings()->getThisFactionIndex()) != i &&
|
||||||
listBoxControls[i].mouseClick(x, y)) {
|
listBoxControls[i].mouseClick(x, y)) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
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
|
// Disallow CPU players to be observers
|
||||||
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME) &&
|
if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME) &&
|
||||||
(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
(listBoxControls[i].getSelectedItemIndex() == ctCpuEasy || listBoxControls[i].getSelectedItemIndex() == ctCpu ||
|
||||||
@@ -1310,7 +1323,8 @@ void MenuStateConnectedGame::mouseClickAdmin(int x, int y, MouseButton mouseButt
|
|||||||
|
|
||||||
broadCastGameSettingsToMasterserver();
|
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(factionFiles[listBoxFactions[i].getSelectedItemIndex()] != formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||||
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
if(listBoxTeams[i].getSelectedItemIndex() + 1 != (GameConstants::maxPlayers + fpt_Observer)) {
|
||||||
//lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
//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(dataSynchCheckOk == false) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
mainMessageBoxState=1;
|
mainMessageBoxState=1;
|
||||||
@@ -1610,7 +1644,7 @@ void MenuStateCustomGame::switchSetupForSlots(SwitchSetupRequest **switchSetupRe
|
|||||||
ServerInterface *& serverInterface, int startIndex, int endIndex, bool onlyNetworkUnassigned) {
|
ServerInterface *& serverInterface, int startIndex, int endIndex, bool onlyNetworkUnassigned) {
|
||||||
for(int i= startIndex; i < endIndex; ++i) {
|
for(int i= startIndex; i < endIndex; ++i) {
|
||||||
if(switchSetupRequests[i] != NULL) {
|
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());
|
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("lister", "", "./", FTP_ACC_LS);
|
||||||
ftpCreateAccount("admin", "xxx", "./", FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR);
|
ftpCreateAccount("admin", "xxx", "./", FTP_ACC_RD | FTP_ACC_WR | FTP_ACC_LS | FTP_ACC_DIR);
|
||||||
*/
|
*/
|
||||||
|
if(getQuitStatus() == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ftpStart(portNumber);
|
ftpStart(portNumber);
|
||||||
while(this->getQuitStatus() == false) {
|
while(this->getQuitStatus() == false) {
|
||||||
ftpExecute();
|
ftpExecute();
|
||||||
|
Reference in New Issue
Block a user