mirror of
https://github.com/glest/glest-source.git
synced 2025-08-15 04:43:58 +02:00
- headless mode now properly uses selected slot of player
This commit is contained in:
@@ -167,7 +167,7 @@ static void cleanupProcessObjects() {
|
||||
time_t elapsed = time(NULL);
|
||||
for(;Thread::getThreadList().size() > 0 &&
|
||||
difftime(time(NULL),elapsed) <= 10;) {
|
||||
sleep(10);
|
||||
//sleep(0);
|
||||
}
|
||||
|
||||
std::map<string, vector<FileReader<Pixmap2D> const * >* > &list2d = FileReader<Pixmap2D>::getFileReadersMap();
|
||||
|
@@ -931,6 +931,8 @@ void MenuStateConnectedGame::broadCastGameSettingsToMasterserver() {
|
||||
GameSettings gameSettings = *clientInterface->getGameSettings();
|
||||
loadGameSettings(&gameSettings);
|
||||
|
||||
//printf("broadcast settings:\n%s\n",gameSettings.toString().c_str());
|
||||
|
||||
//printf("Client sending map [%s] admin key [%d]\n",gameSettings.getMap().c_str(),gameSettings.getMasterserver_admin());
|
||||
|
||||
//clientInterface->setGameSettings(&gameSettings);
|
||||
@@ -1547,7 +1549,7 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, slotIndex = %d, getHumanPlayerName(i) [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,slotIndex,getHumanPlayerName(i).c_str());
|
||||
|
||||
gameSettings->setThisFactionIndex(slotIndex);
|
||||
//gameSettings->setNetworkPlayerName(slotIndex, getHumanPlayerName(i));
|
||||
gameSettings->setNetworkPlayerName(slotIndex, getHumanPlayerName());
|
||||
gameSettings->setNetworkPlayerStatuses(slotIndex, getNetworkPlayerStatus());
|
||||
Lang &lang= Lang::getInstance();
|
||||
gameSettings->setNetworkPlayerLanguages(slotIndex, lang.getLanguage());
|
||||
@@ -1581,7 +1583,7 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
|
||||
|
||||
gameSettings->setTeam(slotIndex, listBoxTeams[i].getSelectedItemIndex());
|
||||
gameSettings->setStartLocationIndex(slotIndex, i);
|
||||
|
||||
//printf("!!! setStartLocationIndex #1 slotIndex = %d, i = %d\n",slotIndex, i);
|
||||
|
||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork || listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
|
||||
// if(serverInterface->getSlot(i) != NULL &&
|
||||
@@ -1613,7 +1615,7 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
|
||||
}
|
||||
else {
|
||||
//gameSettings->setNetworkPlayerName("");
|
||||
gameSettings->setNetworkPlayerStatuses(factionCount, 0);
|
||||
//gameSettings->setNetworkPlayerStatuses(factionCount, 0);
|
||||
labelPlayerNames[i].setText("");
|
||||
}
|
||||
}
|
||||
@@ -1628,11 +1630,14 @@ void MenuStateConnectedGame::loadGameSettings(GameSettings *gameSettings) {
|
||||
gameSettings->setFactionControl(slotIndex, ct);
|
||||
gameSettings->setTeam(slotIndex, listBoxTeams[i].getSelectedItemIndex());
|
||||
gameSettings->setStartLocationIndex(slotIndex, i);
|
||||
//printf("!!! setStartLocationIndex #2 slotIndex = %d, i = %d\n",slotIndex, i);
|
||||
|
||||
gameSettings->setResourceMultiplierIndex(slotIndex, 10);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionFiles[listBoxFactions[i].getSelectedItemIndex()] [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,factionFiles[listBoxFactions[i].getSelectedItemIndex()].c_str());
|
||||
|
||||
gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]);
|
||||
gameSettings->setNetworkPlayerStatuses(slotIndex, 0);
|
||||
gameSettings->setNetworkPlayerName(slotIndex, "Closed");
|
||||
|
||||
closedCount++;
|
||||
@@ -2528,6 +2533,8 @@ void MenuStateConnectedGame::update() {
|
||||
vector<string> maps,tilesets,techtree;
|
||||
const GameSettings *gameSettings = clientInterface->getGameSettings();
|
||||
|
||||
//printf("got settings:\n%s\n",gameSettings->toString().c_str());
|
||||
|
||||
if(gameSettings == NULL) {
|
||||
throw runtime_error("gameSettings == NULL");
|
||||
}
|
||||
|
@@ -1763,11 +1763,18 @@ void MenuStateCustomGame::update() {
|
||||
if(this->masterserverMode == true && serverInterface->getGameSettingsUpdateCount() > lastMasterServerSettingsUpdateCount &&
|
||||
serverInterface->getGameSettings() != NULL) {
|
||||
const GameSettings *settings = serverInterface->getGameSettings();
|
||||
//printf("\n\n\n\n=====#1 got settings [%d] [%d]:\n%s\n",lastMasterServerSettingsUpdateCount,serverInterface->getGameSettingsUpdateCount(),settings->toString().c_str());
|
||||
|
||||
lastMasterServerSettingsUpdateCount = serverInterface->getGameSettingsUpdateCount();
|
||||
//printf("#2 custom menu got map [%s]\n",settings->getMap().c_str());
|
||||
|
||||
setupUIFromGameSettings(*settings);
|
||||
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
|
||||
//printf("\n\n\n\n=====#1.1 got settings [%d] [%d]:\n%s\n",lastMasterServerSettingsUpdateCount,serverInterface->getGameSettingsUpdateCount(),gameSettings.toString().c_str());
|
||||
|
||||
}
|
||||
if(this->masterserverMode == true && serverInterface->getMasterserverAdminRequestLaunch() == true) {
|
||||
safeMutex.ReleaseLock();
|
||||
@@ -2341,11 +2348,6 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
|
||||
|
||||
//printf("simpleTask broadCastSettings = %d hasClientConnection = %d\n",broadCastSettings,hasClientConnection);
|
||||
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(callingThread->getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
@@ -2353,7 +2355,15 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
|
||||
if(serverInterface != NULL) {
|
||||
|
||||
if(this->masterserverMode == false || (serverInterface->getGameSettingsUpdateCount() <= lastMasterServerSettingsUpdateCount)) {
|
||||
GameSettings gameSettings;
|
||||
loadGameSettings(&gameSettings);
|
||||
|
||||
//printf("\n\n\n\n=====#2 got settings [%d] [%d]:\n%s\n",lastMasterServerSettingsUpdateCount,serverInterface->getGameSettingsUpdateCount(),gameSettings.toString().c_str());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
serverInterface->setGameSettings(&gameSettings,false);
|
||||
lastMasterServerSettingsUpdateCount = serverInterface->getGameSettingsUpdateCount();
|
||||
|
||||
if(hasClientConnection == true) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@@ -2415,6 +2425,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||
if(this->masterserverMode == true && serverInterface->getGameSettingsUpdateCount() > lastMasterServerSettingsUpdateCount &&
|
||||
serverInterface->getGameSettings() != NULL) {
|
||||
const GameSettings *settings = serverInterface->getGameSettings();
|
||||
//printf("\n\n\n\n=====#3 got settings [%d] [%d]:\n%s\n",lastMasterServerSettingsUpdateCount,serverInterface->getGameSettingsUpdateCount(),settings->toString().c_str());
|
||||
|
||||
lastMasterServerSettingsUpdateCount = serverInterface->getGameSettingsUpdateCount();
|
||||
//printf("#1 custom menu got map [%s]\n",settings->getMap().c_str());
|
||||
@@ -2668,7 +2679,7 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||
|
||||
//printf("slot = %d serverInterface->getSlot(i)->getConnectedTime() = %d session key [%d]\n",i,serverInterface->getSlot(i)->getConnectedTime(),serverInterface->getSlot(i)->getSessionKey());
|
||||
|
||||
if(clientConnectedTime == 0 ||
|
||||
if(clientConnectedTime == 0 || clientConnectedTime == 0 ||
|
||||
(serverInterface->getSlot(i)->getConnectedTime() > 0 && serverInterface->getSlot(i)->getConnectedTime() < clientConnectedTime)) {
|
||||
clientConnectedTime = serverInterface->getSlot(i)->getConnectedTime();
|
||||
gameSettings->setMasterserver_admin(serverInterface->getSlot(i)->getSessionKey());
|
||||
@@ -2678,7 +2689,6 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@@ -2918,36 +2928,40 @@ void MenuStateCustomGame::setupUIFromGameSettings(const GameSettings &gameSettin
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
reloadFactions(false);
|
||||
//reloadFactions(true);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d] gameSettings.getFactionCount() = %d\n",__FILE__,__FUNCTION__,__LINE__,gameSettings.getFactionCount());
|
||||
|
||||
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
||||
if(gameSettings.getFactionControl(i) < listBoxControls[i].getItemCount()) {
|
||||
listBoxControls[i].setSelectedItemIndex(gameSettings.getFactionControl(i));
|
||||
int slotIndex = gameSettings.getStartLocationIndex(i);
|
||||
if(gameSettings.getFactionControl(i) < listBoxControls[slotIndex].getItemCount()) {
|
||||
listBoxControls[slotIndex].setSelectedItemIndex(gameSettings.getFactionControl(i));
|
||||
}
|
||||
|
||||
updateResourceMultiplier(i);
|
||||
listBoxRMultiplier[i].setSelectedItemIndex(gameSettings.getResourceMultiplierIndex(i));
|
||||
updateResourceMultiplier(slotIndex);
|
||||
listBoxRMultiplier[slotIndex].setSelectedItemIndex(gameSettings.getResourceMultiplierIndex(i));
|
||||
|
||||
listBoxTeams[i].setSelectedItemIndex(gameSettings.getTeam(i));
|
||||
listBoxTeams[slotIndex].setSelectedItemIndex(gameSettings.getTeam(i));
|
||||
|
||||
lastSelectedTeamIndex[i] = listBoxTeams[i].getSelectedItemIndex();
|
||||
lastSelectedTeamIndex[slotIndex] = listBoxTeams[slotIndex].getSelectedItemIndex();
|
||||
|
||||
string factionName = gameSettings.getFactionTypeName(i);
|
||||
factionName = formatString(factionName);
|
||||
|
||||
//printf("\n\n\n*** setupUIFromGameSettings A, i = %d, startLoc = %d, factioncontrol = %d, factionName [%s]\n",i,gameSettings.getStartLocationIndex(i),gameSettings.getFactionControl(i),factionName.c_str());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] factionName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,factionName.c_str());
|
||||
|
||||
if(listBoxFactions[i].hasItem(factionName) == true) {
|
||||
listBoxFactions[i].setSelectedItem(factionName);
|
||||
if(listBoxFactions[slotIndex].hasItem(factionName) == true) {
|
||||
listBoxFactions[slotIndex].setSelectedItem(factionName);
|
||||
}
|
||||
else {
|
||||
listBoxFactions[i].setSelectedItem(formatString(GameConstants::RANDOMFACTION_SLOTNAME));
|
||||
listBoxFactions[slotIndex].setSelectedItem(formatString(GameConstants::RANDOMFACTION_SLOTNAME));
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, gameSettings.getNetworkPlayerName(i) [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,gameSettings.getNetworkPlayerName(i).c_str());
|
||||
|
||||
labelPlayerNames[i].setText(gameSettings.getNetworkPlayerName(i));
|
||||
labelPlayerNames[slotIndex].setText(gameSettings.getNetworkPlayerName(i));
|
||||
}
|
||||
|
||||
//SetActivePlayerNameEditor();
|
||||
|
@@ -592,6 +592,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
|
||||
networkMessageLaunch.buildGameSettings(&gameSettings);
|
||||
|
||||
//printf("Connection slot got networkMessageLaunch.getMessageType() = %d, got map [%s]\n",networkMessageLaunch.getMessageType(),gameSettings.getMap().c_str());
|
||||
//printf("\n\n\n\n=====Connection slot got settings:\n%s\n",gameSettings.toString().c_str());
|
||||
|
||||
this->serverInterface->setGameSettings(&gameSettings,false);
|
||||
this->serverInterface->broadcastGameSetup(&gameSettings);
|
||||
|
@@ -270,7 +270,8 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
||||
data.pathFinderType = gameSettings->getPathFinderType();
|
||||
data.flagTypes1 = gameSettings->getFlagTypes1();
|
||||
|
||||
for(int i= 0; i < data.factionCount; ++i) {
|
||||
//for(int i= 0; i < data.factionCount; ++i) {
|
||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
||||
data.factionTypeNames[i]= gameSettings->getFactionTypeName(i);
|
||||
data.networkPlayerNames[i]= gameSettings->getNetworkPlayerName(i);
|
||||
data.networkPlayerStatuses[i] = gameSettings->getNetworkPlayerStatuses(i);
|
||||
@@ -280,16 +281,16 @@ NetworkMessageLaunch::NetworkMessageLaunch(const GameSettings *gameSettings,int8
|
||||
data.teams[i]= gameSettings->getTeam(i);
|
||||
data.startLocationIndex[i]= gameSettings->getStartLocationIndex(i);
|
||||
}
|
||||
for(int i= data.factionCount; i < GameConstants::maxPlayers; ++i) {
|
||||
data.factionTypeNames[i]= "";
|
||||
data.networkPlayerNames[i]= "";
|
||||
data.networkPlayerStatuses[i] = 0;
|
||||
data.networkPlayerLanguages[i] = "";
|
||||
data.factionControls[i]= 0;
|
||||
data.resourceMultiplierIndex[i]= 0;
|
||||
data.teams[i]= -1;
|
||||
data.startLocationIndex[i]= 0;
|
||||
}
|
||||
// for(int i= data.factionCount; i < GameConstants::maxPlayers; ++i) {
|
||||
// data.factionTypeNames[i]= "";
|
||||
// data.networkPlayerNames[i]= "";
|
||||
// data.networkPlayerStatuses[i] = 0;
|
||||
// data.networkPlayerLanguages[i] = "";
|
||||
// data.factionControls[i]= 0;
|
||||
// data.resourceMultiplierIndex[i]= 0;
|
||||
// data.teams[i]= -1;
|
||||
// data.startLocationIndex[i]= 0;
|
||||
// }
|
||||
|
||||
data.aiAcceptSwitchTeamPercentChance = gameSettings->getAiAcceptSwitchTeamPercentChance();
|
||||
data.masterserver_admin = gameSettings->getMasterserver_admin();
|
||||
@@ -327,7 +328,8 @@ void NetworkMessageLaunch::buildGameSettings(GameSettings *gameSettings) const {
|
||||
}
|
||||
gameSettings->setFactionCRCList(factionCRCList);
|
||||
|
||||
for(int i= 0; i < data.factionCount; ++i) {
|
||||
//for(int i= 0; i < data.factionCount; ++i) {
|
||||
for(int i= 0; i < GameConstants::maxPlayers; ++i) {
|
||||
gameSettings->setFactionTypeName(i, data.factionTypeNames[i].getString());
|
||||
gameSettings->setNetworkPlayerName(i,data.networkPlayerNames[i].getString());
|
||||
gameSettings->setNetworkPlayerStatuses(i, data.networkPlayerStatuses[i]);
|
||||
|
Reference in New Issue
Block a user