From 119cfe8212926550029b21ac9e5e00c198bb73ec Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 07:34:29 +0300 Subject: [PATCH] Remove static assertions They were aid to decompilation, now they are source of complaints when compiling for x64. --- src/animation.h | 2 -- src/art.h | 2 -- src/audio_file.cc | 2 -- src/automap.cc | 2 -- src/cache.cc | 3 --- src/character_editor.cc | 1 - src/combat_defs.h | 4 ---- src/core.h | 2 -- src/dfile.cc | 5 ----- src/game_dialog.cc | 1 - src/heap.cc | 6 ------ src/inventory.cc | 3 --- src/item.cc | 1 - src/nevs.cc | 2 -- src/obj_types.h | 4 ---- src/options.cc | 1 - src/options.h | 2 -- src/proto_instance.cc | 1 - src/proto_types.h | 12 ------------ src/region.cc | 2 -- src/scripts.cc | 1 - src/scripts.h | 8 -------- src/skill.cc | 2 -- src/sound.cc | 2 -- src/sound_decoder.h | 4 ---- src/sound_effects_cache.cc | 2 -- src/text_font.cc | 2 -- src/text_font.h | 2 -- src/text_object.cc | 2 -- src/window.h | 1 - src/window_manager.cc | 4 ---- src/world_map.cc | 7 ------- 32 files changed, 95 deletions(-) diff --git a/src/animation.h b/src/animation.h index d545c53..a96b9f9 100644 --- a/src/animation.h +++ b/src/animation.h @@ -194,8 +194,6 @@ typedef struct STRUCT_530014 { }; } STRUCT_530014; -static_assert(sizeof(STRUCT_530014) == 3240, "wrong size"); - typedef Object* PathBuilderCallback(Object* object, int tile, int elevation); extern int _curr_sad; diff --git a/src/art.h b/src/art.h index add05d5..c537fdb 100644 --- a/src/art.h +++ b/src/art.h @@ -80,8 +80,6 @@ typedef struct Art { } Art; #pragma pack() -static_assert(sizeof(Art) == 62, "wrong size"); - typedef struct ArtFrame { short width; short height; diff --git a/src/audio_file.cc b/src/audio_file.cc index c6fcca9..64a85b4 100644 --- a/src/audio_file.cc +++ b/src/audio_file.cc @@ -12,8 +12,6 @@ #define WIN32_LEAN_AND_MEAN #include -static_assert(sizeof(AudioFile) == 28, "wrong size"); - // 0x5108C0 AudioFileIsCompressedProc* _queryCompressedFunc_2 = _defaultCompressionFunc__; diff --git a/src/automap.cc b/src/automap.cc index 33bcdfd..b2bcf76 100644 --- a/src/automap.cc +++ b/src/automap.cc @@ -260,8 +260,6 @@ int _automapDisplayMap(int map) void automapShow(bool isInGame, bool isUsingScanner) { int frmIds[AUTOMAP_FRM_COUNT]; - - static_assert(sizeof(frmIds) == sizeof(gAutomapFrmIds), "wrong size"); memcpy(frmIds, gAutomapFrmIds, sizeof(gAutomapFrmIds)); unsigned char* frmData[AUTOMAP_FRM_COUNT]; diff --git a/src/cache.cc b/src/cache.cc index 4fd1a31..e6ed0b3 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -8,9 +8,6 @@ #include #include -static_assert(sizeof(CacheEntry) == 32, "wrong size"); -static_assert(sizeof(Cache) == 84, "wrong size"); - // 0x510938 int _lock_sound_ticker = 0; diff --git a/src/character_editor.cc b/src/character_editor.cc index 3431ec7..2d176b5 100644 --- a/src/character_editor.cc +++ b/src/character_editor.cc @@ -4477,7 +4477,6 @@ void _RestorePlayer() char* _itostndn(int value, char* dest) { int v16[7]; - static_assert(sizeof(v16) == sizeof(dword_431DD4), "wrong size"); memcpy(v16, dword_431DD4, sizeof(v16)); char* savedDest = dest; diff --git a/src/combat_defs.h b/src/combat_defs.h index ba1b448..b29816b 100644 --- a/src/combat_defs.h +++ b/src/combat_defs.h @@ -104,8 +104,6 @@ typedef struct STRUCT_664980 { int field_24; // flags on defender } STRUCT_664980; -static_assert(sizeof(STRUCT_664980) == 40, "wrong size"); - typedef struct Attack { Object* attacker; int hitMode; @@ -130,8 +128,6 @@ typedef struct Attack { int extrasKnockback[EXPLOSION_TARGET_COUNT]; } Attack; -static_assert(sizeof(Attack) == 184, "wrong size"); - // Provides metadata about critical hit effect. typedef struct CriticalHitDescription { int damageMultiplier; diff --git a/src/core.h b/src/core.h index 0bf9188..04dd262 100644 --- a/src/core.h +++ b/src/core.h @@ -404,8 +404,6 @@ typedef struct STRUCT_51E2F0 { }; } STRUCT_51E2F0; -static_assert(sizeof(STRUCT_51E2F0) == 24, "wrong size"); - typedef struct LogicalKeyEntry { short field_0; short unmodified; diff --git a/src/dfile.cc b/src/dfile.cc index f397bcf..3595798 100644 --- a/src/dfile.cc +++ b/src/dfile.cc @@ -8,11 +8,6 @@ #include #include -static_assert(sizeof(DBase) == 20, "wrong size"); -static_assert(sizeof(DBaseEntry) == 20, "wrong size"); -static_assert(sizeof(DFile) == 44, "wrong size"); -static_assert(sizeof(DFileFindData) == 524, "wrong size"); - // Reads .DAT file contents. // // 0x4E4F58 diff --git a/src/game_dialog.cc b/src/game_dialog.cc index b1381e8..01e5caa 100644 --- a/src/game_dialog.cc +++ b/src/game_dialog.cc @@ -3410,7 +3410,6 @@ void gameDialogCombatControlButtonOnMouseUp(int btn, int keyCode) int _gdPickAIUpdateMsg(Object* critter) { int pids[3]; - static_assert(sizeof(pids) == sizeof(_Dogs), "wrong size"); memcpy(pids, _Dogs, sizeof(pids)); for (int index = 0; index < 3; index++) { diff --git a/src/heap.cc b/src/heap.cc index c7f5215..9028f7a 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -7,12 +7,6 @@ #include #include -static_assert(sizeof(HeapBlockHeader) == 16, "wrong size"); -static_assert(sizeof(HeapBlockFooter) == 4, "wrong size"); -static_assert(sizeof(HeapMoveableExtent) == 16, "wrong size"); -static_assert(sizeof(HeapHandle) == 8, "wrong size"); -static_assert(sizeof(Heap) == 48, "wrong size"); - // An array of pointers to free heap blocks. // // 0x518E9C diff --git a/src/inventory.cc b/src/inventory.cc index d11347f..6c670fc 100644 --- a/src/inventory.cc +++ b/src/inventory.cc @@ -2198,11 +2198,9 @@ int objectGetCarriedQuantityByPid(Object* object, int pid) void inventoryRenderSummary() { int v56[7]; - static_assert(sizeof(v56) == sizeof(dword_46E6D0), "wrong size"); memcpy(v56, dword_46E6D0, sizeof(v56)); int v57[7]; - static_assert(sizeof(v57) == sizeof(dword_46E6EC), "wrong size"); memcpy(v57, dword_46E6EC, sizeof(v57)); char formattedText[80]; @@ -3278,7 +3276,6 @@ int inventoryOpenLooting(Object* a1, Object* a2) CacheEntry* arrowFrmHandles[INVENTORY_ARROW_FRM_COUNT]; MessageListItem messageListItem; - static_assert(sizeof(arrowFrmIds) == sizeof(gInventoryArrowFrmIds), "wrong size"); memcpy(arrowFrmIds, gInventoryArrowFrmIds, sizeof(gInventoryArrowFrmIds)); if (a1 != _inven_dude) { diff --git a/src/item.cc b/src/item.cc index 5545fcc..b0fdbc3 100644 --- a/src/item.cc +++ b/src/item.cc @@ -372,7 +372,6 @@ void _item_compact(int inventoryItemIndex, Inventory* inventory) for (int index = inventoryItemIndex + 1; index < inventory->length; index++) { InventoryItem* prev = &(inventory->items[index - 1]); InventoryItem* curr = &(inventory->items[index]); - static_assert(sizeof(*prev) == sizeof(*curr), "wrong size"); memcpy(prev, curr, sizeof(*prev)); } inventory->length--; diff --git a/src/nevs.cc b/src/nevs.cc index 99d7307..4fd5afe 100644 --- a/src/nevs.cc +++ b/src/nevs.cc @@ -6,8 +6,6 @@ #include #include -static_assert(sizeof(Nevs) == 60, "wrong size"); - // 0x6391C8 Nevs* _nevs; diff --git a/src/obj_types.h b/src/obj_types.h index 96ff8af..e765e2e 100644 --- a/src/obj_types.h +++ b/src/obj_types.h @@ -245,10 +245,6 @@ typedef struct Object { int field_80; } Object; -#ifdef _WIN32 -static_assert(sizeof(Object) == 132, "wrong size"); -#endif - typedef struct ObjectListNode { Object* obj; struct ObjectListNode* next; diff --git a/src/options.cc b/src/options.cc index eb9f16d..24c2bb3 100644 --- a/src/options.cc +++ b/src/options.cc @@ -599,7 +599,6 @@ int showPause(bool a1) CacheEntry* frmHandles[PAUSE_WINDOW_FRM_COUNT]; Size frmSizes[PAUSE_WINDOW_FRM_COUNT]; - static_assert(sizeof(graphicIds) == sizeof(gPauseWindowFrmIds), "wrong size"); memcpy(graphicIds, gPauseWindowFrmIds, sizeof(gPauseWindowFrmIds)); bool gameMouseWasVisible; diff --git a/src/options.h b/src/options.h index 341ba35..0e6da35 100644 --- a/src/options.h +++ b/src/options.h @@ -99,8 +99,6 @@ typedef struct PreferenceDescription { } PreferenceDescription; #pragma pack() -static_assert(sizeof(PreferenceDescription) == 76, "wrong size"); - extern const int _row1Ytab[5]; extern const int _row2Ytab[6]; extern const int _row3Ytab[8]; diff --git a/src/proto_instance.cc b/src/proto_instance.cc index 28f0744..dc28e6d 100644 --- a/src/proto_instance.cc +++ b/src/proto_instance.cc @@ -916,7 +916,6 @@ int _obj_use_power_on_car(Object* item) MessageListItem messageListItem; int messageNum; - static_assert(sizeof(messageListItem) == sizeof(stru_49A990), "wrong size"); memcpy(&messageListItem, &stru_49A990, sizeof(messageListItem)); bool isEnergy = false; diff --git a/src/proto_types.h b/src/proto_types.h index 16f0d22..782b0df 100644 --- a/src/proto_types.h +++ b/src/proto_types.h @@ -324,8 +324,6 @@ typedef struct ItemProto { unsigned char field_80; } ItemProto; -static_assert(sizeof(ItemProto) == 0x84, "wrong size"); - typedef struct CritterProtoData { int flags; // d.flags int baseStats[35]; // d.stat_base @@ -353,8 +351,6 @@ typedef struct CritterProto { int team; // team_num } CritterProto; -static_assert(sizeof(CritterProto) == 0x1A0, "wrong size"); - typedef struct { int openFlags; // d.open_flags int keyCode; // d.key_code @@ -404,8 +400,6 @@ typedef struct SceneryProto { unsigned char field_34; } SceneryProto; -static_assert(sizeof(SceneryProto) == 0x38, "wrong size"); - typedef struct WallProto { int pid; // id int messageId; // message_num @@ -418,8 +412,6 @@ typedef struct WallProto { int material; // material } WallProto; -static_assert(sizeof(WallProto) == 0x24, "wrong size"); - typedef struct TileProto { int pid; // id int messageId; // message_num @@ -430,8 +422,6 @@ typedef struct TileProto { int material; // material } TileProto; -static_assert(sizeof(TileProto) == 0x1C, "wrong size"); - typedef struct MiscProto { int pid; // id int messageId; // message_num @@ -442,8 +432,6 @@ typedef struct MiscProto { int extendedFlags; // flags_ext } MiscProto; -static_assert(sizeof(MiscProto) == 0x1C, "wrong size"); - typedef union Proto { struct { int pid; // pid diff --git a/src/region.cc b/src/region.cc index 9612f04..f6934d4 100644 --- a/src/region.cc +++ b/src/region.cc @@ -6,8 +6,6 @@ #include #include -static_assert(sizeof(Region) == 140, "wrong size"); - char _aNull[] = ""; // Probably recalculates bounding box of the region. diff --git a/src/scripts.cc b/src/scripts.cc index 28bf86f..dd183a3 100644 --- a/src/scripts.cc +++ b/src/scripts.cc @@ -1040,7 +1040,6 @@ int scriptsRequestCombat(STRUCT_664980* a1) } if (a1) { - static_assert(sizeof(stru_664958) == sizeof(*a1), "wrong size"); memcpy(&stru_664958, a1, sizeof(stru_664958)); } else { gScriptsRequests |= SCRIPT_REQUEST_0x40; diff --git a/src/scripts.h b/src/scripts.h index 2db98bd..2c3671b 100644 --- a/src/scripts.h +++ b/src/scripts.h @@ -76,8 +76,6 @@ typedef enum ScriptProc { SCRIPT_PROC_COUNT, } ScriptProc; -static_assert(SCRIPT_PROC_COUNT == 28, "wrong count"); - typedef struct ScriptsListEntry { char name[16]; int local_vars_num; @@ -150,8 +148,6 @@ typedef struct Script { int field_DC; } Script; -static_assert(sizeof(Script) == 0xE0, "wrong size"); - typedef struct ScriptListExtent { Script scripts[SCRIPT_LIST_EXTENT_SIZE]; // Number of scripts in the extent @@ -159,8 +155,6 @@ typedef struct ScriptListExtent { struct ScriptListExtent* next; } ScriptListExtent; -static_assert(sizeof(ScriptListExtent) == 0xE08, "wrong size"); - typedef struct ScriptList { ScriptListExtent* head; ScriptListExtent* tail; @@ -169,8 +163,6 @@ typedef struct ScriptList { int nextScriptId; } ScriptList; -static_assert(sizeof(ScriptList) == 0x10, "wrong size"); - extern char _Error_2[]; extern char byte_50D6C0[]; diff --git a/src/skill.cc b/src/skill.cc index 2b21bf9..44c5611 100644 --- a/src/skill.cc +++ b/src/skill.cc @@ -667,7 +667,6 @@ int skillUse(Object* obj, Object* a2, int skill, int criticalChanceModifier) if (critterGetBodyType(a2) != BODY_TYPE_ROBOTIC && critterIsCrippled(a2)) { int flags[HEALABLE_DAMAGE_FLAGS_LENGTH]; - static_assert(sizeof(flags) == sizeof(gHealableDamageFlags), "wrong size"); memcpy(flags, gHealableDamageFlags, sizeof(gHealableDamageFlags)); for (int index = 0; index < HEALABLE_DAMAGE_FLAGS_LENGTH; index++) { @@ -852,7 +851,6 @@ int skillUse(Object* obj, Object* a2, int skill, int criticalChanceModifier) if (currentHp < maximumHp || critterIsCrippled(a2)) { int flags[REPAIRABLE_DAMAGE_FLAGS_LENGTH]; - static_assert(sizeof(flags) == sizeof(gRepairableDamageFlags), "wrong size"); memcpy(flags, gRepairableDamageFlags, sizeof(gRepairableDamageFlags)); paletteFadeTo(gPaletteBlack); diff --git a/src/sound.cc b/src/sound.cc index 356d541..56f3fdc 100644 --- a/src/sound.cc +++ b/src/sound.cc @@ -9,8 +9,6 @@ #include #include -static_assert(sizeof(Sound) == 156, "wrong size"); - // 0x51D478 STRUCT_51D478* _fadeHead = NULL; diff --git a/src/sound_decoder.h b/src/sound_decoder.h index b81d337..1a4d22e 100644 --- a/src/sound_decoder.h +++ b/src/sound_decoder.h @@ -39,10 +39,6 @@ typedef struct SoundDecoder { int field_50; } SoundDecoder; -#if _WIN32 -static_assert(sizeof(SoundDecoder) == 84, "wrong size"); -#endif - typedef int (*DECODINGPROC)(SoundDecoder* soundDecoder, int offset, int bits); extern int gSoundDecodersCount; diff --git a/src/sound_effects_cache.cc b/src/sound_effects_cache.cc index abd534d..62c5f3a 100644 --- a/src/sound_effects_cache.cc +++ b/src/sound_effects_cache.cc @@ -12,8 +12,6 @@ #include #include -static_assert(sizeof(SoundEffect) == 32, "wrong size"); - // 0x50DE04 const char* off_50DE04 = ""; diff --git a/src/text_font.cc b/src/text_font.cc index ead4885..54efe4a 100644 --- a/src/text_font.cc +++ b/src/text_font.cc @@ -70,7 +70,6 @@ int textFontsInit() int currentFont = -1; FontManager fontManager; - static_assert(sizeof(fontManager) == sizeof(gTextFontManager), "wrong size"); memcpy(&fontManager, &gTextFontManager, sizeof(fontManager)); for (int font = 0; font < TEXT_FONT_MAX; font++) { @@ -192,7 +191,6 @@ int fontManagerAdd(FontManager* fontManager) } } - static_assert(sizeof(*gFontManagers) == sizeof(*fontManager), "wrong size"); memcpy(&(gFontManagers[gFontManagersCount]), fontManager, sizeof(*fontManager)); gFontManagersCount++; diff --git a/src/text_font.h b/src/text_font.h index bd59028..6c546e7 100644 --- a/src/text_font.h +++ b/src/text_font.h @@ -31,8 +31,6 @@ typedef struct FontManager { FontManagerGetMonospacedCharacterWidth* getMonospacedCharacterWidthProc; } FontManager; -static_assert(sizeof(FontManager) == 44, "wrong size"); - typedef struct TextFontGlyph { // The width of the glyph in pixels. int width; diff --git a/src/text_object.cc b/src/text_object.cc index 7b41c1a..39c749b 100644 --- a/src/text_object.cc +++ b/src/text_object.cc @@ -10,8 +10,6 @@ #include "tile.h" #include "word_wrap.h" -static_assert(sizeof(TextObject) == 48, "wrong size"); - // 0x51D944 int gTextObjectsCount = 0; diff --git a/src/window.h b/src/window.h index b1f9738..06e7071 100644 --- a/src/window.h +++ b/src/window.h @@ -42,7 +42,6 @@ typedef struct ManagedButton { int field_74; int field_78; } ManagedButton; -static_assert(sizeof(ManagedButton) == 0x7C, "wrong size"); typedef struct ManagedWindow { char name[32]; diff --git a/src/window_manager.cc b/src/window_manager.cc index 5728f5a..47c2b5f 100644 --- a/src/window_manager.cc +++ b/src/window_manager.cc @@ -12,10 +12,6 @@ #include -static_assert(sizeof(struc_177) == 572, "wrong size"); -static_assert(sizeof(Window) == 68, "wrong size"); -static_assert(sizeof(Button) == 124, "wrong size"); - // 0x50FA30 char _path_patches[] = ""; diff --git a/src/world_map.cc b/src/world_map.cc index 1d2cf5d..eaabc32 100644 --- a/src/world_map.cc +++ b/src/world_map.cc @@ -37,10 +37,6 @@ #include #include -static_assert(sizeof(Terrain) == 128, "wrong size"); -static_assert(sizeof(ENC_BASE_TYPE) == 3056, "wrong size"); -static_assert(sizeof(EncounterTable) == 7460, "wrong size"); - #define WM_TILE_WIDTH (350) #define WM_TILE_HEIGHT (300) @@ -2693,7 +2689,6 @@ bool _wmMapCanRestHere(int elevation) int flags[3]; // NOTE: I'm not sure why they're copied. - static_assert(sizeof(flags) == sizeof(_can_rest_here), "wrong size"); memcpy(flags, _can_rest_here, sizeof(flags)); MapInfo* map = &(gMaps[gMapHeader.field_34]); @@ -3250,7 +3245,6 @@ int _wmRndEncounterOccurred() int modifiers[DAY_PART_COUNT]; // NOTE: I'm not sure why they're copied. - static_assert(sizeof(modifiers) == sizeof(gDayPartEncounterFrequencyModifiers), "wrong size"); memcpy(modifiers, gDayPartEncounterFrequencyModifiers, sizeof(gDayPartEncounterFrequencyModifiers)); frequency -= modifiers[dayPart]; @@ -5958,7 +5952,6 @@ int carGetCity() int _wmCarGiveToParty() { MessageListItem messageListItem; - static_assert(sizeof(messageListItem) == sizeof(stru_4BC880), "wrong size"); memcpy(&messageListItem, &stru_4BC880, sizeof(MessageListItem)); if (gWorldmapCarFuel <= 0) {