11#include "../string_func.h"
12#include "../strings_func.h"
16#include "table/strings.h"
18#include "../safeguards.h"
31 case 0x0006:
return STR_SV_EMPTY;
32 case 0x7000:
return STR_SV_UNNAMED;
35 case 0x8864:
return STR_SV_TRAIN_NAME;
36 case 0x902B:
return STR_SV_ROAD_VEHICLE_NAME;
37 case 0x9830:
return STR_SV_SHIP_NAME;
38 case 0xA02F:
return STR_SV_AIRCRAFT_NAME;
42 return s - 0x300F + STR_SV_STNAME;
62 if (
GetStringTab(
id) != TEXT_TAB_OLD_CUSTOM)
return std::string();
67 std::ostringstream tmp;
68 std::ostreambuf_iterator<char> strto(tmp);
69 for (
char32_t c : strfrom) {
74 case 0xA4: c = 0x20AC;
break;
75 case 0xA6: c = 0x0160;
break;
76 case 0xA8: c = 0x0161;
break;
77 case 0xB4: c = 0x017D;
break;
78 case 0xB8: c = 0x017E;
break;
79 case 0xBC: c = 0x0152;
break;
80 case 0xBD: c = 0x0153;
break;
81 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.
constexpr bool IsInsideMM(const size_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.
size_t SlGetFieldLength()
Get the length of the current object.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
void SlReadString(std::string &str, size_t length)
Read the given amount of bytes from the buffer into the string.
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.
@ CH_READONLY
Chunk is never saved.
Declaration of functions used in more save/load files.
static void StrMakeValid(T &dst, const char *str, const char *last, StringValidationSettings settings)
Copies the valid (UTF-8) characters from str up to last to the dst.
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.
std::unique_ptr< std::string[]> _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 NUM_OLD_STRINGS
The number of custom strings stored in old savegames.
static const size_t LEN_OLD_STRINGS
The number of characters per string.
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.
static constexpr StringID SPECSTR_COMPANY_NAME_START
Special strings for company names on the form "TownName transport".
Handlers and description of chunk.
void Load() const override
Load the chunk.