Bug Reporting

leave it with me - I think I have the code mostly there.
 
Following up on the Autolog question.

I tested it again by unchecking Silent & Autolog and that did the trick. Thanks again for your help Ruff. :goodjob:
 
Hm...that's odd. I tested it again and no log appears. Yet I'm 100% sure i had this happen before. Never mind, issue solved then... sorry ruff ! :)

Edfit: How do I get rev 606 ? I've downloaded the svn files, but those were the option files with the -a appendix. Renaming and copying them to my Customassets folder left me with no game interface. I reverted and it again says 603...
 
·Imhotep·;6724492 said:
Edfit: How do I get rev 606 ? I've downloaded the svn files, but those were the option files with the -a appendix. Renaming and copying them to my Customassets folder left me with no game interface. I reverted and it again says 603...
The '-a' files was an attempt by me to get our BUG option screens multi-language. It didn't work but (as per usual), I didn't know what was wrong. I uploaded the files hoping that EmpFool could fix my error.

You shouldn't use them if you want BUG to actually work.
 
History: The original logger didn't have the 'silent' option. When you started or loaded a game, a dialog popped up while the game was loading asking you to put in a file name. If you were too slow - it didn't log. For this reason, I put in the Alt-L command that popped up the said dialog box. However, I started to play some games and forgot to start the logger. :mad: Thus I put in the silent option (auto start the logger with a pre-defined name). And also introduced the convoluted way of not logging (uncheck enable AND silent).

Revision 607 of BUG
(just updated) now has an internal 'isLoggingOn' flag which says is logging is on or not. Here are your options:

You start a game / load a game with logging ENABLED checked ...

  • silent is checked - logger auto starts and logs events
  • silent is not checked - nothing happens, you have to manually start the game with Alt-L ... after Alt-L (and ok), logging starts
  • If you uncheck ENABLED while playing a game, all logging stops
  • if you re-ENABLE logging while playing the same game, I think logging starts

You start a game / load a game with logging ENABLED not checked ...

  • silent is checked - nothing happens
  • silent is not checked - nothing happens
  • you press Alt-L - nothing happens
  • ditto Alt-B and Alt-E
  • If you open the BUG option screen and put a check in ENABLED - NOTHING HAPPENS. The game does not start logging, even if you have 'silent' checked. You have to Alt-L to start the logger (if silent is checked, it looks like nothing happens but it does start logging - confirm with Alt-E)
 
That all sounds perfect. :goodjob:

I'm making a couple tweaks to other stuff right now and am trying to get the options XML stuff working. . . .

Edit: I love Civ. The reason it's not looking up the text/hover correctly is that the translator isn't initialized with the XML until after the BUG options stuff loads. Problem solved.

Next thing will be to get it to load the option lists and labels from XML as well.
 
@ruff:

I've another suggestion for the logger. Can you include an option to write the battle stats always to the log ? Sometimes I forget to hit Alt-B after my turnset, so it would be neat if one could enable that once and for all.

Imhotep
 
·Imhotep·;6726275 said:
I've another suggestion for the logger. Can you include an option to write the battle stats always to the log ? Sometimes I forget to hit Alt-B after my turnset, so it would be neat if one could enable that once and for all.
Can do - but it has to be tied to an event. Any suggestions? Game save would seem obvious but if you have auto save, then you would get a dump every turn.

Here are you options ...
Spoiler game events :

## EVENTLIST
self.EventHandlerMap = {
'mouseEvent' : self.onMouseEvent,
'kbdEvent' : self.onKbdEvent,
'ModNetMessage' : self.onModNetMessage,
'Init' : self.onInit,
'Update' : self.onUpdate,
'UnInit' : self.onUnInit,
'OnSave' : self.onSaveGame,
'OnPreSave' : self.onPreSave,
'OnLoad' : self.onLoadGame,
'GameStart' : self.onGameStart,
'GameEnd' : self.onGameEnd, <-- this is game over (ie victory or defeat)
'plotRevealed' : self.onPlotRevealed,
'plotFeatureRemoved' : self.onPlotFeatureRemoved,
'plotPicked' : self.onPlotPicked,
'nukeExplosion' : self.onNukeExplosion,
'gotoPlotSet' : self.onGotoPlotSet,
'BeginGameTurn' : self.onBeginGameTurn,
'EndGameTurn' : self.onEndGameTurn,
'BeginPlayerTurn' : self.onBeginPlayerTurn,
'EndPlayerTurn' : self.onEndPlayerTurn,
'endTurnReady' : self.onEndTurnReady,
'combatResult' : self.onCombatResult,
'combatLogCalc' : self.onCombatLogCalc,
'combatLogHit' : self.onCombatLogHit,
'improvementBuilt' : self.onImprovementBuilt,
'improvementDestroyed' : self.onImprovementDestroyed,
'routeBuilt' : self.onRouteBuilt,
'firstContact' : self.onFirstContact,
'cityBuilt' : self.onCityBuilt,
'cityRazed' : self.onCityRazed,
'cityAcquired' : self.onCityAcquired,
'cityAcquiredAndKept' : self.onCityAcquiredAndKept,
'cityLost' : self.onCityLost,
'cultureExpansion' : self.onCultureExpansion,
'cityGrowth' : self.onCityGrowth,
'cityDoTurn' : self.onCityDoTurn,
'cityBuildingUnit' : self.onCityBuildingUnit,
'cityBuildingBuilding' : self.onCityBuildingBuilding,
'cityRename' : self.onCityRename,
'cityHurry' : self.onCityHurry,
'selectionGroupPushMission' : self.onSelectionGroupPushMission,
'unitMove' : self.onUnitMove,
'unitSetXY' : self.onUnitSetXY,
'unitCreated' : self.onUnitCreated,
'unitBuilt' : self.onUnitBuilt,
'unitKilled' : self.onUnitKilled,
'unitLost' : self.onUnitLost,
'unitPromoted' : self.onUnitPromoted,
'unitSelected' : self.onUnitSelected,
'UnitRename' : self.onUnitRename,
'unitPillage' : self.onUnitPillage,
'unitSpreadReligionAttempt' : self.onUnitSpreadReligionAttempt,
'unitGifted' : self.onUnitGifted,
'unitBuildImprovement' : self.onUnitBuildImprovement,
'goodyReceived' : self.onGoodyReceived,
'greatPersonBorn' : self.onGreatPersonBorn,
'buildingBuilt' : self.onBuildingBuilt,
'projectBuilt' : self.onProjectBuilt,
'techAcquired' : self.onTechAcquired,
'techSelected' : self.onTechSelected,
'religionFounded' : self.onReligionFounded,
'religionSpread' : self.onReligionSpread,
'religionRemove' : self.onReligionRemove,
'corporationFounded' : self.onCorporationFounded,
'corporationSpread' : self.onCorporationSpread,
'corporationRemove' : self.onCorporationRemove,
'goldenAge' : self.onGoldenAge,
'endGoldenAge' : self.onEndGoldenAge,
'chat' : self.onChat,
'victory' : self.onVictory,
'vassalState' : self.onVassalState,
'changeWar' : self.onChangeWar,
'setPlayerAlive' : self.onSetPlayerAlive,
'playerChangeStateReligion' : self.onPlayerChangeStateReligion,
'playerGoldTrade' : self.onPlayerGoldTrade,
'windowActivation' : self.onWindowActivation,
'gameUpdate' : self.onGameUpdate,


A slightly different tack would be to try and link it with a reminder (ie put check box on reminder to dumb battle starts. The dumbed down version of that would be for you to manually set a reminder to dump the battle stats.
 
Actually none of these events work well for this matter I think. But the link to a reminder sounds fine, as I usually set a reminder for stop playing...
 
Edit: I love Civ. The reason it's not looking up the text/hover correctly is that the translator isn't initialized with the XML until after the BUG options stuff loads. Problem solved.
How? I thought it might be something like that - I dropped my XML tags into other areas (ie BUG Flashing hit about the options screen instead of the 'hit enter') and it worked.
 
The code to create the main interface is executed after the XML loading, but the BUG option loading happens as the Python modules are loaded. When a Python module is loaded (Civ loads all the modules when it starts up), any code outside of classes or functions is executed immediately. This is how BUG initializes the options. But the main interface is defined in a class, and after all the Python and XML is loaded, then Civ initializes the class that creates the screen.

To fix the problem, I do what's called "lazy loading" of the option title/hover text. I set the title and hover of each option to "None" -- a special value in Python that can be assigned to any variable. All the options are created, but none of them have a title or hover. When the options screen is displayed and the titles and hovers are needed, only then are they looked up in the XML, and only once for each.

Code:
class Option(object):
	"Holds the metadata for a single option"

	def __init__(self, name, section, key, default, title, tooltip, dirtyBit=None):
		if (name is not None):
			self.name = name
		else:
			self.name = self.section + "_" + self.key
		self.section = section
		self.key = key
		self.default = default
		
		[b]self.xmlKey = "TXT_KEY_BUG_OPT_" + self.name.upper()[/b]
		[b]self.title = None[/b]
		[b]self.tooltip = None[/b]
		
		self.dirtyBit = dirtyBit

	...

	def getTitle(self):
		[b]if not self.title:
			self.title = localText.getText(self.xmlKey + "_TEXT", ())[/b]
		return self.title

	def getTooltip(self):
		[b]if not self.tooltip:
			self.tooltip = localText.getText(self.xmlKey + "_HOVER", ())[/b]
		return self.tooltip
In the code above, testing a variable for true/false returns false if it is set to the magic value "None". Once it as been assigned a real value from the XML file, it evaluates to true; thus the lookup happens only once, but the key is that it happens at the time it is needed -- long after the XML has been loaded.

I thought of this when I remembered that I had the same trouble when writing the advanced scoreboard code. I was looking up symbols in the XML when the Python module was loaded so it would only happen once, but it was failing to find anything. When you start Civ, you can see that it initializes Python and then XML.

If you want to see it working, just make the changes above to your BugOptions.py file. You can delete all the -a.py files as they aren't needed. The only change is the big XML you created and the above class. Also, notice that I used an abbreviated XML key, so just change it in the code or do a search 'n' replace in the XML. I did this in anticipation of having XML keys for the labels and option lists, but it's not necessary.
 
Cool.:) Did you fix your SVN problems, or would you like me to commit the changes for you?

Wonder if we can get Cam to do some translation work again, or if we're going to have to use google translate.
 
Cool.:) Did you fix your SVN problems, or would you like me to commit the changes for you?

Thanks for the offer. I got it to commit using TortoiseSVN, so it must be the Subclipse plugin for Eclipse that I'm using. It worked before, but I see it's a newer version than what I had used before. I'll have to poke around, but at least I can commit now.
 
I'm getting the Trade Route Base Profit error with BUG . . .

I found the problem while looking at splitting out the XML files. Apparently one of the included mods made some "fixes" to one of the BTS XML files. I've committed the fix as rev. 609, available from SVN now.
 
Your kidding me? After all the time we said it was BTS that was causing the problems? it was one of the mods we added? Great.:p So this is gone now? After almost a year?:p
 
Yeah, it was in the same XML file that had the extra hints. There were some minor changes along with the hints, and one not-so-minor one. Now you can once again marvel at all your 1.00 base trade values. :P
 
Back
Top Bottom