mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-19 10:22:39 +01:00
Codechange: reduce required padding of some structs
This commit is contained in:
@@ -2459,25 +2459,25 @@ static bool ConNewGRFReload(std::span<std::string_view> argv)
|
||||
static bool ConListDirs(std::span<std::string_view> argv)
|
||||
{
|
||||
struct SubdirNameMap {
|
||||
Subdirectory subdir; ///< Index of subdirectory type
|
||||
std::string_view name; ///< UI name for the directory
|
||||
bool default_only; ///< Whether only the default (first existing) directory for this is interesting
|
||||
Subdirectory subdir; ///< Index of subdirectory type
|
||||
bool default_only; ///< Whether only the default (first existing) directory for this is interesting
|
||||
};
|
||||
static const SubdirNameMap subdir_name_map[] = {
|
||||
/* Game data directories */
|
||||
{ BASESET_DIR, "baseset", false },
|
||||
{ NEWGRF_DIR, "newgrf", false },
|
||||
{ AI_DIR, "ai", false },
|
||||
{ AI_LIBRARY_DIR, "ailib", false },
|
||||
{ GAME_DIR, "gs", false },
|
||||
{ GAME_LIBRARY_DIR, "gslib", false },
|
||||
{ SCENARIO_DIR, "scenario", false },
|
||||
{ HEIGHTMAP_DIR, "heightmap", false },
|
||||
{ "baseset", BASESET_DIR, false },
|
||||
{ "newgrf", NEWGRF_DIR, false },
|
||||
{ "ai", AI_DIR, false },
|
||||
{ "ailib", AI_LIBRARY_DIR, false },
|
||||
{ "gs", GAME_DIR, false },
|
||||
{ "gslib", GAME_LIBRARY_DIR, false },
|
||||
{ "scenario", SCENARIO_DIR, false },
|
||||
{ "heightmap", HEIGHTMAP_DIR, false },
|
||||
/* Default save locations for user data */
|
||||
{ SAVE_DIR, "save", true },
|
||||
{ AUTOSAVE_DIR, "autosave", true },
|
||||
{ SCREENSHOT_DIR, "screenshot", true },
|
||||
{ SOCIAL_INTEGRATION_DIR, "social_integration", true },
|
||||
{ "save", SAVE_DIR, true },
|
||||
{ "autosave", AUTOSAVE_DIR, true },
|
||||
{ "screenshot", SCREENSHOT_DIR, true },
|
||||
{ "social_integration", SOCIAL_INTEGRATION_DIR, true },
|
||||
};
|
||||
|
||||
if (argv.size() != 2) {
|
||||
|
||||
@@ -2794,12 +2794,12 @@ struct LZMASaveFilter : SaveFilter {
|
||||
|
||||
/** The format for a reader/writer type of a savegame */
|
||||
struct SaveLoadFormat {
|
||||
std::string_view name; ///< name of the compressor/decompressor (debug-only)
|
||||
uint32_t tag; ///< the 4-letter tag by which it is identified in the savegame
|
||||
|
||||
std::shared_ptr<LoadFilter> (*init_load)(std::shared_ptr<LoadFilter> chain); ///< Constructor for the load filter.
|
||||
std::shared_ptr<SaveFilter> (*init_write)(std::shared_ptr<SaveFilter> chain, uint8_t compression); ///< Constructor for the save filter.
|
||||
|
||||
std::string_view name; ///< name of the compressor/decompressor (debug-only)
|
||||
uint32_t tag; ///< the 4-letter tag by which it is identified in the savegame
|
||||
|
||||
uint8_t min_compression; ///< the minimum compression level of this format
|
||||
uint8_t default_compression; ///< the default compression level of this format
|
||||
uint8_t max_compression; ///< the maximum compression level of this format
|
||||
@@ -2814,19 +2814,19 @@ static const uint32_t SAVEGAME_TAG_LZMA = TO_BE32('OTTX');
|
||||
static const SaveLoadFormat _saveload_formats[] = {
|
||||
#if defined(WITH_LZO)
|
||||
/* Roughly 75% larger than zlib level 6 at only ~7% of the CPU usage. */
|
||||
{"lzo", SAVEGAME_TAG_LZO, CreateLoadFilter<LZOLoadFilter>, CreateSaveFilter<LZOSaveFilter>, 0, 0, 0},
|
||||
{CreateLoadFilter<LZOLoadFilter>, CreateSaveFilter<LZOSaveFilter>, "lzo", SAVEGAME_TAG_LZO, 0, 0, 0},
|
||||
#else
|
||||
{"lzo", SAVEGAME_TAG_LZO, nullptr, nullptr, 0, 0, 0},
|
||||
{nullptr, nullptr, "lzo", SAVEGAME_TAG_LZO, 0, 0, 0},
|
||||
#endif
|
||||
/* Roughly 5 times larger at only 1% of the CPU usage over zlib level 6. */
|
||||
{"none", SAVEGAME_TAG_NONE, CreateLoadFilter<NoCompLoadFilter>, CreateSaveFilter<NoCompSaveFilter>, 0, 0, 0},
|
||||
{CreateLoadFilter<NoCompLoadFilter>, CreateSaveFilter<NoCompSaveFilter>, "none", SAVEGAME_TAG_NONE, 0, 0, 0},
|
||||
#if defined(WITH_ZLIB)
|
||||
/* After level 6 the speed reduction is significant (1.5x to 2.5x slower per level), but the reduction in filesize is
|
||||
* fairly insignificant (~1% for each step). Lower levels become ~5-10% bigger by each level than level 6 while level
|
||||
* 1 is "only" 3 times as fast. Level 0 results in uncompressed savegames at about 8 times the cost of "none". */
|
||||
{"zlib", SAVEGAME_TAG_ZLIB, CreateLoadFilter<ZlibLoadFilter>, CreateSaveFilter<ZlibSaveFilter>, 0, 6, 9},
|
||||
{CreateLoadFilter<ZlibLoadFilter>, CreateSaveFilter<ZlibSaveFilter>, "zlib", SAVEGAME_TAG_ZLIB, 0, 6, 9},
|
||||
#else
|
||||
{"zlib", SAVEGAME_TAG_ZLIB, nullptr, nullptr, 0, 0, 0},
|
||||
{nullptr, nullptr, "zlib", SAVEGAME_TAG_ZLIB, 0, 0, 0},
|
||||
#endif
|
||||
#if defined(WITH_LIBLZMA)
|
||||
/* Level 2 compression is speed wise as fast as zlib level 6 compression (old default), but results in ~10% smaller saves.
|
||||
@@ -2834,9 +2834,9 @@ static const SaveLoadFormat _saveload_formats[] = {
|
||||
* The next significant reduction in file size is at level 4, but that is already 4 times slower. Level 3 is primarily 50%
|
||||
* slower while not improving the filesize, while level 0 and 1 are faster, but don't reduce savegame size much.
|
||||
* It's OTTX and not e.g. OTTL because liblzma is part of xz-utils and .tar.xz is preferred over .tar.lzma. */
|
||||
{"lzma", SAVEGAME_TAG_LZMA, CreateLoadFilter<LZMALoadFilter>, CreateSaveFilter<LZMASaveFilter>, 0, 2, 9},
|
||||
{CreateLoadFilter<LZMALoadFilter>, CreateSaveFilter<LZMASaveFilter>, "lzma", SAVEGAME_TAG_LZMA, 0, 2, 9},
|
||||
#else
|
||||
{"lzma", SAVEGAME_TAG_LZMA, nullptr, nullptr, 0, 0, 0},
|
||||
{nullptr, nullptr, "lzma", SAVEGAME_TAG_LZMA, 0, 0, 0},
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@ static int _smallmap_cargo_count; ///< Number of cargos in the link stats leg
|
||||
|
||||
/** Structure for holding relevant data for legends in small map */
|
||||
struct LegendAndColour {
|
||||
StringID legend; ///< String corresponding to the coloured item.
|
||||
PixelColour colour; ///< Colour of the item on the map.
|
||||
StringID legend; ///< String corresponding to the coloured item.
|
||||
IndustryType type; ///< Type of industry. Only valid for industry entries.
|
||||
uint8_t height; ///< Height in tiles. Only valid for height legend entries.
|
||||
CompanyID company; ///< Company to display. Only valid for company entries of the owner legend.
|
||||
@@ -60,25 +60,25 @@ static const uint8_t _linkstat_colours_in_legenda[] = {0, 1, 3, 5, 7, 9, 11};
|
||||
static const int NUM_NO_COMPANY_ENTRIES = 4; ///< Number of entries in the owner legend that are not companies.
|
||||
|
||||
/** Macro for ordinary entry of LegendAndColour */
|
||||
#define MK(a, b) {a, b, IT_INVALID, 0, CompanyID::Invalid(), true, false, false}
|
||||
#define MK(a, b) {b, a, IT_INVALID, 0, CompanyID::Invalid(), true, false, false}
|
||||
|
||||
/** Macro for a height legend entry with configurable colour. */
|
||||
#define MC(col_break) {{}, STR_TINY_BLACK_HEIGHT, IT_INVALID, 0, CompanyID::Invalid(), true, false, col_break}
|
||||
#define MC(col_break) {STR_TINY_BLACK_HEIGHT, {}, IT_INVALID, 0, CompanyID::Invalid(), true, false, col_break}
|
||||
|
||||
/** Macro for non-company owned property entry of LegendAndColour */
|
||||
#define MO(a, b) {a, b, IT_INVALID, 0, CompanyID::Invalid(), true, false, false}
|
||||
#define MO(a, b) {b, a, IT_INVALID, 0, CompanyID::Invalid(), true, false, false}
|
||||
|
||||
/** Macro used for forcing a rebuild of the owner legend the first time it is used. */
|
||||
#define MOEND() {{}, STR_NULL, IT_INVALID, 0, OWNER_NONE, true, true, false}
|
||||
#define MOEND() {STR_NULL, {}, IT_INVALID, 0, OWNER_NONE, true, true, false}
|
||||
|
||||
/** Macro for end of list marker in arrays of LegendAndColour */
|
||||
#define MKEND() {{}, STR_NULL, IT_INVALID, 0, CompanyID::Invalid(), true, true, false}
|
||||
#define MKEND() {STR_NULL, {}, IT_INVALID, 0, CompanyID::Invalid(), true, true, false}
|
||||
|
||||
/**
|
||||
* Macro for break marker in arrays of LegendAndColour.
|
||||
* It will have valid data, though
|
||||
*/
|
||||
#define MS(a, b) {a, b, IT_INVALID, 0, CompanyID::Invalid(), true, false, true}
|
||||
#define MS(a, b) {b, a, IT_INVALID, 0, CompanyID::Invalid(), true, false, true}
|
||||
|
||||
/** Legend text giving the colours to look for on the minimap */
|
||||
static LegendAndColour _legend_land_contours[] = {
|
||||
|
||||
Reference in New Issue
Block a user