From a35437e48e4c2487fe63c27421b11090d84d9c81 Mon Sep 17 00:00:00 2001 From: salix5 Date: Thu, 12 Dec 2024 20:39:47 +0800 Subject: [PATCH 1/3] update def --- card.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/card.h b/card.h index e765f381e..227c88e51 100644 --- a/card.h +++ b/card.h @@ -264,9 +264,9 @@ class card { int32_t is_link_state(); int32_t is_extra_link_state(); int32_t is_position(uint32_t pos) const; - void set_status(uint32_t status, int32_t enabled); - int32_t get_status(uint32_t status) const; - int32_t is_status(uint32_t status) const; + void set_status(uint32_t x, int32_t enabled); + int32_t get_status(uint32_t x) const; + int32_t is_status(uint32_t x) const; uint32_t get_column_zone(int32_t location); void get_column_cards(card_set* cset); int32_t is_all_column(); From 988ef2afc67251ac81dc5425ffc92f0c6c47c695 Mon Sep 17 00:00:00 2001 From: salix5 Date: Thu, 12 Dec 2024 21:01:56 +0800 Subject: [PATCH 2/3] card: add default member initializer --- card.cpp | 29 ++--------------------- card.h | 72 ++++++++++++++++++++++++++++---------------------------- 2 files changed, 38 insertions(+), 63 deletions(-) diff --git a/card.cpp b/card.cpp index 52ae5c660..f4868a100 100644 --- a/card.cpp +++ b/card.cpp @@ -143,34 +143,9 @@ uint32_t card::attacker_map::findcard(card* pcard) { else return it->second.second; } -card::card(duel* pd) { - ref_handle = 0; - pduel = pd; - owner = PLAYER_NONE; - sendto_param.clear(); - release_param = 0; - sum_param = 0; - position_param = 0; - spsummon_param = 0; - to_field_param = 0; - direct_attackable = 0; - summon_info = 0; - status = 0; - equiping_target = 0; - pre_equip_target = 0; - overlay_target = 0; - current = {}; - previous = {}; - spsummon = {}; +card::card(duel* pd) + :pduel(pd) { temp.init_state(); - unique_pos[0] = unique_pos[1] = 0; - spsummon_counter[0] = spsummon_counter[1] = 0; - unique_code = 0; - unique_fieldid = 0; - assume_type = 0; - assume_value = 0; - spsummon_code = 0; - xyz_materials_previous_count_onfield = 0; current.controler = PLAYER_NONE; } inline void update_cache(uint32_t tdata, uint32_t& cache, byte*& p, uint32_t& query_flag, uint32_t flag) { diff --git a/card.h b/card.h index 227c88e51..35566d3a9 100644 --- a/card.h +++ b/card.h @@ -144,48 +144,48 @@ class card { uint8_t sequence{ 0 }; }; - int32_t ref_handle; - duel* pduel; + int32_t ref_handle{}; + duel* pduel{}; card_data data; card_state previous; card_state temp; card_state current; card_state spsummon; query_cache q_cache; - uint8_t owner; - uint8_t summon_player; - uint32_t summon_info; - uint32_t status; + uint8_t owner{ PLAYER_NONE }; + uint8_t summon_player{ PLAYER_NONE }; + uint32_t summon_info{}; + uint32_t status{}; sendto_param_t sendto_param; - uint32_t release_param; - uint32_t sum_param; - uint32_t position_param; - uint32_t spsummon_param; - uint32_t to_field_param; - uint8_t attack_announce_count; - uint8_t direct_attackable; - uint8_t announce_count; - uint8_t attacked_count; - uint8_t attack_all_target; - uint8_t attack_controler; - uint16_t cardid; - uint32_t fieldid; - uint32_t fieldid_r; - uint16_t turnid; - uint16_t turn_counter; - uint8_t unique_pos[2]; - uint32_t unique_fieldid; - uint32_t unique_code; - uint32_t unique_location; - int32_t unique_function; - effect* unique_effect; - uint32_t spsummon_code; - uint16_t spsummon_counter[2]; - uint8_t assume_type; - uint32_t assume_value; - card* equiping_target; - card* pre_equip_target; - card* overlay_target; + uint32_t release_param{}; + uint32_t sum_param{}; + uint32_t position_param{}; + uint32_t spsummon_param{}; + uint32_t to_field_param{}; + uint8_t attack_announce_count{}; + uint8_t direct_attackable{}; + uint8_t announce_count{}; + uint8_t attacked_count{}; + uint8_t attack_all_target{}; + uint8_t attack_controler{}; + uint16_t cardid{}; + uint32_t fieldid{}; + uint32_t fieldid_r{}; + uint16_t turnid{}; + uint16_t turn_counter{}; + uint8_t unique_pos[2]{}; + uint32_t unique_fieldid{}; + uint32_t unique_code{}; + uint32_t unique_location{}; + int32_t unique_function{}; + effect* unique_effect{}; + uint32_t spsummon_code{}; + uint16_t spsummon_counter[2]{}; + uint8_t assume_type{}; + uint32_t assume_value{}; + card* equiping_target{}; + card* pre_equip_target{}; + card* overlay_target{}; relation_map relations; counter_map counters; effect_count indestructable_effects; @@ -197,7 +197,7 @@ class card { card_set effect_target_owner; card_set effect_target_cards; card_vector xyz_materials; - int32_t xyz_materials_previous_count_onfield; + int32_t xyz_materials_previous_count_onfield{}; effect_container single_effect; effect_container field_effect; effect_container equip_effect; From 4fb8564285c8923598c1725cbfe935a1a670d971 Mon Sep 17 00:00:00 2001 From: salix5 Date: Thu, 12 Dec 2024 21:40:50 +0800 Subject: [PATCH 3/3] member initializer list --- effect.cpp | 4 ++-- field.cpp | 4 ++-- field.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/effect.cpp b/effect.cpp index fde0321bc..ea9c90a02 100644 --- a/effect.cpp +++ b/effect.cpp @@ -30,8 +30,8 @@ bool is_continuous_event(uint32_t code) { return continuous_event.find(code) != continuous_event.end(); } -effect::effect(duel* pd) { - pduel = pd; +effect::effect(duel* pd) + : pduel(pd) { label.reserve(4); } int32_t effect::is_disable_related() const { diff --git a/field.cpp b/field.cpp index 896b65b1e..0e5d71281 100644 --- a/field.cpp +++ b/field.cpp @@ -53,8 +53,8 @@ void chain::set_triggering_state(card* pcard) { bool tevent::operator< (const tevent& v) const { return std::memcmp(this, &v, sizeof(tevent)) < 0; } -field::field(duel* pduel) { - this->pduel = pduel; +field::field(duel* pd) + : pduel(pd) { for (int32_t i = 0; i < 2; ++i) { player[i].list_mzone.resize(7, 0); player[i].list_szone.resize(8, 0); diff --git a/field.h b/field.h index 71eb9ede1..372fe280b 100644 --- a/field.h +++ b/field.h @@ -362,7 +362,7 @@ struct processor { }; class field { public: - duel* pduel; + duel* pduel{}; player_info player[2]; card* temp_card{}; field_info infos; @@ -373,7 +373,7 @@ class field { tevent nil_event; static int32_t field_used_count[32]; - explicit field(duel* pduel); + explicit field(duel* pd); ~field() = default; void reload_field_info();