[SDK] Crashes when not a complete rebuild

scottrycroft

Chieftain
Joined
Mar 15, 2002
Messages
18
I've been trying to add a list of names for each civ to use as 'governor' or 'official' names for cities. So for I've added the XML code in CIV4CivilizationsSchema and CIV4CivilizationInfos, and now I've started adding it in CvInfos.

I'm copying line for line the input used for importing the city names (m_iNumCityNames and m_paszCityNames), but I've been getting weird and somewhat inconsistent errors.

Sometimes the game crashes on the Init XML stage on load, but then it seems to stop after a few times (one maybe... not sure there). But then it crashes during a new game, right before loading the screen for selecting your civilization. I'm guessing its a cache problem or something.

I first had done a compile with no changes, and that had worked with no problems. Then I started doing changes, but that would produce the errors. Some small changes wouldn't produce them, like simply declaring the new variables. But adding the read/write and XML load seemed to do it.

The odd thing is, the game doesn't crash if I do a complete rebuild (clean). Any ideas on that? Could it be a makefile problem? I'd rather not have to wait 10 minutes each time I add something in. I'm using Visual C++ Express Edition 2005, using the instructions on the site here, and that provided makefile.

I've attached the files I've modded in case that helps, all changes are comment marked with // added by Scott

http://forums.civfanatics.com/uploads/14149/CvInfos.zip
 
I may have had a similar problem a "long" time ago when working on my Events mod. If you are trying to create new strings as part of your info class... sometimes this leads to problems. I believe it had something to do with memory allocation during a string copy... I cannot for the moment offer a fix, but when I get time, I can look at your code and compare it to mine and see if I can help. Meanwhile... can you save your new string to an already existing variable such as setHelp or simply assign one of the base memebers? (This will only work if the class you are changing/creating does not use the given variable). This is how I got around this issue in most of my new classes I added:

Example:
Code:
if (pXML->read(&szTextValue, "MyStringValue"))
{
     m_szHelpKey = szTextValue;
}

What this does, is it essentially copies the given string and assigns the copy to the Base classes "help" string. If the class you are using does not use the help string, this is an easy way to get around this issue. You can also use the following standard base info class members:

m_szStrategyKey
m_szCivilopediaKey // may be m_szCiviliopedia... cannot remember at the moment).
m_szTextKey // is usually filled by the <description> xml tag.

EDIT: Not sure about the "rebuild" aspect of the problem. That is odd...but I used a full (student) version of Visual Studio 2003... I just upgraded to a non-student version of 2005 so I may be in for some trouble.... yikes.
 
I had a similar problem with Visual Studio 2005 Express and strange crashes after changing stuff in CvInfos (especially when adding arrays). It successfully compiled but when launching the mod it broke down. Didn't find a very good solution to it, but doing a complete rebuild once I have changed everything I want in CvInfos does the trick for me. After this I can proceed with incomplete rebuilds.
 
I had a similar problem with Visual Studio 2005 Express and strange crashes after changing stuff in CvInfos (especially when adding arrays). It successfully compiled but when launching the mod it broke down. Didn't find a very good solution to it, but doing a complete rebuild once I have changed everything I want in CvInfos does the trick for me. After this I can proceed with incomplete rebuilds.

Make sure you are initializing your arrays (before you create them) to NULL... This tends to lead to memory issues down the road.
 
Back
Top Bottom