Need SDK help adding new Info Class

Jeckel

Great Reverend
Joined
Nov 16, 2005
Messages
1,637
Location
Peoria, IL
Ok, I am trying to add a ReligionClassInfo to the SDK. I have just about everything working, but have run into a problem.

I have the xml file, the schema is changed, I added the new Info Class into the CvInfos.ccp and all the other needed places, added getNumReligionClassInfos, getReligionClassInfo() and getReligionClassInfo(eReligionClass). Everything is working fine to this point, the dll compiles, xml files load, and the game runs.

But, getNumReligionClassInfos() equals 0 for some reason. I have 2 Religion Classes in the new xml file and if I put unexpected tags in the religionclass data I get the expected xml load errors so it seems to be reading through the file correctly. But it just doesn't add the religion classes to the religionclass array in the SDK.

I have the feeling I'm missing something simple, but I just can't figure it out. I have basicly gone thought the files and every where I found something to do with Religion Infos I added the same thing but for Religion Class Infos.

If anyone could offer suggestions on what I might be forgetting or point me to a BtS mod that addes a new xml file I would really appriciate it. :)

Here is a zip with the changed C++ files.

Here is the GameInfo directory with the modified GameInfo schemea, and the ReligionClassInfo.xml files.
 
To start with, check that logging is enabled (LoggingEnabled = 1) in CivilizationIV.ini (I can't remember if it's enabled by default).

Then if you open up MyDocuments\MyGames\BeyondTheSword\Logs\xml.log, you should see whether or not the file has been successfully loaded.
 
To start with, check that logging is enabled (LoggingEnabled = 1) in CivilizationIV.ini (I can't remember if it's enabled by default).

Then if you open up MyDocuments\MyGames\BeyondTheSword\Logs\xml.log, you should see whether or not the file has been successfully loaded.
Intresting, will this allow looking at all printf/assert text output?
 
It reads the xml file, the log says it is loaded successfully, this is not the problem. It just doesn't seem to save the religion classes. If I put erroneus code in the new xml file it errors correctly. But when I call gc.getNumReligionClassInfos() it returns 0 and gc.getReligionClassInfo(0) returns None.

I would really appriecate it if someone that has done this kind of thing before could take a quick look at my files. I just need a pointer to which file I'm not modifying or where it accualy takes the Type tag from the xml and assaigns that to its appropriate enum.

Help please. :)
 
Jeckel, can you attach your new XML file and also the schema file that formats it.

Fanatic Demon, there are a number of logs but asserts work differently. You can easily make your own log by adding this code to CvGlobals.cpp:

Code:
static const int kBufSize = 2048;
//
// for logging
//
void CvGlobals::logMsg(char* format, ... )
{
	static char buf[kBufSize];
	_vsnprintf( buf, kBufSize-4, format, (char*)(&format+1) );
	gDLL->logMsg("MyDebugLog.log", buf);
}

and "void logMsg(char* format, ... );//for debugging" as a public method in CvGlobals.h.

"MyDebugLog" can be any legal name you want. You print to the log by, e.g.,

Code:
m_iTechPrereq = pXML->FindInInfoClass(szTextVal);
[i]GC.logMsg("m_iTechPrereq=%d",m_iTechPrereq);[/i]
 
I see you understand your stuff very well.

Unfortunatly, I'm not there yet.

The problem of being an expert is that it can be very lonely :(

Thanx, but it is just because I've been doing this since Civ4 came out. You mess with the same files enough times and you eventually bang it into something. ;)
 
Jeckel, can you attach your new XML file and also the schema file that formats it.

Fanatic Demon, there are a number of logs but asserts work differently. You can easily make your own log by adding this code to CvGlobals.cpp:

Code:
static const int kBufSize = 2048;
//
// for logging
//
void CvGlobals::logMsg(char* format, ... )
{
	static char buf[kBufSize];
	_vsnprintf( buf, kBufSize-4, format, (char*)(&format+1) );
	gDLL->logMsg("MyDebugLog.log", buf);
}

and "void logMsg(char* format, ... );//for debugging" as a public method in CvGlobals.h.

"MyDebugLog" can be any legal name you want. You print to the log by, e.g.,

Code:
m_iTechPrereq = pXML->FindInInfoClass(szTextVal);
[i]GC.logMsg("m_iTechPrereq=%d",m_iTechPrereq);[/i]

I added a link to a zip of the GamInfo directory in the OP. It has the gameinfo schemea and the ReligionClassInfo.xml files.

And thanx for that function, being able to drop values to a log will help me in a few other SDK projects I'm messing with. :goodjob:
 
But, getNumReligionClassInfos() equals 0 for some reason. I have 2 Religion Classes in the new xml file

I built your dll with:

Code:
        // < 47 Religions Mod Start >
	LoadGlobalClassInfo(GC.getReligionClassInfo(), "CIV4ReligionClassInfo", "GameInfo", "Civ4ReligionClassInfo/ReligionClassInfos/ReligionClassInfo", false);
	// < 47 Religions Mod End >
GC.logMsg("num rel classes=%d",GC.getNumReligionClassInfos());

The output I got was "num rel classes=2". How are you calling the function?
 
Well, I didn't know a way to emit any variable values until you posted that logging function. I just got home from out of town and am recompiling with the logMsg function now.

Before I was acually using python to emit gc.getNumReligionClassInfos() to the ingame event log. This makes me think that perhaps the problem is in the exposing to python. Perhaps I have a typo somewhere.?.?

Thanx PeteT, atleast I have somewhere to look. I will post my results in a little while. :)
 
I must say, I am baffled. I have just recompiled from the exact same files I have uploaded except I added the logMsg function, and the log says "num rel classes=0".

This is just blowing my mind. What could possible cause the same code to work on one computer, but not work on mine. In my mod directory I have only the modded dll, the modded GameInfo schema, and the ReligionClassInfo.xml.

I tried it with modular xml loading on and off, just in case that mattered and it didn't make a difference.

Ideas? What could possibly be going on? Could it possably be some setting in the compiler? I wouldn't think it could be anything like that, but I'm grasping at staws here.
 
Without looking at the files, have you tried a clean build? If it builds on one PC and works but not on another my first suspicion is that your compiler isn't rebuilding everything that it needs to.
 
Yea, I have the sneaking susspition that maybe some of the files not in the mod may have been messed with. I will get it working if it kills me. :)
 
Yea, I have the sneaking susspition that maybe some of the files not in the mod may have been messed with. I will get it working if it kills me. :)
Acutally, by 'clean build' I mean a fresh rebuild of your source, so nuke all files in your release folder (wherever you're outputting your *.obj files) and recompile it.
 
Back
Top Bottom