How to get a new xml file to load?

NotSoGood

Emperor
Joined
Jan 25, 2009
Messages
1,077
Location
Finland
I'm trying to get new xml/schema files to load. I have added the functions, that should find the info from xml, to CvInfos.cpp and CvInfos.h, but nothing seems to happen. I checked the xml log, and my new files weren't loaded. :confused:
Where is defined loading the new xml files, or have I done something wrong/missed something?

Just in case here's all my changes:
  • CIV4IdeologyInfos
    Spoiler :
    Code:
    <?xml version="1.0"?>
    <!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Alex Mantzaris (Firaxis Games) -->
    <!-- Sid Meier's Civilization 4 -->
    <!-- Copyright Firaxis Games 2005 -->
    <!-- -->
    <!-- Ideology -->
    <Civ4IdeologyInfo xmlns="x-schema:CIV4IdeologySchema.xml">
    	<IdeologyInfos>
    		<IdeologyInfo>
    			<Type>IDEOLOGY_DEMOCRACY</Type>
    			<Description>Democracy</Description>
    			<Civilopedia>democracy_pedia</Civilopedia>
    			<Button>Art/Interface/Buttons/Religions/Jewish.dds</Button>
    			<TechPrereq>NONE</TechPrereq>
    			<FreeUnitClass>NONE</FreeUnitClass>
    			<iFreeUnits>0</iFreeUnits>
    			<iSpreadFactor>100</iSpreadFactor>
    		</IdeologyInfo>
    	</IdeologyInfos>
    </Civ4IdeologyInfo>
    and CIV4IdeologyShema
    Spoiler :
    Code:
    <!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Alex Mantzaris (Firaxis Games) -->
    <!-- Sid Meier's Civilization 4 -->
    <!-- Copyright Firaxis Games 2005 -->
    <!-- -->
    <!-- Ideology Schema -->
    <Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">
    	<ElementType name="Type" content="textOnly"/>
    	<ElementType name="Description" content="textOnly"/>
    	<ElementType name="Civilopedia" content="textOnly"/>
    	<ElementType name="Button" content="textOnly"/>
    	<ElementType name="TechPrereq" content="textOnly"/>
    	<ElementType name="FreeUnitClass" content="textOnly"/>
    	<ElementType name="iFreeUnits" content="textOnly" dt:type="int"/>
    	<ElementType name="iSpreadFactor" content="textOnly" dt:type="int"/>
    	<ElementType name="iOrderPriority" content="textOnly" dt:type="int"/>
    	<ElementType name="IdeologyInfo" content="eltOnly">
    		<element type="Type"/>
    		<element type="Description"/>
    		<element type="Civilopedia"/>
    		<element type="Button"/>
    		<element type="TechPrereq"/>
    		<element type="FreeUnitClass"/>
    		<element type="iFreeUnits"/>
    		<element type="iSpreadFactor"/>
    		<element type="iOrderPriority" minOccurs="0"/>
    	</ElementType>
    	<ElementType name="IdeologyInfos" content="eltOnly">
    		<element type="IdeologyInfo" maxOccurs="*"/>
    	</ElementType>
    	<ElementType name="Civ4IdeologyInfo" content="eltOnly">
    		<element type="IdeologyInfos"/>
    	</ElementType>
    </Schema>
  • CvInfos.h
    Spoiler :
    Code:
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    //
    //  class : CvIdeologyInfo
    //
    //  DESC:   
    //
    //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    class CvIdeologyInfo :
    	public CvInfoBase
    {
    //---------------------------------------PUBLIC INTERFACE---------------------------------
    public:
    
    	CvIdeologyInfo();
    	virtual ~CvIdeologyInfo();
    
    	int getTechPrereq() const;
    	int getFreeUnitClass() const;
    	int getNumFreeUnits() const;
    	int getSpreadFactor() const;
    
    	// Arrays
    
    	bool read(CvXMLLoadUtility* pXML);
    
    //---------------------------------------PROTECTED MEMBER VARIABLES---------------------------------
    protected:
    
    	int m_iTechPrereq;
    	int m_iFreeUnitClass;
    	int m_iNumFreeUnits;
    	int m_iSpreadFactor;
    
    	// Arrays
    	
    };
  • CvInfos.cpp
    Spoiler :
    Code:
    //======================================================================================================
    //					CvIdeologyInfo
    //======================================================================================================
    
    //------------------------------------------------------------------------------------------------------
    //
    //  FUNCTION:   CvIdeologyInfo()
    //
    //  PURPOSE :   Default constructor
    //
    //------------------------------------------------------------------------------------------------------
    CvIdeologyInfo::CvIdeologyInfo() :
    m_iTechPrereq(NO_TECH),
    m_iFreeUnitClass(NO_UNITCLASS),
    m_iNumFreeUnits(0),
    m_iSpreadFactor(0)
    {
    }
    
    //------------------------------------------------------------------------------------------------------
    //
    //  FUNCTION:   ~CvIdeologyInfo()
    //
    //  PURPOSE :   Default destructor
    //
    //------------------------------------------------------------------------------------------------------
    CvIdeologyInfo::~CvIdeologyInfo()
    {
    }
    int CvIdeologyInfo::getTechPrereq() const							
    {
    	return m_iTechPrereq;
    }
    int CvIdeologyInfo::getFreeUnitClass() const
    {
    	return m_iFreeUnitClass; 
    }
    
    int CvIdeologyInfo::getNumFreeUnits() const
    {
    	return m_iNumFreeUnits; 
    }
    
    int CvIdeologyInfo::getSpreadFactor() const
    {
    	return m_iSpreadFactor;
    }
    
    bool CvIdeologyInfo::read(CvXMLLoadUtility* pXML)
    {
    	CvString szTextVal;
    	if (!CvInfoBase::read(pXML))
    	{
    		return false;
    	}
    
    	pXML->GetChildXmlValByName(szTextVal, "TechPrereq");
    	m_iTechPrereq = pXML->FindInInfoClass(szTextVal);
    
    	pXML->GetChildXmlValByName(szTextVal, "FreeUnitClass");
    	m_iFreeUnitClass = pXML->FindInInfoClass(szTextVal);
    
    	pXML->GetChildXmlValByName(&m_iNumFreeUnits, "iFreeUnits");
    	pXML->GetChildXmlValByName(&m_iSpreadFactor, "iSpreadFactor");
    
    	return true;
    }
It's just the bare bones of the system. I'll add new tags to it when I get this to work. No need to make it complex before it even works.
 
You need to add it to CvXMLLoadUtilitySet.cpp

First, you need to ask yourself, when should this load, before python, after python (Civ loads 99.9% of XML before python), and what XML files this is dependant on. It looks like this will need to be loaded after the UnitClassInfo is loaded, as you cite them without a ReadPass3.

So in LoadPreMenuGlobals()

Let's explain this call:
Code:
LoadGlobalClassInfo(GC.getTerrainInfo(), "CIV4TerrainInfos", "Terrain", "Civ4TerrainInfos/TerrainInfos/TerrainInfo", false);

The GC.getTerrainInfo is the section of CvInfos to load, the next bit is the name of the XML file, the folder name, the schema info, and the true/false is true if there is a readpass2. So false, in your case.

So just add this line somewhere AFTER the UnitClass's are loaded.:
Code:
LoadGlobalClassInfo(GC.getIdeologyInfo(), "CIV4IdeologyInfos", "Ideology", "Civ4IdeologyInfos/IdeologyInfos/IdeologyInfo", false);

This is assuming you put the XML file in Mod/Assets/XML/Ideology/...


Hopefully that helps, If I'm not clear enough or it doesn't work just post again.
 
To keep things consistent, it would make the most sense for you to put this in the GameInfo folder, instead of creating a new one. Afforess do you know how to reflect this in the GameInfo schema file if he does it that way?
 
To keep things consistent, it would make the most sense for you to put this in the GameInfo folder, instead of creating a new one. Afforess do you know how to reflect this in the GameInfo schema file if he does it that way?

Sure, just mimic how one of those files are layed out in the Schema's.
 
I'm having a similar problem trying to get edited XML files to show up (editing units, correcting textual typos). The files will save, but don't show up after loading; I just get the unedited files... :confused:
 
Now I can compile the DLL without any crashes. But when I start my mod, the game crashes bofore it even starts loading xml. I had to add few things to CvGlobals.h, CvGlobals.cpp and CvEnums.h to get GC.getIdeologyInfo work (not to produce any errors).
Any ideas why would it crash? Is the order important somewhere?
This is completely new to me, so I appoligize my stuppid questions.
 
I'm new at modding the SDK myself, so I apologize if I'm stating the obvious, but did you try doing a clean build of your project? That would definitely be required since you made changes to CvEnums.h.
 
I'm having a similar problem trying to get edited XML files to show up (editing units, correcting textual typos). The files will save, but don't show up after loading; I just get the unedited files... :confused:

You are probably running into the Vista/Win7 security system. Make a copy elsewhere, edit that copy, save, then copy back.

Either that or your game has the old stuff cached and you need to disable caching.
 
Now I can compile the DLL without any crashes. But when I start my mod, the game crashes bofore it even starts loading xml. I had to add few things to CvGlobals.h, CvGlobals.cpp and CvEnums.h to get GC.getIdeologyInfo work (not to produce any errors).
Any ideas why would it crash? Is the order important somewhere?
This is completely new to me, so I appoligize my stuppid questions.

Run a Debug DLL, it will tell you why it crashed;

Also, could you post your CvXMLLoadUlilitySet code? It's hard to diagnose problems without seeing your code.
 
I'm new at modding the SDK myself, so I apologize if I'm stating the obvious, but did you try doing a clean build of your project? That would definitely be required since you made changes to CvEnums.h.
:wallbash: :aargh: Argh, I must be very very stupid. :hammer2:

Now the game starts but I get this error message twice

Also a part of the xml log
Code:
...
[7006.578] Loading XML file xml\GameInfo/Civ4IdeologyInfos.xml
[7012.640] Load XML file xml\GameInfo/Civ4IdeologyInfos.xml FAILED
...
Where do you think the problem might be? And what part of the code you want me to post here?
 
It seems there should be more detailed errors somewhere, but I am not sure where to suggest. I suggest trying smaller files. First, try with an empty file, or just the open/close syntax items. If that fails, then don't bother looking for details in your additional syntax. With a debugger or print statements, try looking at the return codes from the xml parsing subroutines on one other file, to see what the "right answer" is; then compare to the return codes on your file.

If a tiny file passes, then compare the details of your schema to your xml. Even when I am adding new elements to existing schemas, I usually take at least two tries to make sure everything is defined correctly in the schema and used the same way in the xml. Build up one small syntax element at a time to see which one is wrong.
 
Your schema is probably bad, that's what the error generally means.
 
It seems there should be more detailed errors somewhere, but I am not sure where to suggest. I suggest trying smaller files. First, try with an empty file, or just the open/close syntax items. If that fails, then don't bother looking for details in your additional syntax. With a debugger or print statements, try looking at the return codes from the xml parsing subroutines on one other file, to see what the "right answer" is; then compare to the return codes on your file.
I removed everything from both schema and xml files, but it still crashes. But I don't understand what you say in bold. :confused:
Your schema is probably bad, that's what the error generally means.
I haven't played much with the schemas. Any idea what seems to be wrong?

CIV4IdeologySchema.xml
Spoiler :
Code:
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Alex Mantzaris (Firaxis Games) -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- Ideology Schema -->
<Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">
	<ElementType name="Type" content="textOnly"/>
	<ElementType name="Description" content="textOnly"/>
	<ElementType name="Civilopedia" content="textOnly"/>
	<ElementType name="Button" content="textOnly"/>
	<ElementType name="TechPrereq" content="textOnly"/>
	<ElementType name="FreeUnitClass" content="textOnly"/>
	<ElementType name="iFreeUnits" content="textOnly" dt:type="int"/>
	<ElementType name="iSpreadFactor" content="textOnly" dt:type="int"/>
	<ElementType name="iOrderPriority" content="textOnly" dt:type="int"/>
	<ElementType name="IdeologyInfo" content="eltOnly">
		<element type="Type"/>
		<element type="Description"/>
		<element type="Civilopedia"/>
		<element type="Button"/>
		<element type="TechPrereq"/>
		<element type="FreeUnitClass"/>
		<element type="iFreeUnits"/>
		<element type="iSpreadFactor"/>
		<element type="iOrderPriority" minOccurs="0"/>
	</ElementType>
	<ElementType name="IdeologyInfos" content="eltOnly">
		<element type="IdeologyInfo" maxOccurs="*"/>
	</ElementType>
	<ElementType name="Civ4IdeologyInfo" content="eltOnly">
		<element type="IdeologyInfos"/>
	</ElementType>
</Schema>
CIV4IdeologyInfo.xml
Spoiler :
Code:
<?xml version="1.0"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Alex Mantzaris (Firaxis Games) -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- Ideology -->
<Civ4IdeologyInfo xmlns="x-schema:CIV4IdeologySchema.xml">
	<IdeologyInfos>
		<IdeologyInfo>
			<Type>IDEOLOGY_DEMOCRACY</Type>
			<Description>Democracy</Description>
			<Civilopedia>democracy_pedia</Civilopedia>
			<Button>Art/Interface/Buttons/Religions/Jewish.dds</Button>
			<TechPrereq>NONE</TechPrereq>
			<FreeUnitClass>NONE</FreeUnitClass>
			<iFreeUnits>0</iFreeUnits>
			<iSpreadFactor>100</iSpreadFactor>
		</IdeologyInfo>
	</IdeologyInfos>
</Civ4IdeologyInfo>

BTW, I noticed that the second error message isn't the same as the first.
First

Second

Could that give any hints?
 
Try this schema:

Code:
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Alex Mantzaris (Firaxis Games) -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- Ideology Schema -->
<Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">
	<ElementType name="Type" content="textOnly"/>
	<ElementType name="Description" content="textOnly"/>
	<ElementType name="Civilopedia" content="textOnly"/>
	<ElementType name="Button" content="textOnly"/>
	<ElementType name="TechPrereq" content="textOnly"/>
	<ElementType name="FreeUnitClass" content="textOnly"/>
	<ElementType name="iFreeUnits" content="textOnly" dt:type="int"/>
	<ElementType name="iSpreadFactor" content="textOnly" dt:type="int"/>
	<ElementType name="iOrderPriority" content="textOnly" dt:type="int"/>
	<ElementType name="IdeologyInfo" content="eltOnly">
		<element type="Type" minOccurs="0"/>
		<element type="Description" minOccurs="0"/>
		<element type="Civilopedia" minOccurs="0"/>
		<element type="Button" minOccurs="0"/>
		<element type="TechPrereq" minOccurs="0"/>
		<element type="FreeUnitClass" minOccurs="0"/>
		<element type="iFreeUnits" minOccurs="0"/>
		<element type="iSpreadFactor" minOccurs="0"/>
		<element type="iOrderPriority" minOccurs="0"/>
	</ElementType>
	<ElementType name="IdeologyInfos" content="eltOnly">
		<element type="IdeologyInfo" maxOccurs="*"/>
	</ElementType>
	<ElementType name="Civ4IdeologyInfo" content="eltOnly">
		<element type="IdeologyInfos"/>
	</ElementType>
</Schema>
 
You are probably running into the Vista/Win7 security system. Make a copy elsewhere, edit that copy, save, then copy back.

Either that or your game has the old stuff cached and you need to disable caching.

Thx, I'll try that. (BTW, the textual corrections did show up after reloading, my unit editing didn't. So it's not Vista related - I don't use Win7.)
 
No, I still get the same error. Does it mean that the xml loading in DLL isn't working?

Nope, it means your schema is still bad. Those errors are typical schema formatting errors, I know, I get them all the time. :p
(If your XML file wasn't loading, you'd get a vastly different error, something like "Failed to Allocate Memory in CvXMLLoadUtility"...)

I'd go through very slowly and make sure everything matches what another files looks like.

If that doesn't work, remove everything but one element in IdeologyInfo and check if it can load.
 
:lol: I removed every single tag from IdeologyInfo
Code:
<Civ4IdeologyInfo xmlns="x-schema:CIV4IdeologySchema.xml">
	<IdeologyInfos>
		<IdeologyInfo>
		</IdeologyInfo>
	</IdeologyInfos>
</Civ4IdeologyInfo>
and when startting the game, it automatically starts with fullscreen even thought I have defined it to ask it in CivilizatioINI. I looked at the editing date and time, and the game had rewritten the INI file itself.
But it seems, it won't work even if I remove all but one tag and the structure seems to match. Any other ideas how to track it down?

EDIT: I removed few lines from schema, to get a different type of error about what the schema would expect to be next, but I got the same error. Could this mean I haven't made the ideologyInfo xml loading corectly and it crashes before even loading anything? So the problem would not be in my xml but DLL.
 
:lol: I removed every single tag from IdeologyInfo
Code:
<Civ4IdeologyInfo xmlns="x-schema:CIV4IdeologySchema.xml">
	<IdeologyInfos>
		<IdeologyInfo>
		</IdeologyInfo>
	</IdeologyInfos>
</Civ4IdeologyInfo>
and when startting the game, it automatically starts with fullscreen even thought I have defined it to ask it in CivilizatioINI. I looked at the editing date and time, and the game had rewritten the INI file itself.
But it seems, it won't work even if I remove all but one tag and the structure seems to match. Any other ideas how to track it down?

EDIT: I removed few lines from schema, to get a different type of error about what the schema would expect to be next, but I got the same error. Could this mean I haven't made the ideologyInfo xml loading corectly and it crashes before even loading anything? So the problem would not be in my xml but DLL.

As I said earlier; build a debug dll and find out. ;)
 
As I said earlier; build a debug dll and find out. ;)

Okay, now I have tried to find the cause by taking tags out of it, removing tags from IdeologyInfos, changed ideologyInfos to use GameInfosSchema, built a debug dll, rebuilt the whole DLL and attached VC++ to BTS, but I haven't found anything. This is getting frustrating, but does anyone have other ideas? I think i have tested all suggested.
 
Top Bottom