Archid
Warlord
I am having a CTD issue on adding a new int array into a custom XML file.
I have stripped out as much custom code as possible and just added a skeleton set of changes into the standard BTS code base and compiled that to try and isolate where the problem lies. It appears that my array is being read successfully as putting some breakpoints in I can see that the array is initialised by inspecting the CvGlobals cache.
I initially put a breakpoint in the call to get my custom type from the global cache
and could see that the array is being initialised with the correct number of values. In order to eliminate any XML traversal errors I stripped out the proper code to initialise the array from the XML, and used a InitList call with a specific initialisation value:
With the constant coming from enums.h
Looking at the watch window in VC++ on the breakpoint using m_piTargetTypeValue,5 I can see that the the first 4 entries have a value of 3 with the 5th value being random as I would expect.
The thing that is stumping me is that it doesn't appear to be a specific line of the custom dll code that is throwing the error. I have been stepping through the code and the error is usually being thrown when I hit the 'End Turn' button by ntdll.dll coming from the main Civ4BeyondSword.exe with CvGameCoreDLL.dll not even showing in the Call Stack.
Looking at the ntdll.dll disassembly the offending op is
which dredging my memory is the stack pointer being incremented, so I would suspect it is trying to get the next int from an array...but that is a guess as it has been years since I touched assembler!
All my code snippets have been copied from existing OOB BTS code and I have double and triple checked variable names, but can't see where I have gone wrong. If I comment out the
to initialise the array then the game appears to run fine; maybe that is a red herring, but as I have stripped out all my other custom code I suspect not.
Does anyone have any ideas or pointers on how to debug this further?
I have stripped out as much custom code as possible and just added a skeleton set of changes into the standard BTS code base and compiled that to try and isolate where the problem lies. It appears that my array is being read successfully as putting some breakpoints in I can see that the array is initialised by inspecting the CvGlobals cache.
I initially put a breakpoint in the call to get my custom type from the global cache
Spoiler :
PHP:
CvStarEventInfo& CvGlobals::getStarEventInfo(StarEventTypes eEvent)
{
FAssert(eEvent > -1);
FAssert(eEvent < GC.getNumStarEventInfos());
return *(m_paStarEventInfo[eEvent]);
}
Spoiler :
PHP:
bool CvStarEventInfo::read(CvXMLLoadUtility* pXML)
{
CvString szTextVal;
if (!CvInfoBase::read(pXML))
{
return false;
}
pXML->InitList(&m_piTargetTypeValue, NUM_STAR_EVENT_TARGET_TYPES,3);
return true;
}
Spoiler :
PHP:
enum StarEventTargetTypes
{
STAR_EVENT_NO_CITY,
STAR_EVENT_ALL_CITIES,
STAR_EVENT_CAPITAL_CITY,
STAR_EVENT_RANDOM_CITY,
#ifdef _USRDLL
NUM_STAR_EVENT_TARGET_TYPES
#endif
};
The thing that is stumping me is that it doesn't appear to be a specific line of the custom dll code that is throwing the error. I have been stepping through the code and the error is usually being thrown when I hit the 'End Turn' button by ntdll.dll coming from the main Civ4BeyondSword.exe with CvGameCoreDLL.dll not even showing in the Call Stack.
Looking at the ntdll.dll disassembly the offending op is
PHP:
add esp,4
All my code snippets have been copied from existing OOB BTS code and I have double and triple checked variable names, but can't see where I have gone wrong. If I comment out the
PHP:
pXML->InitList(...)
Does anyone have any ideas or pointers on how to debug this further?