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 #include "core_data.h"
13
14 #include "logger.h"
15 #include "renderer.h"
16 #include "graphics_interface.h"
17 #include "config.h"
18 #include "util.h"
19 #include "platform_util.h"
20 #include "game_constants.h"
21 #include "game_util.h"
22 #include "lang.h"
23 #include "game_settings.h"
24 #include "video_player.h"
25 #include "byte_order.h"
26 #include "leak_dumper.h"
27
28 using namespace Shared::Sound;
29 using namespace Shared::Graphics;
30 using namespace Shared::Util;
31
32 namespace Glest{ namespace Game{
33
34 // =====================================================
35 // class CoreData
36 // =====================================================
37
38 static string tempDataLocation = getUserHome();
39 // ===================== PUBLIC ========================
40
41 static const string CORE_PATH = "data/core/";
42 static const string CORE_MISC_TEXTURES_PATH = CORE_PATH + "misc_textures/";
43
44 static const string CORE_MENU_PATH = CORE_PATH + "menu/";
45 static const string CORE_MENU_TEXTURES_PATH = CORE_MENU_PATH + "textures/";
46 static const string CORE_MENU_SOUND_PATH = CORE_MENU_PATH + "sound/";
47 static const string CORE_MENU_MUSIC_PATH = CORE_MENU_PATH + "music/";
48 static const string CORE_MENU_VIDEOS_PATH = CORE_MENU_PATH + "videos/";
49
50 static const string CORE_WATER_SOUNDS_PATH = CORE_PATH + "/water_sounds/";
51
getInstance()52 CoreData &CoreData::getInstance() {
53 static CoreData coreData;
54 return coreData;
55 }
56
CoreData()57 CoreData::CoreData() {
58 logoTexture=NULL;
59 logoTextureList.clear();
60 backgroundTexture=NULL;
61 fireTexture=NULL;
62 teamColorTexture=NULL;
63 snowTexture=NULL;
64 waterSplashTexture=NULL;
65 customTexture=NULL;
66 buttonSmallTexture=NULL;
67 buttonBigTexture=NULL;
68 horizontalLineTexture=NULL;
69 verticalLineTexture=NULL;
70 checkBoxTexture=NULL;
71 checkedCheckBoxTexture=NULL;
72 gameWinnerTexture=NULL;
73 notOnServerTexture=NULL;
74 onServerDifferentTexture=NULL;
75 onServerTexture=NULL;
76 onServerInstalledTexture=NULL;
77 statusReadyTexture=NULL;
78 statusNotReadyTexture=NULL;
79 statusBRBTexture=NULL;
80
81 healthbarTexture=NULL;
82 healthbarBackgroundTexture=NULL;
83
84 miscTextureList.clear();
85
86 displayFont=NULL;
87 menuFontNormal=NULL;
88 displayFontSmall=NULL;
89 menuFontBig=NULL;
90 menuFontVeryBig=NULL;
91 consoleFont=NULL;
92
93 displayFont3D=NULL;
94 menuFontNormal3D=NULL;
95 displayFontSmall3D=NULL;
96 menuFontBig3D=NULL;
97 menuFontVeryBig3D=NULL;
98 consoleFont3D=NULL;
99
100 introVideoFilename="";
101 mainMenuVideoFilename="";
102
103 battleEndWinVideoFilename="";
104 battleEndWinVideoFilenameFallback="";
105 battleEndWinMusicFilename="";
106 battleEndLoseVideoFilename="";
107 battleEndLoseVideoFilenameFallback="";
108 battleEndLoseMusicFilename="";
109 }
110
~CoreData()111 CoreData::~CoreData() {
112 cleanup();
113 }
114
cleanup()115 void CoreData::cleanup() {
116 deleteValues(waterSounds.getSoundsPtr()->begin(), waterSounds.getSoundsPtr()->end());
117 waterSounds.getSoundsPtr()->clear();
118 }
119
getTextureBySystemId(TextureSystemType type)120 Texture2D *CoreData::getTextureBySystemId(TextureSystemType type) {
121 Texture2D *result = NULL;
122 switch(type) {
123 case tsyst_logoTexture:
124 result = getLogoTexture();
125 break;
126 //std::vector<Texture2D *> logoTextureList;
127 case tsyst_backgroundTexture:
128 result = getBackgroundTexture();
129 break;
130 case tsyst_fireTexture:
131 result = getFireTexture();
132 break;
133 case tsyst_teamColorTexture:
134 result = getTeamColorTexture();
135 break;
136 case tsyst_snowTexture:
137 result = getSnowTexture();
138 break;
139 case tsyst_waterSplashTexture:
140 result = getWaterSplashTexture();
141 break;
142 case tsyst_customTexture:
143 result = getCustomTexture();
144 break;
145 case tsyst_buttonSmallTexture:
146 result = buttonSmallTexture;
147 break;
148 case tsyst_buttonBigTexture:
149 result = buttonBigTexture;
150 break;
151 case tsyst_horizontalLineTexture:
152 result = horizontalLineTexture;
153 break;
154 case tsyst_verticalLineTexture:
155 result = verticalLineTexture;
156 break;
157 case tsyst_checkBoxTexture:
158 result = checkBoxTexture;
159 break;
160 case tsyst_checkedCheckBoxTexture:
161 result = checkedCheckBoxTexture;
162 break;
163 case tsyst_gameWinnerTexture:
164 result = gameWinnerTexture;
165 break;
166 case tsyst_notOnServerTexture:
167 result = notOnServerTexture;
168 break;
169 case tsyst_onServerDifferentTexture:
170 result = onServerDifferentTexture;
171 break;
172 case tsyst_onServerTexture:
173 result = onServerTexture;
174 break;
175 case tsyst_onServerInstalledTexture:
176 result = onServerInstalledTexture;
177 break;
178 case tsyst_statusReadyTexture:
179 result = statusReadyTexture;
180 break;
181 case tsyst_statusNotReadyTexture:
182 result = statusNotReadyTexture;
183 break;
184 case tsyst_statusBRBTexture:
185 result = statusBRBTexture;
186 break;
187 case tsyst_healthbarTexture:
188 result = healthbarTexture;
189 break;
190 case tsyst_healthbarBackgroundTexture:
191 result = healthbarBackgroundTexture;
192 break;
193
194 //std::vector<Texture2D *> miscTextureList;
195 }
196 return result;
197 }
198
cleanupTexture(Texture2D ** texture)199 void CoreData::cleanupTexture(Texture2D **texture) {
200 Renderer &renderer= Renderer::getInstance();
201 renderer.endTexture(rsGlobal, *texture);
202 *texture=NULL;
203 }
204
loadTextureIfRequired(Texture2D ** tex,string data_path,string uniqueFilePath,int texSystemId,bool setMipMap,bool setAlpha,bool loadUniqueFilePath,bool compressionDisabled)205 void CoreData::loadTextureIfRequired(Texture2D **tex,string data_path,
206 string uniqueFilePath, int texSystemId,
207 bool setMipMap, bool setAlpha,
208 bool loadUniqueFilePath, bool compressionDisabled) {
209 if(*tex == NULL) {
210 bool attemptToLoadTexture = (texSystemId == tsyst_NONE);
211 if(attemptToLoadTexture == false &&
212 itemLoadAttempted.find(texSystemId) == itemLoadAttempted.end()) {
213
214 attemptToLoadTexture = true;
215 itemLoadAttempted[texSystemId] = true;
216 }
217
218 if(attemptToLoadTexture == true) {
219 Renderer &renderer = Renderer::getInstance();
220 *tex = renderer.newTexture2D(rsGlobal);
221 if (*tex) {
222
223 (*tex)->setForceCompressionDisabled(compressionDisabled);
224 (*tex)->setMipmap(setMipMap);
225 if(setAlpha == true) {
226
227 (*tex)->setFormat(Texture::fAlpha);
228 (*tex)->getPixmap()->init(1);
229 }
230
231 try {
232 string fileToLoad = uniqueFilePath;
233 if(loadUniqueFilePath == false) {
234
235 fileToLoad = getGameCustomCoreDataPath(data_path,uniqueFilePath);
236 }
237 (*tex)->getPixmap()->load(fileToLoad);
238 (*tex)->setTextureSystemId(texSystemId);
239
240 renderer.initTexture(rsGlobal,*tex);
241 }
242 catch (const megaglest_runtime_error& ex) {
243 message(ex.what(),GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
244 tempDataLocation);
245 cleanupTexture (tex);
246 }
247 }
248 }
249 }
250 }
251
getDataPath()252 string CoreData::getDataPath() {
253 string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey);
254 if(data_path != "") {
255 endPathWithSlash(data_path);
256 }
257 return data_path;
258 }
259
getBackgroundTexture()260 Texture2D * CoreData::getBackgroundTexture() {
261 string data_path = getDataPath();
262 loadTextureIfRequired(&backgroundTexture, getDataPath(),
263 CORE_MENU_TEXTURES_PATH + "back.tga", tsyst_backgroundTexture,
264 false, false, false);
265
266 return backgroundTexture;
267 }
getFireTexture()268 Texture2D *CoreData::getFireTexture() {
269 string data_path = getDataPath();
270 loadTextureIfRequired(&fireTexture,data_path,
271 CORE_MISC_TEXTURES_PATH + "fire_particle.tga", tsyst_fireTexture,
272 true, true, false);
273
274 return fireTexture;
275 }
getTeamColorTexture()276 Texture2D *CoreData::getTeamColorTexture() {
277 string data_path = getDataPath();
278 loadTextureIfRequired(&teamColorTexture,data_path,
279 CORE_MISC_TEXTURES_PATH + "team_color_texture.tga", tsyst_teamColorTexture,
280 true, true, false);
281
282 return teamColorTexture;
283 }
getSnowTexture()284 Texture2D *CoreData::getSnowTexture() {
285 string data_path = getDataPath();
286 loadTextureIfRequired(&snowTexture,data_path,
287 CORE_MISC_TEXTURES_PATH + "snow_particle.tga", tsyst_snowTexture,
288 false, true, false);
289
290 return snowTexture;
291 }
getLogoTexture()292 Texture2D *CoreData::getLogoTexture() {
293 string data_path = getDataPath();
294 loadTextureIfRequired(&logoTexture,data_path,
295 CORE_MENU_TEXTURES_PATH + "logo.tga", tsyst_logoTexture,
296 false, false, false);
297
298 return logoTexture;
299 }
getWaterSplashTexture()300 Texture2D *CoreData::getWaterSplashTexture() {
301 string data_path = getDataPath();
302 loadTextureIfRequired(&waterSplashTexture,data_path,
303 CORE_MISC_TEXTURES_PATH + "water_splash.tga", tsyst_waterSplashTexture,
304 true, true, false);
305
306 return waterSplashTexture;
307 }
getCustomTexture()308 Texture2D *CoreData::getCustomTexture() {
309 string data_path = getDataPath();
310 loadTextureIfRequired(&customTexture,data_path,
311 CORE_MENU_TEXTURES_PATH + "custom_texture.tga", tsyst_customTexture,
312 true, false, false);
313
314 return customTexture;
315 }
getButtonSmallTexture()316 Texture2D *CoreData::getButtonSmallTexture() {
317 string data_path = getDataPath();
318 loadTextureIfRequired(&buttonSmallTexture,data_path,
319 CORE_MENU_TEXTURES_PATH + "button_small.tga", tsyst_buttonSmallTexture,
320 true, false, false, true);
321
322 return buttonSmallTexture;
323 }
getButtonBigTexture()324 Texture2D *CoreData::getButtonBigTexture() {
325 string data_path = getDataPath();
326 loadTextureIfRequired(&buttonBigTexture,data_path,
327 CORE_MENU_TEXTURES_PATH + "button_big.tga", tsyst_buttonBigTexture,
328 true, false, false, true);
329
330 return buttonBigTexture;
331 }
getHorizontalLineTexture()332 Texture2D *CoreData::getHorizontalLineTexture() {
333 string data_path = getDataPath();
334 loadTextureIfRequired(&horizontalLineTexture,data_path,
335 CORE_MENU_TEXTURES_PATH + "line_horizontal.tga", tsyst_horizontalLineTexture,
336 true, false, false, true);
337
338 return horizontalLineTexture;
339 }
getVerticalLineTexture()340 Texture2D *CoreData::getVerticalLineTexture() {
341 string data_path = getDataPath();
342 loadTextureIfRequired(&verticalLineTexture,data_path,
343 CORE_MENU_TEXTURES_PATH + "line_vertical.tga", tsyst_verticalLineTexture,
344 true, false, false, true);
345
346 return verticalLineTexture;
347 }
getCheckBoxTexture()348 Texture2D *CoreData::getCheckBoxTexture() {
349 string data_path = getDataPath();
350 loadTextureIfRequired(&checkBoxTexture,data_path,
351 CORE_MENU_TEXTURES_PATH + "checkbox.tga", tsyst_checkBoxTexture,
352 true, false, false, true);
353
354 return checkBoxTexture;
355 }
getCheckedCheckBoxTexture()356 Texture2D *CoreData::getCheckedCheckBoxTexture() {
357 string data_path = getDataPath();
358 loadTextureIfRequired(&checkedCheckBoxTexture,data_path,
359 CORE_MENU_TEXTURES_PATH + "checkbox_checked.tga", tsyst_checkedCheckBoxTexture,
360 true, false, false, true);
361
362 return checkedCheckBoxTexture;
363 }
getNotOnServerTexture()364 Texture2D *CoreData::getNotOnServerTexture() {
365 string data_path = getDataPath();
366 loadTextureIfRequired(¬OnServerTexture,data_path,
367 CORE_MENU_TEXTURES_PATH + "not_on_server.tga", tsyst_notOnServerTexture,
368 true, false, false);
369
370 return notOnServerTexture;
371 }
getOnServerDifferentTexture()372 Texture2D *CoreData::getOnServerDifferentTexture() {
373 string data_path = getDataPath();
374 loadTextureIfRequired(&onServerDifferentTexture,data_path,
375 CORE_MENU_TEXTURES_PATH + "on_server_different.tga", tsyst_onServerDifferentTexture,
376 true, false, false);
377
378 return onServerDifferentTexture;
379 }
getOnServerTexture()380 Texture2D *CoreData::getOnServerTexture() {
381 string data_path = getDataPath();
382 loadTextureIfRequired(&onServerTexture,data_path,
383 CORE_MENU_TEXTURES_PATH + "on_server.tga", tsyst_onServerTexture,
384 true, false, false);
385
386 return onServerTexture;
387 }
getOnServerInstalledTexture()388 Texture2D *CoreData::getOnServerInstalledTexture() {
389 string data_path = getDataPath();
390 loadTextureIfRequired(&onServerInstalledTexture,data_path,
391 CORE_MENU_TEXTURES_PATH + "on_server_installed.tga", tsyst_onServerInstalledTexture,
392 true, false, false);
393
394 return onServerInstalledTexture;
395 }
getStatusReadyTexture()396 Texture2D *CoreData::getStatusReadyTexture() {
397 string data_path = getDataPath();
398 loadTextureIfRequired(&statusReadyTexture,data_path,
399 CORE_MENU_TEXTURES_PATH + "status_ready.png", tsyst_statusReadyTexture,
400 true, false, false);
401
402 return statusReadyTexture;
403 }
getStatusNotReadyTexture()404 Texture2D *CoreData::getStatusNotReadyTexture() {
405 string data_path = getDataPath();
406 loadTextureIfRequired(&statusNotReadyTexture,data_path,
407 CORE_MENU_TEXTURES_PATH + "status_notready.png", tsyst_statusNotReadyTexture,
408 true, false, false);
409
410 return statusNotReadyTexture;
411 }
getStatusBRBTexture()412 Texture2D *CoreData::getStatusBRBTexture() {
413 string data_path = getDataPath();
414 loadTextureIfRequired(&statusBRBTexture,data_path,
415 CORE_MENU_TEXTURES_PATH + "status_brb.png", tsyst_statusBRBTexture,
416 true, false, false);
417
418 return statusBRBTexture;
419 }
getGameWinnerTexture()420 Texture2D *CoreData::getGameWinnerTexture() {
421 string data_path = getDataPath();
422 loadTextureIfRequired(&gameWinnerTexture,data_path,
423 CORE_MISC_TEXTURES_PATH + "game_winner.png", tsyst_gameWinnerTexture,
424 true, false, false, true);
425
426 return gameWinnerTexture;
427 }
428
getHealthbarTexture()429 Texture2D *CoreData::getHealthbarTexture() {
430 string data_path = getDataPath();
431 loadTextureIfRequired(&healthbarTexture,data_path,
432 CORE_MISC_TEXTURES_PATH + "healthbar.png", tsyst_healthbarTexture,
433 true, false, false, true);
434
435 return healthbarTexture;
436 }
437
getHealthbarBackgroundTexture()438 Texture2D *CoreData::getHealthbarBackgroundTexture() {
439 string data_path = getDataPath();
440 loadTextureIfRequired(&healthbarBackgroundTexture,data_path,
441 CORE_MISC_TEXTURES_PATH + "healthbarBackground.png", tsyst_healthbarBackgroundTexture,
442 true, false, false, true);
443
444 return healthbarBackgroundTexture;
445 }
446
loadLogoTextureExtraIfRequired()447 void CoreData::loadLogoTextureExtraIfRequired() {
448 int loadAttemptLookupKey = tsyst_COUNT + 1;
449 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
450
451 itemLoadAttempted[loadAttemptLookupKey] = true;
452
453 string data_path = getDataPath();
454 logoTextureList.clear();
455 string logosPath = getGameCustomCoreDataPath(data_path, "")
456 + CORE_MENU_TEXTURES_PATH + "logo*.*";
457 vector<string> logoFilenames;
458 findAll(logosPath, logoFilenames, false, false);
459 for (int index = 0; index < (int)logoFilenames.size(); ++index) {
460
461 string logo = logoFilenames[index];
462 if (strcmp("logo.tga", logo.c_str()) != 0) {
463
464 Texture2D* logoTextureExtra = NULL;
465 loadTextureIfRequired(&logoTextureExtra,data_path,
466 getGameCustomCoreDataPath(data_path, "") +
467 CORE_MENU_TEXTURES_PATH + logo, tsyst_NONE,
468 true, false, true);
469 logoTextureList.push_back(logoTextureExtra);
470 }
471 }
472 if (logoTextureList.empty() == true) {
473
474 logosPath = data_path + CORE_MENU_TEXTURES_PATH + "logo*.*";
475 vector<string> logoFilenames;
476 findAll(logosPath, logoFilenames, false, false);
477 for (int index = 0; index < (int)logoFilenames.size(); ++index) {
478
479 string logo = logoFilenames[index];
480 if (strcmp("logo.tga", logo.c_str()) != 0) {
481
482 Texture2D* logoTextureExtra = NULL;
483 loadTextureIfRequired(&logoTextureExtra,data_path,
484 data_path + CORE_MENU_TEXTURES_PATH + logo, tsyst_NONE,
485 true, false, true);
486 logoTextureList.push_back(logoTextureExtra);
487 }
488 }
489 }
490 }
491 }
getLogoTextureExtraCount()492 size_t CoreData::getLogoTextureExtraCount() {
493 loadLogoTextureExtraIfRequired();
494 return logoTextureList.size();
495 }
getLogoTextureExtra(int idx)496 Texture2D *CoreData::getLogoTextureExtra(int idx) {
497 loadLogoTextureExtraIfRequired();
498 return logoTextureList[idx];
499 }
500
loadMiscTextureListIfRequired()501 void CoreData::loadMiscTextureListIfRequired() {
502 int loadAttemptLookupKey = tsyst_COUNT + 2;
503 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
504
505 itemLoadAttempted[loadAttemptLookupKey] = true;
506
507 string data_path = getDataPath();
508
509 miscTextureList.clear();
510 string introPath = getGameCustomCoreDataPath(data_path, "")
511 + CORE_MENU_TEXTURES_PATH + "intro*.*";
512 vector<string> introFilenames;
513 findAll(introPath, introFilenames, false, false);
514 for (int i = 0; i < (int)introFilenames.size(); ++i) {
515 string logo = introFilenames[i];
516
517 Texture2D* logoTextureExtra = NULL;
518 loadTextureIfRequired(&logoTextureExtra,data_path,
519 getGameCustomCoreDataPath(data_path, "") + CORE_MENU_TEXTURES_PATH +
520 logo, tsyst_NONE,
521 true, false, true);
522 miscTextureList.push_back(logoTextureExtra);
523 }
524 if (miscTextureList.empty() == true) {
525 introPath = data_path + CORE_MENU_TEXTURES_PATH + "intro*.*";
526 vector<string> introFilenames;
527 findAll(introPath, introFilenames, false, false);
528 for (int i = 0; i < (int)introFilenames.size(); ++i) {
529 string logo = introFilenames[i];
530
531 Texture2D* logoTextureExtra = NULL;
532 loadTextureIfRequired(&logoTextureExtra,data_path,
533 data_path + CORE_MENU_TEXTURES_PATH + logo, tsyst_NONE,
534 true, false, true);
535 miscTextureList.push_back(logoTextureExtra);
536 }
537 }
538
539 }
540 }
541
getMiscTextureList()542 std::vector<Texture2D *> & CoreData::getMiscTextureList() {
543 loadMiscTextureListIfRequired();
544 return miscTextureList;
545 }
546
loadTextures(string data_path)547 void CoreData::loadTextures(string data_path) {
548 // Required to be loaded at program startup as they may be accessed in
549 // threads or some other dangerous way so lazy loading is not an option
550 getCustomTexture();
551 }
552
getClickSoundA()553 StaticSound *CoreData::getClickSoundA() {
554 int loadAttemptLookupKey = tsyst_COUNT + 3;
555 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
556
557 itemLoadAttempted[loadAttemptLookupKey] = true;
558
559 try {
560 string data_path = getDataPath();
561 clickSoundA.load(getGameCustomCoreDataPath(data_path,
562 CORE_MENU_SOUND_PATH + "click_a.wav"));
563 }
564 catch (const megaglest_runtime_error& ex) {
565 message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
566 tempDataLocation);
567 }
568 }
569 return &clickSoundA;
570 }
571
getClickSoundB()572 StaticSound *CoreData::getClickSoundB() {
573 int loadAttemptLookupKey = tsyst_COUNT + 4;
574 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
575
576 itemLoadAttempted[loadAttemptLookupKey] = true;
577
578 try {
579 string data_path = getDataPath();
580 clickSoundB.load(getGameCustomCoreDataPath(data_path,
581 CORE_MENU_SOUND_PATH + "click_b.wav"));
582 }
583 catch (const megaglest_runtime_error& ex) {
584 message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
585 tempDataLocation);
586 }
587 }
588
589 return &clickSoundB;
590 }
getClickSoundC()591 StaticSound *CoreData::getClickSoundC() {
592 int loadAttemptLookupKey = tsyst_COUNT + 5;
593 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
594
595 itemLoadAttempted[loadAttemptLookupKey] = true;
596
597 try {
598 string data_path = getDataPath();
599 clickSoundC.load(getGameCustomCoreDataPath(data_path,
600 CORE_MENU_SOUND_PATH + "click_c.wav"));
601 }
602 catch (const megaglest_runtime_error& ex) {
603 message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
604 tempDataLocation);
605 }
606 }
607
608 return &clickSoundC;
609 }
getAttentionSound()610 StaticSound *CoreData::getAttentionSound() {
611 int loadAttemptLookupKey = tsyst_COUNT + 6;
612 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
613
614 itemLoadAttempted[loadAttemptLookupKey] = true;
615
616 try {
617 string data_path = getDataPath();
618 attentionSound.load(getGameCustomCoreDataPath(data_path,
619 CORE_MENU_SOUND_PATH + "attention.wav"));
620 }
621 catch (const megaglest_runtime_error& ex) {
622 message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
623 tempDataLocation);
624 }
625 }
626
627 return &attentionSound;
628 }
getHighlightSound()629 StaticSound *CoreData::getHighlightSound() {
630 int loadAttemptLookupKey = tsyst_COUNT + 7;
631 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
632
633 itemLoadAttempted[loadAttemptLookupKey] = true;
634
635 try {
636 string data_path = getDataPath();
637 highlightSound.load(getGameCustomCoreDataPath(data_path,
638 CORE_MENU_SOUND_PATH + "highlight.wav"));
639 }
640 catch (const megaglest_runtime_error& ex) {
641 message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
642 tempDataLocation);
643 }
644 }
645
646 return &highlightSound;
647 }
getMarkerSound()648 StaticSound *CoreData::getMarkerSound() {
649 int loadAttemptLookupKey = tsyst_COUNT + 8;
650 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
651
652 itemLoadAttempted[loadAttemptLookupKey] = true;
653
654 try {
655 string data_path = getDataPath();
656 markerSound.load(getGameCustomCoreDataPath(data_path,
657 CORE_MENU_SOUND_PATH + "sonar.wav"));
658 }
659 catch (const megaglest_runtime_error& ex) {
660 message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
661 tempDataLocation);
662 }
663 }
664
665 return &markerSound;
666 }
667
loadWaterSoundsIfRequired()668 void CoreData::loadWaterSoundsIfRequired() {
669 int loadAttemptLookupKey = tsyst_COUNT + 9;
670 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
671
672 itemLoadAttempted[loadAttemptLookupKey] = true;
673
674 string data_path = getDataPath();
675 cleanup();
676 waterSounds.resize(6);
677
678 for (int index = 0; index < 6; ++index) {
679 waterSounds[index] = new StaticSound();
680 if (waterSounds[index] != NULL) {
681 try {
682 waterSounds[index]->load(getGameCustomCoreDataPath(data_path,
683 CORE_WATER_SOUNDS_PATH +
684 "water" + intToStr(index) + ".wav"));
685 }
686 catch (const megaglest_runtime_error& ex) {
687 message(ex.what(),
688 GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
689 tempDataLocation);
690 }
691 }
692 }
693 }
694 }
695
getWaterSound()696 StaticSound *CoreData::getWaterSound() {
697 loadWaterSoundsIfRequired();
698 return waterSounds.getRandSound();
699 }
700
loadSounds(string data_path)701 void CoreData::loadSounds(string data_path) {
702 // sounds
703 // try {
704 // clickSoundA.load(
705 // getGameCustomCoreDataPath(data_path,
706 // CORE_MENU_SOUND_PATH + "click_a.wav"));
707 // clickSoundB.load(
708 // getGameCustomCoreDataPath(data_path,
709 // CORE_MENU_SOUND_PATH + "click_b.wav"));
710 // clickSoundC.load(
711 // getGameCustomCoreDataPath(data_path,
712 // CORE_MENU_SOUND_PATH + "click_c.wav"));
713 // attentionSound.load(
714 // getGameCustomCoreDataPath(data_path,
715 // CORE_MENU_SOUND_PATH + "attention.wav"));
716 // highlightSound.load(
717 // getGameCustomCoreDataPath(data_path,
718 // CORE_MENU_SOUND_PATH + "highlight.wav"));
719 // markerSound.load(
720 // getGameCustomCoreDataPath(data_path,
721 // CORE_MENU_SOUND_PATH + "sonar.wav"));
722 // }
723 // catch (const megaglest_runtime_error& ex) {
724 // message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
725 // tempDataLocation);
726 // }
727
728 // cleanup();
729 // waterSounds.resize(6);
730 //
731 // for (int i = 0; i < 6; ++i) {
732 // waterSounds[i] = new StaticSound();
733 // if (waterSounds[i]) {
734 // try {
735 // waterSounds[i]->load(
736 // getGameCustomCoreDataPath(data_path,
737 // CORE_WATER_SOUNDS_PATH + "water" + intToStr(i)
738 // + ".wav"));
739 // } catch (const megaglest_runtime_error& ex) {
740 // message(ex.what(),
741 // GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
742 // tempDataLocation);
743 // }
744 // }
745 // }
746 }
747
748
loadMusicIfRequired()749 void CoreData::loadMusicIfRequired() {
750 int loadAttemptLookupKey = tsyst_COUNT + 10;
751 if(itemLoadAttempted.find(loadAttemptLookupKey) == itemLoadAttempted.end()) {
752
753 itemLoadAttempted[loadAttemptLookupKey] = true;
754
755 string data_path = getDataPath();
756
757 XmlTree xmlTree;
758 xmlTree.load(
759 getGameCustomCoreDataPath(data_path, CORE_MENU_PATH + "menu.xml"),
760 Properties::getTagReplacementValues());
761 const XmlNode* menuNode = xmlTree.getRootNode();
762 string menuMusicPath = "/menu/music/";
763 string menuIntroMusicFile = "intro_music.ogg";
764 string menuMusicFile = "menu_music.ogg";
765 if (menuNode->hasChild("intro") == true) {
766 const XmlNode* introNode = menuNode->getChild("intro");
767 // intro info
768 const XmlNode* menuPathNode = introNode->getChild("menu-music-path");
769 menuMusicPath =
770 menuPathNode->getAttribute("value")->getRestrictedValue();
771 const XmlNode* menuIntroMusicNode = introNode->getChild(
772 "menu-intro-music");
773 menuIntroMusicFile =
774 menuIntroMusicNode->getAttribute("value")->getRestrictedValue();
775 const XmlNode* menuMusicNode = introNode->getChild("menu-music");
776 menuMusicFile =
777 menuMusicNode->getAttribute("value")->getRestrictedValue();
778 }
779 try {
780 introMusic.open(
781 getGameCustomCoreDataPath(data_path,
782 CORE_PATH + menuMusicPath + menuIntroMusicFile));
783 introMusic.setNext(&menuMusic);
784 menuMusic.open(
785 getGameCustomCoreDataPath(data_path,
786 CORE_PATH + menuMusicPath + menuMusicFile));
787 menuMusic.setNext(&menuMusic);
788 }
789 catch (const megaglest_runtime_error& ex) {
790 message(ex.what(), GlobalStaticFlags::getIsNonGraphicalModeEnabled(),
791 tempDataLocation);
792 }
793 }
794 }
795
getIntroMusic()796 StrSound *CoreData::getIntroMusic() {
797 loadMusicIfRequired();
798 return &introMusic;
799 }
800
getMenuMusic()801 StrSound *CoreData::getMenuMusic() {
802 loadMusicIfRequired();
803 return &menuMusic;
804 }
805
loadMusic(string data_path)806 void CoreData::loadMusic(string data_path) {
807 }
808
loadIntroMedia(string data_path)809 void CoreData::loadIntroMedia(string data_path) {
810 Config &config= Config::getInstance();
811
812 introVideoFilename = config.getString("IntroVideoURL", "");
813 introVideoFilenameFallback = config.getString("IntroVideoURLFallback", "");
814 if (introVideoFilename == "") {
815 string introVideoPath = getGameCustomCoreDataPath(data_path, "")
816 + CORE_MENU_VIDEOS_PATH + "intro.*";
817 vector<string> introVideos;
818 findAll(introVideoPath, introVideos, false, false);
819 for (int i = 0; i < (int)introVideos.size(); ++i) {
820 string video = getGameCustomCoreDataPath(data_path, "")
821 + CORE_MENU_VIDEOS_PATH + introVideos[i];
822 if (SystemFlags::VERBOSE_MODE_ENABLED)
823 printf("Checking if intro video [%s] exists\n", video.c_str());
824
825 if (fileExists(video)) {
826 introVideoFilename = video;
827 if (SystemFlags::VERBOSE_MODE_ENABLED)
828 printf("FOUND intro video [%s] will use this file\n",
829 video.c_str());
830
831 break;
832 }
833 }
834 if (introVideoFilename == "") {
835 introVideoPath = data_path + CORE_MENU_VIDEOS_PATH + "intro.*";
836 introVideos.clear();
837 findAll(introVideoPath, introVideos, false, false);
838 for (int i = 0; i < (int)introVideos.size(); ++i) {
839 string video = data_path + CORE_MENU_VIDEOS_PATH
840 + introVideos[i];
841 if (SystemFlags::VERBOSE_MODE_ENABLED)
842 printf("Checking if intro video [%s] exists\n",
843 video.c_str());
844
845 if (fileExists(video)) {
846 introVideoFilename = video;
847 if (SystemFlags::VERBOSE_MODE_ENABLED)
848 printf("FOUND intro video [%s] will use this file\n",
849 video.c_str());
850
851 break;
852 }
853 }
854 }
855 }
856 }
857
loadMainMenuMedia(string data_path)858 void CoreData::loadMainMenuMedia(string data_path) {
859 Config &config= Config::getInstance();
860
861 mainMenuVideoFilename = config.getString("MainMenuVideoURL", "");
862 mainMenuVideoFilenameFallback = config.getString("MainMenuVideoURLFallback",
863 "");
864 if (mainMenuVideoFilename == "") {
865 string mainVideoPath = getGameCustomCoreDataPath(data_path, "")
866 + CORE_MENU_VIDEOS_PATH + "main.*";
867 vector<string> mainVideos;
868 findAll(mainVideoPath, mainVideos, false, false);
869 for (int i = 0; i < (int)mainVideos.size(); ++i) {
870 string video = getGameCustomCoreDataPath(data_path, "")
871 + CORE_MENU_VIDEOS_PATH + mainVideos[i];
872 if (SystemFlags::VERBOSE_MODE_ENABLED)
873 printf("Checking if mainmenu video [%s] exists\n",
874 video.c_str());
875
876 if (fileExists(video)) {
877 mainMenuVideoFilename = video;
878 if (SystemFlags::VERBOSE_MODE_ENABLED)
879 printf("FOUND mainmenu video [%s] will use this file\n",
880 video.c_str());
881
882 break;
883 }
884 }
885 if (mainMenuVideoFilename == "") {
886 mainVideoPath = data_path + CORE_MENU_VIDEOS_PATH + "main.*";
887 mainVideos.clear();
888 findAll(mainVideoPath, mainVideos, false, false);
889 for (int i = 0; i < (int)mainVideos.size(); ++i) {
890 string video = data_path + CORE_MENU_VIDEOS_PATH
891 + mainVideos[i];
892 if (SystemFlags::VERBOSE_MODE_ENABLED)
893 printf("Checking if mainmenu video [%s] exists\n",
894 video.c_str());
895
896 if (fileExists(video)) {
897 mainMenuVideoFilename = video;
898 if (SystemFlags::VERBOSE_MODE_ENABLED)
899 printf("FOUND mainmenu video [%s] will use this file\n",
900 video.c_str());
901
902 break;
903 }
904 }
905 }
906 }
907 }
908
loadBattleEndMedia(string data_path)909 void CoreData::loadBattleEndMedia(string data_path) {
910 Config &config= Config::getInstance();
911
912 battleEndWinVideoFilename = config.getString("BattleEndWinVideoURL", "");
913 battleEndWinVideoFilenameFallback = config.getString(
914 "BattleEndWinVideoURLFallback", "");
915 if (battleEndWinVideoFilename == "") {
916 string battleEndWinVideoPath = getGameCustomCoreDataPath(data_path, "")
917 + CORE_MENU_VIDEOS_PATH + "battle_end_win.*";
918 vector<string> battleEndWinVideos;
919 findAll(battleEndWinVideoPath, battleEndWinVideos, false, false);
920 for (int i = 0; i < (int)battleEndWinVideos.size(); ++i) {
921 string video = getGameCustomCoreDataPath(data_path, "")
922 + CORE_MENU_VIDEOS_PATH + battleEndWinVideos[i];
923 if (SystemFlags::VERBOSE_MODE_ENABLED)
924 printf("Checking if battle end win video [%s] exists\n",
925 video.c_str());
926
927 if (fileExists(video)) {
928 battleEndWinVideoFilename = video;
929 if (SystemFlags::VERBOSE_MODE_ENABLED)
930 printf(
931 "FOUND battle end win video [%s] will use this file\n",
932 video.c_str());
933
934 break;
935 }
936 }
937 if (battleEndWinVideoFilename == "") {
938 battleEndWinVideoPath = data_path + CORE_MENU_VIDEOS_PATH
939 + "battle_end_win.*";
940 battleEndWinVideos.clear();
941 findAll(battleEndWinVideoPath, battleEndWinVideos, false, false);
942 for (int i = 0; i < (int)battleEndWinVideos.size(); ++i) {
943 string video = data_path + CORE_MENU_VIDEOS_PATH
944 + battleEndWinVideos[i];
945 if (SystemFlags::VERBOSE_MODE_ENABLED)
946 printf("Checking if battle end win video [%s] exists\n",
947 video.c_str());
948
949 if (fileExists(video)) {
950 battleEndWinVideoFilename = video;
951 if (SystemFlags::VERBOSE_MODE_ENABLED)
952 printf(
953 "FOUND battle end video win [%s] will use this file\n",
954 video.c_str());
955
956 break;
957 }
958 }
959 }
960 }
961 battleEndWinMusicFilename = config.getString("BattleEndWinMusicFilename",
962 "");
963 if (battleEndWinMusicFilename == "") {
964 string battleEndWinPath = getGameCustomCoreDataPath(data_path, "")
965 + CORE_MENU_MUSIC_PATH + "battle_end_win.*";
966 vector<string> battleEndWinMusic;
967 findAll(battleEndWinPath, battleEndWinMusic, false, false);
968 for (int i = 0; i < (int)battleEndWinMusic.size(); ++i) {
969 string music = getGameCustomCoreDataPath(data_path, "")
970 + CORE_MENU_MUSIC_PATH + battleEndWinMusic[i];
971 if (SystemFlags::VERBOSE_MODE_ENABLED)
972 printf("Checking if battle end win music [%s] exists\n",
973 music.c_str());
974
975 if (fileExists(music)) {
976 battleEndWinMusicFilename = music;
977 if (SystemFlags::VERBOSE_MODE_ENABLED)
978 printf(
979 "FOUND battle end win music [%s] will use this file\n",
980 music.c_str());
981
982 break;
983 }
984 }
985 if (battleEndWinMusicFilename == "") {
986 battleEndWinPath = data_path + CORE_MENU_MUSIC_PATH
987 + "battle_end_win.*";
988 battleEndWinMusic.clear();
989 findAll(battleEndWinPath, battleEndWinMusic, false, false);
990 for (int i = 0; i < (int)battleEndWinMusic.size(); ++i) {
991 string music = data_path + CORE_MENU_MUSIC_PATH
992 + battleEndWinMusic[i];
993 if (SystemFlags::VERBOSE_MODE_ENABLED)
994 printf("Checking if battle end win music [%s] exists\n",
995 music.c_str());
996
997 if (fileExists(music)) {
998 battleEndWinMusicFilename = music;
999 if (SystemFlags::VERBOSE_MODE_ENABLED)
1000 printf(
1001 "FOUND battle end music win [%s] will use this file\n",
1002 music.c_str());
1003
1004 break;
1005 }
1006 }
1007 }
1008 }
1009 battleEndLoseVideoFilename = config.getString("BattleEndLoseVideoURL", "");
1010 battleEndLoseVideoFilenameFallback = config.getString(
1011 "BattleEndLoseVideoURLFallback", "");
1012 if (battleEndLoseVideoFilename == "") {
1013 string battleEndLoseVideoPath = getGameCustomCoreDataPath(data_path, "")
1014 + CORE_MENU_VIDEOS_PATH + "battle_end_lose.*";
1015 vector<string> battleEndLoseVideos;
1016 findAll(battleEndLoseVideoPath, battleEndLoseVideos, false, false);
1017 for (int i = 0; i < (int)battleEndLoseVideos.size(); ++i) {
1018 string video = getGameCustomCoreDataPath(data_path, "")
1019 + CORE_MENU_VIDEOS_PATH + battleEndLoseVideos[i];
1020 if (SystemFlags::VERBOSE_MODE_ENABLED)
1021 printf("Checking if battle end lose video [%s] exists\n",
1022 video.c_str());
1023
1024 if (fileExists(video)) {
1025 battleEndLoseVideoFilename = video;
1026 if (SystemFlags::VERBOSE_MODE_ENABLED)
1027 printf(
1028 "FOUND battle end lose video [%s] will use this file\n",
1029 video.c_str());
1030
1031 break;
1032 }
1033 }
1034 if (battleEndLoseVideoFilename == "") {
1035 battleEndLoseVideoPath = data_path + CORE_MENU_VIDEOS_PATH
1036 + "battle_end_lose.*";
1037 battleEndLoseVideos.clear();
1038 findAll(battleEndLoseVideoPath, battleEndLoseVideos, false, false);
1039 for (int i = 0; i < (int)battleEndLoseVideos.size(); ++i) {
1040 string video = data_path + CORE_MENU_VIDEOS_PATH
1041 + battleEndLoseVideos[i];
1042 if (SystemFlags::VERBOSE_MODE_ENABLED)
1043 printf("Checking if battle end lose video [%s] exists\n",
1044 video.c_str());
1045
1046 if (fileExists(video)) {
1047 battleEndLoseVideoFilename = video;
1048 if (SystemFlags::VERBOSE_MODE_ENABLED)
1049 printf(
1050 "FOUND battle end video lose [%s] will use this file\n",
1051 video.c_str());
1052
1053 break;
1054 }
1055 }
1056 }
1057 }
1058 battleEndLoseMusicFilename = config.getString("BattleEndLoseMusicFilename",
1059 "");
1060 if (battleEndLoseMusicFilename == "") {
1061 string battleEndLosePath = getGameCustomCoreDataPath(data_path, "")
1062 + CORE_MENU_MUSIC_PATH + "battle_end_lose.*";
1063 vector<string> battleEndLoseMusic;
1064 findAll(battleEndLosePath, battleEndLoseMusic, false, false);
1065 for (int i = 0; i < (int)battleEndLoseMusic.size(); ++i) {
1066 string music = getGameCustomCoreDataPath(data_path, "")
1067 + CORE_MENU_MUSIC_PATH + battleEndLoseMusic[i];
1068 if (SystemFlags::VERBOSE_MODE_ENABLED)
1069 printf("Checking if battle end lose music [%s] exists\n",
1070 music.c_str());
1071
1072 if (fileExists(music)) {
1073 battleEndLoseMusicFilename = music;
1074 if (SystemFlags::VERBOSE_MODE_ENABLED)
1075 printf(
1076 "FOUND battle end lose music [%s] will use this file\n",
1077 music.c_str());
1078
1079 break;
1080 }
1081 }
1082 if (battleEndLoseMusicFilename == "") {
1083 battleEndLosePath = data_path + CORE_MENU_MUSIC_PATH
1084 + "battle_end_lose.*";
1085 battleEndLoseMusic.clear();
1086 findAll(battleEndLosePath, battleEndLoseMusic, false, false);
1087 for (int i = 0; i < (int)battleEndLoseMusic.size(); ++i) {
1088 string music = data_path + CORE_MENU_MUSIC_PATH
1089 + battleEndLoseMusic[i];
1090 if (SystemFlags::VERBOSE_MODE_ENABLED)
1091 printf("Checking if battle end lose music [%s] exists\n",
1092 music.c_str());
1093
1094 if (fileExists(music)) {
1095 battleEndLoseMusicFilename = music;
1096 if (SystemFlags::VERBOSE_MODE_ENABLED)
1097 printf(
1098 "FOUND battle end music lose [%s] will use this file\n",
1099 music.c_str());
1100
1101 break;
1102 }
1103 }
1104 }
1105 }
1106 }
1107
load()1108 void CoreData::load() {
1109 string data_path = CoreData::getDataPath();
1110
1111 Logger::getInstance().add(Lang::getInstance().getString("LogScreenCoreDataLoading","",true));
1112
1113 // textures
1114 loadTextures(data_path);
1115
1116 // fonts
1117 loadFonts();
1118
1119 // sounds
1120 loadSounds(data_path);
1121
1122 // music
1123 loadMusic(data_path);
1124
1125 if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false &&
1126 Shared::Graphics::VideoPlayer::hasBackEndVideoPlayer() == true) {
1127
1128 loadIntroMedia(data_path);
1129
1130 loadMainMenuMedia(data_path);
1131
1132 loadBattleEndMedia(data_path);
1133 }
1134 }
1135
hasIntroVideoFilename() const1136 bool CoreData::hasIntroVideoFilename() const {
1137 bool result = (introVideoFilename != "");
1138 return result;
1139 }
1140
hasMainMenuVideoFilename() const1141 bool CoreData::hasMainMenuVideoFilename() const {
1142 bool result = (mainMenuVideoFilename != "");
1143 return result;
1144 }
1145
hasBattleEndVideoFilename(bool won) const1146 bool CoreData::hasBattleEndVideoFilename(bool won) const {
1147 bool result = false;
1148 if(won == true) {
1149 result =(battleEndWinVideoFilename != "");
1150 }
1151 else {
1152 result =(battleEndLoseVideoFilename != "");
1153 }
1154 return result;
1155 }
1156
registerFontChangedCallback(std::string entityName,FontChangedCallbackInterface * cb)1157 void CoreData::registerFontChangedCallback(std::string entityName, FontChangedCallbackInterface *cb) {
1158 if(entityName == "") {
1159 printf("Register Font Callback detected a blank entityName!\n");
1160 throw megaglest_runtime_error("Register Font Callback detected a blank entityName!");
1161 }
1162 if (entityName != "") {
1163 registeredFontChangedCallbacks[entityName].push_back(cb);
1164 }
1165 }
unRegisterFontChangedCallback(std::string entityName)1166 void CoreData::unRegisterFontChangedCallback(std::string entityName) {
1167 if (entityName == "") {
1168 printf("UnRegister Font Callback detected a blank entityName!\n");
1169 throw megaglest_runtime_error("UnRegister Font Callback detected a blank entityName!");
1170 }
1171 if(entityName != "") {
1172 registeredFontChangedCallbacks.erase(entityName);
1173 }
1174 }
triggerFontChangedCallbacks(std::string fontUniqueId,Font * font)1175 void CoreData::triggerFontChangedCallbacks(std::string fontUniqueId, Font *font) {
1176 for (std::map<std::string, std::vector<FontChangedCallbackInterface *> >::const_iterator iterMap =
1177 registeredFontChangedCallbacks.begin();
1178 iterMap != registeredFontChangedCallbacks.end(); iterMap++) {
1179 for (unsigned int index = 0; index < iterMap->second.size(); ++index) {
1180 //printf("Font Callback detected calling: Control [%s] for Font: [%s] value [%p]\n",iterMap->first.c_str(),fontUniqueId.c_str(),font);
1181 FontChangedCallbackInterface *cb = iterMap->second[index];
1182 cb->FontChangedCallback(fontUniqueId, font);
1183 }
1184 }
1185 }
loadFonts()1186 void CoreData::loadFonts() {
1187 Lang &lang= Lang::getInstance();
1188
1189 //display font
1190 Config &config= Config::getInstance();
1191
1192 string displayFontNamePrefix = config.getString("FontDisplayPrefix");
1193 string displayFontNamePostfix = config.getString("FontDisplayPostfix");
1194 int displayFontSize = computeFontSize(config.getInt("FontDisplayBaseSize"));
1195
1196 if(lang.hasString("FontDisplayPrefix") == true) {
1197 displayFontNamePrefix = lang.getString("FontDisplayPrefix");
1198 }
1199 if(lang.hasString("FontDisplayPostfix") == true) {
1200 displayFontNamePostfix = lang.getString("FontDisplayPostfix");
1201 }
1202 if(lang.hasString("FontDisplayBaseSize") == true) {
1203 displayFontSize = computeFontSize(strToInt(lang.getString("FontDisplayBaseSize")));
1204 }
1205 string displayFontName = displayFontNamePrefix + intToStr(displayFontSize) + displayFontNamePostfix;
1206
1207 displayFont = loadFont<Font2D>(displayFont, displayFontName, displayFontSize, "FontDisplay", "FontDisplayFamily", "displayFont");
1208 displayFont3D = loadFont<Font3D>(displayFont3D, displayFontName, displayFontSize, "FontDisplay", "FontDisplayFamily", "displayFont3D");
1209
1210 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontName = [%s] displayFontSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontName.c_str(),displayFontSize);
1211
1212 //menu fonts
1213 string displayFontNameSmallPrefix = config.getString("FontDisplayPrefix");
1214 string displayFontNameSmallPostfix = config.getString("FontDisplayPostfix");
1215 int displayFontNameSmallSize = computeFontSize(config.getInt("FontDisplaySmallBaseSize"));
1216
1217 if(lang.hasString("FontDisplayPrefix") == true) {
1218 displayFontNameSmallPrefix = lang.getString("FontDisplayPrefix");
1219 }
1220 if(lang.hasString("FontDisplayPostfix") == true) {
1221 displayFontNameSmallPostfix = lang.getString("FontDisplayPostfix");
1222 }
1223 if(lang.hasString("FontDisplaySmallBaseSize") == true) {
1224 displayFontNameSmallSize = computeFontSize(strToInt(lang.getString("FontDisplaySmallBaseSize")));
1225 }
1226 string displayFontNameSmall = displayFontNameSmallPrefix + intToStr(displayFontNameSmallSize) + displayFontNameSmallPostfix;
1227
1228 displayFontSmall = loadFont<Font2D>(displayFontSmall, displayFontNameSmall, displayFontNameSmallSize, "FontSmallDisplay", "FontSmallDisplayFamily", "displayFontSmall");
1229 displayFontSmall3D = loadFont<Font3D>(displayFontSmall3D, displayFontNameSmall, displayFontNameSmallSize, "FontSmallDisplay", "FontSmallDisplayFamily", "displayFontSmall3D");
1230
1231 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] displayFontSmallName = [%s] displayFontSmallNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,displayFontNameSmall.c_str(),displayFontNameSmallSize);
1232
1233 string menuFontNameNormalPrefix = config.getString("FontMenuNormalPrefix");
1234 string menuFontNameNormalPostfix = config.getString("FontMenuNormalPostfix");
1235 int menuFontNameNormalSize = computeFontSize(config.getInt("FontMenuNormalBaseSize"));
1236 if(lang.hasString("FontMenuNormalPrefix") == true) {
1237 menuFontNameNormalPrefix = lang.getString("FontMenuNormalPrefix");
1238 }
1239 if(lang.hasString("FontMenuNormalPostfix") == true) {
1240 menuFontNameNormalPostfix = lang.getString("FontMenuNormalPostfix");
1241 }
1242 if(lang.hasString("FontMenuNormalBaseSize") == true) {
1243 menuFontNameNormalSize = computeFontSize(strToInt(lang.getString("FontMenuNormalBaseSize")));
1244 }
1245 string menuFontNameNormal= menuFontNameNormalPrefix + intToStr(menuFontNameNormalSize) + menuFontNameNormalPostfix;
1246
1247 menuFontNormal = loadFont<Font2D>(menuFontNormal, menuFontNameNormal, menuFontNameNormalSize, "FontMenuNormal", "FontMenuNormalFamily", "menuFontNormal");
1248 menuFontNormal3D = loadFont<Font3D>(menuFontNormal3D, menuFontNameNormal, menuFontNameNormalSize, "FontMenuNormal", "FontMenuNormalFamily", "menuFontNormal3D");
1249
1250 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNormalName = [%s] menuFontNormalNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameNormal.c_str(),menuFontNameNormalSize);
1251
1252 string menuFontNameBigPrefix = config.getString("FontMenuBigPrefix");
1253 string menuFontNameBigPostfix = config.getString("FontMenuBigPostfix");
1254 int menuFontNameBigSize = computeFontSize(config.getInt("FontMenuBigBaseSize"));
1255
1256 if(lang.hasString("FontMenuBigPrefix") == true) {
1257 menuFontNameBigPrefix = lang.getString("FontMenuBigPrefix");
1258 }
1259 if(lang.hasString("FontMenuBigPostfix") == true) {
1260 menuFontNameBigPostfix = lang.getString("FontMenuBigPostfix");
1261 }
1262 if(lang.hasString("FontMenuBigBaseSize") == true) {
1263 menuFontNameBigSize = computeFontSize(strToInt(lang.getString("FontMenuBigBaseSize")));
1264 }
1265 string menuFontNameBig= menuFontNameBigPrefix+intToStr(menuFontNameBigSize)+menuFontNameBigPostfix;
1266
1267 menuFontBig = loadFont<Font2D>(menuFontBig, menuFontNameBig, menuFontNameBigSize, "FontMenuBig", "FontMenuBigFamily", "menuFontBig");
1268 menuFontBig3D = loadFont<Font3D>(menuFontBig3D, menuFontNameBig, menuFontNameBigSize, "FontMenuBig", "FontMenuBigFamily", "menuFontBig3D");
1269
1270 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameBig = [%s] menuFontNameBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameBig.c_str(),menuFontNameBigSize);
1271
1272 string menuFontNameVeryBigPrefix = config.getString("FontMenuBigPrefix");
1273 string menuFontNameVeryBigPostfix = config.getString("FontMenuBigPostfix");
1274 int menuFontNameVeryBigSize = computeFontSize(config.getInt("FontMenuVeryBigBaseSize"));
1275
1276 if(lang.hasString("FontMenuBigPrefix") == true) {
1277 menuFontNameVeryBigPrefix = lang.getString("FontMenuBigPrefix");
1278 }
1279 if(lang.hasString("FontMenuBigPostfix") == true) {
1280 menuFontNameVeryBigPostfix = lang.getString("FontMenuBigPostfix");
1281 }
1282 if(lang.hasString("FontMenuVeryBigBaseSize") == true) {
1283 menuFontNameVeryBigSize = computeFontSize(strToInt(lang.getString("FontMenuVeryBigBaseSize")));
1284 }
1285 string menuFontNameVeryBig= menuFontNameVeryBigPrefix + intToStr(menuFontNameVeryBigSize) + menuFontNameVeryBigPostfix;
1286
1287 menuFontVeryBig = loadFont<Font2D>(menuFontVeryBig, menuFontNameVeryBig, menuFontNameVeryBigSize, "FontMenuVeryBig", "FontMenuVeryBigFamily", "menuFontVeryBig");
1288 menuFontVeryBig3D = loadFont<Font3D>(menuFontVeryBig3D, menuFontNameVeryBig, menuFontNameVeryBigSize, "FontMenuVeryBig", "FontMenuVeryBigFamily", "menuFontVeryBig3D");
1289
1290 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] menuFontNameVeryBig = [%s] menuFontNameVeryBigSize = %d\n",__FILE__,__FUNCTION__,__LINE__,menuFontNameVeryBig.c_str(),menuFontNameVeryBigSize);
1291
1292 //console font
1293 string consoleFontNamePrefix = config.getString("FontConsolePrefix");
1294 string consoleFontNamePostfix = config.getString("FontConsolePostfix");
1295 int consoleFontNameSize = computeFontSize(config.getInt("FontConsoleBaseSize"));
1296
1297 if(lang.hasString("FontConsolePrefix") == true) {
1298 consoleFontNamePrefix = lang.getString("FontConsolePrefix");
1299 }
1300 if(lang.hasString("FontConsolePostfix") == true) {
1301 consoleFontNamePostfix = lang.getString("FontConsolePostfix");
1302 }
1303 if(lang.hasString("FontConsoleBaseSize") == true) {
1304 consoleFontNameSize = computeFontSize(strToInt(lang.getString("FontConsoleBaseSize")));
1305 }
1306 string consoleFontName= consoleFontNamePrefix + intToStr(consoleFontNameSize) + consoleFontNamePostfix;
1307
1308 consoleFont = loadFont<Font2D>(consoleFont, consoleFontName, consoleFontNameSize, "FontConsole", "FontConsoleFamily", "consoleFont");
1309 consoleFont3D = loadFont<Font3D>(consoleFont3D, consoleFontName, consoleFontNameSize, "FontConsole", "FontConsoleFamily", "consoleFont3D");
1310
1311 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] consoleFontName = [%s] consoleFontNameSize = %d\n",__FILE__,__FUNCTION__,__LINE__,consoleFontName.c_str(),consoleFontNameSize);
1312 }
1313
1314
loadFont(Font * menuFont,string menuFontName,int menuFontNameSize,string fontType,string fontTypeFamily,string fontUniqueKey)1315 template<typename T> T * CoreData::loadFont(Font *menuFont, string menuFontName,
1316 int menuFontNameSize, string fontType, string fontTypeFamily, string fontUniqueKey) {
1317 Renderer &renderer= Renderer::getInstance();
1318 if(menuFont) {
1319 string fontUniqueId = menuFont->getFontUniqueId();
1320 renderer.endFont(menuFont, rsGlobal);
1321 menuFont = NULL;
1322 triggerFontChangedCallbacks(fontUniqueId, menuFont);
1323 }
1324 if(Renderer::renderText3DEnabled == false) {
1325 menuFont = renderer.newFont(rsGlobal);
1326 }
1327 else {
1328 menuFont = renderer.newFont3D(rsGlobal);
1329 }
1330 if(menuFont) {
1331 Config &config= Config::getInstance();
1332 menuFont->setType(menuFontName,config.getString(fontType,""),config.getString(fontTypeFamily,""));
1333 menuFont->setSize(menuFontNameSize);
1334 menuFont->setWidth(Font::wBold);
1335 menuFont->setFontUniqueId(fontUniqueKey);
1336 triggerFontChangedCallbacks(menuFont->getFontUniqueId(), menuFont);
1337 }
1338 return (T *)menuFont;
1339 }
1340
computeFontSize(int size)1341 int CoreData::computeFontSize(int size) {
1342 int rs = size;
1343 Config &config= Config::getInstance();
1344 if(Font::forceLegacyFonts == true) {
1345 int screenH = config.getInt("ScreenHeight");
1346 rs = size * screenH / 1024;
1347 }
1348 //FontSizeAdjustment
1349 rs += config.getInt("FontSizeAdjustment");
1350 if(Font::forceLegacyFonts == false) {
1351 rs += Font::baseSize; //basesize only for new font system
1352 }
1353 if(Font::forceLegacyFonts == true) {
1354 if(rs < 10) {
1355 rs= 10;
1356 }
1357 }
1358 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fontsize original %d calculated:%d \n",__FILE__,__FUNCTION__,__LINE__,size,rs);
1359 return rs;
1360 }
1361
saveGameSettingsToFile(std::string fileName,GameSettings * gameSettings,int advancedIndex)1362 void CoreData::saveGameSettingsToFile(std::string fileName, GameSettings *gameSettings, int advancedIndex) {
1363 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
1364
1365 Config &config = Config::getInstance();
1366 string userData = config.getString("UserData_Root","");
1367 if(userData != "") {
1368 endPathWithSlash(userData);
1369 }
1370 fileName = userData + fileName;
1371
1372 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
1373
1374 #if defined(WIN32) && !defined(__MINGW32__)
1375 FILE *fp = _wfopen(utf8_decode(fileName).c_str(), L"w");
1376 std::ofstream saveGameFile(fp);
1377 #else
1378 std::ofstream saveGameFile;
1379 saveGameFile.open(fileName.c_str(), ios_base::out | ios_base::trunc);
1380 #endif
1381
1382 saveGameFile << "Description=" << gameSettings->getDescription() << std::endl;
1383 saveGameFile << "MapFilterIndex=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getMapFilter()) << std::endl;
1384 saveGameFile << "Map=" << gameSettings->getMap() << std::endl;
1385 saveGameFile << "Tileset=" << gameSettings->getTileset() << std::endl;
1386 saveGameFile << "TechTree=" << gameSettings->getTech() << std::endl;
1387 saveGameFile << "DefaultUnits=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getDefaultUnits()) << std::endl;
1388 saveGameFile << "DefaultResources=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getDefaultResources()) << std::endl;
1389 saveGameFile << "DefaultVictoryConditions=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getDefaultVictoryConditions()) << std::endl;
1390 saveGameFile << "FogOfWar=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getFogOfWar()) << std::endl;
1391 saveGameFile << "AdvancedIndex=" << Shared::PlatformByteOrder::toCommonEndian(advancedIndex) << std::endl;
1392 saveGameFile << "AllowObservers=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getAllowObservers()) << std::endl;
1393 saveGameFile << "FlagTypes1=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getFlagTypes1()) << std::endl;
1394 saveGameFile << "EnableObserverModeAtEndGame=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getEnableObserverModeAtEndGame()) << std::endl;
1395 saveGameFile << "AiAcceptSwitchTeamPercentChance=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getAiAcceptSwitchTeamPercentChance()) << std::endl;
1396 saveGameFile << "FallbackCpuMultiplier=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getFallbackCpuMultiplier()) << std::endl;
1397 saveGameFile << "PathFinderType=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getPathFinderType()) << std::endl;
1398 saveGameFile << "EnableServerControlledAI=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getEnableServerControlledAI()) << std::endl;
1399 saveGameFile << "NetworkFramePeriod=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getNetworkFramePeriod()) << std::endl;
1400 saveGameFile << "NetworkPauseGameForLaggedClients=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getNetworkPauseGameForLaggedClients()) << std::endl;
1401
1402 saveGameFile << "FactionThisFactionIndex=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getThisFactionIndex()) << std::endl;
1403 saveGameFile << "FactionCount=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getFactionCount()) << std::endl;
1404
1405 saveGameFile << "NetworkAllowNativeLanguageTechtree=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getNetworkAllowNativeLanguageTechtree()) << std::endl;
1406
1407 for(int i = 0; i < GameConstants::maxPlayers; ++i) {
1408 int slotIndex = gameSettings->getStartLocationIndex(i);
1409
1410 saveGameFile << "FactionControlForIndex" << Shared::PlatformByteOrder::toCommonEndian(slotIndex) << "=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getFactionControl(i)) << std::endl;
1411 saveGameFile << "ResourceMultiplierIndex" << Shared::PlatformByteOrder::toCommonEndian(slotIndex) << "=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getResourceMultiplierIndex(i)) << std::endl;
1412 saveGameFile << "FactionTeamForIndex" << Shared::PlatformByteOrder::toCommonEndian(slotIndex) << "=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getTeam(i)) << std::endl;
1413 saveGameFile << "FactionStartLocationForIndex" << Shared::PlatformByteOrder::toCommonEndian(slotIndex) << "=" << Shared::PlatformByteOrder::toCommonEndian(gameSettings->getStartLocationIndex(i)) << std::endl;
1414 saveGameFile << "FactionTypeNameForIndex" << Shared::PlatformByteOrder::toCommonEndian(slotIndex) << "=" << gameSettings->getFactionTypeName(i) << std::endl;
1415 saveGameFile << "FactionPlayerNameForIndex" << Shared::PlatformByteOrder::toCommonEndian(slotIndex) << "=" << gameSettings->getNetworkPlayerName(i) << std::endl;
1416
1417 saveGameFile << "FactionPlayerUUIDForIndex" << Shared::PlatformByteOrder::toCommonEndian(slotIndex) << "=" << gameSettings->getNetworkPlayerUUID(i) << std::endl;
1418 }
1419
1420 #if defined(WIN32) && !defined(__MINGW32__)
1421 if(fp) fclose(fp);
1422 #endif
1423 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
1424 }
1425
loadGameSettingsFromFile(std::string fileName,GameSettings * gameSettings)1426 bool CoreData::loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings) {
1427 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
1428
1429 bool fileWasFound = false;
1430 Config &config = Config::getInstance();
1431 string userData = config.getString("UserData_Root","");
1432 if(userData != "") {
1433 endPathWithSlash(userData);
1434 }
1435 if(fileExists(userData + fileName) == true) {
1436 fileName = userData + fileName;
1437 fileWasFound = true;
1438 }
1439
1440 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
1441
1442 if(fileExists(fileName) == false) {
1443 return false;
1444 }
1445
1446 fileWasFound = true;
1447 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
1448
1449 Properties properties;
1450 properties.load(fileName);
1451
1452 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] fileName = [%s]\n",__FILE__,__FUNCTION__,__LINE__,fileName.c_str());
1453
1454 gameSettings->setMapFilter(properties.getInt("MapFilterIndex","0"));
1455 gameSettings->setDescription(properties.getString("Description"));
1456 gameSettings->setMap(properties.getString("Map"));
1457 gameSettings->setTileset(properties.getString("Tileset"));
1458 gameSettings->setTech(properties.getString("TechTree"));
1459 gameSettings->setDefaultUnits(properties.getBool("DefaultUnits"));
1460 gameSettings->setDefaultResources(properties.getBool("DefaultResources"));
1461 gameSettings->setDefaultVictoryConditions(properties.getBool("DefaultVictoryConditions"));
1462 gameSettings->setFogOfWar(properties.getBool("FogOfWar"));
1463 //listBoxAdvanced.setSelectedItemIndex(properties.getInt("AdvancedIndex","0"));
1464
1465 gameSettings->setAllowObservers(properties.getBool("AllowObservers","false"));
1466 gameSettings->setFlagTypes1(properties.getInt("FlagTypes1","0"));
1467
1468 uint32 valueFlags1 = gameSettings->getFlagTypes1();
1469 if(Config::getInstance().getBool("EnableNetworkGameSynchChecks","false") == true) {
1470 //printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n");
1471
1472 valueFlags1 |= ft1_network_synch_checks_verbose;
1473 gameSettings->setFlagTypes1(valueFlags1);
1474
1475 }
1476 else {
1477 valueFlags1 &= ~ft1_network_synch_checks_verbose;
1478 gameSettings->setFlagTypes1(valueFlags1);
1479
1480 }
1481 if(Config::getInstance().getBool("EnableNetworkGameSynchMonitor","false") == true) {
1482 //printf("*WARNING* - EnableNetworkGameSynchChecks is enabled\n");
1483
1484 valueFlags1 |= ft1_network_synch_checks;
1485 gameSettings->setFlagTypes1(valueFlags1);
1486
1487 }
1488 else {
1489 valueFlags1 &= ~ft1_network_synch_checks;
1490 gameSettings->setFlagTypes1(valueFlags1);
1491
1492 }
1493
1494
1495 gameSettings->setEnableObserverModeAtEndGame(properties.getBool("EnableObserverModeAtEndGame"));
1496 gameSettings->setAiAcceptSwitchTeamPercentChance(properties.getInt("AiAcceptSwitchTeamPercentChance","30"));
1497 gameSettings->setFallbackCpuMultiplier(properties.getInt("FallbackCpuMultiplier","5"));
1498
1499 gameSettings->setPathFinderType(static_cast<PathFinderType>(properties.getInt("PathFinderType",intToStr(pfBasic).c_str())));
1500 gameSettings->setEnableServerControlledAI(properties.getBool("EnableServerControlledAI","true"));
1501 gameSettings->setNetworkFramePeriod(properties.getInt("NetworkFramePeriod",intToStr(GameConstants::networkFramePeriod).c_str()));
1502 gameSettings->setNetworkPauseGameForLaggedClients(properties.getBool("NetworkPauseGameForLaggedClients","false"));
1503
1504 gameSettings->setThisFactionIndex(properties.getInt("FactionThisFactionIndex"));
1505 gameSettings->setFactionCount(properties.getInt("FactionCount"));
1506
1507 if(properties.hasString("NetworkAllowNativeLanguageTechtree") == true) {
1508 gameSettings->setNetworkAllowNativeLanguageTechtree(properties.getBool("NetworkAllowNativeLanguageTechtree"));
1509 }
1510 else {
1511 gameSettings->setNetworkAllowNativeLanguageTechtree(false);
1512 }
1513
1514 for(int i = 0; i < GameConstants::maxPlayers; ++i) {
1515 gameSettings->setFactionControl(i,(ControlType)properties.getInt(string("FactionControlForIndex") + intToStr(i),intToStr(ctClosed).c_str()) );
1516
1517 if(gameSettings->getFactionControl(i) == ctNetworkUnassigned) {
1518 gameSettings->setFactionControl(i,ctNetwork);
1519 }
1520
1521 gameSettings->setResourceMultiplierIndex(i,properties.getInt(string("ResourceMultiplierIndex") + intToStr(i),"5"));
1522 gameSettings->setTeam(i,properties.getInt(string("FactionTeamForIndex") + intToStr(i),"0") );
1523 gameSettings->setStartLocationIndex(i,properties.getInt(string("FactionStartLocationForIndex") + intToStr(i),intToStr(i).c_str()) );
1524 gameSettings->setFactionTypeName(i,properties.getString(string("FactionTypeNameForIndex") + intToStr(i),"?") );
1525
1526 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] i = %d, factionTypeName [%s]\n",__FILE__,__FUNCTION__,__LINE__,i,gameSettings->getFactionTypeName(i).c_str());
1527
1528 if(gameSettings->getFactionControl(i) == ctHuman) {
1529 gameSettings->setNetworkPlayerName(i,properties.getString(string("FactionPlayerNameForIndex") + intToStr(i),"") );
1530 }
1531 else {
1532 gameSettings->setNetworkPlayerName(i,"");
1533 }
1534
1535 gameSettings->setNetworkPlayerUUID(i,properties.getString(string("FactionPlayerUUIDForIndex") + intToStr(i),"") );
1536 }
1537
1538 if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
1539
1540 return fileWasFound;
1541 }
1542
1543 // ================== PRIVATE ========================
1544
1545 }}//end namespace
1546