Debugging Help (mod mergers)

Ha, nevermind, I just completely broke it. I forgot to add <load mod="Revolution"/> to init.xml, and the moment I did I lost my interface. So many python exceptions, I don't even know where to start... It did all start with getMaxScoreLines though, which makes sense, I wondered about this and ScoreShowCivName, since they are nowhere to be found in Revolution.ini
 
Yeah, put it there. Things are broke though, like it says above. No interface, and swarms of python errors :s
 
Code:
Traceback (most recent call last):
  File "BugConfig", line 99, in unknown_starttag
  File "BugConfig", line 330, in startChild
  File "BugConfig", line 289, in start
  File "BugConfig", line 309, in flatten
ConfigError: Element <options> requires attribute 'id'
Traceback (most recent call last):
  File "BugConfig", line 110, in unknown_endtag
  File "BugConfig", line 334, in endChild
  File "BugConfig", line 337, in end
  File "BugConfig", line 318, in process
  File "BugOptions", line 1375, in handle
  File "BugOptions", line 1332, in createOption
  File "BugOptions", line 1040, in __init__
  File "BugOptions", line 706, in __init__
ConfigError: Invalid option type: init
Traceback (most recent call last):
  File "BugConfig", line 99, in unknown_starttag
  File "BugConfig", line 326, in startChild
ConfigError: Element <mod> does not accept child <section>
Traceback (most recent call last):
  File "BugConfig", line 110, in unknown_endtag
  File "BugConfig", line 334, in endChild
  File "BugConfig", line 337, in end
  File "BugConfig", line 318, in process
  File "BugOptions", line 1375, in handle
  File "BugOptions", line 1330, in createOption
  File "BugOptions", line 1120, in __init__
  File "BugOptions", line 1075, in __init__
AttributeError: 'NoneType' object has no attribute 'addOption'
Traceback (most recent call last):
  File "BugConfig", line 99, in unknown_starttag
  File "BugConfig", line 326, in startChild
ConfigError: Element <None> does not accept child <section>
Traceback (most recent call last):
  File "BugConfig", line 99, in unknown_starttag
  File "BugConfig", line 326, in startChild
ConfigError: Element <None> does not accept child <option>
Traceback (most recent call last):
  File "BugConfig", line 77, in parse
  File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 171, in feed
  File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 268, in goahead
  File "BugConfig", line 119, in handle_data
AttributeError: 'NoneType' object has no attribute 'addText'
Traceback (most recent call last):
  File "BugConfig", line 110, in unknown_endtag
  File "BugConfig", line 334, in endChild
  File "BugConfig", line 337, in end
  File "BugConfig", line 318, in process
  File "BugConfig", line 409, in handle
  File "BugInit", line 69, in loadMod
  File "BugConfig", line 77, in parse
  File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 171, in feed
  File "e:/main/civilization4/warlords/assets/python/system\xmllib.py", line 268, in goahead
  File "BugConfig", line 119, in handle_data
AttributeError: 'NoneType' object has no attribute 'addText'
Traceback (most recent call last):
  File "BugEventManager", line 356, in _handleDefaultEvent
  File "RevolutionInit", line 141, in onGameLoad
  File "Tester", line 35, in __init__
  File "BugCore", line 139, in __getattr__
AttributeError: getboolean
Traceback (most recent call last):

  File "CvAppInterface", line 79, in preGameStart

  File "CvScreensInterface", line 72, in showMainInterface

  File "CvMainInterface", line 2338, in interfaceScreen

  File "CvMainInterface", line 2250, in initState

  File "BugCore", line 139, in __getattr__

AttributeError: getMaxScoreLines
ERR: Python function preGameStart failed, module CvAppInterface
 
All happened when I added Load Revolution to the init.xml file. Before that things ran fine, except the custom RevOptions pop up window just warned me that Revolution.ini was not found.
 
Writnig this on an iPhone, so I'll be brief.

The first error says you are missing the ID attribute on the <options> element. The second say that you have either closed that element early, like <options .../> or you have the <section> element in the wrong place.

Compare your XML file with any of BUG's or the example in the docs.
 
It also looks like you have one <option> specifying a TYPE of "init" which should be "int". If you post your Revolution.xml file I can help you get it straight.

There's also a call to getboolean() left somewhere; you've changed to using the BUG option, but you left in getboolean() instead of using the option's ID to access it.

Oh yeah, you can use "is<ID>" for boolean type options to make the code read nicer, but "get<ID>" should still work:

Code:
if RevOpt.isEnabled():
 
Well double checked everything, lots of extra config stuff in the Revolution Python folders which I needed to change. Still no interface though with lots of python errors. Uploading the original files, the modified files, and the python errors logs. Hoping you can take a look at it and let me know what I've done wrong.
 
There were just a couple errors--the ones I pointed out twice above. ;) Also, I don't see the first two options that aren't in a section in the INI file, so I moved them to be under the Revolution section. I don't remember now if they'll work outside a section (possibly), but this should work now.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
	Revolution Mod Configuration
-->
<mod id="Revolution">
	<options id="Revolution" file="Revolution.ini">
		<section id="RevConfig">
			<option id="FoundConfig" type="boolean" default="True"/>
			<option id="ActivePopup" type="boolean" default="True"/>
			<option id="RevConfigDebugMode" key="DebugMode" type="boolean" default="True"/>
		</section>
		<section id="BarbarianCiv">
			<option id="BarbCivDebugMode" key="DebugMode" type="boolean" default="True"/>
			<option id="AnnounceBarbSettle" type="boolean" default="True"/>
			<option id="UsePopup" type="boolean" default="True"/>
			<option id="OnlyNotifyNearbyPlayers" type="boolean" default="True"/>
			<option id="BlockPopupInAuto" type="boolean" default="True"/>
			<option id="NewWorldPolicy" type="int" default="0"/>
			<option id="MinorHalfLife" type="int" default="10"/>
			<option id="FierceNatives" type="boolean" default="False"/>
			<option id="OfferControl" type="boolean" default="False"/>
			<option id="CancelAutoForOffer" type="boolean" default="True"/>
			<option id="BarbCivsByStyle" type="boolean" default="True"/>
			<option id="BarbCivMaxCivs" key="MaxCivs" type="int" default="-1"/>
			<option id="FormMinorModifier" type="float" default="1.00"/>
			<option id="MinPopulation" type="int" default="3"/>
			<option id="MinContacts" type="int" default="1"/>
			<option id="MinFullContacts" type="int" default="1"/>
			<option id="BaseMilitaryOdds" type="float" default="0.50"/>
			<option id="BarbTechFrac" type="float" default="0.65"/>
			<option id="NewWorldReduction" type="float" default="0.12"/>
			<option id="NewWorldErasBehind" type="int" default="1"/>
			<option id="BuilderBonusTechs" type="int" default="3"/>
			<option id="MilitaryWindow" type="int" default="35"/>
			<option id="WarCloseDist" type="int" default="21"/>
			<option id="MilitaryStrength" type="float" default="1.0"/>
		</section>
		<section id="Revolution">
			<option id="MaxScoreLines" type="int" default="-1"/>
			<option id="ScoreShowCivName" type="boolean" default="True"/>
			<option id="RevDebugMode" key="DebugMode" type="boolean" default="True"/>
			<option id="ShowDebugMessages" type="boolean" default="False"/>
			<option id="ShowRevIndexInPopup" type="boolean" default="True"/>
			<option id="CenterPopups" type="boolean" default="False"/>
			<option id="StopAutoForRevolt" type="boolean" default="False"/>
			<option id="ReinstateOnRevolt" type="boolean" default="True"/>
			<option id="OfferDefectToRevs" type="boolean" default="True"/>
			<option id="RebelTypes" type="boolean" default="True"/>
			<option id="ArtStyleTypes" type="boolean" default="True"/>
			<option id="AllowAssimilation" type="boolean" default="True"/>
			<option id="AllowSmallBarbRevs" type="boolean" default="True"/>
			<option id="AllowBreakVassal" type="boolean" default="True"/>
			<option id="CulturalRevolution" type="boolean" default="True"/>
			<option id="ReligiousRevolution" type="boolean" default="True"/>
			<option id="CivicRevolution" type="boolean" default="True"/>
			<option id="LeaderRevolution" type="boolean" default="True"/>
			<option id="HumanLeaderRevolution" type="boolean" default="True"/>
			<option id="EndWarsOnDeath" type="boolean" default="True"/>
			<option id="MaxNationality" type="int" default="45"/>
			<option id="CloseRadius" type="int" default="8"/>
			<option id="AllowStateReligionToJoin" type="boolean" default="True"/>
			<option id="IndexModifier" type="float" default="1.0"/>
			<option id="IndexOffset" type="float" default="0"/>
			<option id="HumanIndexModifier" type="float" default="1.0"/>
			<option id="HumanIndexOffset" type="float" default="0"/>
			<option id="ChanceModifier" type="float" default="1.0"/>
			<option id="StrengthModifier" type="float" default="1.0"/>
			<option id="ReinforcementModifier" type="float" default="1.0"/>
			<option id="HappinessModifier" type="float" default="1.0"/>
			<option id="ColonyModifier" type="float" default="1.0"/>
			<option id="DistanceToCapitalModifier" type="float" default="1.0"/>
			<option id="CultureRateModifier" type="float" default="1.0"/>
			<option id="NationalityModifier" type="float" default="1.0"/>
			<option id="GarrisonModifier" type="float" default="3.0"/>
			<option id="ReligionModifier" type="float" default="1.0"/>
			<option id="CivSizeModifier" type="float" default="1.0"/>
			<option id="CityLostModifier" type="float" default="1.0"/>
			<option id="CityAcquiredModifier" type="float" default="1.0"/>
			<option id="CivicsOdds" type="int" default="0"/>
			<option id="ReligionOdds" type="int" default="0"/>
			<option id="LeaderOdds" type="int" default="0"/>
			<option id="CrusadeOdds" type="int" default="0"/>
			<option id="IndependenceOdds" type="int" default="0"/>
			<option id="HumanWarnFrac" type="float" default="0.9"/>
			<option id="WarnTurns" type="int" default="15"/>
			<option id="WarWearinessMod" type="float" default="1.0"/>
			<option id="RevMaxCivs" key="MaxCivs" type="int" default="-1"/>
			<option id="TurnsBetweenRevs" type="int" default="8"/>
			<option id="DeniedRevs" type="int" default="5"/>
			<option id="AcceptedTurns" type="int" default="10"/>
			<option id="AcquiredTurns" type="int" default="10"/>
			<option id="BuyoffTurns" type="int" default="10"/>
			<option id="BaseReinforcementTurns" type="int" default="3"/>
			<option id="MinReinforcementTurns" type="int" default="1"/>
			<option id="RevRevCultureModifier" key="RevCultureModifier" type="float" default="1.0"/>
			<option id="AlwaysViolentThreshold" type="int" default="1700"/>
			<option id="InstigateRevolutionThreshold" type="int" default="1000"/>
			<option id="JoinRevolutionFrac" type="float" default="0.6"/>
			<option id="BadLocalThreshold" type="int" default="8"/>
			<option id="DeniedTurns" type="int" default="5"/>
		</section>
		<section id="AIAutoPlay">
			<option id="AIAutoPlayEnable" key="Enable" type="boolean" default="True"/>
			<option id="AIAutoPlayDebugMode" key="DebugMode" type="boolean" default="False"/>
			<option id="BlockPopups" type="boolean" default="True"/>
			<option id="SaveAllDeaths" type="boolean" default="True"/>
			<option id="ShowNewLeaderPopup" type="boolean" default="False"/>
			<option id="Refortify" type="boolean" default="True"/>
		</section>
		<section id="ChangePlayer">
			<option id="ChangePlayerEnable" key="Enable" type="boolean" default="True"/>
			<option id="ChangePlayerDebugMode" key="DebugMode" type="boolean" default="False"/>
		</section>
		<section id="TechDiffusion">
			<option id="TechDifDebugMode" key="DebugMode" type="boolean" default="False"/>
			<option id="MinTechsBehind" type="int" default="5"/>
			<option id="FullEffectTechsBehind" type="int" default="8"/>
			<option id="BonusTechsBehind" type="int" default="12"/>
			<option id="TechDifRevCultureModifier" key="RevCultureModifier" type="float" default="1.0"/>
			<option id="DiffusionMod" type="float" default="1.0"/>
		</section>
		<section id="DynamicCivNames">
			<option id="DynamicNamesDebugMode" key="DebugMode" type="boolean" default="True"/>
			<option id="TeamNaming" type="boolean" default="True"/>
			<option id="LeaveHumanPlayerName" type="boolean" default="False"/>
		</section>
	</options>
</mod>
 
Thanks EF, almost got it now. It loads up, and the values are loading correctly (it's not going on the "default" set ups, it's using the values in XML). However it's still telling me "Warning Revolution.ini not found" in the RevDCM pop up. I'm not sure where this check is that's causing this and can't find it. The only reference to Revolution.ini I can find in the python files I changed was in the BugEventManager file, also the code there I wasn't sure what I should change it to, it just doesn't look right. Any ideas (could this file even be the cause of the warning?)?

Edit:
I've found where this is occuring, but don't know how to fix it:
In RevolutionInit.py:
Code:
		if( not self.bFoundConfig ) :
			popup = PyPopup.PyPopup( )
			bodStr = "WARNING:  " + self.RevOptFileName + " not found!  Revolution components using default settings."
			bodStr += "  Check mod installation directory, should be:\n\n" + BugPath.getModDir()
			bodStr += self.getRevComponentsText()
			popup.setBodyString( bodStr )
			popup.launch()

Also I'm not sure what to do about the code in BugEventManager.py that references Revolution.ini

Other then these two things though, I think it's working.
 
Remove the bFoundConfig variable, the FoundConfig <option>, and that code block you posted. If the Revolution.ini file isn't present, it is created with the defaults in the XML file, so there's no possibility it isn't found (sorta, they could remove the UserSettings folder).

As for BugEventManager, take a fresh copy from BUG. The code in there is designed to initialize Revolutions with the event manager so it can add its event handlers. This is better done in the XML file. At the end, before the closing </mod> tag, add this:

Code:
    ...
    </options>

    [B][COLOR="DarkOrange"]<events module="RevolutionInit" function="RevolutionInit"/>[/COLOR][/B]
</mod>

Finally, in RevolutionInit.py, modify the __init__() function slightly. Remove all references to RevOptFileName:

Code:
class RevolutionInit :

	def __init__( self, customEM[s], RevOptFileName = None[/s] ) :
		
		CvUtil.pyPrint("Initializing Revolution Mod")

		self.EventKeyDown = 6
		self.customEM = customEM
		[s]self.RevOptFileName = RevOptFileName[/s]
		self.RevOpt = RevOpt

The only other reference to it is in the block of code you posted which you should remove.
 
I get python exceptions when I try the above. Everything still looks like it's working though (I need to play through and make sure Revolutions, and barbarian civ settling still occurs though since reverting to BUG's BugEventManager file removed all the RevDCM code in it). Here are the python errors:

Code:
Traceback (most recent call last):
  File "BugEventManager", line 349, in _handleDefaultEvent
  File "RevolutionInit", line 107, in onGameLoad
AttributeError: 'bool' object has no attribute 'removeEventHandlers'
 
Somehow one of those event manager objects stored in all those FooInst variables is being set to a boolean value (True/False) and later being told to remove its event handlers.

I didn't see any other extra code in BugEventManager, but it wouldn't hurt to diff it against the one from Revolutions to make sure only those two sections are extra.
 
Winmerge only shows this code being different:

Code:
# --------- Revolution mod (1/2) -------------
import CvConfigParser
import RevolutionInit
# --------------------------------------------
...

		# --------- Revolution mod (2/2) -------------
		revConfigFile = "Revolution.ini"
		RevolutionInit.RevolutionInit( self, revConfigFile )
		# --------------------------------------------

Also the variable revConfigFile is never referenced again as far as I can tell (notepad++ doesn't find it in the python files anywhere).
 
Good, that's a safe removal then. You'll have to dig into the Revolution modules to figure out how some event manager is set to True/False.
 
To be honest I don't really know what that means. What should I be looking for?
 
That error is the first thing that happens when I load up a saved game, or start a new one. Also a typical bug error message comes up on the top of the screen, saying something about RevolutionInit (looks similar to the error messages one gets from Vista if you don't launch as an admin when the UserSettings folder is in the Program Files path). The exception does not fire when starting a new turn, just on the initial loading of the game.

That's also the only error in the PythonError log file.
 
Can you post the PythonDbg.log file as well? It will contain that error message appearing on-screen.
 
Top Bottom