OpenTTD

Functions | Variables
strings_sl.cpp File Reference

Code handling saving and loading of strings. More...

`#include "../stdafx.h"`
`#include "../string_func.h"`
`#include "../strings_func.h"`
`#include "saveload_internal.h"`
`#include "table/strings.h"`
`#include "../safeguards.h"`

Go to the source code of this file.

## Functions
StringID | RemapOldStringID (StringID s)
| Remap a string ID from the old format to the new format. More...
char * | CopyFromOldName (StringID id)
| Copy and convert old custom names to UTF-8. More...
void | ResetOldNames ()
| Free the memory of the old names array. More...
void | InitializeOldNames ()
| Initialize the old names table memory.
static void | Load_NAME ()
| Load the NAME chunk.

## Variables
static const int | NUM_OLD_STRINGS = 512
| The number of custom strings stored in old savegames.
static const int | LEN_OLD_STRINGS = 32
| The number of characters per string.
static const int | LEN_OLD_STRINGS_TTO = 24
| The number of characters per string in TTO savegames.
char * | _old_name_array = NULL
| Location to load the old names to. More...
const ChunkHandler | _name_chunk_handlers []
| Chunk handlers related to strings. More...

## Detailed Description

Code handling saving and loading of strings.

Definition in file strings_sl.cpp.

## Function Documentation

## ◆ CopyFromOldName()

char* CopyFromOldName | ( | StringID | id | ) |

Copy and convert old custom names to UTF-8.

They were all stored in a 512 by 32 (200 by 24 for TTO) long string array and are now stored with stations, waypoints and other places with names.

Parameters

  id | the StringID of the custom name to clone.

Returns
  the clones custom name.

Definition at line 61 of file strings_sl.cpp.

References GetStringTab().

Referenced by FixOldVehicles().

## ◆ RemapOldStringID()

StringID RemapOldStringID | ( | StringID | s | ) |

Remap a string ID from the old format to the new format.

Parameters

  s | StringID that requires remapping

Returns
  translated ID

Definition at line 30 of file strings_sl.cpp.

## ◆ ResetOldNames()

void ResetOldNames | ( |  | ) |

Free the memory of the old names array.

Should be called once the old names have all been converted.

Definition at line 109 of file strings_sl.cpp.

References _old_name_array, and free().

## Variable Documentation

## ◆ _name_chunk_handlers

const ChunkHandler _name_chunk_handlers[]

Initial value:
= {
{ 'NAME', NULL, Load_NAME, NULL, NULL, CH_ARRAY | CH_LAST},
}
Load_NAME
static void Load_NAME()
Load the NAME chunk.
Definition: strings_sl.cpp:127
CH_LAST
Last chunk in this array.
Definition: saveload.h:104

Chunk handlers related to strings.

## ◆ _old_name_array

char* _old_name_array = NULL

Location to load the old names to.

Definition at line 52 of file strings_sl.cpp.

Referenced by InitializeOldNames(), Load_NAME(), and ResetOldNames().