From 5a1880bd65670d250be47d57dfbdb0c7a45be8d2 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sat, 23 Mar 2024 21:01:31 -0700 Subject: [PATCH] allow sender_c to be null in Ep3 server command handlers --- src/Episode3/Server.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Episode3/Server.cc b/src/Episode3/Server.cc index b03c01c2..bbd8505e 100644 --- a/src/Episode3/Server.cc +++ b/src/Episode3/Server.cc @@ -1842,7 +1842,7 @@ void Server::on_server_data_input(shared_ptr sender_c, const string& dat l->battle_record->add_command(BattleRecord::Event::Type::SERVER_DATA_COMMAND, data.data(), data.size()); } - if ((sender_c->version() == Version::GC_EP3_NTE) || !header.mask_key) { + if ((sender_c && (sender_c->version() == Version::GC_EP3_NTE)) || !header.mask_key) { (this->*handler)(sender_c, data); } else { string unmasked_data = data; @@ -2172,7 +2172,8 @@ void Server::handle_CAx13_update_map_during_setup_t(shared_ptr c, const // in the case of NTE, no values at all, since the Rules structure is // smaller). So, use the values from the last chosen map if applicable, or // the values from the $dicerange command if available. - const Rules* map_rules = this->last_chosen_map ? &this->last_chosen_map->version(c->language())->map->default_rules : nullptr; + uint8_t language = c ? c->language() : 1; + const Rules* map_rules = this->last_chosen_map ? &this->last_chosen_map->version(language)->map->default_rules : nullptr; auto& server_rules = this->map_and_rules->rules; // NTE can specify the DEF dice value range in its Rules struct, so we use // that unless the map or $dicerange overrides it. @@ -2559,8 +2560,7 @@ void Server::handle_CAx3A_time_limit_expired(shared_ptr, const string& d void Server::handle_CAx40_map_list_request(shared_ptr sender_c, const string& data) { const auto& in_cmd = check_size_t(data); - this->send_debug_command_received_message( - in_cmd.header.subsubcommand, "MAP LIST"); + this->send_debug_command_received_message(in_cmd.header.subsubcommand, "MAP LIST"); auto l = this->lobby.lock(); if (!l) {