City names starting with special characters

somegrue

Chieftain
Joined
Jan 10, 2024
Messages
7
Version: MGE with 64-bit Editbox Patcher

Hi,

I came across a little bug just now for the first time that may actually be a little bit useful. If this is already common knowledge, never mind - I tried a couple of obvious search terms and nothing relevant showed up.

For context, I rely quite heavily on the city screen cycle: Open one city screen, then use the cursor keys (or the up/down symbols in the bottom-right button group) to flip to the (alphabetically) next/previous city. If one keeps going until the one originally opened shows up again, one has seen all one's cities.

The alphabetic ordering means that adding prefixes to city names creates sub-cycles of a sort. Like, when one puts a "C-" before the name for coastal cities and an "L-" for landlocked ones, and cycles through the cities again, starting at the top of the alphabet, all the Cs show up first, and all the Ls last. Which can be convenient.

So far, so obvious. The wrinkle I found is that some special characters in some places sometimes have a somewhat more interesting effect. Specifically, I enclosed a handful of city names in {curly brackets}, intending to group them in said manner... instead, poof, they vanish from the up-cycle (forward thru the alphabet, up/left key, up button) altogether. More specifically, this affects names starting with either an opening or closing curly bracket, but not names starting with round or square brackets, or with curly brackets somewhere other than at the start. I've not yet experimented beyond that.

What makes this potentially useful instead of plain annoying (YMMV) is that they do stay in the down-cycle (backward, down/right key, down button). So instead of having the same cycle in either direction, one now has two different cycles, one with all and without some of the cities.

Thoughts?
 
I absolutely love this investigation! Though I would be worries that the same bug that effects names for cycling through, also effects some other part of the game. For example if the code that cycles through cities calculating population growth, happiness rebellions and wltkd etc uses the same code then they may get skipped. With the same logic in mind, also worth testing if the AI still see those cities.
 
For example if the code that cycles through cities calculating population growth, happiness rebellions and wltkd etc uses the same code then they may get skipped.

AFAI can tell, the evaluation cycle that starts a turn is chronological, from most to least recently founded. So it stands to reason that this alphabetical oddity can't affect it. Good thinking in general, though, I'll keep out an eye for any other issues. :)
 
Version: MGE with 64-bit Editbox Patcher

Hi,

I came across a little bug just now for the first time that may actually be a little bit useful. If this is already common knowledge, never mind - I tried a couple of obvious search terms and nothing relevant showed up.

For context, I rely quite heavily on the city screen cycle: Open one city screen, then use the cursor keys (or the up/down symbols in the bottom-right button group) to flip to the (alphabetically) next/previous city. If one keeps going until the one originally opened shows up again, one has seen all one's cities.

The alphabetic ordering means that adding prefixes to city names creates sub-cycles of a sort. Like, when one puts a "C-" before the name for coastal cities and an "L-" for landlocked ones, and cycles through the cities again, starting at the top of the alphabet, all the Cs show up first, and all the Ls last. Which can be convenient.

So far, so obvious. The wrinkle I found is that some special characters in some places sometimes have a somewhat more interesting effect. Specifically, I enclosed a handful of city names in {curly brackets}, intending to group them in said manner... instead, poof, they vanish from the up-cycle (forward thru the alphabet, up/left key, up button) altogether. More specifically, this affects names starting with either an opening or closing curly bracket, but not names starting with round or square brackets, or with curly brackets somewhere other than at the start. I've not yet experimented beyond that.

What makes this potentially useful instead of plain annoying (YMMV) is that they do stay in the down-cycle (backward, down/right key, down button). So instead of having the same cycle in either direction, one now has two different cycles, one with all and without some of the cities.

Thoughts?
There are two copy-pasted functions for each direction with some interesting sorting algorithm. The main difference is upper/lower limit represented by string.
C-like:
strcpy(v2, "                         ");
 vs
strcpy(v2, "zzzzzzzzzzzzzzzzzzzzzzzzz");

1704989695157.png


Spaces are for lowest possible name as the space has the lowest ASCII-code (0x20) from all printable characters. And 'z' (0x7A) for highest name. But ASCII-codes for curly brackets are higher than 'z'.

1704989671231.png

To fix this you can hex-edit civ2.exe replacing all 'z' with tilde '~'. For MGE 5.4.0f you can find 'z'-string at offset 0x230024. For ToT 1.1 the offset is 0x1D95B4.

These functions are only used in city window, so I believe it couldn't be exploited in-game.
 
There are two copy-pasted functions for each direction with some interesting sorting algorithm. The main difference is upper/lower limit represented by string.

Ah, yes, I think I get the general idea.Finding the largest name below the current name, and the largest name overall, and showing one or the other, closes the cycle, and vice versa for the other direction. But because of the too-early cutoff at 'z', that closure happens in the wrong place for one of them. Makes sense, cheers!

Ironically, I think this may actually have occurred to them, and they put a safeguard in place - just not the right one in the right place. Namely, when one tries to start a city name with a space, that space gets replaced with an underscore. That ensures that an all-space string is definitely a safe lower bound. Heh.
 
I've been reading some of the early (and epic!) Succession Game threads, and this jumped out at me:

Hmm, I treid to look at the game real quick last night but when I started to cycle through the cities, the game crashed on me.

Man, I wanted a big war. I'll have to see what I can do about that. :mischief:
I noticed this as well. Actually, I could use the "down" arrow to cycle through cities, but when I clicked the top arrow it crashed. I chalked it up to my version being a downgraded MPG, but it could be something else.

There are a couple more posts touching on it. Sounds too similar to be unrelated. I tried grabbing a sav, but didn't manage to find a working attachment - one or more forum software migrations, I'm guessing? This happens at a point at which the players have recently started naming cities themselves because the pre-supply has run dry, which fits in general, even though I didn't notice any mentions of using non-alphanumeric characters.

The obvious difference is that they get a crash instead of harmlessly buggy behaviour, which makes no immediate sense, going by the functions posted upthread. I do remember my version crashing every once in a while before I applied the first of the 64-bit patches - likely forums.civfanatics.com/threads/193215, which is dated 2006, 3 years after that game was played.

So, yeah, related somehow, surely. :p
 
More grist:

(5) WARNING: Maybe everyone else is already used to this and it regularly occurs when playing with so many cities, but the practice of using the forward- and back-arrows to page through the cities does not work properly with our vast empire; duplicate names appears to be only part of the problem.

ETA: Unlike the succession game mentioned previously, this one occasionally does have working attachments. The most recent sav I see is in post #193, in case anybody wants to try reproducing the problem.
 
Last edited:
Top Bottom