D0xx strings limit

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
User avatar
George
Tycoon
Tycoon
Posts: 4362
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

D0xx strings limit

Post by George »

Hello.

In xUSSR set we came to D0xx strings limit (1024 strings), while we have only 400 train IDs

I have the following questions:
1) does nmlc makes a D0xx string for every callback even if several vehicles assemble callback text from the same parts?
I made the code

Code: Select all

switch (FEAT_TRAINS, SELF, dr1_h_additional_text,
  (current_year >= 1966) +
  (current_year >= 1968))
{
  0: return string(STR_PURCHASE_HINT_ENGINE_MU,
                   string(STR_PURCHASE_HINT_LOADING_SPEED_2TIC),
                   string(STR_PURCHASE_HINT_AGING_PERIOD_1_1),
                   string(STR_PURCHASE_HINT_ENGINE_TYPE_DMU_H),
                   string(STR_SECTIONS_DMU_3_4),
                   string(STR_PURCHASE_HINT_FROMTO, 1963, 1969),
                   string(STR_PURCHASE_HINT_FACTORY_RIGA_CW));
  1: return string(STR_PURCHASE_HINT_ENGINE_MU_WITH_COMMENT,
                   string(STR_PURCHASE_HINT_LOADING_SPEED_2TIC),
                   string(STR_PURCHASE_HINT_AGING_PERIOD_1_1),
                   string(STR_PURCHASE_HINT_ENGINE_TYPE_DMU_H),
                   string(STR_SECTIONS_DMU_3_4),
                   string(STR_PURCHASE_HINT_FROMTO, 1963, 1969),
                   string(STR_PURCHASE_HINT_FACTORY_RIGA_CW),
                   string(STR_PURCHASE_HINT_ATTACH_YEAR,"...-1965","1966-..."));
     return string(STR_PURCHASE_HINT_ENGINE_MU_WITH_COMMENT,
                   string(STR_PURCHASE_HINT_LOADING_SPEED_2TIC),
                   string(STR_PURCHASE_HINT_AGING_PERIOD_1_1),
                   string(STR_PURCHASE_HINT_ENGINE_TYPE_DMU_H),
                   string(STR_SECTIONS_DMU_3_6),
                   string(STR_PURCHASE_HINT_FROMTO, 1963, 1969),
                   string(STR_PURCHASE_HINT_FACTORY_RIGA_CW),
                   string(STR_PURCHASE_HINT_ATTACH_YEAR,"...-1967","1968-..."));
}
and when I added

Code: Select all

switch (FEAT_TRAINS, SELF, dr2_h_additional_text,
  (current_year >= 1966) +
  (current_year >= 1968))
{
  0: return string(STR_PURCHASE_HINT_ENGINE_MU,
                   string(STR_PURCHASE_HINT_LOADING_SPEED_2TIC),
                   string(STR_PURCHASE_HINT_AGING_PERIOD_1_1),
                   string(STR_PURCHASE_HINT_ENGINE_TYPE_DMU_H),
                   string(STR_SECTIONS_DMU_3_4),
                   string(STR_PURCHASE_HINT_FROMTO, 1963, 1969),
                   string(STR_PURCHASE_HINT_FACTORY_RIGA_CW));
  1: return string(STR_PURCHASE_HINT_ENGINE_MU_WITH_COMMENT,
                   string(STR_PURCHASE_HINT_LOADING_SPEED_2TIC),
                   string(STR_PURCHASE_HINT_AGING_PERIOD_1_1),
                   string(STR_PURCHASE_HINT_ENGINE_TYPE_DMU_H),
                   string(STR_SECTIONS_DMU_3_4),
                   string(STR_PURCHASE_HINT_FROMTO, 1963, 1969),
                   string(STR_PURCHASE_HINT_FACTORY_RIGA_CW),
                   string(STR_PURCHASE_HINT_ATTACH_YEAR,"...-1965","1966-..."));
     return string(STR_PURCHASE_HINT_ENGINE_MU_WITH_COMMENT,
                   string(STR_PURCHASE_HINT_LOADING_SPEED_2TIC),
                   string(STR_PURCHASE_HINT_AGING_PERIOD_1_1),
                   string(STR_PURCHASE_HINT_ENGINE_TYPE_DMU_H),
                   string(STR_SECTIONS_DMU_3_6),
                   string(STR_PURCHASE_HINT_FROMTO, 1963, 1969),
                   string(STR_PURCHASE_HINT_FACTORY_RIGA_CW),
                   string(STR_PURCHASE_HINT_ATTACH_YEAR,"...-1967","1968-..."));
}
it increased amount of D0xx strings by 2!
Why? It has no new strings.
2) How to make nmlc to reduce amount of D0xx strings used? I have only 479 different string in lng file for additional text CB, but nmlc uses more than 500 for it (then I remove additional text CB completely, I get about 480 sting used instead of 1024.
Image Image Image Image
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: D0xx strings limit

Post by frosch »

The result of string(..) is always a single string Id. If you pass parameters within string(..) then NML composes the string at compile time, that is there will be a string id for every combination which you use.

To compose strings with real parameters, you need to assign the text stack registers using STORE_TEMP(...).

Try this:

Code: Select all

switch (FEAT_TRAINS, SELF, dr2_h_additional_text,
  (current_year >= 1966) +
  (current_year >= 1968))
{
  0: return [STORE_TEMP(string(STR_PURCHASE_HINT_LOADING_SPEED_2TIC) | string(STR_PURCHASE_HINT_AGING_PERIOD_1_1) << 16, 0x100),
      STORE_TEMP(string(STR_PURCHASE_HINT_AGING_PERIOD_1_1) | string(STR_PURCHASE_HINT_ENGINE_TYPE_DMU_H) << 16, 0x101),
      STORE_TEMP(string(STR_SECTIONS_DMU_3_4) | string(STR_PURCHASE_HINT_FROMTO, 1963, 1969) << 16, 0x102),
      STORE_TEMP(string(STR_PURCHASE_HINT_FACTORY_RIGA_CW), 0x103), string(STR_PURCHASE_HINT_ENGINE_MU)]
  ...
}
I am not sure whether the [...] syntax to list multiple expressions works within a case. If it doesn't you need to create separate switches for the results, like

Code: Select all

switch (FEAT_TRAINS, SELF, dr2_h_additional_text_0, [
  STORE_TEMP(string(STR_PURCHASE_HINT_LOADING_SPEED_2TIC) | string(STR_PURCHASE_HINT_AGING_PERIOD_1_1) << 16, 0x100),
  STORE_TEMP(string(STR_PURCHASE_HINT_AGING_PERIOD_1_1) | string(STR_PURCHASE_HINT_ENGINE_TYPE_DMU_H) << 16, 0x101),
  STORE_TEMP(string(STR_SECTIONS_DMU_3_4) | string(STR_PURCHASE_HINT_FROMTO, 1963, 1969) << 16, 0x102),
  STORE_TEMP(string(STR_PURCHASE_HINT_FACTORY_RIGA_CW), 0x103), string(STR_PURCHASE_HINT_ENGINE_MU)]
{
  default: return;
}


switch (FEAT_TRAINS, SELF, dr2_h_additional_text,
  (current_year >= 1966) +
  (current_year >= 1968))
{
  0: dr2_h_additional_text_0;
  ...
}
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
George
Tycoon
Tycoon
Posts: 4362
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Re: D0xx strings limit

Post by George »

I've tried and something went wrong
https://jenkins.openttdcoop.org/job/xus ... 59/console

Code: Select all

09:18:36 nmlc ERROR: nmlc: An internal error has occurred:
09:18:36 nmlc-version: v6379:afad0c76c40b from 2017-06-19
09:18:36 Error:    (IndexError) "pop from empty list".
09:18:36 Command:  ['/usr/local/bin/nmlc', '-c', '--grf', 'xussr.grf', 'xussr.nml']
09:18:36 Location: File "/var/lib/jenkins/bin/repos/nml-trunk/nml/actions/action4.py", line 170, in get_string_action4s
code changed:
https://dev.openttdcoop.org/projects/xu ... 2-726.pnml
code added:
https://dev.openttdcoop.org/projects/xu ... rings.pnml
Image Image Image Image
User avatar
George
Tycoon
Tycoon
Posts: 4362
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: Varna, Bulgaria
Contact:

Re: D0xx strings limit

Post by George »

Looks like that it gets more than 1024 strings and becomes confused with it
Removing some trains solves the problem
Image Image Image Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 6 guests