From 93f42a9398125ed657a2d8206881407b3d0b57ce Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Thu, 8 Dec 2022 17:32:33 -0800 Subject: [PATCH] automatically delete tournaments when complete --- src/ReceiveCommands.cc | 7 ++++++- src/SendCommands.cc | 2 +- src/SendCommands.hh | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index bf0b78ab..f3a6025d 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -1058,7 +1058,12 @@ static void on_ep3_server_data_request(shared_ptr s, shared_ptrtournament_match); + send_ep3_tournament_match_result(l, l->tournament_match); + + auto tourn = l->tournament_match->tournament.lock(); + if (tourn && (tourn->get_state() == Episode3::Tournament::State::COMPLETE)) { + s->ep3_tournament_index->delete_tournament(tourn->get_number()); + } } } diff --git a/src/SendCommands.cc b/src/SendCommands.cc index 6d38cb34..baff325e 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -2101,7 +2101,7 @@ void send_ep3_set_tournament_player_decks( // TODO: Handle disconnection during the match (the other team should win) } -void send_ep3_tournament_match_result_result( +void send_ep3_tournament_match_result( shared_ptr l, shared_ptr match) { auto tourn = match->tournament.lock(); if (!tourn) { diff --git a/src/SendCommands.hh b/src/SendCommands.hh index 910396df..7993a950 100644 --- a/src/SendCommands.hh +++ b/src/SendCommands.hh @@ -322,7 +322,7 @@ void send_ep3_set_tournament_player_decks( std::shared_ptr l, std::shared_ptr c, std::shared_ptr match); -void send_ep3_tournament_match_result_result( +void send_ep3_tournament_match_result( std::shared_ptr l, std::shared_ptr match);