From 408bc1befc3949fe93f841e343fa083c931a8ca0 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Tue, 16 Jan 2024 21:11:56 -0800 Subject: [PATCH] fix team_dice_bonus variable names --- src/Episode3/Card.cc | 2 +- src/Episode3/CardSpecial.cc | 20 ++++++++++---------- src/Episode3/CardSpecial.hh | 4 ++-- src/Episode3/DataIndexes.cc | 6 +++--- src/Episode3/DataIndexes.hh | 7 +++---- src/Episode3/PlayerState.cc | 8 ++++---- src/Episode3/PlayerState.hh | 2 +- src/Episode3/Server.cc | 14 +++++++------- src/Episode3/Server.hh | 4 ++-- src/ReceiveCommands.cc | 2 +- 10 files changed, 34 insertions(+), 35 deletions(-) diff --git a/src/Episode3/Card.cc b/src/Episode3/Card.cc index 7b93f46e..a9cdc483 100644 --- a/src/Episode3/Card.cc +++ b/src/Episode3/Card.cc @@ -264,7 +264,7 @@ void Card::commit_attack( int16_t exp_amount = clamp(this->server()->team_exp[team_id], 0, effective_damage); this->server()->team_exp[team_id] -= exp_amount; effective_damage -= exp_amount; - this->server()->compute_team_dice_boost(team_id); + this->server()->compute_team_dice_bonus(team_id); this->server()->update_battle_state_flags_and_send_6xB4x03_if_needed(); if (cmd) { cmd->effect.ap += exp_amount; diff --git a/src/Episode3/CardSpecial.cc b/src/Episode3/CardSpecial.cc index 255d2e84..910a17bb 100644 --- a/src/Episode3/CardSpecial.cc +++ b/src/Episode3/CardSpecial.cc @@ -72,7 +72,7 @@ void CardSpecial::AttackEnvStats::clear() { this->num_gun_type_items = 0; this->num_cane_type_items = 0; this->effective_ap_if_not_tech2 = 0; - this->team_dice_boost = 0; + this->team_dice_bonus = 0; this->sc_effective_ap = 0; this->attack_bonus = 0; this->num_sword_type_items_on_team = 0; @@ -115,7 +115,7 @@ void CardSpecial::AttackEnvStats::print(FILE* stream) const { fprintf(stream, "(kap) action_cards_ap = %" PRIu32 "\n", this->action_cards_ap); fprintf(stream, "(ktp) action_cards_tp = %" PRIu32 "\n", this->action_cards_tp); fprintf(stream, "(ldm) last_attack_preliminary_damage = %" PRIu32 "\n", this->last_attack_preliminary_damage); - fprintf(stream, "(lv) team_dice_boost = %" PRIu32 "\n", this->team_dice_boost); + fprintf(stream, "(lv) team_dice_bonus = %" PRIu32 "\n", this->team_dice_bonus); fprintf(stream, "(mc) num_machine_creatures = %" PRIu32 "\n", this->num_machine_creatures); fprintf(stream, "(mhp) max_hp = %" PRIu32 "\n", this->max_hp); fprintf(stream, "(ndm) last_attack_damage_count = %" PRIu32 "\n", this->last_attack_damage_count); @@ -195,7 +195,7 @@ void CardSpecial::adjust_attack_damage_due_to_conditions( } this->send_6xB4x06_for_exp_change( target_card, attacker_card_ref, -exp_deduction, true); - this->compute_team_dice_boost(target_team_id); + this->compute_team_dice_bonus(target_team_id); } break; } @@ -753,7 +753,7 @@ CardSpecial::AttackEnvStats CardSpecial::compute_attack_env_stats( ast.effective_tp = card->action_chain.chain.effective_tp; ast.current_hp = card->get_current_hp(); ast.max_hp = card->get_max_hp(); - ast.team_dice_boost = card ? this->server()->team_dice_boost[card->get_team_id()] : 0; + ast.team_dice_bonus = card ? this->server()->team_dice_bonus[card->get_team_id()] : 0; ast.effective_ap_if_not_tech = (!attacker_card || (attacker_card->action_chain.chain.attack_medium == AttackMedium::TECH)) ? 0 @@ -1180,10 +1180,10 @@ StatSwapType CardSpecial::compute_stat_swap_type(shared_ptr card) co return ret; } -void CardSpecial::compute_team_dice_boost(uint8_t team_id) { +void CardSpecial::compute_team_dice_bonus(uint8_t team_id) { uint8_t value = this->server()->team_exp[team_id] / (this->server()->team_client_count[team_id] * 12); this->adjust_dice_boost_if_team_has_condition_52(team_id, &value, 0); - this->server()->team_dice_boost[team_id] = min(value, 8); + this->server()->team_dice_bonus[team_id] = min(value, 8); } bool CardSpecial::condition_has_when_20_or_21(const Condition& cond) const { @@ -2047,8 +2047,8 @@ bool CardSpecial::execute_effect( this->server()->team_exp[attacker_team_id] += this->server()->team_exp[target_team_id]; this->server()->team_exp[target_team_id] = 0; } - this->compute_team_dice_boost(attacker_team_id); - this->compute_team_dice_boost(target_team_id); + this->compute_team_dice_bonus(attacker_team_id); + this->compute_team_dice_bonus(target_team_id); this->send_6xB4x06_for_exp_change(card, attacker_card_ref, -positive_expr_value, 1); this->server()->update_battle_state_flags_and_send_6xB4x03_if_needed(); } @@ -2090,7 +2090,7 @@ bool CardSpecial::execute_effect( delta = -3; this->server()->team_exp[team_id] -= 3; } - this->compute_team_dice_boost(team_id); + this->compute_team_dice_bonus(team_id); this->send_6xB4x06_for_exp_change(card, attacker_card_ref, delta, 1); } } @@ -2167,7 +2167,7 @@ bool CardSpecial::execute_effect( this->server()->team_exp[team_id] = existing_exp + clamped_expr_value; } this->send_6xB4x06_for_exp_change(card, attacker_card_ref, clamped_expr_value, 1); - this->compute_team_dice_boost(team_id); + this->compute_team_dice_bonus(team_id); this->server()->update_battle_state_flags_and_send_6xB4x03_if_needed(); } } diff --git a/src/Episode3/CardSpecial.hh b/src/Episode3/CardSpecial.hh index c6668a2e..720cc267 100644 --- a/src/Episode3/CardSpecial.hh +++ b/src/Episode3/CardSpecial.hh @@ -74,7 +74,7 @@ public: uint32_t num_gun_type_items; // "gn" in expr uint32_t num_cane_type_items; // "wd" in expr uint32_t effective_ap_if_not_tech2; // "tt" in expr - uint32_t team_dice_boost; // "lv" in expr + uint32_t team_dice_bonus; // "lv" in expr uint32_t sc_effective_ap; // "adm" in expr uint32_t attack_bonus; // "ddm" in expr uint32_t num_sword_type_items_on_team; // "sat" in expr @@ -159,7 +159,7 @@ public: uint32_t* unknown_p11, uint16_t sc_card_ref); StatSwapType compute_stat_swap_type(std::shared_ptr card) const; - void compute_team_dice_boost(uint8_t team_id); + void compute_team_dice_bonus(uint8_t team_id); bool condition_has_when_20_or_21(const Condition& cond) const; size_t count_action_cards_with_condition_for_all_current_attacks( ConditionType cond_type, uint16_t card_ref) const; diff --git a/src/Episode3/DataIndexes.cc b/src/Episode3/DataIndexes.cc index 95644020..20c67229 100644 --- a/src/Episode3/DataIndexes.cc +++ b/src/Episode3/DataIndexes.cc @@ -1498,7 +1498,7 @@ bool StateFlags::operator==(const StateFlags& other) const { (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->team_dice_bonus == other.team_dice_bonus) && (this->first_team_turn == other.first_team_turn) && (this->tournament_flag == other.tournament_flag) && (this->client_sc_card_types == other.client_sc_card_types); @@ -1516,7 +1516,7 @@ void StateFlags::clear() { this->setup_phase = SetupPhase::REGISTRATION; this->registration_phase = RegistrationPhase::AWAITING_NUM_PLAYERS; this->team_exp.clear(0); - this->team_dice_boost.clear(0); + this->team_dice_bonus.clear(0); this->first_team_turn = 0; this->tournament_flag = 0; this->client_sc_card_types.clear(CardType::HUNTERS_SC); @@ -1531,7 +1531,7 @@ void StateFlags::clear_FF() { this->setup_phase = SetupPhase::INVALID_FF; this->registration_phase = RegistrationPhase::INVALID_FF; this->team_exp.clear(0xFFFFFFFF); - this->team_dice_boost.clear(0xFF); + this->team_dice_bonus.clear(0xFF); this->first_team_turn = 0xFF; this->tournament_flag = 0xFF; this->client_sc_card_types.clear(CardType::INVALID_FF); diff --git a/src/Episode3/DataIndexes.hh b/src/Episode3/DataIndexes.hh index 727adc1d..b73cf3e4 100644 --- a/src/Episode3/DataIndexes.hh +++ b/src/Episode3/DataIndexes.hh @@ -979,12 +979,11 @@ struct Rules { } __attribute__((packed)); struct RulesTrial { - // The fields here have the same meaning as in the final version. The only - // difference is that Dice Boost does not exist in the trial version. + // Most fields here have the same meanings as in the final version. /* 00 */ uint8_t overall_time_limit = 0; /* 01 */ uint8_t phase_time_limit = 0; /* 02 */ AllowedCards allowed_cards = AllowedCards::ALL; - /* 03 */ uint8_t atk_dice_max = 1; + /* 03 */ uint8_t atk_dice_max = 1; // TODO: Are these actually maxes? Look at the dice roll function /* 04 */ uint8_t def_dice_max = 6; /* 05 */ uint8_t disable_deck_shuffle = 0; /* 06 */ uint8_t disable_deck_loop = 0; @@ -1009,7 +1008,7 @@ struct StateFlags { /* 06 */ SetupPhase setup_phase; /* 07 */ RegistrationPhase registration_phase; /* 08 */ parray team_exp; - /* 10 */ parray team_dice_boost; + /* 10 */ parray team_dice_bonus; /* 12 */ uint8_t first_team_turn; /* 13 */ uint8_t tournament_flag; /* 14 */ parray client_sc_card_types; diff --git a/src/Episode3/PlayerState.cc b/src/Episode3/PlayerState.cc index adcff7c7..40b6aac9 100644 --- a/src/Episode3/PlayerState.cc +++ b/src/Episode3/PlayerState.cc @@ -1884,8 +1884,8 @@ void PlayerState::roll_main_dice() { this->dice_results[0] = this->atk_points; this->dice_results[1] = this->def_points; - this->atk_points += s->team_dice_boost[this->team_id]; - this->def_points += s->team_dice_boost[this->team_id]; + this->atk_points += s->team_dice_bonus[this->team_id]; + this->def_points += s->team_dice_bonus[this->team_id]; this->atk_points = clamp(this->atk_points, 1, 9); this->def_points = clamp(this->def_points, 1, 9); this->atk_bonuses = this->atk_points - atk_before_bonuses; @@ -1906,7 +1906,7 @@ void PlayerState::unknown_8023C110() { } } -void PlayerState::compute_team_dice_boost_after_draw_phase() { +void PlayerState::compute_team_dice_bonus_after_draw_phase() { auto s = this->server(); if (this->sc_card) { @@ -1924,7 +1924,7 @@ void PlayerState::compute_team_dice_boost_after_draw_phase() { (s->team_client_count[current_team_turn] * 12); s->card_special->adjust_dice_boost_if_team_has_condition_52( current_team_turn, &dice_boost, 0); - s->team_dice_boost[current_team_turn] = clamp(dice_boost, 0, 8); + s->team_dice_bonus[current_team_turn] = clamp(dice_boost, 0, 8); this->update_hand_and_equip_state_and_send_6xB4x02_if_needed(); } diff --git a/src/Episode3/PlayerState.hh b/src/Episode3/PlayerState.hh index 29a2e4ce..b0983b22 100644 --- a/src/Episode3/PlayerState.hh +++ b/src/Episode3/PlayerState.hh @@ -143,7 +143,7 @@ public: void apply_main_die_assist_effects(uint8_t* die_value) const; void roll_main_dice(); void unknown_8023C110(); - void compute_team_dice_boost_after_draw_phase(); + void compute_team_dice_bonus_after_draw_phase(); private: std::weak_ptr w_server; diff --git a/src/Episode3/Server.cc b/src/Episode3/Server.cc index ba738aae..6b7fbfc3 100644 --- a/src/Episode3/Server.cc +++ b/src/Episode3/Server.cc @@ -57,7 +57,7 @@ Server::Server(shared_ptr lobby, Options&& options) defense_list_ended_for_client(false), next_assist_card_set_number(1), team_exp(0), - team_dice_boost(0), + team_dice_bonus(0), team_client_count(0), team_num_ally_fcs_destroyed(0), team_num_cards_destroyed(0), @@ -362,7 +362,7 @@ void Server::add_team_exp(uint8_t team_id, int32_t exp) { uint8_t dice_boost = this->team_exp[team_id] / (this->team_client_count[team_id] * 12); this->card_special->adjust_dice_boost_if_team_has_condition_52(team_id, &dice_boost, 0); - this->team_dice_boost[team_id] = min(dice_boost, 8); + this->team_dice_bonus[team_id] = min(dice_boost, 8); } bool Server::advance_battle_phase() { @@ -657,8 +657,8 @@ void Server::compute_all_map_occupied_bits() { } } -void Server::compute_team_dice_boost(uint8_t team_id) { - this->team_dice_boost[team_id] = clamp( +void Server::compute_team_dice_bonus(uint8_t team_id) { + this->team_dice_bonus[team_id] = clamp( this->team_exp[team_id] / (this->team_client_count[team_id] * 12), 0, 8); } @@ -775,7 +775,7 @@ void Server::draw_phase_after() { ps->draw_hand(0); } if (ps->is_team_turn()) { - ps->compute_team_dice_boost_after_draw_phase(); + ps->compute_team_dice_bonus_after_draw_phase(); } } } @@ -1562,8 +1562,8 @@ G_SetStateFlags_GC_Ep3_6xB4x03 Server::prepare_6xB4x03() const { cmd.state.registration_phase = this->registration_phase; cmd.state.team_exp[0] = this->team_exp[0]; cmd.state.team_exp[1] = this->team_exp[1]; - cmd.state.team_dice_boost[0] = this->team_dice_boost[0]; - cmd.state.team_dice_boost[1] = this->team_dice_boost[1]; + cmd.state.team_dice_bonus[0] = this->team_dice_bonus[0]; + cmd.state.team_dice_bonus[1] = this->team_dice_bonus[1]; cmd.state.first_team_turn = this->first_team_turn; cmd.state.tournament_flag = this->options.tournament ? 1 : 0; for (size_t z = 0; z < 4; z++) { diff --git a/src/Episode3/Server.hh b/src/Episode3/Server.hh index 18f4dd0a..9c1aba45 100644 --- a/src/Episode3/Server.hh +++ b/src/Episode3/Server.hh @@ -143,7 +143,7 @@ public: bool check_presence_entry(uint8_t client_id) const; void clear_player_flags_after_dice_phase(); void compute_all_map_occupied_bits(); - void compute_team_dice_boost(uint8_t team_id); + void compute_team_dice_bonus(uint8_t team_id); void copy_player_states_to_prev_states(); std::shared_ptr definition_for_card_id(uint16_t card_id) const; void destroy_cards_with_zero_hp(); @@ -303,7 +303,7 @@ public: std::shared_ptr ruler_server; parray, 2>, 5> warp_positions; // Array indexes are (type, end, x/y) parray team_exp; - parray team_dice_boost; + parray team_dice_bonus; parray team_client_count; parray team_num_ally_fcs_destroyed; parray team_num_cards_destroyed; diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index bdf14d88..98e38e3e 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -1287,7 +1287,7 @@ static bool add_next_game_client(shared_ptr l) { state_cmd.state.setup_phase = Episode3::SetupPhase::REGISTRATION; state_cmd.state.registration_phase = Episode3::RegistrationPhase::AWAITING_NUM_PLAYERS; state_cmd.state.team_exp.clear(0); - state_cmd.state.team_dice_boost.clear(0); + state_cmd.state.team_dice_bonus.clear(0); state_cmd.state.first_team_turn = 0xFF; state_cmd.state.tournament_flag = 0x01; state_cmd.state.client_sc_card_types.clear(Episode3::CardType::INVALID_FF);