From 3c32a660641532c8743a57971bd9dcb77473b62f Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sat, 11 Oct 2025 17:35:48 -0700 Subject: [PATCH] hide section ID for empty persistent games --- src/ChatCommands.cc | 9 +++-- src/HTTPServer.cc | 14 ++++++- src/Lobby.cc | 8 +++- src/Lobby.hh | 2 +- src/ReceiveCommands.cc | 5 ++- src/ReceiveSubcommands.cc | 6 ++- tests/GC-XB-CrossplayForestGame.test.txt | 48 ++++++++++-------------- 7 files changed, 53 insertions(+), 39 deletions(-) diff --git a/src/ChatCommands.cc b/src/ChatCommands.cc index 04863da0..0630a132 100644 --- a/src/ChatCommands.cc +++ b/src/ChatCommands.cc @@ -1433,11 +1433,12 @@ ChatCommandDefinition cc_lobby_info( if (l->max_level == 0xFFFFFFFF) { lines.emplace_back(std::format("$C6{:08X}$C7 L$C6{}+$C7", l->lobby_id, l->min_level + 1)); } else { - lines.emplace_back(std::format( - "$C6{:08X}$C7 L$C6{}-{}$C7", l->lobby_id, l->min_level + 1, l->max_level + 1)); + lines.emplace_back(std::format("$C6{:08X}$C7 L$C6{}-{}$C7", l->lobby_id, l->min_level + 1, l->max_level + 1)); + } + uint8_t effective_section_id = l->effective_section_id(); + if (effective_section_id < 10) { + lines.emplace_back(std::format("$C7Section ID: $C6{}$C7", name_for_section_id(effective_section_id))); } - lines.emplace_back(std::format( - "$C7Section ID: $C6{}$C7", name_for_section_id(l->effective_section_id()))); switch (l->drop_mode) { case ServerDropMode::DISABLED: diff --git a/src/HTTPServer.cc b/src/HTTPServer.cc index 671e7158..44a96da2 100644 --- a/src/HTTPServer.cc +++ b/src/HTTPServer.cc @@ -379,7 +379,12 @@ std::shared_ptr HTTPServer::generate_lobby_json( ret->emplace("QuestInProgress", l->check_flag(Lobby::Flag::QUEST_IN_PROGRESS)); ret->emplace("JoinableQuestInProgress", l->check_flag(Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS)); ret->emplace("Variations", l->variations.json()); - ret->emplace("SectionID", name_for_section_id(l->effective_section_id())); + uint8_t effective_section_id = l->effective_section_id(); + if (effective_section_id < 10) { + ret->emplace("SectionID", name_for_section_id(effective_section_id)); + } else { + ret->emplace("SectionID", nullptr); + } ret->emplace("Mode", name_for_mode(l->mode)); ret->emplace("Difficulty", name_for_difficulty(l->difficulty)); ret->emplace("BaseEXPMultiplier", l->base_exp_multiplier); @@ -634,7 +639,12 @@ std::shared_ptr HTTPServer::generate_summary_json() const { game_json.emplace("QuestSelectionInProgress", l->check_flag(Lobby::Flag::QUEST_SELECTION_IN_PROGRESS)); game_json.emplace("QuestInProgress", l->check_flag(Lobby::Flag::QUEST_IN_PROGRESS)); game_json.emplace("JoinableQuestInProgress", l->check_flag(Lobby::Flag::JOINABLE_QUEST_IN_PROGRESS)); - game_json.emplace("SectionID", name_for_section_id(l->effective_section_id())); + uint8_t effective_section_id = l->effective_section_id(); + if (effective_section_id < 10) { + game_json.emplace("SectionID", name_for_section_id(effective_section_id)); + } else { + game_json.emplace("SectionID", nullptr); + } game_json.emplace("Mode", name_for_mode(l->mode)); game_json.emplace("Difficulty", name_for_difficulty(l->difficulty)); game_json.emplace("Quest", l->quest ? l->quest->json() : phosg::JSON(nullptr)); diff --git a/src/Lobby.cc b/src/Lobby.cc index 0102d45c..06f19505 100644 --- a/src/Lobby.cc +++ b/src/Lobby.cc @@ -211,6 +211,10 @@ void Lobby::create_item_creator(Version logic_version) { } else { rand_crypt = make_shared(this->rand_crypt->seed()); } + uint8_t effective_section_id = this->effective_section_id(); + if (effective_section_id >= 10) { + effective_section_id = 0x00; + } this->item_creator = make_shared( s->common_item_set(logic_version, this->quest), s->rare_item_set(logic_version, this->quest), @@ -223,7 +227,7 @@ void Lobby::create_item_creator(Version logic_version) { this->episode, (this->mode == GameMode::SOLO) ? GameMode::NORMAL : this->mode, this->difficulty, - this->effective_section_id(), + effective_section_id, rand_crypt, this->quest ? this->quest->meta.battle_rules : nullptr); } @@ -239,7 +243,7 @@ uint8_t Lobby::effective_section_id() const { if (leader) { return leader->character_file()->disp.visual.section_id; } - return 0; + return 0xFF; } uint16_t Lobby::quest_version_flags() const { diff --git a/src/Lobby.hh b/src/Lobby.hh index 86b7d22e..4a7fbda9 100644 --- a/src/Lobby.hh +++ b/src/Lobby.hh @@ -206,7 +206,7 @@ struct Lobby : public std::enable_shared_from_this { std::shared_ptr require_server_state() const; std::shared_ptr require_challenge_params() const; void create_item_creator(Version logic_version = Version::UNKNOWN); - uint8_t effective_section_id() const; + uint8_t effective_section_id() const; // Returns 0xFF if not assigned (e.g. empty persistent game) uint16_t quest_version_flags() const; uint8_t client_extension_flags() const; void load_maps(); diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 9b2bee00..c987c07a 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -2246,7 +2246,10 @@ static asio::awaitable on_09(shared_ptr c, Channel::Message& msg) // time, send page 2 (extended info) if (info.empty()) { c->last_game_info_requested = 0; - info += std::format("Section ID: {}\n", name_for_section_id(game->effective_section_id())); + uint8_t effective_section_id = game->effective_section_id(); + if (effective_section_id < 10) { + info += std::format("Section ID: {}\n", name_for_section_id(effective_section_id)); + } if (game->max_level != 0xFFFFFFFF) { info += std::format("Req. level: {}-{}\n", game->min_level + 1, game->max_level + 1); } else if (game->min_level != 0) { diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 0a33313c..317ed2a1 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -4377,7 +4377,11 @@ static asio::awaitable on_identify_item_bb(shared_ptr c, Subcomman p->disp.stats.meseta -= 100; c->bb_identify_result = p->inventory.items[x].data; c->bb_identify_result.data1[4] &= 0x7F; - l->item_creator->apply_tekker_deltas(c->bb_identify_result, l->effective_section_id()); + uint8_t effective_section_id = l->effective_section_id(); + if (effective_section_id >= 10) { + throw std::runtime_error("effective section ID is not valid"); + } + l->item_creator->apply_tekker_deltas(c->bb_identify_result, effective_section_id); send_item_identify_result(c); } else { diff --git a/tests/GC-XB-CrossplayForestGame.test.txt b/tests/GC-XB-CrossplayForestGame.test.txt index 7f63b00b..29ffa25f 100644 --- a/tests/GC-XB-CrossplayForestGame.test.txt +++ b/tests/GC-XB-CrossplayForestGame.test.txt @@ -19562,43 +19562,35 @@ I 56583 2025-05-23 21:27:15 - [Commands] Sending to C-4 (Jess Lv.51) @ ipss:N-1: I 56583 2025-05-23 21:27:15 - [Commands] Received from C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=09 flag=00) 0000 | 09 00 0C 00 44 00 00 44 15 00 00 00 | D D I 56583 2025-05-23 21:27:15 - [Commands] Sending to C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=11 flag=00) -0000 | 11 00 64 00 00 00 00 00 00 00 00 00 53 65 63 74 | d Sect -0010 | 69 6F 6E 20 49 44 3A 20 56 69 72 69 64 69 61 0A | ion ID: Viridia -0020 | 09 43 36 43 68 65 61 74 73 20 65 6E 61 62 6C 65 | C6Cheats enable -0030 | 64 09 43 37 0A 09 43 36 50 65 72 73 69 73 74 65 | d C7 C6Persiste -0040 | 6E 63 65 20 65 6E 61 62 6C 65 64 09 43 37 0A 09 | nce enabled C7 -0050 | 43 36 50 72 69 76 61 74 65 20 64 72 6F 70 73 09 | C6Private drops -0060 | 43 37 00 00 | C7 +0000 | 11 00 50 00 00 00 00 00 00 00 00 00 09 43 36 43 | P C6C +0010 | 68 65 61 74 73 20 65 6E 61 62 6C 65 64 09 43 37 | heats enabled C7 +0020 | 0A 09 43 36 50 65 72 73 69 73 74 65 6E 63 65 20 | C6Persistence +0030 | 65 6E 61 62 6C 65 64 09 43 37 0A 09 43 36 50 72 | enabled C7 C6Pr +0040 | 69 76 61 74 65 20 64 72 6F 70 73 09 43 37 00 00 | ivate drops C7 I 56583 2025-05-23 21:27:16 - [Commands] Received from C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=09 flag=00) 0000 | 09 00 0C 00 44 00 00 44 15 00 00 00 | D D I 56583 2025-05-23 21:27:16 - [Commands] Sending to C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=11 flag=00) -0000 | 11 00 64 00 00 00 00 00 00 00 00 00 53 65 63 74 | d Sect -0010 | 69 6F 6E 20 49 44 3A 20 56 69 72 69 64 69 61 0A | ion ID: Viridia -0020 | 09 43 36 43 68 65 61 74 73 20 65 6E 61 62 6C 65 | C6Cheats enable -0030 | 64 09 43 37 0A 09 43 36 50 65 72 73 69 73 74 65 | d C7 C6Persiste -0040 | 6E 63 65 20 65 6E 61 62 6C 65 64 09 43 37 0A 09 | nce enabled C7 -0050 | 43 36 50 72 69 76 61 74 65 20 64 72 6F 70 73 09 | C6Private drops -0060 | 43 37 00 00 | C7 +0000 | 11 00 50 00 00 00 00 00 00 00 00 00 09 43 36 43 | P C6C +0010 | 68 65 61 74 73 20 65 6E 61 62 6C 65 64 09 43 37 | heats enabled C7 +0020 | 0A 09 43 36 50 65 72 73 69 73 74 65 6E 63 65 20 | C6Persistence +0030 | 65 6E 61 62 6C 65 64 09 43 37 0A 09 43 36 50 72 | enabled C7 C6Pr +0040 | 69 76 61 74 65 20 64 72 6F 70 73 09 43 37 00 00 | ivate drops C7 I 56583 2025-05-23 21:27:17 - [Commands] Received from C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=09 flag=00) 0000 | 09 00 0C 00 44 00 00 44 15 00 00 00 | D D I 56583 2025-05-23 21:27:17 - [Commands] Sending to C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=11 flag=00) -0000 | 11 00 64 00 00 00 00 00 00 00 00 00 53 65 63 74 | d Sect -0010 | 69 6F 6E 20 49 44 3A 20 56 69 72 69 64 69 61 0A | ion ID: Viridia -0020 | 09 43 36 43 68 65 61 74 73 20 65 6E 61 62 6C 65 | C6Cheats enable -0030 | 64 09 43 37 0A 09 43 36 50 65 72 73 69 73 74 65 | d C7 C6Persiste -0040 | 6E 63 65 20 65 6E 61 62 6C 65 64 09 43 37 0A 09 | nce enabled C7 -0050 | 43 36 50 72 69 76 61 74 65 20 64 72 6F 70 73 09 | C6Private drops -0060 | 43 37 00 00 | C7 +0000 | 11 00 50 00 00 00 00 00 00 00 00 00 09 43 36 43 | P C6C +0010 | 68 65 61 74 73 20 65 6E 61 62 6C 65 64 09 43 37 | heats enabled C7 +0020 | 0A 09 43 36 50 65 72 73 69 73 74 65 6E 63 65 20 | C6Persistence +0030 | 65 6E 61 62 6C 65 64 09 43 37 0A 09 43 36 50 72 | enabled C7 C6Pr +0040 | 69 76 61 74 65 20 64 72 6F 70 73 09 43 37 00 00 | ivate drops C7 I 56583 2025-05-23 21:27:18 - [Commands] Received from C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=09 flag=00) 0000 | 09 00 0C 00 44 00 00 44 15 00 00 00 | D D I 56583 2025-05-23 21:27:18 - [Commands] Sending to C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=11 flag=00) -0000 | 11 00 64 00 00 00 00 00 00 00 00 00 53 65 63 74 | d Sect -0010 | 69 6F 6E 20 49 44 3A 20 56 69 72 69 64 69 61 0A | ion ID: Viridia -0020 | 09 43 36 43 68 65 61 74 73 20 65 6E 61 62 6C 65 | C6Cheats enable -0030 | 64 09 43 37 0A 09 43 36 50 65 72 73 69 73 74 65 | d C7 C6Persiste -0040 | 6E 63 65 20 65 6E 61 62 6C 65 64 09 43 37 0A 09 | nce enabled C7 -0050 | 43 36 50 72 69 76 61 74 65 20 64 72 6F 70 73 09 | C6Private drops -0060 | 43 37 00 00 | C7 +0000 | 11 00 50 00 00 00 00 00 00 00 00 00 09 43 36 43 | P C6C +0010 | 68 65 61 74 73 20 65 6E 61 62 6C 65 64 09 43 37 | heats enabled C7 +0020 | 0A 09 43 36 50 65 72 73 69 73 74 65 6E 63 65 20 | C6Persistence +0030 | 65 6E 61 62 6C 65 64 09 43 37 0A 09 43 36 50 72 | enabled C7 C6Pr +0040 | 69 76 61 74 65 20 64 72 6F 70 73 09 43 37 00 00 | ivate drops C7 I 56583 2025-05-23 21:27:19 - [Commands] Received from C-4 (Jess Lv.51) @ ipss:N-1:127.0.0.1:49211 (version=GC_V3 command=10 flag=00) 0000 | 10 00 0C 00 44 00 00 44 15 00 00 00 | D D I 56583 2025-05-23 21:27:19 - [Lobby:00000015:FloorItems:00] Added floor item CC000000 at 264.563, 264.725 with drop number 0 with flags 00F