Civ4 Crashes...but not in VS

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
I was doing some fairly ordinary work editing my BuildingInfos, and I tried to load the game up to see my changes. It crashed with a LoadCall on BuildingInfos. I figured it was because of my changes to my schema, but after double checking them, I could see nothing wrong. Despite that, I reverted to a slightly earlier schema. I didn't get any loadcall errors, but the game still crashed. Switching to a debug dll was no more enlightening. However, when I started the game up via Visual Studio w/ a debug dll, I was able to reach the main menu just fine. :confused:

What could be causing a crash in release and debug dll's but allow VS to get past it?
 
I seem to have narrowed down my problem anyway. Apparently the crash is linked to my ProjectInfos file. I added some new projects, but the game instantly rejects them. Now, making changes to existing projects also causes a CTD. Is there some hardcoded limit to projects in the SDK?
 
This is the oddest thing ever. A section of commented out projects is causing my crash. When I remove this from the end of my projectinfos:
Code:
<!--Afforess
		<ProjectInfo>
			<Type>PROJECT_CURE_FOR_CANCER</Type>
			<Description>TXT_KEY_BUILDING_CANCER</Description>
			<Civilopedia>TXT_KEY_BUILDING_CANCER_PEDIA</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_CANCER_STRATEGY</Strategy>
			<VictoryPrereq>NONE</VictoryPrereq>
			<TechPrereq>TECH_GENEMANIPULATION</TechPrereq>
			<AnyonePrereqProject>NONE</AnyonePrereqProject>
			<iMaxGlobalInstances>1</iMaxGlobalInstances>
			<iMaxTeamInstances>-1</iMaxTeamInstances>
			<iCost>2100</iCost>
			<iNukeInterception>0</iNukeInterception>
			<iTechShare>0</iTechShare>
			<EveryoneSpecialUnit>NONE</EveryoneSpecialUnit>
			<EveryoneSpecialBuilding>NONE</EveryoneSpecialBuilding>
			<bSpaceship>0</bSpaceship>
			<bAllowsNukes>0</bAllowsNukes>
			<Button>,Art/Interface/Buttons/Buildings/Cancer.dds,Art/Interface/Buttons/RoM_Building_Atlas.dds,5,2</Button>
			<PrereqProjects/>
			<VictoryThresholds/>
			<VictoryMinThresholds/>
			<iVictoryDelayPercent>0</iVictoryDelayPercent>
			<iSuccessRate>0</iSuccessRate>
			<BonusProductionModifiers>
			</BonusProductionModifiers>
			<CreateSound/>
			<MovieDefineTag></MovieDefineTag>
			<iGlobalHealth>2</iGlobalHealth>
			<iGlobalHappiness>1</iGlobalHappiness>
			<iWorldHappiness>0</iWorldHappiness>
			<iWorldHealth>2</iWorldHealth>
		</ProjectInfo>
		<ProjectInfo>
			<Type>PROJECT_HUMAN_GENOME</Type>
			<Description>TXT_KEY_BUILDING_HUMAN_GENOME_PROJECT</Description>
			<Civilopedia>TXT_KEY_BUILDING_HUMAN_GENOME_PROJECT_PEDIA</Civilopedia>
			<Strategy>TXT_KEY_BUILDING_HUMAN_GENOME_PROJECT_STRATEGY</Strategy>
			<VictoryPrereq>NONE</VictoryPrereq>
			<TechPrereq>TECH_GENETICS</TechPrereq>
			<AnyonePrereqProject>NONE</AnyonePrereqProject>
			<iMaxGlobalInstances>1</iMaxGlobalInstances>
			<iMaxTeamInstances>-1</iMaxTeamInstances>
			<iCost>2100</iCost>
			<iNukeInterception>0</iNukeInterception>
			<iTechShare>0</iTechShare>
			<EveryoneSpecialUnit>NONE</EveryoneSpecialUnit>
			<EveryoneSpecialBuilding>NONE</EveryoneSpecialBuilding>
			<bSpaceship>0</bSpaceship>
			<bAllowsNukes>0</bAllowsNukes>
			<Button>,Art/Interface/Buttons/Buildings/Genemaping.dds,Art/Interface/Buttons/RoM_Building_Atlas.dds,1,4</Button>
			<PrereqProjects/>
			<VictoryThresholds/>
			<VictoryMinThresholds/>
			<iVictoryDelayPercent>0</iVictoryDelayPercent>
			<iSuccessRate>0</iSuccessRate>
			<BonusProductionModifiers>
			</BonusProductionModifiers>
			<CreateSound/>
			<MovieDefineTag></MovieDefineTag>
			<iGlobalHealth>2</iGlobalHealth>
			<iGlobalHappiness>0</iGlobalHappiness>
			<iWorldHappiness>0</iWorldHappiness>
			<iWorldHealth>1</iWorldHealth>
		</ProjectInfo>
		Afforess -->

My CTD goes away. Adding it back causes it again. The odd part is that I have a project commented out higher up, and various other comments strewn along. What on earth!? :confused::confused:
 
Commments in XML are bad juju. Some places in the DLL it checks that NextSibling (or NextChild or whatever) exists, but does NOT check if it is a non-comment. It then proceeds with attempting to load things, ignoring comments, and thus finds either no data (and crashes) if you were commenting at the end of the file, or the WRONG data (and causes confusing mis-alignment issues) if the data was not at the end of the file.

In many locations, comments are fine. But in some key locations, they are crashes or the most annoying bugs ever.
 
Looking at just the two examples, i would guess, that iWorldHealth and iGlobalHealth do somehow interfere.

Nah, I added those to projects. They work perfectly. :) My projects can give health and happiness to all of a players cities or all cities in the world. :mischief:
 
Top Bottom