infrequent error

Joined
Jul 5, 2004
Messages
23,562
Location
Canberra, Australia
I have a modular component which gives an error or warning every now and then. It does not stop or change game play it just causes one bit of text to be displayed or not.

The error from PythonDbg.log is:-
Code:
load_module UnitGrouper

08:52:33 WARN : getText - received Unicode key TXT_KEY_UNIT_SLAVE
08:52:33 DEBUG: BugUtil.getText - XML key TXT_KEY_UNIT_SLAVE not found
load_module SevoPediaUtil

The game text file is
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- edited with XMLSPY v2004 rel. 2 U (http://www.xmlspy.com) by XMLSPY 2004 Professional Ed. Release 2, Installed Multi + SMP for 3 users (Firaxis Games) -->
<!-- Sid Meier's Civilization 4 -->
<!-- Copyright Firaxis Games 2005 -->
<!-- -->
<!-- Game Text - New -->
<Civ4GameText xmlns="http://www.firaxis.com">
	<TEXT>
		<Tag>TXT_KEY_UNIT_SLAVE</Tag>
		<English>Slave</English>
		<French>Slave</French>
		<German>Slave</German>
		<Italian>Slave</Italian>
		<Spanish>Slave</Spanish>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_UNIT_SLAVE_PEDIA</Tag>
		<English>[TAB]Slavery is a social-economic system under which certain persons—known as slaves—are deprived of personal freedom and compelled to perform labour or services. The term also refers to the status or condition of those persons who are treated as the property of another person or household. This is referred to as "chattel slavery". Slaves are held against their will from the time of their capture, purchase, or birth, and are deprived of the right to leave, to refuse to work, or to receive compensation in return for their labour. As such, slavery is one form of unfree labour. Although outlawed in nearly all countries today slavery is still secretly practiced in many parts of the world. There are an estimated 27 million victims of slavery worldwide. In Mauritania alone it is estimated that up to 600,000 men, women and children, or 20% of the population, are enslaved, many of them used as bonded labour. Slavery in Mauritania was finally criminalized in August 2007. In Niger, slavery is also a current phenomenon; a Nigerian study has found that more than 800,000 people are still slaves, almost 8% of the population.</English>
	</TEXT>
	<TEXT>
		<Tag>TXT_KEY_UNIT_SLAVE_STRATEGY</Tag>
		<English>Slaves can use their labour as citizens in the city (+1 Production) and also can be converted to warriors ,archers, or workers. </English>
	</TEXT>
</Civ4GameText>

I can't see anything wrong here. Nor can I figure out why it will work fine one time and not the next.
 
The warning pertains to the Python module that is looking up that <Text> entry--not the XML entry itself. Search your Python files for all occurrences of TXT_KEY_UNIT_SLAVE and make sure none are using a unicode string:

Code:
BugUtil.getText([B]u"TXT_KEY_UNIT_SLAVE"[/B])

When BUG issues this warning it attempts to convert the Unicode string to a normal string and uses that to look up the entry. I don't know why it's not finding it after the conversion. You can try to see what's wrong by adding a line in BugUtil:

Code:
if isinstance(key, unicode):
	warn("getText - received Unicode key %s", key)
	key = str(key)
	[B][COLOR="Red"]debug("getText - converted Unicode key to \"%s\"", key)[/COLOR][/B]
 
I searched all the files in the Python folder for TXT_KEY_UNIT_SLAVE and got no matches. I will try adding the line to bug once I get back from (giving) classes ;). Thanks.

Edit: oops. put debug in wrong place
 
It has taken me awhile to get the error again, as I said it is infrequent. This is the result

Code:
load_module UnitGrouper

07:58:34 WARN : getText - received Unicode key TXT_KEY_UNIT_SLAVE
07:58:34 DEBUG: getText - converted Unicode key to "TXT_KEY_UNIT_SLAVE"
07:58:34 DEBUG: BugUtil.getText - XML key TXT_KEY_UNIT_SLAVE not found
load_module SevoPediaUtil

and i have no idea what it means :(
 
It means 2 != 2. :( Okay, change that line you added to this:

Code:
debug("getText - converted Unicode key to \"%s\" with length %d, equal: %r", key, len(key), key == "TXT_KEY_UNIT_SLAVE")

This will hopefully tell us if there are invisible control characters embedded in that string which is the only thing left I can think of. Add it and report back when you see it again.
 
the result is

Code:
load_module UnitGrouper

08:48:02 WARN : getText - received Unicode key TXT_KEY_UNIT_SLAVE
08:48:02 DEBUG: getText - converted Unicode key to "TXT_KEY_UNIT_SLAVE" with length 18, equal: True
08:48:02 DEBUG: BugUtil.getText - XML key TXT_KEY_UNIT_SLAVE not found
load_module SevoPediaUtil

Which means there are no hidden or unprintable characters in it. :( I had thought of this and looked at it in another editor but it was worth a try.
 
Then my guess is that it has unprintable characters in the XML files. This would make sense and cause it to be read as a Unicode string and not to find the <Text> entry, especially if you copied and pasted it from one XML file to the other. I would go to both XML files where it appears and retype it and its enclosing XML tags to make sure you get it completely.

If that doesn't fix it, I dunno what's up. Somehow those XML files are not being read as plain text files.
 
I am looking into it now. I have been tempted to rewrite the whole thing before :). Interestingly enough if I have a python error I get this problem every time but if I don't then I get it infrequently.
 
Damn, you were supposed to say Vista 64 alpha3, Tagalog! I'm out of ideas. Hopefully retyping that stuff in the XML files does the trick.
 
I thought I had done this earlier but looks like I have version control problems again.

The game text file was called CIV4GameText_Slave.xml but I changed it to Slave_CIV4GameText.xml and now the problem has gone away. Or it seems to ;).
 
More likely removing and adding the file anew has fixed whatever was wrong with the file contents. The name of the file shouldn't matter for GameText files. I think BTS loads all XML files in the Text folder(s).
 
We have had problems before which have been fixed by changing the name of the file around so it may be something to do with game text files or WoC or just the weirdness of reality!
 
Top Bottom