explicitly define equality operators to satisfy older gcc versions

This commit is contained in:
Martin Michelsen
2022-11-28 00:27:21 -08:00
parent 53efff5c4a
commit dc319e3a5d
4 changed files with 133 additions and 22 deletions
+28
View File
@@ -21,6 +21,16 @@ Location::Location(uint8_t x, uint8_t y) : Location(x, y, Direction::RIGHT) { }
Location::Location(uint8_t x, uint8_t y, Direction direction)
: x(x), y(y), direction(direction), unused(0) { }
bool Location::operator==(const Location& other) const {
return (this->x == other.x) &&
(this->y == other.y) &&
(this->direction == other.direction) &&
(this->unused == other.unused);
}
bool Location::operator!=(const Location& other) const {
return !this->operator==(other);
}
void Location::clear() {
this->x = 0;
this->y = 0;
@@ -873,6 +883,24 @@ StateFlags::StateFlags() {
this->clear();
}
bool StateFlags::operator==(const StateFlags& other) const {
return (this->turn_num == other.turn_num) &&
(this->battle_phase == other.battle_phase) &&
(this->current_team_turn1 == other.current_team_turn1) &&
(this->current_team_turn2 == other.current_team_turn2) &&
(this->action_subphase == other.action_subphase) &&
(this->setup_phase == other.setup_phase) &&
(this->registration_phase == other.registration_phase) &&
(this->team_exp == other.team_exp) &&
(this->team_dice_boost == other.team_dice_boost) &&
(this->first_team_turn == other.first_team_turn) &&
(this->tournament_flag == other.tournament_flag) &&
(this->client_sc_card_types == other.client_sc_card_types);
}
bool StateFlags::operator!=(const StateFlags& other) const {
return !this->operator==(other);
}
void StateFlags::clear() {
this->turn_num = 0;
this->battle_phase = BattlePhase::INVALID_00;
+6 -6
View File
@@ -416,8 +416,8 @@ struct Location {
Location();
Location(uint8_t x, uint8_t y);
Location(uint8_t x, uint8_t y, Direction direction);
bool operator==(const Location& other) const = default;
bool operator!=(const Location& other) const = default;
bool operator==(const Location& other) const;
bool operator!=(const Location& other) const;
void clear();
void clear_FF();
@@ -613,8 +613,8 @@ struct Rules {
parray<uint8_t, 3> unused;
Rules();
bool operator==(const Rules& other) const = default;
bool operator!=(const Rules& other) const = default;
bool operator==(const Rules& other) const;
bool operator!=(const Rules& other) const;
void clear();
bool check_invalid_fields() const;
@@ -638,8 +638,8 @@ struct StateFlags {
parray<CardType, 4> client_sc_card_types;
StateFlags();
bool operator==(const StateFlags& other) const = default;
bool operator!=(const StateFlags& other) const = default;
bool operator==(const StateFlags& other) const;
bool operator!=(const StateFlags& other) const;
void clear();
void clear_FF();
} __attribute__((packed));
+83
View File
@@ -12,6 +12,25 @@ Condition::Condition() {
this->clear();
}
bool Condition::operator==(const Condition& other) const {
return (this->type == other.type) &&
(this->remaining_turns == other.remaining_turns) &&
(this->a_arg_value == other.a_arg_value) &&
(this->dice_roll_value == other.dice_roll_value) &&
(this->flags == other.flags) &&
(this->card_definition_effect_index == other.card_definition_effect_index) &&
(this->card_ref == other.card_ref) &&
(this->value == other.value) &&
(this->condition_giver_card_ref == other.condition_giver_card_ref) &&
(this->random_percent == other.random_percent) &&
(this->value8 == other.value8) &&
(this->order == other.order) &&
(this->unknown_a8 == other.unknown_a8);
}
bool Condition::operator!=(const Condition& other) const {
return !this->operator==(other);
}
void Condition::clear() {
this->type = ConditionType::NONE;
this->remaining_turns = 0;
@@ -69,6 +88,19 @@ CardShortStatus::CardShortStatus() {
this->clear();
}
bool CardShortStatus::operator==(const CardShortStatus& other) const {
return (this->card_ref == other.card_ref) &&
(this->current_hp == other.current_hp) &&
(this->card_flags == other.card_flags) &&
(this->loc == other.loc) &&
(this->unused1 == other.unused1) &&
(this->max_hp == other.max_hp) &&
(this->unused2 == other.unused2);
}
bool CardShortStatus::operator!=(const CardShortStatus& other) const {
return !this->operator==(other);
}
void CardShortStatus::clear() {
this->card_ref = 0xFFFF;
this->current_hp = 0;
@@ -112,6 +144,33 @@ ActionChain::ActionChain() {
this->clear();
}
bool ActionChain::operator==(const ActionChain& other) const {
return (this->effective_ap == other.effective_ap) &&
(this->effective_tp == other.effective_tp) &&
(this->ap_effect_bonus == other.ap_effect_bonus) &&
(this->damage == other.damage) &&
(this->acting_card_ref == other.acting_card_ref) &&
(this->unknown_card_ref_a3 == other.unknown_card_ref_a3) &&
(this->attack_action_card_refs == other.attack_action_card_refs) &&
(this->attack_action_card_ref_count == other.attack_action_card_ref_count) &&
(this->attack_medium == other.attack_medium) &&
(this->target_card_ref_count == other.target_card_ref_count) &&
(this->action_subphase == other.action_subphase) &&
(this->strike_count == other.strike_count) &&
(this->damage_multiplier == other.damage_multiplier) &&
(this->attack_number == other.attack_number) &&
(this->tp_effect_bonus == other.tp_effect_bonus) &&
(this->unused1 == other.unused1) &&
(this->unused2 == other.unused2) &&
(this->card_ap == other.card_ap) &&
(this->card_tp == other.card_tp) &&
(this->flags == other.flags) &&
(this->target_card_refs == other.target_card_refs);
}
bool ActionChain::operator!=(const ActionChain& other) const {
return !this->operator==(other);
}
void ActionChain::clear() {
this->effective_ap = 0;
this->effective_tp = 0;
@@ -166,6 +225,13 @@ ActionChainWithConds::ActionChainWithConds() {
this->clear();
}
bool ActionChainWithConds::operator==(const ActionChainWithConds& other) const {
return (this->chain == other.chain && this->conditions == other.conditions);
}
bool ActionChainWithConds::operator!=(const ActionChainWithConds& other) const {
return !this->operator==(other);
}
void ActionChainWithConds::clear() {
this->chain.effective_ap = 0;
this->chain.effective_tp = 0;
@@ -298,6 +364,23 @@ ActionMetadata::ActionMetadata() {
this->clear();
}
bool ActionMetadata::operator==(const ActionMetadata& other) const {
return (this->card_ref == other.card_ref) &&
(this->target_card_ref_count == other.target_card_ref_count) &&
(this->defense_card_ref_count == other.defense_card_ref_count) &&
(this->action_subphase == other.action_subphase) &&
(this->defense_power == other.defense_power) &&
(this->defense_bonus == other.defense_bonus) &&
(this->attack_bonus == other.attack_bonus) &&
(this->flags == other.flags) &&
(this->target_card_refs == other.target_card_refs) &&
(this->defense_card_refs == other.defense_card_refs) &&
(this->original_attacker_card_refs == other.original_attacker_card_refs);
}
bool ActionMetadata::operator!=(const ActionMetadata& other) const {
return !this->operator==(other);
}
void ActionMetadata::clear() {
this->card_ref = 0xFFFF;
this->target_card_ref_count = 0;
+16 -16
View File
@@ -31,8 +31,8 @@ struct Condition {
uint8_t unknown_a8;
Condition();
bool operator==(const Condition& other) const = default;
bool operator!=(const Condition& other) const = default;
bool operator==(const Condition& other) const;
bool operator!=(const Condition& other) const;
void clear();
void clear_FF();
@@ -51,8 +51,8 @@ struct EffectResult {
uint8_t dice_roll_value;
EffectResult();
bool operator==(const EffectResult& other) const = default;
bool operator!=(const EffectResult& other) const = default;
bool operator==(const EffectResult& other) const;
bool operator!=(const EffectResult& other) const;
void clear();
} __attribute__((packed));
@@ -67,8 +67,8 @@ struct CardShortStatus {
uint8_t unused2;
CardShortStatus();
bool operator==(const CardShortStatus& other) const = default;
bool operator!=(const CardShortStatus& other) const = default;
bool operator==(const CardShortStatus& other) const;
bool operator!=(const CardShortStatus& other) const;
void clear();
void clear_FF();
@@ -85,8 +85,8 @@ struct ActionState {
le_uint16_t original_attacker_card_ref;
ActionState();
bool operator==(const ActionState& other) const = default;
bool operator!=(const ActionState& other) const = default;
bool operator==(const ActionState& other) const;
bool operator!=(const ActionState& other) const;
void clear();
} __attribute__((packed));
@@ -115,8 +115,8 @@ struct ActionChain {
parray<le_uint16_t, 4 * 9> target_card_refs;
ActionChain();
bool operator==(const ActionChain& other) const = default;
bool operator!=(const ActionChain& other) const = default;
bool operator==(const ActionChain& other) const;
bool operator!=(const ActionChain& other) const;
void clear();
void clear_FF();
@@ -127,8 +127,8 @@ struct ActionChainWithConds {
parray<Condition, 9> conditions;
ActionChainWithConds();
bool operator==(const ActionChainWithConds& other) const = default;
bool operator!=(const ActionChainWithConds& other) const = default;
bool operator==(const ActionChainWithConds& other) const;
bool operator!=(const ActionChainWithConds& other) const;
void clear();
void clear_FF();
@@ -169,8 +169,8 @@ struct ActionMetadata {
parray<le_uint16_t, 8> original_attacker_card_refs;
ActionMetadata();
bool operator==(const ActionMetadata& other) const = default;
bool operator!=(const ActionMetadata& other) const = default;
bool operator==(const ActionMetadata& other) const;
bool operator!=(const ActionMetadata& other) const;
void clear();
void clear_FF();
@@ -213,8 +213,8 @@ struct HandAndEquipState {
parray<uint8_t, 2> unused2;
HandAndEquipState();
bool operator==(const HandAndEquipState& other) const = default;
bool operator!=(const HandAndEquipState& other) const = default;
bool operator==(const HandAndEquipState& other) const;
bool operator!=(const HandAndEquipState& other) const;
void clear();
void clear_FF();