ignore client rules in tournament matches

This commit is contained in:
Martin Michelsen
2023-09-23 09:11:22 -07:00
parent 14973f7453
commit 85897baaeb
3 changed files with 14 additions and 7 deletions
+10 -4
View File
@@ -29,14 +29,14 @@ Server::Server(shared_ptr<Lobby> lobby,
shared_ptr<const MapIndex> map_index,
uint32_t behavior_flags,
shared_ptr<PSOLFGEncryption> random_crypt,
shared_ptr<const MapIndex::MapEntry> map_if_tournament)
shared_ptr<const Tournament> tournament)
: lobby(lobby),
card_index(card_index),
map_index(map_index),
behavior_flags(behavior_flags),
random_crypt(random_crypt),
last_chosen_map(map_if_tournament),
is_tournament(!!map_if_tournament),
last_chosen_map(tournament ? tournament->get_map() : nullptr),
tournament(tournament),
tournament_match_result_sent(false),
override_environment_number(0xFF),
battle_finished(false),
@@ -1532,7 +1532,7 @@ G_SetStateFlags_GC_Ep3_6xB4x03 Server::prepare_6xB4x03() const {
cmd.state.team_dice_boost[0] = this->team_dice_boost[0];
cmd.state.team_dice_boost[1] = this->team_dice_boost[1];
cmd.state.first_team_turn = this->first_team_turn;
cmd.state.tournament_flag = this->is_tournament ? 1 : 0;
cmd.state.tournament_flag = this->tournament ? 1 : 0;
for (size_t z = 0; z < 4; z++) {
auto ps = this->player_states[z];
if (!ps) {
@@ -1939,6 +1939,12 @@ void Server::handle_CAx13_update_map_during_setup(const string& data) {
*this->map_and_rules = in_cmd.map_and_rules_state;
this->map_and_rules->rules.def_dice_range = def_dice_range;
// If this match is part of a tournament, ignore the rules sent by the
// client and use the tournament rules instead.
if (this->tournament) {
this->map_and_rules->rules = this->tournament->get_rules();
}
if (this->override_environment_number != 0xFF) {
this->map_and_rules->environment_number = this->override_environment_number;
this->override_environment_number = 0xFF;
+3 -2
View File
@@ -12,6 +12,7 @@
#include "MapState.hh"
#include "PlayerState.hh"
#include "RulerServer.hh"
#include "Tournament.hh"
struct Lobby;
@@ -63,7 +64,7 @@ public:
std::shared_ptr<const MapIndex> map_index,
uint32_t behavior_flags,
std::shared_ptr<PSOLFGEncryption> random_crypt,
std::shared_ptr<const MapIndex::MapEntry> map_if_tournament);
std::shared_ptr<const Tournament> tournament);
~Server() noexcept(false);
void init();
@@ -233,7 +234,7 @@ public:
uint32_t behavior_flags;
std::shared_ptr<PSOLFGEncryption> random_crypt;
std::shared_ptr<const MapIndex::MapEntry> last_chosen_map;
bool is_tournament;
std::shared_ptr<const Tournament> tournament;
bool tournament_match_result_sent;
uint8_t override_environment_number;
mutable std::deque<StackLogger*> logger_stack;
+1 -1
View File
@@ -1275,7 +1275,7 @@ static void on_CA_Ep3(shared_ptr<Client> c, uint16_t, uint32_t, const string& da
s->ep3_map_index,
s->ep3_behavior_flags,
l->random_crypt,
tourn ? tourn->get_map() : nullptr);
tourn);
l->ep3_server->init();
if (s->ep3_behavior_flags & Episode3::BehaviorFlag::ENABLE_STATUS_MESSAGES) {