From 3907fcd9d20533f82f01d73f820b84051552f5ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Tue, 31 May 2016 15:25:32 +0200 Subject: [PATCH 1/5] Explicitly pack structs --- src/addresses.h | 10 +++---- src/audio/audio.c | 2 +- src/audio/audio.h | 12 ++++---- src/audio/mixer.cpp | 4 +-- src/audio/mixer.h | 6 ++-- src/cmdline/CommandLine.hpp | 6 ++-- src/cmdline_sprite.c | 6 ++-- src/core/Nullable.hpp | 2 +- src/core/stopwatch.h | 2 +- src/core/textinputbuffer.h | 2 +- src/drawing/drawing.h | 12 ++++---- src/drawing/font.h | 4 +-- src/drawing/string.c | 6 ++-- src/input.c | 2 +- src/input.h | 2 +- src/interface/Theme.cpp | 8 ++--- src/interface/colour.h | 4 +-- src/interface/console.c | 2 +- src/interface/viewport.h | 2 +- src/interface/window.h | 32 ++++++++++---------- src/localisation/LanguagePack.h | 6 ++-- src/localisation/convert.c | 2 +- src/localisation/currency.h | 2 +- src/localisation/date.h | 2 +- src/localisation/language.h | 2 +- src/localisation/localisation.c | 2 +- src/management/award.h | 2 +- src/management/news_item.h | 2 +- src/management/research.h | 2 +- src/network/NetworkTypes.h | 6 ++-- src/network/http.cpp | 6 ++-- src/network/http.h | 4 +-- src/network/network.h | 8 +---- src/network/twitch.cpp | 2 +- src/object.h | 10 +++---- src/object_list.c | 2 +- src/paint/map_element/scenery_multiple.c | 2 +- src/paint/map_element/surface.c | 6 ++-- src/paint/paint.h | 8 ++--- src/paint/supports.c | 10 +++---- src/peep/peep.c | 2 +- src/peep/peep.h | 8 ++--- src/rct1.h | 14 ++++----- src/rct2.h | 6 ++-- src/ride/gentle/crooked_house.c | 2 +- src/ride/gentle/ferris_wheel.c | 4 +-- src/ride/gentle/haunted_house.c | 2 +- src/ride/ride.c | 4 +-- src/ride/ride.h | 28 ++++++++--------- src/ride/ride_data.h | 14 ++++----- src/ride/thrill/magic_carpet.c | 2 +- src/ride/thrill/pirate_ship.c | 2 +- src/ride/thrill/swinging_inverter_ship.c | 2 +- src/ride/track.h | 8 ++--- src/ride/track_data.h | 6 ++-- src/ride/track_design.c | 2 +- src/ride/track_design.h | 18 +++++------ src/ride/track_design_index.c | 2 +- src/ride/track_design_save.c | 2 +- src/ride/vehicle.c | 2 +- src/ride/vehicle.h | 14 ++++----- src/ride/vehicle_paint.h | 2 +- src/scenario.h | 18 +++++------ src/util/sawyercoding.h | 2 +- src/windows/editor_object_selection.c | 2 +- src/windows/loadsave.c | 2 +- src/windows/news_options.c | 3 +- src/windows/ride.c | 4 +-- src/windows/ride_construction.c | 2 +- src/windows/scenery.c | 2 +- src/windows/title_command_editor.c | 2 +- src/windows/title_scenarioselect.c | 4 +-- src/world/banner.h | 2 +- src/world/climate.c | 2 +- src/world/climate.h | 2 +- src/world/entrance.h | 2 +- src/world/footpath.c | 4 +-- src/world/footpath.h | 2 +- src/world/map.h | 38 ++++++++++++------------ src/world/map_animation.h | 2 +- src/world/scenery.h | 20 ++++++------- src/world/sprite.h | 28 ++++++++--------- src/world/water.h | 2 +- 83 files changed, 249 insertions(+), 254 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 23db0dd901..7c61b76a5f 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -666,7 +666,7 @@ typedef struct registers { struct { char al; char ah; - }; + } PACKED; }; union { int ebx; @@ -674,7 +674,7 @@ typedef struct registers { struct { char bl; char bh; - }; + } PACKED; }; union { int ecx; @@ -682,7 +682,7 @@ typedef struct registers { struct { char cl; char ch; - }; + } PACKED; }; union { int edx; @@ -690,7 +690,7 @@ typedef struct registers { struct { char dl; char dh; - }; + } PACKED; }; union { int esi; @@ -704,7 +704,7 @@ typedef struct registers { int ebp; short bp; }; -} registers; +} PACKED registers; static int RCT2_CALLFUNC_Y(int address, registers *inOut) { diff --git a/src/audio/audio.c b/src/audio/audio.c index 19e3a84354..95dbe006dc 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -32,7 +32,7 @@ typedef struct rct_audio_params { bool in_range; int volume; int pan; -} rct_audio_params; +} PACKED rct_audio_params; audio_device *gAudioDevices = NULL; int gAudioDeviceCount; diff --git a/src/audio/audio.h b/src/audio/audio.h index 77dadeef91..cb62ad8ba0 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -29,7 +29,7 @@ typedef struct audio_device { char name[AUDIO_DEVICE_NAME_SIZE]; -} audio_device; +} PACKED audio_device; typedef struct rct_ride_music { uint8 ride_id; @@ -38,14 +38,14 @@ typedef struct rct_ride_music { sint16 pan; uint16 frequency; void* sound_channel; -} rct_ride_music; +} PACKED rct_ride_music; typedef struct rct_ride_music_info { uint32 length; uint32 offset; uint8 path_id; uint8 var_9; -} rct_ride_music_info; +} PACKED rct_ride_music_info; typedef struct rct_ride_music_params { uint8 ride_id; @@ -54,7 +54,7 @@ typedef struct rct_ride_music_params { sint16 volume; sint16 pan; uint16 frequency; -} rct_ride_music_params; +} PACKED rct_ride_music_params; typedef struct rct_vehicle_sound { uint16 id; @@ -69,7 +69,7 @@ typedef struct rct_vehicle_sound { uint16 sound2_freq; void* sound1_channel; void* sound2_channel; -} rct_vehicle_sound; +} PACKED rct_vehicle_sound; typedef struct rct_vehicle_sound_params { uint16 id; @@ -78,7 +78,7 @@ typedef struct rct_vehicle_sound_params { uint16 frequency; sint16 volume; uint16 var_A; -} rct_vehicle_sound_params; +} PACKED rct_vehicle_sound_params; typedef enum RCT2_SOUND { SOUND_LIFT_1 = 0, diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index 79735ac26f..2b53e53e53 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -146,7 +146,7 @@ bool Source_Sample::LoadCSS1(const char *filename, unsigned int offset) Uint16 blockalign; Uint16 bitspersample; Uint16 extrasize; - } waveformat; + } PACKED waveformat; SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); format.freq = waveformat.frequency; format.format = AUDIO_S16LSB; @@ -270,7 +270,7 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw) Uint32 byterate; Uint16 blockalign; Uint16 bitspersample; - } waveformat; + } PACKED waveformat; SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); SDL_RWseek(rw, chunkstart + fmtchunk_size, RW_SEEK_SET); const Uint16 pcmformat = 0x0001; diff --git a/src/audio/mixer.h b/src/audio/mixer.h index bac6effcaa..b2097a01f2 100644 --- a/src/audio/mixer.h +++ b/src/audio/mixer.h @@ -43,12 +43,12 @@ extern "C" { #include } -struct AudioFormat { - int BytesPerSample() const { return (SDL_AUDIO_BITSIZE(format)) / 8; }; +typedef struct AudioFormat { + int BytesPerSample() const { return (SDL_AUDIO_BITSIZE(format)) / 8; } int freq; SDL_AudioFormat format; int channels; -}; +} PACKED AudioFormat; class Source { diff --git a/src/cmdline/CommandLine.hpp b/src/cmdline/CommandLine.hpp index 52b96ae297..1633dc6a69 100644 --- a/src/cmdline/CommandLine.hpp +++ b/src/cmdline/CommandLine.hpp @@ -60,7 +60,7 @@ struct CommandLineExample { const char * Arguments; const char * Description; -}; +} PACKED; struct CommandLineOptionDefinition { @@ -69,7 +69,7 @@ struct CommandLineOptionDefinition char ShortName; const char * LongName; const char * Description; -}; +} PACKED; struct CommandLineCommand { @@ -78,7 +78,7 @@ struct CommandLineCommand const CommandLineOptionDefinition * Options; const CommandLineCommand * SubCommands; CommandLineFunc Func; -}; +} PACKED; enum { diff --git a/src/cmdline_sprite.c b/src/cmdline_sprite.c index 62d3a399d5..f4891747cc 100644 --- a/src/cmdline_sprite.c +++ b/src/cmdline_sprite.c @@ -29,11 +29,11 @@ extern int gSpriteMode; typedef struct rct_sprite_file_header { uint32 num_entries; uint32 total_size; -} rct_sprite_file_header; +} PACKED rct_sprite_file_header; typedef struct rct_sprite_file_palette_entry { uint8 b, g, r, a; -} rct_sprite_file_palette_entry; +} PACKED rct_sprite_file_palette_entry; rct_sprite_file_palette_entry spriteFilePalette[256]; static rct_sprite_file_palette_entry _standardPalette[256]; @@ -234,7 +234,7 @@ int get_palette_index(sint16 *colour) typedef struct rle_code { uint8 num_pixels; uint8 offset_x; -} rle_code; +} PACKED rle_code; bool sprite_file_import(const char *path, rct_g1_element *outElement, uint8 **outBuffer, int *outBufferLength, int mode) { diff --git a/src/core/Nullable.hpp b/src/core/Nullable.hpp index 869d6d8ebe..e03d8a4fc2 100644 --- a/src/core/Nullable.hpp +++ b/src/core/Nullable.hpp @@ -58,4 +58,4 @@ public: private: T _value; bool _hasValue; -}; +} PACKED; diff --git a/src/core/stopwatch.h b/src/core/stopwatch.h index 56aa1a3c52..995bb36bb1 100644 --- a/src/core/stopwatch.h +++ b/src/core/stopwatch.h @@ -25,7 +25,7 @@ typedef struct stopwatch { void *context; -} stopwatch; +} PACKED stopwatch; void stopwatch_create(stopwatch *stopwatch); void stopwatch_dispose(stopwatch *stopwatch); diff --git a/src/core/textinputbuffer.h b/src/core/textinputbuffer.h index 787473609f..a0180af66b 100644 --- a/src/core/textinputbuffer.h +++ b/src/core/textinputbuffer.h @@ -28,7 +28,7 @@ typedef struct textinputbuffer { size_t selection_offset; // Selection start, in bytes size_t selection_size; // Selection length in bytes -} textinputbuffer; +} PACKED textinputbuffer; void textinputbuffer_init(textinputbuffer * tib, utf8 * buffer, size_t size); void textinputbuffer_clear(textinputbuffer * tib); diff --git a/src/drawing/drawing.h b/src/drawing/drawing.h index 53a309952c..61637604db 100644 --- a/src/drawing/drawing.h +++ b/src/drawing/drawing.h @@ -29,7 +29,7 @@ typedef struct rct_drawpixelinfo { short height; // 0x0A short pitch; // 0x0C note: this is actually (pitch - width) uint16 zoom_level; // 0x0E -} rct_drawpixelinfo; +} PACKED rct_drawpixelinfo; // Size: 0x10 typedef struct rct_g1_element { @@ -40,7 +40,7 @@ typedef struct rct_g1_element { sint16 y_offset; // 0x0A uint16 flags; // 0x0C uint16 zoomed_offset; // 0x0E -} rct_g1_element; +} PACKED rct_g1_element; enum { G1_FLAG_BMP = (1 << 0), //No invisible sections @@ -57,24 +57,24 @@ enum { typedef struct rct_g1_header { uint32 num_entries; uint32 total_size; -} rct_g1_header; +} PACKED rct_g1_header; typedef struct rct_gx { rct_g1_header header; rct_g1_element *elements; void *data; -} rct_gx; +} PACKED rct_gx; typedef struct rct_palette_entry { uint8 blue; uint8 green; uint8 red; uint8 alpha; -} rct_palette_entry; +} PACKED rct_palette_entry; typedef struct rct_palette { rct_palette_entry entries[256]; -} rct_palette; +} PACKED rct_palette; #define SPRITE_ID_PALETTE_COLOUR_1(colourId) ((IMAGE_TYPE_USE_PALETTE << 28) | ((colourId) << 19)) diff --git a/src/drawing/font.h b/src/drawing/font.h index 01321e6648..79d9a37ad5 100644 --- a/src/drawing/font.h +++ b/src/drawing/font.h @@ -45,11 +45,11 @@ typedef struct TTFFontDescriptor { int offset_y; int line_height; TTF_Font *font; -} TTFFontDescriptor; +} PACKED TTFFontDescriptor; typedef struct TTFFontSetDescriptor { TTFFontDescriptor size[FONT_SIZE_COUNT]; -} TTFFontSetDescriptor; +} PACKED TTFFontSetDescriptor; extern TTFFontSetDescriptor *gCurrentTTFFontSet; diff --git a/src/drawing/string.c b/src/drawing/string.c index 12ee28304a..259bfa62d0 100644 --- a/src/drawing/string.c +++ b/src/drawing/string.c @@ -36,7 +36,7 @@ typedef struct ttf_cache_entry { TTF_Font *font; utf8 *text; uint32 lastUseTick; -} ttf_cache_entry; +} PACKED ttf_cache_entry; static ttf_cache_entry _ttfSurfaceCache[TTF_SURFACE_CACHE_SIZE] = { 0 }; static int _ttfSurfaceCacheCount = 0; @@ -48,7 +48,7 @@ typedef struct ttf_getwidth_cache_entry { TTF_Font *font; utf8 *text; uint32 lastUseTick; -} ttf_getwidth_cache_entry; +} PACKED ttf_getwidth_cache_entry; static ttf_getwidth_cache_entry _ttfGetWidthCache[TTF_GETWIDTH_CACHE_SIZE] = { 0 }; static int _ttfGetWidthCacheCount = 0; @@ -908,7 +908,7 @@ typedef struct text_draw_info { uint8 palette[8]; uint16 font_sprite_base; const sint8 *y_offset; -} text_draw_info; +} PACKED text_draw_info; static void ttf_draw_character_sprite(rct_drawpixelinfo *dpi, int codepoint, text_draw_info *info) { diff --git a/src/input.c b/src/input.c index eb8a79b233..e182cb6059 100644 --- a/src/input.c +++ b/src/input.c @@ -51,7 +51,7 @@ typedef struct rct_mouse_data { uint32 x; uint32 y; uint32 state; -} rct_mouse_data; +} PACKED rct_mouse_data; static rct_mouse_data _mouseInputQueue[64]; static uint8 _mouseInputQueueReadIndex = 0; diff --git a/src/input.h b/src/input.h index 808a77276f..3ddc772690 100644 --- a/src/input.h +++ b/src/input.h @@ -66,7 +66,7 @@ typedef struct widget_ref { rct_windowclass window_classification; rct_windownumber window_number; rct_widgetindex widget_index; -} widget_ref; +} PACKED widget_ref; extern uint8 gInputState; extern uint8 gInputFlags; diff --git a/src/interface/Theme.cpp b/src/interface/Theme.cpp index d26191fb0c..bc3ed6f147 100644 --- a/src/interface/Theme.cpp +++ b/src/interface/Theme.cpp @@ -43,7 +43,7 @@ constexpr uint64 MAX_THEME_SIZE = 64 * 1024 * 1024; struct WindowTheme { colour_t Colours[6]; -}; +} PACKED; /** * Represents the style for a particular type of window. @@ -56,7 +56,7 @@ struct UIThemeWindowEntry json_t * ToJson() const; static UIThemeWindowEntry FromJson(const WindowThemeDesc * wtDesc, const json_t * json); -}; +} PACKED; /** * Represents a user interface theme. Contains window colour schemes and appearance features. @@ -95,7 +95,7 @@ struct WindowThemeDesc rct_string_id WindowName; uint8 NumColours; WindowTheme DefaultTheme; -}; +} PACKED; #pragma region Window Theme Descriptors @@ -495,7 +495,7 @@ namespace ThemeManager { utf8 Path[MAX_PATH]; utf8 Name[96]; - }; + } PACKED; utf8 * CurrentThemePath; UITheme * CurrentTheme; diff --git a/src/interface/colour.h b/src/interface/colour.h index c9144af39d..99a02f016b 100644 --- a/src/interface/colour.h +++ b/src/interface/colour.h @@ -79,7 +79,7 @@ typedef struct rct_colour_map_a { uint8 light; uint8 lighter; uint8 lightest; -} rct_colour_map_a; +} PACKED rct_colour_map_a; typedef struct rct_colour_map_b { uint8 a; @@ -90,7 +90,7 @@ typedef struct rct_colour_map_b { uint8 f; uint8 g; uint8 h; -} rct_colour_map_b; +} PACKED rct_colour_map_b; extern rct_colour_map_a *ColourMapA; extern rct_colour_map_b *ColourMapB; diff --git a/src/interface/console.c b/src/interface/console.c index ccd5f03a3b..520ef3023d 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -999,7 +999,7 @@ typedef struct console_command { console_command_func func; utf8 *help; utf8 *usage; -} console_command; +} PACKED console_command; utf8* console_variable_table[] = { "park_rating", diff --git a/src/interface/viewport.h b/src/interface/viewport.h index d62b8caad4..bfc4f07a72 100644 --- a/src/interface/viewport.h +++ b/src/interface/viewport.h @@ -82,7 +82,7 @@ typedef struct viewport_interaction_info { rct_peep *peep; rct_vehicle *vehicle; }; -} viewport_interaction_info; +} PACKED viewport_interaction_info; #define MAX_VIEWPORT_COUNT MAX_WINDOW_COUNT diff --git a/src/interface/window.h b/src/interface/window.h index 7a4dc8cc78..e51aabee6f 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -45,12 +45,12 @@ typedef sint16 rct_widgetindex; typedef struct window_identifier { rct_windowclass classification; rct_windownumber number; -} window_identifier; +} PACKED window_identifier; typedef struct widget_identifier { window_identifier window; int widget_index; -} widget_identifier; +} PACKED widget_identifier; extern widget_identifier gCurrentTextBox; @@ -67,7 +67,7 @@ typedef struct rct_widget { sint16 bottom; // 0x08 uint32 image; // 0x0A uint16 tooltip; // 0x0E -} rct_widget; +} PACKED rct_widget; /** * Viewport structure @@ -85,7 +85,7 @@ typedef struct rct_viewport { uint8 zoom; // 0x10 uint8 var_11; uint16 flags; // 0x12 -} rct_viewport; +} PACKED rct_viewport; /** * Scroll structure @@ -101,7 +101,7 @@ typedef struct rct_scroll { uint16 v_bottom; // 0x0C uint16 v_thumb_top; // 0x0E uint16 v_thumb_bottom; // 0x10 -} rct_scroll; +} PACKED rct_scroll; /** * Viewport focus structure. @@ -115,7 +115,7 @@ typedef struct coordinate_focus { sint16 z; //0x486 uint8 rotation;//0x488 uint8 zoom;//0x489 -} coordinate_focus; +} PACKED coordinate_focus; // Type is viewport_target_sprite_id & 0x80000000 != 0 typedef struct sprite_focus { @@ -164,14 +164,14 @@ typedef struct rct_window_event_list { void (*invalidate)(struct rct_window*); void (*paint)(struct rct_window*, rct_drawpixelinfo*); void (*scroll_paint)(struct rct_window*, rct_drawpixelinfo*, int); -} rct_window_event_list; +} PACKED rct_window_event_list; typedef struct campaign_variables { sint16 campaign_type; sint16 no_weeks; //0x482 uint16 ride_id; //0x484 uint32 pad_486; -} campaign_variables; +} PACKED campaign_variables; typedef struct new_ride_variables { sint16 selected_ride_id; //0x480 @@ -179,7 +179,7 @@ typedef struct new_ride_variables { uint16 pad_484; uint16 pad_486; uint16 selected_ride_countdown; //488 -} new_ride_variables; +} PACKED new_ride_variables; typedef struct news_variables { sint16 var_480; @@ -187,7 +187,7 @@ typedef struct news_variables { uint16 var_484; uint16 var_486; uint16 var_488; -} news_variables; +} PACKED news_variables; typedef struct map_variables { sint16 rotation; @@ -195,28 +195,28 @@ typedef struct map_variables { uint16 var_484; uint16 var_486; uint16 var_488; -} map_variables; +} PACKED map_variables; typedef struct ride_variables { sint16 view; sint32 var_482; sint32 var_486; -} ride_variables; +} PACKED ride_variables; typedef struct scenery_variables { sint16 selected_scenery_id; sint16 hover_counter; -} scenery_variables; +} PACKED scenery_variables; typedef struct track_list_variables { uint16 var_480; uint16 var_484; bool reload_track_designs; -} track_list_variables; +} PACKED track_list_variables; typedef struct error_variables { uint16 var_480; -} error_variables; +} PACKED error_variables; /** * Window structure @@ -288,7 +288,7 @@ typedef struct rct_window { sint8 var_4B8; sint8 var_4B9; uint8 colours[6]; // 0x4BA -} rct_window; +} PACKED rct_window; #define RCT_WINDOW_RIGHT(w) (w->x + w->width) #define RCT_WINDOW_BOTTOM(w) (w->y + w->height) diff --git a/src/localisation/LanguagePack.h b/src/localisation/LanguagePack.h index 0cd1966ec4..76bffdb295 100644 --- a/src/localisation/LanguagePack.h +++ b/src/localisation/LanguagePack.h @@ -56,7 +56,7 @@ private: { char name[8]; const utf8 * strings[4]; - }; + } PACKED; struct ScenarioOverride { @@ -67,9 +67,9 @@ private: const utf8 * name; const utf8 * park; const utf8 * details; - }; + } PACKED; }; - }; + } PACKED; uint16 _id; utf8 * _stringData; diff --git a/src/localisation/convert.c b/src/localisation/convert.c index 9daca90bec..9ce15a3b6e 100644 --- a/src/localisation/convert.c +++ b/src/localisation/convert.c @@ -19,7 +19,7 @@ typedef struct encoding_convert_entry { uint16 code; uint16 unicode; -} encoding_convert_entry; +} PACKED encoding_convert_entry; static const encoding_convert_entry GB2312ToUnicodeTable[7445]; static const encoding_convert_entry Big5ToUnicodeTable[13710]; diff --git a/src/localisation/currency.h b/src/localisation/currency.h index 7c96eb8ab1..631dfea0cd 100644 --- a/src/localisation/currency.h +++ b/src/localisation/currency.h @@ -58,7 +58,7 @@ typedef struct currency_descriptor { uint8 affix_ascii; char symbol_ascii[CURRENCY_SYMBOL_MAX_SIZE]; rct_string_id stringId; -} currency_descriptor; +} PACKED currency_descriptor; // List of currency formats extern const currency_descriptor CurrencyDescriptors[CURRENCY_END]; diff --git a/src/localisation/date.h b/src/localisation/date.h index df414533c6..05491335b2 100644 --- a/src/localisation/date.h +++ b/src/localisation/date.h @@ -43,7 +43,7 @@ typedef struct openrct_timeofday { uint8 second; uint8 minute; uint8 hour; -} openrct_timeofday; +} PACKED openrct_timeofday; extern const sint16 days_in_month[MONTH_COUNT]; extern const rct_string_id DateFormatStringIds[]; diff --git a/src/localisation/language.h b/src/localisation/language.h index 8e2d1f8511..b028cdef7f 100644 --- a/src/localisation/language.h +++ b/src/localisation/language.h @@ -52,7 +52,7 @@ typedef struct language_descriptor { const utf8 *native_name; TTFFontSetDescriptor *font; uint8 rct2_original_id; -} language_descriptor; +} PACKED language_descriptor; extern const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT]; diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c index fc632365fe..3e0f0d2044 100644 --- a/src/localisation/localisation.c +++ b/src/localisation/localisation.c @@ -38,7 +38,7 @@ uint8 gMapTooltipFormatArgs[40]; typedef struct format_code_token { uint32 code; const char *token; -} format_code_token; +} PACKED format_code_token; format_code_token format_code_tokens[] = { { FORMAT_MOVE_X, "MOVE_X" }, diff --git a/src/management/award.h b/src/management/award.h index 0edb722fe0..c372e2bc72 100644 --- a/src/management/award.h +++ b/src/management/award.h @@ -22,7 +22,7 @@ typedef struct rct_award { uint16 time; uint16 type; -} rct_award; +} PACKED rct_award; enum { PARK_AWARD_MOST_UNTIDY, diff --git a/src/management/news_item.h b/src/management/news_item.h index e270595cdd..5f55d7245c 100644 --- a/src/management/news_item.h +++ b/src/management/news_item.h @@ -45,7 +45,7 @@ typedef struct rct_news_item { uint8 day; // 0x0A uint8 pad_0B; // 0x0B utf8 text[256]; // 0x0C -} rct_news_item; +} PACKED rct_news_item; #define MAX_NEWS_ITEMS 60 diff --git a/src/management/research.h b/src/management/research.h index cb3dae2f58..e948e5d812 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -23,7 +23,7 @@ typedef struct rct_research_item { // Bit 16 (0: scenery entry, 1: ride entry) sint32 entryIndex; uint8 category; -} rct_research_item; +} PACKED rct_research_item; enum{ RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED = (1 << 29), diff --git a/src/network/NetworkTypes.h b/src/network/NetworkTypes.h index 0c933fba2b..face3cec77 100644 --- a/src/network/NetworkTypes.h +++ b/src/network/NetworkTypes.h @@ -72,7 +72,7 @@ struct ByteSwapT<1> { return value; } -}; +} PACKED; template <> struct ByteSwapT<2> @@ -81,7 +81,7 @@ struct ByteSwapT<2> { return SDL_SwapBE16(value); } -}; +} PACKED; template <> struct ByteSwapT<4> @@ -90,7 +90,7 @@ struct ByteSwapT<4> { return SDL_SwapBE32(value); } -}; +} PACKED; template T ByteSwapBE(const T& value) diff --git a/src/network/http.cpp b/src/network/http.cpp index 0ebcbea449..b5a647c988 100644 --- a/src/network/http.cpp +++ b/src/network/http.cpp @@ -43,13 +43,13 @@ typedef struct read_buffer { char *ptr; int length; int position; -} read_buffer; +} PACKED read_buffer; typedef struct write_buffer { char *ptr; int length; int capacity; -} write_buffer; +} PACKED write_buffer; #ifdef __WINDOWS__ static utf8 _caBundlePath[MAX_PATH]; @@ -203,7 +203,7 @@ void http_request_json_async(const http_json_request *request, void (*callback)( struct TempThreadArgs { http_json_request request; void (*callback)(http_json_response*); - }; + } PACKED; TempThreadArgs *args = (TempThreadArgs*)malloc(sizeof(TempThreadArgs)); args->request.url = _strdup(request->url); diff --git a/src/network/http.h b/src/network/http.h index c6c8a87284..58c7c37b36 100644 --- a/src/network/http.h +++ b/src/network/http.h @@ -25,12 +25,12 @@ typedef struct http_json_request { const char *method; const char *url; const json_t *body; -} http_json_request; +} PACKED http_json_request; typedef struct http_json_response { int status_code; json_t *root; -} http_json_response; +} PACKED http_json_response; #define HTTP_METHOD_GET "GET" #define HTTP_METHOD_POST "POST" diff --git a/src/network/network.h b/src/network/network.h index a436a13129..e323353281 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -57,12 +57,6 @@ extern "C" { #define NETWORK_STREAM_VERSION "9" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION -// Fixes issues on OS X -#if defined(_RCT2_H_) && !defined(_MSC_VER) -// use similar struct packing as MSVC for our structs -#pragma pack(1) -#endif - #ifdef __cplusplus #include @@ -182,7 +176,7 @@ private: bool operator<(const GameCommand& comp) const { return tick < comp.tick; } - }; + } PACKED; int mode = NETWORK_MODE_NONE; int status = NETWORK_STATUS_NONE; diff --git a/src/network/twitch.cpp b/src/network/twitch.cpp index 291e29c248..c22c4c32fc 100644 --- a/src/network/twitch.cpp +++ b/src/network/twitch.cpp @@ -96,7 +96,7 @@ namespace Twitch member.ShouldTrack = false; return member; } - }; + } PACKED; /** * The time between HTTP requests. diff --git a/src/object.h b/src/object.h index eebef4e10f..52637f904d 100644 --- a/src/object.h +++ b/src/object.h @@ -58,7 +58,7 @@ typedef struct rct_object_entry { uint32 flags; char name[8]; uint32 checksum; -} rct_object_entry; +} PACKED rct_object_entry; /** * Object entry structure extended. @@ -69,7 +69,7 @@ typedef struct rct_object_entry_extended { char name[8]; uint32 checksum; uint32 chunk_size; -} rct_object_entry_extended; +} PACKED rct_object_entry_extended; extern int object_entry_group_counts[]; extern int object_entry_group_encoding[]; @@ -77,18 +77,18 @@ extern int object_entry_group_encoding[]; typedef struct rct_object_entry_group { uint8 **chunks; rct_object_entry_extended *entries; -} rct_object_entry_group; +} PACKED rct_object_entry_group; typedef struct rct_ride_filters { uint8 category[2]; uint8 ride_type; -} rct_ride_filters; +} PACKED rct_ride_filters; typedef struct rct_object_filters { union { rct_ride_filters ride; }; -} rct_object_filters; +} PACKED rct_object_filters; extern rct_object_entry_group object_entry_groups[]; extern void** gObjectList; diff --git a/src/object_list.c b/src/object_list.c index 941af926b7..3794858252 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -37,7 +37,7 @@ typedef struct rct_plugin_header { uint32 date_modified_checksum; uint32 object_list_size; uint32 object_list_no_items; -} rct_plugin_header; +} PACKED rct_plugin_header; // 98DA00 int object_entry_group_counts[] = { diff --git a/src/paint/map_element/scenery_multiple.c b/src/paint/map_element/scenery_multiple.c index 4244ae9642..a2858acd95 100644 --- a/src/paint/map_element/scenery_multiple.c +++ b/src/paint/map_element/scenery_multiple.c @@ -157,7 +157,7 @@ void scenery_multiple_sign_paint_line(const utf8 *str, rct_large_scenery_text *t typedef struct boundbox { rct_xy16 offset; rct_xy16 length; -} boundbox; +} PACKED boundbox; static const boundbox s98E3C4[] = { { 3, 3, 26, 26 }, diff --git a/src/paint/map_element/surface.c b/src/paint/map_element/surface.c index 9fed05acd0..14a809e4d5 100644 --- a/src/paint/map_element/surface.c +++ b/src/paint/map_element/surface.c @@ -74,7 +74,7 @@ struct corner_height uint8 right; uint8 bottom; uint8 left; -}; +} PACKED; /** * rct2: 0x0097B4A4 (R), 0x0097B4C4 (T), 0x0097B4E4 (L), 0x0097B504 (B) @@ -312,7 +312,7 @@ struct tile_descriptor uint8 terrain; uint8 slope; corner_height corner_heights; -}; +} PACKED; uint8 viewport_surface_paint_setup_get_relative_slope(rct_map_element * mapElement, int rotation) { @@ -332,7 +332,7 @@ typedef struct viewport_surface_paint_struct_0 { uint32 var_0C; uint32 var_10; uint32 pad[3]; -} viewport_surface_paint_struct_0; +} PACKED viewport_surface_paint_struct_0; /** * rct2: 0x0065E890, 0x0065E946, 0x0065E9FC, 0x0065EAB2 diff --git a/src/paint/paint.h b/src/paint/paint.h index f350847d3d..ee19f1d3da 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -37,7 +37,7 @@ struct attached_paint_struct { uint8 flags; // 0x0C uint8 pad_0D; attached_paint_struct* next; //0x0E -}; +} PACKED; typedef struct paint_struct paint_struct; @@ -69,7 +69,7 @@ struct paint_struct { uint16 map_x; // 0x2C uint16 map_y; // 0x2E rct_map_element *mapElement; // 0x30 (or sprite pointer) -}; +} PACKED; typedef struct paint_string_struct paint_string_struct; @@ -81,14 +81,14 @@ struct paint_string_struct { uint16 y; // 0x08 uint32 args[4]; // 0x0A uint8 *y_offsets; // 0x1A -}; +} PACKED; typedef struct sprite_bb { uint32 sprite_id; rct_xyz16 offset; rct_xyz16 bb_offset; rct_xyz16 bb_size; -} sprite_bb; +} PACKED sprite_bb; enum PAINT_STRUCT_FLAGS { PAINT_STRUCT_FLAG_IS_MASKED = (1 << 0) diff --git a/src/paint/supports.c b/src/paint/supports.c index cbc676416f..af20c2fabb 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -24,7 +24,7 @@ typedef struct supports_id_desc { uint16 half; uint16 flat; uint16 slope; -} supports_id_desc; +} PACKED supports_id_desc; /* 0x0097B1C4 */ const supports_id_desc WoodenSupportImageIds[] = { @@ -61,17 +61,17 @@ const uint16 WoodenCurveSupportImageIds[] = { typedef struct unk_supports_desc_bound_box { struct { uint8 x, y, z; - } offset; + } PACKED offset; struct { uint8 y, x, z; - } length; -} unk_supports_desc_bound_box; + } PACKED length; +} PACKED unk_supports_desc_bound_box; typedef struct unk_supports_desc { unk_supports_desc_bound_box bounding_box; uint8 var_6; uint8 var_7; -} unk_supports_desc; +} PACKED unk_supports_desc; /* 0x0097B23C */ const unk_supports_desc byte_97B23C[] = { diff --git a/src/peep/peep.c b/src/peep/peep.c index ca40a45b4a..12135cec12 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -1123,7 +1123,7 @@ typedef struct item_pref { uint8 type; // 0 for standard, 1 for extra uint32 item; // And this with the relevant flags uint8 sprite_type; -} item_pref; +} PACKED item_pref; item_pref item_order_preference[] = { { 0, PEEP_ITEM_ICE_CREAM, 15 }, diff --git a/src/peep/peep.h b/src/peep/peep.h index bffaf25db2..6695ea1d3f 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -375,7 +375,7 @@ typedef struct rct_peep_thought { uint8 item; //1 uint8 var_2; //2 uint8 var_3; //3 -} rct_peep_thought; +} PACKED rct_peep_thought; typedef struct rct_peep { uint8 sprite_identifier; // 0x00 @@ -449,12 +449,12 @@ typedef struct rct_peep { struct{ uint8 current_car; // 0x6B uint8 current_seat; // 0x6C - }; + } PACKED; uint16 time_to_sitdown; //0x6B struct{ uint8 time_to_stand; //0x6B uint8 standing_flags; //0x6C - }; + } PACKED; }; // Normally 0, 1 for carrying sliding board on spiral slide ride, 2 for carrying lawn mower uint8 special_sprite; // 0x6D @@ -545,7 +545,7 @@ typedef struct rct_peep { uint8 favourite_ride_rating; // 0xFA uint8 pad_FB; uint32 item_standard_flags; // 0xFC -} rct_peep; +} PACKED rct_peep; enum { EASTEREGG_PEEP_NAME_MICHAEL_SCHUMACHER, diff --git a/src/rct1.h b/src/rct1.h index fde853f762..81ca2fc65e 100644 --- a/src/rct1.h +++ b/src/rct1.h @@ -31,7 +31,7 @@ typedef struct rct1_entrance { uint16 y; uint16 z; uint8 direction; -} rct1_entrance; +} PACKED rct1_entrance; /** * RCT1 ride structure @@ -46,7 +46,7 @@ typedef struct rct1_ride { struct { colour_t body; colour_t trim; - } vehicle_colours[12]; + } PACKED vehicle_colours[12]; colour_t track_primary_colour; colour_t track_secondary_colour; colour_t track_support_colour; @@ -123,7 +123,7 @@ typedef struct rct1_ride { ride_rating excitement; ride_rating intensity; ride_rating nausea; - }; + } PACKED; }; uint16 value; uint16 var_F8; @@ -159,7 +159,7 @@ typedef struct rct1_ride { uint8 music; uint8 entrance_style; uint8 unk_17A[230]; -} rct1_ride; +} PACKED rct1_ride; typedef struct rct1_research_item { uint8 item; @@ -167,7 +167,7 @@ typedef struct rct1_research_item { uint8 category; uint8 flags; uint8 expenditure_area; -} rct1_research_item; +} PACKED rct1_research_item; /** * RCT1,AA,LL scenario / saved game structure. @@ -339,7 +339,7 @@ typedef struct rct1_s4 { uint32 scenario_flags; uint8 unk_1F8358[432]; uint32 expansion_pack_checksum; -} rct1_s4; +} PACKED rct1_s4; enum { RCT1_RIDE_TYPE_NULL = 255, @@ -688,7 +688,7 @@ typedef struct rct_track_td4 { }; uint8 pad_41[0x83]; uint16 start_track_data_AA_CF; // 0xC4 -} rct_track_td4; // Information based off RCTTechDepot +} PACKED rct_track_td4; // Information based off RCTTechDepot enum { RCT1_SCENARIO_FLAG_0 = 1 << 0, diff --git a/src/rct2.h b/src/rct2.h index ac9c01245e..6fb92d1902 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -113,7 +113,9 @@ typedef uint8 colour_t; #ifndef _MSC_VER // use similar struct packing as MSVC for our structs -#pragma pack(1) +#define PACKED __attribute__((packed,aligned(1))) +#else +#define PACKED #endif #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) @@ -190,7 +192,7 @@ typedef struct rct2_install_info { uint8 pad_210[256]; char expansionPackNames[16][128]; uint32 activeExpansionPacks; //0xB10 -} rct2_install_info; +} PACKED rct2_install_info; enum { // Although this is labeled a flag it actually means when diff --git a/src/ride/gentle/crooked_house.c b/src/ride/gentle/crooked_house.c index c1e3f3f520..ccbac23796 100644 --- a/src/ride/gentle/crooked_house.c +++ b/src/ride/gentle/crooked_house.c @@ -24,7 +24,7 @@ typedef struct rct_crooked_house_bound_box { sint16 offset_y; sint16 length_x; sint16 length_y; -} rct_crooked_house_bound_box; +} PACKED rct_crooked_house_bound_box; rct_crooked_house_bound_box crooked_house_data[] = { {6, 0, 42, 24}, diff --git a/src/ride/gentle/ferris_wheel.c b/src/ride/gentle/ferris_wheel.c index d4e67d0037..f7c2475b20 100644 --- a/src/ride/gentle/ferris_wheel.c +++ b/src/ride/gentle/ferris_wheel.c @@ -39,7 +39,7 @@ typedef struct ferris_wheel_bound_box sint16 length_y; sint16 offset_x; sint16 offset_y; -} ferris_wheel_bound_box; +} PACKED ferris_wheel_bound_box; /** rct2: 0x008A8CA8 */ static ferris_wheel_bound_box ferris_wheel_data[] = { @@ -187,4 +187,4 @@ TRACK_PAINT_FUNCTION get_track_paint_function_ferris_wheel(int trackType, int di } return paint_ferris_wheel; -} \ No newline at end of file +} diff --git a/src/ride/gentle/haunted_house.c b/src/ride/gentle/haunted_house.c index e7af92e66b..be60686241 100644 --- a/src/ride/gentle/haunted_house.c +++ b/src/ride/gentle/haunted_house.c @@ -26,7 +26,7 @@ typedef struct haunted_house_bound_box sint16 offset_y; sint16 length_x; sint16 length_y; -} haunted_house_bound_box; +} PACKED haunted_house_bound_box; /** rct2: 0x1428180 */ static haunted_house_bound_box haunted_house_data[] = { diff --git a/src/ride/ride.c b/src/ride/ride.c index 7228acdafa..07442377ac 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -5948,7 +5948,7 @@ foundRideEntry: struct { uint16 type_name; uint16 number; - } name_args; + } PACKED name_args; name_args.type_name = 2 + ride->type; name_args.number = 0; do { @@ -8519,7 +8519,7 @@ void ride_reset_all_names() struct { uint16 type_name; uint16 number; - } name_args; + } PACKED name_args; name_args.type_name = 2 + ride->type; name_args.number = 0; do { diff --git a/src/ride/ride.h b/src/ride/ride.h index b5dbb5c482..5f5dccc405 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -35,7 +35,7 @@ typedef struct rating_tuple { ride_rating excitement; ride_rating intensity; ride_rating nausea; -} rating_tuple; +} PACKED rating_tuple; /** * Couples a ride type and subtype together. @@ -45,32 +45,32 @@ typedef struct ride_list_item { struct { uint8 type; uint8 entry_index; - }; + } PACKED; uint16 ride_type_and_entry; }; -} ride_list_item; +} PACKED ride_list_item; typedef struct track_colour { uint8 main; uint8 additional; uint8 supports; -} track_colour; +} PACKED track_colour; typedef struct vehicle_colour { uint8 main; uint8 additional_1; uint8 additional_2; -} vehicle_colour; +} PACKED vehicle_colour; typedef struct track_colour_preset_list { uint8 count; track_colour list[256]; -} track_colour_preset_list; +} PACKED track_colour_preset_list; typedef struct vehicle_colour_preset_list { uint8 count; vehicle_colour list[256]; -} vehicle_colour_preset_list; +} PACKED vehicle_colour_preset_list; /** * Ride type structure. @@ -109,12 +109,12 @@ typedef struct rct_ride_entry { struct { uint32 enabledTrackPiecesA; // 0x1B6 uint32 enabledTrackPiecesB; // 0x1BA - }; + } PACKED; }; uint8 category[2]; // 0x1BE uint8 shop_item; // 0x1C0 uint8 shop_item_secondary; // 0x1C1 -} rct_ride_entry; +} PACKED rct_ride_entry; /** * Ride structure. @@ -138,7 +138,7 @@ typedef struct rct_ride { struct { rct_string_id name_arguments_type_name; // 0x04C uint16 name_arguments_number; // 0x04E - }; + } PACKED; }; uint16 overall_view; // 0x050 00XX = X, XX00 = Y (* 32 + 16) uint16 station_starts[4]; // 0x052 @@ -237,7 +237,7 @@ typedef struct rct_ride { ride_rating excitement; // 0x140 ride_rating intensity; // 0x142 ride_rating nausea; // 0x144 - }; + } PACKED; }; uint16 value; // 0x146 uint16 chairlift_bullwheel_rotation; // 0x148 @@ -320,7 +320,7 @@ typedef struct rct_ride { uint16 cable_lift; // 0x1FE uint16 queue_length[4]; // 0x200 uint8 pad_208[0x58]; -} rct_ride; +} PACKED rct_ride; #define RIDE_MEASUREMENT_MAX_ITEMS 4800 @@ -340,7 +340,7 @@ typedef struct rct_ride_measurement { sint8 lateral[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x12CC uint8 velocity[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x258C uint8 altitude[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x384C -} rct_ride_measurement; +} PACKED rct_ride_measurement; typedef struct track_begin_end { int begin_x; @@ -352,7 +352,7 @@ typedef struct track_begin_end { int end_y; int end_direction; rct_map_element *end_element; -} track_begin_end; +} PACKED track_begin_end; enum { RIDE_CLASS_RIDE, diff --git a/src/ride/ride_data.h b/src/ride/ride_data.h index 7ec189ee80..d1ac3a63f8 100644 --- a/src/ride/ride_data.h +++ b/src/ride/ride_data.h @@ -25,7 +25,7 @@ typedef struct rct_ride_name_convention { rct_string_id structure_name; rct_string_id station_name; rct_string_id unk_name; -} rct_ride_name_convention; +} PACKED rct_ride_name_convention; typedef struct rct_ride_entrance_definition { uint32 sprite_index; @@ -34,14 +34,14 @@ typedef struct rct_ride_entrance_definition { rct_string_id string_id; uint32 base_image_id; uint16 colour_use_flags; -} rct_ride_entrance_definition; +} PACKED rct_ride_entrance_definition; typedef struct rct_shop_item_string_types { rct_string_id singular; // Balloon rct_string_id plural; // Balloons rct_string_id indefinite; // a Balloon rct_string_id display; // "Diamond Heights" Balloon -} rct_shop_item_string_types; +} PACKED rct_shop_item_string_types; typedef struct rct_ride_data_4 { uint8 price; @@ -50,12 +50,12 @@ typedef struct rct_ride_data_4 { uint8 default_music; uint8 var_3; uint8 pad[2]; -} rct_ride_data_4; +} PACKED rct_ride_data_4; typedef struct ride_cost { uint16 track_price; uint16 support_price; -} ride_cost; +} PACKED ride_cost; typedef struct rct_ride_data_5 { uint8 max_height; @@ -66,13 +66,13 @@ typedef struct rct_ride_data_5 { uint8 price; uint8 bonus_value; // Deprecated. Use rideBonusValue instead uint8 pad; -} rct_ride_data_5; +} PACKED rct_ride_data_5; typedef struct rct_ride_lift_data { uint8 sound_id; uint8 minimum_speed; uint8 maximum_speed; -} rct_ride_lift_data; +} PACKED rct_ride_lift_data; enum { RIDE_TYPE_FLAG4_0 = (1 << 0), diff --git a/src/ride/thrill/magic_carpet.c b/src/ride/thrill/magic_carpet.c index 073bedb77b..17d0a768c6 100644 --- a/src/ride/thrill/magic_carpet.c +++ b/src/ride/thrill/magic_carpet.c @@ -40,7 +40,7 @@ typedef struct bound_box { sint16 y; sint16 width; sint16 height; -} bound_box; +} PACKED bound_box; /** rct2: 0x01428220 */ static const sint16 MagicCarpetOscillationZ[] = { diff --git a/src/ride/thrill/pirate_ship.c b/src/ride/thrill/pirate_ship.c index afad6723be..b474e8796f 100644 --- a/src/ride/thrill/pirate_ship.c +++ b/src/ride/thrill/pirate_ship.c @@ -33,7 +33,7 @@ typedef struct pirate_ship_bound_box sint16 length_y; sint16 offset_x; sint16 offset_y; -} pirate_ship_bound_box; +} PACKED pirate_ship_bound_box; /** rct2: 0x008A83B0 */ static const uint32 pirate_ship_base_sprite_offset[] = { diff --git a/src/ride/thrill/swinging_inverter_ship.c b/src/ride/thrill/swinging_inverter_ship.c index f2f2cbf55d..a585a5a41c 100644 --- a/src/ride/thrill/swinging_inverter_ship.c +++ b/src/ride/thrill/swinging_inverter_ship.c @@ -35,7 +35,7 @@ typedef struct swinging_inverter_ship_bound_box sint16 length_y; sint16 offset_x; sint16 offset_y; -} swinging_inverter_ship_bound_box; +} PACKED swinging_inverter_ship_bound_box; /** rct2: 0x01428020 */ static const swinging_inverter_ship_bound_box swinging_inverter_ship_bounds[] = { diff --git a/src/ride/track.h b/src/ride/track.h index 0b68506c46..6333f6bde9 100644 --- a/src/ride/track.h +++ b/src/ride/track.h @@ -29,7 +29,7 @@ typedef struct rct_trackdefinition { uint8 bank_start; uint8 special; uint8 pad[2]; -} rct_trackdefinition; +} PACKED rct_trackdefinition; /** * Size: 0x0A @@ -42,7 +42,7 @@ typedef struct rct_preview_track { uint8 var_07; uint8 var_08; uint8 var_09; -} rct_preview_track; +} PACKED rct_preview_track; /* size 0x0A */ typedef struct rct_track_coordinates { @@ -52,7 +52,7 @@ typedef struct rct_track_coordinates { sint16 z_end; // 0x04 sint16 x; // 0x06 sint16 y; // 0x08 -} rct_track_coordinates; +} PACKED rct_track_coordinates; enum { TRACK_ELEMENT_FLAG_TERMINAL_STATION = 1 << 3, @@ -456,7 +456,7 @@ typedef struct track_circuit_iterator { rct_map_element *first; bool firstIteration; bool looped; -} track_circuit_iterator; +} PACKED track_circuit_iterator; extern const rct_trackdefinition *gFlatRideTrackDefinitions; extern const rct_trackdefinition *gTrackDefinitions; diff --git a/src/ride/track_data.h b/src/ride/track_data.h index 0a9bc8e0b6..bb59bbc74f 100644 --- a/src/ride/track_data.h +++ b/src/ride/track_data.h @@ -32,7 +32,7 @@ extern const uint8 TrackPieceLengths[256]; typedef struct track_curve_chain { uint16 next; uint16 previous; -} track_curve_chain; +} PACKED track_curve_chain; extern const track_curve_chain gTrackCurveChain[256]; extern const track_curve_chain gFlatRideTrackCurveChain[256]; @@ -48,13 +48,13 @@ typedef struct track_descriptor { uint8 slope_end; uint8 bank_end; uint8 track_element; -} track_descriptor; +} PACKED track_descriptor; extern const track_descriptor gTrackDescriptors[142]; typedef struct { uint16 size; const rct_vehicle_info info[]; -} rct_vehicle_info_list; +} PACKED rct_vehicle_info_list; extern const rct_vehicle_info_list **gTrackVehicleInfo[17]; diff --git a/src/ride/track_design.c b/src/ride/track_design.c index 9e3f8b14ab..2a65cf4111 100644 --- a/src/ride/track_design.c +++ b/src/ride/track_design.c @@ -42,7 +42,7 @@ typedef struct map_backup { uint16 map_size_units_minus_2; uint16 map_size; uint8 current_rotation; -} map_backup; +} PACKED map_backup; static rct_track_td6 *track_design_open_from_buffer(uint8 *src, size_t srcLength); diff --git a/src/ride/track_design.h b/src/ride/track_design.h index a6b28a67a6..e55390c612 100644 --- a/src/ride/track_design.h +++ b/src/ride/track_design.h @@ -36,17 +36,17 @@ typedef struct rct_td6_maze_element { struct{ uint8 unk_2; uint8 type; - }; + } PACKED; }; - }; + } PACKED; }; -} rct_td6_maze_element; +} PACKED rct_td6_maze_element; /* Track Element entry size: 0x02 */ typedef struct rct_td6_track_element { uint8 type; // 0x00 uint8 flags; // 0x01 -} rct_td6_track_element; +} PACKED rct_td6_track_element; /* Track Entrance entry size: 0x06 */ typedef struct rct_td6_entrance_element { @@ -54,7 +54,7 @@ typedef struct rct_td6_entrance_element { uint8 direction; // 0x01 sint16 x; // 0x02 sint16 y; // 0x04 -} rct_td6_entrance_element; +} PACKED rct_td6_entrance_element; /* Track Scenery entry size: 0x16 */ typedef struct rct_td6_scenery_element { @@ -65,7 +65,7 @@ typedef struct rct_td6_scenery_element { uint8 flags; // 0x13 direction quadrant tertiary colour uint8 primary_colour; // 0x14 uint8 secondary_colour; // 0x15 -} rct_td6_scenery_element; +} PACKED rct_td6_scenery_element; /** * Track design structure. @@ -140,17 +140,17 @@ typedef struct rct_track_td6 { rct_td6_scenery_element *scenery_elements; utf8 *name; -} rct_track_td6; +} PACKED rct_track_td6; typedef struct rct_track_design { rct_track_td6 track_td6; uint8 preview[4][TRACK_PREVIEW_IMAGE_SIZE]; // 0xA3 -} rct_track_design; +} PACKED rct_track_design; typedef struct track_design_file_ref { utf8 *name; utf8 *path; -} track_design_file_ref; +} PACKED track_design_file_ref; enum { TRACK_FLAGS2_CONTAINS_LOG_FLUME_REVERSER = (1 << 1), diff --git a/src/ride/track_design_index.c b/src/ride/track_design_index.c index ea0f98e708..dddbdd8219 100644 --- a/src/ride/track_design_index.c +++ b/src/ride/track_design_index.c @@ -27,7 +27,7 @@ typedef struct td_index_item { uint8 ride_type; char ride_entry[9]; utf8 path[MAX_PATH]; -} td_index_item; +} PACKED td_index_item; static bool track_design_index_read_header(SDL_RWops *file, uint32 *tdidxCount); static void track_design_index_scan(); diff --git a/src/ride/track_design_save.c b/src/ride/track_design_save.c index d6b5c1c16b..c981742a98 100644 --- a/src/ride/track_design_save.c +++ b/src/ride/track_design_save.c @@ -1249,7 +1249,7 @@ typedef struct auto_buffer { void *ptr; size_t length; size_t capacity; -} auto_buffer; +} PACKED auto_buffer; static void auto_buffer_write(auto_buffer *buffer, const void *src, size_t len) { diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 821ee03720..333702d636 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -1885,7 +1885,7 @@ typedef struct rct_synchronised_vehicle { uint8 ride_id; uint8 station_id; uint16 vehicle_id; -} rct_synchronised_vehicle; +} PACKED rct_synchronised_vehicle; // 8 synchronised vehicle info rct_synchronised_vehicle *_synchronisedVehicles = (rct_synchronised_vehicle*)0x00F64E4C; diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index c1a4a386d2..ee3552e0dd 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -23,7 +23,7 @@ typedef struct rct_vehicle_colour { uint8 body_colour; uint8 trim_colour; -} rct_vehicle_colour; +} PACKED rct_vehicle_colour; /** * Ride type vehicle structure. @@ -74,7 +74,7 @@ typedef struct rct_ride_entry_vehicle { uint8 draw_order; uint8 special_frames; // 0x60 , 0x7A sint8* peep_loading_positions; // 0x61 , 0x7B -} rct_ride_entry_vehicle; +} PACKED rct_ride_entry_vehicle; typedef struct rct_vehicle { uint8 sprite_identifier; // 0x00 @@ -113,7 +113,7 @@ typedef struct rct_vehicle { struct { sint8 var_34; uint8 var_35; - }; + } PACKED; }; union { sint16 track_direction; // 0x36 (0000 0000 0000 0011) @@ -142,7 +142,7 @@ typedef struct rct_vehicle { struct { sint8 ferris_wheel_var_0; // 0x4C sint8 ferris_wheel_var_1; // 0x4D - }; + } PACKED; }; sint16 var_4E; uint8 status; // 0x50 @@ -192,12 +192,12 @@ typedef struct rct_vehicle { uint8 colours_extended; // 0xD7 uint8 seat_rotation; // 0xD8 uint8 target_seat_rotation; // 0xD9 -} rct_vehicle; +} PACKED rct_vehicle; typedef struct train_ref { rct_vehicle *head; rct_vehicle *tail; -} train_ref; +} PACKED train_ref; // Size: 0x09 typedef struct rct_vehicle_info { @@ -207,7 +207,7 @@ typedef struct rct_vehicle_info { uint8 direction; // 0x06 uint8 vehicle_sprite_type; // 0x07 uint8 bank_rotation; // 0x08 -} rct_vehicle_info; +} PACKED rct_vehicle_info; enum { VEHICLE_ENTRY_FLAG_A_0 = 1 << 0, diff --git a/src/ride/vehicle_paint.h b/src/ride/vehicle_paint.h index 99fe93de06..fba946f439 100644 --- a/src/ride/vehicle_paint.h +++ b/src/ride/vehicle_paint.h @@ -26,7 +26,7 @@ typedef struct vehicle_boundbox { uint8 length_x; uint8 length_y; uint8 length_z; -} vehicle_boundbox; +} PACKED vehicle_boundbox; extern const vehicle_boundbox VehicleBoundboxes[16][224]; diff --git a/src/scenario.h b/src/scenario.h index d2350befc1..b044a00454 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -40,7 +40,7 @@ typedef struct rct_s6_header { uint32 version; // 0x04 uint32 magic_number; // 0x08 uint8 pad_0C[0x14]; -} rct_s6_header; +} PACKED rct_s6_header; /** * SC6 information chunk @@ -57,7 +57,7 @@ typedef struct rct_s6_info { char name[64]; // 0x48 char details[256]; // 0x88 rct_object_entry entry; // 0x188 -} rct_s6_info; +} PACKED rct_s6_info; /** * Scenario scores file header. @@ -68,7 +68,7 @@ typedef struct rct_scenario_scores_header { uint32 var_4; uint32 var_8; uint32 scenario_count; // 0x0C -} rct_scenario_scores_header; +} PACKED rct_scenario_scores_header; typedef enum scenario_source { SCENARIO_SOURCE_RCT1, @@ -100,14 +100,14 @@ typedef struct rct_scenario_basic { char completed_by[64]; // 0x0270 // uint8 source_game; // new in OpenRCT2 // sint16 source_index; // new in OpenRCT2 -} rct_scenario_basic; +} PACKED rct_scenario_basic; typedef struct rct_stex_entry { rct_string_id scenario_name; // 0x00 rct_string_id park_name; // 0x02 rct_string_id details; // 0x04 uint8 var_06; -} rct_stex_entry; +} PACKED rct_stex_entry; #define g_stexEntries ((rct_stex_entry**)object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].chunks) @@ -335,7 +335,7 @@ typedef struct rct_s6_data { uint16 wide_path_tile_loop_x; uint16 wide_path_tile_loop_y; uint8 pad_13CE778[434]; -} rct_s6_data; +} PACKED rct_s6_data; enum { SCENARIO_FLAGS_VISIBLE = (1 << 0), @@ -386,7 +386,7 @@ typedef struct scenario_highscore_entry { utf8 *name; money32 company_value; datetime64 timestamp; -} scenario_highscore_entry; +} PACKED scenario_highscore_entry; typedef struct scenario_index_entry { utf8 path[MAX_PATH]; @@ -407,7 +407,7 @@ typedef struct scenario_index_entry { utf8 name[64]; utf8 details[256]; -} scenario_index_entry; +} PACKED scenario_index_entry; typedef struct source_desc { const utf8 *title; @@ -415,7 +415,7 @@ typedef struct source_desc { uint8 source; sint32 index; uint8 category; -} source_desc; +} PACKED source_desc; extern const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT]; diff --git a/src/util/sawyercoding.h b/src/util/sawyercoding.h index 1c25c0cc49..da0dc35446 100644 --- a/src/util/sawyercoding.h +++ b/src/util/sawyercoding.h @@ -23,7 +23,7 @@ typedef struct sawyercoding_chunk_header { uint8 encoding; uint32 length; -} sawyercoding_chunk_header; +} PACKED sawyercoding_chunk_header; enum { CHUNK_ENCODING_NONE, diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 3d74519d74..75a2bcf2bb 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -279,7 +279,7 @@ typedef struct list_item { rct_object_entry *entry; rct_object_filters *filter; uint8 *flags; -} list_item; +} PACKED list_item; typedef int (*sortFunc)(const void *, const void *); diff --git a/src/windows/loadsave.c b/src/windows/loadsave.c index c068229904..1b012219b6 100644 --- a/src/windows/loadsave.c +++ b/src/windows/loadsave.c @@ -119,7 +119,7 @@ typedef struct loadsave_list_item { char path[MAX_PATH]; time_t date_modified; uint8 type; -} loadsave_list_item; +} PACKED loadsave_list_item; modal_callback gLoadSaveCallback; diff --git a/src/windows/news_options.c b/src/windows/news_options.c index 6ed9c9d2a5..774109a260 100644 --- a/src/windows/news_options.c +++ b/src/windows/news_options.c @@ -30,8 +30,7 @@ typedef struct notification_def { uint8 category; rct_string_id caption; size_t config_offset; - -} notification_def; +} PACKED notification_def; static const notification_def NewsItemOptionDefinitions[] = { { NOTIFICATION_CATEGORY_PARK, STR_NOTIFICATION_PARK_AWARD, offsetof(notification_configuration, park_award) }, diff --git a/src/windows/ride.c b/src/windows/ride.c index e0803f78e2..d5945663e5 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -958,7 +958,7 @@ static rct_window_event_list *window_ride_page_events[] = { typedef struct ride_overall_view_t { sint16 x, y, z; uint8 zoom; -} ride_overall_view; +} PACKED ride_overall_view; ride_overall_view ride_overall_views[MAX_RIDES] = {0}; @@ -2641,7 +2641,7 @@ typedef struct rct_vehichle_paintinfo { short y; int sprite_index; int tertiary_colour; -} rct_vehichle_paintinfo; +} PACKED rct_vehichle_paintinfo; rct_vehichle_paintinfo _sprites_to_draw[144]; diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index 50e02a9a90..f20489cbaa 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -446,7 +446,7 @@ union { struct { uint32 a; uint32 b; - }; + } PACKED; } _enabledRidePieces; static bool _trackPlaceCtrlState; diff --git a/src/windows/scenery.c b/src/windows/scenery.c index dcc3b93c81..7ecd2676e3 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -521,7 +521,7 @@ typedef struct scenery_item { int allRows; int selected_item; sint16 sceneryId; -} scenery_item; +} PACKED scenery_item; static scenery_item window_scenery_count_rows_with_selected_item(int tabIndex) { diff --git a/src/windows/title_command_editor.c b/src/windows/title_command_editor.c index ddd5dc85c3..dcb8a26a5a 100644 --- a/src/windows/title_command_editor.c +++ b/src/windows/title_command_editor.c @@ -32,7 +32,7 @@ typedef struct TITLE_COMMAND_ORDER { uint8 command; rct_string_id nameStringId; rct_string_id descStringId; -} TITLE_COMMAND_ORDER; +} PACKED TITLE_COMMAND_ORDER; TITLE_COMMAND_ORDER window_title_command_editor_orders[] = { { TITLE_SCRIPT_LOAD, 5413, 5431 }, diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index 65806de370..3e159272c2 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -40,11 +40,11 @@ typedef struct sc_list_item { union { struct { rct_string_id string_id; - } heading; + } PACKED heading; struct { scenario_index_entry *scenario; bool is_locked; - } scenario; + } PACKED scenario; }; } sc_list_item; diff --git a/src/world/banner.h b/src/world/banner.h index 52e5257ab3..1af945f82c 100644 --- a/src/world/banner.h +++ b/src/world/banner.h @@ -31,7 +31,7 @@ typedef struct rct_banner { uint8 text_colour; //0x05 uint8 x; //0x06 uint8 y; //0x07 -} rct_banner; +} PACKED rct_banner; enum{ BANNER_FLAG_NO_ENTRY = (1 << 0), diff --git a/src/world/climate.c b/src/world/climate.c index e1984e6882..cbce5caeac 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -37,7 +37,7 @@ typedef struct rct_weather_transition { sint8 base_temperature; sint8 distribution_size; sint8 distribution[24]; -} rct_weather_transition; +} PACKED rct_weather_transition; static const rct_weather_transition* climate_transitions[4]; diff --git a/src/world/climate.h b/src/world/climate.h index d8be5341ca..a5a552bbc7 100644 --- a/src/world/climate.h +++ b/src/world/climate.h @@ -41,7 +41,7 @@ typedef struct rct_weather { sint8 gloom_level; sint8 rain_level; uint32 sprite_id; -} rct_weather; +} PACKED rct_weather; #define gClimate RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, uint8) #define gClimateCurrentWeather RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, uint8) diff --git a/src/world/entrance.h b/src/world/entrance.h index 26ac7441a3..9054e83dd1 100644 --- a/src/world/entrance.h +++ b/src/world/entrance.h @@ -24,6 +24,6 @@ typedef struct rct_entrance_type { uint32 image_id; // 0x02 uint8 scrolling_mode; // 0x06 uint8 text_height; // 0x07 -} rct_entrance_type; +} PACKED rct_entrance_type; #endif diff --git a/src/world/footpath.c b/src/world/footpath.c index de619134eb..9ad8853e36 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -952,12 +952,12 @@ typedef struct rct_neighbour { uint8 direction; uint8 ride_index; uint8 entrance_index; -} rct_neighbour; +} PACKED rct_neighbour; typedef struct rct_neighbour_list { rct_neighbour items[8]; int count; -} rct_neighbour_list; +} PACKED rct_neighbour_list; static int rct_neighbour_compare(const void *a, const void *b) { diff --git a/src/world/footpath.h b/src/world/footpath.h index b82e8f830d..9f8610aada 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -33,7 +33,7 @@ typedef struct rct_footpath_entry { uint32 bridge_image; // 0x06 uint8 var_0A; uint8 flags; // 0x0B -} rct_footpath_entry; +} PACKED rct_footpath_entry; enum { FOOTPATH_SEARCH_SUCCESS, diff --git a/src/world/map.h b/src/world/map.h index 11f7334bda..3ff512f6b7 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -24,7 +24,7 @@ typedef struct rct_map_element_surface_properties { uint8 terrain; //5 0xE0 Terrain Style, 0x1F Water height uint8 grass_length; //6 uint8 ownership; //7 -} rct_map_element_surface_properties; +} PACKED rct_map_element_surface_properties; typedef struct rct_map_element_path_properties { uint8 type; //4 0xF0 Path type, 0x08 Unknown/Unused, 0x04 Set when path is diagonal, 0x03 Rotation @@ -34,7 +34,7 @@ typedef struct rct_map_element_path_properties { uint8 addition_status; //7 uint8 ride_index; }; -} rct_map_element_path_properties; +} PACKED rct_map_element_path_properties; typedef struct rct_map_element_track_properties { uint8 type; //4 @@ -42,42 +42,42 @@ typedef struct rct_map_element_track_properties { struct{ uint8 sequence; //5 uint8 colour; //6 - }; + } PACKED; uint16 maze_entry; // 5 }; uint8 ride_index; //7 -} rct_map_element_track_properties; +} PACKED rct_map_element_track_properties; typedef struct rct_map_element_scenery_properties { uint8 type; //4 uint8 age; //5 uint8 colour_1; //6 uint8 colour_2; //7 -} rct_map_element_scenery_properties; +} PACKED rct_map_element_scenery_properties; typedef struct rct_map_element_entrance_properties { uint8 type; //4 uint8 index; //5 uint8 path_type; //6 uint8 ride_index; //7 -} rct_map_element_entrance_properties; +} PACKED rct_map_element_entrance_properties; typedef struct rct_map_element_fence_properties { uint8 type; //4 uint8 item[3]; //5 -} rct_map_element_fence_properties; +} PACKED rct_map_element_fence_properties; typedef struct rct_map_element_scenerymultiple_properties { uint16 type; //4 uint8 colour[2]; //6 -} rct_map_element_scenerymultiple_properties; +} PACKED rct_map_element_scenerymultiple_properties; typedef struct rct_map_element_banner_properties { uint8 index; //4 uint8 position; //5 uint8 flags; //6 uint8 unused; //7 -} rct_map_element_banner_properties; +} PACKED rct_map_element_banner_properties; typedef union { rct_map_element_surface_properties surface; @@ -100,7 +100,7 @@ typedef struct rct_map_element { uint8 base_height; //2 uint8 clearance_height; //3 rct_map_element_properties properties; -} rct_map_element; +} PACKED rct_map_element; enum { MAP_ELEMENT_QUADRANT_SW, @@ -233,38 +233,38 @@ typedef struct rct_xy8 { union { struct { uint8 x, y; - }; + } PACKED; uint16 xy; }; -} rct_xy8; +} PACKED rct_xy8; typedef struct rct_xyz8 { uint8 x, y, z; -} rct_xyz8; +} PACKED rct_xyz8; typedef struct rct_xyzd8 { uint8 x, y, z, direction; -} rct_xyzd8; +} PACKED rct_xyzd8; typedef struct rct_xy16 { sint16 x, y; -} rct_xy16; +} PACKED rct_xy16; typedef struct rct_xyz16 { sint16 x, y, z; -} rct_xyz16; +} PACKED rct_xyz16; typedef struct rct_xy_element { int x, y; rct_map_element *element; -} rct_xy_element; +} PACKED rct_xy_element; typedef struct rct2_peep_spawn { uint16 x; uint16 y; uint8 z; uint8 direction; -} rct2_peep_spawn; +} PACKED rct2_peep_spawn; enum { MAP_SELECT_FLAG_ENABLE = 1 << 0, @@ -420,7 +420,7 @@ typedef struct map_element_iterator { int x; int y; rct_map_element *element; -} map_element_iterator; +} PACKED map_element_iterator; void map_element_iterator_begin(map_element_iterator *it); int map_element_iterator_next(map_element_iterator *it); diff --git a/src/world/map_animation.h b/src/world/map_animation.h index de4ae8fbbd..0579b65788 100644 --- a/src/world/map_animation.h +++ b/src/world/map_animation.h @@ -28,7 +28,7 @@ typedef struct rct_map_animation { uint8 type; uint16 x; uint16 y; -} rct_map_animation; +} PACKED rct_map_animation; enum { MAP_ANIMATION_TYPE_RIDE_ENTRANCE, diff --git a/src/world/scenery.h b/src/world/scenery.h index 5d3da5de56..b3fee27b6a 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -32,7 +32,7 @@ typedef struct rct_small_scenery_entry { uint16 var_16; uint16 var_18; uint8 scenery_tab_id; // 0x1A -} rct_small_scenery_entry; +} PACKED rct_small_scenery_entry; typedef enum { SMALL_SCENERY_FLAG_FULL_TILE = (1 << 0), // 0x1 @@ -71,14 +71,14 @@ typedef struct rct_large_scenery_tile { sint16 z_offset; uint8 z_clearance; uint16 var_7; -} rct_large_scenery_tile; +} PACKED rct_large_scenery_tile; typedef struct rct_large_scenery_text_glyph { uint8 image_offset; uint8 width; uint8 height; uint8 var_3; -} rct_large_scenery_text_glyph; +} PACKED rct_large_scenery_text_glyph; typedef struct rct_large_scenery_text { rct_xy16 offset[2]; // 0x0 @@ -86,7 +86,7 @@ typedef struct rct_large_scenery_text { uint16 var_A; // 0xA uint16 var_C; // 0xC rct_large_scenery_text_glyph glyphs[256]; // 0xE -} rct_large_scenery_text; +} PACKED rct_large_scenery_text; typedef struct rct_large_scenery_entry { uint8 tool_id; // 0x06 @@ -98,7 +98,7 @@ typedef struct rct_large_scenery_entry { uint8 var_11; rct_large_scenery_text* text; // 0x12 uint32 text_image; // 0x16 -} rct_large_scenery_entry; +} PACKED rct_large_scenery_entry; typedef struct rct_wall_scenery_entry { @@ -109,7 +109,7 @@ typedef struct rct_wall_scenery_entry { sint16 price; // 0x0A uint8 scenery_tab_id; // 0x0C uint8 var_0D; -} rct_wall_scenery_entry; +} PACKED rct_wall_scenery_entry; typedef enum { WALL_SCENERY_FLAG1 = (1 << 0), // 0x1 @@ -132,14 +132,14 @@ typedef struct rct_path_bit_scenery_entry { uint8 tool_id; // 0x09 sint16 price; // 0x0A uint8 scenery_tab_id; // 0x0C -} rct_path_bit_scenery_entry; +} PACKED rct_path_bit_scenery_entry; typedef struct rct_banner_scenery_entry { uint8 scrolling_mode; // 0x06 uint8 flags; // 0x07 sint16 price; // 0x08 uint8 scenery_tab_id; // 0x0A -} rct_banner_scenery_entry; +} PACKED rct_banner_scenery_entry; typedef struct rct_scenery_entry { rct_string_id name; // 0x00 @@ -151,7 +151,7 @@ typedef struct rct_scenery_entry { rct_path_bit_scenery_entry path_bit; rct_banner_scenery_entry banner; }; -} rct_scenery_entry; +} PACKED rct_scenery_entry; typedef struct rct_scenery_set_entry { rct_string_id name; // 0x00 @@ -162,7 +162,7 @@ typedef struct rct_scenery_set_entry { uint8 var_108; // 0x108, order? uint8 pad_109; uint32 var_10A; -} rct_scenery_set_entry; +} PACKED rct_scenery_set_entry; enum { PATH_BIT_FLAG_BIN = 1 << 0, diff --git a/src/world/sprite.h b/src/world/sprite.h index 3e5543ca6b..e1d1e14d43 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -74,7 +74,7 @@ typedef struct rct_unk_sprite { uint8 var_2B; uint8 pad_2C[0x45]; uint8 var_71; -} rct_unk_sprite; +} PACKED rct_unk_sprite; typedef struct rct_litter { uint8 sprite_identifier; // 0x00 @@ -95,7 +95,7 @@ typedef struct rct_litter { uint8 sprite_direction; // 0x1E uint8 pad_1F[5]; uint32 creationTick; // 0x24 -} rct_litter; +} PACKED rct_litter; typedef struct rct_balloon { uint8 sprite_identifier; // 0x00 @@ -119,12 +119,12 @@ typedef struct rct_balloon { struct { uint8 var_26a; uint8 var_26b; - }; + } PACKED; }; uint8 pad_28[4]; uint8 colour; // 0x2C uint8 var_2D; -} rct_balloon; +} PACKED rct_balloon; typedef struct rct_duck { uint8 sprite_identifier; // 0x00 @@ -150,7 +150,7 @@ typedef struct rct_duck { sint16 target_y; // 0x32 uint8 pad_34[0x14]; uint8 state; // 0x48 -} rct_duck; +} PACKED rct_duck; typedef struct rct_jumping_fountain { uint8 sprite_identifier; // 0x00 @@ -175,7 +175,7 @@ typedef struct rct_jumping_fountain { struct { uint8 var_26a; uint8 var_26b; - }; + } PACKED; }; uint8 pad_28[0x6]; uint8 var_2E; @@ -184,7 +184,7 @@ typedef struct rct_jumping_fountain { sint16 target_y; // 0x32 uint8 pad_34[0x12]; uint16 iteration; // 0x46 -} rct_jumping_fountain; +} PACKED rct_jumping_fountain; typedef struct rct_money_effect { uint8 sprite_identifier; // 0x00 @@ -208,7 +208,7 @@ typedef struct rct_money_effect { uint8 pad_2C[0x18]; sint16 offset_x; // 0x44 uint16 wiggle; // 0x46 -} rct_money_effect; +} PACKED rct_money_effect; typedef struct rct_crashed_vehicle_particle { uint8 sprite_identifier; // 0x00 @@ -250,7 +250,7 @@ typedef struct rct_crashed_vehicle_particle { sint32 acceleration_z; // 0x40 uint8 pad_44[0x2D]; uint8 var_71; -} rct_crashed_vehicle_particle; +} PACKED rct_crashed_vehicle_particle; typedef struct rct_crash_splash { uint8 sprite_identifier; // 0x00 @@ -279,7 +279,7 @@ typedef struct rct_crash_splash { uint16 name_string_idx; // 0x22 uint16 var_24; uint16 frame; // 0x26 -} rct_crash_splash; +} PACKED rct_crash_splash; typedef struct rct_steam_particle { uint8 sprite_identifier; // 0x00 @@ -308,7 +308,7 @@ typedef struct rct_steam_particle { uint16 name_string_idx; // 0x22 uint16 var_24; uint16 frame; // 0x26 -} rct_steam_particle; +} PACKED rct_steam_particle; /** * Sprite structure. @@ -334,17 +334,17 @@ typedef struct rct_sprite_bounds { uint8 sprite_height_negative; // 0x01 uint8 sprite_height_positive; // 0x02 uint8 unused; // 0x03 -} rct_sprite_bounds; +} PACKED rct_sprite_bounds; typedef struct rct_sprite_image { uint32 base_image; // 0x00 uint8* unkn_04; // 0x04 -} rct_sprite_image; +} PACKED rct_sprite_image; typedef struct rct_sprite_entry { rct_sprite_image *sprite_image; // 0x00 rct_sprite_bounds *sprite_bounds; // 0x04 -} rct_sprite_entry; +} PACKED rct_sprite_entry; enum { SPRITE_MISC_STEAM_PARTICLE, diff --git a/src/world/water.h b/src/world/water.h index b805979057..7dc545337a 100644 --- a/src/world/water.h +++ b/src/world/water.h @@ -25,6 +25,6 @@ typedef struct rct_water_type { uint32 var_06; uint32 var_0A; uint16 var_0E; -} rct_water_type; +} PACKED rct_water_type; #endif From df3030e4a9b5e12491e86a34889af0426cded3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 2 Jun 2016 20:40:29 +0200 Subject: [PATCH 2/5] Provide static_assert for hard-coded struct sizes. --- src/addresses.h | 6 ++++++ src/audio/audio.h | 14 ++++++++++++++ src/audio/mixer.cpp | 2 ++ src/cmdline_sprite.c | 6 ++++++ src/common.h | 11 +++++++++++ src/drawing/drawing.h | 5 +++++ src/interface/colour.h | 2 ++ src/management/award.h | 1 + src/management/news_item.h | 1 + src/management/research.h | 1 + src/object.h | 5 +++++ src/object_list.c | 1 + src/paint/map_element/surface.c | 9 --------- src/paint/paint.h | 5 +++++ src/peep/peep.h | 2 ++ src/rct1.h | 5 +++++ src/ride/ride.c | 2 ++ src/ride/ride.h | 13 +++++++++++++ src/ride/track.h | 1 + src/ride/track_design.h | 11 ++++++----- src/ride/track_design_index.c | 3 +++ src/ride/vehicle.c | 1 + src/ride/vehicle.h | 3 +++ src/scenario.h | 7 +++++++ src/util/sawyercoding.h | 1 + src/windows/ride_construction.c | 1 + src/world/banner.h | 1 + src/world/entrance.h | 1 + src/world/footpath.h | 1 + src/world/map.h | 18 ++++++++++++++++++ src/world/map_animation.h | 1 + src/world/scenery.h | 10 ++++++++++ src/world/sprite.h | 13 +++++++++++++ src/world/water.h | 1 + 34 files changed, 151 insertions(+), 14 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 7c61b76a5f..77b8a0f301 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -659,6 +659,8 @@ static int RCT2_CALLPROC_EBPSAFE(int address) */ int RCT2_CALLFUNC_X(int address, int *_eax, int *_ebx, int *_ecx, int *_edx, int *_esi, int *_edi, int *_ebp); +#pragma pack(push, 1) + typedef struct registers { union { int eax; @@ -706,6 +708,10 @@ typedef struct registers { }; } PACKED registers; +STATIC_ASSERT (sizeof(registers) == 7 * 4, "Improper struct size"); + +#pragma pack(pop) + static int RCT2_CALLFUNC_Y(int address, registers *inOut) { return RCT2_CALLFUNC_X(address, &inOut->eax, &inOut->ebx, &inOut->ecx, &inOut->edx, &inOut->esi, &inOut->edi, &inOut->ebp); diff --git a/src/audio/audio.h b/src/audio/audio.h index cb62ad8ba0..2f084e6011 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -31,6 +31,8 @@ typedef struct audio_device { char name[AUDIO_DEVICE_NAME_SIZE]; } PACKED audio_device; +#pragma pack(push, 1) + typedef struct rct_ride_music { uint8 ride_id; uint8 tune_id; @@ -40,6 +42,8 @@ typedef struct rct_ride_music { void* sound_channel; } PACKED rct_ride_music; +STATIC_ASSERT (sizeof(rct_ride_music) == 12, "Improper struct size"); + typedef struct rct_ride_music_info { uint32 length; uint32 offset; @@ -47,6 +51,8 @@ typedef struct rct_ride_music_info { uint8 var_9; } PACKED rct_ride_music_info; +STATIC_ASSERT (sizeof(rct_ride_music_info) == 10, "Improper struct size"); + typedef struct rct_ride_music_params { uint8 ride_id; uint8 tune_id; @@ -56,6 +62,8 @@ typedef struct rct_ride_music_params { uint16 frequency; } PACKED rct_ride_music_params; +STATIC_ASSERT (sizeof(rct_ride_music_params) == 12, "Improper struct size"); + typedef struct rct_vehicle_sound { uint16 id; sint16 volume; @@ -71,6 +79,8 @@ typedef struct rct_vehicle_sound { void* sound2_channel; } PACKED rct_vehicle_sound; +STATIC_ASSERT (sizeof(rct_vehicle_sound) == 28, "Improper struct size"); + typedef struct rct_vehicle_sound_params { uint16 id; sint16 pan_x; @@ -80,6 +90,10 @@ typedef struct rct_vehicle_sound_params { uint16 var_A; } PACKED rct_vehicle_sound_params; +STATIC_ASSERT (sizeof(rct_vehicle_sound_params) == 12, "Improper struct size"); + +#pragma pack(pop) + typedef enum RCT2_SOUND { SOUND_LIFT_1 = 0, SOUND_TRACK_FRICTION_1 = 1, diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index 2b53e53e53..448345d743 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -147,6 +147,7 @@ bool Source_Sample::LoadCSS1(const char *filename, unsigned int offset) Uint16 bitspersample; Uint16 extrasize; } PACKED waveformat; + STATIC_ASSERT (sizeof(waveformat) == 18, "Improper struct size"); SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); format.freq = waveformat.frequency; format.format = AUDIO_S16LSB; @@ -271,6 +272,7 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw) Uint16 blockalign; Uint16 bitspersample; } PACKED waveformat; + STATIC_ASSERT (sizeof(waveformat) == 16, "Improper struct size"); SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); SDL_RWseek(rw, chunkstart + fmtchunk_size, RW_SEEK_SET); const Uint16 pcmformat = 0x0001; diff --git a/src/cmdline_sprite.c b/src/cmdline_sprite.c index f4891747cc..c74d006029 100644 --- a/src/cmdline_sprite.c +++ b/src/cmdline_sprite.c @@ -31,10 +31,14 @@ typedef struct rct_sprite_file_header { uint32 total_size; } PACKED rct_sprite_file_header; +STATIC_ASSERT (sizeof(rct_sprite_file_header) == 8, "Improper struct size"); + typedef struct rct_sprite_file_palette_entry { uint8 b, g, r, a; } PACKED rct_sprite_file_palette_entry; +STATIC_ASSERT (sizeof(rct_sprite_file_palette_entry) == 4, "Improper struct size"); + rct_sprite_file_palette_entry spriteFilePalette[256]; static rct_sprite_file_palette_entry _standardPalette[256]; @@ -236,6 +240,8 @@ typedef struct rle_code { uint8 offset_x; } PACKED rle_code; +STATIC_ASSERT (sizeof(rle_code) == 2, "Improper struct size"); + bool sprite_file_import(const char *path, rct_g1_element *outElement, uint8 **outBuffer, int *outBufferLength, int mode) { uint8 *pixels; diff --git a/src/common.h b/src/common.h index 69c29d6f17..c9dfd4998d 100644 --- a/src/common.h +++ b/src/common.h @@ -55,6 +55,17 @@ #define RESTRICT #endif +#ifdef __cplusplus +#define STATIC_ASSERT static_assert +#else + // Visual Studio does not know _Static_assert + #if !defined(_MSC_VER) + #define STATIC_ASSERT _Static_assert + #else + #define STATIC_ASSERT(x, y) + #endif // !defined(_MSC_VER) +#endif + #ifdef PLATFORM_X86 #ifndef FASTCALL #ifdef __GNUC__ diff --git a/src/drawing/drawing.h b/src/drawing/drawing.h index 61637604db..31944cf598 100644 --- a/src/drawing/drawing.h +++ b/src/drawing/drawing.h @@ -30,6 +30,7 @@ typedef struct rct_drawpixelinfo { short pitch; // 0x0C note: this is actually (pitch - width) uint16 zoom_level; // 0x0E } PACKED rct_drawpixelinfo; +STATIC_ASSERT (sizeof(rct_drawpixelinfo) == 0x10, "Improper struct size"); // Size: 0x10 typedef struct rct_g1_element { @@ -41,6 +42,7 @@ typedef struct rct_g1_element { uint16 flags; // 0x0C uint16 zoomed_offset; // 0x0E } PACKED rct_g1_element; +STATIC_ASSERT (sizeof(rct_g1_element) == 0x10, "Improper struct size"); enum { G1_FLAG_BMP = (1 << 0), //No invisible sections @@ -58,12 +60,14 @@ typedef struct rct_g1_header { uint32 num_entries; uint32 total_size; } PACKED rct_g1_header; +STATIC_ASSERT (sizeof(rct_g1_header) == 8, "Improper struct size"); typedef struct rct_gx { rct_g1_header header; rct_g1_element *elements; void *data; } PACKED rct_gx; +STATIC_ASSERT (sizeof(rct_gx) == 16, "Improper struct size"); typedef struct rct_palette_entry { uint8 blue; @@ -71,6 +75,7 @@ typedef struct rct_palette_entry { uint8 red; uint8 alpha; } PACKED rct_palette_entry; +STATIC_ASSERT (sizeof(rct_palette_entry) == 4, "Improper struct size"); typedef struct rct_palette { rct_palette_entry entries[256]; diff --git a/src/interface/colour.h b/src/interface/colour.h index 99a02f016b..63c8897e38 100644 --- a/src/interface/colour.h +++ b/src/interface/colour.h @@ -80,6 +80,7 @@ typedef struct rct_colour_map_a { uint8 lighter; uint8 lightest; } PACKED rct_colour_map_a; +STATIC_ASSERT (sizeof(rct_colour_map_a) == 8, "Improper struct size"); typedef struct rct_colour_map_b { uint8 a; @@ -91,6 +92,7 @@ typedef struct rct_colour_map_b { uint8 g; uint8 h; } PACKED rct_colour_map_b; +STATIC_ASSERT (sizeof(rct_colour_map_b) == 8, "Improper struct size"); extern rct_colour_map_a *ColourMapA; extern rct_colour_map_b *ColourMapB; diff --git a/src/management/award.h b/src/management/award.h index c372e2bc72..bad382ca14 100644 --- a/src/management/award.h +++ b/src/management/award.h @@ -23,6 +23,7 @@ typedef struct rct_award { uint16 time; uint16 type; } PACKED rct_award; +STATIC_ASSERT (sizeof(rct_award) == 4, "Improper struct size"); enum { PARK_AWARD_MOST_UNTIDY, diff --git a/src/management/news_item.h b/src/management/news_item.h index 5f55d7245c..7145f4782b 100644 --- a/src/management/news_item.h +++ b/src/management/news_item.h @@ -46,6 +46,7 @@ typedef struct rct_news_item { uint8 pad_0B; // 0x0B utf8 text[256]; // 0x0C } PACKED rct_news_item; +STATIC_ASSERT (sizeof(rct_news_item) == 12 + 256, "Improper struct size"); #define MAX_NEWS_ITEMS 60 diff --git a/src/management/research.h b/src/management/research.h index e948e5d812..1a60849828 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -24,6 +24,7 @@ typedef struct rct_research_item { sint32 entryIndex; uint8 category; } PACKED rct_research_item; +STATIC_ASSERT (sizeof(rct_research_item) == 5, "Improper struct size"); enum{ RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED = (1 << 29), diff --git a/src/object.h b/src/object.h index 52637f904d..3e68600d2b 100644 --- a/src/object.h +++ b/src/object.h @@ -59,6 +59,7 @@ typedef struct rct_object_entry { char name[8]; uint32 checksum; } PACKED rct_object_entry; +STATIC_ASSERT (sizeof(rct_object_entry) == 0x10, "Improper struct size"); /** * Object entry structure extended. @@ -70,6 +71,7 @@ typedef struct rct_object_entry_extended { uint32 checksum; uint32 chunk_size; } PACKED rct_object_entry_extended; +STATIC_ASSERT (sizeof(rct_object_entry_extended) == 0x14, "Improper struct size"); extern int object_entry_group_counts[]; extern int object_entry_group_encoding[]; @@ -78,17 +80,20 @@ typedef struct rct_object_entry_group { uint8 **chunks; rct_object_entry_extended *entries; } PACKED rct_object_entry_group; +STATIC_ASSERT (sizeof(rct_object_entry_group) == 8, "Improper struct size"); typedef struct rct_ride_filters { uint8 category[2]; uint8 ride_type; } PACKED rct_ride_filters; +STATIC_ASSERT (sizeof(rct_ride_filters) == 3, "Improper struct size"); typedef struct rct_object_filters { union { rct_ride_filters ride; }; } PACKED rct_object_filters; +STATIC_ASSERT (sizeof(rct_object_filters) == 3, "Improper struct size"); extern rct_object_entry_group object_entry_groups[]; extern void** gObjectList; diff --git a/src/object_list.c b/src/object_list.c index 3794858252..bd79e0ef46 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -38,6 +38,7 @@ typedef struct rct_plugin_header { uint32 object_list_size; uint32 object_list_no_items; } PACKED rct_plugin_header; +STATIC_ASSERT (sizeof(rct_plugin_header) == 20, "Improper struct size"); // 98DA00 int object_entry_group_counts[] = { diff --git a/src/paint/map_element/surface.c b/src/paint/map_element/surface.c index 14a809e4d5..a4884d8fec 100644 --- a/src/paint/map_element/surface.c +++ b/src/paint/map_element/surface.c @@ -325,15 +325,6 @@ uint8 viewport_surface_paint_setup_get_relative_slope(rct_map_element * mapEleme return ebx | di; } -typedef struct viewport_surface_paint_struct_0 { - uint32 var_00; - uint32 var_04; - uint32 var_08; - uint32 var_0C; - uint32 var_10; - uint32 pad[3]; -} PACKED viewport_surface_paint_struct_0; - /** * rct2: 0x0065E890, 0x0065E946, 0x0065E9FC, 0x0065EAB2 */ diff --git a/src/paint/paint.h b/src/paint/paint.h index ee19f1d3da..ebc861e018 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -38,6 +38,8 @@ struct attached_paint_struct { uint8 pad_0D; attached_paint_struct* next; //0x0E } PACKED; +// TODO: drop packing from this when all rendering is done. +STATIC_ASSERT (sizeof(attached_paint_struct) == 0x12, "Improper struct size"); typedef struct paint_struct paint_struct; @@ -70,6 +72,8 @@ struct paint_struct { uint16 map_y; // 0x2E rct_map_element *mapElement; // 0x30 (or sprite pointer) } PACKED; +// TODO: drop packing from this when all rendering is done. +STATIC_ASSERT (sizeof(paint_struct) == 0x34, "Improper struct size"); typedef struct paint_string_struct paint_string_struct; @@ -82,6 +86,7 @@ struct paint_string_struct { uint32 args[4]; // 0x0A uint8 *y_offsets; // 0x1A } PACKED; +STATIC_ASSERT (sizeof(paint_string_struct) == 0x1e, "Improper struct size"); typedef struct sprite_bb { uint32 sprite_id; diff --git a/src/peep/peep.h b/src/peep/peep.h index 6695ea1d3f..d1a2ec5cc7 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -376,6 +376,7 @@ typedef struct rct_peep_thought { uint8 var_2; //2 uint8 var_3; //3 } PACKED rct_peep_thought; +STATIC_ASSERT (sizeof(rct_peep_thought) == 4, "Improper struct size"); typedef struct rct_peep { uint8 sprite_identifier; // 0x00 @@ -546,6 +547,7 @@ typedef struct rct_peep { uint8 pad_FB; uint32 item_standard_flags; // 0xFC } PACKED rct_peep; +STATIC_ASSERT (sizeof(rct_peep) == 0x100, "Improper struct size"); enum { EASTEREGG_PEEP_NAME_MICHAEL_SCHUMACHER, diff --git a/src/rct1.h b/src/rct1.h index 81ca2fc65e..b8bb040859 100644 --- a/src/rct1.h +++ b/src/rct1.h @@ -32,6 +32,7 @@ typedef struct rct1_entrance { uint16 z; uint8 direction; } PACKED rct1_entrance; +STATIC_ASSERT (sizeof(rct1_entrance) == 7, "Improper struct size"); /** * RCT1 ride structure @@ -160,6 +161,7 @@ typedef struct rct1_ride { uint8 entrance_style; uint8 unk_17A[230]; } PACKED rct1_ride; +STATIC_ASSERT (sizeof(rct1_ride) == 0x260, "Improper struct size"); typedef struct rct1_research_item { uint8 item; @@ -168,6 +170,7 @@ typedef struct rct1_research_item { uint8 flags; uint8 expenditure_area; } PACKED rct1_research_item; +STATIC_ASSERT (sizeof(rct1_research_item) == 5, "Improper struct size"); /** * RCT1,AA,LL scenario / saved game structure. @@ -340,6 +343,7 @@ typedef struct rct1_s4 { uint8 unk_1F8358[432]; uint32 expansion_pack_checksum; } PACKED rct1_s4; +STATIC_ASSERT (sizeof(rct1_s4) == 0x1F850C, "Improper struct size"); enum { RCT1_RIDE_TYPE_NULL = 255, @@ -689,6 +693,7 @@ typedef struct rct_track_td4 { uint8 pad_41[0x83]; uint16 start_track_data_AA_CF; // 0xC4 } PACKED rct_track_td4; // Information based off RCTTechDepot +STATIC_ASSERT (sizeof(rct_track_td4) == 0xC9, "Improper struct size"); enum { RCT1_SCENARIO_FLAG_0 = 1 << 0, diff --git a/src/ride/ride.c b/src/ride/ride.c index 07442377ac..162714fd54 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -5949,6 +5949,7 @@ foundRideEntry: uint16 type_name; uint16 number; } PACKED name_args; + STATIC_ASSERT (sizeof(name_args) == 4, "Improper struct size"); name_args.type_name = 2 + ride->type; name_args.number = 0; do { @@ -8520,6 +8521,7 @@ void ride_reset_all_names() uint16 type_name; uint16 number; } PACKED name_args; + STATIC_ASSERT (sizeof(name_args) == 4, "Improper struct size"); name_args.type_name = 2 + ride->type; name_args.number = 0; do { diff --git a/src/ride/ride.h b/src/ride/ride.h index 5f5dccc405..5d031efe28 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -29,6 +29,7 @@ typedef fixed16_2dp ride_rating; // integer. To create the ride rating 3.65 type RIDE_RATING(3,65) #define RIDE_RATING(whole, fraction) FIXED_2DP(whole, fraction) +#pragma pack(push, 1) // Used for return values, for functions that modify all three. typedef struct rating_tuple { @@ -36,6 +37,7 @@ typedef struct rating_tuple { ride_rating intensity; ride_rating nausea; } PACKED rating_tuple; +STATIC_ASSERT (sizeof(rating_tuple) == 6, "Improper struct size"); /** * Couples a ride type and subtype together. @@ -49,28 +51,33 @@ typedef struct ride_list_item { uint16 ride_type_and_entry; }; } PACKED ride_list_item; +STATIC_ASSERT (sizeof(ride_list_item) == 2, "Improper struct size"); typedef struct track_colour { uint8 main; uint8 additional; uint8 supports; } PACKED track_colour; +STATIC_ASSERT (sizeof(track_colour) == 3, "Improper struct size"); typedef struct vehicle_colour { uint8 main; uint8 additional_1; uint8 additional_2; } PACKED vehicle_colour; +STATIC_ASSERT (sizeof(vehicle_colour) == 3, "Improper struct size"); typedef struct track_colour_preset_list { uint8 count; track_colour list[256]; } PACKED track_colour_preset_list; +STATIC_ASSERT (sizeof(track_colour_preset_list) == (1 + 256 * 3), "Improper struct size"); typedef struct vehicle_colour_preset_list { uint8 count; vehicle_colour list[256]; } PACKED vehicle_colour_preset_list; +STATIC_ASSERT (sizeof(vehicle_colour_preset_list) == (1 + 256 * 3), "Improper struct size"); /** * Ride type structure. @@ -115,6 +122,7 @@ typedef struct rct_ride_entry { uint8 shop_item; // 0x1C0 uint8 shop_item_secondary; // 0x1C1 } PACKED rct_ride_entry; +STATIC_ASSERT (sizeof(rct_ride_entry) == 0x1c2, "Improper struct size"); /** * Ride structure. @@ -321,6 +329,7 @@ typedef struct rct_ride { uint16 queue_length[4]; // 0x200 uint8 pad_208[0x58]; } PACKED rct_ride; +STATIC_ASSERT (sizeof(rct_ride) == 0x260, "Improper struct size"); #define RIDE_MEASUREMENT_MAX_ITEMS 4800 @@ -341,6 +350,7 @@ typedef struct rct_ride_measurement { uint8 velocity[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x258C uint8 altitude[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x384C } PACKED rct_ride_measurement; +STATIC_ASSERT (sizeof(rct_ride_measurement) == 0x4b0c, "Improper struct size"); typedef struct track_begin_end { int begin_x; @@ -353,6 +363,9 @@ typedef struct track_begin_end { int end_direction; rct_map_element *end_element; } PACKED track_begin_end; +STATIC_ASSERT (sizeof(track_begin_end) == 36, "Improper struct size"); + +#pragma pack(pop) enum { RIDE_CLASS_RIDE, diff --git a/src/ride/track.h b/src/ride/track.h index 6333f6bde9..af072464a3 100644 --- a/src/ride/track.h +++ b/src/ride/track.h @@ -30,6 +30,7 @@ typedef struct rct_trackdefinition { uint8 special; uint8 pad[2]; } PACKED rct_trackdefinition; +STATIC_ASSERT (sizeof(rct_trackdefinition) == 8, "Improper struct size"); /** * Size: 0x0A diff --git a/src/ride/track_design.h b/src/ride/track_design.h index e55390c612..f923bf88c0 100644 --- a/src/ride/track_design.h +++ b/src/ride/track_design.h @@ -41,12 +41,14 @@ typedef struct rct_td6_maze_element { } PACKED; }; } PACKED rct_td6_maze_element; +STATIC_ASSERT (sizeof(rct_td6_maze_element) == 0x04, "Improper struct size"); /* Track Element entry size: 0x02 */ typedef struct rct_td6_track_element { uint8 type; // 0x00 uint8 flags; // 0x01 } PACKED rct_td6_track_element; +STATIC_ASSERT (sizeof(rct_td6_track_element) == 0x02, "Improper struct size"); /* Track Entrance entry size: 0x06 */ typedef struct rct_td6_entrance_element { @@ -55,6 +57,7 @@ typedef struct rct_td6_entrance_element { sint16 x; // 0x02 sint16 y; // 0x04 } PACKED rct_td6_entrance_element; +STATIC_ASSERT (sizeof(rct_td6_entrance_element) == 0x06, "Improper struct size"); /* Track Scenery entry size: 0x16 */ typedef struct rct_td6_scenery_element { @@ -66,6 +69,7 @@ typedef struct rct_td6_scenery_element { uint8 primary_colour; // 0x14 uint8 secondary_colour; // 0x15 } PACKED rct_td6_scenery_element; +STATIC_ASSERT (sizeof(rct_td6_scenery_element) == 0x16, "Improper struct size"); /** * Track design structure. @@ -141,11 +145,8 @@ typedef struct rct_track_td6 { utf8 *name; } PACKED rct_track_td6; - -typedef struct rct_track_design { - rct_track_td6 track_td6; - uint8 preview[4][TRACK_PREVIEW_IMAGE_SIZE]; // 0xA3 -} PACKED rct_track_design; +//Warning: improper struct size in comment +STATIC_ASSERT (sizeof(rct_track_td6) == 0xbf, "Improper struct size"); typedef struct track_design_file_ref { utf8 *name; diff --git a/src/ride/track_design_index.c b/src/ride/track_design_index.c index dddbdd8219..b19888c19b 100644 --- a/src/ride/track_design_index.c +++ b/src/ride/track_design_index.c @@ -28,6 +28,9 @@ typedef struct td_index_item { char ride_entry[9]; utf8 path[MAX_PATH]; } PACKED td_index_item; +// NOTE: this is our own struct and should not get packed, but it is stored in a file +// so removing packing from it would require refactoring file access +STATIC_ASSERT (sizeof(td_index_item) == 1 + 9 + 260, "Improper struct size"); static bool track_design_index_read_header(SDL_RWops *file, uint32 *tdidxCount); static void track_design_index_scan(); diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 333702d636..7c74f8c322 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -1886,6 +1886,7 @@ typedef struct rct_synchronised_vehicle { uint8 station_id; uint16 vehicle_id; } PACKED rct_synchronised_vehicle; +STATIC_ASSERT (sizeof(rct_synchronised_vehicle) == 4, "Improper struct size"); // 8 synchronised vehicle info rct_synchronised_vehicle *_synchronisedVehicles = (rct_synchronised_vehicle*)0x00F64E4C; diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index ee3552e0dd..a656206fa3 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -24,6 +24,7 @@ typedef struct rct_vehicle_colour { uint8 body_colour; uint8 trim_colour; } PACKED rct_vehicle_colour; +STATIC_ASSERT (sizeof(rct_vehicle_colour) == 2, "Improper struct size"); /** * Ride type vehicle structure. @@ -75,6 +76,7 @@ typedef struct rct_ride_entry_vehicle { uint8 special_frames; // 0x60 , 0x7A sint8* peep_loading_positions; // 0x61 , 0x7B } PACKED rct_ride_entry_vehicle; +STATIC_ASSERT (sizeof(rct_ride_entry_vehicle) == 0x65, "Improper struct size"); typedef struct rct_vehicle { uint8 sprite_identifier; // 0x00 @@ -193,6 +195,7 @@ typedef struct rct_vehicle { uint8 seat_rotation; // 0xD8 uint8 target_seat_rotation; // 0xD9 } PACKED rct_vehicle; +STATIC_ASSERT (sizeof(rct_vehicle) == 0xDA, "Improper struct size"); typedef struct train_ref { rct_vehicle *head; diff --git a/src/scenario.h b/src/scenario.h index b044a00454..c594a6996d 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -41,6 +41,7 @@ typedef struct rct_s6_header { uint32 magic_number; // 0x08 uint8 pad_0C[0x14]; } PACKED rct_s6_header; +STATIC_ASSERT (sizeof(rct_s6_header) == 0x20, "Improper struct size"); /** * SC6 information chunk @@ -58,6 +59,7 @@ typedef struct rct_s6_info { char details[256]; // 0x88 rct_object_entry entry; // 0x188 } PACKED rct_s6_info; +STATIC_ASSERT (sizeof(rct_s6_info) == 0x198, "Improper struct size"); /** * Scenario scores file header. @@ -69,6 +71,7 @@ typedef struct rct_scenario_scores_header { uint32 var_8; uint32 scenario_count; // 0x0C } PACKED rct_scenario_scores_header; +STATIC_ASSERT (sizeof(rct_scenario_scores_header) == 16, "Improper struct size"); typedef enum scenario_source { SCENARIO_SOURCE_RCT1, @@ -101,6 +104,7 @@ typedef struct rct_scenario_basic { // uint8 source_game; // new in OpenRCT2 // sint16 source_index; // new in OpenRCT2 } PACKED rct_scenario_basic; +STATIC_ASSERT (sizeof(rct_scenario_basic) == 0x02B0, "Improper struct size"); typedef struct rct_stex_entry { rct_string_id scenario_name; // 0x00 @@ -108,6 +112,7 @@ typedef struct rct_stex_entry { rct_string_id details; // 0x04 uint8 var_06; } PACKED rct_stex_entry; +STATIC_ASSERT (sizeof(rct_stex_entry) == 7, "Improper struct size"); #define g_stexEntries ((rct_stex_entry**)object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].chunks) @@ -387,6 +392,8 @@ typedef struct scenario_highscore_entry { money32 company_value; datetime64 timestamp; } PACKED scenario_highscore_entry; +// NOTE: Check if needed +STATIC_ASSERT (sizeof(scenario_highscore_entry) == 20, "Improper struct size"); typedef struct scenario_index_entry { utf8 path[MAX_PATH]; diff --git a/src/util/sawyercoding.h b/src/util/sawyercoding.h index da0dc35446..6cc147e683 100644 --- a/src/util/sawyercoding.h +++ b/src/util/sawyercoding.h @@ -24,6 +24,7 @@ typedef struct sawyercoding_chunk_header { uint8 encoding; uint32 length; } PACKED sawyercoding_chunk_header; +STATIC_ASSERT (sizeof(sawyercoding_chunk_header) == 5, "Improper struct size"); enum { CHUNK_ENCODING_NONE, diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index f20489cbaa..b8affa2214 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -448,6 +448,7 @@ union { uint32 b; } PACKED; } _enabledRidePieces; +STATIC_ASSERT (sizeof(_enabledRidePieces) == 8, "Improper struct size"); static bool _trackPlaceCtrlState; static int _trackPlaceCtrlZ; diff --git a/src/world/banner.h b/src/world/banner.h index 1af945f82c..400d1f4b3b 100644 --- a/src/world/banner.h +++ b/src/world/banner.h @@ -32,6 +32,7 @@ typedef struct rct_banner { uint8 x; //0x06 uint8 y; //0x07 } PACKED rct_banner; +STATIC_ASSERT (sizeof(rct_banner) == 8, "Improper struct size"); enum{ BANNER_FLAG_NO_ENTRY = (1 << 0), diff --git a/src/world/entrance.h b/src/world/entrance.h index 9054e83dd1..0ef25f3ddf 100644 --- a/src/world/entrance.h +++ b/src/world/entrance.h @@ -25,5 +25,6 @@ typedef struct rct_entrance_type { uint8 scrolling_mode; // 0x06 uint8 text_height; // 0x07 } PACKED rct_entrance_type; +STATIC_ASSERT (sizeof(rct_entrance_type) == 8, "Improper struct size"); #endif diff --git a/src/world/footpath.h b/src/world/footpath.h index 9f8610aada..19fd13a26e 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -34,6 +34,7 @@ typedef struct rct_footpath_entry { uint8 var_0A; uint8 flags; // 0x0B } PACKED rct_footpath_entry; +STATIC_ASSERT (sizeof(rct_footpath_entry) == 12, "Improper struct size"); enum { FOOTPATH_SEARCH_SUCCESS, diff --git a/src/world/map.h b/src/world/map.h index 3ff512f6b7..570825871c 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -25,6 +25,7 @@ typedef struct rct_map_element_surface_properties { uint8 grass_length; //6 uint8 ownership; //7 } PACKED rct_map_element_surface_properties; +STATIC_ASSERT (sizeof(rct_map_element_surface_properties) == 4, "Improper struct size"); typedef struct rct_map_element_path_properties { uint8 type; //4 0xF0 Path type, 0x08 Unknown/Unused, 0x04 Set when path is diagonal, 0x03 Rotation @@ -35,6 +36,7 @@ typedef struct rct_map_element_path_properties { uint8 ride_index; }; } PACKED rct_map_element_path_properties; +STATIC_ASSERT (sizeof(rct_map_element_path_properties) == 4, "Improper struct size"); typedef struct rct_map_element_track_properties { uint8 type; //4 @@ -47,6 +49,7 @@ typedef struct rct_map_element_track_properties { }; uint8 ride_index; //7 } PACKED rct_map_element_track_properties; +STATIC_ASSERT (sizeof(rct_map_element_track_properties) == 4, "Improper struct size"); typedef struct rct_map_element_scenery_properties { uint8 type; //4 @@ -54,6 +57,7 @@ typedef struct rct_map_element_scenery_properties { uint8 colour_1; //6 uint8 colour_2; //7 } PACKED rct_map_element_scenery_properties; +STATIC_ASSERT (sizeof(rct_map_element_scenery_properties) == 4, "Improper struct size"); typedef struct rct_map_element_entrance_properties { uint8 type; //4 @@ -61,16 +65,19 @@ typedef struct rct_map_element_entrance_properties { uint8 path_type; //6 uint8 ride_index; //7 } PACKED rct_map_element_entrance_properties; +STATIC_ASSERT (sizeof(rct_map_element_entrance_properties) == 4, "Improper struct size"); typedef struct rct_map_element_fence_properties { uint8 type; //4 uint8 item[3]; //5 } PACKED rct_map_element_fence_properties; +STATIC_ASSERT (sizeof(rct_map_element_fence_properties) == 4, "Improper struct size"); typedef struct rct_map_element_scenerymultiple_properties { uint16 type; //4 uint8 colour[2]; //6 } PACKED rct_map_element_scenerymultiple_properties; +STATIC_ASSERT (sizeof(rct_map_element_scenerymultiple_properties) == 4, "Improper struct size"); typedef struct rct_map_element_banner_properties { uint8 index; //4 @@ -78,6 +85,7 @@ typedef struct rct_map_element_banner_properties { uint8 flags; //6 uint8 unused; //7 } PACKED rct_map_element_banner_properties; +STATIC_ASSERT (sizeof(rct_map_element_banner_properties) == 4, "Improper struct size"); typedef union { rct_map_element_surface_properties surface; @@ -89,6 +97,7 @@ typedef union { rct_map_element_scenerymultiple_properties scenerymultiple; rct_map_element_banner_properties banner; } rct_map_element_properties; +STATIC_ASSERT (sizeof(rct_map_element_properties) == 4, "Improper struct size"); /** * Map element structure @@ -101,6 +110,7 @@ typedef struct rct_map_element { uint8 clearance_height; //3 rct_map_element_properties properties; } PACKED rct_map_element; +STATIC_ASSERT (sizeof(rct_map_element) == 8, "Improper struct size"); enum { MAP_ELEMENT_QUADRANT_SW, @@ -237,27 +247,33 @@ typedef struct rct_xy8 { uint16 xy; }; } PACKED rct_xy8; +STATIC_ASSERT (sizeof(rct_xy8) == 2, "Improper struct size"); typedef struct rct_xyz8 { uint8 x, y, z; } PACKED rct_xyz8; +STATIC_ASSERT (sizeof(rct_xyz8) == 3, "Improper struct size"); typedef struct rct_xyzd8 { uint8 x, y, z, direction; } PACKED rct_xyzd8; +STATIC_ASSERT (sizeof(rct_xyzd8) == 4, "Improper struct size"); typedef struct rct_xy16 { sint16 x, y; } PACKED rct_xy16; +STATIC_ASSERT (sizeof(rct_xy16) == 4, "Improper struct size"); typedef struct rct_xyz16 { sint16 x, y, z; } PACKED rct_xyz16; +STATIC_ASSERT (sizeof(rct_xyz16) == 6, "Improper struct size"); typedef struct rct_xy_element { int x, y; rct_map_element *element; } PACKED rct_xy_element; +STATIC_ASSERT (sizeof(rct_xy_element) == 12, "Improper struct size"); typedef struct rct2_peep_spawn { uint16 x; @@ -265,6 +281,7 @@ typedef struct rct2_peep_spawn { uint8 z; uint8 direction; } PACKED rct2_peep_spawn; +STATIC_ASSERT (sizeof(rct2_peep_spawn) == 6, "Improper struct size"); enum { MAP_SELECT_FLAG_ENABLE = 1 << 0, @@ -421,6 +438,7 @@ typedef struct map_element_iterator { int y; rct_map_element *element; } PACKED map_element_iterator; +STATIC_ASSERT (sizeof(map_element_iterator) == 12, "Improper struct size"); void map_element_iterator_begin(map_element_iterator *it); int map_element_iterator_next(map_element_iterator *it); diff --git a/src/world/map_animation.h b/src/world/map_animation.h index 0579b65788..8f38157fd4 100644 --- a/src/world/map_animation.h +++ b/src/world/map_animation.h @@ -29,6 +29,7 @@ typedef struct rct_map_animation { uint16 x; uint16 y; } PACKED rct_map_animation; +STATIC_ASSERT (sizeof(rct_map_animation) == 6, "Improper struct size"); enum { MAP_ANIMATION_TYPE_RIDE_ENTRANCE, diff --git a/src/world/scenery.h b/src/world/scenery.h index b3fee27b6a..adf11de83a 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -33,6 +33,7 @@ typedef struct rct_small_scenery_entry { uint16 var_18; uint8 scenery_tab_id; // 0x1A } PACKED rct_small_scenery_entry; +STATIC_ASSERT (sizeof(rct_small_scenery_entry) == 21, "Improper struct size"); typedef enum { SMALL_SCENERY_FLAG_FULL_TILE = (1 << 0), // 0x1 @@ -72,6 +73,7 @@ typedef struct rct_large_scenery_tile { uint8 z_clearance; uint16 var_7; } PACKED rct_large_scenery_tile; +STATIC_ASSERT (sizeof(rct_large_scenery_tile) == 9, "Improper struct size"); typedef struct rct_large_scenery_text_glyph { uint8 image_offset; @@ -79,6 +81,7 @@ typedef struct rct_large_scenery_text_glyph { uint8 height; uint8 var_3; } PACKED rct_large_scenery_text_glyph; +STATIC_ASSERT (sizeof(rct_large_scenery_text_glyph) == 4, "Improper struct size"); typedef struct rct_large_scenery_text { rct_xy16 offset[2]; // 0x0 @@ -87,6 +90,7 @@ typedef struct rct_large_scenery_text { uint16 var_C; // 0xC rct_large_scenery_text_glyph glyphs[256]; // 0xE } PACKED rct_large_scenery_text; +STATIC_ASSERT (sizeof(rct_large_scenery_text) == 14 + 4 * 256, "Improper struct size"); typedef struct rct_large_scenery_entry { uint8 tool_id; // 0x06 @@ -99,6 +103,7 @@ typedef struct rct_large_scenery_entry { rct_large_scenery_text* text; // 0x12 uint32 text_image; // 0x16 } PACKED rct_large_scenery_entry; +STATIC_ASSERT (sizeof(rct_large_scenery_entry) == 20, "Improper struct size"); typedef struct rct_wall_scenery_entry { @@ -110,6 +115,7 @@ typedef struct rct_wall_scenery_entry { uint8 scenery_tab_id; // 0x0C uint8 var_0D; } PACKED rct_wall_scenery_entry; +STATIC_ASSERT (sizeof(rct_wall_scenery_entry) == 8, "Improper struct size"); typedef enum { WALL_SCENERY_FLAG1 = (1 << 0), // 0x1 @@ -133,6 +139,7 @@ typedef struct rct_path_bit_scenery_entry { sint16 price; // 0x0A uint8 scenery_tab_id; // 0x0C } PACKED rct_path_bit_scenery_entry; +STATIC_ASSERT (sizeof(rct_path_bit_scenery_entry) == 7, "Improper struct size"); typedef struct rct_banner_scenery_entry { uint8 scrolling_mode; // 0x06 @@ -140,6 +147,7 @@ typedef struct rct_banner_scenery_entry { sint16 price; // 0x08 uint8 scenery_tab_id; // 0x0A } PACKED rct_banner_scenery_entry; +STATIC_ASSERT (sizeof(rct_banner_scenery_entry) == 5, "Improper struct size"); typedef struct rct_scenery_entry { rct_string_id name; // 0x00 @@ -152,6 +160,7 @@ typedef struct rct_scenery_entry { rct_banner_scenery_entry banner; }; } PACKED rct_scenery_entry; +STATIC_ASSERT (sizeof(rct_scenery_entry) == 6 + 21, "Improper struct size"); typedef struct rct_scenery_set_entry { rct_string_id name; // 0x00 @@ -163,6 +172,7 @@ typedef struct rct_scenery_set_entry { uint8 pad_109; uint32 var_10A; } PACKED rct_scenery_set_entry; +STATIC_ASSERT (sizeof(rct_scenery_set_entry) == 14 + 2 * 0x80, "Improper struct size"); enum { PATH_BIT_FLAG_BIN = 1 << 0, diff --git a/src/world/sprite.h b/src/world/sprite.h index e1d1e14d43..ca9b711ae2 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -75,6 +75,7 @@ typedef struct rct_unk_sprite { uint8 pad_2C[0x45]; uint8 var_71; } PACKED rct_unk_sprite; +STATIC_ASSERT (sizeof(rct_unk_sprite) == 0x72, "Improper struct size"); typedef struct rct_litter { uint8 sprite_identifier; // 0x00 @@ -96,6 +97,7 @@ typedef struct rct_litter { uint8 pad_1F[5]; uint32 creationTick; // 0x24 } PACKED rct_litter; +STATIC_ASSERT (sizeof(rct_litter) == 0x28, "Improper struct size"); typedef struct rct_balloon { uint8 sprite_identifier; // 0x00 @@ -125,6 +127,7 @@ typedef struct rct_balloon { uint8 colour; // 0x2C uint8 var_2D; } PACKED rct_balloon; +STATIC_ASSERT (sizeof(rct_balloon) == 0x2e, "Improper struct size"); typedef struct rct_duck { uint8 sprite_identifier; // 0x00 @@ -151,6 +154,7 @@ typedef struct rct_duck { uint8 pad_34[0x14]; uint8 state; // 0x48 } PACKED rct_duck; +STATIC_ASSERT (sizeof(rct_duck) == 0x49, "Improper struct size"); typedef struct rct_jumping_fountain { uint8 sprite_identifier; // 0x00 @@ -185,6 +189,7 @@ typedef struct rct_jumping_fountain { uint8 pad_34[0x12]; uint16 iteration; // 0x46 } PACKED rct_jumping_fountain; +STATIC_ASSERT (sizeof(rct_jumping_fountain) == 0x48, "Improper struct size"); typedef struct rct_money_effect { uint8 sprite_identifier; // 0x00 @@ -209,6 +214,7 @@ typedef struct rct_money_effect { sint16 offset_x; // 0x44 uint16 wiggle; // 0x46 } PACKED rct_money_effect; +STATIC_ASSERT (sizeof(rct_money_effect) == 0x48, "Improper struct size"); typedef struct rct_crashed_vehicle_particle { uint8 sprite_identifier; // 0x00 @@ -251,6 +257,7 @@ typedef struct rct_crashed_vehicle_particle { uint8 pad_44[0x2D]; uint8 var_71; } PACKED rct_crashed_vehicle_particle; +STATIC_ASSERT (sizeof(rct_crashed_vehicle_particle) == 0x45 + 0x2D, "Improper struct size"); typedef struct rct_crash_splash { uint8 sprite_identifier; // 0x00 @@ -280,6 +287,7 @@ typedef struct rct_crash_splash { uint16 var_24; uint16 frame; // 0x26 } PACKED rct_crash_splash; +STATIC_ASSERT (sizeof(rct_crash_splash) == 0x28, "Improper struct size"); typedef struct rct_steam_particle { uint8 sprite_identifier; // 0x00 @@ -309,6 +317,7 @@ typedef struct rct_steam_particle { uint16 var_24; uint16 frame; // 0x26 } PACKED rct_steam_particle; +STATIC_ASSERT (sizeof(rct_steam_particle) == 0x28, "Improper struct size"); /** * Sprite structure. @@ -328,6 +337,7 @@ typedef union { rct_crash_splash crash_splash; rct_steam_particle steam_particle; } rct_sprite; +STATIC_ASSERT (sizeof(rct_sprite) == 0x100, "Improper struct size"); typedef struct rct_sprite_bounds { uint8 sprite_width; // 0x00 @@ -335,16 +345,19 @@ typedef struct rct_sprite_bounds { uint8 sprite_height_positive; // 0x02 uint8 unused; // 0x03 } PACKED rct_sprite_bounds; +STATIC_ASSERT (sizeof(rct_sprite_bounds) == 4, "Improper struct size"); typedef struct rct_sprite_image { uint32 base_image; // 0x00 uint8* unkn_04; // 0x04 } PACKED rct_sprite_image; +STATIC_ASSERT (sizeof(rct_sprite_image) == 8, "Improper struct size"); typedef struct rct_sprite_entry { rct_sprite_image *sprite_image; // 0x00 rct_sprite_bounds *sprite_bounds; // 0x04 } PACKED rct_sprite_entry; +STATIC_ASSERT (sizeof(rct_sprite_entry) == 8, "Improper struct size"); enum { SPRITE_MISC_STEAM_PARTICLE, diff --git a/src/world/water.h b/src/world/water.h index 7dc545337a..f67b05d499 100644 --- a/src/world/water.h +++ b/src/world/water.h @@ -26,5 +26,6 @@ typedef struct rct_water_type { uint32 var_0A; uint16 var_0E; } PACKED rct_water_type; +STATIC_ASSERT (sizeof(rct_water_type) == 16, "Improper struct size"); #endif From 60630b9ad7f98d90dc92573d9a2f4f0a00ab0500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 2 Jun 2016 23:22:08 +0200 Subject: [PATCH 3/5] Drop `PACKED` attribute --- src/addresses.h | 10 +-- src/audio/audio.c | 2 +- src/audio/audio.h | 12 +-- src/audio/mixer.cpp | 8 +- src/audio/mixer.h | 2 +- src/cmdline/CommandLine.hpp | 6 +- src/cmdline_sprite.c | 22 +++-- src/core/Nullable.hpp | 2 +- src/core/stopwatch.h | 2 +- src/core/textinputbuffer.h | 2 +- src/drawing/drawing.h | 15 ++-- src/drawing/font.h | 4 +- src/drawing/string.c | 6 +- src/input.c | 2 +- src/input.h | 2 +- src/interface/Theme.cpp | 8 +- src/interface/colour.h | 8 +- src/interface/console.c | 2 +- src/interface/viewport.h | 2 +- src/interface/window.h | 32 +++---- src/localisation/LanguagePack.h | 6 +- src/localisation/convert.c | 2 +- src/localisation/currency.h | 2 +- src/localisation/date.h | 2 +- src/localisation/language.h | 2 +- src/localisation/localisation.c | 2 +- src/management/award.h | 4 +- src/management/news_item.h | 4 +- src/management/research.h | 4 +- src/network/NetworkTypes.h | 6 +- src/network/http.cpp | 6 +- src/network/http.h | 4 +- src/network/network.h | 2 +- src/network/twitch.cpp | 2 +- src/object.h | 12 +-- src/object_list.c | 4 +- src/paint/map_element/scenery_multiple.c | 2 +- src/paint/map_element/surface.c | 4 +- src/paint/paint.h | 10 ++- src/paint/supports.c | 10 +-- src/peep/peep.c | 2 +- src/peep/peep.h | 10 ++- src/rct1.h | 106 ++++++++++++----------- src/rct2.h | 9 +- src/ride/gentle/crooked_house.c | 2 +- src/ride/gentle/ferris_wheel.c | 2 +- src/ride/gentle/haunted_house.c | 2 +- src/ride/ride.c | 8 +- src/ride/ride.h | 28 +++--- src/ride/ride_data.h | 14 +-- src/ride/thrill/magic_carpet.c | 2 +- src/ride/thrill/pirate_ship.c | 2 +- src/ride/thrill/swinging_inverter_ship.c | 2 +- src/ride/track.h | 10 ++- src/ride/track_data.h | 6 +- src/ride/track_design.c | 2 +- src/ride/track_design.h | 18 ++-- src/ride/track_design_index.c | 4 +- src/ride/track_design_save.c | 2 +- src/ride/vehicle.c | 4 +- src/ride/vehicle.h | 16 ++-- src/ride/vehicle_paint.h | 2 +- src/scenario.h | 23 +++-- src/util/sawyercoding.h | 4 +- src/windows/editor_object_selection.c | 2 +- src/windows/loadsave.c | 2 +- src/windows/news_options.c | 2 +- src/windows/ride.c | 4 +- src/windows/ride_construction.c | 4 +- src/windows/scenery.c | 2 +- src/windows/title_command_editor.c | 2 +- src/windows/title_scenarioselect.c | 4 +- src/world/banner.h | 4 +- src/world/climate.c | 5 +- src/world/climate.h | 5 +- src/world/entrance.h | 4 +- src/world/footpath.c | 4 +- src/world/footpath.h | 4 +- src/world/map.h | 42 +++++---- src/world/map_animation.h | 4 +- src/world/scenery.h | 22 ++--- src/world/sprite.h | 30 ++++--- src/world/water.h | 4 +- 83 files changed, 370 insertions(+), 299 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 77b8a0f301..86670606d9 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -668,7 +668,7 @@ typedef struct registers { struct { char al; char ah; - } PACKED; + }; }; union { int ebx; @@ -676,7 +676,7 @@ typedef struct registers { struct { char bl; char bh; - } PACKED; + }; }; union { int ecx; @@ -684,7 +684,7 @@ typedef struct registers { struct { char cl; char ch; - } PACKED; + }; }; union { int edx; @@ -692,7 +692,7 @@ typedef struct registers { struct { char dl; char dh; - } PACKED; + }; }; union { int esi; @@ -706,7 +706,7 @@ typedef struct registers { int ebp; short bp; }; -} PACKED registers; +} registers; STATIC_ASSERT (sizeof(registers) == 7 * 4, "Improper struct size"); diff --git a/src/audio/audio.c b/src/audio/audio.c index 95dbe006dc..19e3a84354 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -32,7 +32,7 @@ typedef struct rct_audio_params { bool in_range; int volume; int pan; -} PACKED rct_audio_params; +} rct_audio_params; audio_device *gAudioDevices = NULL; int gAudioDeviceCount; diff --git a/src/audio/audio.h b/src/audio/audio.h index 2f084e6011..ed4015d38b 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -29,7 +29,7 @@ typedef struct audio_device { char name[AUDIO_DEVICE_NAME_SIZE]; -} PACKED audio_device; +} audio_device; #pragma pack(push, 1) @@ -40,7 +40,7 @@ typedef struct rct_ride_music { sint16 pan; uint16 frequency; void* sound_channel; -} PACKED rct_ride_music; +} rct_ride_music; STATIC_ASSERT (sizeof(rct_ride_music) == 12, "Improper struct size"); @@ -49,7 +49,7 @@ typedef struct rct_ride_music_info { uint32 offset; uint8 path_id; uint8 var_9; -} PACKED rct_ride_music_info; +} rct_ride_music_info; STATIC_ASSERT (sizeof(rct_ride_music_info) == 10, "Improper struct size"); @@ -60,7 +60,7 @@ typedef struct rct_ride_music_params { sint16 volume; sint16 pan; uint16 frequency; -} PACKED rct_ride_music_params; +} rct_ride_music_params; STATIC_ASSERT (sizeof(rct_ride_music_params) == 12, "Improper struct size"); @@ -77,7 +77,7 @@ typedef struct rct_vehicle_sound { uint16 sound2_freq; void* sound1_channel; void* sound2_channel; -} PACKED rct_vehicle_sound; +} rct_vehicle_sound; STATIC_ASSERT (sizeof(rct_vehicle_sound) == 28, "Improper struct size"); @@ -88,7 +88,7 @@ typedef struct rct_vehicle_sound_params { uint16 frequency; sint16 volume; uint16 var_A; -} PACKED rct_vehicle_sound_params; +} rct_vehicle_sound_params; STATIC_ASSERT (sizeof(rct_vehicle_sound_params) == 12, "Improper struct size"); diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index 448345d743..a2bfb3ba6b 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -137,6 +137,7 @@ bool Source_Sample::LoadCSS1(const char *filename, unsigned int offset) Uint32 soundsize; SDL_RWread(rw, &soundsize, sizeof(soundsize), 1); length = soundsize; +#pragma pack(push, 1) struct WaveFormatEx { Uint16 encoding; @@ -146,7 +147,8 @@ bool Source_Sample::LoadCSS1(const char *filename, unsigned int offset) Uint16 blockalign; Uint16 bitspersample; Uint16 extrasize; - } PACKED waveformat; + } waveformat; +#pragma pack(pop) STATIC_ASSERT (sizeof(waveformat) == 18, "Improper struct size"); SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); format.freq = waveformat.frequency; @@ -263,6 +265,7 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw) return false; } Uint64 chunkstart = SDL_RWtell(rw); +#pragma pack(push, 1) struct WaveFormat { Uint16 encoding; @@ -271,7 +274,8 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw) Uint32 byterate; Uint16 blockalign; Uint16 bitspersample; - } PACKED waveformat; + } waveformat; +#pragma pack(pop) STATIC_ASSERT (sizeof(waveformat) == 16, "Improper struct size"); SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); SDL_RWseek(rw, chunkstart + fmtchunk_size, RW_SEEK_SET); diff --git a/src/audio/mixer.h b/src/audio/mixer.h index b2097a01f2..947ef1de5b 100644 --- a/src/audio/mixer.h +++ b/src/audio/mixer.h @@ -48,7 +48,7 @@ typedef struct AudioFormat { int freq; SDL_AudioFormat format; int channels; -} PACKED AudioFormat; +} AudioFormat; class Source { diff --git a/src/cmdline/CommandLine.hpp b/src/cmdline/CommandLine.hpp index 1633dc6a69..52b96ae297 100644 --- a/src/cmdline/CommandLine.hpp +++ b/src/cmdline/CommandLine.hpp @@ -60,7 +60,7 @@ struct CommandLineExample { const char * Arguments; const char * Description; -} PACKED; +}; struct CommandLineOptionDefinition { @@ -69,7 +69,7 @@ struct CommandLineOptionDefinition char ShortName; const char * LongName; const char * Description; -} PACKED; +}; struct CommandLineCommand { @@ -78,7 +78,7 @@ struct CommandLineCommand const CommandLineOptionDefinition * Options; const CommandLineCommand * SubCommands; CommandLineFunc Func; -} PACKED; +}; enum { diff --git a/src/cmdline_sprite.c b/src/cmdline_sprite.c index c74d006029..9e278adcf7 100644 --- a/src/cmdline_sprite.c +++ b/src/cmdline_sprite.c @@ -26,16 +26,27 @@ extern int gSpriteMode; +#pragma pack(push, 1) + typedef struct rct_sprite_file_header { uint32 num_entries; uint32 total_size; -} PACKED rct_sprite_file_header; +} rct_sprite_file_header; STATIC_ASSERT (sizeof(rct_sprite_file_header) == 8, "Improper struct size"); typedef struct rct_sprite_file_palette_entry { uint8 b, g, r, a; -} PACKED rct_sprite_file_palette_entry; +} rct_sprite_file_palette_entry; + +typedef struct rle_code { + uint8 num_pixels; + uint8 offset_x; +} rle_code; + +STATIC_ASSERT (sizeof(rle_code) == 2, "Improper struct size"); + +#pragma pack(pop) STATIC_ASSERT (sizeof(rct_sprite_file_palette_entry) == 4, "Improper struct size"); @@ -235,13 +246,6 @@ int get_palette_index(sint16 *colour) return -1; } -typedef struct rle_code { - uint8 num_pixels; - uint8 offset_x; -} PACKED rle_code; - -STATIC_ASSERT (sizeof(rle_code) == 2, "Improper struct size"); - bool sprite_file_import(const char *path, rct_g1_element *outElement, uint8 **outBuffer, int *outBufferLength, int mode) { uint8 *pixels; diff --git a/src/core/Nullable.hpp b/src/core/Nullable.hpp index e03d8a4fc2..869d6d8ebe 100644 --- a/src/core/Nullable.hpp +++ b/src/core/Nullable.hpp @@ -58,4 +58,4 @@ public: private: T _value; bool _hasValue; -} PACKED; +}; diff --git a/src/core/stopwatch.h b/src/core/stopwatch.h index 995bb36bb1..56aa1a3c52 100644 --- a/src/core/stopwatch.h +++ b/src/core/stopwatch.h @@ -25,7 +25,7 @@ typedef struct stopwatch { void *context; -} PACKED stopwatch; +} stopwatch; void stopwatch_create(stopwatch *stopwatch); void stopwatch_dispose(stopwatch *stopwatch); diff --git a/src/core/textinputbuffer.h b/src/core/textinputbuffer.h index a0180af66b..787473609f 100644 --- a/src/core/textinputbuffer.h +++ b/src/core/textinputbuffer.h @@ -28,7 +28,7 @@ typedef struct textinputbuffer { size_t selection_offset; // Selection start, in bytes size_t selection_size; // Selection length in bytes -} PACKED textinputbuffer; +} textinputbuffer; void textinputbuffer_init(textinputbuffer * tib, utf8 * buffer, size_t size); void textinputbuffer_clear(textinputbuffer * tib); diff --git a/src/drawing/drawing.h b/src/drawing/drawing.h index 31944cf598..cc9a70274f 100644 --- a/src/drawing/drawing.h +++ b/src/drawing/drawing.h @@ -20,6 +20,7 @@ #include "../common.h" #include "font.h" +#pragma pack(push, 1) // Size: 0x10 typedef struct rct_drawpixelinfo { uint8* bits; // 0x00 @@ -29,7 +30,7 @@ typedef struct rct_drawpixelinfo { short height; // 0x0A short pitch; // 0x0C note: this is actually (pitch - width) uint16 zoom_level; // 0x0E -} PACKED rct_drawpixelinfo; +} rct_drawpixelinfo; STATIC_ASSERT (sizeof(rct_drawpixelinfo) == 0x10, "Improper struct size"); // Size: 0x10 @@ -41,7 +42,7 @@ typedef struct rct_g1_element { sint16 y_offset; // 0x0A uint16 flags; // 0x0C uint16 zoomed_offset; // 0x0E -} PACKED rct_g1_element; +} rct_g1_element; STATIC_ASSERT (sizeof(rct_g1_element) == 0x10, "Improper struct size"); enum { @@ -59,14 +60,14 @@ enum { typedef struct rct_g1_header { uint32 num_entries; uint32 total_size; -} PACKED rct_g1_header; +} rct_g1_header; STATIC_ASSERT (sizeof(rct_g1_header) == 8, "Improper struct size"); typedef struct rct_gx { rct_g1_header header; rct_g1_element *elements; void *data; -} PACKED rct_gx; +} rct_gx; STATIC_ASSERT (sizeof(rct_gx) == 16, "Improper struct size"); typedef struct rct_palette_entry { @@ -74,12 +75,14 @@ typedef struct rct_palette_entry { uint8 green; uint8 red; uint8 alpha; -} PACKED rct_palette_entry; +} rct_palette_entry; STATIC_ASSERT (sizeof(rct_palette_entry) == 4, "Improper struct size"); +#pragma pack(pop) + typedef struct rct_palette { rct_palette_entry entries[256]; -} PACKED rct_palette; +} rct_palette; #define SPRITE_ID_PALETTE_COLOUR_1(colourId) ((IMAGE_TYPE_USE_PALETTE << 28) | ((colourId) << 19)) diff --git a/src/drawing/font.h b/src/drawing/font.h index 79d9a37ad5..01321e6648 100644 --- a/src/drawing/font.h +++ b/src/drawing/font.h @@ -45,11 +45,11 @@ typedef struct TTFFontDescriptor { int offset_y; int line_height; TTF_Font *font; -} PACKED TTFFontDescriptor; +} TTFFontDescriptor; typedef struct TTFFontSetDescriptor { TTFFontDescriptor size[FONT_SIZE_COUNT]; -} PACKED TTFFontSetDescriptor; +} TTFFontSetDescriptor; extern TTFFontSetDescriptor *gCurrentTTFFontSet; diff --git a/src/drawing/string.c b/src/drawing/string.c index 259bfa62d0..12ee28304a 100644 --- a/src/drawing/string.c +++ b/src/drawing/string.c @@ -36,7 +36,7 @@ typedef struct ttf_cache_entry { TTF_Font *font; utf8 *text; uint32 lastUseTick; -} PACKED ttf_cache_entry; +} ttf_cache_entry; static ttf_cache_entry _ttfSurfaceCache[TTF_SURFACE_CACHE_SIZE] = { 0 }; static int _ttfSurfaceCacheCount = 0; @@ -48,7 +48,7 @@ typedef struct ttf_getwidth_cache_entry { TTF_Font *font; utf8 *text; uint32 lastUseTick; -} PACKED ttf_getwidth_cache_entry; +} ttf_getwidth_cache_entry; static ttf_getwidth_cache_entry _ttfGetWidthCache[TTF_GETWIDTH_CACHE_SIZE] = { 0 }; static int _ttfGetWidthCacheCount = 0; @@ -908,7 +908,7 @@ typedef struct text_draw_info { uint8 palette[8]; uint16 font_sprite_base; const sint8 *y_offset; -} PACKED text_draw_info; +} text_draw_info; static void ttf_draw_character_sprite(rct_drawpixelinfo *dpi, int codepoint, text_draw_info *info) { diff --git a/src/input.c b/src/input.c index e182cb6059..eb8a79b233 100644 --- a/src/input.c +++ b/src/input.c @@ -51,7 +51,7 @@ typedef struct rct_mouse_data { uint32 x; uint32 y; uint32 state; -} PACKED rct_mouse_data; +} rct_mouse_data; static rct_mouse_data _mouseInputQueue[64]; static uint8 _mouseInputQueueReadIndex = 0; diff --git a/src/input.h b/src/input.h index 3ddc772690..808a77276f 100644 --- a/src/input.h +++ b/src/input.h @@ -66,7 +66,7 @@ typedef struct widget_ref { rct_windowclass window_classification; rct_windownumber window_number; rct_widgetindex widget_index; -} PACKED widget_ref; +} widget_ref; extern uint8 gInputState; extern uint8 gInputFlags; diff --git a/src/interface/Theme.cpp b/src/interface/Theme.cpp index bc3ed6f147..fe19a8fd6e 100644 --- a/src/interface/Theme.cpp +++ b/src/interface/Theme.cpp @@ -43,7 +43,7 @@ constexpr uint64 MAX_THEME_SIZE = 64 * 1024 * 1024; struct WindowTheme { colour_t Colours[6]; -} PACKED; +}; /** * Represents the style for a particular type of window. @@ -56,7 +56,7 @@ struct UIThemeWindowEntry json_t * ToJson() const; static UIThemeWindowEntry FromJson(const WindowThemeDesc * wtDesc, const json_t * json); -} PACKED; +}; /** * Represents a user interface theme. Contains window colour schemes and appearance features. @@ -95,7 +95,7 @@ struct WindowThemeDesc rct_string_id WindowName; uint8 NumColours; WindowTheme DefaultTheme; -} PACKED; +}; #pragma region Window Theme Descriptors @@ -495,7 +495,7 @@ namespace ThemeManager { utf8 Path[MAX_PATH]; utf8 Name[96]; - } PACKED; + }; utf8 * CurrentThemePath; UITheme * CurrentTheme; diff --git a/src/interface/colour.h b/src/interface/colour.h index 63c8897e38..45bae54eae 100644 --- a/src/interface/colour.h +++ b/src/interface/colour.h @@ -70,6 +70,8 @@ enum { #define NUM_COLOURS 32 +#pragma pack(push, 1) + typedef struct rct_colour_map_a { uint8 darkest; uint8 darker; @@ -79,7 +81,7 @@ typedef struct rct_colour_map_a { uint8 light; uint8 lighter; uint8 lightest; -} PACKED rct_colour_map_a; +} rct_colour_map_a; STATIC_ASSERT (sizeof(rct_colour_map_a) == 8, "Improper struct size"); typedef struct rct_colour_map_b { @@ -91,9 +93,11 @@ typedef struct rct_colour_map_b { uint8 f; uint8 g; uint8 h; -} PACKED rct_colour_map_b; +} rct_colour_map_b; STATIC_ASSERT (sizeof(rct_colour_map_b) == 8, "Improper struct size"); +#pragma pack(pop) + extern rct_colour_map_a *ColourMapA; extern rct_colour_map_b *ColourMapB; diff --git a/src/interface/console.c b/src/interface/console.c index 520ef3023d..ccd5f03a3b 100644 --- a/src/interface/console.c +++ b/src/interface/console.c @@ -999,7 +999,7 @@ typedef struct console_command { console_command_func func; utf8 *help; utf8 *usage; -} PACKED console_command; +} console_command; utf8* console_variable_table[] = { "park_rating", diff --git a/src/interface/viewport.h b/src/interface/viewport.h index bfc4f07a72..d62b8caad4 100644 --- a/src/interface/viewport.h +++ b/src/interface/viewport.h @@ -82,7 +82,7 @@ typedef struct viewport_interaction_info { rct_peep *peep; rct_vehicle *vehicle; }; -} PACKED viewport_interaction_info; +} viewport_interaction_info; #define MAX_VIEWPORT_COUNT MAX_WINDOW_COUNT diff --git a/src/interface/window.h b/src/interface/window.h index e51aabee6f..7a4dc8cc78 100644 --- a/src/interface/window.h +++ b/src/interface/window.h @@ -45,12 +45,12 @@ typedef sint16 rct_widgetindex; typedef struct window_identifier { rct_windowclass classification; rct_windownumber number; -} PACKED window_identifier; +} window_identifier; typedef struct widget_identifier { window_identifier window; int widget_index; -} PACKED widget_identifier; +} widget_identifier; extern widget_identifier gCurrentTextBox; @@ -67,7 +67,7 @@ typedef struct rct_widget { sint16 bottom; // 0x08 uint32 image; // 0x0A uint16 tooltip; // 0x0E -} PACKED rct_widget; +} rct_widget; /** * Viewport structure @@ -85,7 +85,7 @@ typedef struct rct_viewport { uint8 zoom; // 0x10 uint8 var_11; uint16 flags; // 0x12 -} PACKED rct_viewport; +} rct_viewport; /** * Scroll structure @@ -101,7 +101,7 @@ typedef struct rct_scroll { uint16 v_bottom; // 0x0C uint16 v_thumb_top; // 0x0E uint16 v_thumb_bottom; // 0x10 -} PACKED rct_scroll; +} rct_scroll; /** * Viewport focus structure. @@ -115,7 +115,7 @@ typedef struct coordinate_focus { sint16 z; //0x486 uint8 rotation;//0x488 uint8 zoom;//0x489 -} PACKED coordinate_focus; +} coordinate_focus; // Type is viewport_target_sprite_id & 0x80000000 != 0 typedef struct sprite_focus { @@ -164,14 +164,14 @@ typedef struct rct_window_event_list { void (*invalidate)(struct rct_window*); void (*paint)(struct rct_window*, rct_drawpixelinfo*); void (*scroll_paint)(struct rct_window*, rct_drawpixelinfo*, int); -} PACKED rct_window_event_list; +} rct_window_event_list; typedef struct campaign_variables { sint16 campaign_type; sint16 no_weeks; //0x482 uint16 ride_id; //0x484 uint32 pad_486; -} PACKED campaign_variables; +} campaign_variables; typedef struct new_ride_variables { sint16 selected_ride_id; //0x480 @@ -179,7 +179,7 @@ typedef struct new_ride_variables { uint16 pad_484; uint16 pad_486; uint16 selected_ride_countdown; //488 -} PACKED new_ride_variables; +} new_ride_variables; typedef struct news_variables { sint16 var_480; @@ -187,7 +187,7 @@ typedef struct news_variables { uint16 var_484; uint16 var_486; uint16 var_488; -} PACKED news_variables; +} news_variables; typedef struct map_variables { sint16 rotation; @@ -195,28 +195,28 @@ typedef struct map_variables { uint16 var_484; uint16 var_486; uint16 var_488; -} PACKED map_variables; +} map_variables; typedef struct ride_variables { sint16 view; sint32 var_482; sint32 var_486; -} PACKED ride_variables; +} ride_variables; typedef struct scenery_variables { sint16 selected_scenery_id; sint16 hover_counter; -} PACKED scenery_variables; +} scenery_variables; typedef struct track_list_variables { uint16 var_480; uint16 var_484; bool reload_track_designs; -} PACKED track_list_variables; +} track_list_variables; typedef struct error_variables { uint16 var_480; -} PACKED error_variables; +} error_variables; /** * Window structure @@ -288,7 +288,7 @@ typedef struct rct_window { sint8 var_4B8; sint8 var_4B9; uint8 colours[6]; // 0x4BA -} PACKED rct_window; +} rct_window; #define RCT_WINDOW_RIGHT(w) (w->x + w->width) #define RCT_WINDOW_BOTTOM(w) (w->y + w->height) diff --git a/src/localisation/LanguagePack.h b/src/localisation/LanguagePack.h index 76bffdb295..0cd1966ec4 100644 --- a/src/localisation/LanguagePack.h +++ b/src/localisation/LanguagePack.h @@ -56,7 +56,7 @@ private: { char name[8]; const utf8 * strings[4]; - } PACKED; + }; struct ScenarioOverride { @@ -67,9 +67,9 @@ private: const utf8 * name; const utf8 * park; const utf8 * details; - } PACKED; + }; }; - } PACKED; + }; uint16 _id; utf8 * _stringData; diff --git a/src/localisation/convert.c b/src/localisation/convert.c index 9ce15a3b6e..9daca90bec 100644 --- a/src/localisation/convert.c +++ b/src/localisation/convert.c @@ -19,7 +19,7 @@ typedef struct encoding_convert_entry { uint16 code; uint16 unicode; -} PACKED encoding_convert_entry; +} encoding_convert_entry; static const encoding_convert_entry GB2312ToUnicodeTable[7445]; static const encoding_convert_entry Big5ToUnicodeTable[13710]; diff --git a/src/localisation/currency.h b/src/localisation/currency.h index 631dfea0cd..7c96eb8ab1 100644 --- a/src/localisation/currency.h +++ b/src/localisation/currency.h @@ -58,7 +58,7 @@ typedef struct currency_descriptor { uint8 affix_ascii; char symbol_ascii[CURRENCY_SYMBOL_MAX_SIZE]; rct_string_id stringId; -} PACKED currency_descriptor; +} currency_descriptor; // List of currency formats extern const currency_descriptor CurrencyDescriptors[CURRENCY_END]; diff --git a/src/localisation/date.h b/src/localisation/date.h index 05491335b2..df414533c6 100644 --- a/src/localisation/date.h +++ b/src/localisation/date.h @@ -43,7 +43,7 @@ typedef struct openrct_timeofday { uint8 second; uint8 minute; uint8 hour; -} PACKED openrct_timeofday; +} openrct_timeofday; extern const sint16 days_in_month[MONTH_COUNT]; extern const rct_string_id DateFormatStringIds[]; diff --git a/src/localisation/language.h b/src/localisation/language.h index b028cdef7f..8e2d1f8511 100644 --- a/src/localisation/language.h +++ b/src/localisation/language.h @@ -52,7 +52,7 @@ typedef struct language_descriptor { const utf8 *native_name; TTFFontSetDescriptor *font; uint8 rct2_original_id; -} PACKED language_descriptor; +} language_descriptor; extern const language_descriptor LanguagesDescriptors[LANGUAGE_COUNT]; diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c index 3e0f0d2044..fc632365fe 100644 --- a/src/localisation/localisation.c +++ b/src/localisation/localisation.c @@ -38,7 +38,7 @@ uint8 gMapTooltipFormatArgs[40]; typedef struct format_code_token { uint32 code; const char *token; -} PACKED format_code_token; +} format_code_token; format_code_token format_code_tokens[] = { { FORMAT_MOVE_X, "MOVE_X" }, diff --git a/src/management/award.h b/src/management/award.h index bad382ca14..984c4a3fe1 100644 --- a/src/management/award.h +++ b/src/management/award.h @@ -19,11 +19,13 @@ #include "../common.h" +#pragma pack(push, 1) typedef struct rct_award { uint16 time; uint16 type; -} PACKED rct_award; +} rct_award; STATIC_ASSERT (sizeof(rct_award) == 4, "Improper struct size"); +#pragma pack(pop) enum { PARK_AWARD_MOST_UNTIDY, diff --git a/src/management/news_item.h b/src/management/news_item.h index 7145f4782b..dd1f8fe2a3 100644 --- a/src/management/news_item.h +++ b/src/management/news_item.h @@ -32,6 +32,7 @@ enum { NEWS_ITEM_GRAPH }; +#pragma pack(push, 1) /** * News item structure. * size: 0x10C @@ -45,8 +46,9 @@ typedef struct rct_news_item { uint8 day; // 0x0A uint8 pad_0B; // 0x0B utf8 text[256]; // 0x0C -} PACKED rct_news_item; +} rct_news_item; STATIC_ASSERT (sizeof(rct_news_item) == 12 + 256, "Improper struct size"); +#pragma pack(pop) #define MAX_NEWS_ITEMS 60 diff --git a/src/management/research.h b/src/management/research.h index 1a60849828..c2b741cad0 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -19,12 +19,14 @@ #include "../common.h" +#pragma pack(push, 1) typedef struct rct_research_item { // Bit 16 (0: scenery entry, 1: ride entry) sint32 entryIndex; uint8 category; -} PACKED rct_research_item; +} rct_research_item; STATIC_ASSERT (sizeof(rct_research_item) == 5, "Improper struct size"); +#pragma pack(pop) enum{ RESEARCH_ENTRY_FLAG_SCENERY_SET_ALWAYS_RESEARCHED = (1 << 29), diff --git a/src/network/NetworkTypes.h b/src/network/NetworkTypes.h index face3cec77..0c933fba2b 100644 --- a/src/network/NetworkTypes.h +++ b/src/network/NetworkTypes.h @@ -72,7 +72,7 @@ struct ByteSwapT<1> { return value; } -} PACKED; +}; template <> struct ByteSwapT<2> @@ -81,7 +81,7 @@ struct ByteSwapT<2> { return SDL_SwapBE16(value); } -} PACKED; +}; template <> struct ByteSwapT<4> @@ -90,7 +90,7 @@ struct ByteSwapT<4> { return SDL_SwapBE32(value); } -} PACKED; +}; template T ByteSwapBE(const T& value) diff --git a/src/network/http.cpp b/src/network/http.cpp index b5a647c988..0ebcbea449 100644 --- a/src/network/http.cpp +++ b/src/network/http.cpp @@ -43,13 +43,13 @@ typedef struct read_buffer { char *ptr; int length; int position; -} PACKED read_buffer; +} read_buffer; typedef struct write_buffer { char *ptr; int length; int capacity; -} PACKED write_buffer; +} write_buffer; #ifdef __WINDOWS__ static utf8 _caBundlePath[MAX_PATH]; @@ -203,7 +203,7 @@ void http_request_json_async(const http_json_request *request, void (*callback)( struct TempThreadArgs { http_json_request request; void (*callback)(http_json_response*); - } PACKED; + }; TempThreadArgs *args = (TempThreadArgs*)malloc(sizeof(TempThreadArgs)); args->request.url = _strdup(request->url); diff --git a/src/network/http.h b/src/network/http.h index 58c7c37b36..c6c8a87284 100644 --- a/src/network/http.h +++ b/src/network/http.h @@ -25,12 +25,12 @@ typedef struct http_json_request { const char *method; const char *url; const json_t *body; -} PACKED http_json_request; +} http_json_request; typedef struct http_json_response { int status_code; json_t *root; -} PACKED http_json_response; +} http_json_response; #define HTTP_METHOD_GET "GET" #define HTTP_METHOD_POST "POST" diff --git a/src/network/network.h b/src/network/network.h index e323353281..e4dc772d18 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -176,7 +176,7 @@ private: bool operator<(const GameCommand& comp) const { return tick < comp.tick; } - } PACKED; + }; int mode = NETWORK_MODE_NONE; int status = NETWORK_STATUS_NONE; diff --git a/src/network/twitch.cpp b/src/network/twitch.cpp index c22c4c32fc..291e29c248 100644 --- a/src/network/twitch.cpp +++ b/src/network/twitch.cpp @@ -96,7 +96,7 @@ namespace Twitch member.ShouldTrack = false; return member; } - } PACKED; + }; /** * The time between HTTP requests. diff --git a/src/object.h b/src/object.h index 3e68600d2b..c4f72389db 100644 --- a/src/object.h +++ b/src/object.h @@ -50,6 +50,7 @@ typedef enum{ #define OBJECT_ENTRY_GROUP_COUNT 11 #define OBJECT_ENTRY_COUNT 721 +#pragma pack(push, 1) /** * Object entry structure. * size: 0x10 @@ -58,7 +59,7 @@ typedef struct rct_object_entry { uint32 flags; char name[8]; uint32 checksum; -} PACKED rct_object_entry; +} rct_object_entry; STATIC_ASSERT (sizeof(rct_object_entry) == 0x10, "Improper struct size"); /** @@ -70,7 +71,7 @@ typedef struct rct_object_entry_extended { char name[8]; uint32 checksum; uint32 chunk_size; -} PACKED rct_object_entry_extended; +} rct_object_entry_extended; STATIC_ASSERT (sizeof(rct_object_entry_extended) == 0x14, "Improper struct size"); extern int object_entry_group_counts[]; @@ -79,21 +80,22 @@ extern int object_entry_group_encoding[]; typedef struct rct_object_entry_group { uint8 **chunks; rct_object_entry_extended *entries; -} PACKED rct_object_entry_group; +} rct_object_entry_group; STATIC_ASSERT (sizeof(rct_object_entry_group) == 8, "Improper struct size"); typedef struct rct_ride_filters { uint8 category[2]; uint8 ride_type; -} PACKED rct_ride_filters; +} rct_ride_filters; STATIC_ASSERT (sizeof(rct_ride_filters) == 3, "Improper struct size"); typedef struct rct_object_filters { union { rct_ride_filters ride; }; -} PACKED rct_object_filters; +} rct_object_filters; STATIC_ASSERT (sizeof(rct_object_filters) == 3, "Improper struct size"); +#pragma pack(pop) extern rct_object_entry_group object_entry_groups[]; extern void** gObjectList; diff --git a/src/object_list.c b/src/object_list.c index bd79e0ef46..bd51da84a5 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -31,14 +31,16 @@ #define FILTER_VERSION 1 +#pragma pack(push, 1) typedef struct rct_plugin_header { uint32 total_files; uint32 total_file_size; uint32 date_modified_checksum; uint32 object_list_size; uint32 object_list_no_items; -} PACKED rct_plugin_header; +} rct_plugin_header; STATIC_ASSERT (sizeof(rct_plugin_header) == 20, "Improper struct size"); +#pragma pack(pop) // 98DA00 int object_entry_group_counts[] = { diff --git a/src/paint/map_element/scenery_multiple.c b/src/paint/map_element/scenery_multiple.c index a2858acd95..4244ae9642 100644 --- a/src/paint/map_element/scenery_multiple.c +++ b/src/paint/map_element/scenery_multiple.c @@ -157,7 +157,7 @@ void scenery_multiple_sign_paint_line(const utf8 *str, rct_large_scenery_text *t typedef struct boundbox { rct_xy16 offset; rct_xy16 length; -} PACKED boundbox; +} boundbox; static const boundbox s98E3C4[] = { { 3, 3, 26, 26 }, diff --git a/src/paint/map_element/surface.c b/src/paint/map_element/surface.c index a4884d8fec..2dc1008865 100644 --- a/src/paint/map_element/surface.c +++ b/src/paint/map_element/surface.c @@ -74,7 +74,7 @@ struct corner_height uint8 right; uint8 bottom; uint8 left; -} PACKED; +}; /** * rct2: 0x0097B4A4 (R), 0x0097B4C4 (T), 0x0097B4E4 (L), 0x0097B504 (B) @@ -312,7 +312,7 @@ struct tile_descriptor uint8 terrain; uint8 slope; corner_height corner_heights; -} PACKED; +}; uint8 viewport_surface_paint_setup_get_relative_slope(rct_map_element * mapElement, int rotation) { diff --git a/src/paint/paint.h b/src/paint/paint.h index ebc861e018..a027dfde42 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -24,6 +24,7 @@ typedef struct attached_paint_struct attached_paint_struct; +#pragma pack(push, 1) /* size 0x12 */ struct attached_paint_struct { uint32 image_id; // 0x00 @@ -37,7 +38,7 @@ struct attached_paint_struct { uint8 flags; // 0x0C uint8 pad_0D; attached_paint_struct* next; //0x0E -} PACKED; +}; // TODO: drop packing from this when all rendering is done. STATIC_ASSERT (sizeof(attached_paint_struct) == 0x12, "Improper struct size"); @@ -71,7 +72,7 @@ struct paint_struct { uint16 map_x; // 0x2C uint16 map_y; // 0x2E rct_map_element *mapElement; // 0x30 (or sprite pointer) -} PACKED; +}; // TODO: drop packing from this when all rendering is done. STATIC_ASSERT (sizeof(paint_struct) == 0x34, "Improper struct size"); @@ -85,15 +86,16 @@ struct paint_string_struct { uint16 y; // 0x08 uint32 args[4]; // 0x0A uint8 *y_offsets; // 0x1A -} PACKED; +}; STATIC_ASSERT (sizeof(paint_string_struct) == 0x1e, "Improper struct size"); +#pragma pack(pop) typedef struct sprite_bb { uint32 sprite_id; rct_xyz16 offset; rct_xyz16 bb_offset; rct_xyz16 bb_size; -} PACKED sprite_bb; +} sprite_bb; enum PAINT_STRUCT_FLAGS { PAINT_STRUCT_FLAG_IS_MASKED = (1 << 0) diff --git a/src/paint/supports.c b/src/paint/supports.c index af20c2fabb..cbc676416f 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -24,7 +24,7 @@ typedef struct supports_id_desc { uint16 half; uint16 flat; uint16 slope; -} PACKED supports_id_desc; +} supports_id_desc; /* 0x0097B1C4 */ const supports_id_desc WoodenSupportImageIds[] = { @@ -61,17 +61,17 @@ const uint16 WoodenCurveSupportImageIds[] = { typedef struct unk_supports_desc_bound_box { struct { uint8 x, y, z; - } PACKED offset; + } offset; struct { uint8 y, x, z; - } PACKED length; -} PACKED unk_supports_desc_bound_box; + } length; +} unk_supports_desc_bound_box; typedef struct unk_supports_desc { unk_supports_desc_bound_box bounding_box; uint8 var_6; uint8 var_7; -} PACKED unk_supports_desc; +} unk_supports_desc; /* 0x0097B23C */ const unk_supports_desc byte_97B23C[] = { diff --git a/src/peep/peep.c b/src/peep/peep.c index 12135cec12..ca40a45b4a 100644 --- a/src/peep/peep.c +++ b/src/peep/peep.c @@ -1123,7 +1123,7 @@ typedef struct item_pref { uint8 type; // 0 for standard, 1 for extra uint32 item; // And this with the relevant flags uint8 sprite_type; -} PACKED item_pref; +} item_pref; item_pref item_order_preference[] = { { 0, PEEP_ITEM_ICE_CREAM, 15 }, diff --git a/src/peep/peep.h b/src/peep/peep.h index d1a2ec5cc7..fbff2e3afc 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -370,12 +370,13 @@ enum PEEP_RIDE_DECISION { PEEP_RIDE_DECISION_THINKING = 1 << 2 }; +#pragma pack(push, 1) typedef struct rct_peep_thought { uint8 type; //0 uint8 item; //1 uint8 var_2; //2 uint8 var_3; //3 -} PACKED rct_peep_thought; +} rct_peep_thought; STATIC_ASSERT (sizeof(rct_peep_thought) == 4, "Improper struct size"); typedef struct rct_peep { @@ -450,12 +451,12 @@ typedef struct rct_peep { struct{ uint8 current_car; // 0x6B uint8 current_seat; // 0x6C - } PACKED; + }; uint16 time_to_sitdown; //0x6B struct{ uint8 time_to_stand; //0x6B uint8 standing_flags; //0x6C - } PACKED; + }; }; // Normally 0, 1 for carrying sliding board on spiral slide ride, 2 for carrying lawn mower uint8 special_sprite; // 0x6D @@ -546,8 +547,9 @@ typedef struct rct_peep { uint8 favourite_ride_rating; // 0xFA uint8 pad_FB; uint32 item_standard_flags; // 0xFC -} PACKED rct_peep; +} rct_peep; STATIC_ASSERT (sizeof(rct_peep) == 0x100, "Improper struct size"); +#pragma pack(pop) enum { EASTEREGG_PEEP_NAME_MICHAEL_SCHUMACHER, diff --git a/src/rct1.h b/src/rct1.h index b8bb040859..1fb3f816fe 100644 --- a/src/rct1.h +++ b/src/rct1.h @@ -26,12 +26,13 @@ #include "world/map.h" #include "world/sprite.h" +#pragma pack(push, 1) typedef struct rct1_entrance { uint16 x; uint16 y; uint16 z; uint8 direction; -} PACKED rct1_entrance; +} rct1_entrance; STATIC_ASSERT (sizeof(rct1_entrance) == 7, "Improper struct size"); /** @@ -47,7 +48,7 @@ typedef struct rct1_ride { struct { colour_t body; colour_t trim; - } PACKED vehicle_colours[12]; + } vehicle_colours[12]; colour_t track_primary_colour; colour_t track_secondary_colour; colour_t track_support_colour; @@ -124,7 +125,7 @@ typedef struct rct1_ride { ride_rating excitement; ride_rating intensity; ride_rating nausea; - } PACKED; + }; }; uint16 value; uint16 var_F8; @@ -160,7 +161,7 @@ typedef struct rct1_ride { uint8 music; uint8 entrance_style; uint8 unk_17A[230]; -} PACKED rct1_ride; +} rct1_ride; STATIC_ASSERT (sizeof(rct1_ride) == 0x260, "Improper struct size"); typedef struct rct1_research_item { @@ -169,7 +170,7 @@ typedef struct rct1_research_item { uint8 category; uint8 flags; uint8 expenditure_area; -} PACKED rct1_research_item; +} rct1_research_item; STATIC_ASSERT (sizeof(rct1_research_item) == 5, "Improper struct size"); /** @@ -342,9 +343,56 @@ typedef struct rct1_s4 { uint32 scenario_flags; uint8 unk_1F8358[432]; uint32 expansion_pack_checksum; -} PACKED rct1_s4; +} rct1_s4; STATIC_ASSERT (sizeof(rct1_s4) == 0x1F850C, "Improper struct size"); +typedef struct rct_track_td4 { + uint8 type; // 0x00 + uint8 vehicle_type; // 0x01 + uint32 special_track_flags; // 0x02 + uint8 operating_mode; // 0x06 + uint8 vehicle_colour_version; // 0x07 Vehicle colour type in first two bits, Version in bits 3,4 + colour_t body_trim_colour[24]; // 0x08 + colour_t track_spine_colour_rct1; // 0x20 + colour_t track_rail_colour_rct1; // 0x21 + colour_t track_support_colour_rct1; // 0x22 + uint8 departure_control_flags; // 0x23 + uint8 number_of_trains; // 0x24 + uint8 cars_per_train; // 0x25 + uint8 min_wait_time; // 0x26 + uint8 max_wait_time; // 0x27 + uint8 speed; // 0x28 + uint8 max_speed; // 0x29 + uint8 average_speed; // 0x2A + uint16 ride_length; // 0x2B + uint8 max_positive_vertical_g; // 0x2D + uint8 max_negitive_vertical_g; // 0x2E + uint8 max_lateral_g; // 0x2F + union { + uint8 inversions; // 0x30 + uint8 holes; // 0x30 + }; + uint8 drops; // 0x31 + uint8 highest_drop_height; // 0x32 + uint8 excitement; // 0x33 + uint8 intensity; // 0x34 + uint8 nausea; // 0x35 + uint8 pad_36[2]; + union{ + uint16 start_track_data_original; // 0x38 + colour_t track_spine_colour[4]; // 0x38 + }; + colour_t track_rail_colour[4]; // 0x3C + union{ + colour_t track_support_colour[4]; // 0x40 + uint8 wall_type[4]; // 0x40 + }; + uint8 pad_41[0x83]; + uint16 start_track_data_AA_CF; // 0xC4 +} rct_track_td4; // Information based off RCTTechDepot +STATIC_ASSERT (sizeof(rct_track_td4) == 0xC9, "Improper struct size"); +#pragma pack(pop) + enum { RCT1_RIDE_TYPE_NULL = 255, RCT1_RIDE_TYPE_WOODEN_ROLLER_COASTER = 0, @@ -649,52 +697,6 @@ enum { RCT1_RESEARCH_SPECIAL_REVERSING_SECTIONS = 0x23, }; -typedef struct rct_track_td4 { - uint8 type; // 0x00 - uint8 vehicle_type; // 0x01 - uint32 special_track_flags; // 0x02 - uint8 operating_mode; // 0x06 - uint8 vehicle_colour_version; // 0x07 Vehicle colour type in first two bits, Version in bits 3,4 - colour_t body_trim_colour[24]; // 0x08 - colour_t track_spine_colour_rct1; // 0x20 - colour_t track_rail_colour_rct1; // 0x21 - colour_t track_support_colour_rct1; // 0x22 - uint8 departure_control_flags; // 0x23 - uint8 number_of_trains; // 0x24 - uint8 cars_per_train; // 0x25 - uint8 min_wait_time; // 0x26 - uint8 max_wait_time; // 0x27 - uint8 speed; // 0x28 - uint8 max_speed; // 0x29 - uint8 average_speed; // 0x2A - uint16 ride_length; // 0x2B - uint8 max_positive_vertical_g; // 0x2D - uint8 max_negitive_vertical_g; // 0x2E - uint8 max_lateral_g; // 0x2F - union { - uint8 inversions; // 0x30 - uint8 holes; // 0x30 - }; - uint8 drops; // 0x31 - uint8 highest_drop_height; // 0x32 - uint8 excitement; // 0x33 - uint8 intensity; // 0x34 - uint8 nausea; // 0x35 - uint8 pad_36[2]; - union{ - uint16 start_track_data_original; // 0x38 - colour_t track_spine_colour[4]; // 0x38 - }; - colour_t track_rail_colour[4]; // 0x3C - union{ - colour_t track_support_colour[4]; // 0x40 - uint8 wall_type[4]; // 0x40 - }; - uint8 pad_41[0x83]; - uint16 start_track_data_AA_CF; // 0xC4 -} PACKED rct_track_td4; // Information based off RCTTechDepot -STATIC_ASSERT (sizeof(rct_track_td4) == 0xC9, "Improper struct size"); - enum { RCT1_SCENARIO_FLAG_0 = 1 << 0, RCT1_SCENARIO_FLAG_1 = 1 << 1, diff --git a/src/rct2.h b/src/rct2.h index 6fb92d1902..14955173b3 100644 --- a/src/rct2.h +++ b/src/rct2.h @@ -111,13 +111,6 @@ typedef uint8 colour_t; #endif // __GNUC__ #endif // __cplusplus -#ifndef _MSC_VER -// use similar struct packing as MSVC for our structs -#define PACKED __attribute__((packed,aligned(1))) -#else -#define PACKED -#endif - #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__)) #include #define STUB() log_warning("Function %s at %s:%d is a stub.\n", __PRETTY_FUNCTION__, __FILE__, __LINE__) @@ -192,7 +185,7 @@ typedef struct rct2_install_info { uint8 pad_210[256]; char expansionPackNames[16][128]; uint32 activeExpansionPacks; //0xB10 -} PACKED rct2_install_info; +} rct2_install_info; enum { // Although this is labeled a flag it actually means when diff --git a/src/ride/gentle/crooked_house.c b/src/ride/gentle/crooked_house.c index ccbac23796..c1e3f3f520 100644 --- a/src/ride/gentle/crooked_house.c +++ b/src/ride/gentle/crooked_house.c @@ -24,7 +24,7 @@ typedef struct rct_crooked_house_bound_box { sint16 offset_y; sint16 length_x; sint16 length_y; -} PACKED rct_crooked_house_bound_box; +} rct_crooked_house_bound_box; rct_crooked_house_bound_box crooked_house_data[] = { {6, 0, 42, 24}, diff --git a/src/ride/gentle/ferris_wheel.c b/src/ride/gentle/ferris_wheel.c index f7c2475b20..230395164d 100644 --- a/src/ride/gentle/ferris_wheel.c +++ b/src/ride/gentle/ferris_wheel.c @@ -39,7 +39,7 @@ typedef struct ferris_wheel_bound_box sint16 length_y; sint16 offset_x; sint16 offset_y; -} PACKED ferris_wheel_bound_box; +} ferris_wheel_bound_box; /** rct2: 0x008A8CA8 */ static ferris_wheel_bound_box ferris_wheel_data[] = { diff --git a/src/ride/gentle/haunted_house.c b/src/ride/gentle/haunted_house.c index be60686241..e7af92e66b 100644 --- a/src/ride/gentle/haunted_house.c +++ b/src/ride/gentle/haunted_house.c @@ -26,7 +26,7 @@ typedef struct haunted_house_bound_box sint16 offset_y; sint16 length_x; sint16 length_y; -} PACKED haunted_house_bound_box; +} haunted_house_bound_box; /** rct2: 0x1428180 */ static haunted_house_bound_box haunted_house_data[] = { diff --git a/src/ride/ride.c b/src/ride/ride.c index 162714fd54..94eb5e79b3 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -5945,11 +5945,13 @@ foundRideEntry: useDefaultName: ride->name = STR_NONE; +#pragma pack(push, 1) struct { uint16 type_name; uint16 number; - } PACKED name_args; + } name_args; STATIC_ASSERT (sizeof(name_args) == 4, "Improper struct size"); +#pragma pack(pop) name_args.type_name = 2 + ride->type; name_args.number = 0; do { @@ -8517,11 +8519,13 @@ void ride_reset_all_names() { ride->name = STR_NONE; +#pragma pack(push, 1) struct { uint16 type_name; uint16 number; - } PACKED name_args; + } name_args; STATIC_ASSERT (sizeof(name_args) == 4, "Improper struct size"); +#pragma pack(pop) name_args.type_name = 2 + ride->type; name_args.number = 0; do { diff --git a/src/ride/ride.h b/src/ride/ride.h index 5d031efe28..2c247a5f7e 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -36,7 +36,7 @@ typedef struct rating_tuple { ride_rating excitement; ride_rating intensity; ride_rating nausea; -} PACKED rating_tuple; +} rating_tuple; STATIC_ASSERT (sizeof(rating_tuple) == 6, "Improper struct size"); /** @@ -47,36 +47,36 @@ typedef struct ride_list_item { struct { uint8 type; uint8 entry_index; - } PACKED; + }; uint16 ride_type_and_entry; }; -} PACKED ride_list_item; +} ride_list_item; STATIC_ASSERT (sizeof(ride_list_item) == 2, "Improper struct size"); typedef struct track_colour { uint8 main; uint8 additional; uint8 supports; -} PACKED track_colour; +} track_colour; STATIC_ASSERT (sizeof(track_colour) == 3, "Improper struct size"); typedef struct vehicle_colour { uint8 main; uint8 additional_1; uint8 additional_2; -} PACKED vehicle_colour; +} vehicle_colour; STATIC_ASSERT (sizeof(vehicle_colour) == 3, "Improper struct size"); typedef struct track_colour_preset_list { uint8 count; track_colour list[256]; -} PACKED track_colour_preset_list; +} track_colour_preset_list; STATIC_ASSERT (sizeof(track_colour_preset_list) == (1 + 256 * 3), "Improper struct size"); typedef struct vehicle_colour_preset_list { uint8 count; vehicle_colour list[256]; -} PACKED vehicle_colour_preset_list; +} vehicle_colour_preset_list; STATIC_ASSERT (sizeof(vehicle_colour_preset_list) == (1 + 256 * 3), "Improper struct size"); /** @@ -116,12 +116,12 @@ typedef struct rct_ride_entry { struct { uint32 enabledTrackPiecesA; // 0x1B6 uint32 enabledTrackPiecesB; // 0x1BA - } PACKED; + }; }; uint8 category[2]; // 0x1BE uint8 shop_item; // 0x1C0 uint8 shop_item_secondary; // 0x1C1 -} PACKED rct_ride_entry; +} rct_ride_entry; STATIC_ASSERT (sizeof(rct_ride_entry) == 0x1c2, "Improper struct size"); /** @@ -146,7 +146,7 @@ typedef struct rct_ride { struct { rct_string_id name_arguments_type_name; // 0x04C uint16 name_arguments_number; // 0x04E - } PACKED; + }; }; uint16 overall_view; // 0x050 00XX = X, XX00 = Y (* 32 + 16) uint16 station_starts[4]; // 0x052 @@ -245,7 +245,7 @@ typedef struct rct_ride { ride_rating excitement; // 0x140 ride_rating intensity; // 0x142 ride_rating nausea; // 0x144 - } PACKED; + }; }; uint16 value; // 0x146 uint16 chairlift_bullwheel_rotation; // 0x148 @@ -328,7 +328,7 @@ typedef struct rct_ride { uint16 cable_lift; // 0x1FE uint16 queue_length[4]; // 0x200 uint8 pad_208[0x58]; -} PACKED rct_ride; +} rct_ride; STATIC_ASSERT (sizeof(rct_ride) == 0x260, "Improper struct size"); #define RIDE_MEASUREMENT_MAX_ITEMS 4800 @@ -349,7 +349,7 @@ typedef struct rct_ride_measurement { sint8 lateral[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x12CC uint8 velocity[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x258C uint8 altitude[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x384C -} PACKED rct_ride_measurement; +} rct_ride_measurement; STATIC_ASSERT (sizeof(rct_ride_measurement) == 0x4b0c, "Improper struct size"); typedef struct track_begin_end { @@ -362,7 +362,7 @@ typedef struct track_begin_end { int end_y; int end_direction; rct_map_element *end_element; -} PACKED track_begin_end; +} track_begin_end; STATIC_ASSERT (sizeof(track_begin_end) == 36, "Improper struct size"); #pragma pack(pop) diff --git a/src/ride/ride_data.h b/src/ride/ride_data.h index d1ac3a63f8..7ec189ee80 100644 --- a/src/ride/ride_data.h +++ b/src/ride/ride_data.h @@ -25,7 +25,7 @@ typedef struct rct_ride_name_convention { rct_string_id structure_name; rct_string_id station_name; rct_string_id unk_name; -} PACKED rct_ride_name_convention; +} rct_ride_name_convention; typedef struct rct_ride_entrance_definition { uint32 sprite_index; @@ -34,14 +34,14 @@ typedef struct rct_ride_entrance_definition { rct_string_id string_id; uint32 base_image_id; uint16 colour_use_flags; -} PACKED rct_ride_entrance_definition; +} rct_ride_entrance_definition; typedef struct rct_shop_item_string_types { rct_string_id singular; // Balloon rct_string_id plural; // Balloons rct_string_id indefinite; // a Balloon rct_string_id display; // "Diamond Heights" Balloon -} PACKED rct_shop_item_string_types; +} rct_shop_item_string_types; typedef struct rct_ride_data_4 { uint8 price; @@ -50,12 +50,12 @@ typedef struct rct_ride_data_4 { uint8 default_music; uint8 var_3; uint8 pad[2]; -} PACKED rct_ride_data_4; +} rct_ride_data_4; typedef struct ride_cost { uint16 track_price; uint16 support_price; -} PACKED ride_cost; +} ride_cost; typedef struct rct_ride_data_5 { uint8 max_height; @@ -66,13 +66,13 @@ typedef struct rct_ride_data_5 { uint8 price; uint8 bonus_value; // Deprecated. Use rideBonusValue instead uint8 pad; -} PACKED rct_ride_data_5; +} rct_ride_data_5; typedef struct rct_ride_lift_data { uint8 sound_id; uint8 minimum_speed; uint8 maximum_speed; -} PACKED rct_ride_lift_data; +} rct_ride_lift_data; enum { RIDE_TYPE_FLAG4_0 = (1 << 0), diff --git a/src/ride/thrill/magic_carpet.c b/src/ride/thrill/magic_carpet.c index 17d0a768c6..073bedb77b 100644 --- a/src/ride/thrill/magic_carpet.c +++ b/src/ride/thrill/magic_carpet.c @@ -40,7 +40,7 @@ typedef struct bound_box { sint16 y; sint16 width; sint16 height; -} PACKED bound_box; +} bound_box; /** rct2: 0x01428220 */ static const sint16 MagicCarpetOscillationZ[] = { diff --git a/src/ride/thrill/pirate_ship.c b/src/ride/thrill/pirate_ship.c index b474e8796f..afad6723be 100644 --- a/src/ride/thrill/pirate_ship.c +++ b/src/ride/thrill/pirate_ship.c @@ -33,7 +33,7 @@ typedef struct pirate_ship_bound_box sint16 length_y; sint16 offset_x; sint16 offset_y; -} PACKED pirate_ship_bound_box; +} pirate_ship_bound_box; /** rct2: 0x008A83B0 */ static const uint32 pirate_ship_base_sprite_offset[] = { diff --git a/src/ride/thrill/swinging_inverter_ship.c b/src/ride/thrill/swinging_inverter_ship.c index a585a5a41c..f2f2cbf55d 100644 --- a/src/ride/thrill/swinging_inverter_ship.c +++ b/src/ride/thrill/swinging_inverter_ship.c @@ -35,7 +35,7 @@ typedef struct swinging_inverter_ship_bound_box sint16 length_y; sint16 offset_x; sint16 offset_y; -} PACKED swinging_inverter_ship_bound_box; +} swinging_inverter_ship_bound_box; /** rct2: 0x01428020 */ static const swinging_inverter_ship_bound_box swinging_inverter_ship_bounds[] = { diff --git a/src/ride/track.h b/src/ride/track.h index af072464a3..a573f312be 100644 --- a/src/ride/track.h +++ b/src/ride/track.h @@ -21,6 +21,7 @@ #include "../object.h" #include "ride.h" +#pragma pack(push, 1) typedef struct rct_trackdefinition { uint8 type; uint8 vangle_end; @@ -29,8 +30,9 @@ typedef struct rct_trackdefinition { uint8 bank_start; uint8 special; uint8 pad[2]; -} PACKED rct_trackdefinition; +} rct_trackdefinition; STATIC_ASSERT (sizeof(rct_trackdefinition) == 8, "Improper struct size"); +#pragma pack(pop) /** * Size: 0x0A @@ -43,7 +45,7 @@ typedef struct rct_preview_track { uint8 var_07; uint8 var_08; uint8 var_09; -} PACKED rct_preview_track; +} rct_preview_track; /* size 0x0A */ typedef struct rct_track_coordinates { @@ -53,7 +55,7 @@ typedef struct rct_track_coordinates { sint16 z_end; // 0x04 sint16 x; // 0x06 sint16 y; // 0x08 -} PACKED rct_track_coordinates; +} rct_track_coordinates; enum { TRACK_ELEMENT_FLAG_TERMINAL_STATION = 1 << 3, @@ -457,7 +459,7 @@ typedef struct track_circuit_iterator { rct_map_element *first; bool firstIteration; bool looped; -} PACKED track_circuit_iterator; +} track_circuit_iterator; extern const rct_trackdefinition *gFlatRideTrackDefinitions; extern const rct_trackdefinition *gTrackDefinitions; diff --git a/src/ride/track_data.h b/src/ride/track_data.h index bb59bbc74f..0a9bc8e0b6 100644 --- a/src/ride/track_data.h +++ b/src/ride/track_data.h @@ -32,7 +32,7 @@ extern const uint8 TrackPieceLengths[256]; typedef struct track_curve_chain { uint16 next; uint16 previous; -} PACKED track_curve_chain; +} track_curve_chain; extern const track_curve_chain gTrackCurveChain[256]; extern const track_curve_chain gFlatRideTrackCurveChain[256]; @@ -48,13 +48,13 @@ typedef struct track_descriptor { uint8 slope_end; uint8 bank_end; uint8 track_element; -} PACKED track_descriptor; +} track_descriptor; extern const track_descriptor gTrackDescriptors[142]; typedef struct { uint16 size; const rct_vehicle_info info[]; -} PACKED rct_vehicle_info_list; +} rct_vehicle_info_list; extern const rct_vehicle_info_list **gTrackVehicleInfo[17]; diff --git a/src/ride/track_design.c b/src/ride/track_design.c index 2a65cf4111..9e3f8b14ab 100644 --- a/src/ride/track_design.c +++ b/src/ride/track_design.c @@ -42,7 +42,7 @@ typedef struct map_backup { uint16 map_size_units_minus_2; uint16 map_size; uint8 current_rotation; -} PACKED map_backup; +} map_backup; static rct_track_td6 *track_design_open_from_buffer(uint8 *src, size_t srcLength); diff --git a/src/ride/track_design.h b/src/ride/track_design.h index f923bf88c0..da433d57da 100644 --- a/src/ride/track_design.h +++ b/src/ride/track_design.h @@ -24,6 +24,7 @@ #define TRACK_PREVIEW_IMAGE_SIZE (370 * 217) +#pragma pack(push, 1) /* Maze Element entry size: 0x04 */ typedef struct rct_td6_maze_element { union { @@ -36,18 +37,18 @@ typedef struct rct_td6_maze_element { struct{ uint8 unk_2; uint8 type; - } PACKED; + }; }; - } PACKED; + }; }; -} PACKED rct_td6_maze_element; +} rct_td6_maze_element; STATIC_ASSERT (sizeof(rct_td6_maze_element) == 0x04, "Improper struct size"); /* Track Element entry size: 0x02 */ typedef struct rct_td6_track_element { uint8 type; // 0x00 uint8 flags; // 0x01 -} PACKED rct_td6_track_element; +} rct_td6_track_element; STATIC_ASSERT (sizeof(rct_td6_track_element) == 0x02, "Improper struct size"); /* Track Entrance entry size: 0x06 */ @@ -56,7 +57,7 @@ typedef struct rct_td6_entrance_element { uint8 direction; // 0x01 sint16 x; // 0x02 sint16 y; // 0x04 -} PACKED rct_td6_entrance_element; +} rct_td6_entrance_element; STATIC_ASSERT (sizeof(rct_td6_entrance_element) == 0x06, "Improper struct size"); /* Track Scenery entry size: 0x16 */ @@ -68,7 +69,7 @@ typedef struct rct_td6_scenery_element { uint8 flags; // 0x13 direction quadrant tertiary colour uint8 primary_colour; // 0x14 uint8 secondary_colour; // 0x15 -} PACKED rct_td6_scenery_element; +} rct_td6_scenery_element; STATIC_ASSERT (sizeof(rct_td6_scenery_element) == 0x16, "Improper struct size"); /** @@ -144,14 +145,15 @@ typedef struct rct_track_td6 { rct_td6_scenery_element *scenery_elements; utf8 *name; -} PACKED rct_track_td6; +} rct_track_td6; //Warning: improper struct size in comment STATIC_ASSERT (sizeof(rct_track_td6) == 0xbf, "Improper struct size"); +#pragma pack(pop) typedef struct track_design_file_ref { utf8 *name; utf8 *path; -} PACKED track_design_file_ref; +} track_design_file_ref; enum { TRACK_FLAGS2_CONTAINS_LOG_FLUME_REVERSER = (1 << 1), diff --git a/src/ride/track_design_index.c b/src/ride/track_design_index.c index b19888c19b..6fe8f7f3fa 100644 --- a/src/ride/track_design_index.c +++ b/src/ride/track_design_index.c @@ -23,14 +23,16 @@ #include "track.h" #include "track_design.h" +#pragma pack(push, 1) typedef struct td_index_item { uint8 ride_type; char ride_entry[9]; utf8 path[MAX_PATH]; -} PACKED td_index_item; +} td_index_item; // NOTE: this is our own struct and should not get packed, but it is stored in a file // so removing packing from it would require refactoring file access STATIC_ASSERT (sizeof(td_index_item) == 1 + 9 + 260, "Improper struct size"); +#pragma pack(pop) static bool track_design_index_read_header(SDL_RWops *file, uint32 *tdidxCount); static void track_design_index_scan(); diff --git a/src/ride/track_design_save.c b/src/ride/track_design_save.c index c981742a98..d6b5c1c16b 100644 --- a/src/ride/track_design_save.c +++ b/src/ride/track_design_save.c @@ -1249,7 +1249,7 @@ typedef struct auto_buffer { void *ptr; size_t length; size_t capacity; -} PACKED auto_buffer; +} auto_buffer; static void auto_buffer_write(auto_buffer *buffer, const void *src, size_t len) { diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 7c74f8c322..9143037e13 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -1881,12 +1881,14 @@ static void vehicle_update_waiting_to_depart(rct_vehicle* vehicle) { } } +#pragma pack(push, 1) typedef struct rct_synchronised_vehicle { uint8 ride_id; uint8 station_id; uint16 vehicle_id; -} PACKED rct_synchronised_vehicle; +} rct_synchronised_vehicle; STATIC_ASSERT (sizeof(rct_synchronised_vehicle) == 4, "Improper struct size"); +#pragma pack(pop) // 8 synchronised vehicle info rct_synchronised_vehicle *_synchronisedVehicles = (rct_synchronised_vehicle*)0x00F64E4C; diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index a656206fa3..a9b94b425e 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -19,11 +19,12 @@ #include "../common.h" +#pragma pack(push, 1) /* size: 0x2 */ typedef struct rct_vehicle_colour { uint8 body_colour; uint8 trim_colour; -} PACKED rct_vehicle_colour; +} rct_vehicle_colour; STATIC_ASSERT (sizeof(rct_vehicle_colour) == 2, "Improper struct size"); /** @@ -75,7 +76,7 @@ typedef struct rct_ride_entry_vehicle { uint8 draw_order; uint8 special_frames; // 0x60 , 0x7A sint8* peep_loading_positions; // 0x61 , 0x7B -} PACKED rct_ride_entry_vehicle; +} rct_ride_entry_vehicle; STATIC_ASSERT (sizeof(rct_ride_entry_vehicle) == 0x65, "Improper struct size"); typedef struct rct_vehicle { @@ -115,7 +116,7 @@ typedef struct rct_vehicle { struct { sint8 var_34; uint8 var_35; - } PACKED; + }; }; union { sint16 track_direction; // 0x36 (0000 0000 0000 0011) @@ -144,7 +145,7 @@ typedef struct rct_vehicle { struct { sint8 ferris_wheel_var_0; // 0x4C sint8 ferris_wheel_var_1; // 0x4D - } PACKED; + }; }; sint16 var_4E; uint8 status; // 0x50 @@ -194,13 +195,14 @@ typedef struct rct_vehicle { uint8 colours_extended; // 0xD7 uint8 seat_rotation; // 0xD8 uint8 target_seat_rotation; // 0xD9 -} PACKED rct_vehicle; +} rct_vehicle; STATIC_ASSERT (sizeof(rct_vehicle) == 0xDA, "Improper struct size"); +#pragma pack(pop) typedef struct train_ref { rct_vehicle *head; rct_vehicle *tail; -} PACKED train_ref; +} train_ref; // Size: 0x09 typedef struct rct_vehicle_info { @@ -210,7 +212,7 @@ typedef struct rct_vehicle_info { uint8 direction; // 0x06 uint8 vehicle_sprite_type; // 0x07 uint8 bank_rotation; // 0x08 -} PACKED rct_vehicle_info; +} rct_vehicle_info; enum { VEHICLE_ENTRY_FLAG_A_0 = 1 << 0, diff --git a/src/ride/vehicle_paint.h b/src/ride/vehicle_paint.h index fba946f439..99fe93de06 100644 --- a/src/ride/vehicle_paint.h +++ b/src/ride/vehicle_paint.h @@ -26,7 +26,7 @@ typedef struct vehicle_boundbox { uint8 length_x; uint8 length_y; uint8 length_z; -} PACKED vehicle_boundbox; +} vehicle_boundbox; extern const vehicle_boundbox VehicleBoundboxes[16][224]; diff --git a/src/scenario.h b/src/scenario.h index c594a6996d..caeb4656e0 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -30,6 +30,7 @@ #include "world/map_animation.h" #include "world/sprite.h" +#pragma pack(push, 1) /** * SV6/SC6 header chunk * size: 0x20 @@ -40,7 +41,7 @@ typedef struct rct_s6_header { uint32 version; // 0x04 uint32 magic_number; // 0x08 uint8 pad_0C[0x14]; -} PACKED rct_s6_header; +} rct_s6_header; STATIC_ASSERT (sizeof(rct_s6_header) == 0x20, "Improper struct size"); /** @@ -58,7 +59,7 @@ typedef struct rct_s6_info { char name[64]; // 0x48 char details[256]; // 0x88 rct_object_entry entry; // 0x188 -} PACKED rct_s6_info; +} rct_s6_info; STATIC_ASSERT (sizeof(rct_s6_info) == 0x198, "Improper struct size"); /** @@ -70,7 +71,7 @@ typedef struct rct_scenario_scores_header { uint32 var_4; uint32 var_8; uint32 scenario_count; // 0x0C -} PACKED rct_scenario_scores_header; +} rct_scenario_scores_header; STATIC_ASSERT (sizeof(rct_scenario_scores_header) == 16, "Improper struct size"); typedef enum scenario_source { @@ -103,7 +104,7 @@ typedef struct rct_scenario_basic { char completed_by[64]; // 0x0270 // uint8 source_game; // new in OpenRCT2 // sint16 source_index; // new in OpenRCT2 -} PACKED rct_scenario_basic; +} rct_scenario_basic; STATIC_ASSERT (sizeof(rct_scenario_basic) == 0x02B0, "Improper struct size"); typedef struct rct_stex_entry { @@ -111,11 +112,13 @@ typedef struct rct_stex_entry { rct_string_id park_name; // 0x02 rct_string_id details; // 0x04 uint8 var_06; -} PACKED rct_stex_entry; +} rct_stex_entry; STATIC_ASSERT (sizeof(rct_stex_entry) == 7, "Improper struct size"); +#pragma pack(pop) #define g_stexEntries ((rct_stex_entry**)object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].chunks) +#pragma pack(push, 1) // This will be useful for backwards compatibility typedef struct rct_s6_data { // SC6[0] @@ -340,7 +343,9 @@ typedef struct rct_s6_data { uint16 wide_path_tile_loop_x; uint16 wide_path_tile_loop_y; uint8 pad_13CE778[434]; -} PACKED rct_s6_data; +} rct_s6_data; +STATIC_ASSERT (sizeof(rct_s6_data) == 0x46b44a, "Improper struct size"); +#pragma pack(pop) enum { SCENARIO_FLAGS_VISIBLE = (1 << 0), @@ -391,7 +396,7 @@ typedef struct scenario_highscore_entry { utf8 *name; money32 company_value; datetime64 timestamp; -} PACKED scenario_highscore_entry; +} scenario_highscore_entry; // NOTE: Check if needed STATIC_ASSERT (sizeof(scenario_highscore_entry) == 20, "Improper struct size"); @@ -414,7 +419,7 @@ typedef struct scenario_index_entry { utf8 name[64]; utf8 details[256]; -} PACKED scenario_index_entry; +} scenario_index_entry; typedef struct source_desc { const utf8 *title; @@ -422,7 +427,7 @@ typedef struct source_desc { uint8 source; sint32 index; uint8 category; -} PACKED source_desc; +} source_desc; extern const rct_string_id ScenarioCategoryStringIds[SCENARIO_CATEGORY_COUNT]; diff --git a/src/util/sawyercoding.h b/src/util/sawyercoding.h index 6cc147e683..7f443b7fc0 100644 --- a/src/util/sawyercoding.h +++ b/src/util/sawyercoding.h @@ -20,11 +20,13 @@ #include #include "../common.h" +#pragma pack(push, 1) typedef struct sawyercoding_chunk_header { uint8 encoding; uint32 length; -} PACKED sawyercoding_chunk_header; +} sawyercoding_chunk_header; STATIC_ASSERT (sizeof(sawyercoding_chunk_header) == 5, "Improper struct size"); +#pragma pack(pop) enum { CHUNK_ENCODING_NONE, diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index 75a2bcf2bb..3d74519d74 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -279,7 +279,7 @@ typedef struct list_item { rct_object_entry *entry; rct_object_filters *filter; uint8 *flags; -} PACKED list_item; +} list_item; typedef int (*sortFunc)(const void *, const void *); diff --git a/src/windows/loadsave.c b/src/windows/loadsave.c index 1b012219b6..c068229904 100644 --- a/src/windows/loadsave.c +++ b/src/windows/loadsave.c @@ -119,7 +119,7 @@ typedef struct loadsave_list_item { char path[MAX_PATH]; time_t date_modified; uint8 type; -} PACKED loadsave_list_item; +} loadsave_list_item; modal_callback gLoadSaveCallback; diff --git a/src/windows/news_options.c b/src/windows/news_options.c index 774109a260..8e11301e87 100644 --- a/src/windows/news_options.c +++ b/src/windows/news_options.c @@ -30,7 +30,7 @@ typedef struct notification_def { uint8 category; rct_string_id caption; size_t config_offset; -} PACKED notification_def; +} notification_def; static const notification_def NewsItemOptionDefinitions[] = { { NOTIFICATION_CATEGORY_PARK, STR_NOTIFICATION_PARK_AWARD, offsetof(notification_configuration, park_award) }, diff --git a/src/windows/ride.c b/src/windows/ride.c index d5945663e5..e0803f78e2 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -958,7 +958,7 @@ static rct_window_event_list *window_ride_page_events[] = { typedef struct ride_overall_view_t { sint16 x, y, z; uint8 zoom; -} PACKED ride_overall_view; +} ride_overall_view; ride_overall_view ride_overall_views[MAX_RIDES] = {0}; @@ -2641,7 +2641,7 @@ typedef struct rct_vehichle_paintinfo { short y; int sprite_index; int tertiary_colour; -} PACKED rct_vehichle_paintinfo; +} rct_vehichle_paintinfo; rct_vehichle_paintinfo _sprites_to_draw[144]; diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index b8affa2214..d52d3d3dc7 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -441,14 +441,16 @@ rct_string_id RideConfigurationStringIds[] = { #pragma endregion +#pragma pack(push, 1) union { uint64 ab; struct { uint32 a; uint32 b; - } PACKED; + }; } _enabledRidePieces; STATIC_ASSERT (sizeof(_enabledRidePieces) == 8, "Improper struct size"); +#pragma pack(pop) static bool _trackPlaceCtrlState; static int _trackPlaceCtrlZ; diff --git a/src/windows/scenery.c b/src/windows/scenery.c index 7ecd2676e3..dcc3b93c81 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -521,7 +521,7 @@ typedef struct scenery_item { int allRows; int selected_item; sint16 sceneryId; -} PACKED scenery_item; +} scenery_item; static scenery_item window_scenery_count_rows_with_selected_item(int tabIndex) { diff --git a/src/windows/title_command_editor.c b/src/windows/title_command_editor.c index dcb8a26a5a..ddd5dc85c3 100644 --- a/src/windows/title_command_editor.c +++ b/src/windows/title_command_editor.c @@ -32,7 +32,7 @@ typedef struct TITLE_COMMAND_ORDER { uint8 command; rct_string_id nameStringId; rct_string_id descStringId; -} PACKED TITLE_COMMAND_ORDER; +} TITLE_COMMAND_ORDER; TITLE_COMMAND_ORDER window_title_command_editor_orders[] = { { TITLE_SCRIPT_LOAD, 5413, 5431 }, diff --git a/src/windows/title_scenarioselect.c b/src/windows/title_scenarioselect.c index 3e159272c2..65806de370 100644 --- a/src/windows/title_scenarioselect.c +++ b/src/windows/title_scenarioselect.c @@ -40,11 +40,11 @@ typedef struct sc_list_item { union { struct { rct_string_id string_id; - } PACKED heading; + } heading; struct { scenario_index_entry *scenario; bool is_locked; - } PACKED scenario; + } scenario; }; } sc_list_item; diff --git a/src/world/banner.h b/src/world/banner.h index 400d1f4b3b..323ce5920c 100644 --- a/src/world/banner.h +++ b/src/world/banner.h @@ -23,6 +23,7 @@ #define BANNER_NULL 255 #define MAX_BANNERS 250 +#pragma pack(push, 1) typedef struct rct_banner { uint8 type; uint8 flags; //0x01 bit 0 is no entry @@ -31,8 +32,9 @@ typedef struct rct_banner { uint8 text_colour; //0x05 uint8 x; //0x06 uint8 y; //0x07 -} PACKED rct_banner; +} rct_banner; STATIC_ASSERT (sizeof(rct_banner) == 8, "Improper struct size"); +#pragma pack(pop) enum{ BANNER_FLAG_NO_ENTRY = (1 << 0), diff --git a/src/world/climate.c b/src/world/climate.c index cbce5caeac..5b79b3c395 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -33,11 +33,14 @@ enum { MAX_THUNDER_INSTANCES = 2 }; +#pragma pack(push, 1) typedef struct rct_weather_transition { sint8 base_temperature; sint8 distribution_size; sint8 distribution[24]; -} PACKED rct_weather_transition; +} rct_weather_transition; +STATIC_ASSERT (sizeof(rct_weather_transition) == 26, "Improper struct size"); +#pragma pack(pop) static const rct_weather_transition* climate_transitions[4]; diff --git a/src/world/climate.h b/src/world/climate.h index a5a552bbc7..e6f1d68c8d 100644 --- a/src/world/climate.h +++ b/src/world/climate.h @@ -35,13 +35,16 @@ enum{ WEATHER_THUNDER }; +#pragma pack(push, 1) typedef struct rct_weather { sint8 temp_delta; sint8 effect_level; sint8 gloom_level; sint8 rain_level; uint32 sprite_id; -} PACKED rct_weather; +} rct_weather; +STATIC_ASSERT (sizeof(rct_weather) == 8, "Improper struct size"); +#pragma pack(pop) #define gClimate RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, uint8) #define gClimateCurrentWeather RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WEATHER, uint8) diff --git a/src/world/entrance.h b/src/world/entrance.h index 0ef25f3ddf..d412c855cf 100644 --- a/src/world/entrance.h +++ b/src/world/entrance.h @@ -19,12 +19,14 @@ #include "../common.h" +#pragma pack(push, 1) typedef struct rct_entrance_type { rct_string_id string_idx; // 0x00 uint32 image_id; // 0x02 uint8 scrolling_mode; // 0x06 uint8 text_height; // 0x07 -} PACKED rct_entrance_type; +} rct_entrance_type; STATIC_ASSERT (sizeof(rct_entrance_type) == 8, "Improper struct size"); +#pragma pack(pop) #endif diff --git a/src/world/footpath.c b/src/world/footpath.c index 9ad8853e36..de619134eb 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -952,12 +952,12 @@ typedef struct rct_neighbour { uint8 direction; uint8 ride_index; uint8 entrance_index; -} PACKED rct_neighbour; +} rct_neighbour; typedef struct rct_neighbour_list { rct_neighbour items[8]; int count; -} PACKED rct_neighbour_list; +} rct_neighbour_list; static int rct_neighbour_compare(const void *a, const void *b) { diff --git a/src/world/footpath.h b/src/world/footpath.h index 19fd13a26e..cb64c4e715 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -27,14 +27,16 @@ enum { PROVISIONAL_PATH_FLAG_2 = (1 << 2), }; +#pragma pack(push, 1) typedef struct rct_footpath_entry { rct_string_id string_idx; // 0x00 uint32 image; // 0x02 uint32 bridge_image; // 0x06 uint8 var_0A; uint8 flags; // 0x0B -} PACKED rct_footpath_entry; +} rct_footpath_entry; STATIC_ASSERT (sizeof(rct_footpath_entry) == 12, "Improper struct size"); +#pragma pack(pop) enum { FOOTPATH_SEARCH_SUCCESS, diff --git a/src/world/map.h b/src/world/map.h index 570825871c..f4230726c1 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -19,12 +19,13 @@ #include "../common.h" +#pragma pack(push, 1) typedef struct rct_map_element_surface_properties { uint8 slope; //4 0xE0 Edge Style, 0x1F Slope uint8 terrain; //5 0xE0 Terrain Style, 0x1F Water height uint8 grass_length; //6 uint8 ownership; //7 -} PACKED rct_map_element_surface_properties; +} rct_map_element_surface_properties; STATIC_ASSERT (sizeof(rct_map_element_surface_properties) == 4, "Improper struct size"); typedef struct rct_map_element_path_properties { @@ -35,7 +36,7 @@ typedef struct rct_map_element_path_properties { uint8 addition_status; //7 uint8 ride_index; }; -} PACKED rct_map_element_path_properties; +} rct_map_element_path_properties; STATIC_ASSERT (sizeof(rct_map_element_path_properties) == 4, "Improper struct size"); typedef struct rct_map_element_track_properties { @@ -44,11 +45,11 @@ typedef struct rct_map_element_track_properties { struct{ uint8 sequence; //5 uint8 colour; //6 - } PACKED; + }; uint16 maze_entry; // 5 }; uint8 ride_index; //7 -} PACKED rct_map_element_track_properties; +} rct_map_element_track_properties; STATIC_ASSERT (sizeof(rct_map_element_track_properties) == 4, "Improper struct size"); typedef struct rct_map_element_scenery_properties { @@ -56,7 +57,7 @@ typedef struct rct_map_element_scenery_properties { uint8 age; //5 uint8 colour_1; //6 uint8 colour_2; //7 -} PACKED rct_map_element_scenery_properties; +} rct_map_element_scenery_properties; STATIC_ASSERT (sizeof(rct_map_element_scenery_properties) == 4, "Improper struct size"); typedef struct rct_map_element_entrance_properties { @@ -64,19 +65,19 @@ typedef struct rct_map_element_entrance_properties { uint8 index; //5 uint8 path_type; //6 uint8 ride_index; //7 -} PACKED rct_map_element_entrance_properties; +} rct_map_element_entrance_properties; STATIC_ASSERT (sizeof(rct_map_element_entrance_properties) == 4, "Improper struct size"); typedef struct rct_map_element_fence_properties { uint8 type; //4 uint8 item[3]; //5 -} PACKED rct_map_element_fence_properties; +} rct_map_element_fence_properties; STATIC_ASSERT (sizeof(rct_map_element_fence_properties) == 4, "Improper struct size"); typedef struct rct_map_element_scenerymultiple_properties { uint16 type; //4 uint8 colour[2]; //6 -} PACKED rct_map_element_scenerymultiple_properties; +} rct_map_element_scenerymultiple_properties; STATIC_ASSERT (sizeof(rct_map_element_scenerymultiple_properties) == 4, "Improper struct size"); typedef struct rct_map_element_banner_properties { @@ -84,7 +85,7 @@ typedef struct rct_map_element_banner_properties { uint8 position; //5 uint8 flags; //6 uint8 unused; //7 -} PACKED rct_map_element_banner_properties; +} rct_map_element_banner_properties; STATIC_ASSERT (sizeof(rct_map_element_banner_properties) == 4, "Improper struct size"); typedef union { @@ -109,8 +110,9 @@ typedef struct rct_map_element { uint8 base_height; //2 uint8 clearance_height; //3 rct_map_element_properties properties; -} PACKED rct_map_element; +} rct_map_element; STATIC_ASSERT (sizeof(rct_map_element) == 8, "Improper struct size"); +#pragma pack(pop) enum { MAP_ELEMENT_QUADRANT_SW, @@ -239,40 +241,41 @@ enum { #define TILE_UNDEFINED_MAP_ELEMENT (rct_map_element*)-1 +#pragma pack(push, 1) typedef struct rct_xy8 { union { struct { uint8 x, y; - } PACKED; + }; uint16 xy; }; -} PACKED rct_xy8; +} rct_xy8; STATIC_ASSERT (sizeof(rct_xy8) == 2, "Improper struct size"); typedef struct rct_xyz8 { uint8 x, y, z; -} PACKED rct_xyz8; +} rct_xyz8; STATIC_ASSERT (sizeof(rct_xyz8) == 3, "Improper struct size"); typedef struct rct_xyzd8 { uint8 x, y, z, direction; -} PACKED rct_xyzd8; +} rct_xyzd8; STATIC_ASSERT (sizeof(rct_xyzd8) == 4, "Improper struct size"); typedef struct rct_xy16 { sint16 x, y; -} PACKED rct_xy16; +} rct_xy16; STATIC_ASSERT (sizeof(rct_xy16) == 4, "Improper struct size"); typedef struct rct_xyz16 { sint16 x, y, z; -} PACKED rct_xyz16; +} rct_xyz16; STATIC_ASSERT (sizeof(rct_xyz16) == 6, "Improper struct size"); typedef struct rct_xy_element { int x, y; rct_map_element *element; -} PACKED rct_xy_element; +} rct_xy_element; STATIC_ASSERT (sizeof(rct_xy_element) == 12, "Improper struct size"); typedef struct rct2_peep_spawn { @@ -280,8 +283,9 @@ typedef struct rct2_peep_spawn { uint16 y; uint8 z; uint8 direction; -} PACKED rct2_peep_spawn; +} rct2_peep_spawn; STATIC_ASSERT (sizeof(rct2_peep_spawn) == 6, "Improper struct size"); +#pragma pack(pop) enum { MAP_SELECT_FLAG_ENABLE = 1 << 0, @@ -437,7 +441,7 @@ typedef struct map_element_iterator { int x; int y; rct_map_element *element; -} PACKED map_element_iterator; +} map_element_iterator; STATIC_ASSERT (sizeof(map_element_iterator) == 12, "Improper struct size"); void map_element_iterator_begin(map_element_iterator *it); diff --git a/src/world/map_animation.h b/src/world/map_animation.h index 8f38157fd4..245937d97e 100644 --- a/src/world/map_animation.h +++ b/src/world/map_animation.h @@ -19,6 +19,7 @@ #include "../common.h" +#pragma pack(push, 1) /** * Animated object * size: 0x06 @@ -28,8 +29,9 @@ typedef struct rct_map_animation { uint8 type; uint16 x; uint16 y; -} PACKED rct_map_animation; +} rct_map_animation; STATIC_ASSERT (sizeof(rct_map_animation) == 6, "Improper struct size"); +#pragma pack(pop) enum { MAP_ANIMATION_TYPE_RIDE_ENTRANCE, diff --git a/src/world/scenery.h b/src/world/scenery.h index adf11de83a..2ca3ae033c 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -21,6 +21,7 @@ #include "../object.h" #include "../world/map.h" +#pragma pack(push, 1) typedef struct rct_small_scenery_entry { uint32 flags; // 0x06 uint8 height; // 0x0A @@ -32,7 +33,7 @@ typedef struct rct_small_scenery_entry { uint16 var_16; uint16 var_18; uint8 scenery_tab_id; // 0x1A -} PACKED rct_small_scenery_entry; +} rct_small_scenery_entry; STATIC_ASSERT (sizeof(rct_small_scenery_entry) == 21, "Improper struct size"); typedef enum { @@ -72,7 +73,7 @@ typedef struct rct_large_scenery_tile { sint16 z_offset; uint8 z_clearance; uint16 var_7; -} PACKED rct_large_scenery_tile; +} rct_large_scenery_tile; STATIC_ASSERT (sizeof(rct_large_scenery_tile) == 9, "Improper struct size"); typedef struct rct_large_scenery_text_glyph { @@ -80,7 +81,7 @@ typedef struct rct_large_scenery_text_glyph { uint8 width; uint8 height; uint8 var_3; -} PACKED rct_large_scenery_text_glyph; +} rct_large_scenery_text_glyph; STATIC_ASSERT (sizeof(rct_large_scenery_text_glyph) == 4, "Improper struct size"); typedef struct rct_large_scenery_text { @@ -89,7 +90,7 @@ typedef struct rct_large_scenery_text { uint16 var_A; // 0xA uint16 var_C; // 0xC rct_large_scenery_text_glyph glyphs[256]; // 0xE -} PACKED rct_large_scenery_text; +} rct_large_scenery_text; STATIC_ASSERT (sizeof(rct_large_scenery_text) == 14 + 4 * 256, "Improper struct size"); typedef struct rct_large_scenery_entry { @@ -102,7 +103,7 @@ typedef struct rct_large_scenery_entry { uint8 var_11; rct_large_scenery_text* text; // 0x12 uint32 text_image; // 0x16 -} PACKED rct_large_scenery_entry; +} rct_large_scenery_entry; STATIC_ASSERT (sizeof(rct_large_scenery_entry) == 20, "Improper struct size"); @@ -114,7 +115,7 @@ typedef struct rct_wall_scenery_entry { sint16 price; // 0x0A uint8 scenery_tab_id; // 0x0C uint8 var_0D; -} PACKED rct_wall_scenery_entry; +} rct_wall_scenery_entry; STATIC_ASSERT (sizeof(rct_wall_scenery_entry) == 8, "Improper struct size"); typedef enum { @@ -138,7 +139,7 @@ typedef struct rct_path_bit_scenery_entry { uint8 tool_id; // 0x09 sint16 price; // 0x0A uint8 scenery_tab_id; // 0x0C -} PACKED rct_path_bit_scenery_entry; +} rct_path_bit_scenery_entry; STATIC_ASSERT (sizeof(rct_path_bit_scenery_entry) == 7, "Improper struct size"); typedef struct rct_banner_scenery_entry { @@ -146,7 +147,7 @@ typedef struct rct_banner_scenery_entry { uint8 flags; // 0x07 sint16 price; // 0x08 uint8 scenery_tab_id; // 0x0A -} PACKED rct_banner_scenery_entry; +} rct_banner_scenery_entry; STATIC_ASSERT (sizeof(rct_banner_scenery_entry) == 5, "Improper struct size"); typedef struct rct_scenery_entry { @@ -159,7 +160,7 @@ typedef struct rct_scenery_entry { rct_path_bit_scenery_entry path_bit; rct_banner_scenery_entry banner; }; -} PACKED rct_scenery_entry; +} rct_scenery_entry; STATIC_ASSERT (sizeof(rct_scenery_entry) == 6 + 21, "Improper struct size"); typedef struct rct_scenery_set_entry { @@ -171,8 +172,9 @@ typedef struct rct_scenery_set_entry { uint8 var_108; // 0x108, order? uint8 pad_109; uint32 var_10A; -} PACKED rct_scenery_set_entry; +} rct_scenery_set_entry; STATIC_ASSERT (sizeof(rct_scenery_set_entry) == 14 + 2 * 0x80, "Improper struct size"); +#pragma pack(pop) enum { PATH_BIT_FLAG_BIN = 1 << 0, diff --git a/src/world/sprite.h b/src/world/sprite.h index ca9b711ae2..04e1156039 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -43,6 +43,7 @@ enum SPRITE_LIST { SPRITE_LIST_UNKNOWN, }; +#pragma pack(push, 1) typedef struct rct_unk_sprite { uint8 sprite_identifier; // 0x00 uint8 misc_identifier; // 0x01 @@ -74,7 +75,7 @@ typedef struct rct_unk_sprite { uint8 var_2B; uint8 pad_2C[0x45]; uint8 var_71; -} PACKED rct_unk_sprite; +} rct_unk_sprite; STATIC_ASSERT (sizeof(rct_unk_sprite) == 0x72, "Improper struct size"); typedef struct rct_litter { @@ -96,7 +97,7 @@ typedef struct rct_litter { uint8 sprite_direction; // 0x1E uint8 pad_1F[5]; uint32 creationTick; // 0x24 -} PACKED rct_litter; +} rct_litter; STATIC_ASSERT (sizeof(rct_litter) == 0x28, "Improper struct size"); typedef struct rct_balloon { @@ -121,12 +122,12 @@ typedef struct rct_balloon { struct { uint8 var_26a; uint8 var_26b; - } PACKED; + }; }; uint8 pad_28[4]; uint8 colour; // 0x2C uint8 var_2D; -} PACKED rct_balloon; +} rct_balloon; STATIC_ASSERT (sizeof(rct_balloon) == 0x2e, "Improper struct size"); typedef struct rct_duck { @@ -153,7 +154,7 @@ typedef struct rct_duck { sint16 target_y; // 0x32 uint8 pad_34[0x14]; uint8 state; // 0x48 -} PACKED rct_duck; +} rct_duck; STATIC_ASSERT (sizeof(rct_duck) == 0x49, "Improper struct size"); typedef struct rct_jumping_fountain { @@ -179,7 +180,7 @@ typedef struct rct_jumping_fountain { struct { uint8 var_26a; uint8 var_26b; - } PACKED; + }; }; uint8 pad_28[0x6]; uint8 var_2E; @@ -188,7 +189,7 @@ typedef struct rct_jumping_fountain { sint16 target_y; // 0x32 uint8 pad_34[0x12]; uint16 iteration; // 0x46 -} PACKED rct_jumping_fountain; +} rct_jumping_fountain; STATIC_ASSERT (sizeof(rct_jumping_fountain) == 0x48, "Improper struct size"); typedef struct rct_money_effect { @@ -213,7 +214,7 @@ typedef struct rct_money_effect { uint8 pad_2C[0x18]; sint16 offset_x; // 0x44 uint16 wiggle; // 0x46 -} PACKED rct_money_effect; +} rct_money_effect; STATIC_ASSERT (sizeof(rct_money_effect) == 0x48, "Improper struct size"); typedef struct rct_crashed_vehicle_particle { @@ -256,7 +257,7 @@ typedef struct rct_crashed_vehicle_particle { sint32 acceleration_z; // 0x40 uint8 pad_44[0x2D]; uint8 var_71; -} PACKED rct_crashed_vehicle_particle; +} rct_crashed_vehicle_particle; STATIC_ASSERT (sizeof(rct_crashed_vehicle_particle) == 0x45 + 0x2D, "Improper struct size"); typedef struct rct_crash_splash { @@ -286,7 +287,7 @@ typedef struct rct_crash_splash { uint16 name_string_idx; // 0x22 uint16 var_24; uint16 frame; // 0x26 -} PACKED rct_crash_splash; +} rct_crash_splash; STATIC_ASSERT (sizeof(rct_crash_splash) == 0x28, "Improper struct size"); typedef struct rct_steam_particle { @@ -316,7 +317,7 @@ typedef struct rct_steam_particle { uint16 name_string_idx; // 0x22 uint16 var_24; uint16 frame; // 0x26 -} PACKED rct_steam_particle; +} rct_steam_particle; STATIC_ASSERT (sizeof(rct_steam_particle) == 0x28, "Improper struct size"); /** @@ -344,20 +345,21 @@ typedef struct rct_sprite_bounds { uint8 sprite_height_negative; // 0x01 uint8 sprite_height_positive; // 0x02 uint8 unused; // 0x03 -} PACKED rct_sprite_bounds; +} rct_sprite_bounds; STATIC_ASSERT (sizeof(rct_sprite_bounds) == 4, "Improper struct size"); typedef struct rct_sprite_image { uint32 base_image; // 0x00 uint8* unkn_04; // 0x04 -} PACKED rct_sprite_image; +} rct_sprite_image; STATIC_ASSERT (sizeof(rct_sprite_image) == 8, "Improper struct size"); typedef struct rct_sprite_entry { rct_sprite_image *sprite_image; // 0x00 rct_sprite_bounds *sprite_bounds; // 0x04 -} PACKED rct_sprite_entry; +} rct_sprite_entry; STATIC_ASSERT (sizeof(rct_sprite_entry) == 8, "Improper struct size"); +#pragma pack(pop) enum { SPRITE_MISC_STEAM_PARTICLE, diff --git a/src/world/water.h b/src/world/water.h index f67b05d499..35032277af 100644 --- a/src/world/water.h +++ b/src/world/water.h @@ -19,13 +19,15 @@ #include "../common.h" +#pragma pack(push, 1) typedef struct rct_water_type { rct_string_id string_idx; // 0x00 uint32 image_id; // 0x02 uint32 var_06; uint32 var_0A; uint16 var_0E; -} PACKED rct_water_type; +} rct_water_type; STATIC_ASSERT (sizeof(rct_water_type) == 16, "Improper struct size"); +#pragma pack(pop) #endif From 934ce5e84e5f8385c46289438aa1877b94fb6e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 3 Jun 2016 00:18:20 +0200 Subject: [PATCH 4/5] Fix 64 bit by skipping static_asserts for structs with pointers --- src/audio/audio.h | 9 ++++----- src/common.h | 6 ++++++ src/drawing/drawing.h | 6 ++++++ src/object.h | 2 ++ src/paint/paint.h | 6 ++++++ src/ride/ride.h | 4 ++++ src/ride/track_design.h | 2 ++ src/ride/vehicle.h | 2 ++ src/scenario.h | 2 ++ src/world/map.h | 4 ++++ src/world/scenery.h | 5 ++++- src/world/sprite.h | 4 ++++ 12 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/audio/audio.h b/src/audio/audio.h index ed4015d38b..463f1520b4 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -41,8 +41,9 @@ typedef struct rct_ride_music { uint16 frequency; void* sound_channel; } rct_ride_music; - +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_ride_music) == 12, "Improper struct size"); +#endif typedef struct rct_ride_music_info { uint32 length; @@ -50,7 +51,6 @@ typedef struct rct_ride_music_info { uint8 path_id; uint8 var_9; } rct_ride_music_info; - STATIC_ASSERT (sizeof(rct_ride_music_info) == 10, "Improper struct size"); typedef struct rct_ride_music_params { @@ -61,7 +61,6 @@ typedef struct rct_ride_music_params { sint16 pan; uint16 frequency; } rct_ride_music_params; - STATIC_ASSERT (sizeof(rct_ride_music_params) == 12, "Improper struct size"); typedef struct rct_vehicle_sound { @@ -78,8 +77,9 @@ typedef struct rct_vehicle_sound { void* sound1_channel; void* sound2_channel; } rct_vehicle_sound; - +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_vehicle_sound) == 28, "Improper struct size"); +#endif typedef struct rct_vehicle_sound_params { uint16 id; @@ -89,7 +89,6 @@ typedef struct rct_vehicle_sound_params { sint16 volume; uint16 var_A; } rct_vehicle_sound_params; - STATIC_ASSERT (sizeof(rct_vehicle_sound_params) == 12, "Improper struct size"); #pragma pack(pop) diff --git a/src/common.h b/src/common.h index c9dfd4998d..9d68f41744 100644 --- a/src/common.h +++ b/src/common.h @@ -34,6 +34,12 @@ #define PLATFORM_X86 #endif +#if defined(__LP64__) || defined(_WIN64) + #define PLATFORM_64BIT +#else + #define PLATFORM_32BIT +#endif + // C99's restrict keywords guarantees the pointer in question, for the whole of its lifetime, // will be the only way to access a given memory region. In other words: there is no other pointer // aliasing the same memory area. Using it lets compiler generate better code. If your compiler diff --git a/src/drawing/drawing.h b/src/drawing/drawing.h index cc9a70274f..828b944ce6 100644 --- a/src/drawing/drawing.h +++ b/src/drawing/drawing.h @@ -31,7 +31,9 @@ typedef struct rct_drawpixelinfo { short pitch; // 0x0C note: this is actually (pitch - width) uint16 zoom_level; // 0x0E } rct_drawpixelinfo; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_drawpixelinfo) == 0x10, "Improper struct size"); +#endif // Size: 0x10 typedef struct rct_g1_element { @@ -43,7 +45,9 @@ typedef struct rct_g1_element { uint16 flags; // 0x0C uint16 zoomed_offset; // 0x0E } rct_g1_element; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_g1_element) == 0x10, "Improper struct size"); +#endif enum { G1_FLAG_BMP = (1 << 0), //No invisible sections @@ -68,7 +72,9 @@ typedef struct rct_gx { rct_g1_element *elements; void *data; } rct_gx; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_gx) == 16, "Improper struct size"); +#endif typedef struct rct_palette_entry { uint8 blue; diff --git a/src/object.h b/src/object.h index c4f72389db..29693cf16a 100644 --- a/src/object.h +++ b/src/object.h @@ -81,7 +81,9 @@ typedef struct rct_object_entry_group { uint8 **chunks; rct_object_entry_extended *entries; } rct_object_entry_group; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_object_entry_group) == 8, "Improper struct size"); +#endif typedef struct rct_ride_filters { uint8 category[2]; diff --git a/src/paint/paint.h b/src/paint/paint.h index a027dfde42..491bec2006 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -39,8 +39,10 @@ struct attached_paint_struct { uint8 pad_0D; attached_paint_struct* next; //0x0E }; +#ifdef PLATFORM_32BIT // TODO: drop packing from this when all rendering is done. STATIC_ASSERT (sizeof(attached_paint_struct) == 0x12, "Improper struct size"); +#endif typedef struct paint_struct paint_struct; @@ -73,8 +75,10 @@ struct paint_struct { uint16 map_y; // 0x2E rct_map_element *mapElement; // 0x30 (or sprite pointer) }; +#ifdef PLATFORM_32BIT // TODO: drop packing from this when all rendering is done. STATIC_ASSERT (sizeof(paint_struct) == 0x34, "Improper struct size"); +#endif typedef struct paint_string_struct paint_string_struct; @@ -87,7 +91,9 @@ struct paint_string_struct { uint32 args[4]; // 0x0A uint8 *y_offsets; // 0x1A }; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(paint_string_struct) == 0x1e, "Improper struct size"); +#endif #pragma pack(pop) typedef struct sprite_bb { diff --git a/src/ride/ride.h b/src/ride/ride.h index 2c247a5f7e..4a53d80b1a 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -122,7 +122,9 @@ typedef struct rct_ride_entry { uint8 shop_item; // 0x1C0 uint8 shop_item_secondary; // 0x1C1 } rct_ride_entry; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_ride_entry) == 0x1c2, "Improper struct size"); +#endif /** * Ride structure. @@ -363,7 +365,9 @@ typedef struct track_begin_end { int end_direction; rct_map_element *end_element; } track_begin_end; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(track_begin_end) == 36, "Improper struct size"); +#endif #pragma pack(pop) diff --git a/src/ride/track_design.h b/src/ride/track_design.h index da433d57da..e23db102fa 100644 --- a/src/ride/track_design.h +++ b/src/ride/track_design.h @@ -147,7 +147,9 @@ typedef struct rct_track_td6 { utf8 *name; } rct_track_td6; //Warning: improper struct size in comment +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_track_td6) == 0xbf, "Improper struct size"); +#endif #pragma pack(pop) typedef struct track_design_file_ref { diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index a9b94b425e..b72205d96a 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -77,7 +77,9 @@ typedef struct rct_ride_entry_vehicle { uint8 special_frames; // 0x60 , 0x7A sint8* peep_loading_positions; // 0x61 , 0x7B } rct_ride_entry_vehicle; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_ride_entry_vehicle) == 0x65, "Improper struct size"); +#endif typedef struct rct_vehicle { uint8 sprite_identifier; // 0x00 diff --git a/src/scenario.h b/src/scenario.h index caeb4656e0..b3f4cac62f 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -398,7 +398,9 @@ typedef struct scenario_highscore_entry { datetime64 timestamp; } scenario_highscore_entry; // NOTE: Check if needed +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(scenario_highscore_entry) == 20, "Improper struct size"); +#endif typedef struct scenario_index_entry { utf8 path[MAX_PATH]; diff --git a/src/world/map.h b/src/world/map.h index f4230726c1..7acaf3aac2 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -276,7 +276,9 @@ typedef struct rct_xy_element { int x, y; rct_map_element *element; } rct_xy_element; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_xy_element) == 12, "Improper struct size"); +#endif typedef struct rct2_peep_spawn { uint16 x; @@ -442,7 +444,9 @@ typedef struct map_element_iterator { int y; rct_map_element *element; } map_element_iterator; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(map_element_iterator) == 12, "Improper struct size"); +#endif void map_element_iterator_begin(map_element_iterator *it); int map_element_iterator_next(map_element_iterator *it); diff --git a/src/world/scenery.h b/src/world/scenery.h index 2ca3ae033c..bc0fa7132b 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -104,8 +104,9 @@ typedef struct rct_large_scenery_entry { rct_large_scenery_text* text; // 0x12 uint32 text_image; // 0x16 } rct_large_scenery_entry; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_large_scenery_entry) == 20, "Improper struct size"); - +#endif typedef struct rct_wall_scenery_entry { uint8 tool_id; // 0x06 @@ -161,7 +162,9 @@ typedef struct rct_scenery_entry { rct_banner_scenery_entry banner; }; } rct_scenery_entry; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_scenery_entry) == 6 + 21, "Improper struct size"); +#endif typedef struct rct_scenery_set_entry { rct_string_id name; // 0x00 diff --git a/src/world/sprite.h b/src/world/sprite.h index 04e1156039..a086c20ac5 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -352,13 +352,17 @@ typedef struct rct_sprite_image { uint32 base_image; // 0x00 uint8* unkn_04; // 0x04 } rct_sprite_image; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_sprite_image) == 8, "Improper struct size"); +#endif typedef struct rct_sprite_entry { rct_sprite_image *sprite_image; // 0x00 rct_sprite_bounds *sprite_bounds; // 0x04 } rct_sprite_entry; +#ifdef PLATFORM_32BIT STATIC_ASSERT (sizeof(rct_sprite_entry) == 8, "Improper struct size"); +#endif #pragma pack(pop) enum { From 1508e49a28f038d762528075989aa9653c570a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 3 Jun 2016 10:54:44 +0200 Subject: [PATCH 5/5] Change macro to assert_struct_size --- src/addresses.h | 2 +- src/audio/audio.h | 10 ++++----- src/audio/mixer.cpp | 4 ++-- src/cmdline_sprite.c | 6 +++--- src/common.h | 6 +++--- src/drawing/drawing.h | 10 ++++----- src/interface/Theme.cpp | 2 +- src/interface/colour.h | 4 ++-- src/management/award.h | 2 +- src/management/news_item.h | 2 +- src/management/research.h | 2 +- src/object.h | 10 ++++----- src/object_list.c | 2 +- src/paint/paint.h | 6 +++--- src/peep/peep.h | 4 ++-- src/rct1.h | 10 ++++----- src/ride/ride.c | 4 ++-- src/ride/ride.h | 20 +++++++++--------- src/ride/track.h | 2 +- src/ride/track_design.h | 10 ++++----- src/ride/track_design_index.c | 2 +- src/ride/vehicle.c | 2 +- src/ride/vehicle.h | 6 +++--- src/scenario.h | 16 +++++++-------- src/util/sawyercoding.h | 2 +- src/windows/ride_construction.c | 2 +- src/world/banner.h | 2 +- src/world/climate.c | 2 +- src/world/climate.h | 2 +- src/world/entrance.h | 2 +- src/world/footpath.h | 2 +- src/world/map.h | 36 ++++++++++++++++----------------- src/world/map_animation.h | 2 +- src/world/scenery.h | 20 +++++++++--------- src/world/sprite.h | 26 ++++++++++++------------ src/world/water.h | 2 +- 36 files changed, 121 insertions(+), 123 deletions(-) diff --git a/src/addresses.h b/src/addresses.h index 86670606d9..cbfff546a9 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -708,7 +708,7 @@ typedef struct registers { }; } registers; -STATIC_ASSERT (sizeof(registers) == 7 * 4, "Improper struct size"); +assert_struct_size(registers, 7 * 4); #pragma pack(pop) diff --git a/src/audio/audio.h b/src/audio/audio.h index 463f1520b4..ca530c2d87 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -42,7 +42,7 @@ typedef struct rct_ride_music { void* sound_channel; } rct_ride_music; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_ride_music) == 12, "Improper struct size"); +assert_struct_size(rct_ride_music, 12); #endif typedef struct rct_ride_music_info { @@ -51,7 +51,7 @@ typedef struct rct_ride_music_info { uint8 path_id; uint8 var_9; } rct_ride_music_info; -STATIC_ASSERT (sizeof(rct_ride_music_info) == 10, "Improper struct size"); +assert_struct_size(rct_ride_music_info, 10); typedef struct rct_ride_music_params { uint8 ride_id; @@ -61,7 +61,7 @@ typedef struct rct_ride_music_params { sint16 pan; uint16 frequency; } rct_ride_music_params; -STATIC_ASSERT (sizeof(rct_ride_music_params) == 12, "Improper struct size"); +assert_struct_size(rct_ride_music_params, 12); typedef struct rct_vehicle_sound { uint16 id; @@ -78,7 +78,7 @@ typedef struct rct_vehicle_sound { void* sound2_channel; } rct_vehicle_sound; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_vehicle_sound) == 28, "Improper struct size"); +assert_struct_size(rct_vehicle_sound, 28); #endif typedef struct rct_vehicle_sound_params { @@ -89,7 +89,7 @@ typedef struct rct_vehicle_sound_params { sint16 volume; uint16 var_A; } rct_vehicle_sound_params; -STATIC_ASSERT (sizeof(rct_vehicle_sound_params) == 12, "Improper struct size"); +assert_struct_size(rct_vehicle_sound_params, 12); #pragma pack(pop) diff --git a/src/audio/mixer.cpp b/src/audio/mixer.cpp index a2bfb3ba6b..54ec923337 100644 --- a/src/audio/mixer.cpp +++ b/src/audio/mixer.cpp @@ -149,7 +149,7 @@ bool Source_Sample::LoadCSS1(const char *filename, unsigned int offset) Uint16 extrasize; } waveformat; #pragma pack(pop) - STATIC_ASSERT (sizeof(waveformat) == 18, "Improper struct size"); + assert_struct_size(waveformat, 18); SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); format.freq = waveformat.frequency; format.format = AUDIO_S16LSB; @@ -276,7 +276,7 @@ bool Source_SampleStream::LoadWAV(SDL_RWops* rw) Uint16 bitspersample; } waveformat; #pragma pack(pop) - STATIC_ASSERT (sizeof(waveformat) == 16, "Improper struct size"); + assert_struct_size(waveformat, 16); SDL_RWread(rw, &waveformat, sizeof(waveformat), 1); SDL_RWseek(rw, chunkstart + fmtchunk_size, RW_SEEK_SET); const Uint16 pcmformat = 0x0001; diff --git a/src/cmdline_sprite.c b/src/cmdline_sprite.c index 9e278adcf7..ba322c1483 100644 --- a/src/cmdline_sprite.c +++ b/src/cmdline_sprite.c @@ -33,7 +33,7 @@ typedef struct rct_sprite_file_header { uint32 total_size; } rct_sprite_file_header; -STATIC_ASSERT (sizeof(rct_sprite_file_header) == 8, "Improper struct size"); +assert_struct_size(rct_sprite_file_header, 8); typedef struct rct_sprite_file_palette_entry { uint8 b, g, r, a; @@ -44,11 +44,11 @@ typedef struct rle_code { uint8 offset_x; } rle_code; -STATIC_ASSERT (sizeof(rle_code) == 2, "Improper struct size"); +assert_struct_size(rle_code, 2); #pragma pack(pop) -STATIC_ASSERT (sizeof(rct_sprite_file_palette_entry) == 4, "Improper struct size"); +assert_struct_size(rct_sprite_file_palette_entry, 4); rct_sprite_file_palette_entry spriteFilePalette[256]; static rct_sprite_file_palette_entry _standardPalette[256]; diff --git a/src/common.h b/src/common.h index 9d68f41744..cd2a13869c 100644 --- a/src/common.h +++ b/src/common.h @@ -62,13 +62,13 @@ #endif #ifdef __cplusplus -#define STATIC_ASSERT static_assert +#define assert_struct_size(x, y) static_assert(sizeof(x) == (y), "Improper struct size") #else // Visual Studio does not know _Static_assert #if !defined(_MSC_VER) - #define STATIC_ASSERT _Static_assert + #define assert_struct_size(x, y) _Static_assert(sizeof(x) == (y), "Improper struct size") #else - #define STATIC_ASSERT(x, y) + #define assert_struct_size(x, y) #endif // !defined(_MSC_VER) #endif diff --git a/src/drawing/drawing.h b/src/drawing/drawing.h index 828b944ce6..0520da78f7 100644 --- a/src/drawing/drawing.h +++ b/src/drawing/drawing.h @@ -32,7 +32,7 @@ typedef struct rct_drawpixelinfo { uint16 zoom_level; // 0x0E } rct_drawpixelinfo; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_drawpixelinfo) == 0x10, "Improper struct size"); +assert_struct_size(rct_drawpixelinfo, 0x10); #endif // Size: 0x10 @@ -46,7 +46,7 @@ typedef struct rct_g1_element { uint16 zoomed_offset; // 0x0E } rct_g1_element; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_g1_element) == 0x10, "Improper struct size"); +assert_struct_size(rct_g1_element, 0x10); #endif enum { @@ -65,7 +65,7 @@ typedef struct rct_g1_header { uint32 num_entries; uint32 total_size; } rct_g1_header; -STATIC_ASSERT (sizeof(rct_g1_header) == 8, "Improper struct size"); +assert_struct_size(rct_g1_header, 8); typedef struct rct_gx { rct_g1_header header; @@ -73,7 +73,7 @@ typedef struct rct_gx { void *data; } rct_gx; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_gx) == 16, "Improper struct size"); +assert_struct_size(rct_gx, 16); #endif typedef struct rct_palette_entry { @@ -82,7 +82,7 @@ typedef struct rct_palette_entry { uint8 red; uint8 alpha; } rct_palette_entry; -STATIC_ASSERT (sizeof(rct_palette_entry) == 4, "Improper struct size"); +assert_struct_size(rct_palette_entry, 4); #pragma pack(pop) diff --git a/src/interface/Theme.cpp b/src/interface/Theme.cpp index fe19a8fd6e..d26191fb0c 100644 --- a/src/interface/Theme.cpp +++ b/src/interface/Theme.cpp @@ -495,7 +495,7 @@ namespace ThemeManager { utf8 Path[MAX_PATH]; utf8 Name[96]; - }; + }; utf8 * CurrentThemePath; UITheme * CurrentTheme; diff --git a/src/interface/colour.h b/src/interface/colour.h index 45bae54eae..bc59c841ba 100644 --- a/src/interface/colour.h +++ b/src/interface/colour.h @@ -82,7 +82,7 @@ typedef struct rct_colour_map_a { uint8 lighter; uint8 lightest; } rct_colour_map_a; -STATIC_ASSERT (sizeof(rct_colour_map_a) == 8, "Improper struct size"); +assert_struct_size(rct_colour_map_a, 8); typedef struct rct_colour_map_b { uint8 a; @@ -94,7 +94,7 @@ typedef struct rct_colour_map_b { uint8 g; uint8 h; } rct_colour_map_b; -STATIC_ASSERT (sizeof(rct_colour_map_b) == 8, "Improper struct size"); +assert_struct_size(rct_colour_map_b, 8); #pragma pack(pop) diff --git a/src/management/award.h b/src/management/award.h index 984c4a3fe1..8833a1dd90 100644 --- a/src/management/award.h +++ b/src/management/award.h @@ -24,7 +24,7 @@ typedef struct rct_award { uint16 time; uint16 type; } rct_award; -STATIC_ASSERT (sizeof(rct_award) == 4, "Improper struct size"); +assert_struct_size(rct_award, 4); #pragma pack(pop) enum { diff --git a/src/management/news_item.h b/src/management/news_item.h index dd1f8fe2a3..6a14361c60 100644 --- a/src/management/news_item.h +++ b/src/management/news_item.h @@ -47,7 +47,7 @@ typedef struct rct_news_item { uint8 pad_0B; // 0x0B utf8 text[256]; // 0x0C } rct_news_item; -STATIC_ASSERT (sizeof(rct_news_item) == 12 + 256, "Improper struct size"); +assert_struct_size(rct_news_item, 12 + 256); #pragma pack(pop) #define MAX_NEWS_ITEMS 60 diff --git a/src/management/research.h b/src/management/research.h index c2b741cad0..3ab2a3327b 100644 --- a/src/management/research.h +++ b/src/management/research.h @@ -25,7 +25,7 @@ typedef struct rct_research_item { sint32 entryIndex; uint8 category; } rct_research_item; -STATIC_ASSERT (sizeof(rct_research_item) == 5, "Improper struct size"); +assert_struct_size(rct_research_item, 5); #pragma pack(pop) enum{ diff --git a/src/object.h b/src/object.h index 29693cf16a..d2cf8d2824 100644 --- a/src/object.h +++ b/src/object.h @@ -60,7 +60,7 @@ typedef struct rct_object_entry { char name[8]; uint32 checksum; } rct_object_entry; -STATIC_ASSERT (sizeof(rct_object_entry) == 0x10, "Improper struct size"); +assert_struct_size(rct_object_entry, 0x10); /** * Object entry structure extended. @@ -72,7 +72,7 @@ typedef struct rct_object_entry_extended { uint32 checksum; uint32 chunk_size; } rct_object_entry_extended; -STATIC_ASSERT (sizeof(rct_object_entry_extended) == 0x14, "Improper struct size"); +assert_struct_size(rct_object_entry_extended, 0x14); extern int object_entry_group_counts[]; extern int object_entry_group_encoding[]; @@ -82,21 +82,21 @@ typedef struct rct_object_entry_group { rct_object_entry_extended *entries; } rct_object_entry_group; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_object_entry_group) == 8, "Improper struct size"); +assert_struct_size(rct_object_entry_group, 8); #endif typedef struct rct_ride_filters { uint8 category[2]; uint8 ride_type; } rct_ride_filters; -STATIC_ASSERT (sizeof(rct_ride_filters) == 3, "Improper struct size"); +assert_struct_size(rct_ride_filters, 3); typedef struct rct_object_filters { union { rct_ride_filters ride; }; } rct_object_filters; -STATIC_ASSERT (sizeof(rct_object_filters) == 3, "Improper struct size"); +assert_struct_size(rct_object_filters, 3); #pragma pack(pop) extern rct_object_entry_group object_entry_groups[]; diff --git a/src/object_list.c b/src/object_list.c index bd51da84a5..1fd71edbe5 100644 --- a/src/object_list.c +++ b/src/object_list.c @@ -39,7 +39,7 @@ typedef struct rct_plugin_header { uint32 object_list_size; uint32 object_list_no_items; } rct_plugin_header; -STATIC_ASSERT (sizeof(rct_plugin_header) == 20, "Improper struct size"); +assert_struct_size(rct_plugin_header, 20); #pragma pack(pop) // 98DA00 diff --git a/src/paint/paint.h b/src/paint/paint.h index 491bec2006..91cc7c0549 100644 --- a/src/paint/paint.h +++ b/src/paint/paint.h @@ -41,7 +41,7 @@ struct attached_paint_struct { }; #ifdef PLATFORM_32BIT // TODO: drop packing from this when all rendering is done. -STATIC_ASSERT (sizeof(attached_paint_struct) == 0x12, "Improper struct size"); +assert_struct_size(attached_paint_struct, 0x12); #endif typedef struct paint_struct paint_struct; @@ -77,7 +77,7 @@ struct paint_struct { }; #ifdef PLATFORM_32BIT // TODO: drop packing from this when all rendering is done. -STATIC_ASSERT (sizeof(paint_struct) == 0x34, "Improper struct size"); +assert_struct_size(paint_struct, 0x34); #endif typedef struct paint_string_struct paint_string_struct; @@ -92,7 +92,7 @@ struct paint_string_struct { uint8 *y_offsets; // 0x1A }; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(paint_string_struct) == 0x1e, "Improper struct size"); +assert_struct_size(paint_string_struct, 0x1e); #endif #pragma pack(pop) diff --git a/src/peep/peep.h b/src/peep/peep.h index fbff2e3afc..bd88d8b0ec 100644 --- a/src/peep/peep.h +++ b/src/peep/peep.h @@ -377,7 +377,7 @@ typedef struct rct_peep_thought { uint8 var_2; //2 uint8 var_3; //3 } rct_peep_thought; -STATIC_ASSERT (sizeof(rct_peep_thought) == 4, "Improper struct size"); +assert_struct_size(rct_peep_thought, 4); typedef struct rct_peep { uint8 sprite_identifier; // 0x00 @@ -548,7 +548,7 @@ typedef struct rct_peep { uint8 pad_FB; uint32 item_standard_flags; // 0xFC } rct_peep; -STATIC_ASSERT (sizeof(rct_peep) == 0x100, "Improper struct size"); +assert_struct_size(rct_peep, 0x100); #pragma pack(pop) enum { diff --git a/src/rct1.h b/src/rct1.h index 1fb3f816fe..4ae06a295e 100644 --- a/src/rct1.h +++ b/src/rct1.h @@ -33,7 +33,7 @@ typedef struct rct1_entrance { uint16 z; uint8 direction; } rct1_entrance; -STATIC_ASSERT (sizeof(rct1_entrance) == 7, "Improper struct size"); +assert_struct_size(rct1_entrance, 7); /** * RCT1 ride structure @@ -162,7 +162,7 @@ typedef struct rct1_ride { uint8 entrance_style; uint8 unk_17A[230]; } rct1_ride; -STATIC_ASSERT (sizeof(rct1_ride) == 0x260, "Improper struct size"); +assert_struct_size(rct1_ride, 0x260); typedef struct rct1_research_item { uint8 item; @@ -171,7 +171,7 @@ typedef struct rct1_research_item { uint8 flags; uint8 expenditure_area; } rct1_research_item; -STATIC_ASSERT (sizeof(rct1_research_item) == 5, "Improper struct size"); +assert_struct_size(rct1_research_item, 5); /** * RCT1,AA,LL scenario / saved game structure. @@ -344,7 +344,7 @@ typedef struct rct1_s4 { uint8 unk_1F8358[432]; uint32 expansion_pack_checksum; } rct1_s4; -STATIC_ASSERT (sizeof(rct1_s4) == 0x1F850C, "Improper struct size"); +assert_struct_size(rct1_s4, 0x1F850C); typedef struct rct_track_td4 { uint8 type; // 0x00 @@ -390,7 +390,7 @@ typedef struct rct_track_td4 { uint8 pad_41[0x83]; uint16 start_track_data_AA_CF; // 0xC4 } rct_track_td4; // Information based off RCTTechDepot -STATIC_ASSERT (sizeof(rct_track_td4) == 0xC9, "Improper struct size"); +assert_struct_size(rct_track_td4, 0xC9); #pragma pack(pop) enum { diff --git a/src/ride/ride.c b/src/ride/ride.c index 94eb5e79b3..1b4f94aee4 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -5950,7 +5950,7 @@ foundRideEntry: uint16 type_name; uint16 number; } name_args; - STATIC_ASSERT (sizeof(name_args) == 4, "Improper struct size"); + assert_struct_size(name_args, 4); #pragma pack(pop) name_args.type_name = 2 + ride->type; name_args.number = 0; @@ -8524,7 +8524,7 @@ void ride_reset_all_names() uint16 type_name; uint16 number; } name_args; - STATIC_ASSERT (sizeof(name_args) == 4, "Improper struct size"); + assert_struct_size(name_args, 4); #pragma pack(pop) name_args.type_name = 2 + ride->type; name_args.number = 0; diff --git a/src/ride/ride.h b/src/ride/ride.h index 4a53d80b1a..3efc434c87 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -37,7 +37,7 @@ typedef struct rating_tuple { ride_rating intensity; ride_rating nausea; } rating_tuple; -STATIC_ASSERT (sizeof(rating_tuple) == 6, "Improper struct size"); +assert_struct_size(rating_tuple, 6); /** * Couples a ride type and subtype together. @@ -51,33 +51,33 @@ typedef struct ride_list_item { uint16 ride_type_and_entry; }; } ride_list_item; -STATIC_ASSERT (sizeof(ride_list_item) == 2, "Improper struct size"); +assert_struct_size(ride_list_item, 2); typedef struct track_colour { uint8 main; uint8 additional; uint8 supports; } track_colour; -STATIC_ASSERT (sizeof(track_colour) == 3, "Improper struct size"); +assert_struct_size(track_colour, 3); typedef struct vehicle_colour { uint8 main; uint8 additional_1; uint8 additional_2; } vehicle_colour; -STATIC_ASSERT (sizeof(vehicle_colour) == 3, "Improper struct size"); +assert_struct_size(vehicle_colour, 3); typedef struct track_colour_preset_list { uint8 count; track_colour list[256]; } track_colour_preset_list; -STATIC_ASSERT (sizeof(track_colour_preset_list) == (1 + 256 * 3), "Improper struct size"); +assert_struct_size(track_colour_preset_list, (1 + 256 * 3)); typedef struct vehicle_colour_preset_list { uint8 count; vehicle_colour list[256]; } vehicle_colour_preset_list; -STATIC_ASSERT (sizeof(vehicle_colour_preset_list) == (1 + 256 * 3), "Improper struct size"); +assert_struct_size(vehicle_colour_preset_list, (1 + 256 * 3)); /** * Ride type structure. @@ -123,7 +123,7 @@ typedef struct rct_ride_entry { uint8 shop_item_secondary; // 0x1C1 } rct_ride_entry; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_ride_entry) == 0x1c2, "Improper struct size"); +assert_struct_size(rct_ride_entry, 0x1c2); #endif /** @@ -331,7 +331,7 @@ typedef struct rct_ride { uint16 queue_length[4]; // 0x200 uint8 pad_208[0x58]; } rct_ride; -STATIC_ASSERT (sizeof(rct_ride) == 0x260, "Improper struct size"); +assert_struct_size(rct_ride, 0x260); #define RIDE_MEASUREMENT_MAX_ITEMS 4800 @@ -352,7 +352,7 @@ typedef struct rct_ride_measurement { uint8 velocity[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x258C uint8 altitude[RIDE_MEASUREMENT_MAX_ITEMS]; // 0x384C } rct_ride_measurement; -STATIC_ASSERT (sizeof(rct_ride_measurement) == 0x4b0c, "Improper struct size"); +assert_struct_size(rct_ride_measurement, 0x4b0c); typedef struct track_begin_end { int begin_x; @@ -366,7 +366,7 @@ typedef struct track_begin_end { rct_map_element *end_element; } track_begin_end; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(track_begin_end) == 36, "Improper struct size"); +assert_struct_size(track_begin_end, 36); #endif #pragma pack(pop) diff --git a/src/ride/track.h b/src/ride/track.h index a573f312be..bbfdebeb8c 100644 --- a/src/ride/track.h +++ b/src/ride/track.h @@ -31,7 +31,7 @@ typedef struct rct_trackdefinition { uint8 special; uint8 pad[2]; } rct_trackdefinition; -STATIC_ASSERT (sizeof(rct_trackdefinition) == 8, "Improper struct size"); +assert_struct_size(rct_trackdefinition, 8); #pragma pack(pop) /** diff --git a/src/ride/track_design.h b/src/ride/track_design.h index e23db102fa..34a5e99ce0 100644 --- a/src/ride/track_design.h +++ b/src/ride/track_design.h @@ -42,14 +42,14 @@ typedef struct rct_td6_maze_element { }; }; } rct_td6_maze_element; -STATIC_ASSERT (sizeof(rct_td6_maze_element) == 0x04, "Improper struct size"); +assert_struct_size(rct_td6_maze_element, 0x04); /* Track Element entry size: 0x02 */ typedef struct rct_td6_track_element { uint8 type; // 0x00 uint8 flags; // 0x01 } rct_td6_track_element; -STATIC_ASSERT (sizeof(rct_td6_track_element) == 0x02, "Improper struct size"); +assert_struct_size(rct_td6_track_element, 0x02); /* Track Entrance entry size: 0x06 */ typedef struct rct_td6_entrance_element { @@ -58,7 +58,7 @@ typedef struct rct_td6_entrance_element { sint16 x; // 0x02 sint16 y; // 0x04 } rct_td6_entrance_element; -STATIC_ASSERT (sizeof(rct_td6_entrance_element) == 0x06, "Improper struct size"); +assert_struct_size(rct_td6_entrance_element, 0x06); /* Track Scenery entry size: 0x16 */ typedef struct rct_td6_scenery_element { @@ -70,7 +70,7 @@ typedef struct rct_td6_scenery_element { uint8 primary_colour; // 0x14 uint8 secondary_colour; // 0x15 } rct_td6_scenery_element; -STATIC_ASSERT (sizeof(rct_td6_scenery_element) == 0x16, "Improper struct size"); +assert_struct_size(rct_td6_scenery_element, 0x16); /** * Track design structure. @@ -148,7 +148,7 @@ typedef struct rct_track_td6 { } rct_track_td6; //Warning: improper struct size in comment #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_track_td6) == 0xbf, "Improper struct size"); +assert_struct_size(rct_track_td6, 0xbf); #endif #pragma pack(pop) diff --git a/src/ride/track_design_index.c b/src/ride/track_design_index.c index 6fe8f7f3fa..d2af592ce5 100644 --- a/src/ride/track_design_index.c +++ b/src/ride/track_design_index.c @@ -31,7 +31,7 @@ typedef struct td_index_item { } td_index_item; // NOTE: this is our own struct and should not get packed, but it is stored in a file // so removing packing from it would require refactoring file access -STATIC_ASSERT (sizeof(td_index_item) == 1 + 9 + 260, "Improper struct size"); +assert_struct_size(td_index_item, 1 + 9 + 260); #pragma pack(pop) static bool track_design_index_read_header(SDL_RWops *file, uint32 *tdidxCount); diff --git a/src/ride/vehicle.c b/src/ride/vehicle.c index 9143037e13..34e1a3f7ff 100644 --- a/src/ride/vehicle.c +++ b/src/ride/vehicle.c @@ -1887,7 +1887,7 @@ typedef struct rct_synchronised_vehicle { uint8 station_id; uint16 vehicle_id; } rct_synchronised_vehicle; -STATIC_ASSERT (sizeof(rct_synchronised_vehicle) == 4, "Improper struct size"); +assert_struct_size(rct_synchronised_vehicle, 4); #pragma pack(pop) // 8 synchronised vehicle info diff --git a/src/ride/vehicle.h b/src/ride/vehicle.h index b72205d96a..424fd2e21f 100644 --- a/src/ride/vehicle.h +++ b/src/ride/vehicle.h @@ -25,7 +25,7 @@ typedef struct rct_vehicle_colour { uint8 body_colour; uint8 trim_colour; } rct_vehicle_colour; -STATIC_ASSERT (sizeof(rct_vehicle_colour) == 2, "Improper struct size"); +assert_struct_size(rct_vehicle_colour, 2); /** * Ride type vehicle structure. @@ -78,7 +78,7 @@ typedef struct rct_ride_entry_vehicle { sint8* peep_loading_positions; // 0x61 , 0x7B } rct_ride_entry_vehicle; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_ride_entry_vehicle) == 0x65, "Improper struct size"); +assert_struct_size(rct_ride_entry_vehicle, 0x65); #endif typedef struct rct_vehicle { @@ -198,7 +198,7 @@ typedef struct rct_vehicle { uint8 seat_rotation; // 0xD8 uint8 target_seat_rotation; // 0xD9 } rct_vehicle; -STATIC_ASSERT (sizeof(rct_vehicle) == 0xDA, "Improper struct size"); +assert_struct_size(rct_vehicle, 0xDA); #pragma pack(pop) typedef struct train_ref { diff --git a/src/scenario.h b/src/scenario.h index b3f4cac62f..ccb0f63973 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -42,7 +42,7 @@ typedef struct rct_s6_header { uint32 magic_number; // 0x08 uint8 pad_0C[0x14]; } rct_s6_header; -STATIC_ASSERT (sizeof(rct_s6_header) == 0x20, "Improper struct size"); +assert_struct_size(rct_s6_header, 0x20); /** * SC6 information chunk @@ -60,7 +60,7 @@ typedef struct rct_s6_info { char details[256]; // 0x88 rct_object_entry entry; // 0x188 } rct_s6_info; -STATIC_ASSERT (sizeof(rct_s6_info) == 0x198, "Improper struct size"); +assert_struct_size(rct_s6_info, 0x198); /** * Scenario scores file header. @@ -72,7 +72,7 @@ typedef struct rct_scenario_scores_header { uint32 var_8; uint32 scenario_count; // 0x0C } rct_scenario_scores_header; -STATIC_ASSERT (sizeof(rct_scenario_scores_header) == 16, "Improper struct size"); +assert_struct_size(rct_scenario_scores_header, 16); typedef enum scenario_source { SCENARIO_SOURCE_RCT1, @@ -105,7 +105,7 @@ typedef struct rct_scenario_basic { // uint8 source_game; // new in OpenRCT2 // sint16 source_index; // new in OpenRCT2 } rct_scenario_basic; -STATIC_ASSERT (sizeof(rct_scenario_basic) == 0x02B0, "Improper struct size"); +assert_struct_size(rct_scenario_basic, 0x02B0); typedef struct rct_stex_entry { rct_string_id scenario_name; // 0x00 @@ -113,12 +113,10 @@ typedef struct rct_stex_entry { rct_string_id details; // 0x04 uint8 var_06; } rct_stex_entry; -STATIC_ASSERT (sizeof(rct_stex_entry) == 7, "Improper struct size"); -#pragma pack(pop) +assert_struct_size(rct_stex_entry, 7); #define g_stexEntries ((rct_stex_entry**)object_entry_groups[OBJECT_TYPE_SCENARIO_TEXT].chunks) -#pragma pack(push, 1) // This will be useful for backwards compatibility typedef struct rct_s6_data { // SC6[0] @@ -344,7 +342,7 @@ typedef struct rct_s6_data { uint16 wide_path_tile_loop_y; uint8 pad_13CE778[434]; } rct_s6_data; -STATIC_ASSERT (sizeof(rct_s6_data) == 0x46b44a, "Improper struct size"); +assert_struct_size(rct_s6_data, 0x46b44a); #pragma pack(pop) enum { @@ -399,7 +397,7 @@ typedef struct scenario_highscore_entry { } scenario_highscore_entry; // NOTE: Check if needed #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(scenario_highscore_entry) == 20, "Improper struct size"); +assert_struct_size(scenario_highscore_entry, 20); #endif typedef struct scenario_index_entry { diff --git a/src/util/sawyercoding.h b/src/util/sawyercoding.h index 7f443b7fc0..360ef82246 100644 --- a/src/util/sawyercoding.h +++ b/src/util/sawyercoding.h @@ -25,7 +25,7 @@ typedef struct sawyercoding_chunk_header { uint8 encoding; uint32 length; } sawyercoding_chunk_header; -STATIC_ASSERT (sizeof(sawyercoding_chunk_header) == 5, "Improper struct size"); +assert_struct_size(sawyercoding_chunk_header, 5); #pragma pack(pop) enum { diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index d52d3d3dc7..206326eba2 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -449,7 +449,7 @@ union { uint32 b; }; } _enabledRidePieces; -STATIC_ASSERT (sizeof(_enabledRidePieces) == 8, "Improper struct size"); +assert_struct_size(_enabledRidePieces, 8); #pragma pack(pop) static bool _trackPlaceCtrlState; diff --git a/src/world/banner.h b/src/world/banner.h index 323ce5920c..974fcb5fc1 100644 --- a/src/world/banner.h +++ b/src/world/banner.h @@ -33,7 +33,7 @@ typedef struct rct_banner { uint8 x; //0x06 uint8 y; //0x07 } rct_banner; -STATIC_ASSERT (sizeof(rct_banner) == 8, "Improper struct size"); +assert_struct_size(rct_banner, 8); #pragma pack(pop) enum{ diff --git a/src/world/climate.c b/src/world/climate.c index 5b79b3c395..9d6a856caf 100644 --- a/src/world/climate.c +++ b/src/world/climate.c @@ -39,7 +39,7 @@ typedef struct rct_weather_transition { sint8 distribution_size; sint8 distribution[24]; } rct_weather_transition; -STATIC_ASSERT (sizeof(rct_weather_transition) == 26, "Improper struct size"); +assert_struct_size(rct_weather_transition, 26); #pragma pack(pop) static const rct_weather_transition* climate_transitions[4]; diff --git a/src/world/climate.h b/src/world/climate.h index e6f1d68c8d..8b7c72797f 100644 --- a/src/world/climate.h +++ b/src/world/climate.h @@ -43,7 +43,7 @@ typedef struct rct_weather { sint8 rain_level; uint32 sprite_id; } rct_weather; -STATIC_ASSERT (sizeof(rct_weather) == 8, "Improper struct size"); +assert_struct_size(rct_weather, 8); #pragma pack(pop) #define gClimate RCT2_GLOBAL(RCT2_ADDRESS_CLIMATE, uint8) diff --git a/src/world/entrance.h b/src/world/entrance.h index d412c855cf..781fa6d1a0 100644 --- a/src/world/entrance.h +++ b/src/world/entrance.h @@ -26,7 +26,7 @@ typedef struct rct_entrance_type { uint8 scrolling_mode; // 0x06 uint8 text_height; // 0x07 } rct_entrance_type; -STATIC_ASSERT (sizeof(rct_entrance_type) == 8, "Improper struct size"); +assert_struct_size(rct_entrance_type, 8); #pragma pack(pop) #endif diff --git a/src/world/footpath.h b/src/world/footpath.h index cb64c4e715..394f8b8ff7 100644 --- a/src/world/footpath.h +++ b/src/world/footpath.h @@ -35,7 +35,7 @@ typedef struct rct_footpath_entry { uint8 var_0A; uint8 flags; // 0x0B } rct_footpath_entry; -STATIC_ASSERT (sizeof(rct_footpath_entry) == 12, "Improper struct size"); +assert_struct_size(rct_footpath_entry, 12); #pragma pack(pop) enum { diff --git a/src/world/map.h b/src/world/map.h index 7acaf3aac2..9d9e5a8329 100644 --- a/src/world/map.h +++ b/src/world/map.h @@ -26,7 +26,7 @@ typedef struct rct_map_element_surface_properties { uint8 grass_length; //6 uint8 ownership; //7 } rct_map_element_surface_properties; -STATIC_ASSERT (sizeof(rct_map_element_surface_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_surface_properties, 4); typedef struct rct_map_element_path_properties { uint8 type; //4 0xF0 Path type, 0x08 Unknown/Unused, 0x04 Set when path is diagonal, 0x03 Rotation @@ -37,7 +37,7 @@ typedef struct rct_map_element_path_properties { uint8 ride_index; }; } rct_map_element_path_properties; -STATIC_ASSERT (sizeof(rct_map_element_path_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_path_properties, 4); typedef struct rct_map_element_track_properties { uint8 type; //4 @@ -50,7 +50,7 @@ typedef struct rct_map_element_track_properties { }; uint8 ride_index; //7 } rct_map_element_track_properties; -STATIC_ASSERT (sizeof(rct_map_element_track_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_track_properties, 4); typedef struct rct_map_element_scenery_properties { uint8 type; //4 @@ -58,7 +58,7 @@ typedef struct rct_map_element_scenery_properties { uint8 colour_1; //6 uint8 colour_2; //7 } rct_map_element_scenery_properties; -STATIC_ASSERT (sizeof(rct_map_element_scenery_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_scenery_properties, 4); typedef struct rct_map_element_entrance_properties { uint8 type; //4 @@ -66,19 +66,19 @@ typedef struct rct_map_element_entrance_properties { uint8 path_type; //6 uint8 ride_index; //7 } rct_map_element_entrance_properties; -STATIC_ASSERT (sizeof(rct_map_element_entrance_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_entrance_properties, 4); typedef struct rct_map_element_fence_properties { uint8 type; //4 uint8 item[3]; //5 } rct_map_element_fence_properties; -STATIC_ASSERT (sizeof(rct_map_element_fence_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_fence_properties, 4); typedef struct rct_map_element_scenerymultiple_properties { uint16 type; //4 uint8 colour[2]; //6 } rct_map_element_scenerymultiple_properties; -STATIC_ASSERT (sizeof(rct_map_element_scenerymultiple_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_scenerymultiple_properties, 4); typedef struct rct_map_element_banner_properties { uint8 index; //4 @@ -86,7 +86,7 @@ typedef struct rct_map_element_banner_properties { uint8 flags; //6 uint8 unused; //7 } rct_map_element_banner_properties; -STATIC_ASSERT (sizeof(rct_map_element_banner_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_banner_properties, 4); typedef union { rct_map_element_surface_properties surface; @@ -98,7 +98,7 @@ typedef union { rct_map_element_scenerymultiple_properties scenerymultiple; rct_map_element_banner_properties banner; } rct_map_element_properties; -STATIC_ASSERT (sizeof(rct_map_element_properties) == 4, "Improper struct size"); +assert_struct_size(rct_map_element_properties, 4); /** * Map element structure @@ -111,7 +111,7 @@ typedef struct rct_map_element { uint8 clearance_height; //3 rct_map_element_properties properties; } rct_map_element; -STATIC_ASSERT (sizeof(rct_map_element) == 8, "Improper struct size"); +assert_struct_size(rct_map_element, 8); #pragma pack(pop) enum { @@ -250,34 +250,34 @@ typedef struct rct_xy8 { uint16 xy; }; } rct_xy8; -STATIC_ASSERT (sizeof(rct_xy8) == 2, "Improper struct size"); +assert_struct_size(rct_xy8, 2); typedef struct rct_xyz8 { uint8 x, y, z; } rct_xyz8; -STATIC_ASSERT (sizeof(rct_xyz8) == 3, "Improper struct size"); +assert_struct_size(rct_xyz8, 3); typedef struct rct_xyzd8 { uint8 x, y, z, direction; } rct_xyzd8; -STATIC_ASSERT (sizeof(rct_xyzd8) == 4, "Improper struct size"); +assert_struct_size(rct_xyzd8, 4); typedef struct rct_xy16 { sint16 x, y; } rct_xy16; -STATIC_ASSERT (sizeof(rct_xy16) == 4, "Improper struct size"); +assert_struct_size(rct_xy16, 4); typedef struct rct_xyz16 { sint16 x, y, z; } rct_xyz16; -STATIC_ASSERT (sizeof(rct_xyz16) == 6, "Improper struct size"); +assert_struct_size(rct_xyz16, 6); typedef struct rct_xy_element { int x, y; rct_map_element *element; } rct_xy_element; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_xy_element) == 12, "Improper struct size"); +assert_struct_size(rct_xy_element, 12); #endif typedef struct rct2_peep_spawn { @@ -286,7 +286,7 @@ typedef struct rct2_peep_spawn { uint8 z; uint8 direction; } rct2_peep_spawn; -STATIC_ASSERT (sizeof(rct2_peep_spawn) == 6, "Improper struct size"); +assert_struct_size(rct2_peep_spawn, 6); #pragma pack(pop) enum { @@ -445,7 +445,7 @@ typedef struct map_element_iterator { rct_map_element *element; } map_element_iterator; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(map_element_iterator) == 12, "Improper struct size"); +assert_struct_size(map_element_iterator, 12); #endif void map_element_iterator_begin(map_element_iterator *it); diff --git a/src/world/map_animation.h b/src/world/map_animation.h index 245937d97e..6f1a2f0353 100644 --- a/src/world/map_animation.h +++ b/src/world/map_animation.h @@ -30,7 +30,7 @@ typedef struct rct_map_animation { uint16 x; uint16 y; } rct_map_animation; -STATIC_ASSERT (sizeof(rct_map_animation) == 6, "Improper struct size"); +assert_struct_size(rct_map_animation, 6); #pragma pack(pop) enum { diff --git a/src/world/scenery.h b/src/world/scenery.h index bc0fa7132b..145761db2a 100644 --- a/src/world/scenery.h +++ b/src/world/scenery.h @@ -34,7 +34,7 @@ typedef struct rct_small_scenery_entry { uint16 var_18; uint8 scenery_tab_id; // 0x1A } rct_small_scenery_entry; -STATIC_ASSERT (sizeof(rct_small_scenery_entry) == 21, "Improper struct size"); +assert_struct_size(rct_small_scenery_entry, 21); typedef enum { SMALL_SCENERY_FLAG_FULL_TILE = (1 << 0), // 0x1 @@ -74,7 +74,7 @@ typedef struct rct_large_scenery_tile { uint8 z_clearance; uint16 var_7; } rct_large_scenery_tile; -STATIC_ASSERT (sizeof(rct_large_scenery_tile) == 9, "Improper struct size"); +assert_struct_size(rct_large_scenery_tile, 9); typedef struct rct_large_scenery_text_glyph { uint8 image_offset; @@ -82,7 +82,7 @@ typedef struct rct_large_scenery_text_glyph { uint8 height; uint8 var_3; } rct_large_scenery_text_glyph; -STATIC_ASSERT (sizeof(rct_large_scenery_text_glyph) == 4, "Improper struct size"); +assert_struct_size(rct_large_scenery_text_glyph, 4); typedef struct rct_large_scenery_text { rct_xy16 offset[2]; // 0x0 @@ -91,7 +91,7 @@ typedef struct rct_large_scenery_text { uint16 var_C; // 0xC rct_large_scenery_text_glyph glyphs[256]; // 0xE } rct_large_scenery_text; -STATIC_ASSERT (sizeof(rct_large_scenery_text) == 14 + 4 * 256, "Improper struct size"); +assert_struct_size(rct_large_scenery_text, 14 + 4 * 256); typedef struct rct_large_scenery_entry { uint8 tool_id; // 0x06 @@ -105,7 +105,7 @@ typedef struct rct_large_scenery_entry { uint32 text_image; // 0x16 } rct_large_scenery_entry; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_large_scenery_entry) == 20, "Improper struct size"); +assert_struct_size(rct_large_scenery_entry, 20); #endif typedef struct rct_wall_scenery_entry { @@ -117,7 +117,7 @@ typedef struct rct_wall_scenery_entry { uint8 scenery_tab_id; // 0x0C uint8 var_0D; } rct_wall_scenery_entry; -STATIC_ASSERT (sizeof(rct_wall_scenery_entry) == 8, "Improper struct size"); +assert_struct_size(rct_wall_scenery_entry, 8); typedef enum { WALL_SCENERY_FLAG1 = (1 << 0), // 0x1 @@ -141,7 +141,7 @@ typedef struct rct_path_bit_scenery_entry { sint16 price; // 0x0A uint8 scenery_tab_id; // 0x0C } rct_path_bit_scenery_entry; -STATIC_ASSERT (sizeof(rct_path_bit_scenery_entry) == 7, "Improper struct size"); +assert_struct_size(rct_path_bit_scenery_entry, 7); typedef struct rct_banner_scenery_entry { uint8 scrolling_mode; // 0x06 @@ -149,7 +149,7 @@ typedef struct rct_banner_scenery_entry { sint16 price; // 0x08 uint8 scenery_tab_id; // 0x0A } rct_banner_scenery_entry; -STATIC_ASSERT (sizeof(rct_banner_scenery_entry) == 5, "Improper struct size"); +assert_struct_size(rct_banner_scenery_entry, 5); typedef struct rct_scenery_entry { rct_string_id name; // 0x00 @@ -163,7 +163,7 @@ typedef struct rct_scenery_entry { }; } rct_scenery_entry; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_scenery_entry) == 6 + 21, "Improper struct size"); +assert_struct_size(rct_scenery_entry, 6 + 21); #endif typedef struct rct_scenery_set_entry { @@ -176,7 +176,7 @@ typedef struct rct_scenery_set_entry { uint8 pad_109; uint32 var_10A; } rct_scenery_set_entry; -STATIC_ASSERT (sizeof(rct_scenery_set_entry) == 14 + 2 * 0x80, "Improper struct size"); +assert_struct_size(rct_scenery_set_entry, 14 + 2 * 0x80); #pragma pack(pop) enum { diff --git a/src/world/sprite.h b/src/world/sprite.h index a086c20ac5..d80fc0428a 100644 --- a/src/world/sprite.h +++ b/src/world/sprite.h @@ -76,7 +76,7 @@ typedef struct rct_unk_sprite { uint8 pad_2C[0x45]; uint8 var_71; } rct_unk_sprite; -STATIC_ASSERT (sizeof(rct_unk_sprite) == 0x72, "Improper struct size"); +assert_struct_size(rct_unk_sprite, 0x72); typedef struct rct_litter { uint8 sprite_identifier; // 0x00 @@ -98,7 +98,7 @@ typedef struct rct_litter { uint8 pad_1F[5]; uint32 creationTick; // 0x24 } rct_litter; -STATIC_ASSERT (sizeof(rct_litter) == 0x28, "Improper struct size"); +assert_struct_size(rct_litter, 0x28); typedef struct rct_balloon { uint8 sprite_identifier; // 0x00 @@ -128,7 +128,7 @@ typedef struct rct_balloon { uint8 colour; // 0x2C uint8 var_2D; } rct_balloon; -STATIC_ASSERT (sizeof(rct_balloon) == 0x2e, "Improper struct size"); +assert_struct_size(rct_balloon, 0x2e); typedef struct rct_duck { uint8 sprite_identifier; // 0x00 @@ -155,7 +155,7 @@ typedef struct rct_duck { uint8 pad_34[0x14]; uint8 state; // 0x48 } rct_duck; -STATIC_ASSERT (sizeof(rct_duck) == 0x49, "Improper struct size"); +assert_struct_size(rct_duck, 0x49); typedef struct rct_jumping_fountain { uint8 sprite_identifier; // 0x00 @@ -190,7 +190,7 @@ typedef struct rct_jumping_fountain { uint8 pad_34[0x12]; uint16 iteration; // 0x46 } rct_jumping_fountain; -STATIC_ASSERT (sizeof(rct_jumping_fountain) == 0x48, "Improper struct size"); +assert_struct_size(rct_jumping_fountain, 0x48); typedef struct rct_money_effect { uint8 sprite_identifier; // 0x00 @@ -215,7 +215,7 @@ typedef struct rct_money_effect { sint16 offset_x; // 0x44 uint16 wiggle; // 0x46 } rct_money_effect; -STATIC_ASSERT (sizeof(rct_money_effect) == 0x48, "Improper struct size"); +assert_struct_size(rct_money_effect, 0x48); typedef struct rct_crashed_vehicle_particle { uint8 sprite_identifier; // 0x00 @@ -258,7 +258,7 @@ typedef struct rct_crashed_vehicle_particle { uint8 pad_44[0x2D]; uint8 var_71; } rct_crashed_vehicle_particle; -STATIC_ASSERT (sizeof(rct_crashed_vehicle_particle) == 0x45 + 0x2D, "Improper struct size"); +assert_struct_size(rct_crashed_vehicle_particle, 0x45 + 0x2D); typedef struct rct_crash_splash { uint8 sprite_identifier; // 0x00 @@ -288,7 +288,7 @@ typedef struct rct_crash_splash { uint16 var_24; uint16 frame; // 0x26 } rct_crash_splash; -STATIC_ASSERT (sizeof(rct_crash_splash) == 0x28, "Improper struct size"); +assert_struct_size(rct_crash_splash, 0x28); typedef struct rct_steam_particle { uint8 sprite_identifier; // 0x00 @@ -318,7 +318,7 @@ typedef struct rct_steam_particle { uint16 var_24; uint16 frame; // 0x26 } rct_steam_particle; -STATIC_ASSERT (sizeof(rct_steam_particle) == 0x28, "Improper struct size"); +assert_struct_size(rct_steam_particle, 0x28); /** * Sprite structure. @@ -338,7 +338,7 @@ typedef union { rct_crash_splash crash_splash; rct_steam_particle steam_particle; } rct_sprite; -STATIC_ASSERT (sizeof(rct_sprite) == 0x100, "Improper struct size"); +assert_struct_size(rct_sprite, 0x100); typedef struct rct_sprite_bounds { uint8 sprite_width; // 0x00 @@ -346,14 +346,14 @@ typedef struct rct_sprite_bounds { uint8 sprite_height_positive; // 0x02 uint8 unused; // 0x03 } rct_sprite_bounds; -STATIC_ASSERT (sizeof(rct_sprite_bounds) == 4, "Improper struct size"); +assert_struct_size(rct_sprite_bounds, 4); typedef struct rct_sprite_image { uint32 base_image; // 0x00 uint8* unkn_04; // 0x04 } rct_sprite_image; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_sprite_image) == 8, "Improper struct size"); +assert_struct_size(rct_sprite_image, 8); #endif typedef struct rct_sprite_entry { @@ -361,7 +361,7 @@ typedef struct rct_sprite_entry { rct_sprite_bounds *sprite_bounds; // 0x04 } rct_sprite_entry; #ifdef PLATFORM_32BIT -STATIC_ASSERT (sizeof(rct_sprite_entry) == 8, "Improper struct size"); +assert_struct_size(rct_sprite_entry, 8); #endif #pragma pack(pop) diff --git a/src/world/water.h b/src/world/water.h index 35032277af..b7ad3e497f 100644 --- a/src/world/water.h +++ b/src/world/water.h @@ -27,7 +27,7 @@ typedef struct rct_water_type { uint32 var_0A; uint16 var_0E; } rct_water_type; -STATIC_ASSERT (sizeof(rct_water_type) == 16, "Improper struct size"); +assert_struct_size(rct_water_type, 16); #pragma pack(pop) #endif