From 325f7c6efc25c63160b67ac49bf9fa9f899b0b3f Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Mon, 18 Mar 2024 10:03:37 -0700 Subject: [PATCH] add UnlockAllAreas config option --- src/ReceiveCommands.cc | 34 ++++++++++++++++++++++++++++++++++ src/ServerState.cc | 1 + src/ServerState.hh | 1 + system/config.example.json | 6 ++++++ tests/config.json | 1 + 5 files changed, 43 insertions(+) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 0cdc70c1..11daaf7a 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -4322,6 +4322,40 @@ shared_ptr create_game_generic( game->quest_flag_values = make_unique(); game->quest_flags_known = make_unique(); } + + if (s->unlock_all_areas) { + static const vector flags_ep1_v123 = {0x0017, 0x0020, 0x002A}; + static const vector flags_ep1_v4 = {0x01F9, 0x0201, 0x0207}; + static const vector flags_ep2_v123 = {0x004C, 0x004F, 0x0052}; + static const vector flags_ep2_v4 = {0x021B, 0x0225, 0x022F}; + static const vector flags_ep4_v4 = {0x02BD, 0x02BE, 0x02BF, 0x02C0, 0x02C1}; + + const vector* flags_to_enable; + switch (game->episode) { + case Episode::EP1: + flags_to_enable = is_v4(game->base_version) ? &flags_ep1_v4 : &flags_ep1_v123; + break; + case Episode::EP2: + flags_to_enable = is_v4(game->base_version) ? &flags_ep2_v4 : &flags_ep2_v123; + break; + case Episode::EP4: + flags_to_enable = &flags_ep1_v4; + break; + default: + flags_to_enable = nullptr; + } + + if (flags_to_enable) { + for (uint16_t flag_num : *flags_to_enable) { + game->quest_flag_values->set(game->difficulty, flag_num); + if (game->quest_flags_known) { + game->quest_flags_known->set(game->difficulty, flag_num); + } + } + c->config.set_flag(Client::Flag::SHOULD_SEND_ARTIFICIAL_FLAG_STATE); + } + } + game->switch_flags = make_unique(); return game; diff --git a/src/ServerState.cc b/src/ServerState.cc index 87befe6b..19641837 100644 --- a/src/ServerState.cc +++ b/src/ServerState.cc @@ -890,6 +890,7 @@ void ServerState::load_config_early() { this->allow_dc_pc_games = this->config_json->get_bool("AllowDCPCGames", true); this->allow_gc_xb_games = this->config_json->get_bool("AllowGCXBGames", true); this->enable_chat_commands = this->config_json->get_bool("EnableChatCommands", true); + this->unlock_all_areas = this->config_json->get_bool("UnlockAllAreas", false); this->version_name_colors.reset(); try { diff --git a/src/ServerState.hh b/src/ServerState.hh index d1f8b9cb..2e5ff957 100644 --- a/src/ServerState.hh +++ b/src/ServerState.hh @@ -91,6 +91,7 @@ struct ServerState : public std::enable_shared_from_this { bool allow_dc_pc_games = true; bool allow_gc_xb_games = true; bool enable_chat_commands = true; + bool unlock_all_areas = false; std::unique_ptr> version_name_colors; uint8_t allowed_drop_modes_v1_v2_normal = 0x1F; uint8_t allowed_drop_modes_v1_v2_battle = 0x07; diff --git a/system/config.example.json b/system/config.example.json index 9e005e48..83f49d46 100644 --- a/system/config.example.json +++ b/system/config.example.json @@ -957,6 +957,12 @@ // available on the proxy server. "CheatModeBehavior": "OnByDefault", + // Whether to unlock all areas by default in Ep1/2/4 games. If this is on, + // the Ragol warp in Pioneer 2 will allow access to all base areas (Forest 1, + // Cave 1, Mine 1, and Ruins 1 in Episode 1, for example) even if the player + // who created the game does not yet have access to those areas. + "UnlockAllAreas": false, + // Whether to enable rare drop notifications by default. Players can toggle // this behavior for themselves with the $itemnotifs command. "RareNotificationsEnabledByDefaultV1V2": false, diff --git a/tests/config.json b/tests/config.json index 55ce4a08..b1755710 100644 --- a/tests/config.json +++ b/tests/config.json @@ -30,6 +30,7 @@ "DefaultDropModeV4Battle": "SERVER_SHARED", "DefaultDropModeV4Challenge": "SERVER_SHARED", "CheatModeBehavior": "OnByDefault", + "UnlockAllAreas": false, "RareNotificationsEnabledByDefault": false, "LocalAddress": "en0",