factor out debug mode check
This commit is contained in:
@@ -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.
|
* `$gc` (game server only): Send your own Guild Card to yourself.
|
||||||
* `$sc <data>`: Send a command to yourself.
|
* `$sc <data>`: Send a command to yourself.
|
||||||
* `$ss <data>`: Send a command to the remote server (if in a proxy session) or to the game server.
|
* `$ss <data>`: Send a command to the remote server (if in a proxy session) or to the game server.
|
||||||
* `$sb <data>`: Send a comamnd to yourself, and to the remote server or game server.
|
* `$sb <data>`: Send a command to yourself, and to the remote server or game server.
|
||||||
* `$meseta <amount>` (game server only; Episode 3 only): Add the given amount to your Meseta total.
|
* `$meseta <amount>` (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.
|
* `$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.
|
* `$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.
|
||||||
|
|||||||
+15
-28
@@ -65,6 +65,12 @@ static void check_is_ep3(shared_ptr<Client> c, bool is_ep3) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void check_debug_enabled(shared_ptr<Client> 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<Lobby> l, shared_ptr<Client> c) {
|
static void check_cheats_enabled(shared_ptr<Lobby> l, shared_ptr<Client> c) {
|
||||||
if (!l->check_flag(Lobby::Flag::CHEATS_ENABLED) && !c->license->check_flag(License::Flag::CHEAT_ANYWHERE)) {
|
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.");
|
throw precondition_failed("$C6This command can\nonly be used in\ncheat mode.");
|
||||||
@@ -290,10 +296,7 @@ static void server_command_debug(shared_ptr<Client> c, const std::string&) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void server_command_quest(shared_ptr<Client> c, const std::string& args) {
|
static void server_command_quest(shared_ptr<Client> c, const std::string& args) {
|
||||||
if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
check_debug_enabled(c);
|
||||||
send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Version effective_version = is_ep3(c->version()) ? Version::GC_V3 : c->version();
|
Version effective_version = is_ep3(c->version()) ? Version::GC_V3 : c->version();
|
||||||
|
|
||||||
@@ -330,10 +333,7 @@ static void server_command_qcheck(shared_ptr<Client> c, const std::string& args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void server_command_qset_qclear(shared_ptr<Client> c, const std::string& args, bool should_set) {
|
static void server_command_qset_qclear(shared_ptr<Client> c, const std::string& args, bool should_set) {
|
||||||
if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
check_debug_enabled(c);
|
||||||
send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto l = c->require_lobby();
|
auto l = c->require_lobby();
|
||||||
if (!l->is_game()) {
|
if (!l->is_game()) {
|
||||||
send_text_message(c, "$C6This command cannot\nbe used in the lobby");
|
send_text_message(c, "$C6This command cannot\nbe used in the lobby");
|
||||||
@@ -419,10 +419,7 @@ static void server_command_qgwrite(shared_ptr<Client> c, const std::string& args
|
|||||||
send_text_message(c, "$C6This command can\nonly be used on BB");
|
send_text_message(c, "$C6This command can\nonly be used on BB");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
check_debug_enabled(c);
|
||||||
send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto l = c->require_lobby();
|
auto l = c->require_lobby();
|
||||||
if (!l->is_game()) {
|
if (!l->is_game()) {
|
||||||
send_text_message(c, "$C6This command cannot\nbe used in the lobby");
|
send_text_message(c, "$C6This command cannot\nbe used in the lobby");
|
||||||
@@ -449,10 +446,7 @@ static void server_command_qgwrite(shared_ptr<Client> c, const std::string& args
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void server_command_qsync_qsyncall(shared_ptr<Client> c, const std::string& args, bool send_to_lobby) {
|
static void server_command_qsync_qsyncall(shared_ptr<Client> c, const std::string& args, bool send_to_lobby) {
|
||||||
if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
check_debug_enabled(c);
|
||||||
send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
auto l = c->require_lobby();
|
auto l = c->require_lobby();
|
||||||
if (!l->is_game()) {
|
if (!l->is_game()) {
|
||||||
send_text_message(c, "$C6This command cannot\nbe used in the lobby");
|
send_text_message(c, "$C6This command cannot\nbe used in the lobby");
|
||||||
@@ -531,10 +525,7 @@ static void proxy_command_qsyncall(shared_ptr<ProxyServer::LinkedSession> ses, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void server_command_qcall(shared_ptr<Client> c, const std::string& args) {
|
static void server_command_qcall(shared_ptr<Client> c, const std::string& args) {
|
||||||
if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
check_debug_enabled(c);
|
||||||
send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto l = c->require_lobby();
|
auto l = c->require_lobby();
|
||||||
if (l->is_game() && l->quest) {
|
if (l->is_game() && l->quest) {
|
||||||
@@ -742,12 +733,14 @@ static void proxy_command_get_player_card(shared_ptr<ProxyServer::LinkedSession>
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void server_command_send_client(shared_ptr<Client> c, const std::string& args) {
|
static void server_command_send_client(shared_ptr<Client> c, const std::string& args) {
|
||||||
|
check_debug_enabled(c);
|
||||||
string data = parse_data_string(args);
|
string data = parse_data_string(args);
|
||||||
data.resize((data.size() + 3) & (~3));
|
data.resize((data.size() + 3) & (~3));
|
||||||
c->channel.send(data);
|
c->channel.send(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void server_command_send_server(shared_ptr<Client> c, const std::string& args) {
|
static void server_command_send_server(shared_ptr<Client> c, const std::string& args) {
|
||||||
|
check_debug_enabled(c);
|
||||||
string data = parse_data_string(args);
|
string data = parse_data_string(args);
|
||||||
data.resize((data.size() + 3) & (~3));
|
data.resize((data.size() + 3) & (~3));
|
||||||
on_command_with_header(c, data);
|
on_command_with_header(c, data);
|
||||||
@@ -948,10 +941,7 @@ static void server_command_playrec(shared_ptr<Client> c, const std::string& args
|
|||||||
|
|
||||||
static void server_command_meseta(shared_ptr<Client> c, const std::string& args) {
|
static void server_command_meseta(shared_ptr<Client> c, const std::string& args) {
|
||||||
check_is_ep3(c, true);
|
check_is_ep3(c, true);
|
||||||
if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
check_debug_enabled(c);
|
||||||
send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t amount = stoul(args, nullptr, 0);
|
uint32_t amount = stoul(args, nullptr, 0);
|
||||||
c->license->ep3_current_meseta += amount;
|
c->license->ep3_current_meseta += amount;
|
||||||
@@ -1890,10 +1880,7 @@ static void proxy_command_item(shared_ptr<ProxyServer::LinkedSession> ses, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void server_command_enable_ep3_battle_debug_menu(shared_ptr<Client> c, const std::string& args) {
|
static void server_command_enable_ep3_battle_debug_menu(shared_ptr<Client> c, const std::string& args) {
|
||||||
if (!c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
check_debug_enabled(c);
|
||||||
send_text_message(c, "$C6This command can only\nbe run in debug mode\n(run %sdebug first)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto l = c->require_lobby();
|
auto l = c->require_lobby();
|
||||||
check_is_game(l, true);
|
check_is_game(l, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user