Accessing custom XML inside the DLL

glider1

Deity
Joined
May 29, 2006
Messages
2,905
Location
Where animals hop not run
Hi there great modders of Civ5

I have been playing around with the DLL for BNW. I tried to access a custom XML variable by doing this:

1) Create a new XML variable like this in the mod:
Spoiler :
<GameData>
<Defines>
<Row Name="ALL_START_WAR">
<Value>1</Value>
</Row>
</Defines>
</GameData>

2) Build a custom DLL doing things exactly the way Firaxis do it:
Spoiler :
CvGlobals:
int m_iALL_START_WAR;
m_iALL_START_WAR(0),
m_iALL_START_WAR = getDefineINT("ALL_START_WAR");
inline int getALL_START_WAR()
{
return m_iALL_START_WAR;
}

Now it actually works that is not my problem.
The problem is that every now and then the DLL will crash on exit or reload.
If I build a custom DLL without this code, it never crashes.
How do you people access custom XML from inside the DLL?
 
Exactly that way, and not seeing crashes during exit/reload

So, what version of the SDK / game have you tried this with? Until yesterday the SDK source code was not in step with the game release, so it could be being caused by that. Do you get the same problems if you just use the compile the DLL and include it into a mod with NO changes? Do you get the same issues if you then use the DLL as shipped with the game as the dll being used by your mod (this will show if the problem is with the way the mod API within the game loads the DLL)

Are you using real-time debugging and/or FireTuner? Both of those cause the game to occasionally crash during a reload I've discovered.
 
Thanks Whoward! At least I know that the method works for someone else. As you will well know the dreaded random CTD is the modders curse. Will report back with any findings and those debugging techniques are classic:goodjob:. I actually thought at the time that the source was in sync with the game maybe that was half my problem :sad::blush::eek::dunno:
 
Would you describe this crash as a hang or it actually CTDs? I'm experiencing an intermittent crash on load (when I click the "Begin your journey" button). I find the game locks up (video stops updating, user input does nothing, between the DoM panel disappearing and the default settler being selected), but the audio keeps playing, and it doesn't become an unresponsive task, in the traditional windows sense - you can kill it with Task Manager with no prompts.

And this crash is ruining my life! I thought it was a memory leak, because it was getting worse the more times I booted the game until a machine restart. I fixed one of those and it *seemed* to get better. But it has since returned (I've made several changes, so maybe it is a memory leak and I introduced yet another one).

I've yet to merge in the latest Firaxis code, so that's yet another maybe as a way to fix it. I'm not sure if the crash's timeline is in line with the out of sync source, but it seems like the right sort of time period.

Also, yes, I use the exact same code to load in new defines in the DLL.
 
I feel your pain! It works properly now that I updated the source code...Before it would randomly CTD sometimes on load, sometimes on exit or returning to the main menu. No other symptoms like you are experiencing. Suggest that initially your mod should do things exactly the way that Firaxis does things and then branch out into more radical approaches once you have set a basic benchmark.
 
Back
Top Bottom