OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../string_func.h"
12 #include "../strings_func.h"
16 #include "table/strings.h"
18 #include "../safeguards.h"
32 case 0x0006:
return STR_SV_EMPTY;
33 case 0x7000:
return STR_SV_UNNAMED;
34 case 0x70E4:
return SPECSTR_COMPANY_NAME_START;
35 case 0x70E9:
return SPECSTR_COMPANY_NAME_START;
36 case 0x8864:
return STR_SV_TRAIN_NAME;
37 case 0x902B:
return STR_SV_ROAD_VEHICLE_NAME;
38 case 0x9830:
return STR_SV_SHIP_NAME;
39 case 0xA02F:
return STR_SV_AIRCRAFT_NAME;
43 return s - 0x300F + STR_SV_STNAME;
63 if (
GetStringTab(
id) != TEXT_TAB_OLD_CUSTOM)
return std::string();
69 std::ostringstream tmp;
70 std::ostreambuf_iterator<char> strto(tmp);
71 for (; *strfrom !=
'\0'; strfrom++) {
72 WChar c = (byte)*strfrom;
76 case 0xA4: c = 0x20AC;
break;
77 case 0xA6: c = 0x0160;
break;
78 case 0xA8: c = 0x0161;
break;
79 case 0xB4: c = 0x017D;
break;
80 case 0xB8: c = 0x017E;
break;
81 case 0xBC: c = 0x0152;
break;
82 case 0xBD: c = 0x0153;
break;
83 case 0xBE: c = 0x0178;
break;
static StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
char32_t WChar
Type for wide characters, i.e.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
void Load() const override
Load the chunk.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
void SlCopy(void *object, size_t length, VarType conv)
Copy a list of SL_VARs to/from a savegame.
size_t Utf8Encode(T buf, WChar c)
Encode a unicode character and place it in the buffer.
Handlers and description of chunk.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
SavegameType _savegame_type
type of savegame we are loading
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void InitializeOldNames()
Initialize the old names table memory.
A trimmed down version of what std::span will be in C++20.
@ CH_READONLY
Chunk is never saved.
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
size_t SlGetFieldLength()
Get the length of the current object.
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
char * _old_name_array
Location to load the old names to.
static const int NUM_OLD_STRINGS
The number of custom strings stored in old savegames.
StringID RemapOldStringID(StringID s)
Remap a string ID from the old format to the new format.
static const int LEN_OLD_STRINGS_TTO
The number of characters per string in TTO savegames.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
static const int LEN_OLD_STRINGS
The number of characters per string.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void ResetOldNames()
Free the memory of the old names array.