TownName Resonance Issue
Closed this issue · 6 comments
Please let me know if this issue should be filed directly against the main OpenTTD repo rather than here.
With the following code:
// lang/english.lng
##grflangid 00
STR_GRF_NAME :Test Town Names
STR_GRF_DESCRIPTION :Test TownName GRF{}{BLACK}Version: {SILVER}1 [2020-05-02]
STR_GAME_OPTIONS_TOWN_NAME_Test :Test
STR_OPENTTD_VERSION :ERROR. Requires a newer version of OpenTTD. Please upgrade.
and
// testname.nml
grf {
grfid: "STNM";
name: string(STR_GRF_NAME);
desc: string(STR_GRF_DESCRIPTION);
version: 1;
min_compatible_version: 1;
}
if (version_openttd(1,2,0,22723) > openttd_version) {
error(FATAL, REQUIRES_OPENTTD, string(STR_OPENTTD_VERSION));
}
// prefixes
town_names(prefixes) {
{
text("1", 1),
text("2", 1),
text("3", 1),
text("4", 1),
text("5", 1),
}
}
town_names(bodies) {
{
text("A", 1),
text("B", 1),
text("C", 1),
text("D", 1),
text("E", 1),
}
}
town_names(main) {
styles: string(STR_GAME_OPTIONS_TOWN_NAME_TEST);
{
town_names(prefixes, 1),
}
{
text("-", 1),
}
{
town_names(bodies, 1),
}
}
This will only produce 5 town names, on any size map: 1-A, 2-B, 3-C, 4-D, 5-E.
I know that OpenTTD will stop attempting to add towns if it fails to successfully create a new town name enough times, so I think what is happening is that the map engine is going down the same paths again and again and hitting the same 5 names, rather than generating all possible 25 names, and then giving up.
I would expect this to give all 25 names, or at least more than 5.
I'm reporting this in part because I expect that there may be other combinations that hit the "resonance".
I seem to hit it if the two lists are the same length. This happens if the lists are 2, 5, 6, or 12 items long (although I haven't tried others).
I think the NFO output needs to be checked to see if it's a bug or not
The NFO out of nmlc:
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 32)
// Escapes: 2+ 2- 2< 2> 2u< 2u> 2/ 2% 2u/ 2u% 2* 2& 2| 2^ 2sto = 2s 2rst = 2r 2psto 2ror = 2rot 2cmp 2ucmp 2<< 2u>> 2>>
// Escapes: 71 70 7= 7! 7< 7> 7G 7g 7gG 7GG 7gg 7c 7C
// Escapes: D= = DR D+ = DF D- = DC Du* = DM D* = DnF Du<< = DnC D<< = DO D& D| Du/ D/ Du% D%
// Format: spritenum imagefile depth xpos ypos xsize ysize xrel yrel zoom flags
0 * 4 \d10
1 * 54 14 "C" "INFO"
"B" "VRSN" \w4 \dx00000001
"B" "MINV" \w4 \dx00000001
"B" "NPAR" \w1 00
"B" "PALS" \w1 "A"
"B" "BLTR" \w1 "8"
00
00
2 * 66 08 08 "STNM" "Test Town Names" 00 "Test TownName GRF\0D\98Version: \891 [2020-05-02]" 00
// param[126] = param[161]
3 * 5 0D 7E \D= A1 00
// param[127] = (param[126] - 302012611)
4 * 9 0D 7F \D- 7E FF \dx120058C3
// param[127] = (param[127] << -31)
5 * 9 0D 7F \Du<< 7F FF \dxFFFFFFE1
6 * 9 09 7F 04 \7= \dx00000000 01
7 * 64 0B 03 7F 06 "ERROR. Requires a newer version of OpenTTD. Please upgrade." 00
8 * 21 0F 00 // prefixes
01 05 00 03 02 "1" 00
01 "2" 00
01 "3" 00
01 "4" 00
01 "5" 00
9 * 21 0F 01 // bodies
01 05 00 03 01 "A" 00
01 "B" 00
01 "C" 00
01 "D" 00
01 "E" 00
10 * 26 0F 82 // main
7F "Test" 00
00
03 01 03 01 81 00
01 04 01 01 "-" 00
01 05 01 81 01
Ok I think it's a bug, prefixes
and bodies
use the same bits.
@glx22 Thanks for fixing this so fast!
I know there is a new release process...do you have any idea when we might see a 0.5.1 release containing this fix?