OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "../core/alloc_func.hpp"
12 #include "../string_func.h"
13 #include "../strings_func.h"
17 #include "table/strings.h"
19 #include "../safeguards.h"
33 case 0x0006:
return STR_SV_EMPTY;
34 case 0x7000:
return STR_SV_UNNAMED;
35 case 0x70E4:
return SPECSTR_COMPANY_NAME_START;
36 case 0x70E9:
return SPECSTR_COMPANY_NAME_START;
37 case 0x8864:
return STR_SV_TRAIN_NAME;
38 case 0x902B:
return STR_SV_ROAD_VEHICLE_NAME;
39 case 0x9830:
return STR_SV_SHIP_NAME;
40 case 0xA02F:
return STR_SV_AIRCRAFT_NAME;
44 return s - 0x300F + STR_SV_STNAME;
64 if (
GetStringTab(
id) != TEXT_TAB_OLD_CUSTOM)
return std::string();
70 std::ostringstream tmp;
71 std::ostreambuf_iterator<char> strto(tmp);
72 for (; *strfrom !=
'\0'; strfrom++) {
73 char32_t c = (uint8_t)*strfrom;
77 case 0xA4: c = 0x20AC;
break;
78 case 0xA6: c = 0x0160;
break;
79 case 0xA8: c = 0x0161;
break;
80 case 0xB4: c = 0x017D;
break;
81 case 0xB8: c = 0x017E;
break;
82 case 0xBC: c = 0x0152;
break;
83 case 0xBD: c = 0x0153;
break;
84 case 0xBE: c = 0x0178;
break;
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
void Load() const override
Load the chunk.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void SlCopy(void *object, size_t length, VarType conv)
Copy a list of SL_VARs to/from a savegame.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
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
void InitializeOldNames()
Initialize the old names table memory.
@ CH_READONLY
Chunk is never saved.
void free(const void *ptr)
Version of the standard free that accepts const pointers.
size_t SlGetFieldLength()
Get the length of the current object.
char * _old_name_array
Location to load the old names to.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
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.
size_t Utf8Encode(T buf, char32_t c)
Encode a unicode character and place it in the buffer.
static const int LEN_OLD_STRINGS_TTO
The number of characters per string in TTO savegames.
StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
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.