From ad1fb7765b798d8d9657da50b41756106b4c380d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0imek?= Date: Sat, 28 May 2022 05:55:42 +0200 Subject: [PATCH 1/9] Remove the use of stdbool (#19) It should not be needed anymore after the migration to C++ --- src/actions.h | 2 -- src/animation.h | 2 -- src/audio_file.h | 2 -- src/automap.h | 2 -- src/autorun.h | 2 -- src/cache.h | 2 -- src/character_selector.h | 2 -- src/color.h | 1 - src/combat_ai.h | 2 -- src/config.h | 2 -- src/core.h | 2 -- src/credits.h | 2 -- src/critter.h | 2 -- src/cycle.h | 2 -- src/db.h | 1 - src/dfile.h | 1 - src/dictionary.cc | 1 - src/display_monitor.h | 2 -- src/endgame.h | 2 -- src/file_find.h | 2 -- src/file_utils.cc | 1 - src/font_manager.h | 2 -- src/game.h | 2 -- src/game_config.h | 2 -- src/game_dialog.h | 2 -- src/game_mouse.h | 2 -- src/game_movie.h | 2 -- src/game_sound.cc | 1 - src/game_sound.h | 2 -- src/heap.h | 2 -- src/interface.h | 2 -- src/interpreter.h | 1 - src/interpreter_extra.h | 2 -- src/inventory.h | 2 -- src/item.h | 2 -- src/light.h | 2 -- src/lips.h | 1 - src/loadsave.h | 2 -- src/main.h | 2 -- src/map.h | 2 -- src/map_defs.h | 2 -- src/message.h | 2 -- src/mmx.h | 2 -- src/movie_effect.h | 2 -- src/movie_lib.h | 2 -- src/options.h | 2 -- src/party_member.h | 2 -- src/perk.h | 2 -- src/pipboy.h | 2 -- src/proto_instance.h | 2 -- src/queue.h | 2 -- src/scripts.h | 2 -- src/sfall_config.h | 2 -- src/skill.h | 2 -- src/skilldex.h | 2 -- src/sound_decoder.h | 1 - src/sound_effects_cache.h | 2 -- src/sound_effects_list.h | 2 -- src/stat.h | 2 -- src/text_font.h | 2 -- src/text_object.h | 2 -- src/tile.h | 2 -- src/trait.h | 2 -- src/win32.h | 2 -- src/window.h | 2 -- src/window_manager.h | 1 - src/window_manager_private.h | 2 -- src/world_map.h | 2 -- src/xfile.h | 1 - 69 files changed, 127 deletions(-) diff --git a/src/actions.h b/src/actions.h index 412e360..f64e775 100644 --- a/src/actions.h +++ b/src/actions.h @@ -5,8 +5,6 @@ #include "obj_types.h" #include "proto_types.h" -#include - extern int _action_in_explode; extern const int gNormalDeathAnimations[DAMAGE_TYPE_COUNT]; extern const int gMaximumBloodDeathAnimations[DAMAGE_TYPE_COUNT]; diff --git a/src/animation.h b/src/animation.h index 1a16828..d545c53 100644 --- a/src/animation.h +++ b/src/animation.h @@ -6,8 +6,6 @@ #include "obj_types.h" #include "sound.h" -#include - #define ANIMATION_SEQUENCE_LIST_CAPACITY (32) #define ANIMATION_DESCRIPTION_LIST_CAPACITY (55) diff --git a/src/audio_file.h b/src/audio_file.h index 59f7504..fa10b08 100644 --- a/src/audio_file.h +++ b/src/audio_file.h @@ -3,8 +3,6 @@ #include "sound_decoder.h" -#include - typedef enum AudioFileFlags { AUDIO_FILE_IN_USE = 0x01, AUDIO_FILE_COMPRESSED = 0x02, diff --git a/src/automap.h b/src/automap.h index 5d669f3..647874b 100644 --- a/src/automap.h +++ b/src/automap.h @@ -4,8 +4,6 @@ #include "db.h" #include "map_defs.h" -#include - #define AUTOMAP_DB ("AUTOMAP.DB") #define AUTOMAP_TMP ("AUTOMAP.TMP") diff --git a/src/autorun.h b/src/autorun.h index 44a718e..ba84d7e 100644 --- a/src/autorun.h +++ b/src/autorun.h @@ -1,8 +1,6 @@ #ifndef AUTORUN_H #define AUTORUN_H -#include - #define WIN32_LEAN_AND_MEAN #include diff --git a/src/cache.h b/src/cache.h index dfe371a..31cca22 100644 --- a/src/cache.h +++ b/src/cache.h @@ -3,8 +3,6 @@ #include "heap.h" -#include - #define INVALID_CACHE_ENTRY ((CacheEntry*)-1) // The initial number of cache entries in new cache. diff --git a/src/character_selector.h b/src/character_selector.h index 257bf7e..014531e 100644 --- a/src/character_selector.h +++ b/src/character_selector.h @@ -3,8 +3,6 @@ #include "art.h" -#include - #define CS_WINDOW_WIDTH (640) #define CS_WINDOW_HEIGHT (480) diff --git a/src/color.h b/src/color.h index fd6b7cb..0ad16c7 100644 --- a/src/color.h +++ b/src/color.h @@ -3,7 +3,6 @@ #include "memory_defs.h" -#include #include typedef char*(ColorFileNameManger)(char*); diff --git a/src/combat_ai.h b/src/combat_ai.h index 521e566..e884cd5 100644 --- a/src/combat_ai.h +++ b/src/combat_ai.h @@ -8,8 +8,6 @@ #include "obj_types.h" #include "party_member.h" -#include - #define AI_PACKET_CHEM_PRIMARY_DESIRE_COUNT (3) typedef enum AiMessageType { diff --git a/src/config.h b/src/config.h index 09dabf5..34a5488 100644 --- a/src/config.h +++ b/src/config.h @@ -3,8 +3,6 @@ #include "dictionary.h" -#include - #define CONFIG_FILE_MAX_LINE_LENGTH (256) // The initial number of sections (or key-value) pairs in the config. diff --git a/src/core.h b/src/core.h index c934568..0bf9188 100644 --- a/src/core.h +++ b/src/core.h @@ -8,8 +8,6 @@ #include -#include - #define MOUSE_DEFAULT_CURSOR_WIDTH 8 #define MOUSE_DEFAULT_CURSOR_HEIGHT 8 #define MOUSE_DEFAULT_CURSOR_SIZE (MOUSE_DEFAULT_CURSOR_WIDTH * MOUSE_DEFAULT_CURSOR_HEIGHT) diff --git a/src/credits.h b/src/credits.h index 2eace56..e416225 100644 --- a/src/credits.h +++ b/src/credits.h @@ -3,8 +3,6 @@ #include "db.h" -#include - #define CREDITS_WINDOW_WIDTH (640) #define CREDITS_WINDOW_HEIGHT (480) #define CREDITS_WINDOW_SCROLLING_DELAY (38) diff --git a/src/critter.h b/src/critter.h index 5c84789..9849222 100644 --- a/src/critter.h +++ b/src/critter.h @@ -6,8 +6,6 @@ #include "obj_types.h" #include "proto_types.h" -#include - // Maximum length of dude's name length. #define DUDE_NAME_MAX_LENGTH (32) diff --git a/src/cycle.h b/src/cycle.h index 4c3e7c5..5cc6b4c 100644 --- a/src/cycle.h +++ b/src/cycle.h @@ -1,8 +1,6 @@ #ifndef CYCLE_H #define CYCLE_H -#include - #define COLOR_CYCLE_PERIOD_1 (200U) #define COLOR_CYCLE_PERIOD_2 (142U) #define COLOR_CYCLE_PERIOD_3 (100U) diff --git a/src/db.h b/src/db.h index 0d9e45e..6d4ce6e 100644 --- a/src/db.h +++ b/src/db.h @@ -4,7 +4,6 @@ #include "memory_defs.h" #include "xfile.h" -#include #include typedef XFile File; diff --git a/src/dfile.h b/src/dfile.h index c831d61..54e5b2d 100644 --- a/src/dfile.h +++ b/src/dfile.h @@ -4,7 +4,6 @@ #define WIN32_LEAN_AND_MEAN #include -#include #include #include diff --git a/src/dictionary.cc b/src/dictionary.cc index 39ca87f..2cb9252 100644 --- a/src/dictionary.cc +++ b/src/dictionary.cc @@ -1,7 +1,6 @@ #include "dictionary.h" #include -#include #include #include diff --git a/src/display_monitor.h b/src/display_monitor.h index 038bc75..db72546 100644 --- a/src/display_monitor.h +++ b/src/display_monitor.h @@ -3,8 +3,6 @@ #include "geometry.h" -#include - // The maximum number of lines display monitor can hold. Once this value // is reached earlier messages are thrown away. #define DISPLAY_MONITOR_LINES_CAPACITY (100) diff --git a/src/endgame.h b/src/endgame.h index eb841cd..b3a2bdb 100644 --- a/src/endgame.h +++ b/src/endgame.h @@ -5,8 +5,6 @@ #define WIN32_LEAN_AND_MEAN #include -#include - typedef enum EndgameDeathEndingReason { // Dude died. ENDGAME_DEATH_ENDING_REASON_DEATH = 0, diff --git a/src/file_find.h b/src/file_find.h index 10490d9..0dbb552 100644 --- a/src/file_find.h +++ b/src/file_find.h @@ -1,8 +1,6 @@ #ifndef FILE_FIND_H #define FILE_FIND_H -#include - #define WIN32_LEAN_AND_MEAN #include diff --git a/src/file_utils.cc b/src/file_utils.cc index 52bde9f..725eb62 100644 --- a/src/file_utils.cc +++ b/src/file_utils.cc @@ -3,7 +3,6 @@ #include "file_utils.h" -#include #include #include diff --git a/src/font_manager.h b/src/font_manager.h index c6117dd..42b1230 100644 --- a/src/font_manager.h +++ b/src/font_manager.h @@ -3,8 +3,6 @@ #include "text_font.h" -#include - // The maximum number of interface fonts. #define INTERFACE_FONT_MAX (16) diff --git a/src/game.h b/src/game.h index 0959aa6..532258c 100644 --- a/src/game.h +++ b/src/game.h @@ -4,8 +4,6 @@ #include "game_vars.h" #include "message.h" -#include - extern char _aGame_0[]; extern bool gGameUiDisabled; diff --git a/src/game_config.h b/src/game_config.h index 784d339..5f5e11f 100644 --- a/src/game_config.h +++ b/src/game_config.h @@ -3,8 +3,6 @@ #include "config.h" -#include - // The file name of the main config file. #define GAME_CONFIG_FILE_NAME "fallout2.cfg" diff --git a/src/game_dialog.h b/src/game_dialog.h index d299d04..7b98253 100644 --- a/src/game_dialog.h +++ b/src/game_dialog.h @@ -8,8 +8,6 @@ #include "message.h" #include "obj_types.h" -#include - #define DIALOG_REVIEW_ENTRIES_CAPACITY 80 #define DIALOG_OPTION_ENTRIES_CAPACITY 30 diff --git a/src/game_mouse.h b/src/game_mouse.h index 2f68658..82106dd 100644 --- a/src/game_mouse.h +++ b/src/game_mouse.h @@ -5,8 +5,6 @@ #include "geometry.h" #include "obj_types.h" -#include - typedef enum ScrollableDirections { SCROLLABLE_W = 0x01, SCROLLABLE_E = 0x02, diff --git a/src/game_movie.h b/src/game_movie.h index 88a70b6..fb574ec 100644 --- a/src/game_movie.h +++ b/src/game_movie.h @@ -3,8 +3,6 @@ #include "db.h" -#include - #define WIN32_LEAN_AND_MEAN #include diff --git a/src/game_sound.cc b/src/game_sound.cc index 132f396..461a661 100644 --- a/src/game_sound.cc +++ b/src/game_sound.cc @@ -21,7 +21,6 @@ #include "window_manager.h" #include "world_map.h" -#include #include #include diff --git a/src/game_sound.h b/src/game_sound.h index 87aa6a1..bb23ac8 100644 --- a/src/game_sound.h +++ b/src/game_sound.h @@ -4,8 +4,6 @@ #include "obj_types.h" #include "sound.h" -#include - #define WIN32_LEAN_AND_MEAN #include diff --git a/src/heap.h b/src/heap.h index 4795fae..fdd78d7 100644 --- a/src/heap.h +++ b/src/heap.h @@ -1,8 +1,6 @@ #ifndef HEAP_H #define HEAP_H -#include - #define HEAP_BLOCK_HEADER_GUARD (0xDEADC0DE) #define HEAP_BLOCK_FOOTER_GUARD (0xACDCACDC) diff --git a/src/interface.h b/src/interface.h index b7f3141..ef9fed5 100644 --- a/src/interface.h +++ b/src/interface.h @@ -6,8 +6,6 @@ #include "geometry.h" #include "obj_types.h" -#include - typedef enum Hand { // Item1 (Punch) HAND_LEFT, diff --git a/src/interpreter.h b/src/interpreter.h index ef92cfe..beee1bf 100644 --- a/src/interpreter.h +++ b/src/interpreter.h @@ -2,7 +2,6 @@ #define INTERPRETER_H #include -#include // The maximum number of opcodes. #define OPCODE_MAX_COUNT (342) diff --git a/src/interpreter_extra.h b/src/interpreter_extra.h index e1362ce..2f7a4f5 100644 --- a/src/interpreter_extra.h +++ b/src/interpreter_extra.h @@ -6,8 +6,6 @@ #include "interpreter.h" #include "obj_types.h" -#include - typedef enum ScriptError { SCRIPT_ERROR_NOT_IMPLEMENTED, SCRIPT_ERROR_OBJECT_IS_NULL, diff --git a/src/inventory.h b/src/inventory.h index 0cf7395..41ed42a 100644 --- a/src/inventory.h +++ b/src/inventory.h @@ -6,8 +6,6 @@ #include "message.h" #include "obj_types.h" -#include - #define INVENTORY_NORMAL_WINDOW_PC_ROTATION_DELAY (1000U / ROTATION_COUNT) #define OFF_59E7BC_COUNT 12 diff --git a/src/item.h b/src/item.h index d02183d..8c54038 100644 --- a/src/item.h +++ b/src/item.h @@ -5,8 +5,6 @@ #include "message.h" #include "obj_types.h" -#include - #define ADDICTION_COUNT (9) typedef enum _WeaponClass { diff --git a/src/light.h b/src/light.h index 90b75b0..3f84d62 100644 --- a/src/light.h +++ b/src/light.h @@ -3,8 +3,6 @@ #include "map_defs.h" -#include - #define LIGHT_LEVEL_MIN (65536 / 4) #define LIGHT_LEVEL_MAX 65536 diff --git a/src/lips.h b/src/lips.h index f0e5d4c..1ad9bcf 100644 --- a/src/lips.h +++ b/src/lips.h @@ -4,7 +4,6 @@ #include "db.h" #include "sound.h" -#include #include #define PHONEME_COUNT (42) diff --git a/src/loadsave.h b/src/loadsave.h index 596b6bf..112742b 100644 --- a/src/loadsave.h +++ b/src/loadsave.h @@ -6,8 +6,6 @@ #include "geometry.h" #include "message.h" -#include - #define WIN32_LEAN_AND_MEAN #include diff --git a/src/main.h b/src/main.h index dd89a59..87e1078 100644 --- a/src/main.h +++ b/src/main.h @@ -4,8 +4,6 @@ #include "art.h" #include "fps_limiter.h" -#include - typedef enum MainMenuButton { MAIN_MENU_BUTTON_INTRO, MAIN_MENU_BUTTON_NEW_GAME, diff --git a/src/map.h b/src/map.h index 0f8a278..cc9ca6f 100644 --- a/src/map.h +++ b/src/map.h @@ -7,8 +7,6 @@ #include "map_defs.h" #include "message.h" -#include - #define WIN32_LEAN_AND_MEAN #include diff --git a/src/map_defs.h b/src/map_defs.h index 87a2c95..33124bd 100644 --- a/src/map_defs.h +++ b/src/map_defs.h @@ -1,8 +1,6 @@ #ifndef MAPDEFS_H #define MAPDEFS_H -#include - #define ELEVATION_COUNT (3) #define SQUARE_GRID_WIDTH (100) diff --git a/src/message.h b/src/message.h index b763508..b8fb129 100644 --- a/src/message.h +++ b/src/message.h @@ -3,8 +3,6 @@ #include "db.h" -#include - #define BADWORD_LENGTH_MAX 80 #define MESSAGE_LIST_ITEM_TEXT_FILTERED 0x01 diff --git a/src/mmx.h b/src/mmx.h index 547ef7f..4c97a29 100644 --- a/src/mmx.h +++ b/src/mmx.h @@ -1,8 +1,6 @@ #ifndef MMX_H #define MMX_H -#include - bool mmxIsSupported(); void mmxBlit(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height); void mmxBlitTrans(unsigned char* dest, int destPitch, unsigned char* src, int srcPitch, int width, int height); diff --git a/src/movie_effect.h b/src/movie_effect.h index ab2b3ec..ac872f7 100644 --- a/src/movie_effect.h +++ b/src/movie_effect.h @@ -1,8 +1,6 @@ #ifndef MOVIE_EFFECT_H #define MOVIE_EFFECT_H -#include - typedef enum MovieEffectType { MOVIE_EFFECT_TYPE_NONE = 0, MOVIE_EFFECT_TYPE_FADE_IN = 1, diff --git a/src/movie_lib.h b/src/movie_lib.h index 06f2920..e19a650 100644 --- a/src/movie_lib.h +++ b/src/movie_lib.h @@ -8,8 +8,6 @@ #define DIRECTSOUND_VERSION 0x0300 #include -#include - typedef struct STRUCT_6B3690 { void* field_0; int field_4; diff --git a/src/options.h b/src/options.h index f0b72c9..341ba35 100644 --- a/src/options.h +++ b/src/options.h @@ -6,8 +6,6 @@ #include "message.h" #include "geometry.h" -#include - #define OPTIONS_WINDOW_BUTTONS_COUNT (10) #define PRIMARY_OPTION_VALUE_COUNT (4) #define SECONDARY_OPTION_VALUE_COUNT (2) diff --git a/src/party_member.h b/src/party_member.h index 5931a19..f87cccf 100644 --- a/src/party_member.h +++ b/src/party_member.h @@ -6,8 +6,6 @@ #include "obj_types.h" #include "scripts.h" -#include - typedef struct PartyMemberDescription { bool areaAttackMode[AREA_ATTACK_MODE_COUNT]; bool runAwayMode[RUN_AWAY_MODE_COUNT]; diff --git a/src/perk.h b/src/perk.h index 044f045..55fb641 100644 --- a/src/perk.h +++ b/src/perk.h @@ -7,8 +7,6 @@ #include "perk_defs.h" #include "stat_defs.h" -#include - typedef struct PerkDescription { char* name; char* description; diff --git a/src/pipboy.h b/src/pipboy.h index eee8de2..6be51c7 100644 --- a/src/pipboy.h +++ b/src/pipboy.h @@ -6,8 +6,6 @@ #include "geometry.h" #include "message.h" -#include - #define PIPBOY_WINDOW_WIDTH (640) #define PIPBOY_WINDOW_HEIGHT (480) diff --git a/src/proto_instance.h b/src/proto_instance.h index 1e93aa0..a7af363 100644 --- a/src/proto_instance.h +++ b/src/proto_instance.h @@ -4,8 +4,6 @@ #include "message.h" #include "obj_types.h" -#include - extern MessageListItem stru_49A990; int _obj_sid(Object* object, int* sidPtr); diff --git a/src/queue.h b/src/queue.h index 91fd1c4..22ac198 100644 --- a/src/queue.h +++ b/src/queue.h @@ -4,8 +4,6 @@ #include "db.h" #include "obj_types.h" -#include - typedef enum EventType { EVENT_TYPE_DRUG = 0, EVENT_TYPE_KNOCKOUT = 1, diff --git a/src/scripts.h b/src/scripts.h index 0901eb1..2db98bd 100644 --- a/src/scripts.h +++ b/src/scripts.h @@ -7,8 +7,6 @@ #include "message.h" #include "obj_types.h" -#include - #define SCRIPT_LIST_EXTENT_SIZE 16 #define SCRIPT_FLAG_0x01 (0x01) diff --git a/src/sfall_config.h b/src/sfall_config.h index fe0b6d7..69be7a0 100644 --- a/src/sfall_config.h +++ b/src/sfall_config.h @@ -3,8 +3,6 @@ #include "config.h" -#include - #define SFALL_CONFIG_FILE_NAME "ddraw.ini" #define SFALL_CONFIG_MISC_KEY "Misc" diff --git a/src/skill.h b/src/skill.h index 63e787e..64b1bd5 100644 --- a/src/skill.h +++ b/src/skill.h @@ -7,8 +7,6 @@ #include "proto_types.h" #include "skill_defs.h" -#include - #define SKILLS_MAX_USES_PER_DAY (3) #define REPAIRABLE_DAMAGE_FLAGS_LENGTH (5) diff --git a/src/skilldex.h b/src/skilldex.h index 0cc81a7..a3a6de7 100644 --- a/src/skilldex.h +++ b/src/skilldex.h @@ -5,8 +5,6 @@ #include "geometry.h" #include "message.h" -#include - #define SKILLDEX_SKILL_BUTTON_BUFFER_COUNT (SKILLDEX_SKILL_COUNT * 2) typedef enum SkilldexFrm { diff --git a/src/sound_decoder.h b/src/sound_decoder.h index b165c43..b81d337 100644 --- a/src/sound_decoder.h +++ b/src/sound_decoder.h @@ -1,7 +1,6 @@ #ifndef SOUND_DECODER_H #define SOUND_DECODER_H -#include #include #define SOUND_DECODER_IN_BUFFER_SIZE (512) diff --git a/src/sound_effects_cache.h b/src/sound_effects_cache.h index 399624c..6fdcabe 100644 --- a/src/sound_effects_cache.h +++ b/src/sound_effects_cache.h @@ -3,8 +3,6 @@ #include "cache.h" -#include - // The maximum number of sound effects that can be loaded and played // simultaneously. #define SOUND_EFFECTS_MAX_COUNT (4) diff --git a/src/sound_effects_list.h b/src/sound_effects_list.h index 10341f9..fbe8bda 100644 --- a/src/sound_effects_list.h +++ b/src/sound_effects_list.h @@ -1,8 +1,6 @@ #ifndef SOUND_EFFECTS_LIST_H #define SOUND_EFFECTS_LIST_H -#include - #define SFXL_OK (0) #define SFXL_ERR (1) #define SFXL_ERR_TAG_INVALID (2) diff --git a/src/stat.h b/src/stat.h index 4f91ffc..6c9876c 100644 --- a/src/stat.h +++ b/src/stat.h @@ -7,8 +7,6 @@ #include "proto_types.h" #include "stat_defs.h" -#include - #define STAT_ERR_INVALID_STAT (-5) // Provides metadata about stats. diff --git a/src/text_font.h b/src/text_font.h index 0fd00ad..bd59028 100644 --- a/src/text_font.h +++ b/src/text_font.h @@ -1,8 +1,6 @@ #ifndef TEXT_FONT_H #define TEXT_FONT_H -#include - // The maximum number of text fonts. #define TEXT_FONT_MAX (10) diff --git a/src/text_object.h b/src/text_object.h index fa7fdf2..f9f10b3 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -4,8 +4,6 @@ #include "geometry.h" #include "obj_types.h" -#include - // The maximum number of text objects that can exist at the same time. #define TEXT_OBJECTS_MAX_COUNT (20) diff --git a/src/tile.h b/src/tile.h index a4b14ce..d07d884 100644 --- a/src/tile.h +++ b/src/tile.h @@ -5,8 +5,6 @@ #include "map.h" #include "obj_types.h" -#include - #define TILE_SET_CENTER_FLAG_0x01 0x01 #define TILE_SET_CENTER_FLAG_0x02 0x02 diff --git a/src/trait.h b/src/trait.h index 4ce92a8..f2cf382 100644 --- a/src/trait.h +++ b/src/trait.h @@ -5,8 +5,6 @@ #include "message.h" #include "trait_defs.h" -#include - // Provides metadata about traits. typedef struct TraitDescription { // The name of trait. diff --git a/src/win32.h b/src/win32.h index 8f7a7b6..076d34a 100644 --- a/src/win32.h +++ b/src/win32.h @@ -9,8 +9,6 @@ #define DIRECTSOUND_VERSION 0x0300 #include -#include - typedef HRESULT(__stdcall DirectSoundCreateProc)(GUID*, LPDIRECTSOUND*, IUnknown*); extern DirectSoundCreateProc* gDirectSoundCreateProc; diff --git a/src/window.h b/src/window.h index 6d79d15..b1f9738 100644 --- a/src/window.h +++ b/src/window.h @@ -5,8 +5,6 @@ #include "interpreter.h" #include "region.h" -#include - #define MANAGED_WINDOW_COUNT (16) typedef void (*WINDOWDRAWINGPROC)(unsigned char* src, int src_pitch, int a3, int src_x, int src_y, int src_width, int src_height, int dest_x, int dest_y); diff --git a/src/window_manager.h b/src/window_manager.h index 6b3751a..e1da1ec 100644 --- a/src/window_manager.h +++ b/src/window_manager.h @@ -3,7 +3,6 @@ #include "geometry.h" -#include #include #define WIN32_LEAN_AND_MEAN diff --git a/src/window_manager_private.h b/src/window_manager_private.h index 00e6b17..c199ca7 100644 --- a/src/window_manager_private.h +++ b/src/window_manager_private.h @@ -1,8 +1,6 @@ #ifndef WINDOW_MANAGER_PRIVATE_H #define WINDOW_MANAGER_PRIVATE_H -#include - typedef struct struc_177 struc_177; typedef struct STRUCT_6B2340 { diff --git a/src/world_map.h b/src/world_map.h index 65576ba..794583c 100644 --- a/src/world_map.h +++ b/src/world_map.h @@ -8,8 +8,6 @@ #include "message.h" #include "obj_types.h" -#include - #define CITY_NAME_SIZE (40) #define TILE_WALK_MASK_NAME_SIZE (40) #define ENTRANCE_LIST_CAPACITY (10) diff --git a/src/xfile.h b/src/xfile.h index 4c19d53..50bfd35 100644 --- a/src/xfile.h +++ b/src/xfile.h @@ -3,7 +3,6 @@ #include "dfile.h" -#include #include #include From 49f0d833ab27e1259615ce6e0d366544c840227b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0imek?= Date: Sat, 28 May 2022 05:57:53 +0200 Subject: [PATCH 2/9] Fix help and end game window positions (#21) --- src/endgame.cc | 17 +++++++++++------ src/game.cc | 4 +++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/endgame.cc b/src/endgame.cc index 8462148..cde8413 100644 --- a/src/endgame.cc +++ b/src/endgame.cc @@ -33,6 +33,9 @@ // The maximum number of subtitle lines per slide. #define ENDGAME_ENDING_MAX_SUBTITLES (50) +#define ENDGAME_ENDING_WINDOW_WIDTH 640 +#define ENDGAME_ENDING_WINDOW_HEIGHT 480 + // 0x50B00C char _aEnglish_2[] = ENGLISH; @@ -270,7 +273,7 @@ void endgameEndingRenderPanningScene(int direction, const char* narratorFileName int width = artGetWidth(background, 0, 0); int height = artGetHeight(background, 0, 0); unsigned char* backgroundData = artGetFrameData(background, 0, 0); - bufferFill(gEndgameEndingSlideshowWindowBuffer, 640, 480, 640, _colorTable[0]); + bufferFill(gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, _colorTable[0]); endgameEndingLoadPalette(6, 327); unsigned char palette[768]; @@ -312,7 +315,7 @@ void endgameEndingRenderPanningScene(int direction, const char* narratorFileName // TODO: Complex math, setup scene in debugger. if (getTicksSince(since) >= v9) { - blitBufferToBuffer(backgroundData + start, 640, 480, width, gEndgameEndingSlideshowWindowBuffer, 640); + blitBufferToBuffer(backgroundData + start, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, width, gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH); if (subtitlesLoaded) { endgameEndingRefreshSubtitles(); @@ -371,7 +374,7 @@ void endgameEndingRenderPanningScene(int direction, const char* narratorFileName artUnlock(backgroundHandle); paletteFadeTo(gPaletteBlack); - bufferFill(gEndgameEndingSlideshowWindowBuffer, 640, 480, 640, _colorTable[0]); + bufferFill(gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, _colorTable[0]); windowRefresh(gEndgameEndingSlideshowWindow); } @@ -391,7 +394,7 @@ void endgameEndingRenderStaticScene(int fid, const char* narratorFileName) unsigned char* backgroundData = artGetFrameData(background, 0, 0); if (backgroundData != NULL) { - blitBufferToBuffer(backgroundData, 640, 480, 640, gEndgameEndingSlideshowWindowBuffer, 640); + blitBufferToBuffer(backgroundData, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH); windowRefresh(gEndgameEndingSlideshowWindow); endgameEndingLoadPalette((fid & 0xF000000) >> 24, fid & 0xFFF); @@ -434,7 +437,7 @@ void endgameEndingRenderStaticScene(int fid, const char* narratorFileName) break; } - blitBufferToBuffer(backgroundData, 640, 480, 640, gEndgameEndingSlideshowWindowBuffer, 640); + blitBufferToBuffer(backgroundData, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH); endgameEndingRefreshSubtitles(); windowRefresh(gEndgameEndingSlideshowWindow); soundContinueAll(); @@ -487,7 +490,9 @@ int endgameEndingSlideshowWindowInit() paletteFadeTo(gPaletteBlack); - gEndgameEndingSlideshowWindow = windowCreate(0, 0, 640, 480, _colorTable[0], 4); + int windowEndgameEndingX = (screenGetWidth() - ENDGAME_ENDING_WINDOW_WIDTH) / 2; + int windowEndgameEndingY = (screenGetHeight() - ENDGAME_ENDING_WINDOW_HEIGHT) / 2; + gEndgameEndingSlideshowWindow = windowCreate(windowEndgameEndingX, windowEndgameEndingY, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, _colorTable[0], 4); if (gEndgameEndingSlideshowWindow == -1) { return -1; } diff --git a/src/game.cc b/src/game.cc index 5bd4563..4647d27 100644 --- a/src/game.cc +++ b/src/game.cc @@ -1055,7 +1055,9 @@ void showHelp() bool colorCycleWasEnabled = colorCycleEnabled(); colorCycleDisable(); - int win = windowCreate(0, 0, HELP_SCREEN_WIDTH, HELP_SCREEN_HEIGHT, 0, WINDOW_HIDDEN | WINDOW_FLAG_0x04); + int helpWindowX = (screenGetWidth() - HELP_SCREEN_WIDTH) / 2; + int helpWindowY = (screenGetHeight() - HELP_SCREEN_HEIGHT) / 2; + int win = windowCreate(helpWindowX, helpWindowY, HELP_SCREEN_WIDTH, HELP_SCREEN_HEIGHT, 0, WINDOW_HIDDEN | WINDOW_FLAG_0x04); if (win != -1) { unsigned char* windowBuffer = windowGetBuffer(win); if (windowBuffer != NULL) { From 7a1119bac02dcbc915791fb60b91173701871f14 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 07:26:08 +0300 Subject: [PATCH 3/9] Use C++ noreturn attribute --- src/interpreter.cc | 2 +- src/interpreter.h | 2 +- src/memory_manager.cc | 2 +- src/memory_manager.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/interpreter.cc b/src/interpreter.cc index 826b606..0bc49b7 100644 --- a/src/interpreter.cc +++ b/src/interpreter.cc @@ -127,7 +127,7 @@ char* programGetCurrentProcedureName(Program* program) } // 0x4671F0 -__declspec(noreturn) void programFatalError(const char* format, ...) +[[noreturn]] void programFatalError(const char* format, ...) { char string[260]; diff --git a/src/interpreter.h b/src/interpreter.h index beee1bf..ff0d9f8 100644 --- a/src/interpreter.h +++ b/src/interpreter.h @@ -189,7 +189,7 @@ int _checkWait(Program* program); void _interpretOutputFunc(int (*func)(char*)); int _interpretOutput(const char* format, ...); char* programGetCurrentProcedureName(Program* s); -__declspec(noreturn) void programFatalError(const char* str, ...); +[[noreturn]] void programFatalError(const char* str, ...); opcode_t stackReadInt16(unsigned char* data, int pos); int stackReadInt32(unsigned char* a1, int a2); void stackWriteInt16(int value, unsigned char* a2, int a3); diff --git a/src/memory_manager.cc b/src/memory_manager.cc index 1abf8df..2c7b5a0 100644 --- a/src/memory_manager.cc +++ b/src/memory_manager.cc @@ -44,7 +44,7 @@ int memoryManagerPrintError(const char* format, ...) } // 0x484610 -__declspec(noreturn) void memoryManagerFatalAllocationError(const char* func, size_t size, const char* file, int line) +[[noreturn]] void memoryManagerFatalAllocationError(const char* func, size_t size, const char* file, int line) { memoryManagerPrintError("%s: Error allocating block of size %ld (%x), %s %d\n", func, size, size, file, line); exit(1); diff --git a/src/memory_manager.h b/src/memory_manager.h index 10e3c5b..6dd24dd 100644 --- a/src/memory_manager.h +++ b/src/memory_manager.h @@ -15,7 +15,7 @@ extern char gMemoryManagerLastError[256]; void memoryManagerDefaultPrintErrorImpl(const char* string); int memoryManagerPrintError(const char* format, ...); -__declspec(noreturn) void memoryManagerFatalAllocationError(const char* func, size_t size, const char* file, int line); +[[noreturn]] void memoryManagerFatalAllocationError(const char* func, size_t size, const char* file, int line); void* memoryManagerDefaultMallocImpl(size_t size); void* memoryManagerDefaultReallocImpl(void* ptr, size_t size); void memoryManagerDefaultFreeImpl(void* ptr); From 119cfe8212926550029b21ac9e5e00c198bb73ec Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 07:34:29 +0300 Subject: [PATCH 4/9] 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) { From 7174cc703d1f033ca43682334c12ca2342159bf4 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 07:59:41 +0300 Subject: [PATCH 5/9] Reorganize fpattern config --- CMakeLists.txt | 3 +++ src/dfile.cc | 2 +- third_party/fpattern/CMakeLists.txt | 9 +++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e12f86f..02d5f71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,5 +243,8 @@ target_link_libraries(fallout2-ce ) add_subdirectory("third_party/fpattern") +target_link_libraries(fallout2-ce ${FPATTERN_LIBRARY}) +target_include_directories(fallout2-ce PRIVATE ${FPATTERN_INCLUDE_DIR}) + add_subdirectory("third_party/zlib") add_subdirectory("third_party/sdl2") diff --git a/src/dfile.cc b/src/dfile.cc index 3595798..90a6b21 100644 --- a/src/dfile.cc +++ b/src/dfile.cc @@ -1,6 +1,6 @@ #include "dfile.h" -#include "fpattern.h" +#include #include #include diff --git a/third_party/fpattern/CMakeLists.txt b/third_party/fpattern/CMakeLists.txt index 1bb90aa..43f4153 100644 --- a/third_party/fpattern/CMakeLists.txt +++ b/third_party/fpattern/CMakeLists.txt @@ -10,10 +10,15 @@ if (NOT fpattern_POPULATED) FetchContent_Populate(fpattern) endif() -target_sources(fallout2-ce PUBLIC +if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") +endif() + +add_library(fpattern STATIC "${fpattern_SOURCE_DIR}/debug.h" "${fpattern_SOURCE_DIR}/fpattern.c" "${fpattern_SOURCE_DIR}/fpattern.h" ) -target_include_directories(fallout2-ce PUBLIC ${fpattern_SOURCE_DIR}) +set(FPATTERN_LIBRARY "fpattern" PARENT_SCOPE) +set(FPATTERN_INCLUDE_DIR "${fpattern_SOURCE_DIR}" PARENT_SCOPE) From 456fd43d8aefd634eca1a70f132d7c5f87f8956a Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 08:17:23 +0300 Subject: [PATCH 6/9] Reorganize zlib config --- CMakeLists.txt | 3 +++ third_party/zlib/CMakeLists.txt | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 02d5f71..50698bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,4 +247,7 @@ target_link_libraries(fallout2-ce ${FPATTERN_LIBRARY}) target_include_directories(fallout2-ce PRIVATE ${FPATTERN_INCLUDE_DIR}) add_subdirectory("third_party/zlib") +target_link_libraries(fallout2-ce ${ZLIB_LIBRARIES}) +target_include_directories(fallout2-ce PRIVATE ${ZLIB_INCLUDE_DIRS}) + add_subdirectory("third_party/sdl2") diff --git a/third_party/zlib/CMakeLists.txt b/third_party/zlib/CMakeLists.txt index f7a8acf..9f17c85 100644 --- a/third_party/zlib/CMakeLists.txt +++ b/third_party/zlib/CMakeLists.txt @@ -11,5 +11,6 @@ if (NOT zlib_POPULATED) endif() add_subdirectory(${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} EXCLUDE_FROM_ALL) -target_include_directories(fallout2-ce PUBLIC ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR}) -target_link_libraries(fallout2-ce zlibstatic) + +set(ZLIB_LIBRARIES zlibstatic PARENT_SCOPE) +set(ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} PARENT_SCOPE) From 40a43422a3f79664e006e3f985762833a1aff86e Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 08:24:55 +0300 Subject: [PATCH 7/9] Reorganize sdl2 config --- CMakeLists.txt | 2 ++ third_party/sdl2/CMakeLists.txt | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50698bd..4cc7a1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,3 +251,5 @@ target_link_libraries(fallout2-ce ${ZLIB_LIBRARIES}) target_include_directories(fallout2-ce PRIVATE ${ZLIB_INCLUDE_DIRS}) add_subdirectory("third_party/sdl2") +target_link_libraries(fallout2-ce ${SDL2_LIBRARIES}) +target_include_directories(fallout2-ce PRIVATE ${SDL2_INCLUDE_DIRS}) diff --git a/third_party/sdl2/CMakeLists.txt b/third_party/sdl2/CMakeLists.txt index 8bfdb32..06e5b61 100644 --- a/third_party/sdl2/CMakeLists.txt +++ b/third_party/sdl2/CMakeLists.txt @@ -19,5 +19,6 @@ if (NOT sdl2_POPULATED) endif() add_subdirectory(${sdl2_SOURCE_DIR} ${sdl2_BINARY_DIR} EXCLUDE_FROM_ALL) -target_include_directories(fallout2-ce PUBLIC ${sdl2_SOURCE_DIR} ${sdl2_BINARY_DIR}) -target_link_libraries(fallout2-ce SDL2-static SDL2::SDL2main) + +set(SDL2_INCLUDE_DIRS ${sdl2_SOURCE_DIR} ${sdl2_BINARY_DIR} PARENT_SCOPE) +set(SDL2_LIBRARIES SDL2-static SDL2::SDL2main PARENT_SCOPE) From 31dbf77d6d813ed63c2734a117c617a90facf098 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 09:28:11 +0300 Subject: [PATCH 8/9] Use C++ 17 --- CMakeLists.txt | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cc7a1f..d977423 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,9 +2,15 @@ cmake_minimum_required(VERSION 3.13) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) -project(fallout2-ce LANGUAGES CXX) +set(EXECUTABLE_NAME fallout2-ce) -add_executable(fallout2-ce WIN32 +project(${EXECUTABLE_NAME}) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED YES) +set(CMAKE_CXX_EXTENSIONS NO) + +add_executable(${EXECUTABLE_NAME} WIN32 "src/actions.cc" "src/actions.h" "src/animation.cc" @@ -226,30 +232,30 @@ add_executable(fallout2-ce WIN32 "src/xfile.h" ) -target_sources(fallout2-ce PUBLIC +target_sources(${EXECUTABLE_NAME} PUBLIC "src/fps_limiter.cc" "src/fps_limiter.h" "src/sfall_config.cc" "src/sfall_config.h" ) -target_compile_definitions(fallout2-ce PUBLIC +target_compile_definitions(${EXECUTABLE_NAME} PUBLIC _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS ) -target_link_libraries(fallout2-ce +target_link_libraries(${EXECUTABLE_NAME} winmm ) add_subdirectory("third_party/fpattern") -target_link_libraries(fallout2-ce ${FPATTERN_LIBRARY}) -target_include_directories(fallout2-ce PRIVATE ${FPATTERN_INCLUDE_DIR}) +target_link_libraries(${EXECUTABLE_NAME} ${FPATTERN_LIBRARY}) +target_include_directories(${EXECUTABLE_NAME} PRIVATE ${FPATTERN_INCLUDE_DIR}) add_subdirectory("third_party/zlib") -target_link_libraries(fallout2-ce ${ZLIB_LIBRARIES}) -target_include_directories(fallout2-ce PRIVATE ${ZLIB_INCLUDE_DIRS}) +target_link_libraries(${EXECUTABLE_NAME} ${ZLIB_LIBRARIES}) +target_include_directories(${EXECUTABLE_NAME} PRIVATE ${ZLIB_INCLUDE_DIRS}) add_subdirectory("third_party/sdl2") -target_link_libraries(fallout2-ce ${SDL2_LIBRARIES}) -target_include_directories(fallout2-ce PRIVATE ${SDL2_INCLUDE_DIRS}) +target_link_libraries(${EXECUTABLE_NAME} ${SDL2_LIBRARIES}) +target_include_directories(${EXECUTABLE_NAME} PRIVATE ${SDL2_INCLUDE_DIRS}) From 6714aebbadb8dad028b7153934c761acc6e581a1 Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 28 May 2022 09:32:36 +0300 Subject: [PATCH 9/9] Replace GetTickCount with SDL_GetTicks --- src/core.cc | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/core.cc b/src/core.cc index 3d27d2e..983aa7c 100644 --- a/src/core.cc +++ b/src/core.cc @@ -540,8 +540,7 @@ void tickersExecute() return; } -#pragma warning(suppress : 28159) - gTickerLastTimestamp = GetTickCount(); + gTickerLastTimestamp = SDL_GetTicks(); TickerListNode* curr = gTickerListHead; TickerListNode** currPtr = &(gTickerListHead); @@ -839,8 +838,7 @@ void screenshotHandlerConfigure(int keyCode, ScreenshotHandler* handler) // 0x4C9370 unsigned int _get_time() { -#pragma warning(suppress : 28159) - return GetTickCount(); + return SDL_GetTicks(); } // 0x4C937C @@ -865,8 +863,7 @@ void coreDelayProcessingEvents(unsigned int delay) // 0x4C93B8 void coreDelay(unsigned int ms) { -#pragma warning(suppress : 28159) - unsigned int start = GetTickCount(); + unsigned int start = SDL_GetTicks(); unsigned int diff; do { // NOTE: Uninline @@ -877,8 +874,7 @@ void coreDelay(unsigned int ms) // 0x4C93E0 unsigned int getTicksSince(unsigned int start) { -#pragma warning(suppress : 28159) - unsigned int end = GetTickCount(); + unsigned int end = SDL_GetTicks(); // NOTE: Uninline. return getTicksBetween(end, start);