Unit Naming

Ok, it's time for a report.
Adv Unit Naming.ini works fine at me, but there is a guy, who have a problem with his file.
After editing and starting a game, no units of him was renamed. All units get civ4 standard name. I've tried to find out the error, but all I had find out was a error message at the beginning of the game.
See the picture below:
Civ4ScreenShot0045.JPG

Then I tested the same with my file without any error message at the beginning.

I've attached the file causes the problem here.
View attachment Adv Unit Naming.zip

I hope, anyone can find out the problem.

Thank you very much!

Best regards,
Dead-Eye


P.S.
How I can get a bigger picture here as attachment instead this thumbnail?
 
The error is about [Custom]Assets/Config/UnitNaming.xml--not the INI file. Can you attach his version of that file?

To post larger pictures, upload them to an image hosting service like ImageShack or PhotoBucket and then use the Insert Image icon above your text when posting to place the [IMG] tag into your post (or just copy and paste it from the hosting site).
 
Tell him to replace all the non-English letters with their XML entities. He can look them up on Google; they look like ˜ and such. When I try opening that file on my work Ubuntu machine, it crashes gedit. I can see it's loading some of the special characters fine, so I can only guess that one or more of them are breaking the INI parser.

I'll try opening it again when I get home to see if there's anything else i can spot. Again, this is only a guess.
 
BINGO!!!!!

That is! I've replaced his INI-file all letters like ä and ü to ae and ue, and now, it works.

It's a little strange, because if there is a default parameter, all axemens are called as "Axtkämpfer" in german. Using the string "Axtkämpfer" in the INI-file cause an error message and Unit Naming will be deacitvated until reload the mod.


I've tested with unicodes instead using non-english letters.
For example:
ANCIENT_AXEMAN = ^cnt[n]^. Axtkämpfer
-> Axemens are named like "1. Axtk" instead "1. Axtkämpfer"

I recommend him to replace all non-english letters for a while (maybe forever).
 
Oh, my post didn't come through correctly. I was saying you should be able to (test one) use the XML entities for those characters. I gave an example but the forum munged it. Lemme try again:

ä = ä​
 
Ouch, I've write the wrong example. Sorry!
This is the correct example with result:
ANCIENT_AXEMAN = ^cnt[n]^. Axtkäämpfer
-> Axemens are named like "1. Axtk" instead "1. Axtkämpfer"

I shall not write at the midnight. :crazyeye:

Edith:
Uhm, the code has been replaced by this board.
Whatever, I had tried to use the code, you'd showed. The result is, the name will be cut off.
 
Oh right, # and ; are comment characters in INI files. :( You can try enclosing the whole thing in quotes:

Code:
ANCIENT_AXEMAN = [B][COLOR="Red"]"[/COLOR][/B]^cnt[n][u]^. Axtk[plain]&[/plain]#228;[plain]&[/plain]#228;mpfer[B][COLOR="Red"]"[/COLOR][/B]
 
Now, I had tested your suggestion. Units will get randomized names like ^rc^ or ^rd^.
 
That's probably what it does when it doesn't understand the code. Strange. Even if it doesn't understand the quotes, it should just treat them as normal text just like the names you're entering.

Sorry, I have no other ideas here. The INI file format has it's limitations. I'm actually more surprised that putting in the raw letters like á didn't work. When the file is opened, I don't think the INI parser specifies a specific encoding. In that case, it may get tripped up. I'll see if I can specify a different encoding.
 
Thanks a lot for your help.

At the moment, I recommend all users, who editing the INI file for naming, they shouldn't use non-english letters or unicodes until the code can read out the letters as well.

In the guide, there shall be a notice, who said, all non-english letters and unicodes in the INI file causes troubles. That would be fine for all european users.
 
Great mod, however I am having a problem. It seems the phonetic and greek alphabets are advanced one past where they should be. They start with bravo, and beta instead of alpha. If I use the tester and do not increment, and test the different outputs the rest are correct. I get: A, a, bravo, beta, 1, 1st, I.

Any ideas as to why this is? Where is the list of letters stored, can I just edit it myself?

Edit:
I found the python file, changed the array so that zulu, and omega are first in the list. Now it works fine, but I'm still puzzled as to why.
 
I think I see the problem. The FormatNumber function has the current code for phonetic:

Code:
i = ((i + 1) % 26) - 1

But when the first unit is created the value of i is 1. So you get (2 % 26) - 1 which results in a value of 1. Since the arrays are 0 based the value returned for phonetic_array is Bravo instead of Alpha.

The greek code has the same problem.

The fix, I believe is to replace the code up above with this:

Code:
i = (i % 26) - 1

The reason why the top code works for the two alpha values is that it adds the result value (in this case 1) to either 96 or 64 which results in a chr(97) or chr(65). Which are the values for a and A respectively.

I hope this helps.
 
Here's a quick enhancement for random names for the next version.

Instead of having the ^rd^ and ^rc^ names just returning the random names why doesn't the code just do a replacement like the others? This way you could use the ^rd^ and ^rc^ tokens to randomly create ship names and still retain things like "USS" or "HMS" at the front.

Ex. - If you have the token DS-^cnt[n][Destroyers]^ ^rc^ the current code will just generate the ^rc^ portion and ditch the rest of the string. But if the code is changed to just replace the ^rc^ token then the result will be something like this, DS-12 Homer Simpson.

The key is that just doing the replacement won't damage the current functionality as anyone who just wants a random name can still just have a singular ^rc^ or ^rd^ token.

I've done this to the version of UnitNameEventManager.py that I have and here's the code I have:

Code:
##  - ^rd^ - random name
#		check if random naming convention is required
		if not (zsName.find("^rd^") == -1):
			zsRandomName = RandomNameUtils.getRandomName()
			zsName = zsName.replace("^rd^", zsRandomName)

##  - ^rc^ - random civ related name
#		check if random civ related naming convention is required
		if not (zsName.find("^rc^") == -1):
			zsRandomName = RandomNameUtils.getRandomCivilizationName(pPlayer.getCivilizationType())
			zsName = zsName.replace("^rc^", zsRandomName)
 
Thanks for the fixes. I have committed them to SVN for the next release. I also fixed Juliet (one t). What's the preferred form for X?

  1. X-Ray
  2. X-ray (lowercase r)
  3. Xray (no hyphen)
 
http://en.wikipedia.org/wiki/NATO_phonetic_alphabet

Xray

Edit: Mind you, I wouldn't trust a site that has alpha as 'alfa'! Stuoopid idiots. Here is where I originally got it ... http://www.dynamoo.com/technical/phonetic.htm

Edit2: Maybe take this version ... they also have some history of other phonetic alphabets :) http://www.militaryconnection.com/military-alphabet.asp Apparently they went through quite some changes moving to NATO's version as they had to get one that could cater with some very strange accents (deep south anyone? :lol:)
 
Glad I could help.

Is it possible to have the unit's you start with renamed? You know that first warrior or scout?

It just always bugs me that that one unit doesn't follow the naming convention and if I'm using the counting name conventions then I have to start it a 0 or I end up with two units with a 1 in their names.
 
Is it possible to have the unit's you start with renamed? You know that first warrior or scout?

I'll take a look at this tonight. It's absolutely possible, just gotta see how much work it is. If the API to access the naming is done well, it'll be a snap: loop over all units and call naming function for each.

I have to start it a 0 or I end up with two units with a 1 in their names.

You mean you don't name your first Warrior/Scout "Bob"?! :mischief:
 
I think I might have found the solution in a question I posted on the SDK/Python forum, so I'll give it a whack tonight too.

I'll take a look at this tonight. It's absolutely possible, just gotta see how much work it is. If the API to access the naming is done well, it'll be a snap: loop over all units and call naming function for each.



You mean you don't name your first Warrior/Scout "Bob"?! :mischief:

Strangely enough that's what I had been doing! :D
 
Top Bottom