1 // ==============================================================
2 //	This file is part of Glest (www.glest.org)
3 //
4 //	Copyright (C) 2001-2008 Martiño Figueroa
5 //
6 //	You can redistribute this code and/or modify it under
7 //	the terms of the GNU General Public License as published
8 //	by the Free Software Foundation; either version 2 of the
9 //	License, or (at your option) any later version
10 // ==============================================================
11 
12 #ifndef _GLEST_GAME_GAMESETTINGS_H_
13 #define _GLEST_GAME_GAMESETTINGS_H_
14 
15 #include "game_constants.h"
16 #include "conversion.h"
17 #include <algorithm>
18 #include "xml_parser.h"
19 #include "config.h"
20 #include "platform_common.h"
21 #include "conversion.h"
22 #include "platform_util.h"
23 #include "leak_dumper.h"
24 
25 using namespace Shared::Util;
26 using namespace Shared::PlatformCommon;
27 using namespace Shared::Platform;
28 using Shared::Xml::XmlNode;
29 
30 namespace Glest{ namespace Game{
31 
32 enum ModType {
33     mt_None,
34     mt_Map,
35     mt_Tileset,
36     mt_Techtree,
37     mt_Scenario
38 };
39 
40 // ===============================
41 // 	class ModInfo
42 // ===============================
43 
44 class ModInfo {
45 public:
46 	string name;
47 	string url;
48 	string imageUrl;
49 	string description;
50 	string count; // used for faction count for example
51 	string crc;
52 	string localCRC;
53 	ModType type;
54 public:
55 	ModInfo();
56 };
57 
58 // =====================================================
59 //	class GameSettings
60 // =====================================================
61 
62 enum FlagTypes1 {
63     ft1_none                			= 0x00,
64     ft1_show_map_resources  			= 0x01,
65     ft1_allow_team_switching  			= 0x02,
66     ft1_allow_in_game_joining 			= 0x04,
67     ft1_network_synch_checks_verbose 	= 0x08,
68     ft1_network_synch_checks 			= 0x10,
69     ft1_allow_shared_team_units         = 0x20,
70     ft1_allow_shared_team_resources     = 0x40
71     //ft1_xxx = 0x80
72 };
73 
isFlagType1BitEnabled(uint32 flagValue,FlagTypes1 type)74 inline static bool isFlagType1BitEnabled(uint32 flagValue,FlagTypes1 type) {
75 	return ((flagValue & (uint32)type) == (uint32)type);
76 }
77 
78 enum NetworkPlayerStatusType {
79 	npst_None					= 0,
80 	npst_PickSettings			= 1,
81 	npst_BeRightBack			= 2,
82 	npst_Ready					= 3,
83 	npst_Disconnected			= 4
84 };
85 
86 class GameSettings {
87 private:
88 	string gameName;
89 	string description;
90 	string map;
91 	string tileset;
92 	string tech;
93 	string scenario;
94 	string scenarioDir;
95 	string factionTypeNames[GameConstants::maxPlayers]; //faction names
96 	string networkPlayerNames[GameConstants::maxPlayers];
97 	string networkPlayerPlatform[GameConstants::maxPlayers];
98 	int    networkPlayerStatuses[GameConstants::maxPlayers];
99 	string networkPlayerLanguages[GameConstants::maxPlayers];
100 	int    networkPlayerGameStatus[GameConstants::maxPlayers];
101 
102 	ControlType factionControls[GameConstants::maxPlayers];
103 	int resourceMultiplierIndex[GameConstants::maxPlayers];
104 	string networkPlayerUUID[GameConstants::maxPlayers];
105 
106 
107 	int thisFactionIndex;
108 	int factionCount;
109 	int teams[GameConstants::maxPlayers];
110 	int startLocationIndex[GameConstants::maxPlayers];
111 	int mapFilter;
112 
113 	int fallbackCpuMultiplier;
114 	bool defaultUnits;
115 	bool defaultResources;
116 	bool defaultVictoryConditions;
117 
118 	bool fogOfWar;
119 	bool allowObservers;
120 	bool enableObserverModeAtEndGame;
121 	bool enableServerControlledAI;
122 	int networkFramePeriod;
123 	bool networkPauseGameForLaggedClients;
124 	PathFinderType pathFinderType;
125 
126 	uint32 flagTypes1;
127 
128     uint32 mapCRC;
129     uint32 tilesetCRC;
130     uint32 techCRC;
131     vector<pair<string,uint32> > factionCRCList;
132 
133     int aiAcceptSwitchTeamPercentChance;
134     int masterserver_admin;
135 
136     int masterserver_admin_factionIndex;
137 
138     bool networkAllowNativeLanguageTechtree;
139 
140     string gameUUID;
141 
142 public:
143 
144     static string playerDisconnectedText;
145 
GameSettings()146     GameSettings() {
147     	defaultUnits=false;
148     	defaultResources=false;
149     	defaultVictoryConditions=false;
150     	mapFilter						= 0;
151     	factionCount						= 0;
152     	thisFactionIndex					= 0;
153     	fogOfWar 							= true;
154     	allowObservers						= false;
155     	enableObserverModeAtEndGame 		= false;
156     	enableServerControlledAI    		= false;
157     	networkFramePeriod					= GameConstants::networkFramePeriod;
158     	networkPauseGameForLaggedClients 	= false;
159     	pathFinderType						= pfBasic;
160 
161     	static const string DEFAULT_LANG = "english";
162     	for(int i = 0; i < GameConstants::maxPlayers; ++i) {
163     		factionTypeNames[i] = "";
164     		networkPlayerNames[i] = "";
165     		networkPlayerPlatform[i] = "";
166     		networkPlayerStatuses[i] = npst_None;
167     		networkPlayerLanguages[i] = DEFAULT_LANG;
168     		factionControls[i] = ctClosed;
169     		resourceMultiplierIndex[i] = 1.0f;
170     		teams[i] = 0;
171     		startLocationIndex[i] = i;
172     		networkPlayerGameStatus[i] = 0;
173 
174     		networkPlayerUUID[i] = "";
175     	}
176 
177     	flagTypes1 = ft1_none;
178 
179 		mapCRC      = 0;
180 		tilesetCRC  = 0;
181 		techCRC     = 0;
182 		factionCRCList.clear();
183 		aiAcceptSwitchTeamPercentChance = 30;
184 		masterserver_admin = -1;
185 		masterserver_admin_factionIndex = -1;
186     	fallbackCpuMultiplier = 1.0f;
187     	networkAllowNativeLanguageTechtree = true;
188     }
189 
190 	// default copy constructor will do fine, and will maintain itself ;)
191 
192 	//get
getGameName()193 	const string &getGameName() const							{return gameName;}
getDescription()194 	const string &getDescription() const							{return description;}
getMap()195 	const string &getMap() const 									{return map;}
getTileset()196 	const string &getTileset() const								{return tileset;}
getTech()197 	const string &getTech() const									{return tech;}
getScenario()198 	const string &getScenario() const								{return scenario;}
getScenarioDir()199 	const string &getScenarioDir() const							{return scenarioDir;}
getFactionTypeName(int factionIndex)200 	const string &getFactionTypeName(int factionIndex) const {
201 		if(factionIndex == -1) {
202 			static string HEADLESS_FACTION = "headless-server";
203 			return HEADLESS_FACTION;
204 		}
205 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
206 			char szBuf[8096]="";
207 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
208 			throw megaglest_runtime_error(szBuf);
209 		}
210 		return factionTypeNames[factionIndex];
211 	}
getNetworkPlayerName(int factionIndex)212 	string getNetworkPlayerName(int factionIndex) const  {
213 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
214 			char szBuf[8096]="";
215 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
216 			throw megaglest_runtime_error(szBuf);
217 		}
218 
219 		string result = networkPlayerNames[factionIndex];
220 		if(networkPlayerStatuses[factionIndex] == npst_Disconnected) {
221 			result = playerDisconnectedText + result;
222 		}
223 		return result;
224 	}
getNetworkPlayerPlatform(int factionIndex)225 	string getNetworkPlayerPlatform(int factionIndex) const  {
226 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
227 			char szBuf[8096]="";
228 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
229 			throw megaglest_runtime_error(szBuf);
230 		}
231 
232 		string result = networkPlayerPlatform[factionIndex];
233 		return result;
234 	}
235 
getNetworkPlayerStatuses(int factionIndex)236 	const int    getNetworkPlayerStatuses(int factionIndex) const {
237 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
238 			char szBuf[8096]="";
239 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
240 			throw megaglest_runtime_error(szBuf);
241 		}
242 
243 		return networkPlayerStatuses[factionIndex];
244 	}
getNetworkPlayerLanguages(int factionIndex)245 	const string getNetworkPlayerLanguages(int factionIndex) const {
246 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
247 			char szBuf[8096]="";
248 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
249 			throw megaglest_runtime_error(szBuf);
250 		}
251 
252 		return networkPlayerLanguages[factionIndex];
253 	}
254 
getNetworkPlayerGameStatus(int factionIndex)255 	const int    getNetworkPlayerGameStatus(int factionIndex) const {
256 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
257 			char szBuf[8096]="";
258 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
259 			throw megaglest_runtime_error(szBuf);
260 		}
261 
262 		return networkPlayerGameStatus[factionIndex];
263 	}
264 
getUniqueNetworkPlayerLanguages()265 	const vector<string> getUniqueNetworkPlayerLanguages() const {
266 		vector<string> languageList;
267 		for(int i = 0; i < GameConstants::maxPlayers; ++i) {
268 			if(networkPlayerLanguages[i] != "") {
269 				if(std::find(languageList.begin(),languageList.end(),networkPlayerLanguages[i]) == languageList.end()) {
270 					languageList.push_back(networkPlayerLanguages[i]);
271 				}
272 			}
273 		}
274 		if(languageList.empty() == true) {
275 			languageList.push_back("");
276 		}
277 		return languageList;
278 	}
279 
getNetworkPlayerNameByPlayerIndex(int playerIndex)280 	const string getNetworkPlayerNameByPlayerIndex(int playerIndex) const  {
281 		string result = "";
282 		for(int i = 0; i < GameConstants::maxPlayers; ++i) {
283 			if(startLocationIndex[i] == playerIndex) {
284 				result = networkPlayerNames[i];
285 				break;
286 			}
287 		}
288 		return result;
289 	}
getNetworkPlayerPlatformByPlayerIndex(int playerIndex)290 	const string getNetworkPlayerPlatformByPlayerIndex(int playerIndex) const  {
291 		string result = "";
292 		for(int i = 0; i < GameConstants::maxPlayers; ++i) {
293 			if(startLocationIndex[i] == playerIndex) {
294 				result = networkPlayerPlatform[i];
295 				break;
296 			}
297 		}
298 		return result;
299 	}
300 
getFactionControl(int factionIndex)301 	ControlType getFactionControl(int factionIndex) const {
302 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
303 			char szBuf[8096]="";
304 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
305 			throw megaglest_runtime_error(szBuf);
306 		}
307 
308 		return factionControls[factionIndex];
309 	}
getResourceMultiplierIndex(int factionIndex)310 	int getResourceMultiplierIndex(int factionIndex) const	{
311 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
312 			char szBuf[8096]="";
313 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
314 			throw megaglest_runtime_error(szBuf);
315 		}
316 
317 		return resourceMultiplierIndex[factionIndex];
318 	}
319 
getNetworkPlayerUUID(int factionIndex)320 	const string &getNetworkPlayerUUID(int factionIndex) const {
321 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
322 			char szBuf[8096]="";
323 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
324 			throw megaglest_runtime_error(szBuf);
325 		}
326 		return networkPlayerUUID[factionIndex];
327 	}
328 
isNetworkGame()329 	bool isNetworkGame() const {
330 		bool result = false;
331 		for(int idx = 0; idx < GameConstants::maxPlayers; ++idx) {
332 			if(factionControls[idx] == ctNetwork || factionControls[idx] == ctNetworkUnassigned ||
333 				networkPlayerStatuses[idx] == npst_Disconnected) {
334 				result = true;
335 				break;
336 			}
337 		}
338 		return result;
339 	}
getThisFactionIndex()340 	int getThisFactionIndex() const						{return thisFactionIndex;}
getFactionCount()341 	int getFactionCount() const							{return factionCount;}
getTeam(int factionIndex)342 	int getTeam(int factionIndex) const					{
343 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
344 			char szBuf[8096]="";
345 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
346 			throw megaglest_runtime_error(szBuf);
347 		}
348 
349 		return teams[factionIndex];
350 	}
351 
getStartLocationIndex(int factionIndex)352 	int getStartLocationIndex(int factionIndex) const {
353 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
354 			char szBuf[8096]="";
355 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
356 			throw megaglest_runtime_error(szBuf);
357 		}
358 
359 		return startLocationIndex[factionIndex];
360 	}
getFactionIndexForStartLocation(int startIndex)361 	int getFactionIndexForStartLocation(int startIndex) const {
362 		if(startIndex < 0 || startIndex >= GameConstants::maxPlayers) {
363 			char szBuf[8096]="";
364 			snprintf(szBuf,8096,"In [%s] Invalid startIndex = %d\n",__FUNCTION__,startIndex);
365 			throw megaglest_runtime_error(szBuf);
366 		}
367 
368 		for(int i =0; i < GameConstants::maxPlayers; ++i) {
369 			if(startLocationIndex[i] == startIndex) {
370 				return i;
371 			}
372 		}
373 		return -1;
374 	}
375 
getMapFilter()376 	int getMapFilter() const 						{return mapFilter;}
377 
getDefaultUnits()378 	bool getDefaultUnits() const				{return defaultUnits;}
getDefaultResources()379 	bool getDefaultResources() const			{return defaultResources;}
getDefaultVictoryConditions()380 	bool getDefaultVictoryConditions() const	{return defaultVictoryConditions;}
381 
getFogOfWar()382 	bool getFogOfWar() const					{return fogOfWar;}
getAllowObservers()383 	bool getAllowObservers() const				{ return allowObservers;}
getEnableObserverModeAtEndGame()384 	bool getEnableObserverModeAtEndGame() const {return enableObserverModeAtEndGame;}
getEnableServerControlledAI()385 	bool getEnableServerControlledAI() 	  const {return enableServerControlledAI;}
getNetworkFramePeriod()386 	int getNetworkFramePeriod()			  const {return networkFramePeriod; }
getNetworkPauseGameForLaggedClients()387 	bool getNetworkPauseGameForLaggedClients()	  const {return networkPauseGameForLaggedClients; }
getPathFinderType()388 	PathFinderType getPathFinderType() const { return pathFinderType; }
getFlagTypes1()389 	uint32 getFlagTypes1() const             { return flagTypes1;}
390 
getMapCRC()391 	uint32 getMapCRC() const { return mapCRC; }
getTilesetCRC()392 	uint32 getTilesetCRC() const { return tilesetCRC; }
getTechCRC()393 	uint32 getTechCRC() const { return techCRC; }
getFactionCRCList()394 	vector<pair<string,uint32> > getFactionCRCList() const { return factionCRCList; }
395 
getGameUUID()396 	const string &getGameUUID() const								{return gameUUID;}
397 
398 	//set
setGameName(const string & gameName)399 	void setGameName(const string& gameName)						{this->gameName= gameName;}
setDescription(const string & description)400 	void setDescription(const string& description)						{this->description= description;}
setMap(const string & map)401 	void setMap(const string& map)										{this->map= map;}
setTileset(const string & tileset)402 	void setTileset(const string& tileset)								{this->tileset= tileset;}
setTech(const string & tech)403 	void setTech(const string& tech)									{this->tech= tech;}
setScenario(const string & scenario)404 	void setScenario(const string& scenario)							{this->scenario= scenario;}
setScenarioDir(const string & scenarioDir)405 	void setScenarioDir(const string& scenarioDir)						{this->scenarioDir= scenarioDir;}
406 
setFactionTypeName(int factionIndex,const string & factionTypeName)407 	void setFactionTypeName(int factionIndex, const string& factionTypeName) {
408 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
409 			char szBuf[8096]="";
410 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
411 			throw megaglest_runtime_error(szBuf);
412 		}
413 
414 		this->factionTypeNames[factionIndex]= factionTypeName;
415 	}
setNetworkPlayerName(int factionIndex,const string & playername)416 	void setNetworkPlayerName(int factionIndex,const string& playername) {
417 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
418 			char szBuf[8096]="";
419 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
420 			throw megaglest_runtime_error(szBuf);
421 		}
422 
423 		this->networkPlayerNames[factionIndex]= playername;
424 	}
setNetworkPlayerPlatform(int factionIndex,const string & platform)425 	void setNetworkPlayerPlatform(int factionIndex,const string& platform) {
426 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
427 			char szBuf[8096]="";
428 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
429 			throw megaglest_runtime_error(szBuf);
430 		}
431 
432 		this->networkPlayerPlatform[factionIndex]= platform;
433 	}
434 
setNetworkPlayerStatuses(int factionIndex,int status)435 	void setNetworkPlayerStatuses(int factionIndex,int status) {
436 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
437 			char szBuf[8096]="";
438 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
439 			throw megaglest_runtime_error(szBuf);
440 		}
441 
442 		this->networkPlayerStatuses[factionIndex]= status;
443 	}
444 
setNetworkPlayerGameStatus(int factionIndex,int status)445 	void setNetworkPlayerGameStatus(int factionIndex,int status) {
446 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
447 			char szBuf[8096]="";
448 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
449 			throw megaglest_runtime_error(szBuf);
450 		}
451 
452 		this->networkPlayerGameStatus[factionIndex]= status;
453 	}
setNetworkPlayerLanguages(int factionIndex,string language)454 	void setNetworkPlayerLanguages(int factionIndex, string language) {
455 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
456 			char szBuf[8096]="";
457 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
458 			throw megaglest_runtime_error(szBuf);
459 		}
460 
461 		this->networkPlayerLanguages[factionIndex]=language;
462 	}
463 
setFactionControl(int factionIndex,ControlType controller)464 	void setFactionControl(int factionIndex, ControlType controller) {
465 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
466 			char szBuf[8096]="";
467 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
468 			throw megaglest_runtime_error(szBuf);
469 		}
470 
471 		this->factionControls[factionIndex]= controller;
472 	}
setResourceMultiplierIndex(int factionIndex,int multiplierIndex)473 	void setResourceMultiplierIndex(int factionIndex, int multiplierIndex)	{
474 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
475 			char szBuf[8096]="";
476 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
477 			throw megaglest_runtime_error(szBuf);
478 		}
479 
480 		//if(multiplierIndex >= 45) {
481 		//	printf("gamesettings Line: %d multiplier index: %d factionIndex: %d\n",__LINE__,multiplierIndex,factionIndex);
482 		//}
483 
484 		this->resourceMultiplierIndex[factionIndex]= multiplierIndex;
485 	}
486 
setNetworkPlayerUUID(int factionIndex,const string & uuid)487 	void setNetworkPlayerUUID(int factionIndex, const string& uuid) {
488 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
489 			char szBuf[8096]="";
490 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
491 			throw megaglest_runtime_error(szBuf);
492 		}
493 
494 		this->networkPlayerUUID[factionIndex]= uuid;
495 	}
496 
setThisFactionIndex(int thisFactionIndex)497 	void setThisFactionIndex(int thisFactionIndex) {
498 		this->thisFactionIndex= thisFactionIndex;
499 	}
setFactionCount(int factionCount)500 	void setFactionCount(int factionCount)									{this->factionCount= factionCount;}
setTeam(int factionIndex,int team)501 	void setTeam(int factionIndex, int team)	{
502 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
503 			char szBuf[8096]="";
504 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
505 			throw megaglest_runtime_error(szBuf);
506 		}
507 
508 		this->teams[factionIndex]= team;
509 	}
setStartLocationIndex(int factionIndex,int startLocationIndex)510 	void setStartLocationIndex(int factionIndex, int startLocationIndex) {
511 		if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
512 			char szBuf[8096]="";
513 			snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
514 			throw megaglest_runtime_error(szBuf);
515 		}
516 
517 		this->startLocationIndex[factionIndex]= startLocationIndex;
518 	}
setMapFilter(int mapFilter)519 	void setMapFilter(int mapFilter)								{this->mapFilter=mapFilter;}
520 
setDefaultUnits(bool defaultUnits)521 	void setDefaultUnits(bool defaultUnits) 						{this->defaultUnits= defaultUnits;}
setDefaultResources(bool defaultResources)522 	void setDefaultResources(bool defaultResources) 				{this->defaultResources= defaultResources;}
setDefaultVictoryConditions(bool defaultVictoryConditions)523 	void setDefaultVictoryConditions(bool defaultVictoryConditions) {this->defaultVictoryConditions= defaultVictoryConditions;}
524 
setFogOfWar(bool fogOfWar)525 	void setFogOfWar(bool fogOfWar)									{this->fogOfWar = fogOfWar;}
setAllowObservers(bool value)526 	void setAllowObservers(bool value)								{this->allowObservers = value;}
setEnableObserverModeAtEndGame(bool value)527 	void setEnableObserverModeAtEndGame(bool value) 				{this->enableObserverModeAtEndGame = value;}
setEnableServerControlledAI(bool value)528 	void setEnableServerControlledAI(bool value)					{this->enableServerControlledAI = value;}
setNetworkFramePeriod(int value)529 	void setNetworkFramePeriod(int value)							{this->networkFramePeriod = value; }
setNetworkPauseGameForLaggedClients(bool value)530 	void setNetworkPauseGameForLaggedClients(bool value)			{this->networkPauseGameForLaggedClients = value; }
setPathFinderType(PathFinderType value)531 	void setPathFinderType(PathFinderType value)					{this->pathFinderType = value; }
532 
setFlagTypes1(uint32 value)533 	void setFlagTypes1(uint32 value)                                {this->flagTypes1 = value; }
534 
setMapCRC(uint32 value)535 	void setMapCRC(uint32 value)     { mapCRC = value; }
setTilesetCRC(uint32 value)536 	void setTilesetCRC(uint32 value) { tilesetCRC = value; }
setTechCRC(uint32 value)537 	void setTechCRC(uint32 value)    { techCRC = value; }
538 
setFactionCRCList(vector<pair<string,uint32>> value)539 	void setFactionCRCList(vector<pair<string,uint32> > value) { factionCRCList = value; }
540 
getAiAcceptSwitchTeamPercentChance()541 	int getAiAcceptSwitchTeamPercentChance() const 				{ return aiAcceptSwitchTeamPercentChance;}
setAiAcceptSwitchTeamPercentChance(int value)542 	void setAiAcceptSwitchTeamPercentChance(int value)			{ aiAcceptSwitchTeamPercentChance = value; }
543 
getFallbackCpuMultiplier()544 	int getFallbackCpuMultiplier() const 					{ return fallbackCpuMultiplier;}
setFallbackCpuMultiplier(int value)545 	void setFallbackCpuMultiplier(int value)				{ fallbackCpuMultiplier = value; }
546 
getMasterserver_admin()547 	int getMasterserver_admin() const 						{ return masterserver_admin;}
setMasterserver_admin(int value)548 	void setMasterserver_admin(int value)					{ masterserver_admin = value; }
549 
getMasterserver_admin_faction_index()550 	int getMasterserver_admin_faction_index() const 		{ return masterserver_admin_factionIndex;}
setMasterserver_admin_faction_index(int value)551 	void setMasterserver_admin_faction_index(int value)		{ masterserver_admin_factionIndex = value; }
552 
getNetworkAllowNativeLanguageTechtree()553 	bool getNetworkAllowNativeLanguageTechtree() const 		{ return networkAllowNativeLanguageTechtree;}
setNetworkAllowNativeLanguageTechtree(bool value)554 	void setNetworkAllowNativeLanguageTechtree(bool value)	{ networkAllowNativeLanguageTechtree = value; }
555 
setGameUUID(const string & gameUUID)556 	void setGameUUID(const string& gameUUID)				{this->gameUUID= gameUUID;}
557 
toString()558 	string toString() const {
559 		string result = "";
560 
561 		result += "Game ID = " + gameUUID + "\n";
562 		result += "gameName = " + gameName + "\n";
563 		result += "description = " + description + "\n";
564 		result += "mapFilterIndex = " + intToStr(mapFilter) + "\n";
565 		result += "map = " + map + "\n";
566 		result += "tileset = " + tileset + "\n";
567 		result += "tech = " + tech + "\n";
568 		result += "scenario = " + scenario + "\n";
569 		result += "scenarioDir = " + scenarioDir + "\n";
570 
571 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
572 			result += "player index = " + intToStr(idx) + "\n";
573 			result += "factionTypeName = " + factionTypeNames[idx] + "\n";
574 			result += "networkPlayerName = " + networkPlayerNames[idx] + "\n";
575 			result += "networkPlayerPlatform = " + networkPlayerPlatform[idx] + "\n";
576 			result += "networkPlayerLanguage = " + networkPlayerLanguages[idx] + "\n";
577 
578 			result += "factionControl = " + intToStr(factionControls[idx]) + "\n";
579 			result += "resourceMultiplierIndex = " + intToStr(resourceMultiplierIndex[idx]) + "\n";
580 			result += "team = " + intToStr(teams[idx]) + "\n";
581 			result += "startLocationIndex = " + intToStr(startLocationIndex[idx]) + "\n";
582 			result += "networkPlayerUUID = " + networkPlayerUUID[idx] + "\n";
583 		}
584 
585 		result += "thisFactionIndex = " + intToStr(thisFactionIndex) + "\n";
586 		result += "factionCount = " + intToStr(factionCount) + "\n";
587 		result += "defaultUnits = " + intToStr(defaultUnits) + "\n";
588 		result += "defaultResources = " + intToStr(defaultResources) + "\n";
589 		result += "defaultVictoryConditions = " + intToStr(defaultVictoryConditions) + "\n";
590 		result += "fogOfWar = " + intToStr(fogOfWar) + "\n";
591 		result += "allowObservers = " + intToStr(allowObservers) + "\n";
592 		result += "enableObserverModeAtEndGame = " + intToStr(enableObserverModeAtEndGame) + "\n";
593 		result += "enableServerControlledAI = " + intToStr(enableServerControlledAI) + "\n";
594 		result += "networkFramePeriod = " + intToStr(networkFramePeriod) + "\n";
595 		result += "networkPauseGameForLaggedClients = " + intToStr(networkPauseGameForLaggedClients) + "\n";
596 		result += "pathFinderType = " + intToStr(pathFinderType) + "\n";
597 		result += "flagTypes1 = " + uIntToStr(flagTypes1) + "\n";
598 		result += "mapCRC = " + uIntToStr(mapCRC) + "\n";
599 		result += "tilesetCRC = " + uIntToStr(tilesetCRC) + "\n";
600 		result += "techCRC = " + uIntToStr(techCRC) + "\n";
601 
602 		for(unsigned int i = 0; i < factionCRCList.size(); ++i) {
603 			result += "factionCRCList name [" + factionCRCList[i].first + "] CRC = " + uIntToStr(factionCRCList[i].second) + "\n";
604 		}
605 
606 		result += "aiAcceptSwitchTeamPercentChance = " + intToStr(aiAcceptSwitchTeamPercentChance) + "\n";
607 		result += "masterserver_admin = " + intToStr(masterserver_admin) + "\n";
608 		result += "masterserver_admin_factionIndex = " + intToStr(masterserver_admin_factionIndex) + "\n";
609 
610 		result += "networkAllowNativeLanguageTechtree = " + intToStr(networkAllowNativeLanguageTechtree) + "\n";
611 		return result;
612 	}
613 
saveGame(XmlNode * rootNode)614 	void saveGame(XmlNode *rootNode) const {
615 		std::map<string,string> mapTagReplacements;
616 		XmlNode *gameSettingsNode = rootNode->addChild("GameSettings");
617 
618 		gameSettingsNode->addAttribute("gameUUID",gameUUID, mapTagReplacements);
619 
620 //		string gameName;
621 		gameSettingsNode->addAttribute("gameName",gameName, mapTagReplacements);
622 //		string description;
623 		gameSettingsNode->addAttribute("description",description, mapTagReplacements);
624 //		string map;
625 		gameSettingsNode->addAttribute("map",map, mapTagReplacements);
626 //		string tileset;
627 		gameSettingsNode->addAttribute("tileset",tileset, mapTagReplacements);
628 //		string tech;
629 		gameSettingsNode->addAttribute("tech",tech, mapTagReplacements);
630 //		string scenario;
631 		gameSettingsNode->addAttribute("scenario",scenario, mapTagReplacements);
632 //		string scenarioDir;
633 		gameSettingsNode->addAttribute("scenarioDir",scenarioDir, mapTagReplacements);
634 //		string factionTypeNames[GameConstants::maxPlayers]; //faction names
635 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
636 			XmlNode *factionTypeNamesNode = gameSettingsNode->addChild("factionTypeNames");
637 			factionTypeNamesNode->addAttribute("name",factionTypeNames[idx], mapTagReplacements);
638 		}
639 
640 //		string networkPlayerNames[GameConstants::maxPlayers];
641 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
642 			XmlNode *networkPlayerNamesNode = gameSettingsNode->addChild("networkPlayerNames");
643 			networkPlayerNamesNode->addAttribute("name",networkPlayerNames[idx], mapTagReplacements);
644 		}
645 
646 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
647 			XmlNode *networkPlayerNamesNode = gameSettingsNode->addChild("networkPlayerPlatform");
648 			networkPlayerNamesNode->addAttribute("name",networkPlayerPlatform[idx], mapTagReplacements);
649 		}
650 
651 //		int    networkPlayerStatuses[GameConstants::maxPlayers];
652 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
653 			XmlNode *networkPlayerStatusesNode = gameSettingsNode->addChild("networkPlayerStatuses");
654 			networkPlayerStatusesNode->addAttribute("status",intToStr(networkPlayerStatuses[idx]), mapTagReplacements);
655 		}
656 
657 		//		int    networkPlayerStatuses[GameConstants::maxPlayers];
658 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
659 			XmlNode *networkPlayerStatusesNode = gameSettingsNode->addChild("networkPlayerGameStatus");
660 			networkPlayerStatusesNode->addAttribute("game_status",intToStr(networkPlayerGameStatus[idx]), mapTagReplacements);
661 		}
662 
663 //		string networkPlayerLanguages[GameConstants::maxPlayers];
664 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
665 			XmlNode *networkPlayerLanguagesNode = gameSettingsNode->addChild("networkPlayerLanguages");
666 			networkPlayerLanguagesNode->addAttribute("name",networkPlayerLanguages[idx], mapTagReplacements);
667 		}
668 
669 //		ControlType factionControls[GameConstants::maxPlayers];
670 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
671 			XmlNode *factionControlsNode = gameSettingsNode->addChild("factionControls");
672 			factionControlsNode->addAttribute("control",intToStr(factionControls[idx]), mapTagReplacements);
673 		}
674 
675 //		int resourceMultiplierIndex[GameConstants::maxPlayers];
676 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
677 			XmlNode *resourceMultiplierIndexNode = gameSettingsNode->addChild("resourceMultiplierIndex");
678 			resourceMultiplierIndexNode->addAttribute("multiplier",intToStr(resourceMultiplierIndex[idx]), mapTagReplacements);
679 		}
680 
681 //		int thisFactionIndex;
682 		gameSettingsNode->addAttribute("thisFactionIndex",intToStr(thisFactionIndex), mapTagReplacements);
683 //		int factionCount;
684 		gameSettingsNode->addAttribute("factionCount",intToStr(factionCount), mapTagReplacements);
685 //		int teams[GameConstants::maxPlayers];
686 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
687 			XmlNode *teamsNode = gameSettingsNode->addChild("teams");
688 			teamsNode->addAttribute("team",intToStr(teams[idx]), mapTagReplacements);
689 		}
690 
691 //		int startLocationIndex[GameConstants::maxPlayers];
692 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
693 			XmlNode *startLocationIndexNode = gameSettingsNode->addChild("startLocationIndex");
694 			startLocationIndexNode->addAttribute("location",intToStr(startLocationIndex[idx]), mapTagReplacements);
695 		}
696 
697 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
698 			XmlNode *networkPlayerUUIDNode = gameSettingsNode->addChild("networkPlayerUUID");
699 			networkPlayerUUIDNode->addAttribute("value",networkPlayerUUID[idx], mapTagReplacements);
700 		}
701 
702 //		int mapFilterIndex;
703 		gameSettingsNode->addAttribute("mapFilterIndex",intToStr(mapFilter), mapTagReplacements);
704 //
705 //
706 //		bool defaultUnits;
707 		gameSettingsNode->addAttribute("defaultUnits",intToStr(defaultUnits), mapTagReplacements);
708 //		bool defaultResources;
709 		gameSettingsNode->addAttribute("defaultResources",intToStr(defaultResources), mapTagReplacements);
710 //		bool defaultVictoryConditions;
711 		gameSettingsNode->addAttribute("defaultVictoryConditions",intToStr(defaultVictoryConditions), mapTagReplacements);
712 //		bool fogOfWar;
713 		gameSettingsNode->addAttribute("fogOfWar",intToStr(fogOfWar), mapTagReplacements);
714 //		bool allowObservers;
715 		gameSettingsNode->addAttribute("allowObservers",intToStr(allowObservers), mapTagReplacements);
716 //		bool enableObserverModeAtEndGame;
717 		gameSettingsNode->addAttribute("enableObserverModeAtEndGame",intToStr(enableObserverModeAtEndGame), mapTagReplacements);
718 //		bool enableServerControlledAI;
719 		gameSettingsNode->addAttribute("enableServerControlledAI",intToStr(enableServerControlledAI), mapTagReplacements);
720 //		int networkFramePeriod;
721 		gameSettingsNode->addAttribute("networkFramePeriod",intToStr(networkFramePeriod), mapTagReplacements);
722 //		bool networkPauseGameForLaggedClients;
723 		gameSettingsNode->addAttribute("networkPauseGameForLaggedClients",intToStr(networkPauseGameForLaggedClients), mapTagReplacements);
724 //		PathFinderType pathFinderType;
725 		gameSettingsNode->addAttribute("pathFinderType",intToStr(pathFinderType), mapTagReplacements);
726 //		uint32 flagTypes1;
727 		gameSettingsNode->addAttribute("flagTypes1",uIntToStr(flagTypes1), mapTagReplacements);
728 //	    int32 mapCRC;
729 		gameSettingsNode->addAttribute("mapCRC",uIntToStr(mapCRC), mapTagReplacements);
730 //	    int32 tilesetCRC;
731 		gameSettingsNode->addAttribute("tilesetCRC",uIntToStr(tilesetCRC), mapTagReplacements);
732 //	    int32 techCRC;
733 		gameSettingsNode->addAttribute("techCRC",uIntToStr(techCRC), mapTagReplacements);
734 //	    vector<pair<string,int32> > factionCRCList;
735 		for(unsigned int i = 0; i < factionCRCList.size(); ++i) {
736 			const pair<string,uint32> &item = factionCRCList[i];
737 
738 			XmlNode *factionCRCListNode = gameSettingsNode->addChild("factionCRCList");
739 			factionCRCListNode->addAttribute("key",item.first, mapTagReplacements);
740 			factionCRCListNode->addAttribute("value",uIntToStr(item.second), mapTagReplacements);
741 		}
742 //	    int aiAcceptSwitchTeamPercentChance;
743 		gameSettingsNode->addAttribute("aiAcceptSwitchTeamPercentChance",intToStr(aiAcceptSwitchTeamPercentChance), mapTagReplacements);
744 //	    int masterserver_admin;
745 		gameSettingsNode->addAttribute("masterserver_admin",intToStr(masterserver_admin), mapTagReplacements);
746 
747 		gameSettingsNode->addAttribute("masterserver_admin_factionIndex",intToStr(masterserver_admin_factionIndex), mapTagReplacements);
748 
749 		gameSettingsNode->addAttribute("networkAllowNativeLanguageTechtree",intToStr(networkAllowNativeLanguageTechtree), mapTagReplacements);
750 	}
751 
loadGame(const XmlNode * rootNode)752 	void loadGame(const XmlNode *rootNode) {
753 		const XmlNode *gameSettingsNode = rootNode->getChild("GameSettings");
754 
755 		if(gameSettingsNode->hasAttribute("gameUUID") == true) {
756 			gameUUID = gameSettingsNode->getAttribute("gameUUID")->getValue();
757 		}
758 
759 //		string gameName;
760 		if(gameSettingsNode->hasAttribute("gameName") == true) {
761 			gameName = gameSettingsNode->getAttribute("gameName")->getValue();
762 		}
763 		else {
764 			gameName = "oldSavegame";
765 		}
766 //		string description;
767 		description = gameSettingsNode->getAttribute("description")->getValue();
768 //		string map;
769 		map = gameSettingsNode->getAttribute("map")->getValue();
770 //		string tileset;
771 		tileset = gameSettingsNode->getAttribute("tileset")->getValue();
772 //		string tech;
773 		tech = gameSettingsNode->getAttribute("tech")->getValue();
774 //		string scenario;
775 		scenario = gameSettingsNode->getAttribute("scenario")->getValue();
776 //		string scenarioDir;
777 		scenarioDir = gameSettingsNode->getAttribute("scenarioDir")->getValue();
778 		if(fileExists(scenarioDir) == false) {
779 			scenarioDir = Config::findValidLocalFileFromPath(scenarioDir);
780 		}
781 
782 //		string factionTypeNames[GameConstants::maxPlayers]; //faction names
783 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
784 			const XmlNode *factionTypeNamesNode = gameSettingsNode->getChild("factionTypeNames",idx);
785 			factionTypeNames[idx] = factionTypeNamesNode->getAttribute("name")->getValue();
786 		}
787 
788 //		string networkPlayerNames[GameConstants::maxPlayers];
789 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
790 			const XmlNode *networkPlayerNamesNode = gameSettingsNode->getChild("networkPlayerNames",idx);
791 			networkPlayerNames[idx] = networkPlayerNamesNode->getAttribute("name")->getValue();
792 		}
793 
794 //		int    networkPlayerStatuses[GameConstants::maxPlayers];
795 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
796 			const XmlNode *networkPlayerStatusesNode = gameSettingsNode->getChild("networkPlayerStatuses",idx);
797 			networkPlayerStatuses[idx] = networkPlayerStatusesNode->getAttribute("status")->getIntValue();
798 		}
799 
800 		//		int    networkPlayerStatuses[GameConstants::maxPlayers];
801 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
802 			if(gameSettingsNode->hasChildAtIndex("networkPlayerGameStatus",idx) == true) {
803 				const XmlNode *networkPlayerGameStatusNode = gameSettingsNode->getChild("networkPlayerGameStatus",idx);
804 				networkPlayerGameStatus[idx] = networkPlayerGameStatusNode->getAttribute("game_status")->getIntValue();
805 			}
806 		}
807 
808 //		string networkPlayerLanguages[GameConstants::maxPlayers];
809 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
810 			const XmlNode *networkPlayerLanguagesNode = gameSettingsNode->getChild("networkPlayerLanguages",idx);
811 			networkPlayerLanguages[idx] = networkPlayerLanguagesNode->getAttribute("name")->getValue();
812 		}
813 
814 //		ControlType factionControls[GameConstants::maxPlayers];
815 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
816 			const XmlNode *factionControlsNode = gameSettingsNode->getChild("factionControls",idx);
817 			factionControls[idx] = static_cast<ControlType>(factionControlsNode->getAttribute("control")->getIntValue());
818 		}
819 
820 //		int resourceMultiplierIndex[GameConstants::maxPlayers];
821 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
822 			const XmlNode *resourceMultiplierIndexNode = gameSettingsNode->getChild("resourceMultiplierIndex",idx);
823 			resourceMultiplierIndex[idx] = resourceMultiplierIndexNode->getAttribute("multiplier")->getIntValue();
824 		}
825 
826 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
827 			if(gameSettingsNode->hasChildAtIndex("networkPlayerUUID",idx) == true) {
828 				const XmlNode *networkPlayerUUIDNode = gameSettingsNode->getChild("networkPlayerUUID",idx);
829 				networkPlayerUUID[idx] = networkPlayerUUIDNode->getAttribute("value")->getValue();
830 			}
831 		}
832 
833 //		int thisFactionIndex;
834 		thisFactionIndex = gameSettingsNode->getAttribute("thisFactionIndex")->getIntValue();
835 //		int factionCount;
836 		factionCount = gameSettingsNode->getAttribute("factionCount")->getIntValue();
837 //		int teams[GameConstants::maxPlayers];
838 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
839 			const XmlNode *teamsNode = gameSettingsNode->getChild("teams",idx);
840 			teams[idx] = teamsNode->getAttribute("team")->getIntValue();
841 		}
842 
843 //		int startLocationIndex[GameConstants::maxPlayers];
844 		for(int idx =0; idx < GameConstants::maxPlayers; idx++) {
845 			const XmlNode *startLocationIndexNode = gameSettingsNode->getChild("startLocationIndex",idx);
846 			startLocationIndex[idx] = startLocationIndexNode->getAttribute("location")->getIntValue();
847 		}
848 
849 //		int mapFilterIndex;
850 		mapFilter = gameSettingsNode->getAttribute("mapFilterIndex")->getIntValue();
851 //
852 //
853 //		bool defaultUnits;
854 		defaultUnits = gameSettingsNode->getAttribute("defaultUnits")->getIntValue() != 0;
855 //		bool defaultResources;
856 		defaultResources = gameSettingsNode->getAttribute("defaultResources")->getIntValue() != 0;
857 //		bool defaultVictoryConditions;
858 		defaultVictoryConditions = gameSettingsNode->getAttribute("defaultVictoryConditions")->getIntValue() != 0;
859 //		bool fogOfWar;
860 		fogOfWar = gameSettingsNode->getAttribute("fogOfWar")->getIntValue() != 0;
861 //		bool allowObservers;
862 		allowObservers = gameSettingsNode->getAttribute("allowObservers")->getIntValue() != 0;
863 //		bool enableObserverModeAtEndGame;
864 		enableObserverModeAtEndGame = gameSettingsNode->getAttribute("enableObserverModeAtEndGame")->getIntValue() != 0;
865 //		bool enableServerControlledAI;
866 		enableServerControlledAI = gameSettingsNode->getAttribute("enableServerControlledAI")->getIntValue() != 0;
867 //		int networkFramePeriod;
868 		networkFramePeriod = gameSettingsNode->getAttribute("networkFramePeriod")->getIntValue();
869 //		bool networkPauseGameForLaggedClients;
870 		networkPauseGameForLaggedClients = gameSettingsNode->getAttribute("networkPauseGameForLaggedClients")->getIntValue() != 0;
871 //		PathFinderType pathFinderType;
872 		pathFinderType = static_cast<PathFinderType>(gameSettingsNode->getAttribute("pathFinderType")->getIntValue());
873 //		uint32 flagTypes1;
874 		flagTypes1 = gameSettingsNode->getAttribute("flagTypes1")->getUIntValue();
875 //	    int32 mapCRC;
876 		mapCRC = gameSettingsNode->getAttribute("mapCRC")->getUIntValue();
877 //	    int32 tilesetCRC;
878 		tilesetCRC = gameSettingsNode->getAttribute("tilesetCRC")->getUIntValue();
879 //	    int32 techCRC;
880 		techCRC = gameSettingsNode->getAttribute("techCRC")->getUIntValue();
881 //	    vector<pair<string,int32> > factionCRCList;
882 //		for(unsigned int i = 0; i < factionCRCList.size(); ++i) {
883 //			const pair<string,int32> &item = factionCRCList[i];
884 //
885 //			XmlNode *factionCRCListNode = gameSettingsNode->addChild("factionCRCList");
886 //			factionCRCListNode->addAttribute("key",item.first, mapTagReplacements);
887 //			factionCRCListNode->addAttribute("value",intToStr(item.second), mapTagReplacements);
888 //		}
889 //	    int aiAcceptSwitchTeamPercentChance;
890 		aiAcceptSwitchTeamPercentChance = gameSettingsNode->getAttribute("aiAcceptSwitchTeamPercentChance")->getIntValue();
891 //	    int masterserver_admin;
892 		masterserver_admin = gameSettingsNode->getAttribute("masterserver_admin")->getIntValue();
893 
894 		if(gameSettingsNode->hasAttribute("masterserver_admin_factionIndex") == true) {
895 			masterserver_admin_factionIndex = gameSettingsNode->getAttribute("masterserver_admin_factionIndex")->getIntValue();
896 		}
897 
898 		if(gameSettingsNode->hasAttribute("networkAllowNativeLanguageTechtree") == true) {
899 			networkAllowNativeLanguageTechtree = gameSettingsNode->getAttribute("networkAllowNativeLanguageTechtree")->getIntValue() != 0;
900 		}
901 	}
902 
903 };
904 
905 }}//end namespace
906 
907 #endif
908