delete hard_reset_flag

This commit is contained in:
Martin Michelsen
2023-09-09 17:55:06 -07:00
parent 0863c4f27c
commit aa48dd5e15
7 changed files with 70 additions and 78 deletions
+3 -3
View File
@@ -49,7 +49,7 @@ void Card::init() {
this->max_hp = this->def_entry->def.hp.stat;
this->current_hp = this->def_entry->def.hp.stat;
if (this->sc_card_ref == this->card_ref) {
int16_t rules_char_hp = this->server()->map_and_rules1->rules.char_hp;
int16_t rules_char_hp = this->server()->map_and_rules->rules.char_hp;
int16_t base_char_hp = (rules_char_hp == 0) ? 15 : rules_char_hp;
int16_t hp = clamp<int16_t>(base_char_hp + this->def_entry->def.hp.stat, 1, 99);
this->max_hp = hp;
@@ -358,7 +358,7 @@ void Card::destroy_set_card(shared_ptr<Card> attacker_card) {
}
}
if ((this->server()->map_and_rules1->rules.hp_type == HPType::DEFEAT_TEAM) &&
if ((this->server()->map_and_rules->rules.hp_type == HPType::DEFEAT_TEAM) &&
(this->player_state()->get_sc_card().get() == this)) {
for (size_t set_index = 0; set_index < 8; set_index++) {
auto card = this->player_state()->get_set_card(set_index);
@@ -585,7 +585,7 @@ int32_t Card::move_to_location(const Location& loc) {
}
void Card::propagate_shared_hp_if_needed() {
if ((this->server()->map_and_rules1->rules.hp_type == HPType::COMMON_HP) &&
if ((this->server()->map_and_rules->rules.hp_type == HPType::COMMON_HP) &&
((this->def_entry->def.type == CardType::HUNTERS_SC) || (this->def_entry->def.type == CardType::ARKZ_SC))) {
for (size_t other_client_id = 0; other_client_id < 4; other_client_id++) {
auto other_ps = this->server()->player_states[other_client_id];
+12 -12
View File
@@ -832,7 +832,7 @@ shared_ptr<Card> CardSpecial::compute_replaced_target_based_on_conditions(
// the Gifoie card's ID (00D9) for compute_effective_range.
// TODO: We should fix this so it doesn't rely on a fixed card definition.
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, 0x00D9, target_card_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, 0x00D9, target_card_loc, this->server()->map_and_rules);
auto card_refs_in_parry_range = target_ps->get_all_cards_within_range(
range, target_card_loc, 0xFF);
@@ -2570,7 +2570,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
if (ce && ps) {
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, ce->def.card_id, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
add_card_refs(ps->get_card_refs_within_range_from_all_players(range, card1_loc, CardType::ITEM));
}
}
@@ -2610,7 +2610,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
if (ce && ps) {
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, ce->def.card_id, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
add_card_refs(ps->get_all_cards_within_range(range, card1_loc, card1->get_team_id()));
}
}
@@ -2680,7 +2680,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
// should fix this eventually.
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, 0x00D9, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
auto result_card_refs = ps->get_all_cards_within_range(range, card1_loc, card1->get_team_id());
for (uint16_t result_card_ref : result_card_refs) {
auto result_card = this->server()->card_for_set_card_ref(result_card_ref);
@@ -2706,7 +2706,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, 0x00D9, card2);
log23.debug("effective range card ID is %04hX", range_card_id);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1, &log23);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules, &log23);
auto result_card_refs = ps->get_all_cards_within_range(range, card1_loc, 0xFF);
log23.debug("%zu result card refs", result_card_refs.size());
for (uint16_t result_card_ref : result_card_refs) {
@@ -2783,7 +2783,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
// TODO: Again with the Gifoie hardcoding...
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, 0x00D9, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
auto result_card_refs = ps->get_all_cards_within_range(range, card1_loc, 0xFF);
for (uint16_t result_card_ref : result_card_refs) {
auto result_card = this->server()->card_for_set_card_ref(result_card_ref);
@@ -2837,7 +2837,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
// TODO: Yet another Gifoie hardcode location :(
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, 0x00D9, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
auto result_card_refs = ps->get_all_cards_within_range(range, card1_loc, card1->get_team_id());
for (uint16_t result_card_ref : result_card_refs) {
auto result_card = this->server()->card_for_set_card_ref(result_card_ref);
@@ -2864,7 +2864,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
// TODO: Sigh. Gifoie again.
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, 0x00D9, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
auto result_card_refs = ps->get_all_cards_within_range(range, card1_loc, 0xFF);
for (uint16_t result_card_ref : result_card_refs) {
auto result_card = this->server()->card_for_set_card_ref(result_card_ref);
@@ -2960,7 +2960,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
// Slay instead of Gifoie
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, 0x009C, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
auto result_card_refs = ps->get_all_cards_within_range(range, card1_loc, 0xFF);
for (uint16_t result_card_ref : result_card_refs) {
auto result_card = this->server()->card_for_set_card_ref(result_card_ref);
@@ -2989,7 +2989,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
// TODO: Sigh. Gifoie. Sigh.
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, 0x00D9, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
auto result_card_refs = ps->get_all_cards_within_range(range, card1_loc, 0xFF);
for (uint16_t result_card_ref : result_card_refs) {
auto result_card = this->server()->card_for_set_card_ref(result_card_ref);
@@ -3027,7 +3027,7 @@ vector<shared_ptr<const Card>> CardSpecial::get_targeted_cards_for_condition(
// TODO: One more Gifoie here.
uint16_t range_card_id = this->get_card_id_with_effective_range(card1, 0x00D9, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, range_card_id, card1_loc, this->server()->map_and_rules);
auto result_card_refs = ps->get_all_cards_within_range(range, card1_loc, card1->get_team_id());
for (uint16_t result_card_ref : result_card_refs) {
auto result_card = this->server()->card_for_set_card_ref(result_card_ref);
@@ -4215,7 +4215,7 @@ vector<shared_ptr<const Card>> CardSpecial::filter_cards_by_range(
// TODO: Remove hardcoded card ID here (Earthquake)
uint16_t card_id = this->get_card_id_with_effective_range(card1, 0x00ED, card2);
parray<uint8_t, 9 * 9> range;
compute_effective_range(range, this->server()->card_index, card_id, card1_loc, this->server()->map_and_rules1);
compute_effective_range(range, this->server()->card_index, card_id, card1_loc, this->server()->map_and_rules);
auto card_refs_in_range = ps->get_card_refs_within_range_from_all_players(range, card1_loc, CardType::ITEM);
for (auto card : cards) {
+1 -1
View File
@@ -24,7 +24,7 @@ struct NameEntry {
struct DeckEntry {
ptext<char, 0x10> name;
le_uint32_t team_id;
parray<le_uint16_t, 0x1F> card_ids;
parray<le_uint16_t, 31> card_ids;
// If the following flag is not set to 3, then the God Whim assist effect can
// use cards that are hidden from the player during deck building. The client
// always sets this to 3, and it's not clear why this even exists.
+8 -8
View File
@@ -52,10 +52,10 @@ void PlayerState::init() {
this->client_id,
s->deck_entries[client_id]->card_ids,
s->random_crypt));
if (s->map_and_rules1->rules.disable_deck_shuffle) {
if (s->map_and_rules->rules.disable_deck_shuffle) {
this->deck_state->disable_shuffle();
}
if (s->map_and_rules1->rules.disable_deck_loop) {
if (s->map_and_rules->rules.disable_deck_loop) {
this->deck_state->disable_loop();
}
@@ -756,7 +756,7 @@ int32_t PlayerState::error_code_for_client_setting_card(
return -0x7E;
}
if ((ce->def.type == CardType::CREATURE) &&
!s->map_and_rules1->tile_is_vacant(loc->x, loc->y)) {
!s->map_and_rules->tile_is_vacant(loc->x, loc->y)) {
return -0x7A;
}
return 0;
@@ -1328,7 +1328,7 @@ bool PlayerState::set_card_from_hand(
void PlayerState::set_initial_location() {
auto s = this->server();
auto mr = s->map_and_rules1;
auto mr = s->map_and_rules;
uint8_t num_team_players;
if (this->team_id == 0) {
@@ -1384,7 +1384,7 @@ void PlayerState::set_map_occupied_bit_for_card_on_warp_tile(
for (size_t warp_end = 0; warp_end < 2; warp_end++) {
if ((s->warp_positions[warp_type][warp_end][0] == card->loc.x) &&
(s->warp_positions[warp_type][warp_end][1] == card->loc.y)) {
s->map_and_rules1->set_occupied_bit_for_tile(
s->map_and_rules->set_occupied_bit_for_tile(
s->warp_positions[warp_type][warp_end ^ 1][0],
s->warp_positions[warp_type][warp_end ^ 1][1]);
}
@@ -1396,7 +1396,7 @@ void PlayerState::set_map_occupied_bits_for_sc_and_creatures() {
auto s = this->server();
if (this->sc_card && !(this->sc_card->card_flags & 2)) {
s->map_and_rules1->set_occupied_bit_for_tile(
s->map_and_rules->set_occupied_bit_for_tile(
this->sc_card->loc.x, this->sc_card->loc.y);
this->set_map_occupied_bit_for_card_on_warp_tile(this->sc_card);
}
@@ -1405,7 +1405,7 @@ void PlayerState::set_map_occupied_bits_for_sc_and_creatures() {
for (size_t set_index = 0; set_index < 8; set_index++) {
auto card = this->set_cards[set_index];
if (card) {
s->map_and_rules1->set_occupied_bit_for_tile(
s->map_and_rules->set_occupied_bit_for_tile(
card->loc.x, card->loc.y);
this->set_map_occupied_bit_for_card_on_warp_tile(card);
}
@@ -1809,7 +1809,7 @@ void PlayerState::apply_main_die_assist_effects(uint8_t* die_value) const {
void PlayerState::roll_main_dice() {
auto s = this->server();
const auto& rules = s->map_and_rules1->rules;
const auto& rules = s->map_and_rules->rules;
uint8_t min_dice = rules.min_dice;
uint8_t max_dice = rules.max_dice;
+44 -50
View File
@@ -69,7 +69,6 @@ Server::Server(shared_ptr<Lobby> lobby,
team_client_count(0),
team_num_ally_fcs_destroyed(0),
team_num_cards_destroyed(0),
hard_reset_flag(false),
num_trap_tiles_of_type(0),
chosen_trap_tile_index_of_type(0),
has_done_pb(0),
@@ -77,8 +76,7 @@ Server::Server(shared_ptr<Lobby> lobby,
prev_num_6xB4x06_commands_sent(0) {}
void Server::init() {
this->map_and_rules1.reset(new MapAndRulesState());
this->map_and_rules2.reset(new MapAndRulesState());
this->map_and_rules.reset(new MapAndRulesState());
this->num_clients_present = 0;
this->overlay_state.clear();
for (size_t z = 0; z < 4; z++) {
@@ -104,7 +102,7 @@ void Server::init() {
this->assist_server.reset(new AssistServer(this->shared_from_this()));
this->ruler_server.reset(new RulerServer(this->shared_from_this()));
this->ruler_server->link_objects(this->map_and_rules1, this->state_flags, this->assist_server);
this->ruler_server->link_objects(this->map_and_rules, this->state_flags, this->assist_server);
this->send_6xB4x46();
}
@@ -411,7 +409,7 @@ bool Server::card_ref_is_empty_or_has_valid_card_id(uint16_t card_ref) const {
bool Server::check_for_battle_end() {
bool ret = false;
if (this->map_and_rules1->rules.hp_type == HPType::DEFEAT_TEAM) {
if (this->map_and_rules->rules.hp_type == HPType::DEFEAT_TEAM) {
bool teams_defeated[2] = {true, true};
for (size_t client_id = 0; client_id < 4; client_id++) {
auto ps = this->player_states[client_id];
@@ -525,7 +523,7 @@ void Server::clear_player_flags_after_dice_phase() {
void Server::compute_all_map_occupied_bits() {
for (size_t y = 0; y < 0x10; y++) {
for (size_t x = 0; x < 0x10; x++) {
this->map_and_rules1->clear_occupied_bit_for_tile(x, y);
this->map_and_rules->clear_occupied_bit_for_tile(x, y);
}
}
for (size_t z = 0; z < 4; z++) {
@@ -584,8 +582,8 @@ void Server::destroy_cards_with_zero_hp() {
}
void Server::determine_first_team_turn() {
this->team_client_count[0] = this->map_and_rules1->num_team0_players;
this->team_client_count[1] = this->map_and_rules1->num_players - this->team_client_count[0];
this->team_client_count[0] = this->map_and_rules->num_team0_players;
this->team_client_count[1] = this->map_and_rules->num_players - this->team_client_count[0];
this->first_team_turn = 0xFF;
while (this->first_team_turn == 0xFF) {
uint8_t results[2] = {0, 0};
@@ -665,11 +663,11 @@ void Server::draw_phase_after() {
this->round_num++;
if (this->current_team_turn1 == this->first_team_turn) {
if (this->map_and_rules1->rules.overall_time_limit > 0) {
if (this->map_and_rules->rules.overall_time_limit > 0) {
// Battle time limits are specified in increments of 5 minutes.
// Note: This part is not based on the original code because the timing
// facilities used are different.
uint64_t limit_5mins = this->map_and_rules1->rules.overall_time_limit;
uint64_t limit_5mins = this->map_and_rules->rules.overall_time_limit;
uint64_t end_usecs = this->battle_start_usecs + (limit_5mins * 300 * 1000 * 1000);
if (now() >= end_usecs) {
this->overall_time_expired = true;
@@ -1081,7 +1079,7 @@ void Server::send_all_state_updates() {
this->send(this->prepare_6xB4x07_decks_update());
G_UpdateMap_GC_Ep3_6xB4x05 cmd;
cmd.state = *this->map_and_rules1;
cmd.state = *this->map_and_rules;
this->send(cmd);
this->send_6xB4x02_for_all_players_if_needed();
@@ -1139,7 +1137,7 @@ void Server::set_client_id_ready_to_advance_phase(uint8_t client_id) {
ps->assist_flags |= 1;
ps->update_hand_and_equip_state_and_send_6xB4x02_if_needed();
if (this->battle_phase == BattlePhase::DICE) {
if (!(ps->assist_flags & 0x8000) || this->map_and_rules1->rules.disable_dice_boost) {
if (!(ps->assist_flags & 0x8000) || this->map_and_rules->rules.disable_dice_boost) {
ps->assist_flags &= 0xFFFF7FFF;
ps->roll_main_dice();
if ((ps->get_atk_points() < 3) && (ps->get_def_points() < 3)) {
@@ -1219,8 +1217,8 @@ void Server::set_phase_after() {
switch (this->assist_server->get_active_assist_by_index(z)) {
case AssistEffect::SHUFFLE_ALL:
case AssistEffect::SHUFFLE_GROUP:
if (!this->map_and_rules1->rules.disable_deck_shuffle &&
!this->map_and_rules1->rules.disable_deck_loop) {
if (!this->map_and_rules->rules.disable_deck_shuffle &&
!this->map_and_rules->rules.disable_deck_loop) {
ps->discard_and_redraw_hand();
}
break;
@@ -1293,7 +1291,7 @@ void Server::setup_and_start_battle() {
}
}
if (this->map_and_rules1->rules.hp_type == HPType::COMMON_HP) {
if (this->map_and_rules->rules.hp_type == HPType::COMMON_HP) {
int16_t team_hp[2] = {99, 99};
for (size_t z = 0; z < 4; z++) {
auto ps = this->player_states[z];
@@ -1321,7 +1319,7 @@ void Server::setup_and_start_battle() {
}
}
this->map_and_rules1->start_facing_directions = 0;
this->map_and_rules->start_facing_directions = 0;
for (size_t z = 0; z < 4; z++) {
auto ps = this->player_states[z];
if (ps) {
@@ -1334,8 +1332,8 @@ void Server::setup_and_start_battle() {
for (size_t y = 0; y < 0x10; y++) {
for (size_t x = 0; x < 0x10; x++) {
if (this->map_and_rules1->map.tiles[y][x] > 1) {
this->map_and_rules1->map.tiles[y][x] = 1;
if (this->map_and_rules->map.tiles[y][x] > 1) {
this->map_and_rules->map.tiles[y][x] = 1;
}
}
}
@@ -1361,7 +1359,7 @@ void Server::setup_and_start_battle() {
this->warp_positions[tile_subtype][1][1] = y;
}
} else if ((tile_type == 0x10) || (tile_type == 0x20) || (tile_type == 0x50)) {
this->map_and_rules1->map.tiles[y][x] = 0;
this->map_and_rules->map.tiles[y][x] = 0;
}
}
}
@@ -1404,7 +1402,7 @@ void Server::setup_and_start_battle() {
this->send_6xB4x50_trap_tile_locations();
G_UpdateMap_GC_Ep3_6xB4x05 cmd05;
cmd05.state = *this->map_and_rules1;
cmd05.state = *this->map_and_rules;
cmd05.unknown_a1 = 1;
this->send(cmd05);
@@ -1450,13 +1448,13 @@ bool Server::update_registration_phase() {
return false;
}
if (this->map_and_rules1->num_players == 0) {
if (this->map_and_rules->num_players == 0) {
this->registration_phase = RegistrationPhase::AWAITING_NUM_PLAYERS;
this->update_battle_state_flags_and_send_6xB4x03_if_needed();
return false;
}
if (this->map_and_rules1->num_players != this->num_clients_present) {
if (this->map_and_rules->num_players != this->num_clients_present) {
this->registration_phase = RegistrationPhase::AWAITING_PLAYERS;
this->update_battle_state_flags_and_send_6xB4x03_if_needed();
return false;
@@ -1469,7 +1467,7 @@ bool Server::update_registration_phase() {
}
}
if (num_team0_registered_players != this->map_and_rules1->num_team0_players) {
if (num_team0_registered_players != this->map_and_rules->num_team0_players) {
this->registration_phase = RegistrationPhase::AWAITING_DECKS;
this->update_battle_state_flags_and_send_6xB4x03_if_needed();
return false;
@@ -1526,17 +1524,6 @@ void Server::on_server_data_input(const string& data) {
set_mask_for_ep3_game_command(unmasked_data.data(), unmasked_data.size(), 0);
(this->*handler)(unmasked_data);
if (this->hard_reset_flag) {
// In the original implementation, this command recreates the server object.
// This is possible because the dispatch function is not part of the server
// object in the original implementation; however, in our implementation, it
// is, so we don't support this. The original implementation did this:
// this->base()->recreate_server(); // Destroys *this, which we can't do here
// root_card_server = this->server;
// this->unknown_8023DC84();
throw runtime_error("hard reset command received");
}
}
void Server::handle_CAx0B_mulligan_hand(const string& data) {
@@ -1831,28 +1818,24 @@ void Server::handle_CAx13_update_map_during_setup(const string& data) {
if (!this->battle_in_progress &&
(this->setup_phase == SetupPhase::REGISTRATION) &&
(this->map_and_rules1->num_players == 0) &&
(this->map_and_rules->num_players == 0) &&
(this->registration_phase != RegistrationPhase::REGISTERED) &&
(this->registration_phase != RegistrationPhase::BATTLE_STARTED)) {
*this->map_and_rules1 = in_cmd.map_and_rules_state;
*this->map_and_rules2 = in_cmd.map_and_rules_state;
*this->map_and_rules = in_cmd.map_and_rules_state;
if (this->override_environment_number != 0xFF) {
this->map_and_rules1->environment_number = this->override_environment_number;
this->map_and_rules2->environment_number = this->override_environment_number;
this->map_and_rules->environment_number = this->override_environment_number;
this->override_environment_number = 0xFF;
}
this->overlay_state = in_cmd.overlay_state;
if (this->behavior_flags & BehaviorFlag::DISABLE_TIME_LIMITS) {
this->map_and_rules1->rules.overall_time_limit = 0;
this->map_and_rules1->rules.phase_time_limit = 0;
this->map_and_rules2->rules.overall_time_limit = 0;
this->map_and_rules2->rules.phase_time_limit = 0;
this->map_and_rules->rules.overall_time_limit = 0;
this->map_and_rules->rules.phase_time_limit = 0;
}
if (this->map_and_rules1->rules.check_invalid_fields()) {
this->map_and_rules1->rules.check_and_reset_invalid_fields();
if (this->map_and_rules->rules.check_invalid_fields()) {
this->map_and_rules->rules.check_and_reset_invalid_fields();
}
if (this->map_and_rules1->num_players_per_team == 0) {
this->map_and_rules1->num_players_per_team = this->map_and_rules1->num_players >> 1;
if (this->map_and_rules->num_players_per_team == 0) {
this->map_and_rules->num_players_per_team = this->map_and_rules->num_players >> 1;
}
this->update_registration_phase();
}
@@ -1912,7 +1895,18 @@ void Server::handle_CAx15_unused_hard_reset_server_state(const string& data) {
const auto& in_cmd = check_size_t<G_HardResetServerState_GC_Ep3_6xB3x15_CAx15>(data);
this->send_debug_command_received_message(
in_cmd.header.subsubcommand, "HARD RESET");
this->hard_reset_flag = true;
// In the original implementation, this command recreates the server object.
// This is possible because the dispatch function is not part of the server
// object in the original implementation; however, in our implementation, it
// is, so we don't support this. The original implementation did this:
// this->base()->recreate_server(); // Destroys *this, which we can't do
// root_card_server = this->server;
// *this->map_and_rules = *this->initial_map_and_rules;
// this->send_all_state_updates();
// this->update_registration_phase();
// this->setup_and_start_battle();
throw runtime_error("hard reset command received");
}
void Server::handle_CAx1B_update_player_name(const string& data) {
@@ -1958,7 +1952,7 @@ void Server::handle_CAx1D_start_battle(const string& data) {
G_RejectBattleStartRequest_GC_Ep3_6xB4x53 out_cmd;
out_cmd.setup_phase = this->setup_phase;
out_cmd.registration_phase = this->registration_phase;
out_cmd.state = *this->map_and_rules1;
out_cmd.state = *this->map_and_rules;
this->send(out_cmd);
for (size_t z = 0; z < 4; z++) {
@@ -2678,7 +2672,7 @@ void Server::send_6xB4x39() const {
void Server::send_6xB4x05() {
this->compute_all_map_occupied_bits();
G_UpdateMap_GC_Ep3_6xB4x05 cmd;
cmd.state = *this->map_and_rules1;
cmd.state = *this->map_and_rules;
this->send(cmd);
}
+1 -3
View File
@@ -227,8 +227,7 @@ public:
PresenceEntry();
void clear();
} __attribute__((packed));
std::shared_ptr<MapAndRulesState> map_and_rules1;
std::shared_ptr<MapAndRulesState> map_and_rules2;
std::shared_ptr<MapAndRulesState> map_and_rules;
std::shared_ptr<DeckEntry> deck_entries[4];
parray<PresenceEntry, 4> presence_entries;
uint8_t num_clients_present;
@@ -278,7 +277,6 @@ public:
parray<uint32_t, 2> team_client_count;
parray<uint32_t, 2> team_num_ally_fcs_destroyed;
parray<uint32_t, 2> team_num_cards_destroyed;
uint32_t hard_reset_flag;
parray<uint8_t, 5> num_trap_tiles_of_type;
parray<uint8_t, 5> chosen_trap_tile_index_of_type;
parray<parray<parray<uint8_t, 2>, 8>, 5> trap_tile_locs;
+1 -1
View File
@@ -2474,7 +2474,7 @@ void send_ep3_game_details(shared_ptr<Client> c, shared_ptr<Lobby> l) {
} else if (primary_lobby &&
primary_lobby->ep3_server &&
primary_lobby->ep3_server->get_setup_phase() != Episode3::SetupPhase::REGISTRATION) {
cmd.rules = primary_lobby->ep3_server->map_and_rules1->rules;
cmd.rules = primary_lobby->ep3_server->map_and_rules->rules;
flag = 0x01;
} else {