/
CvXMLLoadUtilitySet.cpp
2561 lines (2243 loc) · 96.1 KB
/
CvXMLLoadUtilitySet.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// XML Set functions
//
#include "CvGameCoreDLL.h"
#include "CvDLLXMLIFaceBase.h"
#include "CvXMLLoadUtility.h"
#include "CvGlobals.h"
#include "CvArtFileMgr.h"
#include "CvGameTextMgr.h"
#include <algorithm>
#include "CvInfoWater.h"
#include "FProfiler.h"
#include "FVariableSystem.h"
#include "CvGameCoreUtils.h"
// Macro for Setting Global Art Defines
#define INIT_XML_GLOBAL_LOAD(xmlInfoPath, infoArray, numInfos) SetGlobalClassInfo(infoArray, xmlInfoPath, numInfos);
bool CvXMLLoadUtility::ReadGlobalDefines(const TCHAR* szXMLFileName, CvCacheObject* cache)
{
bool bLoaded = false; // used to make sure that the xml file was loaded correctly
if (!gDLL->cacheRead(cache, szXMLFileName)) // src data file name
{
// load normally
if (!CreateFXml())
{
return false;
}
// load the new FXml variable with the szXMLFileName file
bLoaded = LoadCivXml(m_pFXml, szXMLFileName);
if (!bLoaded)
{
char szMessage[1024];
sprintf( szMessage, "LoadXML call failed for %s \n Current XML file is: %s", szXMLFileName, GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Load Error");
}
// if the load succeeded we will continue
if (bLoaded)
{
// locate the first define tag in the xml
if (gDLL->getXMLIFace()->LocateNode(m_pFXml,"Civ4Defines/Define"))
{
int i; // loop counter
// get the number of other Define tags in the xml file
int iNumDefines = gDLL->getXMLIFace()->GetNumSiblings(m_pFXml);
// add one to the total in order to include the current Define tag
iNumDefines++;
// loop through all the Define tags
for (i=0;i<iNumDefines;i++)
{
char szNodeType[256]; // holds the type of the current node
char szName[256];
// Skip any comments and stop at the next value we might want
if (SkipToNextVal())
{
// call the function that sets the FXml pointer to the first non-comment child of
// the current tag and gets the value of that new node
if (GetChildXmlVal(szName))
{
// set the FXml pointer to the next sibling of the current tag``
if (gDLL->getXMLIFace()->NextSibling(GetXML()))
{
// Skip any comments and stop at the next value we might want
if (SkipToNextVal())
{
// if we successfuly get the node type for the current tag
if (gDLL->getXMLIFace()->GetLastLocatedNodeType(GetXML(),szNodeType))
{
// if the node type of the current tag isn't null
if (strcmp(szNodeType,"")!=0)
{
// if the node type of the current tag is a float then
if (strcmp(szNodeType,"float")==0)
{
// get the float value for the define
float fVal;
GetXmlVal(&fVal);
GC.getDefinesVarSystem()->SetValue(szName, fVal);
}
// else if the node type of the current tag is an int then
else if (strcmp(szNodeType,"int")==0)
{
// get the int value for the define
int iVal;
GetXmlVal(&iVal);
GC.getDefinesVarSystem()->SetValue(szName, iVal);
}
// else if the node type of the current tag is a boolean then
else if (strcmp(szNodeType,"boolean")==0)
{
// get the boolean value for the define
bool bVal;
GetXmlVal(&bVal);
GC.getDefinesVarSystem()->SetValue(szName, bVal);
}
// otherwise we will assume it is a string/text value
else
{
char szVal[256];
// get the string/text value for the define
GetXmlVal(szVal);
GC.getDefinesVarSystem()->SetValue(szName, szVal);
}
}
// otherwise we will default to getting the string/text value for the define
else
{
char szVal[256];
// get the string/text value for the define
GetXmlVal(szVal);
GC.getDefinesVarSystem()->SetValue(szName, szVal);
}
}
}
}
// since we are looking at the children of a Define tag we will need to go up
// one level so that we can go to the next Define tag.
// Set the FXml pointer to the parent of the current tag
gDLL->getXMLIFace()->SetToParent(GetXML());
}
}
// now we set the FXml pointer to the sibling of the current tag, which should be the next
// Define tag
if (!gDLL->getXMLIFace()->NextSibling(m_pFXml))
{
break;
}
}
// write global defines info to cache
bool bOk = gDLL->cacheWrite(cache);
if (!bOk)
{
char szMessage[1024];
sprintf( szMessage, "Failed writing to global defines cache. \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Caching Error");
}
else
{
logMsg("Wrote GlobalDefines to cache");
}
}
}
// delete the pointer to the FXml variable
gDLL->getXMLIFace()->DestroyFXml(m_pFXml);
}
else
{
logMsg("Read GobalDefines from cache");
}
return true;
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetGlobalDefines()
//
// PURPOSE : Initialize the variables located in globaldefines.cpp/h with the values in
// GlobalDefines.xml
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::SetGlobalDefines()
{
UpdateProgressCB("GlobalDefines");
/////////////////////////////////
//
// use disk cache if possible.
// if no cache or cache is older than xml file, use xml file like normal, else read from cache
//
CvCacheObject* cache = gDLL->createGlobalDefinesCacheObject("GlobalDefines.dat"); // cache file name
if (!ReadGlobalDefines("xml\\GlobalDefines.xml", cache))
{
return false;
}
if (!ReadGlobalDefines("xml\\GlobalDefinesAlt.xml", cache))
{
return false;
}
if (!ReadGlobalDefines("xml\\PythonCallbackDefines.xml", cache))
{
return false;
}
if (gDLL->isModularXMLLoading())
{
std::vector<CvString> aszFiles;
gDLL->enumerateFiles(aszFiles, "modules\\*_GlobalDefines.xml");
for (std::vector<CvString>::iterator it = aszFiles.begin(); it != aszFiles.end(); ++it)
{
if (!ReadGlobalDefines(*it, cache))
{
return false;
}
}
std::vector<CvString> aszModularFiles;
gDLL->enumerateFiles(aszModularFiles, "modules\\*_PythonCallbackDefines.xml");
for (std::vector<CvString>::iterator it = aszModularFiles.begin(); it != aszModularFiles.end(); ++it)
{
if (!ReadGlobalDefines(*it, cache))
{
return false;
}
}
}
gDLL->destroyCache(cache);
////////////////////////////////////////////////////////////////////////
GC.cacheGlobals();
return true;
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetPostGlobalsGlobalDefines()
//
// PURPOSE : This function assumes that the SetGlobalDefines function has already been called
// it then loads the few global defines that needed to reference a global variable that
// hadn't been loaded in prior to the SetGlobalDefines call
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::SetPostGlobalsGlobalDefines()
{
const char* szVal=NULL; // holds the string value from the define queue
int idx;
if (GC.getDefinesVarSystem()->GetSize() > 0)
{
SetGlobalDefine("LAND_TERRAIN", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("LAND_TERRAIN", idx);
SetGlobalDefine("DEEP_WATER_TERRAIN", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("DEEP_WATER_TERRAIN", idx);
SetGlobalDefine("SHALLOW_WATER_TERRAIN", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("SHALLOW_WATER_TERRAIN", idx);
SetGlobalDefine("LAND_IMPROVEMENT", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("LAND_IMPROVEMENT", idx);
SetGlobalDefine("WATER_IMPROVEMENT", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("WATER_IMPROVEMENT", idx);
SetGlobalDefine("RUINS_IMPROVEMENT", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("RUINS_IMPROVEMENT", idx);
SetGlobalDefine("NUKE_FEATURE", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("NUKE_FEATURE", idx);
SetGlobalDefine("GLOBAL_WARMING_TERRAIN", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("GLOBAL_WARMING_TERRAIN", idx);
SetGlobalDefine("CAPITAL_BUILDINGCLASS", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("CAPITAL_BUILDINGCLASS", idx);
SetGlobalDefine("DEFAULT_SPECIALIST", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("DEFAULT_SPECIALIST", idx);
SetGlobalDefine("INITIAL_CITY_ROUTE_TYPE", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("INITIAL_CITY_ROUTE_TYPE", idx);
SetGlobalDefine("STANDARD_HANDICAP", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("STANDARD_HANDICAP", idx);
SetGlobalDefine("STANDARD_HANDICAP_QUICK", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("STANDARD_HANDICAP_QUICK", idx);
SetGlobalDefine("STANDARD_GAMESPEED", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("STANDARD_GAMESPEED", idx);
SetGlobalDefine("STANDARD_TURNTIMER", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("STANDARD_TURNTIMER", idx);
SetGlobalDefine("STANDARD_CLIMATE", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("STANDARD_CLIMATE", idx);
SetGlobalDefine("STANDARD_SEALEVEL", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("STANDARD_SEALEVEL", idx);
SetGlobalDefine("STANDARD_ERA", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("STANDARD_ERA", idx);
SetGlobalDefine("STANDARD_CALENDAR", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("STANDARD_CALENDAR", idx);
SetGlobalDefine("AI_HANDICAP", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("AI_HANDICAP", idx);
SetGlobalDefine("BARBARIAN_HANDICAP", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("BARBARIAN_HANDICAP", idx);
SetGlobalDefine("BARBARIAN_CIVILIZATION", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("BARBARIAN_CIVILIZATION", idx);
SetGlobalDefine("BARBARIAN_LEADER", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("BARBARIAN_LEADER", idx);
return true;
}
char szMessage[1024];
sprintf( szMessage, "Size of Global Defines is not greater than 0. \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Load Error");
return false;
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetGlobalTypes()
//
// PURPOSE : Initialize the variables located in globaltypes.cpp/h with the values in
// GlobalTypes.xml
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::SetGlobalTypes()
{
UpdateProgressCB("GlobalTypes");
bool bLoaded = false; // used to make sure that the xml file was loaded correctly
if (!CreateFXml())
{
return false;
}
// load the new FXml variable with the GlobalTypes.xml file
bLoaded = LoadCivXml(m_pFXml, "xml/GlobalTypes.xml");
if (!bLoaded)
{
char szMessage[1024];
sprintf( szMessage, "LoadXML call failed for GlobalTypes.xml. \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Load Error");
}
// if the load succeeded we will continue
if (bLoaded)
{
SetGlobalStringArray(&GC.getAnimationOperatorTypes(), "Civ4Types/AnimationOperatorTypes/AnimationOperatorType", &GC.getNumAnimationOperatorTypes());
int iEnumVal = NUM_FUNC_TYPES;
SetGlobalStringArray(&GC.getFunctionTypes(), "Civ4Types/FunctionTypes/FunctionType", &iEnumVal, true);
SetGlobalStringArray(&GC.getFlavorTypes(), "Civ4Types/FlavorTypes/FlavorType", &GC.getNumFlavorTypes());
SetGlobalStringArray(&GC.getArtStyleTypes(), "Civ4Types/ArtStyleTypes/ArtStyleType", &GC.getNumArtStyleTypes());
SetGlobalStringArray(&GC.getCitySizeTypes(), "Civ4Types/CitySizeTypes/CitySizeType", &GC.getNumCitySizeTypes());
iEnumVal = NUM_CONTACT_TYPES;
SetGlobalStringArray(&GC.getContactTypes(), "Civ4Types/ContactTypes/ContactType", &iEnumVal, true);
iEnumVal = NUM_DIPLOMACYPOWER_TYPES;
SetGlobalStringArray(&GC.getDiplomacyPowerTypes(), "Civ4Types/DiplomacyPowerTypes/DiplomacyPowerType", &iEnumVal, true);
iEnumVal = NUM_AUTOMATE_TYPES;
SetGlobalStringArray(&GC.getAutomateTypes(), "Civ4Types/AutomateTypes/AutomateType", &iEnumVal, true);
iEnumVal = NUM_DIRECTION_TYPES;
SetGlobalStringArray(&GC.getDirectionTypes(), "Civ4Types/DirectionTypes/DirectionType", &iEnumVal, true);
SetGlobalStringArray(&GC.getFootstepAudioTypes(), "Civ4Types/FootstepAudioTypes/FootstepAudioType", &GC.getNumFootstepAudioTypes());
gDLL->getXMLIFace()->SetToParent(m_pFXml);
gDLL->getXMLIFace()->SetToParent(m_pFXml);
SetVariableListTagPair(&GC.getFootstepAudioTags(), "FootstepAudioTags", GC.getFootstepAudioTypes(), GC.getNumFootstepAudioTypes(), "");
}
// delete the pointer to the FXml variable
DestroyFXml();
return true;
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetDiplomacyCommentTypes()
//
// PURPOSE : Creates a full list of Diplomacy Comments
//
//
//------------------------------------------------------------------------------------------------------
void CvXMLLoadUtility::SetDiplomacyCommentTypes(CvString** ppszString, int* iNumVals)
{
FAssertMsg(false, "should never get here");
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetupGlobalLandscapeInfos()
//
// PURPOSE : Initialize the appropriate variables located in globals.cpp/h with the values in
// Terrain\Civ4TerrainSettings.xml
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::SetupGlobalLandscapeInfo()
{
if (!CreateFXml())
{
return false;
}
LoadGlobalClassInfo(GC.getLandscapeInfo(), "CIV4TerrainSettings", "Terrain", "Civ4TerrainSettings/LandscapeInfos/LandscapeInfo", false);
// delete the pointer to the FXml variable
DestroyFXml();
return true;
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetGlobalArtDefines()
//
// PURPOSE : Initialize the appropriate variables located in globals.cpp/h with the values in
// Civ4ArtDefines.xml
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::SetGlobalArtDefines()
{
if (!CreateFXml())
{
return false;
}
LoadGlobalClassInfo(ARTFILEMGR.getInterfaceArtInfo(), "CIV4ArtDefines_Interface", "Art", "Civ4ArtDefines/InterfaceArtInfos/InterfaceArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getMovieArtInfo(), "CIV4ArtDefines_Movie", "Art", "Civ4ArtDefines/MovieArtInfos/MovieArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getMiscArtInfo(), "CIV4ArtDefines_Misc", "Art", "Civ4ArtDefines/MiscArtInfos/MiscArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getUnitArtInfo(), "CIV4ArtDefines_Unit", "Art", "Civ4ArtDefines/UnitArtInfos/UnitArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getBuildingArtInfo(), "CIV4ArtDefines_Building", "Art", "Civ4ArtDefines/BuildingArtInfos/BuildingArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getCivilizationArtInfo(), "CIV4ArtDefines_Civilization", "Art", "Civ4ArtDefines/CivilizationArtInfos/CivilizationArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getLeaderheadArtInfo(), "CIV4ArtDefines_Leaderhead", "Art", "Civ4ArtDefines/LeaderheadArtInfos/LeaderheadArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getBonusArtInfo(), "CIV4ArtDefines_Bonus", "Art", "Civ4ArtDefines/BonusArtInfos/BonusArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getImprovementArtInfo(), "CIV4ArtDefines_Improvement", "Art", "Civ4ArtDefines/ImprovementArtInfos/ImprovementArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getTerrainArtInfo(), "CIV4ArtDefines_Terrain", "Art", "Civ4ArtDefines/TerrainArtInfos/TerrainArtInfo", false);
LoadGlobalClassInfo(ARTFILEMGR.getFeatureArtInfo(), "CIV4ArtDefines_Feature", "Art", "Civ4ArtDefines/FeatureArtInfos/FeatureArtInfo", false);
DestroyFXml();
return true;
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetGlobalText()
//
// PURPOSE : Handles all Global Text Infos
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::LoadGlobalText()
{
CvCacheObject* cache = gDLL->createGlobalTextCacheObject("GlobalText.dat"); // cache file name
if (!gDLL->cacheRead(cache))
{
bool bLoaded = false;
if (!CreateFXml())
{
return false;
}
//
// load all files in the xml text directory
//
std::vector<CvString> aszFiles;
std::vector<CvString> aszModfiles;
gDLL->enumerateFiles(aszFiles, "xml\\text\\*.xml");
if (gDLL->isModularXMLLoading())
{
gDLL->enumerateFiles(aszModfiles, "modules\\*_CIV4GameText.xml");
aszFiles.insert(aszFiles.end(), aszModfiles.begin(), aszModfiles.end());
}
for(std::vector<CvString>::iterator it = aszFiles.begin(); it != aszFiles.end(); ++it)
{
bLoaded = LoadCivXml(m_pFXml, *it); // Load the XML
if (!bLoaded)
{
char szMessage[1024];
sprintf( szMessage, "LoadXML call failed for %s. \n Current XML file is: %s", (*it).c_str(), GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Load Error");
}
if (bLoaded)
{
// if the xml is successfully validated
SetGameText("Civ4GameText", "Civ4GameText/TEXT");
}
}
DestroyFXml();
// write global text info to cache
bool bOk = gDLL->cacheWrite(cache);
if (!bLoaded)
{
char szMessage[1024];
sprintf( szMessage, "Failed writing to Global Text cache. \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Caching Error");
}
if (bOk)
{
logMsg("Wrote GlobalText to cache");
}
} // didn't read from cache
else
{
logMsg("Read GlobalText from cache");
}
gDLL->destroyCache(cache);
return true;
}
bool CvXMLLoadUtility::LoadBasicInfos()
{
if (!CreateFXml())
{
return false;
}
LoadGlobalClassInfo(GC.getConceptInfo(), "CIV4BasicInfos", "BasicInfos", "Civ4BasicInfos/ConceptInfos/ConceptInfo", false);
LoadGlobalClassInfo(GC.getNewConceptInfo(), "CIV4NewConceptInfos", "BasicInfos", "Civ4NewConceptInfos/NewConceptInfos/NewConceptInfo", false);
LoadGlobalClassInfo(GC.getCityTabInfo(), "CIV4CityTabInfos", "BasicInfos", "Civ4CityTabInfos/CityTabInfos/CityTabInfo", false);
LoadGlobalClassInfo(GC.getCalendarInfo(), "CIV4CalendarInfos", "BasicInfos", "Civ4CalendarInfos/CalendarInfos/CalendarInfo", false);
LoadGlobalClassInfo(GC.getSeasonInfo(), "CIV4SeasonInfos", "BasicInfos", "Civ4SeasonInfos/SeasonInfos/SeasonInfo", false);
LoadGlobalClassInfo(GC.getMonthInfo(), "CIV4MonthInfos", "BasicInfos", "Civ4MonthInfos/MonthInfos/MonthInfo", false);
LoadGlobalClassInfo(GC.getDenialInfo(), "CIV4DenialInfos", "BasicInfos", "Civ4DenialInfos/DenialInfos/DenialInfo", false);
LoadGlobalClassInfo(GC.getInvisibleInfo(), "CIV4InvisibleInfos", "BasicInfos", "Civ4InvisibleInfos/InvisibleInfos/InvisibleInfo", false);
LoadGlobalClassInfo(GC.getUnitCombatInfo(), "CIV4UnitCombatInfos", "BasicInfos", "Civ4UnitCombatInfos/UnitCombatInfos/UnitCombatInfo", false);
LoadGlobalClassInfo(GC.getDomainInfo(), "CIV4DomainInfos", "BasicInfos", "Civ4DomainInfos/DomainInfos/DomainInfo", false);
LoadGlobalClassInfo(GC.getUnitAIInfo(), "CIV4UnitAIInfos", "BasicInfos", "Civ4UnitAIInfos/UnitAIInfos/UnitAIInfo", false);
LoadGlobalClassInfo(GC.getAttitudeInfo(), "CIV4AttitudeInfos", "BasicInfos", "Civ4AttitudeInfos/AttitudeInfos/AttitudeInfo", false);
LoadGlobalClassInfo(GC.getMemoryInfo(), "CIV4MemoryInfos", "BasicInfos", "Civ4MemoryInfos/MemoryInfos/MemoryInfo", false);
DestroyFXml();
return true;
}
//
// Globals which must be loaded before the main menus.
// Don't put anything in here unless it has to be loaded before the main menus,
// instead try to load things in LoadPostMenuGlobals()
//
bool CvXMLLoadUtility::LoadPreMenuGlobals()
{
if (!CreateFXml())
{
return false;
}
LoadGlobalClassInfo(GC.getGameSpeedInfo(), "CIV4GameSpeedInfo", "GameInfo", "Civ4GameSpeedInfo/GameSpeedInfos/GameSpeedInfo", false);
LoadGlobalClassInfo(GC.getTurnTimerInfo(), "CIV4TurnTimerInfo", "GameInfo", "Civ4TurnTimerInfo/TurnTimerInfos/TurnTimerInfo", false);
LoadGlobalClassInfo(GC.getWorldInfo(), "CIV4WorldInfo", "GameInfo", "Civ4WorldInfo/WorldInfos/WorldInfo", false);
LoadGlobalClassInfo(GC.getClimateInfo(), "CIV4ClimateInfo", "GameInfo", "Civ4ClimateInfo/ClimateInfos/ClimateInfo", false);
LoadGlobalClassInfo(GC.getSeaLevelInfo(), "CIV4SeaLevelInfo", "GameInfo", "Civ4SeaLevelInfo/SeaLevelInfos/SeaLevelInfo", false);
LoadGlobalClassInfo(GC.getAdvisorInfo(), "CIV4AdvisorInfos", "Interface", "Civ4AdvisorInfos/AdvisorInfos/AdvisorInfo", false);
LoadGlobalClassInfo(GC.getTerrainInfo(), "CIV4TerrainInfos", "Terrain", "Civ4TerrainInfos/TerrainInfos/TerrainInfo", false);
LoadGlobalClassInfo(GC.getEraInfo(), "CIV4EraInfos", "GameInfo", "Civ4EraInfos/EraInfos/EraInfo", false);
LoadGlobalClassInfo(GC.getUnitClassInfo(), "CIV4UnitClassInfos", "Units", "Civ4UnitClassInfos/UnitClassInfos/UnitClassInfo", false);
LoadGlobalClassInfo(GC.getSpecialistInfo(), "CIV4SpecialistInfos", "GameInfo", "Civ4SpecialistInfos/SpecialistInfos/SpecialistInfo", false);
LoadGlobalClassInfo(GC.getVoteSourceInfo(), "CIV4VoteSourceInfos", "GameInfo", "Civ4VoteSourceInfos/VoteSourceInfos/VoteSourceInfo", false);
LoadGlobalClassInfo(GC.getTechInfo(), "CIV4TechInfos", "Technologies", "Civ4TechInfos/TechInfos/TechInfo", true, &CvDLLUtilityIFaceBase::createTechInfoCacheObject);
LoadGlobalClassInfo(GC.getFeatureInfo(), "Civ4FeatureInfos", "Terrain", "Civ4FeatureInfos/FeatureInfos/FeatureInfo", false);
LoadGlobalClassInfo(GC.getReligionInfo(), "CIV4ReligionInfo", "GameInfo", "Civ4ReligionInfo/ReligionInfos/ReligionInfo", false);
LoadGlobalClassInfo(GC.getAnimationCategoryInfo(), "CIV4AnimationInfos", "Units", "Civ4AnimationInfos/AnimationCategories/AnimationCategory", false);
LoadGlobalClassInfo(GC.getAnimationPathInfo(), "CIV4AnimationPathInfos", "Units", "Civ4AnimationPathInfos/AnimationPaths/AnimationPath", false);
LoadGlobalClassInfo(GC.getPromotionInfo(), "CIV4PromotionInfos", "Units", "Civ4PromotionInfos/PromotionInfos/PromotionInfo", true, &CvDLLUtilityIFaceBase::createPromotionInfoCacheObject);
LoadGlobalClassInfo(GC.getTraitInfo(), "CIV4TraitInfos", "Civilizations", "Civ4TraitInfos/TraitInfos/TraitInfo", false);
LoadGlobalClassInfo(GC.getGoodyInfo(), "CIV4GoodyInfo", "GameInfo", "Civ4GoodyInfo/GoodyInfos/GoodyInfo", false);
LoadGlobalClassInfo(GC.getHandicapInfo(), "CIV4HandicapInfo", "GameInfo", "Civ4HandicapInfo/HandicapInfos/HandicapInfo", false, &CvDLLUtilityIFaceBase::createHandicapInfoCacheObject);
LoadGlobalClassInfo(GC.getCursorInfo(), "CIV4CursorInfo", "GameInfo", "Civ4CursorInfo/CursorInfos/CursorInfo", false);
LoadGlobalClassInfo(GC.getCivicOptionInfo(), "CIV4CivicOptionInfos", "GameInfo", "Civ4CivicOptionInfos/CivicOptionInfos/CivicOptionInfo", false);
LoadGlobalClassInfo(GC.getUpkeepInfo(), "CIV4UpkeepInfo", "GameInfo", "Civ4UpkeepInfo/UpkeepInfos/UpkeepInfo", false);
LoadGlobalClassInfo(GC.getHurryInfo(), "CIV4HurryInfo", "GameInfo", "Civ4HurryInfo/HurryInfos/HurryInfo", false);
LoadGlobalClassInfo(GC.getSpecialBuildingInfo(), "CIV4SpecialBuildingInfos", "Buildings", "Civ4SpecialBuildingInfos/SpecialBuildingInfos/SpecialBuildingInfo", false);
LoadGlobalClassInfo(GC.getCultureLevelInfo(), "CIV4CultureLevelInfo", "GameInfo", "Civ4CultureLevelInfo/CultureLevelInfos/CultureLevelInfo", false);
LoadGlobalClassInfo(GC.getBonusClassInfo(), "CIV4BonusClassInfos", "Terrain", "Civ4BonusClassInfos/BonusClassInfos/BonusClassInfo", false);
LoadGlobalClassInfo(GC.getVictoryInfo(), "CIV4VictoryInfo", "GameInfo", "Civ4VictoryInfo/VictoryInfos/VictoryInfo", false);
LoadGlobalClassInfo(GC.getBonusInfo(), "CIV4BonusInfos", "Terrain", "Civ4BonusInfos/BonusInfos/BonusInfo", false, &CvDLLUtilityIFaceBase::createBonusInfoCacheObject);
LoadGlobalClassInfo(GC.getCorporationInfo(), "CIV4CorporationInfo", "GameInfo", "Civ4CorporationInfo/CorporationInfos/CorporationInfo", false);
LoadGlobalClassInfo(GC.getRouteInfo(), "Civ4RouteInfos", "Misc", "Civ4RouteInfos/RouteInfos/RouteInfo", false);
LoadGlobalClassInfo(GC.getImprovementInfo(), "CIV4ImprovementInfos", "Terrain", "Civ4ImprovementInfos/ImprovementInfos/ImprovementInfo", true, &CvDLLUtilityIFaceBase::createImprovementInfoCacheObject);
LoadGlobalClassInfo(GC.getBuildingClassInfo(), "CIV4BuildingClassInfos", "Buildings", "Civ4BuildingClassInfos/BuildingClassInfos/BuildingClassInfo", false);
LoadGlobalClassInfo(GC.getBuildingInfo(), "CIV4BuildingInfos", "Buildings", "Civ4BuildingInfos/BuildingInfos/BuildingInfo", false, &CvDLLUtilityIFaceBase::createBuildingInfoCacheObject);
for (int i=0; i < GC.getNumBuildingClassInfos(); ++i)
{
GC.getBuildingClassInfo((BuildingClassTypes)i).readPass3();
}
LoadGlobalClassInfo(GC.getSpecialUnitInfo(), "CIV4SpecialUnitInfos", "Units", "Civ4SpecialUnitInfos/SpecialUnitInfos/SpecialUnitInfo", false);
LoadGlobalClassInfo(GC.getProjectInfo(), "CIV4ProjectInfo", "GameInfo", "Civ4ProjectInfo/ProjectInfos/ProjectInfo", true);
LoadGlobalClassInfo(GC.getCivicInfo(), "CIV4CivicInfos", "GameInfo", "Civ4CivicInfos/CivicInfos/CivicInfo", false, &CvDLLUtilityIFaceBase::createCivicInfoCacheObject);
for (int i=0; i < GC.getNumVoteSourceInfos(); ++i)
{
GC.getVoteSourceInfo((VoteSourceTypes)i).readPass3();
}
LoadGlobalClassInfo(GC.getLeaderHeadInfo(), "CIV4LeaderHeadInfos", "Civilizations", "Civ4LeaderHeadInfos/LeaderHeadInfos/LeaderHeadInfo", false, &CvDLLUtilityIFaceBase::createLeaderHeadInfoCacheObject);
LoadGlobalClassInfo(GC.getColorInfo(), "CIV4ColorVals", "Interface", "Civ4ColorVals/ColorVals/ColorVal", false);
LoadGlobalClassInfo(GC.getPlayerColorInfo(), "CIV4PlayerColorInfos", "Interface", "Civ4PlayerColorInfos/PlayerColorInfos/PlayerColorInfo", false);
LoadGlobalClassInfo(GC.getEffectInfo(), "CIV4EffectInfos", "Misc", "Civ4EffectInfos/EffectInfos/EffectInfo", false);
LoadGlobalClassInfo(GC.getEntityEventInfo(), "CIV4EntityEventInfos", "Units", "Civ4EntityEventInfos/EntityEventInfos/EntityEventInfo", false);
LoadGlobalClassInfo(GC.getBuildInfo(), "CIV4BuildInfos", "Units", "Civ4BuildInfos/BuildInfos/BuildInfo", false);
LoadGlobalClassInfo(GC.getUnitInfo(), "CIV4UnitInfos", "Units", "Civ4UnitInfos/UnitInfos/UnitInfo", false, &CvDLLUtilityIFaceBase::createUnitInfoCacheObject);
for (int i=0; i < GC.getNumUnitClassInfos(); ++i)
{
GC.getUnitClassInfo((UnitClassTypes)i).readPass3();
}
LoadGlobalClassInfo(GC.getUnitArtStyleTypeInfo(), "CIV4UnitArtStyleTypeInfos", "Civilizations", "Civ4UnitArtStyleTypeInfos/UnitArtStyleTypeInfos/UnitArtStyleTypeInfo", false);
LoadGlobalClassInfo(GC.getCivilizationInfo(), "CIV4CivilizationInfos", "Civilizations", "Civ4CivilizationInfos/CivilizationInfos/CivilizationInfo", true, &CvDLLUtilityIFaceBase::createCivilizationInfoCacheObject);
LoadGlobalClassInfo(GC.getHints(), "CIV4Hints", "GameInfo", "Civ4Hints/HintInfos/HintInfo", false);
LoadGlobalClassInfo(GC.getMainMenus(), "CIV4MainMenus", "Art", "Civ4MainMenus/MainMenus/MainMenu", false);
LoadGlobalClassInfo(GC.getSlideShowInfo(), "CIV4SlideShowInfos", "Interface", "Civ4SlideShowInfos/SlideShowInfos/SlideShowInfo", false);
LoadGlobalClassInfo(GC.getSlideShowRandomInfo(), "CIV4SlideShowRandomInfos", "Interface", "Civ4SlideShowRandomInfos/SlideShowRandomInfos/SlideShowRandomInfo", false);
LoadGlobalClassInfo(GC.getWorldPickerInfo(), "CIV4WorldPickerInfos", "Interface", "Civ4WorldPickerInfos/WorldPickerInfos/WorldPickerInfo", false);
LoadGlobalClassInfo(GC.getSpaceShipInfo(), "Civ4SpaceShipInfos", "Interface", "Civ4SpaceShipInfos/SpaceShipInfos/SpaceShipInfo", false);
LoadGlobalClassInfo(GC.getYieldInfo(), "CIV4YieldInfos", "Terrain", "Civ4YieldInfos/YieldInfos/YieldInfo", false);
LoadGlobalClassInfo(GC.getCommerceInfo(), "CIV4CommerceInfo", "GameInfo", "Civ4CommerceInfo/CommerceInfos/CommerceInfo", false);
LoadGlobalClassInfo(GC.getGameOptionInfo(), "CIV4GameOptionInfos", "GameInfo", "Civ4GameOptionInfos/GameOptionInfos/GameOptionInfo", false);
LoadGlobalClassInfo(GC.getMPOptionInfo(), "CIV4MPOptionInfos", "GameInfo", "Civ4MPOptionInfos/MPOptionInfos/MPOptionInfo", false);
LoadGlobalClassInfo(GC.getForceControlInfo(), "CIV4ForceControlInfos", "GameInfo", "Civ4ForceControlInfos/ForceControlInfos/ForceControlInfo", false);
// add types to global var system
for (int i = 0; i < GC.getNumCursorInfos(); ++i)
{
int iVal;
CvString szType = GC.getCursorInfo((CursorTypes)i).getType();
if (GC.getDefinesVarSystem()->GetValue(szType, iVal))
{
char szMessage[1024];
sprintf(szMessage, "cursor type already set? \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
GC.getDefinesVarSystem()->SetValue(szType, i);
}
// Check Playables
for (int i=0; i < GC.getNumCivilizationInfos(); ++i)
{
// if the civilization is playable we will increment the playable var
if (GC.getCivilizationInfo((CivilizationTypes) i).isPlayable())
{
GC.getNumPlayableCivilizationInfos() += 1;
}
// if the civilization is playable by AI increments num playable
if (GC.getCivilizationInfo((CivilizationTypes) i).isAIPlayable())
{
GC.getNumAIPlayableCivilizationInfos() += 1;
}
}
UpdateProgressCB("GlobalOther");
DestroyFXml();
return true;
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: LoadPostMenuGlobals()
//
// PURPOSE : loads global xml data which isn't needed for the main menus
// this data is loaded as a secodn stage, when the game is launched
//
//------------------------------------------------------------------------------------------------------
bool CvXMLLoadUtility::LoadPostMenuGlobals()
{
PROFILE_FUNC();
if (!CreateFXml())
{
return false;
}
//throne room disabled
UpdateProgressCB("Global Throne Room");
LoadGlobalClassInfo(GC.getThroneRoomCamera(), "CIV4ThroneRoomCameraInfos", "Interface", "Civ4ThroneRoomCameraInfos/ThroneRoomCameraInfos/ThroneRoomCamera", false);
LoadGlobalClassInfo(GC.getThroneRoomInfo(), "CIV4ThroneRoomInfos", "Interface", "Civ4ThroneRoomInfos/ThroneRoomInfos/ThroneRoomInfo", false);
LoadGlobalClassInfo(GC.getThroneRoomStyleInfo(), "CIV4ThroneRoomStyleInfos", "Interface", "Civ4ThroneRoomStyleInfos/ThroneRoomStyleInfos/ThroneRoomStyleInfo", false);
UpdateProgressCB("Global Events");
LoadGlobalClassInfo(GC.getEventInfo(), "CIV4EventInfos", "Events", "Civ4EventInfos/EventInfos/EventInfo", true, &CvDLLUtilityIFaceBase::createEventInfoCacheObject);
LoadGlobalClassInfo(GC.getEventTriggerInfo(), "CIV4EventTriggerInfos", "Events", "Civ4EventTriggerInfos/EventTriggerInfos/EventTriggerInfo", false, &CvDLLUtilityIFaceBase::createEventTriggerInfoCacheObject);
UpdateProgressCB("Global Routes");
LoadGlobalClassInfo(GC.getRouteModelInfo(), "Civ4RouteModelInfos", "Art", "Civ4RouteModelInfos/RouteModelInfos/RouteModelInfo", false);
UpdateProgressCB("Global Rivers");
LoadGlobalClassInfo(GC.getRiverInfo(), "CIV4RiverInfos", "Misc", "Civ4RiverInfos/RiverInfos/RiverInfo", false);
LoadGlobalClassInfo(GC.getRiverModelInfo(), "CIV4RiverModelInfos", "Art", "Civ4RiverModelInfos/RiverModelInfos/RiverModelInfo", false);
UpdateProgressCB("Global Other");
LoadGlobalClassInfo(GC.getWaterPlaneInfo(), "CIV4WaterPlaneInfos", "Misc", "Civ4WaterPlaneInfos/WaterPlaneInfos/WaterPlaneInfo", false);
LoadGlobalClassInfo(GC.getTerrainPlaneInfo(), "CIV4TerrainPlaneInfos", "Misc", "Civ4TerrainPlaneInfos/TerrainPlaneInfos/TerrainPlaneInfo", false);
LoadGlobalClassInfo(GC.getCameraOverlayInfo(), "CIV4CameraOverlayInfos", "Misc", "Civ4CameraOverlayInfos/CameraOverlayInfos/CameraOverlayInfo", false);
UpdateProgressCB("Global Process");
LoadGlobalClassInfo(GC.getProcessInfo(), "CIV4ProcessInfo", "GameInfo", "Civ4ProcessInfo/ProcessInfos/ProcessInfo", false);
UpdateProgressCB("Global Emphasize");
LoadGlobalClassInfo(GC.getEmphasizeInfo(), "CIV4EmphasizeInfo", "GameInfo", "Civ4EmphasizeInfo/EmphasizeInfos/EmphasizeInfo", false);
UpdateProgressCB("Global Other");
LoadGlobalClassInfo(GC.getMissionInfo(), "CIV4MissionInfos", "Units", "Civ4MissionInfos/MissionInfos/MissionInfo", false);
LoadGlobalClassInfo(GC.getControlInfo(), "CIV4ControlInfos", "Units", "Civ4ControlInfos/ControlInfos/ControlInfo", false);
LoadGlobalClassInfo(GC.getCommandInfo(), "CIV4CommandInfos", "Units", "Civ4CommandInfos/CommandInfos/CommandInfo", false);
LoadGlobalClassInfo(GC.getAutomateInfo(), "CIV4AutomateInfos", "Units", "Civ4AutomateInfos/AutomateInfos/AutomateInfo", false);
UpdateProgressCB("Global Vote");
LoadGlobalClassInfo(GC.getVoteInfo(), "CIV4VoteInfo", "GameInfo", "Civ4VoteInfo/VoteInfos/VoteInfo", false);
UpdateProgressCB("Global Interface");
LoadGlobalClassInfo(GC.getCameraInfo(), "CIV4CameraInfos", "Interface", "Civ4CameraInfos/CameraInfos/CameraInfo", false);
LoadGlobalClassInfo(GC.getInterfaceModeInfo(), "CIV4InterfaceModeInfos", "Interface", "Civ4InterfaceModeInfos/InterfaceModeInfos/InterfaceModeInfo", false);
SetGlobalActionInfo();
// Load the formation info
LoadGlobalClassInfo(GC.getUnitFormationInfo(), "CIV4FormationInfos", "Units", "UnitFormations/UnitFormation", false);
// Load the attachable infos
LoadGlobalClassInfo(GC.getAttachableInfo(), "CIV4AttachableInfos", "Misc", "Civ4AttachableInfos/AttachableInfos/AttachableInfo", false);
// Specail Case Diplomacy Info due to double vectored nature and appending of Responses
LoadDiplomacyInfo(GC.getDiplomacyInfo(), "CIV4DiplomacyInfos", "GameInfo", "Civ4DiplomacyInfos/DiplomacyInfos/DiplomacyInfo", &CvDLLUtilityIFaceBase::createDiplomacyInfoCacheObject);
LoadGlobalClassInfo(GC.getQuestInfo(), "Civ4QuestInfos", "Misc", "Civ4QuestInfos/QuestInfo", false);
LoadGlobalClassInfo(GC.getTutorialInfo(), "Civ4TutorialInfos", "Misc", "Civ4TutorialInfos/TutorialInfo", false);
LoadGlobalClassInfo(GC.getEspionageMissionInfo(), "CIV4EspionageMissionInfo", "GameInfo", "Civ4EspionageMissionInfo/EspionageMissionInfos/EspionageMissionInfo", false);
DestroyFXml();
return true;
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetGlobalStringArray(TCHAR (**ppszString)[256], char* szTagName, int* iNumVals)
//
// PURPOSE : takes the szTagName parameter and if it finds it in the m_pFXml member variable
// then it loads the ppszString parameter with the string values under it and the
// iNumVals with the total number of tags with the szTagName in the xml file
//
//------------------------------------------------------------------------------------------------------
void CvXMLLoadUtility::SetGlobalStringArray(CvString **ppszString, char* szTagName, int* iNumVals, bool bUseEnum)
{
PROFILE_FUNC();
logMsg("SetGlobalStringArray %s\n", szTagName);
int i=0; //loop counter
CvString *pszString; // hold the local pointer to the newly allocated string memory
pszString = NULL; // null out the local string pointer so that it can be checked at the
// end of the function in an FAssert
// if we locate the szTagName, the current node is set to the first instance of the tag name in the xml file
if (gDLL->getXMLIFace()->LocateNode(m_pFXml,szTagName))
{
if (!bUseEnum)
{
// get the total number of times this tag appears in the xml
*iNumVals = gDLL->getXMLIFace()->NumOfElementsByTagName(m_pFXml,szTagName);
}
// initialize the memory based on the total number of tags in the xml and the 256 character length we selected
*ppszString = new CvString[*iNumVals];
// set the local pointer to the memory just allocated
pszString = *ppszString;
// loop through each of the tags
for (i=0;i<*iNumVals;i++)
{
// get the string value at the current node
GetXmlVal(pszString[i]);
GC.setTypesEnum(pszString[i], i);
// if can't set the current node to a sibling node we will break out of the for loop
// otherwise we will keep looping
if (!gDLL->getXMLIFace()->NextSibling(m_pFXml))
{
break;
}
}
}
// if the local string pointer is null then we weren't able to find the szTagName in the xml
// so we will FAssert to let whoever know it
if (!pszString)
{
char szMessage[1024];
sprintf( szMessage, "Error locating tag node in SetGlobalStringArray function \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
}
//------------------------------------------------------------------------------------------------------
//
// FUNCTION: SetGlobalActionInfo(CvActionInfo** ppActionInfo, int* iNumVals)
//
// PURPOSE : Takes the szTagName parameter and if it exists in the xml it loads the ppActionInfo
// with the value under it and sets the value of the iNumVals parameter to the total number
// of occurances of the szTagName tag in the xml.
//
//------------------------------------------------------------------------------------------------------
void CvXMLLoadUtility::SetGlobalActionInfo()
{
PROFILE_FUNC();
logMsg("SetGlobalActionInfo\n");
int i=0; //loop counter
if(!(NUM_INTERFACEMODE_TYPES > 0))
{
char szMessage[1024];
sprintf( szMessage, "NUM_INTERFACE_TYPES is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(GC.getNumBuildInfos() > 0))
{
char szMessage[1024];
sprintf( szMessage, "GC.getNumBuildInfos() is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(GC.getNumPromotionInfos() > 0))
{
char szMessage[1024];
sprintf( szMessage, "GC.getNumPromotionInfos() is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(GC.getNumUnitClassInfos() > 0) )
{
char szMessage[1024];
sprintf( szMessage, "GC.getNumUnitClassInfos() is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(GC.getNumSpecialistInfos() > 0) )
{
char szMessage[1024];
sprintf( szMessage, "GC.getNumSpecialistInfos() is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(GC.getNumBuildingInfos() > 0) )
{
char szMessage[1024];
sprintf( szMessage, "GC.getNumBuildingInfos() is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(NUM_CONTROL_TYPES > 0) )
{
char szMessage[1024];
sprintf( szMessage, "NUM_CONTROL_TYPES is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(GC.getNumAutomateInfos() > 0) )
{
char szMessage[1024];
sprintf( szMessage, "GC.getNumAutomateInfos() is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(NUM_COMMAND_TYPES > 0) )
{
char szMessage[1024];
sprintf( szMessage, "NUM_COMMAND_TYPES is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
if(!(NUM_MISSION_TYPES > 0) )
{
char szMessage[1024];
sprintf( szMessage, "NUM_MISSION_TYPES is not greater than zero in CvXMLLoadUtility::SetGlobalActionInfo \n Current XML file is: %s", GC.getCurrentXMLFile().GetCString());
gDLL->MessageBox(szMessage, "XML Error");
}
int* piOrderedIndex=NULL;
int iNumOrigVals = GC.getNumActionInfos();
int iNumActionInfos = iNumOrigVals +
NUM_INTERFACEMODE_TYPES +
GC.getNumBuildInfos() +
GC.getNumPromotionInfos() +
GC.getNumReligionInfos() +
GC.getNumCorporationInfos() +
GC.getNumUnitInfos() +
GC.getNumSpecialistInfos() +
GC.getNumBuildingInfos() +
NUM_CONTROL_TYPES +
NUM_COMMAND_TYPES +
GC.getNumAutomateInfos() +
NUM_MISSION_TYPES;
int* piIndexList = new int[iNumActionInfos];
int* piPriorityList = new int[iNumActionInfos];
int* piActionInfoTypeList = new int[iNumActionInfos];
int iTotalActionInfoCount = 0;
// loop through control info
for (i=0;i<NUM_COMMAND_TYPES;i++)
{
piIndexList[iTotalActionInfoCount] = i;
piPriorityList[iTotalActionInfoCount] = GC.getCommandInfo((CommandTypes)i).getOrderPriority();
piActionInfoTypeList[iTotalActionInfoCount] = ACTIONSUBTYPE_COMMAND;
iTotalActionInfoCount++;
}
for (i=0;i<NUM_INTERFACEMODE_TYPES;i++)
{
piIndexList[iTotalActionInfoCount] = i;
piPriorityList[iTotalActionInfoCount] = GC.getInterfaceModeInfo((InterfaceModeTypes)i).getOrderPriority();
piActionInfoTypeList[iTotalActionInfoCount] = ACTIONSUBTYPE_INTERFACEMODE;
iTotalActionInfoCount++;
}
for (i=0;i<GC.getNumBuildInfos();i++)
{
piIndexList[iTotalActionInfoCount] = i;
piPriorityList[iTotalActionInfoCount] = GC.getBuildInfo((BuildTypes)i).getOrderPriority();
piActionInfoTypeList[iTotalActionInfoCount] = ACTIONSUBTYPE_BUILD;
iTotalActionInfoCount++;
}
for (i=0;i<GC.getNumPromotionInfos();i++)
{
piIndexList[iTotalActionInfoCount] = i;
piPriorityList[iTotalActionInfoCount] = GC.getPromotionInfo((PromotionTypes)i).getOrderPriority();
piActionInfoTypeList[iTotalActionInfoCount] = ACTIONSUBTYPE_PROMOTION;
iTotalActionInfoCount++;
}
for (i=0;i<GC.getNumUnitInfos();i++)
{
piIndexList[iTotalActionInfoCount] = i;
piPriorityList[iTotalActionInfoCount] = GC.getUnitInfo((UnitTypes)i).getOrderPriority();
piActionInfoTypeList[iTotalActionInfoCount] = ACTIONSUBTYPE_UNIT;
iTotalActionInfoCount++;
}
for (i=0;i<GC.getNumReligionInfos();i++)
{
piIndexList[iTotalActionInfoCount] = i;
piPriorityList[iTotalActionInfoCount] = GC.getReligionInfo((ReligionTypes)i).getOrderPriority();
piActionInfoTypeList[iTotalActionInfoCount] = ACTIONSUBTYPE_RELIGION;
iTotalActionInfoCount++;
}
for (i=0;i<GC.getNumCorporationInfos();i++)
{
piIndexList[iTotalActionInfoCount] = i;
piPriorityList[iTotalActionInfoCount] = GC.getCorporationInfo((CorporationTypes)i).getOrderPriority();
piActionInfoTypeList[iTotalActionInfoCount] = ACTIONSUBTYPE_CORPORATION;