2010-03-27 07:09:34 +00:00
|
|
|
|
// ==============================================================
|
|
|
|
|
// This file is part of Glest (www.glest.org)
|
|
|
|
|
//
|
2010-04-21 23:13:39 +00:00
|
|
|
|
// Copyright (C) 2001-2008 Marti<74>o Figueroa
|
2010-03-27 07:09:34 +00:00
|
|
|
|
//
|
|
|
|
|
// You can redistribute this code and/or modify it under
|
|
|
|
|
// the terms of the GNU General Public License as published
|
|
|
|
|
// by the Free Software Foundation; either version 2 of the
|
|
|
|
|
// License, or (at your option) any later version
|
|
|
|
|
// ==============================================================
|
|
|
|
|
|
|
|
|
|
#ifndef _GLEST_GAME_GAMESETTINGS_H_
|
|
|
|
|
#define _GLEST_GAME_GAMESETTINGS_H_
|
|
|
|
|
|
|
|
|
|
#include "game_constants.h"
|
2010-06-03 07:52:17 +00:00
|
|
|
|
#include "conversion.h"
|
2010-09-07 05:25:40 +00:00
|
|
|
|
#include "leak_dumper.h"
|
2010-06-03 07:52:17 +00:00
|
|
|
|
|
|
|
|
|
using namespace Shared::Util;
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
|
|
|
|
namespace Glest{ namespace Game{
|
|
|
|
|
|
|
|
|
|
// =====================================================
|
|
|
|
|
// class GameSettings
|
|
|
|
|
// =====================================================
|
|
|
|
|
|
2011-01-20 15:56:30 +00:00
|
|
|
|
enum FlagTypes1 {
|
|
|
|
|
ft1_none = 0x00,
|
|
|
|
|
ft1_show_map_resources = 0x01
|
|
|
|
|
//ft1_xx = 0x02,
|
|
|
|
|
//ft1_xx = 0x04,
|
|
|
|
|
//ft1_xx = 0x08,
|
|
|
|
|
//ft1_xx = 0x10,
|
|
|
|
|
};
|
2010-12-19 08:04:25 +00:00
|
|
|
|
|
|
|
|
|
|
2011-01-09 04:49:21 +00:00
|
|
|
|
class GameSettings {
|
2010-03-27 07:09:34 +00:00
|
|
|
|
private:
|
|
|
|
|
string description;
|
|
|
|
|
string map;
|
|
|
|
|
string tileset;
|
|
|
|
|
string tech;
|
|
|
|
|
string scenario;
|
|
|
|
|
string scenarioDir;
|
|
|
|
|
string factionTypeNames[GameConstants::maxPlayers]; //faction names
|
2010-04-22 23:18:04 +00:00
|
|
|
|
string networkPlayerNames[GameConstants::maxPlayers];
|
2011-03-11 11:11:46 +00:00
|
|
|
|
int networkPlayerStatuses[GameConstants::maxPlayers];
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
|
|
|
|
ControlType factionControls[GameConstants::maxPlayers];
|
2010-11-25 22:45:08 +00:00
|
|
|
|
int resourceMultiplierIndex[GameConstants::maxPlayers];
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
|
|
|
|
int thisFactionIndex;
|
|
|
|
|
int factionCount;
|
|
|
|
|
int teams[GameConstants::maxPlayers];
|
|
|
|
|
int startLocationIndex[GameConstants::maxPlayers];
|
2010-08-30 20:02:58 +00:00
|
|
|
|
int mapFilterIndex;
|
2010-12-19 08:04:25 +00:00
|
|
|
|
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
|
|
|
|
bool defaultUnits;
|
|
|
|
|
bool defaultResources;
|
|
|
|
|
bool defaultVictoryConditions;
|
|
|
|
|
|
|
|
|
|
bool fogOfWar;
|
2010-09-04 01:24:17 +00:00
|
|
|
|
bool allowObservers;
|
2010-05-31 10:20:18 +00:00
|
|
|
|
bool enableObserverModeAtEndGame;
|
2010-06-03 01:10:40 +00:00
|
|
|
|
bool enableServerControlledAI;
|
2010-06-05 07:52:14 +00:00
|
|
|
|
int networkFramePeriod;
|
2010-07-16 16:53:19 +00:00
|
|
|
|
bool networkPauseGameForLaggedClients;
|
2010-07-21 18:21:40 +00:00
|
|
|
|
PathFinderType pathFinderType;
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
2010-12-19 08:04:25 +00:00
|
|
|
|
uint32 flagTypes1;
|
|
|
|
|
|
2011-01-09 04:49:21 +00:00
|
|
|
|
int32 mapCRC;
|
|
|
|
|
int32 tilesetCRC;
|
|
|
|
|
int32 techCRC;
|
2011-03-19 12:04:18 +00:00
|
|
|
|
vector<pair<string,int32> > factionCRCList;
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
2011-01-09 04:49:21 +00:00
|
|
|
|
public:
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
2010-08-21 13:04:52 +00:00
|
|
|
|
GameSettings() {
|
|
|
|
|
thisFactionIndex = 0;
|
|
|
|
|
fogOfWar = true;
|
2010-09-04 01:24:17 +00:00
|
|
|
|
allowObservers = false;
|
2010-07-21 18:21:40 +00:00
|
|
|
|
enableObserverModeAtEndGame = false;
|
|
|
|
|
enableServerControlledAI = false;
|
|
|
|
|
networkFramePeriod = GameConstants::networkFramePeriod;
|
2010-07-16 16:53:19 +00:00
|
|
|
|
networkPauseGameForLaggedClients = false;
|
2010-07-21 18:21:40 +00:00
|
|
|
|
pathFinderType = pfBasic;
|
2010-06-25 04:06:28 +00:00
|
|
|
|
|
|
|
|
|
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
|
|
|
|
factionTypeNames[i] = "";
|
|
|
|
|
networkPlayerNames[i] = "";
|
2011-03-11 11:11:46 +00:00
|
|
|
|
networkPlayerStatuses[i] = 0;
|
2010-06-25 04:06:28 +00:00
|
|
|
|
factionControls[i] = ctClosed;
|
2010-11-25 22:45:08 +00:00
|
|
|
|
resourceMultiplierIndex[i] = 1.0f;
|
2010-06-25 04:06:28 +00:00
|
|
|
|
teams[i] = 0;
|
|
|
|
|
startLocationIndex[i] = i;
|
|
|
|
|
}
|
2010-12-19 08:04:25 +00:00
|
|
|
|
|
|
|
|
|
flagTypes1 = ft1_none;
|
2011-01-09 04:49:21 +00:00
|
|
|
|
|
|
|
|
|
mapCRC = 0;
|
|
|
|
|
tilesetCRC = 0;
|
|
|
|
|
techCRC = 0;
|
2011-03-19 12:04:18 +00:00
|
|
|
|
factionCRCList.clear();
|
2010-04-21 23:13:39 +00:00
|
|
|
|
}
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
|
|
|
|
// default copy constructor will do fine, and will maintain itself ;)
|
|
|
|
|
|
|
|
|
|
//get
|
|
|
|
|
const string &getDescription() const {return description;}
|
|
|
|
|
const string &getMap() const {return map;}
|
|
|
|
|
const string &getTileset() const {return tileset;}
|
|
|
|
|
const string &getTech() const {return tech;}
|
|
|
|
|
const string &getScenario() const {return scenario;}
|
|
|
|
|
const string &getScenarioDir() const {return scenarioDir;}
|
|
|
|
|
const string &getFactionTypeName(int factionIndex) const {return factionTypeNames[factionIndex];}
|
2010-06-01 16:54:44 +00:00
|
|
|
|
const string &getNetworkPlayerName(int factionIndex) const {return networkPlayerNames[factionIndex];}
|
2011-03-11 11:11:46 +00:00
|
|
|
|
const int getNetworkPlayerStatuses(int factionIndex) const { return networkPlayerStatuses[factionIndex];}
|
|
|
|
|
|
2010-10-23 04:00:39 +00:00
|
|
|
|
const string getNetworkPlayerNameByPlayerIndex(int playerIndex) const {
|
|
|
|
|
string result = "";
|
|
|
|
|
for(int i = 0; i < GameConstants::maxPlayers; ++i) {
|
|
|
|
|
if(startLocationIndex[i] == playerIndex) {
|
|
|
|
|
result = networkPlayerNames[i];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-03-27 07:09:34 +00:00
|
|
|
|
ControlType getFactionControl(int factionIndex) const {return factionControls[factionIndex];}
|
2010-11-25 22:45:08 +00:00
|
|
|
|
int getResourceMultiplierIndex(int factionIndex) const {return resourceMultiplierIndex[factionIndex];}
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
2010-06-01 16:54:44 +00:00
|
|
|
|
bool isNetworkGame() const {
|
|
|
|
|
bool result = false;
|
|
|
|
|
for(int idx = 0; idx < GameConstants::maxPlayers; ++idx) {
|
|
|
|
|
if(factionControls[idx] == ctNetwork) {
|
|
|
|
|
result = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-03-27 07:09:34 +00:00
|
|
|
|
int getThisFactionIndex() const {return thisFactionIndex;}
|
|
|
|
|
int getFactionCount() const {return factionCount;}
|
|
|
|
|
int getTeam(int factionIndex) const {return teams[factionIndex];}
|
|
|
|
|
int getStartLocationIndex(int factionIndex) const {return startLocationIndex[factionIndex];}
|
2010-08-30 20:02:58 +00:00
|
|
|
|
int getMapFilterIndex() const {return mapFilterIndex;}
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
|
|
|
|
bool getDefaultUnits() const {return defaultUnits;}
|
|
|
|
|
bool getDefaultResources() const {return defaultResources;}
|
|
|
|
|
bool getDefaultVictoryConditions() const {return defaultVictoryConditions;}
|
|
|
|
|
|
|
|
|
|
bool getFogOfWar() const {return fogOfWar;}
|
2010-09-04 01:24:17 +00:00
|
|
|
|
bool getAllowObservers() const { return allowObservers;}
|
2010-05-31 10:20:18 +00:00
|
|
|
|
bool getEnableObserverModeAtEndGame() const {return enableObserverModeAtEndGame;}
|
2010-06-03 01:10:40 +00:00
|
|
|
|
bool getEnableServerControlledAI() const {return enableServerControlledAI;}
|
2010-06-05 07:52:14 +00:00
|
|
|
|
int getNetworkFramePeriod() const {return networkFramePeriod; }
|
2010-07-16 16:53:19 +00:00
|
|
|
|
bool getNetworkPauseGameForLaggedClients() const {return networkPauseGameForLaggedClients; }
|
2010-07-21 18:21:40 +00:00
|
|
|
|
PathFinderType getPathFinderType() const { return pathFinderType; }
|
2010-12-19 08:04:25 +00:00
|
|
|
|
uint32 getFlagTypes1() const { return flagTypes1;}
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
2011-01-09 04:49:21 +00:00
|
|
|
|
int32 getMapCRC() const { return mapCRC; }
|
|
|
|
|
int32 getTilesetCRC() const { return tilesetCRC; }
|
|
|
|
|
int32 getTechCRC() const { return techCRC; }
|
2011-03-19 12:04:18 +00:00
|
|
|
|
vector<pair<string,int32> > getFactionCRCList() const { return factionCRCList; }
|
2011-01-09 04:49:21 +00:00
|
|
|
|
|
2010-03-27 07:09:34 +00:00
|
|
|
|
//set
|
|
|
|
|
void setDescription(const string& description) {this->description= description;}
|
|
|
|
|
void setMap(const string& map) {this->map= map;}
|
|
|
|
|
void setTileset(const string& tileset) {this->tileset= tileset;}
|
|
|
|
|
void setTech(const string& tech) {this->tech= tech;}
|
|
|
|
|
void setScenario(const string& scenario) {this->scenario= scenario;}
|
|
|
|
|
void setScenarioDir(const string& scenarioDir) {this->scenarioDir= scenarioDir;}
|
|
|
|
|
|
|
|
|
|
void setFactionTypeName(int factionIndex, const string& factionTypeName) {this->factionTypeNames[factionIndex]= factionTypeName;}
|
2010-05-31 19:57:10 +00:00
|
|
|
|
void setNetworkPlayerName(int factionIndex,const string& playername) {this->networkPlayerNames[factionIndex]= playername;}
|
2011-03-11 11:11:46 +00:00
|
|
|
|
void setNetworkPlayerStatuses(int factionIndex,int status) {this->networkPlayerStatuses[factionIndex]= status;}
|
2010-05-31 19:57:10 +00:00
|
|
|
|
void setFactionControl(int factionIndex, ControlType controller) {this->factionControls[factionIndex]= controller;}
|
2011-03-11 11:11:46 +00:00
|
|
|
|
void setResourceMultiplierIndex(int factionIndex, int multiplierIndex) {this->resourceMultiplierIndex[factionIndex]= multiplierIndex;}
|
2010-12-19 08:04:25 +00:00
|
|
|
|
|
2010-03-27 07:09:34 +00:00
|
|
|
|
void setThisFactionIndex(int thisFactionIndex) {this->thisFactionIndex= thisFactionIndex;}
|
|
|
|
|
void setFactionCount(int factionCount) {this->factionCount= factionCount;}
|
|
|
|
|
void setTeam(int factionIndex, int team) {this->teams[factionIndex]= team;}
|
|
|
|
|
void setStartLocationIndex(int factionIndex, int startLocationIndex) {this->startLocationIndex[factionIndex]= startLocationIndex;}
|
2010-08-30 20:02:58 +00:00
|
|
|
|
void setMapFilterIndex(int mapFilterIndex) {this->mapFilterIndex=mapFilterIndex;}
|
2010-03-27 07:09:34 +00:00
|
|
|
|
|
|
|
|
|
void setDefaultUnits(bool defaultUnits) {this->defaultUnits= defaultUnits;}
|
|
|
|
|
void setDefaultResources(bool defaultResources) {this->defaultResources= defaultResources;}
|
|
|
|
|
void setDefaultVictoryConditions(bool defaultVictoryConditions) {this->defaultVictoryConditions= defaultVictoryConditions;}
|
|
|
|
|
|
2010-05-31 10:20:18 +00:00
|
|
|
|
void setFogOfWar(bool fogOfWar) {this->fogOfWar = fogOfWar;}
|
2010-09-04 01:24:17 +00:00
|
|
|
|
void setAllowObservers(bool value) {this->allowObservers = value;}
|
2010-05-31 10:20:18 +00:00
|
|
|
|
void setEnableObserverModeAtEndGame(bool value) {this->enableObserverModeAtEndGame = value;}
|
2010-06-03 01:10:40 +00:00
|
|
|
|
void setEnableServerControlledAI(bool value) {this->enableServerControlledAI = value;}
|
2010-06-05 07:52:14 +00:00
|
|
|
|
void setNetworkFramePeriod(int value) {this->networkFramePeriod = value; }
|
2010-07-16 16:53:19 +00:00
|
|
|
|
void setNetworkPauseGameForLaggedClients(bool value) {this->networkPauseGameForLaggedClients = value; }
|
2010-07-21 18:21:40 +00:00
|
|
|
|
void setPathFinderType(PathFinderType value) {this->pathFinderType = value; }
|
2011-01-09 04:49:21 +00:00
|
|
|
|
|
2010-12-19 08:04:25 +00:00
|
|
|
|
void setFlagTypes1(uint32 value) {this->flagTypes1 = value; }
|
2010-06-03 07:52:17 +00:00
|
|
|
|
|
2011-01-09 04:49:21 +00:00
|
|
|
|
void setMapCRC(int32 value) { mapCRC = value; }
|
|
|
|
|
void setTilesetCRC(int32 value) { tilesetCRC = value; }
|
|
|
|
|
void setTechCRC(int32 value) { techCRC = value; }
|
|
|
|
|
|
2011-03-19 12:04:18 +00:00
|
|
|
|
void setFactionCRCList(vector<pair<string,int32> > value) { factionCRCList = value; }
|
|
|
|
|
|
2010-06-03 07:52:17 +00:00
|
|
|
|
string toString() const {
|
|
|
|
|
string result = "";
|
|
|
|
|
|
|
|
|
|
result += "description = " + description + "\n";
|
2010-08-30 20:02:58 +00:00
|
|
|
|
result += "mapFilterIndex = " + intToStr(mapFilterIndex) + "\n";
|
2010-06-03 07:52:17 +00:00
|
|
|
|
result += "map = " + map + "\n";
|
|
|
|
|
result += "tileset = " + tileset + "\n";
|
|
|
|
|
result += "tech = " + tech + "\n";
|
|
|
|
|
result += "scenario = " + scenario + "\n";
|
|
|
|
|
result += "scenarioDir = " + scenarioDir + "\n";
|
|
|
|
|
|
|
|
|
|
for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
|
|
|
|
|
result += "player index = " + intToStr(idx) + "\n";
|
|
|
|
|
result += "factionTypeName = " + factionTypeNames[idx] + "\n";
|
|
|
|
|
result += "networkPlayerName = " + networkPlayerNames[idx] + "\n";
|
|
|
|
|
|
|
|
|
|
result += "factionControl = " + intToStr(factionControls[idx]) + "\n";
|
2010-11-25 22:45:08 +00:00
|
|
|
|
result += "resourceMultiplierIndex = " + intToStr(resourceMultiplierIndex[idx]) + "\n";
|
2010-06-03 07:52:17 +00:00
|
|
|
|
result += "team = " + intToStr(teams[idx]) + "\n";
|
|
|
|
|
result += "startLocationIndex = " + intToStr(startLocationIndex[idx]) + "\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result += "thisFactionIndex = " + intToStr(thisFactionIndex) + "\n";
|
|
|
|
|
result += "factionCount = " + intToStr(factionCount) + "\n";
|
|
|
|
|
result += "defaultUnits = " + intToStr(defaultUnits) + "\n";
|
|
|
|
|
result += "defaultResources = " + intToStr(defaultResources) + "\n";
|
|
|
|
|
result += "defaultVictoryConditions = " + intToStr(defaultVictoryConditions) + "\n";
|
|
|
|
|
result += "fogOfWar = " + intToStr(fogOfWar) + "\n";
|
2010-09-04 01:24:17 +00:00
|
|
|
|
result += "allowObservers = " + intToStr(allowObservers) + "\n";
|
2010-06-03 07:52:17 +00:00
|
|
|
|
result += "enableObserverModeAtEndGame = " + intToStr(enableObserverModeAtEndGame) + "\n";
|
|
|
|
|
result += "enableServerControlledAI = " + intToStr(enableServerControlledAI) + "\n";
|
2010-06-05 07:52:14 +00:00
|
|
|
|
result += "networkFramePeriod = " + intToStr(networkFramePeriod) + "\n";
|
2010-07-16 16:53:19 +00:00
|
|
|
|
result += "networkPauseGameForLaggedClients = " + intToStr(networkPauseGameForLaggedClients) + "\n";
|
2010-07-21 18:21:40 +00:00
|
|
|
|
result += "pathFinderType = " + intToStr(pathFinderType) + "\n";
|
2010-12-19 08:04:25 +00:00
|
|
|
|
result += "flagTypes1 = " + intToStr(flagTypes1) + "\n";
|
2011-01-09 04:49:21 +00:00
|
|
|
|
result += "mapCRC = " + intToStr(mapCRC) + "\n";
|
|
|
|
|
result += "tilesetCRC = " + intToStr(tilesetCRC) + "\n";
|
|
|
|
|
result += "techCRC = " + intToStr(techCRC) + "\n";
|
2010-06-03 07:52:17 +00:00
|
|
|
|
|
2011-03-19 12:04:18 +00:00
|
|
|
|
for(unsigned int i = 0; i < factionCRCList.size(); ++i) {
|
|
|
|
|
result += "factionCRCList name [" + factionCRCList[i].first + "] CRC = " + intToStr(factionCRCList[i].second) + "\n";
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-03 07:52:17 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-03-27 07:09:34 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}}//end namespace
|
|
|
|
|
|
|
|
|
|
#endif
|