# newgrf_text.h File Reference

Header of Action 04 "universal holder" structure and functions. More...

`#include "strings_type.h"`

Go to the source code of this file.

## Functions

StringID | AddGRFString (uint32 grfid, uint16 stringid, byte langid, bool new_scheme, const char *text_to_add, StringID def_string)
| Add the new read string into our structure.
StringID | GetGRFStringID (uint32 grfid, uint16 stringid)
| Returns the index for this stringid associated with its grfID.
const char * | GetGRFStringPtr (uint16 stringid)
void | CleanUpStrings ()
| House cleaning.
void | SetCurrentGrfLangID (byte language_id)
| Equivalence Setter function between game and newgrf langID.
char * | TranslateTTDPatchCodes (uint32 grfid, const char *str)
bool | CheckGrfLangID (byte lang_id, byte grf_version)
void | PrepareTextRefStackUsage (byte numEntries)
| Prepare the TTDP compatible string code parsing.
void | StopTextRefStackUsage ()
| Stop using the TTDP compatible string code parsing.
void | SwitchToNormalRefStack ()
void | SwitchToErrorRefStack ()
void | RewindTextRefStack ()
uint | RemapNewGRFStringControlCode (uint scc, char *buf_start, char **buff, const char **str, int64 *argv)
| FormatString for NewGRF specific "magic" string control codes.
StringID | TTDPStringIDToOTTDStringIDMapping (StringID string)
| Perform a mapping from TTDPatch's string IDs to OpenTTD's string IDs, but only for the ones we are aware off; the rest like likely unused and will show a warning.

## Detailed Description

Header of Action 04 "universal holder" structure and functions.

Definition in file newgrf_text.h.

## Function Documentation

void CleanUpStrings | ( |  | ) |

House cleaning.

Remove all strings and reset the text counter.

Definition at line 489 of file newgrf_text.cpp.

Referenced by ResetNewGRFData().

void PrepareTextRefStackUsage | ( | byte | numEntries | ) |

Prepare the TTDP compatible string code parsing.

Parameters:

  | numEntries | number of entries to copy from the registers

Definition at line 575 of file newgrf_text.cpp.

References GB(), and TemporaryStorageArray< TYPE, SIZE >::Get().

Referenced by IndustryViewWindow::DrawInfo(), GetCargoSuffix(), and ShowAdditionalText().

uint RemapNewGRFStringControlCode | ( | uint | scc,
|  | char * | buf_start,
|  | char ** | buff,
|  | const char ** | str,
|  | int64 * | argv |
| ) |  |  |

FormatString for NewGRF specific "magic" string control codes.

Parameters:

  | scc | the string control code that has been read
  | buff | the buffer we're writing to
  | str | the string that we need to write
  | argv | the OpenTTD stack of values

Returns:
  the string control code to "execute" now

Definition at line 616 of file newgrf_text.cpp.

References DAYS_TILL_ORIGINAL_BASE_YEAR, max(), TextRefStack::RotateTop4Words(), SCC_NEWGRF_DISCARD_WORD, SCC_NEWGRF_PRINT_DATE, SCC_NEWGRF_PRINT_DWORD, SCC_NEWGRF_PRINT_DWORD_CURRENCY, SCC_NEWGRF_PRINT_HEX_BYTE, SCC_NEWGRF_PRINT_HEX_DWORD, SCC_NEWGRF_PRINT_HEX_QWORD, SCC_NEWGRF_PRINT_HEX_WORD, SCC_NEWGRF_PRINT_MONTH_YEAR, SCC_NEWGRF_PRINT_QWORD_CURRENCY, SCC_NEWGRF_PRINT_SIGNED_BYTE, SCC_NEWGRF_PRINT_SIGNED_WORD, SCC_NEWGRF_PRINT_STRING_ID, SCC_NEWGRF_PRINT_UNSIGNED_WORD, SCC_NEWGRF_PRINT_WORD_LITRES, SCC_NEWGRF_PRINT_WORD_SPEED, SCC_NEWGRF_PUSH_WORD, SCC_NEWGRF_ROTATE_TOP_4_WORDS, SCC_NEWGRF_UNPRINT, and TTDPStringIDToOTTDStringIDMapping().

void SetCurrentGrfLangID | ( | byte | language_id | ) |

Equivalence Setter function between game and newgrf langID.

This function will adjust _currentLangID as to what is the LangID of the current language set by the user. This function is called after the user changed language, from strings.cpp:ReadLanguagePack

Parameters:

  | language_id | iso code of current selection

Definition at line 466 of file newgrf_text.cpp.

References _currentLangID.

StringID TTDPStringIDToOTTDStringIDMapping | ( | StringID | str | ) |

Perform a mapping from TTDPatch's string IDs to OpenTTD's string IDs, but only for the ones we are aware off; the rest like likely unused and will show a warning.

Parameters:

  | str | the string ID to convert

Returns:
  the converted string ID

Definition at line 40 of file newgrf_text.cpp.

References IsInsideMM().

Referenced by MapGRFStringID(), and RemapNewGRFStringControlCode().