send tournament result before battle end command
This commit is contained in:
@@ -61,6 +61,7 @@ void ServerBase::recreate_server() {
|
||||
|
||||
Server::Server(shared_ptr<ServerBase> base)
|
||||
: w_base(base),
|
||||
tournament_match_result_sent(false),
|
||||
battle_finished(false),
|
||||
battle_in_progress(false),
|
||||
round_num(1),
|
||||
|
||||
@@ -242,6 +242,8 @@ private:
|
||||
std::weak_ptr<ServerBase> w_base;
|
||||
|
||||
public:
|
||||
bool tournament_match_result_sent; // Not part of original implementation
|
||||
|
||||
uint32_t battle_finished;
|
||||
uint32_t battle_in_progress;
|
||||
uint32_t round_num;
|
||||
|
||||
@@ -1325,10 +1325,12 @@ static void on_CA_Ep3(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
}
|
||||
}
|
||||
l->ep3_server_base->server->on_server_data_input(data);
|
||||
if (l->ep3_server_base->server->battle_finished && l->tournament_match) {
|
||||
if (l->tournament_match &&
|
||||
l->ep3_server_base->server->setup_phase == Episode3::SetupPhase::BATTLE_ENDED &&
|
||||
!l->ep3_server_base->server->tournament_match_result_sent) {
|
||||
int8_t winner_team_id = l->ep3_server_base->server->get_winner_team_id();
|
||||
if (winner_team_id == -1) {
|
||||
throw runtime_error("match concluded, but winner team not specified");
|
||||
throw runtime_error("match complete, but winner team not specified");
|
||||
}
|
||||
|
||||
auto tourn = l->tournament_match->tournament.lock();
|
||||
@@ -1344,6 +1346,7 @@ static void on_CA_Ep3(shared_ptr<ServerState> s, shared_ptr<Client> c,
|
||||
send_ep3_tournament_match_result(l, l->tournament_match);
|
||||
|
||||
on_tournament_bracket_updated(s, tourn);
|
||||
l->ep3_server_base->server->tournament_match_result_sent = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2299,6 +2299,12 @@ void send_ep3_tournament_match_result(
|
||||
set_mask_for_ep3_game_command(&cmd, sizeof(cmd), mask_key);
|
||||
}
|
||||
send_command_t(l, 0xC9, 0x00, cmd);
|
||||
|
||||
if (tourn->get_data_index()->behavior_flags & Episode3::BehaviorFlag::ENABLE_STATUS_MESSAGES) {
|
||||
send_text_message_printf(l, "$C5TOURN/%02hhX/%zu WIN %c",
|
||||
tourn->get_number(), match->round_num,
|
||||
match->winner_team == match->preceding_a->winner_team ? 'A' : 'B');
|
||||
}
|
||||
}
|
||||
|
||||
void send_ep3_update_spectator_count(shared_ptr<Lobby> l) {
|
||||
|
||||
Reference in New Issue
Block a user