From e6a6e862db947168badc04a0583c24a805322bc8 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 3 Nov 2024 22:51:07 -0800 Subject: [PATCH] add $battle command for dcv1 --- README.md | 1 + TODO.md | 1 - src/ChatCommands.cc | 16 ++++++++++++++++ src/Client.hh | 3 ++- src/ReceiveCommands.cc | 3 ++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b9ff4593..05070c23 100644 --- a/README.md +++ b/README.md @@ -569,6 +569,7 @@ Some commands only work on the game server and not on the proxy server. The chat * Personal state commands * `$arrow `: Change your lobby arrow color. * `$secid `: Set your override section ID. After running this command, any games you create will use your override section ID for rare drops instead of your character's actual section ID. If you're in a game and you are the leader of the game, this also immediately changes the item tables used by the server when creating items. To revert to your actual section id, run `$secid` with no name after it. On the proxy server, this will not work if the remote server controls item drops (e.g. on BB, or on Schtserv with server drops enabled). If the server does not allow cheat mode anywhere (that is, "CheatModeBehavior" is "Off" in config.json), this command does nothing. + * `$battle` (game server only; DC v1 only): After using this command, the next game you create will be in battle mode. (A chat command is required for this because DCv1 doesn't allow this natively.) On DCv1, the battle quests are not available, but free-roam is. * `$rand `: Set your override random seed (specified as a 32-bit hex value). This will make any games you create use the given seed for rare enemies. This also makes item drops deterministic in Blue Burst games hosted by newserv. On the proxy server, this command can cause desyncs with other players in the same game, since they will not see the overridden random seed. To remove the override, run `$rand` with no arguments. If the server does not allow cheat mode anywhere (that is, "CheatModeBehavior" is "Off" in config.json), this command does nothing. * `$ln [name-or-type]`: Set the lobby number. Visible only to you. This command exists because some non-lobby maps can be loaded as lobbies with invalid lobby numbers. See the "GC lobby types" and "Ep3 lobby types" entries in the information menu for acceptable values here. Note that non-lobby maps do not have a lobby counter, so there's no way to exit the lobby without using either `$ln` again or `$exit`. On the game server, `$ln` reloads the lobby immediately; on the proxy server, it doesn't take effect until you load another lobby yourself (which means you'll like have to use `$exit` to escape). Run this command with no argument to return to the default lobby. * `$swa`: Enable or disable switch assist. When enabled, the server will unlock two-player and four-player doors in non-quest games when you step on any of the required switches. diff --git a/TODO.md b/TODO.md index 515dc85a..91da148b 100644 --- a/TODO.md +++ b/TODO.md @@ -8,7 +8,6 @@ ## PSO DC - Investigate if https://crates.io/crates/blaze-ssl-async can be used to implement the HL check server -- Does DCv1 support battle mode? The flag exists on the client; try this out ## Episode 3 diff --git a/src/ChatCommands.cc b/src/ChatCommands.cc index 3ea11cac..b2d2a6d2 100644 --- a/src/ChatCommands.cc +++ b/src/ChatCommands.cc @@ -2293,6 +2293,21 @@ static void proxy_command_item(shared_ptr ses, const } } +static void server_command_enable_battle_mode_v1(shared_ptr c, const std::string&) { + check_is_game(c->require_lobby(), false); + if (!is_v1(c->version())) { + send_text_message(c, "$C6This command can\nonly be used on\nDC v1 and earlier"); + return; + } + + c->config.toggle_flag(Client::Flag::FORCE_BATTLE_MODE_GAME); + if (c->config.check_flag(Client::Flag::FORCE_BATTLE_MODE_GAME)) { + send_text_message(c, "$C6Battle mode enabled\nfor next game"); + } else { + send_text_message(c, "$C6Battle mode disabled\nfor next game"); + } +} + static void server_command_enable_ep3_battle_debug_menu(shared_ptr c, const std::string& args) { check_debug_enabled(c); @@ -2625,6 +2640,7 @@ static const unordered_map chat_commands({ {"$ax", {server_command_ax, nullptr}}, {"$ban", {server_command_ban, nullptr}}, {"$bank", {server_command_change_bank, nullptr}}, + {"$battle", {server_command_enable_battle_mode_v1, nullptr}}, {"$bbchar", {server_command_bbchar, nullptr}}, {"$cheat", {server_command_cheat, nullptr}}, {"$debug", {server_command_debug, nullptr}}, diff --git a/src/Client.hh b/src/Client.hh index 77ad3a8b..5b53e3fa 100644 --- a/src/Client.hh +++ b/src/Client.hh @@ -35,7 +35,7 @@ public: // TODO: It'd be nice to use a pattern here (e.g. all server-side flags are // in the high bits) but that would require re-recording or manually // rewriting all the tests - CLIENT_SIDE_MASK = 0xFF3CFFFF7C0BFFFB, + CLIENT_SIDE_MASK = 0xF73CFFFF7C0BFFFB, // Version-related flags CHECKED_FOR_DC_V1_PROTOTYPE = 0x0000000000000002, @@ -80,6 +80,7 @@ public: DEBUG_ENABLED = 0x0000000800000000, ITEM_DROP_NOTIFICATIONS_1 = 0x0010000000000000, ITEM_DROP_NOTIFICATIONS_2 = 0x0020000000000000, + FORCE_BATTLE_MODE_GAME = 0x0800000000000000, // Proxy option flags PROXY_SAVE_FILES = 0x0000001000000000, diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 59602e0f..9977bd31 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -4570,8 +4570,9 @@ static void on_0C_C1_E7_EC(shared_ptr c, uint16_t command, uint32_t, str GameMode mode = GameMode::NORMAL; bool spectators_forbidden = false; - if (cmd.battle_mode) { + if (cmd.battle_mode || c->config.check_flag(Client::Flag::FORCE_BATTLE_MODE_GAME)) { mode = GameMode::BATTLE; + c->config.clear_flag(Client::Flag::FORCE_BATTLE_MODE_GAME); } if (cmd.challenge_mode) { if (client_is_ep3) {