Adding XML file

deanej

Deity
Joined
Apr 8, 2006
Messages
4,859
Location
New York State
How do I make the SDK recognize a new XML file? I want the game to use the file Civ4CloakingInfos for my Star Trek mod, but I can't find anything about how to add it to the SDK.

EDIT: I think I managed to get it right, but it won't compile. I don't understand what I'm doing wrong.

CvXMLLoadUtilitySet.cpp
Code:
LoadGlobalClassInfo(GC.getCloakingInfo(), "CIV4CloakingInfos", "Misc", "Civ4CloakingInfos/CloakingInfos/CloakInfo", false);

CvGlobals.cpp
Code:
int CvGlobals::getNumCloakInfos()
{
	return (int)m_paCloakingInfo.size();
}

std::vector<CvCloakingInfo*>& CvGlobals::getCloakingInfo()
{
	return m_paCloakingInfo;
}

CvCloakingInfo& CvGlobals::getCloakingInfo(CloakTypes eCloakNum)
{
	FAssert(eCloakNum > -1);
	FAssert(eCloakNum < GC.getNumCloakInfos());
	return *(m_paCloakingInfo[eCloakNum]);
}
Code:
deleteInfoArray(m_paCloakingInfo);

CvGlobals.h
Code:
class CvCloakingInfo;
Code:
	DllExport int getNumCloakInfos();
	std::vector<CvCloakingInfo*>& getCloakingInfo();
	DllExport CvCloakingInfo& getCloakingInfo(CloakTypes eCloakNum);
Code:
std::vector<CvCloakingInfo*> m_paCloakingInfo;

Spoiler :
Error:
1>------ Build started: Project: CvGameCoreDLL, Configuration: Release Win32 ------
1>Performing Makefile project actions
1>Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
1>Copyright (C) Microsoft Corporation. All rights reserved.
1> "C:/Program Files/Microsoft Visual C++ Toolkit 2003/bin/cl.exe" /nologo /MD /Gd /G7 /GR /O2 /W3 /EHsc /DWIN32 /DNDEBUG /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /DFINAL_RELEASE /IBoost-1.32.0/include /IPython24/include /I"C:/Program Files/Microsoft Visual C++ Toolkit 2003/include" /I"C:/Program Files/Microsoft Platform SDK/Include" /c CvArea.cpp /FoFinal_Release/CvArea.obj
1>CvArea.cpp
1>c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\CvGlobals.h(616) : error C2061: syntax error : identifier 'CloakTypes'
1>c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\CvGlobals.h(616) : error C2556: 'CvCloakingInfo &CvGlobals::getCloakingInfo(void)' : overloaded function differs only by return type from 'std::vector<_Ty> &CvGlobals::getCloakingInfo(void)'
1> with
1> [
1> _Ty=CvCloakingInfo *
1> ]
1> c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\CvGlobals.h(615) : see declaration of 'CvGlobals::getCloakingInfo'
1>c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\CvGlobals.h(616) : error C2371: 'CvGlobals::getCloakingInfo' : redefinition; different basic types
1> c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\CvGlobals.h(615) : see declaration of 'CvGlobals::getCloakingInfo'
1>NMAKE : fatal error U1077: '"C:/Program Files/Microsoft Visual C++ Toolkit 2003/bin/cl.exe"' : return code '0x2'
1>Stop.
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\Release\BuildLog.htm"
1>CvGameCoreDLL - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

What am I doing wrong? My form is identical to that which Firaxis used.
 
I see a couple things right away...

You're not defining what CloakTypes are anywhere, if you're going to use it as a valid data type you need to define it. Look at how they do it with other types like 'BonusTypes'

Your trying to overload a function impropperly. An overloaded function is one that is just like another except with different args. You have getCloakingInfo(void) defined twice, the one which is returning a vector should probably be getCloakingInfos(void) (note the added 's').

That will resolve your compiler errors but the code still won't work until you add the code to read the Cloaking Infos from the XML file. I don't have the SDK available right now so I can't tell you exactly where to do that but there are some great tutorials here that will.
 
That change fixed some of the errors but it still fails.
Spoiler :
1>------ Build started: Project: CvGameCoreDLL, Configuration: Release Win32 ------
1>Performing Makefile project actions
1>Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
1>Copyright (C) Microsoft Corporation. All rights reserved.
1> "C:\Program Files\Microsoft Visual C++ Toolkit 2003/bin/cl.exe" /nologo /MD /Gd /G7 /GR /O2 /W3 /EHsc /DWIN32 /DNDEBUG /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /DFINAL_RELEASE /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files\Microsoft Visual C++ Toolkit 2003/include" /I"C:\Program Files\Microsoft Platform SDK/Include" /c CvArea.cpp /FoFinal_Release/CvArea.obj
1>CvArea.cpp
1>c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\CvGlobals.h(616) : error C2061: syntax error : identifier 'CloakTypes'
1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual C++ Toolkit 2003/bin/cl.exe"' : return code '0x2'
1>Stop.
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\Release\BuildLog.htm"
1>CvGameCoreDLL - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Also, why can Firaxis code this one way, but I have to code it differently?

I can't define it yet because I'm not there yet. Right now I just want the game to see the file - I don't even know if it's error-free because I don't have an XML editor. I also know very little about the SDK and C++ - I have never made a mod with it before nor have I attempted to. I would have preferred to have someone else do this, but nobody will help me with my Star Trek mod.
 
It's not a variable that you're trying to define, it's an object. For example you may want something like: int function() where int is the return type, in this case int is valid because it's part of C++, you're saying CloakTypes function() but C++ doesn't know what CloakTypes is. The data it contains is irrelevant at this point because the data type 'CloakTypes' doesn't exist and you need to define it before you can use it.

Now that I'm back home I can look in the SDK :)

You need to define CloakTypes in CvEnums.h with all of the others, for instance:
Code:
enum DllExport BonusTypes						// Exposed to Python
{
	NO_BONUS = -1,
};
Just like Firaxis had to do :)

Once you do that your data type 'CloakTypes' will be valid.
 
I did that but I now get:

Spoiler :
1>------ Build started: Project: CvGameCoreDLL, Configuration: Release Win32 ------
1>Performing Makefile project actions
1>Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
1>Copyright (C) Microsoft Corporation. All rights reserved.
1> "C:\Program Files\Microsoft Visual C++ Toolkit 2003/bin/cl.exe" /nologo /MD /Gd /G7 /GR /O2 /W3 /EHsc /DWIN32 /DNDEBUG /D_WINDOWS /D_USRDLL /DCVGAMECOREDLL_EXPORTS /DFINAL_RELEASE /IBoost-1.32.0/include /IPython24/include /I"C:\Program Files\Microsoft Visual C++ Toolkit 2003/include" /I"C:\Program Files\Microsoft Platform SDK/Include" /c CvArea.cpp /FoFinal_Release/CvArea.obj
1>CvArea.cpp
1>c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\CvEnums.h(1616) : error C2470: 'CloakTypes' : looks like a function definition, but there is no formal parameter list; skipping apparent body
1>c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\CvGlobals.h(616) : error C2061: syntax error : identifier 'CloakTypes'
1>NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual C++ Toolkit 2003/bin/cl.exe"' : return code '0x2'
1>Stop.
1>Project : error PRJ0019: A tool returned an error code from "Performing Makefile project actions"
1>Build log was saved at "file://c:\Documents and Settings\Jon Deane.JON\My Documents\My Games\CvGameCoreDLL\Release\BuildLog.htm"
1>CvGameCoreDLL - 4 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Is the compiler broken, or am I just too inexperienced for this to work?
 
I can't help you with your errors, but I can tell you that creating more and more threads about the same problem turns many people off from helping you.

It seems you don't know enough about programming to do the things you're trying to do. I'd suggest going out and finding tutorials on the languages you're having problems with, C++ and Python.

That's probably not what you wanted to hear, but in the long run, it's best for you.
 
Actually, the errors may not have been my code, but the compiler not working. It won't even compile a clean build of the original files. Also, do you know of any civ-centric C++ tutorial? A problem I ran into with python is that I knew the language well, but I had no clue how it worked in civ. I managed to learn it by looking at the Final Frontier files, but the SDK isn't nearly as well commented. Also, I don't intend to use python with this. Should I?
 
stay away from pythons..they make the game slow..use them only for user input/interface/output.. keep the code in the SDK! faster that way..

PM me, i'll check out your codes...FULL code please..and stop posting several threads for 1 issue..indeed it turns people off
 
The slowest points in Python are loops. Everything else has negligible slowdown. Sometime, even those slowdowns can be minimized if they implement something like Psyco.
 
just stay away from pythons! I've seen the difference of pythons in for example the unitstatistics mod. at later time of the game disabled, gameturns are just by 20% faster just by disabling this 1 single python mod. and tha'ts a fact i can prove you on my PC if you come and look and measure with the stopwatch. I've ported the whole unitstatistics now in the SDk, nada python, and slowdown is unmeasurable..since i do alot of autoAI to test stuff(mostly performance testing) can really warn you, for the sake of the playability of your mod, stay away from have python todo any coding!
whatever you wanna do, program it in the SDK, let do your functions have their math there, use the strenght of the c++ compiler of VS 2005, and use python just for triggering that piece of code, and retrieve the outcome..that's my advise..but everyone who wish to slowdown computers, be my guest! :)
 
As I said, loops are notorious in Python, so if you can avoid them and put them in the DLL, it's probably preferable. I doubt Firaxis included anything like Psyco with their Python implementation, I just mentioned it because you seemed so adamant about professing all things Python evil. :p
 
LOL, yeah, i avoid python whereever i can, prolly also because in c++ i feel free to do anything i want, whereas in python i still have to get used to the syntaxis and possibilities :)

I'm conservative :P
 
OK... I managed to get the base SDK to compile in CodeBlocks. I re-added my changes, but it won't compile. I don't understand it. I can't even tell that my code was added by anyone other than Firaxis, and yet I get many errors. Are there more things I need to modify? I've attached the modified files.
 
Back
Top Bottom