diff --git a/src/BMLArchive.cc b/src/BMLArchive.cc index 973e3ab6..2233e6d7 100644 --- a/src/BMLArchive.cc +++ b/src/BMLArchive.cc @@ -14,7 +14,7 @@ struct BMLHeaderT { parray unknown_a1; U32T num_entries; parray unknown_a2; -} __packed__; +} __attribute__((packed)); using BMLHeader = BMLHeaderT; using BMLHeaderBE = BMLHeaderT; @@ -30,7 +30,7 @@ struct BMLHeaderEntryT { U32T compressed_gvm_size; U32T decompressed_gvm_size; parray unknown_a2; -} __packed__; +} __attribute__((packed)); using BMLHeaderEntry = BMLHeaderEntryT; using BMLHeaderEntryBE = BMLHeaderEntryT; diff --git a/src/ChoiceSearch.hh b/src/ChoiceSearch.hh index 3d1e3666..87476c05 100644 --- a/src/ChoiceSearch.hh +++ b/src/ChoiceSearch.hh @@ -40,7 +40,7 @@ struct ChoiceSearchConfigT { } return ret; } -} __packed__; +} __attribute__((packed)); using ChoiceSearchConfig = ChoiceSearchConfigT; using ChoiceSearchConfigBE = ChoiceSearchConfigT; diff --git a/src/CommandFormats.hh b/src/CommandFormats.hh index eeda3899..171f6932 100644 --- a/src/CommandFormats.hh +++ b/src/CommandFormats.hh @@ -275,7 +275,7 @@ struct S_ReconnectT { be_uint32_t address = 0; PortT port = 0; le_uint16_t unused = 0; -} __packed__; +} __attribute__((packed)); using S_Reconnect_Patch_14 = S_ReconnectT; check_struct_size(S_Reconnect_Patch_14, 0x08); @@ -340,7 +340,7 @@ struct S_ServerInitWithAfterMessageT_DC_PC_V3_02_17_91_9B { // This field is not part of SEGA's implementation; the client ignores it. // newserv sends a message here disavowing the preceding copyright notice. pstring after_message; -} __packed__; +} __attribute__((packed)); // 03 (C->S): Legacy register (non-BB) // Internal name: SndRegist @@ -391,7 +391,7 @@ struct S_ServerInitWithAfterMessageT_BB_03_9B { S_ServerInitDefault_BB_03_9B basic_cmd; // As in 02, this field is not part of SEGA's implementation. pstring after_message; -} __packed__; +} __attribute__((packed)); // 04 (C->S): Legacy login // Internal name: SndLogin2 @@ -566,7 +566,7 @@ struct S_MenuItemT { // 80 = Is Episode 2 (V3/BB) // C0 = Is Episode 4 (BB) uint8_t flags = 0; -} __packed__; +} __attribute__((packed)); using S_MenuItem_PC_BB_08 = S_MenuItemT; using S_MenuItem_DC_V3_08_Ep3_E6 = S_MenuItemT; check_struct_size(S_MenuItem_PC_BB_08, 0x2C); @@ -628,7 +628,7 @@ struct SC_MeetUserExtensionT { /* 40 */ le_uint32_t unknown_a2 = 0; /* 44 */ pstring player_name; /* 64 (or 84 on UTF16 versions) */ -} __packed__; +} __attribute__((packed)); using SC_MeetUserExtension_DC_V3 = SC_MeetUserExtensionT; using SC_MeetUserExtension_PC_BB = SC_MeetUserExtensionT; check_struct_size(SC_MeetUserExtension_DC_V3, 0x64); @@ -683,7 +683,7 @@ template struct C_MenuSelectionT_10_Flag01 { C_MenuSelection_10_Flag00 basic_cmd; pstring name; -} __packed__; +} __attribute__((packed)); using C_MenuSelection_DC_V3_10_Flag01 = C_MenuSelectionT_10_Flag01; using C_MenuSelection_PC_BB_10_Flag01 = C_MenuSelectionT_10_Flag01; check_struct_size(C_MenuSelection_DC_V3_10_Flag01, 0x18); @@ -693,7 +693,7 @@ template struct C_MenuSelectionT_10_Flag02 { C_MenuSelection_10_Flag00 basic_cmd; pstring password; -} __packed__; +} __attribute__((packed)); using C_MenuSelection_DC_V3_10_Flag02 = C_MenuSelectionT_10_Flag02; using C_MenuSelection_PC_BB_10_Flag02 = C_MenuSelectionT_10_Flag02; check_struct_size(C_MenuSelection_DC_V3_10_Flag02, 0x18); @@ -704,7 +704,7 @@ struct C_MenuSelectionT_10_Flag03 { C_MenuSelection_10_Flag00 basic_cmd; pstring name; pstring password; -} __packed__; +} __attribute__((packed)); using C_MenuSelection_DC_V3_10_Flag03 = C_MenuSelectionT_10_Flag03; using C_MenuSelection_PC_BB_10_Flag03 = C_MenuSelectionT_10_Flag03; check_struct_size(C_MenuSelection_DC_V3_10_Flag03, 0x28); @@ -978,7 +978,7 @@ struct S_GuildCardSearchResultT { // reconnect_command. When processing the 9D/9E, newserv uses only the // lobby_id field within, but it fills in all fields when sending a 41. SC_MeetUserExtensionT extension; -} __packed__; +} __attribute__((packed)); using S_GuildCardSearchResult_PC_41 = S_GuildCardSearchResultT; using S_GuildCardSearchResult_DC_V3_41 = S_GuildCardSearchResultT; using S_GuildCardSearchResult_BB_41 = S_GuildCardSearchResultT; @@ -1258,7 +1258,7 @@ struct S_JoinGameT_DC_PC { /* 010B */ uint8_t challenge_mode = 0; /* 010C */ le_uint32_t random_seed = 0; /* 0110 */ -} __packed__; +} __attribute__((packed)); struct S_JoinGame_DCNTE_64 { uint8_t client_id = 0; @@ -1356,7 +1356,7 @@ struct S_JoinLobbyT { LobbyDataT lobby_data; PlayerInventory inventory; DispDataT disp; - } __packed__; + } __attribute__((packed)); // Note: not all of these will be filled in and sent if the lobby isn't full // (the command size will be shorter than this struct's size) parray entries; @@ -1364,7 +1364,7 @@ struct S_JoinLobbyT { static inline size_t size(size_t used_entries) { return offsetof(S_JoinLobbyT, entries) + used_entries * sizeof(Entry); } -} __packed__; +} __attribute__((packed)); using S_JoinLobby_DCNTE_65_67_68 = S_JoinLobbyT; using S_JoinLobby_PC_65_67_68 = S_JoinLobbyT; using S_JoinLobby_DC_GC_65_67_68_Ep3_EB = S_JoinLobbyT; @@ -2111,7 +2111,7 @@ struct S_QuestMenuEntryT { le_uint32_t item_id = 0; pstring name; pstring short_description; -} __packed__; +} __attribute__((packed)); using S_QuestMenuEntry_PC_A2_A4 = S_QuestMenuEntryT; using S_QuestMenuEntry_DC_GC_A2_A4 = S_QuestMenuEntryT; using S_QuestMenuEntry_XB_A2_A4 = S_QuestMenuEntryT; @@ -2495,7 +2495,7 @@ struct S_ChoiceSearchEntryT { le_uint16_t parent_choice_id = 0; // 0 for top-level categories le_uint16_t choice_id = 0; pstring text; -} __packed__; +} __attribute__((packed)); using S_ChoiceSearchEntry_DC_V3_C0 = S_ChoiceSearchEntryT; using S_ChoiceSearchEntry_PC_BB_C0 = S_ChoiceSearchEntryT; check_struct_size(S_ChoiceSearchEntry_DC_V3_C0, 0x20); @@ -2525,7 +2525,7 @@ struct C_CreateGameBaseT { le_uint32_t item_id = 0; pstring name; pstring password; -} __packed__; +} __attribute__((packed)); using C_CreateGame_DCNTE = C_CreateGameBaseT; check_struct_size(C_CreateGame_DCNTE, 0x28); @@ -2540,7 +2540,7 @@ struct C_CreateGameT : C_CreateGameBaseT { // different meaning: if set to 0, the game can be joined by v1 and v2 // players; if set to 1, it's v2-only. uint8_t episode = 0; // 1-4 on V3+ (3 on Episode 3); unused on DC/PC -} __packed__; +} __attribute__((packed)); using C_CreateGame_DC_V3_0C_C1_Ep3_EC = C_CreateGameT; using C_CreateGame_PC_C1 = C_CreateGameT; check_struct_size(C_CreateGame_DC_V3_0C_C1_Ep3_EC, 0x2C); @@ -2580,7 +2580,7 @@ struct S_ChoiceSearchResultEntryT_C4 { HeaderT reconnect_command_header; // Ignored by the client S_Reconnect_19 reconnect_command; SC_MeetUserExtensionT meet_user; -} __packed__; +} __attribute__((packed)); using S_ChoiceSearchResultEntry_DC_V3_C4 = S_ChoiceSearchResultEntryT_C4; using S_ChoiceSearchResultEntry_PC_C4 = S_ChoiceSearchResultEntryT_C4; using S_ChoiceSearchResultEntry_BB_C4 = S_ChoiceSearchResultEntryT_C4; @@ -2602,7 +2602,7 @@ check_struct_size(S_ChoiceSearchResultEntry_BB_C4, 0x158); template struct C_SetBlockedSendersT_C6 { parray blocked_senders; -} __packed__; +} __attribute__((packed)); using C_SetBlockedSenders_V3_C6 = C_SetBlockedSendersT_C6<30>; using C_SetBlockedSenders_BB_C6 = C_SetBlockedSendersT_C6<28>; check_struct_size(C_SetBlockedSenders_V3_C6, 0x78); @@ -2775,7 +2775,7 @@ template struct S_InfoBoardEntryT_D8 { pstring name; pstring message; -} __packed__; +} __attribute__((packed)); using S_InfoBoardEntry_V3_D8 = S_InfoBoardEntryT_D8; using S_InfoBoardEntry_BB_D8 = S_InfoBoardEntryT_D8; check_struct_size(S_InfoBoardEntry_V3_D8, 0xBC); @@ -2976,7 +2976,7 @@ struct S_GameInformationBaseT_Ep3_E1 { /* 0100 */ RulesT rules; /* 0114 */ parray spectator_entries; /* 0294 */ -} __packed__; +} __attribute__((packed)); using S_GameInformation_Ep3NTE_E1 = S_GameInformationBaseT_Ep3_E1; using S_GameInformation_Ep3_E1 = S_GameInformationBaseT_Ep3_E1; check_struct_size(S_GameInformation_Ep3NTE_E1, 0x28C); @@ -3102,7 +3102,7 @@ struct S_TournamentGameDetailsBaseT_Ep3_E3 { /* 05BA */ le_uint16_t num_spectators = 0; /* 05BC */ parray spectator_entries; /* 073C */ -} __packed__; +} __attribute__((packed)); using S_TournamentGameDetails_Ep3NTE_E3 = S_TournamentGameDetailsBaseT_Ep3_E3; using S_TournamentGameDetails_Ep3_E3 = S_TournamentGameDetailsBaseT_Ep3_E3; check_struct_size(S_TournamentGameDetails_Ep3NTE_E3, 0x734); @@ -3890,7 +3890,7 @@ template struct G_ExtendedHeaderT { HeaderT basic_header; le_uint32_t size = 0; -} __packed__; +} __attribute__((packed)); // 6x00: Invalid subcommand // 6x01: Invalid subcommand @@ -4018,7 +4018,7 @@ struct G_UpdateEnemyStateT_6x0A { le_uint16_t enemy_index = 0; // [0, 0xB50) le_uint16_t total_damage = 0; typename std::conditional_t game_flags = 0; -} __packed__; +} __attribute__((packed)); using G_UpdateEnemyState_GC_6x0A = G_UpdateEnemyStateT_6x0A; using G_UpdateEnemyState_DC_PC_XB_BB_6x0A = G_UpdateEnemyStateT_6x0A; check_struct_size(G_UpdateEnemyState_GC_6x0A, 0x0C); @@ -4097,7 +4097,7 @@ struct G_DragonBossActionsT_6x12 { le_uint32_t unknown_a4 = 0; F32T x = 0.0f; F32T z = 0.0f; -} __packed__; +} __attribute__((packed)); using G_DragonBossActions_DC_PC_XB_BB_6x12 = G_DragonBossActionsT_6x12; using G_DragonBossActions_GC_6x12 = G_DragonBossActionsT_6x12; check_struct_size(G_DragonBossActions_DC_PC_XB_BB_6x12, 0x14); @@ -5116,7 +5116,7 @@ struct G_WordSelectT_6x74 { uint8_t size = 0; U16T client_id = 0; WordSelectMessage message; -} __packed__; +} __attribute__((packed)); using G_WordSelect_6x74 = G_WordSelectT_6x74; using G_WordSelectBE_6x74 = G_WordSelectT_6x74; check_struct_size(G_WordSelect_6x74, 0x20); @@ -5155,7 +5155,7 @@ struct G_SyncQuestRegister_6x77 { union { le_uint32_t as_int; le_float as_float; - } __packed__ value; + } __attribute__((packed)) value; } __packed_ws__(G_SyncQuestRegister_6x77, 0x0C); // 6x78: Unknown @@ -5244,7 +5244,7 @@ struct G_BattleScoresT_6x7F { } __packed_ws__(Entry, 8); G_UnusedHeader header; parray entries; -} __packed__; +} __attribute__((packed)); using G_BattleScores_6x7F = G_BattleScoresT_6x7F; using G_BattleScoresBE_6x7F = G_BattleScoresT_6x7F; check_struct_size(G_BattleScores_6x7F, 0x24); @@ -5616,7 +5616,7 @@ struct G_GolDragonBossActionsT_6xA8 { F32T z = 0.0f; uint8_t unknown_a5 = 0; parray unused; -} __packed__; +} __attribute__((packed)); using G_GolDragonBossActions_XB_BB_6xA8 = G_GolDragonBossActionsT_6xA8; using G_GolDragonBossActions_GC_6xA8 = G_GolDragonBossActionsT_6xA8; check_struct_size(G_GolDragonBossActions_XB_BB_6xA8, 0x18); @@ -7038,7 +7038,7 @@ struct G_SetTournamentPlayerDecksT_Ep3_6xB4x3D { /* 01C2:01CA */ uint8_t unknown_a4 = 0; /* 01C3:01CB */ uint8_t unknown_a5 = 0; /* 01C4:01CC */ -} __packed__; +} __attribute__((packed)); using G_SetTournamentPlayerDecks_Ep3NTE_6xB4x3D = G_SetTournamentPlayerDecksT_Ep3_6xB4x3D; check_struct_size(G_SetTournamentPlayerDecks_Ep3NTE_6xB4x3D, 0x1C4); diff --git a/src/CommonFileFormats.hh b/src/CommonFileFormats.hh index 8083c741..c2e96d25 100644 --- a/src/CommonFileFormats.hh +++ b/src/CommonFileFormats.hh @@ -132,7 +132,7 @@ struct ArrayRefT { /* 00 */ U32T count; /* 04 */ U32T offset; /* 08 */ -} __packed__; +} __attribute__((packed)); using ArrayRef = ArrayRefT; using ArrayRefBE = ArrayRefT; check_struct_size(ArrayRef, 8); diff --git a/src/CommonItemSet.hh b/src/CommonItemSet.hh index 98fdf525..c6c47ad0 100644 --- a/src/CommonItemSet.hh +++ b/src/CommonItemSet.hh @@ -22,7 +22,7 @@ public: struct Range { IntT min; IntT max; - } __packed__; + } __attribute__((packed)); Episode episode; parray base_weapon_type_prob_table; @@ -254,7 +254,7 @@ public: /* 50 */ U32T box_item_class_prob_table_offset; // There are several unused fields here. - } __packed__; + } __attribute__((packed)); using Offsets = OffsetsT; using OffsetsBE = OffsetsT; check_struct_size(Offsets, 0x54); @@ -337,7 +337,7 @@ public: struct WeightTableEntry { ValueT value; WeightT weight; - } __packed__; + } __attribute__((packed)); using WeightTableEntry8 = WeightTableEntry; using WeightTableEntry32 = WeightTableEntry; diff --git a/src/FunctionCompiler.cc b/src/FunctionCompiler.cc index c8e19f16..d8699e8a 100644 --- a/src/FunctionCompiler.cc +++ b/src/FunctionCompiler.cc @@ -466,7 +466,7 @@ uint32_t specific_version_for_gc_header_checksum(uint32_t header_checksum) { char developer_code2 = 'P'; uint8_t disc_number = 0; uint8_t version_code; - } __packed__ data; + } __attribute__((packed)) data; for (const char* game_code2 = "OS"; *game_code2; game_code2++) { data.game_code2 = *game_code2; for (const char* region_code = "JEP"; *region_code; region_code++) { diff --git a/src/GSLArchive.cc b/src/GSLArchive.cc index 3863cb81..6394502a 100644 --- a/src/GSLArchive.cc +++ b/src/GSLArchive.cc @@ -15,7 +15,7 @@ struct GSLHeaderEntryT { U32T offset; // In pages, so actual offset is this * 0x800 U32T size; uint64_t unused; -} __packed__; +} __attribute__((packed)); using GSLHeaderEntry = GSLHeaderEntryT; using GSLHeaderEntryBE = GSLHeaderEntryT; diff --git a/src/ItemData.hh b/src/ItemData.hh index b298354a..a4a8840f 100644 --- a/src/ItemData.hh +++ b/src/ItemData.hh @@ -127,7 +127,7 @@ struct ItemData { parray data1wb; parray data1d; parray data1db; - } __packed__; + } __attribute__((packed)); le_uint32_t id; union { parray data2; @@ -135,7 +135,7 @@ struct ItemData { parray data2wb; le_uint32_t data2d; be_uint32_t data2db; - } __packed__; + } __attribute__((packed)); ItemData(); ItemData(const ItemData& other); diff --git a/src/ItemParameterTable.hh b/src/ItemParameterTable.hh index b08848f4..0e3325a1 100644 --- a/src/ItemParameterTable.hh +++ b/src/ItemParameterTable.hh @@ -28,18 +28,18 @@ public: // item's name in the text archive (e.g. TextEnglish) collection 0. /* 00 */ U32T id = 0xFFFFFFFF; /* 04 */ - } __packed__; + } __attribute__((packed)); template struct ItemBaseV3T : ItemBaseV2T { /* 04 */ U16T type = 0; // "Model" in Soly's ItemPMT editor /* 06 */ U16T skin = 0; // "Texture" in Soly's ItemPMT editor /* 08 */ - } __packed__; + } __attribute__((packed)); template struct ItemBaseV4T : ItemBaseV3T { /* 08 */ U32T team_points = 0; /* 0C */ - } __packed__; + } __attribute__((packed)); struct WeaponV4; struct WeaponDCProtos { @@ -142,7 +142,7 @@ public: /* 28 */ WeaponV4 to_v4() const; - } __packed__; + } __attribute__((packed)); using WeaponV3 = WeaponV3T; using WeaponV3BE = WeaponV3T; @@ -197,7 +197,7 @@ public: /* 12 */ uint8_t dfp_range = 0; /* 13 */ uint8_t evp_range = 0; /* 14 */ - } __packed__; + } __attribute__((packed)); template struct ArmorOrShieldFinalT : ArmorOrShieldT { @@ -213,7 +213,7 @@ public: /* 16 */ uint8_t flags_type = 0; /* 17 */ uint8_t unknown_a4 = 0; /* 18 */ - } __packed__; + } __attribute__((packed)); using ArmorOrShieldV4 = ArmorOrShieldFinalT, false>; check_struct_size(ArmorOrShieldV4, 0x20); struct ArmorOrShieldDCProtos : ArmorOrShieldT, false> { @@ -226,7 +226,7 @@ public: template struct ArmorOrShieldV3T : ArmorOrShieldFinalT, BE> { ArmorOrShieldV4 to_v4() const; - } __packed__; + } __attribute__((packed)); using ArmorOrShieldV3 = ArmorOrShieldV3T; using ArmorOrShieldV3BE = ArmorOrShieldV3T; check_struct_size(ArmorOrShieldV3, 0x1C); @@ -239,14 +239,14 @@ public: /* 04 */ U16T stat = 0; /* 06 */ U16T stat_amount = 0; /* 08 */ - } __packed__; + } __attribute__((packed)); template struct UnitFinalT : UnitT { /* 08 */ S16T modifier_amount = 0; /* 0A */ parray unused; /* 0C */ - } __packed__; + } __attribute__((packed)); using UnitV4 = UnitFinalT, false>; check_struct_size(UnitV4, 0x14); struct UnitDCProtos : UnitT, false> { @@ -258,7 +258,7 @@ public: template struct UnitV3T : UnitFinalT, BE> { UnitV4 to_v4() const; - } __packed__; + } __attribute__((packed)); using UnitV3 = UnitV3T; using UnitV3BE = UnitV3T; check_struct_size(UnitV3, 0x10); @@ -295,7 +295,7 @@ public: /* 0E */ uint8_t on_death_flag = 0; /* 0F */ uint8_t on_boss_flag = 0; /* 10 */ - } __packed__; + } __attribute__((packed)); struct MagV4 : MagT, false> { le_uint16_t class_flags = 0x00FF; @@ -318,7 +318,7 @@ public: /* 14 */ MagV4 to_v4() const; - } __packed__; + } __attribute__((packed)); using MagV3 = MagV3T; using MagV3BE = MagV3T; check_struct_size(MagV3, 0x18); @@ -342,7 +342,7 @@ public: // 00000080 - is rare (renders as red box; V3+) /* 0C */ U32T item_flags = 0; /* 10 */ - } __packed__; + } __attribute__((packed)); using ToolV4 = ToolT, false>; check_struct_size(ToolV4, 0x18); @@ -352,7 +352,7 @@ public: template struct ToolV3T : ToolT, BE> { ToolV4 to_v4() const; - } __packed__; + } __attribute__((packed)); using ToolV3 = ToolV3T; using ToolV3BE = ToolV3T; check_struct_size(ToolV3, 0x14); @@ -373,7 +373,7 @@ public: template struct MagFeedResultsListOffsetsT { parray, 8> offsets; // Offsets of MagFeedResultsList objects - } __packed__; + } __attribute__((packed)); using MagFeedResultsListOffsets = MagFeedResultsListOffsetsT; using MagFeedResultsListOffsetsBE = MagFeedResultsListOffsetsT; check_struct_size(MagFeedResultsListOffsets, 0x20); @@ -383,7 +383,7 @@ public: struct SpecialT { U16T type = 0xFFFF; U16T amount = 0; - } __packed__; + } __attribute__((packed)); using Special = SpecialT; using SpecialBE = SpecialT; check_struct_size(Special, 4); @@ -395,7 +395,7 @@ public: uint8_t stat2 = 0; U16T amount1 = 0; U16T amount2 = 0; - } __packed__; + } __attribute__((packed)); using StatBoost = StatBoostT; using StatBoostBE = StatBoostT; check_struct_size(StatBoost, 6); @@ -423,7 +423,7 @@ public: uint8_t flags = 0; parray unused; F32T amount = 0.0f; - } __packed__; + } __attribute__((packed)); using TechniqueBoostEntry = TechniqueBoostEntryT; using TechniqueBoostEntryBE = TechniqueBoostEntryT; check_struct_size(TechniqueBoostEntry, 0x08); @@ -445,7 +445,7 @@ public: F32T shield_divisor = 0.0f; F32T unit_divisor = 0.0f; F32T mag_divisor = 0.0f; - } __packed__; + } __attribute__((packed)); using NonWeaponSaleDivisors = NonWeaponSaleDivisorsT; using NonWeaponSaleDivisorsBE = NonWeaponSaleDivisorsT; check_struct_size(NonWeaponSaleDivisors, 0x10); @@ -599,7 +599,7 @@ protected: /* 50 / F5F0 / 15014 */ U32T unwrap_table; // -> {count, offset -> [{count, offset -> [EventItem]}]} /* 54 / F5F8 / 1501C */ U32T unsealable_table; // -> {count, offset -> [UnsealableItem]} /* 58 / F600 / 15024 */ U32T ranged_special_table; // -> {count, offset -> [4-byte structs]} - } __packed__; + } __attribute__((packed)); using TableOffsetsV3V4 = TableOffsetsV3V4T; using TableOffsetsV3V4BE = TableOffsetsV3V4T; check_struct_size(TableOffsetsV3V4, 0x5C); diff --git a/src/LevelTable.hh b/src/LevelTable.hh index 03eb9164..c4b403e7 100644 --- a/src/LevelTable.hh +++ b/src/LevelTable.hh @@ -33,7 +33,7 @@ struct CharacterStatsT { ret.lck = this->lck.load(); return ret; } -} __packed__; +} __attribute__((packed)); using CharacterStats = CharacterStatsT; using CharacterStatsBE = CharacterStatsT; check_struct_size(CharacterStats, 0x0E); @@ -61,7 +61,7 @@ struct PlayerStatsT { ret.meseta = this->meseta.load(); return ret; } -} __packed__; +} __attribute__((packed)); using PlayerStats = PlayerStatsT; using PlayerStatsBE = PlayerStatsT; check_struct_size(PlayerStats, 0x24); @@ -89,7 +89,7 @@ struct LevelStatsDeltaT { ps.mst += this->mst; ps.lck += this->lck; } -} __packed__; +} __attribute__((packed)); using LevelStatsDelta = LevelStatsDeltaT; using LevelStatsDeltaBE = LevelStatsDeltaT; check_struct_size(LevelStatsDelta, 0x0C); diff --git a/src/PSOEncryption.hh b/src/PSOEncryption.hh index c45f8185..95f14124 100644 --- a/src/PSOEncryption.hh +++ b/src/PSOEncryption.hh @@ -292,7 +292,7 @@ public: ret.store_raw(this->value); return ret; } -} __packed__; +} __attribute__((packed)); using ChallengeTime = ChallengeTimeT; using ChallengeTimeBE = ChallengeTimeT; check_struct_size(ChallengeTime, 4); diff --git a/src/PlayerInventory.hh b/src/PlayerInventory.hh index f838599f..29ff690e 100644 --- a/src/PlayerInventory.hh +++ b/src/PlayerInventory.hh @@ -77,7 +77,7 @@ struct PlayerInventoryItemT { ret.data.id.store_raw(phosg::bswap32(ret.data.id.load_raw())); return ret; } -} __packed__; +} __attribute__((packed)); using PlayerInventoryItem = PlayerInventoryItemT; using PlayerInventoryItemBE = PlayerInventoryItemT; check_struct_size(PlayerInventoryItem, 0x1C); @@ -101,7 +101,7 @@ struct PlayerBankItemT { ret.present = this->present.load(); return ret; } -} __packed__; +} __attribute__((packed)); using PlayerBankItem = PlayerBankItemT; using PlayerBankItemBE = PlayerBankItemT; check_struct_size(PlayerBankItem, 0x18); @@ -292,7 +292,7 @@ struct PlayerInventoryT { ret.items = this->items; return ret; } -} __packed__; +} __attribute__((packed)); using PlayerInventory = PlayerInventoryT; using PlayerInventoryBE = PlayerInventoryT; check_struct_size(PlayerInventory, 0x34C); @@ -416,7 +416,7 @@ struct PlayerBankT { } return ret; } -} __packed__; +} __attribute__((packed)); using PlayerBank60 = PlayerBankT<60, false>; using PlayerBank200 = PlayerBankT<200, false>; using PlayerBank200BE = PlayerBankT<200, true>; diff --git a/src/PlayerSubordinates.hh b/src/PlayerSubordinates.hh index 65b44825..892ef694 100644 --- a/src/PlayerSubordinates.hh +++ b/src/PlayerSubordinates.hh @@ -230,7 +230,7 @@ struct PlayerVisualConfigT { ret.proportion_y = this->proportion_y.load(); return ret; } -} __packed__; +} __attribute__((packed)); using PlayerVisualConfig = PlayerVisualConfigT; using PlayerVisualConfigBE = PlayerVisualConfigT; check_struct_size(PlayerVisualConfig, 0x50); @@ -249,7 +249,7 @@ struct PlayerDispDataDCPCV3T { } PlayerDispDataBB to_bb(uint8_t to_language, uint8_t from_language) const; -} __packed__; +} __attribute__((packed)); using PlayerDispDataDCPCV3 = PlayerDispDataDCPCV3T; using PlayerDispDataDCPCV3BE = PlayerDispDataDCPCV3T; check_struct_size(PlayerDispDataDCPCV3, 0xD0); @@ -382,7 +382,7 @@ struct GuildCardGCT { /* 90:90 */ operator GuildCardBB() const; -} __packed__; +} __attribute__((packed)); using GuildCardGCNTE = GuildCardGCT; using GuildCardGCNTEBE = GuildCardGCT; using GuildCardGC = GuildCardGCT; @@ -530,7 +530,7 @@ struct ChallengeAwardStateT { ret.maximum_rank = this->maximum_rank; return ret; } -} __packed__; +} __attribute__((packed)); using ChallengeAwardState = ChallengeAwardStateT; using ChallengeAwardStateBE = ChallengeAwardStateT; check_struct_size(ChallengeAwardState, 8); @@ -563,7 +563,7 @@ struct PlayerRecordsChallengeDCPCT { /* 78:B0 */ parray, 9> times_ep1_offline; // TODO: This might be online times /* 9C:D4 */ parray unknown_l4; /* A0:D8 */ -} __packed__; +} __attribute__((packed)); using PlayerRecordsChallengeDC = PlayerRecordsChallengeDCPCT; using PlayerRecordsChallengePC = PlayerRecordsChallengeDCPCT; check_struct_size(PlayerRecordsChallengeDC, 0xA0); @@ -598,7 +598,7 @@ struct PlayerRecordsChallengeV3T { /* C8:E4 */ ChallengeAwardStateT ep2_online_award_state; /* D0:EC */ ChallengeAwardStateT ep1_offline_award_state; /* D8:F4 */ - } __packed__; + } __attribute__((packed)); /* 0000:001C */ Stats stats; // On Episode 3, there are special cases that apply to this field - if the // text ends with certain strings, the player will have particle effects @@ -610,7 +610,7 @@ struct PlayerRecordsChallengeV3T { /* 00D8:00F4 */ pstring rank_title; /* 00E4:0100 */ parray unknown_l7; /* 0100:011C */ -} __packed__; +} __attribute__((packed)); using PlayerRecordsChallengeV3 = PlayerRecordsChallengeV3T; using PlayerRecordsChallengeV3BE = PlayerRecordsChallengeV3T; check_struct_size(PlayerRecordsChallengeV3, 0x100); @@ -742,7 +742,7 @@ struct PlayerRecordsBattleT { } return ret; } -} __packed__; +} __attribute__((packed)); using PlayerRecordsBattle = PlayerRecordsBattleT; using PlayerRecordsBattleBE = PlayerRecordsBattleT; check_struct_size(PlayerRecordsBattle, 0x18); @@ -992,7 +992,7 @@ struct SymbolChatT { ret.face_parts = this->face_parts; return ret; } -} __packed__; +} __attribute__((packed)); using SymbolChat = SymbolChatT; using SymbolChatBE = SymbolChatT; check_struct_size(SymbolChat, 0x3C); diff --git a/src/Quest.cc b/src/Quest.cc index 34cdfb60..08cc8d38 100644 --- a/src/Quest.cc +++ b/src/Quest.cc @@ -52,7 +52,7 @@ struct PSOMemCardDLQFileEncryptedHeaderT { le_uint32_t decompressed_size; le_uint32_t round3_seed; // Data follows here. -} __packed__; +} __attribute__((packed)); using PSOVMSDLQFileEncryptedHeader = PSOMemCardDLQFileEncryptedHeaderT; using PSOGCIDLQFileEncryptedHeader = PSOMemCardDLQFileEncryptedHeaderT; check_struct_size(PSOVMSDLQFileEncryptedHeader, 0x10); diff --git a/src/RareItemSet.hh b/src/RareItemSet.hh index 54904144..719a79f5 100644 --- a/src/RareItemSet.hh +++ b/src/RareItemSet.hh @@ -82,7 +82,7 @@ protected: /* 08 */ U32T box_areas_offset; // -> parray /* 0C */ U32T box_rares_offset; // -> parray /* 10 */ - } __packed__; + } __attribute__((packed)); using Offsets = OffsetsT; using OffsetsBE = OffsetsT; check_struct_size(Offsets, 0x10); diff --git a/src/SaveFileFormats.hh b/src/SaveFileFormats.hh index 42ad1465..c3b13ea7 100644 --- a/src/SaveFileFormats.hh +++ b/src/SaveFileFormats.hh @@ -112,7 +112,7 @@ struct SaveFileSymbolChatEntryT { /* 04:04:04:04:04 */ pstring name; /* 1C:34:1C:1C:2C */ SymbolChatT spec; /* 58:70:58:58:68 */ -} __packed__; +} __attribute__((packed)); using SaveFileSymbolChatEntryPC = SaveFileSymbolChatEntryT; using SaveFileSymbolChatEntryGC = SaveFileSymbolChatEntryT; using SaveFileSymbolChatEntryDCXB = SaveFileSymbolChatEntryT; @@ -141,7 +141,7 @@ struct WordSelectMessageT { ret.unknown_a4 = this->unknown_a4.load(); return ret; } -} __packed__; +} __attribute__((packed)); using WordSelectMessage = WordSelectMessageT; using WordSelectMessageBE = WordSelectMessageT; check_struct_size(WordSelectMessage, 0x1C); @@ -160,7 +160,7 @@ struct SaveFileChatShortcutEntryT { this->text = other.text; return *this; } - } __packed__; + } __attribute__((packed)); /* DC:GC:BB */ /* 00:00:00 */ U32T type; // 1 = text, 2 = word select, 3 = symbol chat @@ -186,7 +186,7 @@ struct SaveFileChatShortcutEntryT { } return ret; } -} __packed__; +} __attribute__((packed)); using SaveFileShortcutEntryDC = SaveFileChatShortcutEntryT; using SaveFileShortcutEntryPC = SaveFileChatShortcutEntryT; using SaveFileShortcutEntryGC = SaveFileChatShortcutEntryT; diff --git a/src/Text.hh b/src/Text.hh index ca0cb564..486366e7 100644 --- a/src/Text.hh +++ b/src/Text.hh @@ -13,13 +13,12 @@ #include "Types.hh" -#define __packed__ __attribute__((packed)) #define check_struct_size(StructT, Size) \ static_assert(sizeof(StructT) >= Size, "Structure size is too small"); \ static_assert(sizeof(StructT) <= Size, "Structure size is too large") #define __packed_ws__(StructT, Size) \ - __packed__; \ + __attribute__((packed)); \ check_struct_size(StructT, Size) // Conversion functions @@ -299,7 +298,7 @@ struct parray { } return true; } -} __packed__; +} __attribute__((packed)); template struct bcarray { @@ -383,6 +382,22 @@ struct bcarray { bool operator!=(const bcarray& s) const { return !this->operator==(s); } + + void clear(ItemT v) { + for (size_t x = 0; x < Count; x++) { + this->items[x] = v; + } + } + void clear() { + for (size_t x = 0; x < Count; x++) { + this->items[x] = ItemT(); + } + } + void clear_after(size_t position, ItemT v = 0) { + for (size_t x = position; x < Count; x++) { + this->items[x] = v; + } + } }; // Packed text objects for use in protocol structs @@ -704,7 +719,7 @@ struct pstring { // Note: The contents of a pstring do not have to be null-terminated, so there // is no .c_str() function. -} __packed__; +} __attribute__((packed)); // Helper functions diff --git a/src/WordSelectTable.cc b/src/WordSelectTable.cc index 385e617d..20971102 100644 --- a/src/WordSelectTable.cc +++ b/src/WordSelectTable.cc @@ -40,7 +40,7 @@ struct NonWindowsRootT { U32T table4; U32T article_types_table; U32T table6; -} __packed__; +} __attribute__((packed)); using NonWindowsRoot = NonWindowsRootT; using NonWindowsRootBE = NonWindowsRootT;