Modmodding Q&A Thread

Is there a way in the C++ editor to automatically debug for the XML file?
 
What do you mean with debugging? XML isn't a programming language.

Most editors have syntax highlighting and can detect if tags aren't closed and the like, though.
 
I also found an error in the Python, but I don't understand it. I ran WinMerge and it is the exact same as regular DoC.

I can't upload Python or log files, so I put them onto text documents.
 

Attachments

It seems that there are too many brackets in the tuple beginning in line 1647.
 
I've tried every combination, but it doesn't work any way. Did you take a look at the consts file?
 
Yes. Pretty sure there's an opening bracket too many. Compare equivalent tuples below.
 
There are three in both this one and DoC. When I try to remove a bracket from the line below, it says ")) invalid syntax". If I remove one at the top and bottom, it says "tuple invalid syntax".
 
Sorry about the double post, but I found that I missed a few commas in that section, so that's what caused the problem. Now I have a new problem:

Code:
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "<string>", line 52, in load_module
  File "CvEventInterface", line 13, in ?
  File "<string>", line 52, in load_module
  File "CvRFCEventManager", line 12, in ?
  File "<string>", line 52, in load_module
  File "CvRFCEventHandler", line 7, in ?
  File "<string>", line 52, in load_module
  File "RiseAndFall", line 214, in ?
  File "RiseAndFall", line 636, in RiseAndFall
NameError
: 
name 'self' is not defined

Failed to load python module CvEventInterface.
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface
ERR: Call function onEvent failed. Can't find module CvEventInterface

When I looked, I found nothing out of the ordinary/wrong. What's the problem?

Also, can XML problems be caused by Python problems or not? Lastly, can there be problems in a successfully loaded XML file that causes problems in other file?

Thanks,

mrrandomplayer
 
We're likely on different versions of that file already, can you quote the relevant parts of RiseAndFall.py?

If an XML file has been loaded successfully, it cannot contain any errors itself, but if something is missing there that is used in other files, it can still cause these errors.
 
I updated to the new SVN, merged stuff over, and got this:
Code:
Allocating zero or less memory in CvXMLLoadUtility::SetVariableListTagPair
for everything. I have no idea what this means. Do you?

Interestingly enough, I got this:
Code:
Tag: BUILDING_CHRISTIAN_SHRINE in Info class was incorrect
This does this for every shrine, every monestary, every Academy, and every Military Academy, and once for Interpol, then for every building

The GP buildings came up once for every nationality, then every other building came up once. The weird thing is that for the GP buildings and Monasteries, they were listed under units. Is this because they create/require the building?
 
It seems you still have syntax errors in your XML files (which theoretically could come from selectively updating either only the schema or the info file, though I doubt that).

If there is an error in your Buildings XML (for instance), the error could only show up in consequently loaded XML files. If BUILDING_CHRISTIAN_SHRINE is reported, then it's either that building or the one immediately preceding it.
 
In my Dawn of Man screen, I based my code on the code that handles the dawn of man texts. It works fine, but there is a small problem. I make use of the consts.py. Because of that, it's not really modular. But if I can move the code from the consts.py to the DawnOfMan.py, it will be available for every version. (Regular download and SVN)

So this is the part I include in the consts.py:
Spoiler :
Code:
dawnOfManArt = {
iEgypt		:	"ART_DOM_EGYPT",
iIndia		:	"ART_DOM_INDIA",
iChina		:	"ART_DOM_CHINA",
iBabylonia	:	"ART_DOM_BABYLONIA",
iGreece		:	"ART_DOM_GREECE",
iCarthage	:	"ART_DOM_PHOENICIA",
iPersia		:	"ART_DOM_PERSIA",
iRome		:	"ART_DOM_ROME",
iTamils		:	"ART_DOM_TAMILS",
iEthiopia	:	"ART_DOM_ETHIOPIA",
iJapan		:	"ART_DOM_JAPAN",
iKorea		:	"ART_DOM_KOREA",
iMaya		:	"ART_DOM_MAYA",
iByzantium	:	"ART_DOM_BYZANTIUM",
iVikings	:	"ART_DOM_VIKINGS",
iArabia		:	"ART_DOM_ARABIA",
iTibet		:	"ART_DOM_TIBET",
iMoors		:	"ART_DOM_MOORS",
iIndonesia	:	"ART_DOM_INDONESIA",
iKhmer		:	"ART_DOM_KHMER",
iSpain		:	"ART_DOM_SPAIN",
iFrance		:	"ART_DOM_FRANCE",
iEngland	:	"ART_DOM_ENGLAND",
iHolyRome	:	"ART_DOM_HOLY_ROME",
iRussia		:	"ART_DOM_RUSSIA",
iMali		:	"ART_DOM_MALI",
iPoland		:	"ART_DOM_POLAND",
iItaly		:	"ART_DOM_ITALY",
iPortugal	:	"ART_DOM_PORTUGAL",
iInca		:	"ART_DOM_INCA",
iAztecs		:	"ART_DOM_AZTECS",
iMongolia	:	"ART_DOM_MONGOLIA",
iMughals	:	"ART_DOM_MUGHALS",
iTurkey		:	"ART_DOM_TURKEY",
iThailand	:	"ART_DOM_THAILAND",
iCongo		:	"ART_DOM_CONGO",
iNetherlands	:	"ART_DOM_NETHERLANDS",
iGermany	:	"ART_DOM_GERMANY",
iAmerica	:	"ART_DOM_AMERICA",
iArgentina	:	"ART_DOM_ARGENTINA",
iBrazil		:	"ART_DOM_BRAZIL",
}
And this is the code in the cvDawnOfMan.py:
Spoiler :
Code:
		pActivePlayer = gc.getPlayer(CyGame().getActivePlayer())
		iActivePlayer = CyGame().getActivePlayer()			
		artKey = con.dawnOfManArt[iActivePlayer]	
		screen.addDDSGFC("Civilization Image", ArtFileMgr.getInterfaceArtInfo([COLOR="Blue"]artKey[/COLOR]).getPath(), self.X_TEXT_PANEL, self.Y_TEXT_PANEL, self.W_TEXT_PANEL, self.H_TEXT_PANEL, WidgetTypes.WIDGET_GENERAL, -1, -1 )
As you can see, the code is exactly the same as the Dawn of Man text code.
So, how can I move the code from the consts.py to the other file. Or is that not possible at all?
 
You should be able to simply cut and paste the whole dict into CvDawnOfMan.py. The only other thing to do is renaming the variables to refer to Consts, i.e. iEgypt becomes con.iEgypt and so on.
 
You should be able to simply cut and paste the whole dict into CvDawnOfMan.py. The only other thing to do is renaming the variables to refer to Consts, i.e. iEgypt becomes con.iEgypt and so on.

There is where it went wrong. I did copy it, but I forgot to change iEgypt in con.iEgypt. So it didn't work.
 
So did you try it with the changed variables?
 
Alright, good to know.
 
Maybe the problem is in the GlobalDefinesAlt? I added something in (red is the new code):
Spoiler :
Code:
<?xml version="1.0"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by Tim McCracken (Firaxis Games) -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- Global Defines -->
<Civ4Defines xmlns="x-schema:CIV4GlobalDefinesSchema.xml">
	<Define>
		<!-- edead: change this to 0 if you want autosaves work during AI autoplay for some reason -->
		<DefineName>NO_AUTOSAVE_DURING_AUTOPLAY</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<!-- Leoreth: if set to 1, UHV goals are not checked for AI civilizations so they can never complete them (increases speed)
		      set to 0 to reenable them -->
	<Define>
		<DefineName>NO_AI_UHV_CHECKS</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>AI_SLAVE_VALUE</DefineName>
		<iDefineIntVal>100</iDefineIntVal>
	</Define>
	<!--
		Leoreth: define how often these optional civs should appear
			value=0	Civilization never appears
			value>0	Civilization roughly appears in every i-th game, where i is the entered value
				(so to make this civilization appear every time, enter 1)
		Note that if certain civilizations are controlled by the player, these civs will spawn regardless to provide a historical opponent
	-->
	<Define>
		<DefineName>PLAYER_OCCURENCE_TAMILS</DefineName>
		<iDefineIntVal>1</iDefineIntVal>			<!-- default: 1 -->
	</Define>
	<Define>
		<DefineName>PLAYER_OCCURENCE_TIBET</DefineName>
		<iDefineIntVal>1</iDefineIntVal>			<!-- default: 1 -->
	</Define>
	<Define>
		<DefineName>PLAYER_OCCURENCE_MOORS</DefineName>
		<iDefineIntVal>1</iDefineIntVal>			<!-- default: 1 -->
	</Define>
	<Define>
		<DefineName>PLAYER_OCCURENCE_POLAND</DefineName>
		<iDefineIntVal>1</iDefineIntVal>			<!-- default: 1 -->
	</Define>
	<Define>
		<DefineName>PLAYER_OCCURENCE_CONGO</DefineName>
		<iDefineIntVal>1</iDefineIntVal>			<!-- default: 1 -->
	</Define>
	<Define>
		<DefineName>PLAYER_OCCURENCE_ARGENTINA</DefineName>
		<iDefineIntVal>1</iDefineIntVal>			<!-- default: 1 -->
	</Define>
	<Define>
		<DefineName>PLAYER_OCCURENCE_BRAZIL</DefineName>
		<iDefineIntVal>1</iDefineIntVal>			<!-- default: 1 -->
	</Define>
	
	<!-- Disable the respawn by setting the value to 0 -->
	<Define>
		<DefineName>PLAYER_REBIRTH_MEXICO</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	<Define>
		<DefineName>PLAYER_REBIRTH_COLOMBIA</DefineName>
		<iDefineIntVal>1</iDefineIntVal>
	</Define>
	[B][COLOR="Red"]<Define>
                <DefineName>PLAYER_REBIRTH_VENICE</DefineName>
                <iDefineIntVal>1</iDefineIntVal>
        </Define>
[/COLOR][/B]
<!--
	BULL User Settings
	
	This file is used only when BULL is running without BUG, but it will cause no harm to include it with BUG.

	Copyright (c) 2009 The BUG Mod.
-->
etc etc etc

Did I need to define the new thing somewhere?
 
Nope, you've just defined it right there. Everything looks okay to me.
 
EVERYTHING IS WORKING NOW except for this:

Code:
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "<string>", line 52, in load_module
  File "CvEventInterface", line 13, in ?
  File "<string>", line 52, in load_module
  File "CvRFCEventManager", line 12, in ?
  File "<string>", line 52, in load_module
  File "CvRFCEventHandler", line 7, in ?
  File "<string>", line 35, in load_module
  File "<string>", line 13, in _get_code
  File "RiseAndFall", line 3182
    utils.makeUnit(con.iWarrior, iCiv, tPlot, 2)
    ^
SyntaxError: invalid syntax
 
Back
Top Bottom