mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 19:52:25 +01:00
- changed observer faction to use a special team # and fog of war is auto turned off for this special team #.
This commit is contained in:
parent
72711e2fde
commit
e93ac6d756
@ -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 += " ";
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
// =====================================================
|
||||
|
@ -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)) {
|
||||
|
@ -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; i<GameConstants::maxPlayers; ++i){
|
||||
labelPlayers[i].setText(lang.get("Player")+" "+intToStr(i));
|
||||
labelPlayerNames[i].setText("");
|
||||
@ -948,7 +948,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool
|
||||
else {
|
||||
// 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<results.size(); ++i){
|
||||
|
@ -338,14 +338,13 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
||||
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));
|
||||
}
|
||||
|
||||
reloadFactions();
|
||||
|
||||
@ -803,7 +802,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
}
|
||||
else if(listBoxFactions[i].mouseClick(x, y)){
|
||||
else if(listBoxFactions[i].mouseClick(x, y)) {
|
||||
needToRepublishToMasterserver = true;
|
||||
|
||||
if(hasNetworkGameSettings() == true)
|
||||
@ -1047,7 +1046,7 @@ void MenuStateCustomGame::update() {
|
||||
int switchFactionIdx = switchSetupRequests[i]->getCurrentFactionIndex();
|
||||
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<string> 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<results.size(); ++i){
|
||||
|
@ -44,7 +44,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
||||
|
||||
// Add special Observer Faction
|
||||
Lang &lang= Lang::getInstance();
|
||||
if(name == formatString(lang.get("ObserverOnly"))) {
|
||||
if(name == formatString(GameConstants::OBSERVER_SLOTNAME)) {
|
||||
personalityType = fpt_Observer;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
||||
vector<string> unitFilenames;
|
||||
findAll(unitsPath, unitFilenames);
|
||||
unitTypes.resize(unitFilenames.size());
|
||||
for(int i=0; i<unitTypes.size(); ++i){
|
||||
for(int i=0; i<unitTypes.size(); ++i) {
|
||||
string str= dir + "/units/" + unitFilenames[i];
|
||||
unitTypes[i].preLoad(str);
|
||||
|
||||
@ -68,7 +68,7 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
||||
vector<string> upgradeFilenames;
|
||||
findAll(upgradesPath, upgradeFilenames);
|
||||
upgradeTypes.resize(upgradeFilenames.size());
|
||||
for(int i=0; i<upgradeTypes.size(); ++i){
|
||||
for(int i=0; i<upgradeTypes.size(); ++i) {
|
||||
string str= dir + "/upgrades/" + upgradeFilenames[i];
|
||||
upgradeTypes[i].preLoad(str);
|
||||
|
||||
@ -77,20 +77,20 @@ void FactionType::load(const string &dir, const TechTree *techTree, Checksum* ch
|
||||
|
||||
// b1) load units
|
||||
try{
|
||||
for(int i=0; i<unitTypes.size(); ++i){
|
||||
for(int i = 0; i < unitTypes.size(); ++i) {
|
||||
string str= dir + "/units/" + unitTypes[i].getName();
|
||||
unitTypes[i].load(i, str, techTree, this, checksum);
|
||||
|
||||
SDL_PumpEvents();
|
||||
}
|
||||
}
|
||||
catch(const exception &e){
|
||||
catch(const exception &e) {
|
||||
throw runtime_error("Error loading units: "+ dir + "\n" + e.what());
|
||||
}
|
||||
|
||||
// b2) load upgrades
|
||||
try{
|
||||
for(int i=0; i<upgradeTypes.size(); ++i){
|
||||
for(int i = 0; i < upgradeTypes.size(); ++i) {
|
||||
string str= dir + "/upgrades/" + upgradeTypes[i].getName();
|
||||
upgradeTypes[i].load(str, techTree, this, checksum);
|
||||
|
||||
|
@ -26,11 +26,6 @@ namespace Glest{ namespace Game{
|
||||
/// Each of the possible factions the user can select
|
||||
// =====================================================
|
||||
|
||||
enum FactionPersonalityType {
|
||||
fpt_Normal,
|
||||
fpt_Observer
|
||||
};
|
||||
|
||||
class FactionType{
|
||||
private:
|
||||
typedef pair<const UnitType*, int> PairPUnitTypeInt;
|
||||
|
@ -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;
|
||||
|
@ -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; i<map.getSurfaceW(); ++i){
|
||||
for(int j=0; j<map.getSurfaceH(); ++j){
|
||||
for(int i=0; i< map.getSurfaceW(); ++i) {
|
||||
for(int j=0; j< map.getSurfaceH(); ++j) {
|
||||
|
||||
SurfaceCell *sc= map.getSurfaceCell(i, j);
|
||||
|
||||
@ -816,6 +816,10 @@ void World::initCells(bool fogOfWar){
|
||||
sc->setExplored(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; i<map.getSurfaceW(); ++i) {
|
||||
for(int j=0; j<map.getSurfaceH(); ++j) {
|
||||
for(int k=0; k<GameConstants::maxPlayers; ++k) {
|
||||
if(fogOfWar || k != thisTeamIndex){
|
||||
map.getSurfaceCell(i, j)->setVisible(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.x<map.getSurfaceW()-2 && surfPos.y<map.getSurfaceH()-2){
|
||||
maxAlpha= 1.f;
|
||||
}
|
||||
else if(surfPos.x>0 && surfPos.y>0 && surfPos.x<map.getSurfaceW()-1 && surfPos.y<map.getSurfaceH()-1){
|
||||
maxAlpha= 0.3f;
|
||||
}
|
||||
|
||||
//compute alpha
|
||||
float alpha=maxAlpha;
|
||||
minimap.incFowTextureAlphaSurface(surfPos, alpha);
|
||||
}
|
||||
else {
|
||||
map.getSurfaceCell(i, j)->setVisible(k, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1144,7 +1170,8 @@ void World::computeFow(int factionIdxToTick) {
|
||||
if(fogOfWar) {
|
||||
for(int i=0; i<getFactionCount(); ++i) {
|
||||
Faction *faction= getFaction(i);
|
||||
if(faction->getTeam() == thisTeamIndex){
|
||||
if(faction->getTeam() == thisTeamIndex) {
|
||||
//if(thisTeamIndex == GameConstants::maxPlayers + fpt_Observer) {
|
||||
for(int j=0; j<faction->getUnitCount(); ++j){
|
||||
const Unit *unit= faction->getUnit(j);
|
||||
if(unit->isOperative()){
|
||||
|
Loading…
x
Reference in New Issue
Block a user