diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index fd0ed32d..e1f253bf 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -1576,7 +1576,8 @@ void Game::render2d(){ for(int i = 0; i < world.getFactionCount(); ++i) { //str+= "Player "+intToStr(i)+" res: "; string factionInfo = this->gameSettings.getNetworkPlayerName(i) + - " [" + formatString(this->gameSettings.getFactionTypeName(i)) + "] res: "; + " [" + formatString(this->gameSettings.getFactionTypeName(i)) + + " team: " + intToStr(this->gameSettings.getTeam(i)) + "] res: "; for(int j = 0; j < world.getTechTree()->getResourceTypeCount(); ++j) { factionInfo += intToStr(world.getFaction(i)->getResource(j)->getAmount()); factionInfo += " "; diff --git a/source/glest_game/game/game_constants.h b/source/glest_game/game/game_constants.h index d640ebdb..5d830e52 100644 --- a/source/glest_game/game/game_constants.h +++ b/source/glest_game/game/game_constants.h @@ -43,8 +43,17 @@ enum ControlType{ ctHuman }; + +enum FactionPersonalityType { + fpt_Normal, + fpt_Observer, + + fpt_EndCount +}; + class GameConstants { public: + static const int specialFactions = fpt_EndCount - 1; static const int maxPlayers= 8; static const int serverPort= 61357; //static const int updateFps= 40; @@ -69,6 +78,8 @@ public: static const char *NETWORK_SLOT_UNCONNECTED_SLOTNAME; static const char *folder_path_screenshots; + + static const char *OBSERVER_SLOTNAME; }; enum PathType { diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index ec50db3d..e425966d 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -42,6 +42,8 @@ const char *GameConstants::NETWORK_SLOT_UNCONNECTED_SLOTNAME = "???"; const char *GameConstants::folder_path_screenshots = "screens/"; +const char *GameConstants::OBSERVER_SLOTNAME = "*Observer*"; + // ===================================================== // class Config // ===================================================== diff --git a/source/glest_game/main/battle_end.cpp b/source/glest_game/main/battle_end.cpp index fbdc101c..241318cf 100644 --- a/source/glest_game/main/battle_end.cpp +++ b/source/glest_game/main/battle_end.cpp @@ -97,7 +97,7 @@ void BattleEnd::render(){ string controlString; if(stats.getPersonalityType(i) == fpt_Observer) { - controlString= lang.get("ObserverOnly"); + controlString= GameConstants::OBSERVER_SLOTNAME; } else { switch(stats.getControl(i)) { diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index 2b78c45c..e736346d 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -230,14 +230,14 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM controlItems.push_back(lang.get("CpuMega")); controlItems.push_back(lang.get("Network")); controlItems.push_back(lang.get("Human")); - teamItems.push_back("1"); - teamItems.push_back("2"); - teamItems.push_back("3"); - teamItems.push_back("4"); - teamItems.push_back("5"); - teamItems.push_back("6"); - teamItems.push_back("7"); - teamItems.push_back("8"); + + for(int i = 1; i <= GameConstants::maxPlayers; ++i) { + teamItems.push_back(intToStr(i)); + } + for(int i = GameConstants::maxPlayers + 1; i <= GameConstants::maxPlayers + GameConstants::specialFactions; ++i) { + teamItems.push_back(intToStr(i)); + } + for(int i=0; igetCurrentFactionIndex(); if(serverInterface->switchSlot(switchFactionIdx,newFactionIdx)) { try { - if(switchSetupRequests[i]->getSelectedFactionName() != ""){ + if(switchSetupRequests[i]->getSelectedFactionName() != "") { listBoxFactions[newFactionIdx].setSelectedItem(switchSetupRequests[i]->getSelectedFactionName()); } if(switchSetupRequests[i]->getToTeam() != -1) { @@ -1565,9 +1564,18 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings) { gameSettings->setNetworkPlayerName(slotIndex, getHumanPlayerName(i)); labelPlayerNames[i].setText(getHumanPlayerName(i)); } + + gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]); + if(factionFiles[listBoxFactions[i].getSelectedItemIndex()] == formatString(GameConstants::OBSERVER_SLOTNAME)) { + listBoxTeams[i].setSelectedItem(intToStr(GameConstants::maxPlayers + fpt_Observer)); + } + else if(listBoxTeams[i].getSelectedItem() == intToStr(GameConstants::maxPlayers + fpt_Observer)) { + listBoxTeams[i].setSelectedItem(intToStr(GameConstants::maxPlayers)); + } + gameSettings->setTeam(slotIndex, listBoxTeams[i].getSelectedItemIndex()); gameSettings->setStartLocationIndex(slotIndex, i); - gameSettings->setFactionTypeName(slotIndex, factionFiles[listBoxFactions[i].getSelectedItemIndex()]); + if(listBoxControls[i].getSelectedItemIndex() == ctNetwork) { ConnectionSlot* connectionSlot= serverInterface->getSlot(i); @@ -1885,7 +1893,7 @@ void MenuStateCustomGame::loadMapInfo(string file, MapInfo *mapInfo){ } -void MenuStateCustomGame::reloadFactions(){ +void MenuStateCustomGame::reloadFactions() { vector results; @@ -1907,7 +1915,7 @@ void MenuStateCustomGame::reloadFactions(){ // Add special Observer Faction Lang &lang= Lang::getInstance(); - results.push_back(formatString(lang.get("ObserverOnly"))); + results.push_back(formatString(GameConstants::OBSERVER_SLOTNAME)); factionFiles= results; for(int i= 0; i unitFilenames; findAll(unitsPath, unitFilenames); unitTypes.resize(unitFilenames.size()); - for(int i=0; i upgradeFilenames; findAll(upgradesPath, upgradeFilenames); upgradeTypes.resize(upgradeFilenames.size()); - for(int i=0; i PairPUnitTypeInt; diff --git a/source/glest_game/world/map.h b/source/glest_game/world/map.h index be455bb2..2124aba7 100755 --- a/source/glest_game/world/map.h +++ b/source/glest_game/world/map.h @@ -92,8 +92,8 @@ private: Object *object; //visibility - bool visible[GameConstants::maxPlayers]; - bool explored[GameConstants::maxPlayers]; + bool visible[GameConstants::maxPlayers + GameConstants::specialFactions]; + bool explored[GameConstants::maxPlayers + GameConstants::specialFactions]; //cache bool nearSubmerged; diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 53c7423c..21eb1c8d 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -803,8 +803,8 @@ void World::initCells(bool fogOfWar){ SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); Logger::getInstance().add("State cells", true); - for(int i=0; isetExplored(k, !fogOfWar); sc->setVisible(k, !fogOfWar); } + for (int k = GameConstants::maxPlayers; k < GameConstants::maxPlayers + GameConstants::specialFactions; k++) { + sc->setExplored(k, true); + sc->setVisible(k, true); + } } } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); @@ -1091,11 +1095,33 @@ void World::computeFow(int factionIdxToTick) { //reset cells if(factionIdxToTick == -1 || factionIdxToTick == this->thisFactionIndex) { - for(int i=0; isetVisible(k, false); + for(int i = 0; i < map.getSurfaceW(); ++i) { + for(int j = 0; j < map.getSurfaceH(); ++j) { + for(int k = 0; k < GameConstants::maxPlayers + GameConstants::specialFactions; ++k) { + if(fogOfWar || k != thisTeamIndex) { + if(k == thisTeamIndex && thisTeamIndex == GameConstants::maxPlayers -1 + fpt_Observer) { + map.getSurfaceCell(i, j)->setVisible(k, true); + map.getSurfaceCell(i, j)->setExplored(k, true); + + const Vec2i pos(i,j); + Vec2i surfPos= Map::toSurfCoords(pos); + + //compute max alpha + float maxAlpha= 0.0f; + if(surfPos.x>1 && surfPos.y>1 && surfPos.x0 && surfPos.y>0 && surfPos.xsetVisible(k, false); + } } } } @@ -1144,7 +1170,8 @@ void World::computeFow(int factionIdxToTick) { if(fogOfWar) { for(int i=0; igetTeam() == thisTeamIndex){ + if(faction->getTeam() == thisTeamIndex) { + //if(thisTeamIndex == GameConstants::maxPlayers + fpt_Observer) { for(int j=0; jgetUnitCount(); ++j){ const Unit *unit= faction->getUnit(j); if(unit->isOperative()){