diff --git a/README.md b/README.md index fbe8bf94..6a345bfb 100644 --- a/README.md +++ b/README.md @@ -440,7 +440,7 @@ Some commands only work on the game server and not on the proxy server. The chat * `$gc` (game server only): Send your own Guild Card to yourself. * `$sc `: Send a command to yourself. * `$ss `: Send a command to the remote server (if in a proxy session) or to the game server. - * `$sb `: Send a comamnd to yourself, and to the remote server or game server. + * `$sb `: Send a command to yourself, and to the remote server or game server. * `$meseta ` (game server only; Episode 3 only): Add the given amount to your Meseta total. * `$auction` (Episode 3 only): Bring up the CARD Auction menu, regardless of how many players are in the game or if you have a VIP card. * `$ep3battledebug` (game server only; Episode 3 only): Enable or disable TCard00_Select. If enabled, the game will enter the debug menu when you start a battle. diff --git a/src/ChatCommands.cc b/src/ChatCommands.cc index 1ff1a039..4ac7a787 100644 --- a/src/ChatCommands.cc +++ b/src/ChatCommands.cc @@ -65,6 +65,12 @@ static void check_is_ep3(shared_ptr c, bool is_ep3) { } } +static void check_debug_enabled(shared_ptr c) { + if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { + throw precondition_failed("$C6This command can only\nbe run in debug mode\n(run %sdebug first)"); + } +} + static void check_cheats_enabled(shared_ptr l, shared_ptr c) { if (!l->check_flag(Lobby::Flag::CHEATS_ENABLED) && !c->license->check_flag(License::Flag::CHEAT_ANYWHERE)) { throw precondition_failed("$C6This command can\nonly be used in\ncheat mode."); @@ -290,10 +296,7 @@ static void server_command_debug(shared_ptr c, const std::string&) { } static void server_command_quest(shared_ptr c, const std::string& args) { - if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { - send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)"); - return; - } + check_debug_enabled(c); Version effective_version = is_ep3(c->version()) ? Version::GC_V3 : c->version(); @@ -330,10 +333,7 @@ static void server_command_qcheck(shared_ptr c, const std::string& args) } static void server_command_qset_qclear(shared_ptr c, const std::string& args, bool should_set) { - if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { - send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)"); - return; - } + check_debug_enabled(c); auto l = c->require_lobby(); if (!l->is_game()) { send_text_message(c, "$C6This command cannot\nbe used in the lobby"); @@ -419,10 +419,7 @@ static void server_command_qgwrite(shared_ptr c, const std::string& args send_text_message(c, "$C6This command can\nonly be used on BB"); return; } - if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { - send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)"); - return; - } + check_debug_enabled(c); auto l = c->require_lobby(); if (!l->is_game()) { send_text_message(c, "$C6This command cannot\nbe used in the lobby"); @@ -449,10 +446,7 @@ static void server_command_qgwrite(shared_ptr c, const std::string& args } static void server_command_qsync_qsyncall(shared_ptr c, const std::string& args, bool send_to_lobby) { - if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { - send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)"); - return; - } + check_debug_enabled(c); auto l = c->require_lobby(); if (!l->is_game()) { send_text_message(c, "$C6This command cannot\nbe used in the lobby"); @@ -531,10 +525,7 @@ static void proxy_command_qsyncall(shared_ptr ses, c } static void server_command_qcall(shared_ptr c, const std::string& args) { - if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { - send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)"); - return; - } + check_debug_enabled(c); auto l = c->require_lobby(); if (l->is_game() && l->quest) { @@ -742,12 +733,14 @@ static void proxy_command_get_player_card(shared_ptr } static void server_command_send_client(shared_ptr c, const std::string& args) { + check_debug_enabled(c); string data = parse_data_string(args); data.resize((data.size() + 3) & (~3)); c->channel.send(data); } static void server_command_send_server(shared_ptr c, const std::string& args) { + check_debug_enabled(c); string data = parse_data_string(args); data.resize((data.size() + 3) & (~3)); on_command_with_header(c, data); @@ -948,10 +941,7 @@ static void server_command_playrec(shared_ptr c, const std::string& args static void server_command_meseta(shared_ptr c, const std::string& args) { check_is_ep3(c, true); - if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { - send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)"); - return; - } + check_debug_enabled(c); uint32_t amount = stoul(args, nullptr, 0); c->license->ep3_current_meseta += amount; @@ -1890,10 +1880,7 @@ static void proxy_command_item(shared_ptr ses, const } static void server_command_enable_ep3_battle_debug_menu(shared_ptr c, const std::string& args) { - if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) { - send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)"); - return; - } + check_debug_enabled(c); auto l = c->require_lobby(); check_is_game(l, true);