Multidimensional Arrays

The next thing to test is that the bonus arrays are not NULL:

Code:
void CvCity::setBuildingBonusStockChange(BuildingClassTypes eBuildingClass, BonusTypes eBonus, int iValue)
{
	if (m_aaiBuildingBonusStockChange != NULL)
	{
[B]		if (m_aaiBuildingBonusStockChange[(int) eBuildingClass] != NULL)
		{[/B]
			m_aaiBuildingBonusStockChange[(int) eBuildingClass][(int) eBonus] = iValue;
[B]		}[/B]
	}
}

Given how you initialize the arrays, I don't think this is possible, but we need to remove it as a possibility.
 
If you used the FAssert commands you did NOT check that you are giving valid values unless you also ran a debug DLL, which I am fairly certain you did not do. Replace the FAssert calls will IF checks (so your command will be double nested) and return a default value outside the IF statements for those which need a return (non VOID functions).
 
If you used the FAssert commands you did NOT check that you are giving valid values unless you also ran a debug DLL, which I am fairly certain you did not do. Replace the FAssert calls will IF checks (so your command will be double nested) and return a default value outside the IF statements for those which need a return (non VOID functions).

no i didn't use the fassert commands. i know what they are for thanks to your tutorial. :D

The next thing to test is that the bonus arrays are not NULL:


Code:
void CvCity::setBuildingBonusStockChange(BuildingClassTypes eBuildingClass, BonusTypes eBonus, int iValue)
{
if (m_aaiBuildingBonusStockChange != NULL)
{
if (m_aaiBuildingBonusStockChange[(int) eBuildingClass] != NULL)
{
m_aaiBuildingBonusStockChange[(int) eBuildingClass][(int) eBonus] = iValue;
}
}
}Given how you initialize the arrays, I don't think this is possible, but we need to remove it as a possibility.

okay, ill try this when i get home from work. i've not been testing if the second array is null. thank you!
 
even with the checks, i am still getting the CTD whenever i call changeBuildingBonusStockChange.

i will try rewriting but i'm pretty stumped.

thanks in advance for any ideas!
 
You'll be much quicker to a solution if you compile a Debug build and attach to the game using Visual Studio. Instead of a CTD, VS will popup and show you exactly where the error occurred. Plus you'll be able to examine the call stack (which functions led to the crash) and variables along the way.
 
You'll be much quicker to a solution if you compile a Debug build and attach to the game using Visual Studio. Instead of a CTD, VS will popup and show you exactly where the error occurred. Plus you'll be able to examine the call stack (which functions led to the crash) and variables along the way.

setting VS 2008 up was much easier than i expected. and debug instantly found the problem. two functions were looping back and forth to each other forever, had nothing to do with the arrays after all.

thanks emperorfool!
 
Top Bottom