CvGlobals.cpp crash issue..maybe?

Lib.Spi't

Overlord of the Wasteland
Joined
Feb 12, 2009
Messages
3,708
Location
UK
Code:
CvUnitInfo& CvGlobals::getUnitInfo(UnitTypes eUnitNum)
{
	FAssert([COLOR="Red"]eUnitNum > -1[/COLOR]);
	FAssert(eUnitNum < GC.getNumUnitInfos());
	return *(m_paUnitInfo[eUnitNum]);
}

Any body have any notions as to why this would:

1: be an assert fail

2: cause a CTD because it is an assert fail?

Before this I have this assert fail from supercheese Specialist enhancement code:
Code:
void CvCity::changeSpecialistUnhappiness(int iChange)
{
	if (iChange != 0)
	{
		m_iSpecialistUnhappiness += iChange;
		FAssert([COLOR="Red"]getSpecialistUnhappiness() >= 0[/COLOR]);

		AI_setAssignWorkDirty(true);

		if (getTeam() == GC.getGameINLINE().getActiveTeam())
		{
			setInfoDirty(true);
		}
	}
}

If you would like any other files or code snippets just let me know, I am at a loss as to what is wrong or where the connections to an epic fail might be!

What is even more confusing is that it doesn't happen all the time... just some games..
 
The way it works is that when the XML is loaded each unit gets a reference number (which is the order in which it is loaded). So those under normal circumstances start at 0 and go up, which is why it is asserting that the number is between zero and however many units your mod has. I have no idea how you would be getting a number less than 0 (either heap corruption or one of the calling functions is doing something bad), but check that out in the debugger.
 
have you got any tips on debugging, because i don't get any info that i understand, no file references, just a weird string of numbers and things like mov eax etc. I don't know what they mean.. would it help if i posted them here? it us just way above my pay grade of understanding! :D

Assert Failed

File: CvXMLLoadUtilityGet.cpp
Line: 656
Expression: false
Message: Error in GetChildXmlVal function, unable to find a child node

i get this message when loading the game, it sounds like it could be related? what with the mention of xmlval?

thoughts?

Assert Failed

File: c:\games\civiv\2k games\firaxis games\sid meier's civilization 4 complete\beyond the sword\mods\k-fallout\assets\cvgamecoredll\CvInfos.h
Line: 66
Expression: false
Message: Override this

i get thisone too alot when starting up..
 
The XML load failure means one of your XML files is not even getting loaded properly. After that happens, you can't count on anything working correctly.

The "unable to find a child node" error means you have a tag specified that is supposed to take sub-tags (like the B tags in "<A><B>1</B><B>2</B></A>" which specifies 2 child nodes for the A tag) which does not have as many as it should have - possibly none when it should have some. Check for something that would normally take sub-tags which is specified as <A></A> instead of <A/> (or instead of just leaving it out entirely, for tags that can be left out). Also check for things that specify too few of the sub-values. It can happen if a tag is supposed to have two different sub-tags but is missing one or more, example: in the unit info the UnitAI sub tag of the UnitAIs tag should have both a UnitAIType and a bUnitAI as sub-tags like so:
Code:
				<UnitAI>
					<UnitAIType>UNITAI_ANIMAL</UnitAIType>
					<bUnitAI>1</bUnitAI>
				</UnitAI>
so you'd probably get that error message if you forgot the bUnitAI tag in there.

Or something along those lines.

Anyhow, step 1 is to get all the XML loading correctly. After that, you can work on other issues. Until the XML data is loaded correctly it is hard to know if any error is real or caused just by not having the data it needs.
 
Brilliant cheers! I think there are a lot of possibilities of what that could be! At least I know what I am trying to get now!

grr I got rid of the bits I thought might be causing the problem... but it wasn't those so I am now really doing the needle in a haystack game.... I get the child node error message twice, so I assume that means I am looking for 2 of these kinds of errors?

Is there a log file that would tell me which xml file is having the issue? just to make sure it is definately something in the unit file and not another xml.
 
Assert Failed

File: CvUnit.cpp
Line: 13977
Expression: eIndex >= 0
Message: eIndex is expected to be non-negative (invalid Index)

I am getting a lot of this error in lumps every few turns, the spacing seems fairly random between occurences.

it is connected to this bit of code

bool CvUnit::isHasPromotion(PromotionTypes eIndex) const
{
FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
FAssertMsg(eIndex < GC.getNumPromotionInfos(), "eIndex is expected to be within maximum bounds (invalid Index)");
return m_pabHasPromotion[eIndex];
}

Which is about having promotions, I don't fully understand what is wrong though.. In the mod we have certain free promotions that are like 'race' promotions, that units start with free. I am just trying to figure out what could be making this ishaspromotion call generate a negative number issue?
 
You need to check everything that calls isHasPromotion since one of them is passing a negative number, probably -1.

It could be in the DLL or it could be in Python. It could be as simple as a typo in some Python code when it is getting the promotion info number from the promotion type text via a gc.getInfoTypeForString("PROMOTION_SOMETHING") - if you spelled "PROMOTION_SOMETHING" wrong so it is looking up something that does not exist this call would return -1.
 
I managed to fix the promotion bug :D

But I just cannot find the source of these 2 childval errors...

I am running out of ideas of ways to try and find them..

I have one save game where the crash occurs, and it seems to be related to a unit being built in an ai city, but when I put someone next to it to 'spy' on that unit being built, the crash does not occur???

Any thoughts on why this weird occurence might happen??
 
About the "unable to find a child node" errors: you are seeing those errors because you are running a debug dll right? But there are two ways to run a debug dll: one is just to run your game with it, the other is to debug your game by "attaching" it to Visual C++ studio (whatever tool you are using to compile your dll). In this case, in the Output window or report, you would see at which xml file it is stopping.

If you don't know what I mean by the "attach" process, there's a section on it in Asaf's excellent tutorial on how to compile a dll.

Edit: For me, it is stopping more than a hundred times at the LeaderHeadInfos file, but as far as I know, it does not seem to cause a problem in the game.

Edit2: intrigued, I decided to look further in my file and could not find something significant. Then I found in this section a post by Afforess saying that his own comments (Advanced Diplomacy) were to be deleted in that specific file!
 
SUCCESS!!!

The issue was that I had 2 civs with a derivative civ that did not exist! childval error DEAD!! MUAHAHAA

Code:
Assert Failed

File: c:\games\civiv\2k games\firaxis games\sid meier's civilization 4 complete\beyond the sword\mods\k-fallout\assets\cvgamecoredll\CvInfos.h
Line: 66
Expression: false
Message: Override this

any ideas what I should do about this?

it seems to be connected to this:
CIV4ForceControlInfos.xml

But I don't really know what I should be looking for?
 
Great! You erased two undead Civs! :eek:

Have you ever changed CIV4ForceControlInfos.xml? I guess not. It's the last xml file to load before the menu so the display is stuck at this file and the message is misleading. Typically, it has nothing to do with your problem!

Edit: as for line 66 of CvInfos.h you can see that it is about "readPass3()". I think it has something to do with the order in which the xml files are loaded and their interrelation checked but I can't help you further with this.
 
Ok any ideas what to do about this one, I have added the line it refers to plus a few around it for context, is something missing from this bit or is this even a problem or just a 'feedback' message?

Could this be related to the fact that I don't have any boats in the game?

Code:
Assert Failed

File:  CvTeamAI.cpp
Line:  6161
Expression:  false
Message:

Code:
					case UNITAI_MISSILE_AIR:
						iValue += bWarPlan ? 40 : 20;
						break;

					default:
					[COLOR="Red"]	FAssert(false);[/COLOR]
						break;
					}
					
					if (iNavalValue > 0)
					{
						if (AI_isAnyCapitalAreaAlone())
						{
							iValue += iNavalValue / 2;
						}
						if (bWarPlan && !AI_isLandTarget(eTeam))
						{
							iValue += iNavalValue / 2;
						}
					}
				}
			}
		}
	}
 
Nope, because the Naval stuff is after the Assert.

Look before in the code, it starts with:
switch (GC.getUnitInfo(eLoopUnit).getDefaultUnitAIType())

So there is a Unit with either no "DefaultUnitAIType" or with no match in the list following the code. Since all UNITAIs are in the list, it's the former.
 
Well I have weeded out some issues, I am still stuck on fixing the main CTD though, but I thought I would post this error in the hopes of some one shedding some light on a possible cause!

Assert Failed
File: CvCity.cpp
Line: 1257
Expression: GET_PLAYER(getOwnerINLINE()).getFreeCityCommerce((CommerceTypes)iI) >= 0
Message:

Could this be related to the fact I have leader traits that give free commerce? Or is it a completely different issue?

Code:
#ifdef _DEBUG
	{
		CvPlot* pPlot;
		int iCount;
		int iI, iJ;

		for (iI = 0; iI < NUM_YIELD_TYPES; iI++)
		{
			FAssert(getBaseYieldRate((YieldTypes)iI) >= 0);
			FAssert(getYieldRate((YieldTypes)iI) >= 0);

			iCount = 0;

			for (iJ = 0; iJ < NUM_CITY_PLOTS; iJ++)
			{
				if (isWorkingPlot(iJ))
				{
					pPlot = getCityIndexPlot(iJ);

					if (pPlot != NULL)
					{
						iCount += pPlot->getYield((YieldTypes)iI);
					}
				}
			}

			for (iJ = 0; iJ < GC.getNumSpecialistInfos(); iJ++)
			{
				iCount += (GET_PLAYER(getOwnerINLINE()).specialistYield(((SpecialistTypes)iJ), ((YieldTypes)iI)) * (getSpecialistCount((SpecialistTypes)iJ) + getFreeSpecialistCount((SpecialistTypes)iJ)));
			}

			for (iJ = 0; iJ < GC.getNumBuildingInfos(); iJ++)
			{
				iCount += getNumActiveBuilding((BuildingTypes)iJ) * (GC.getBuildingInfo((BuildingTypes) iJ).getYieldChange(iI) + getBuildingYieldChange((BuildingClassTypes)GC.getBuildingInfo((BuildingTypes) iJ).getBuildingClassType(), (YieldTypes)iI));
			}

			iCount += getTradeYield((YieldTypes)iI);
			iCount += getCorporationYield((YieldTypes)iI);

			FAssert(iCount == getBaseYieldRate((YieldTypes)iI));
		}

		for (iI = 0; iI < NUM_COMMERCE_TYPES; iI++)
		{
			FAssert(getBuildingCommerce((CommerceTypes)iI) >= 0);
			FAssert(getSpecialistCommerce((CommerceTypes)iI) >= 0);
			FAssert(getReligionCommerce((CommerceTypes)iI) >= 0);
			FAssert(getCorporationCommerce((CommerceTypes)iI) >= 0);
			[COLOR="Red"]FAssert(GET_PLAYER(getOwnerINLINE()).getFreeCityCommerce((CommerceTypes)iI) >= 0);[/COLOR]
		}

		for (iI = 0; iI < GC.getNumBonusInfos(); iI++)
		{
			FAssert(isNoBonus((BonusTypes)iI) || getNumBonuses((BonusTypes)iI) >= ((isConnectedToCapital()) ? (GET_PLAYER(getOwnerINLINE()).getBonusImport((BonusTypes)iI) - GET_PLAYER(getOwnerINLINE()).getBonusExport((BonusTypes)iI)) : 0));
		}
	}
#endif

that is the code it relates to..
 
The issue is that the player in question is set to have a modifier that is a negative amount of some type of commerce in all of their cities. This may not be a bug since there can be reasons for this to be valid (although the original programmer didn't think so), in which case you could just comment out the FAssert. So the question is whether or not it is supposed to happen - perhaps you created a trait that gives a reduction for one of the commerce types in each city? If you do not have it set up like that on purpose, you have to figure out where/why that particular value is getting set to something below 0.
 
Back
Top Bottom