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;
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
SavegameType _savegame_type
type of savegame we are loading
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlCopy(void *object, size_t length, VarType conv)
Copy a list of SL_VARs to/from a savegame.
size_t SlGetFieldLength()
Get the length of the current object.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
@ CH_READONLY
Chunk is never saved.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
Declaration of functions used in more save/load files.
void free(const void *ptr)
Version of the standard free that accepts const pointers.
size_t Utf8Encode(T buf, char32_t c)
Encode a unicode character and place it in the buffer.
StringTab GetStringTab(StringID str)
Extract the StringTab from a StringID.
char * _old_name_array
Location to load the old names to.
void ResetOldNames()
Free the memory of the old names array.
StringID RemapOldStringID(StringID s)
Remap a string ID from the old format to the new format.
static const int LEN_OLD_STRINGS
The number of characters per string.
static const int LEN_OLD_STRINGS_TTO
The number of characters per string in TTO savegames.
static const int NUM_OLD_STRINGS
The number of custom strings stored in old savegames.
void InitializeOldNames()
Initialize the old names table memory.
std::string CopyFromOldName(StringID id)
Copy and convert old custom names to UTF-8.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Handlers and description of chunk.
void Load() const override
Load the chunk.