fix results screen for final tournament match

This commit is contained in:
Martin Michelsen
2022-12-08 17:30:24 -08:00
parent 93f42a9398
commit 5f04cbaecb
5 changed files with 24 additions and 9 deletions
+7 -5
View File
@@ -5496,11 +5496,13 @@ struct G_TournamentMatchResult_GC_Ep3_6xB4x51 {
parray<ptext<char, 0x10>, 2> player_names;
} __packed__;
parray<NamesEntry, 2> names_entries;
struct ResultEntry {
le_uint16_t num_players;
le_uint16_t is_winner_team;
} __packed__;
parray<ResultEntry, 2> result_entries;
le_uint16_t unused1 = 0;
// If round_num is equal to 6, the "On to the next battle..." text is replaced
// with "Congratulations!" and some flashier graphics. This is used for the
// final match.
le_uint16_t round_num = 0;
le_uint16_t num_players_per_team = 0;
le_uint16_t winner_team_id = 0;
le_uint32_t meseta_amount = 0;
// This field apparently is supposed to contain a %s token (as for printf)
// that is replaced with meseta_amount.
+2
View File
@@ -145,6 +145,8 @@ shared_ptr<const ServerBase> Server::base() const {
}
int8_t Server::get_winner_team_id() const {
// Note: This function is not part of the original implementation.
parray<size_t, 2> team_player_counts(0);
parray<size_t, 2> team_win_flag_counts(0);
for (size_t client_id = 0; client_id < 4; client_id++) {
+4
View File
@@ -345,6 +345,10 @@ shared_ptr<Tournament::Match> Tournament::next_match_for_team(
return nullptr;
}
shared_ptr<Tournament::Match> Tournament::get_final_match() const {
return this->final_match;
}
void Tournament::start() {
if (this->current_state != State::REGISTRATION) {
throw runtime_error("tournament has already started");
+1
View File
@@ -104,6 +104,7 @@ public:
std::shared_ptr<Team> get_team(size_t index) const;
std::shared_ptr<Team> get_winner_team() const;
std::shared_ptr<Match> next_match_for_team(std::shared_ptr<Team> team) const;
std::shared_ptr<Match> get_final_match() const;
void start();
void print_bracket(FILE* stream) const;
+10 -4
View File
@@ -2108,6 +2108,11 @@ void send_ep3_tournament_match_result(
return;
}
if ((match->winner_team != match->preceding_a->winner_team) &&
(match->winner_team != match->preceding_b->winner_team)) {
throw logic_error("cannot send tournament result without valid winner team");
}
unordered_map<uint32_t, shared_ptr<Client>> serial_number_to_client;
for (auto client : l->clients) {
if (client) {
@@ -2133,10 +2138,11 @@ void send_ep3_tournament_match_result(
write_player_names(cmd.names_entries[0], match->preceding_a->winner_team);
cmd.names_entries[1].team_name = match->preceding_b->winner_team->name;
write_player_names(cmd.names_entries[1], match->preceding_b->winner_team);
cmd.result_entries[0].num_players = match->preceding_a->winner_team->max_players;
cmd.result_entries[0].is_winner_team = (match->preceding_a->winner_team == match->winner_team);
cmd.result_entries[1].num_players = match->preceding_a->winner_team->max_players;
cmd.result_entries[1].is_winner_team = (match->preceding_b->winner_team == match->winner_team);
// The value 6 here causes the client to show the "Congratulations" text
// instead of "On to the next round"
cmd.round_num = (match == tourn->get_final_match()) ? 6 : match->round_num;
cmd.num_players_per_team = match->preceding_a->winner_team->max_players;
cmd.winner_team_id = (match->preceding_b->winner_team == match->winner_team);
// TODO: This amount should vary depending on the match level / round number,
// but newserv doesn't currently implement meseta at all - we just always give
// the player 1000000 and never charge for anything.