From 70e1a75aa793338589bb8d59528e19c800c52ca5 Mon Sep 17 00:00:00 2001 From: 32th-System Date: Sun, 3 Sep 2023 14:45:10 +0200 Subject: [PATCH] th18: use a template for CardBaseList --- thprac/src/thprac/thprac_games.h | 8 ++++++++ thprac/src/thprac/thprac_th18.cpp | 21 +++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/thprac/src/thprac/thprac_games.h b/thprac/src/thprac/thprac_games.h index 179e781..7c4e5ce 100644 --- a/thprac/src/thprac/thprac_games.h +++ b/thprac/src/thprac/thprac_games.h @@ -17,6 +17,14 @@ struct Timer { uint32_t control; }; +template +struct ThList { + T* entry; + ThList* next; + ThList* prev; + ThList* __seldom_used; +}; + #pragma region Gui Wrapper enum game_gui_impl { diff --git a/thprac/src/thprac/thprac_th18.cpp b/thprac/src/thprac/thprac_th18.cpp index 3977806..9fec572 100644 --- a/thprac/src/thprac/thprac_th18.cpp +++ b/thprac/src/thprac/thprac_th18.cpp @@ -35,25 +35,18 @@ namespace TH18 { uint32_t tid; int32_t __bool_c; int32_t __bool_10; - struct HINSTANCE__** phModule; + HINSTANCE* phModule; char filler_24[0x4]; }; - struct CardList { - struct CardBase* entry; - struct CardList* next; - struct CardList* prev; - struct CardList* __seldom_used; - }; - struct CardBase { struct VTableCard* vtable; int32_t card_id; int32_t array_index___plus_1_i_think; - struct CardList list_node; + ThList list_node; int32_t anm_id_for_ingame_effect; - struct Timer recharge_timer; - struct Timer _recharge_timer; + Timer recharge_timer; + Timer _recharge_timer; int32_t recharge_time; struct TableCardData* table_entry; int32_t flags; @@ -70,12 +63,12 @@ namespace TH18 { struct AnmLoaded* ability_anm; struct AnmLoaded* abcard_anm; struct AnmLoaded* abmenu_anm; - struct CardList card_list_head; + ThList card_list_head; int32_t num_total_cards; int32_t num_active_cards; int32_t num_equipment_cards; int32_t num_passive_cards; - struct CardBase* selected_active_card; + CardBase* selected_active_card; int32_t __id_3c; char filler_64[0xc]; int32_t __id_4c; @@ -2828,7 +2821,7 @@ namespace TH18 { auto* ability_manager = *(AbilityManager**)ABILTIY_MANAGER_PTR; - for (CardList* entry = &ability_manager->card_list_head; entry; entry = entry->next) { + for (ThList* entry = &ability_manager->card_list_head; entry; entry = entry->next) { CardBase* card = entry->entry; if (!GameState_Assert(card != nullptr)) continue;