From 24656d587b45d0c9cc4c20a8c55951f5cb2ef0b9 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sun, 16 Jun 2024 11:03:44 -0700 Subject: [PATCH] make $where show other players' floors --- src/ChatCommands.cc | 11 ++++++++++- src/StaticGameData.cc | 22 ++++++++++++++++++++++ src/StaticGameData.hh | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/ChatCommands.cc b/src/ChatCommands.cc index 6729f751..f314f328 100644 --- a/src/ChatCommands.cc +++ b/src/ChatCommands.cc @@ -1827,7 +1827,16 @@ static void proxy_command_next(shared_ptr ses, const } static void server_command_where(shared_ptr c, const std::string&) { - send_text_message_printf(c, "$C7Floor: %02" PRIX32 "\nX: %g\nZ: %g", c->floor, c->x, c->z); + auto l = c->require_lobby(); + send_text_message_printf(c, "$C7%01" PRIX32 ":%s X:%" PRId32 " Z:%" PRId32, + c->floor, short_name_for_floor(l->episode, c->floor), static_cast(c->x), static_cast(c->z)); + for (auto lc : l->clients) { + if (lc && (lc != c)) { + string name = lc->character()->disp.name.decode(lc->language()); + send_text_message_printf(c, "$C6%s$C7 %01" PRIX32 ":%s", + name.c_str(), lc->floor, short_name_for_floor(l->episode, lc->floor)); + } + } } static void server_command_what(shared_ptr c, const std::string&) { diff --git a/src/StaticGameData.cc b/src/StaticGameData.cc index 601fd027..a981523a 100644 --- a/src/StaticGameData.cc +++ b/src/StaticGameData.cc @@ -749,6 +749,15 @@ static const array ep4_floor_names = { "Purgatory", }; +static const array ep1_floor_names_short = { + "P2", "F1", "F2", "C1", "C2", "C3", "M1", "M2", "R1", "R2", "R3", "Dgn", "DRL", "VO", "DF", "Lby", "B1", "B2"}; + +static const array ep2_floor_names_short = { + "Lab", "VRTA", "VRTB", "VRSA", "VRSB", "CCA", "JN", "JE", "Mtn", "SS", "SU", "SL", "GG", "OF", "BR", "GD", "SSN", "Twr"}; + +static const array ep4_floor_names_short = { + "P2", "CE", "CW", "CS", "CN", "CI", "D1", "D2", "D3", "SM", "Pg"}; + size_t floor_limit_for_episode(Episode ep) { switch (ep) { case Episode::EP1: @@ -775,6 +784,19 @@ const char* name_for_floor(Episode episode, uint8_t floor) { } } +const char* short_name_for_floor(Episode episode, uint8_t floor) { + switch (episode) { + case Episode::EP1: + return ep1_floor_names_short.at(floor); + case Episode::EP2: + return ep2_floor_names_short.at(floor); + case Episode::EP4: + return ep4_floor_names_short.at(floor); + default: + throw logic_error("invalid episode for floor"); + } +} + bool floor_is_boss_arena(Episode episode, uint8_t floor) { switch (episode) { case Episode::EP1: diff --git a/src/StaticGameData.hh b/src/StaticGameData.hh index d9124578..44524ac8 100644 --- a/src/StaticGameData.hh +++ b/src/StaticGameData.hh @@ -76,6 +76,7 @@ extern const std::unordered_map mag_color_for_name; size_t floor_limit_for_episode(Episode ep); uint8_t floor_for_name(const std::string& name); const char* name_for_floor(Episode episode, uint8_t floor); +const char* short_name_for_floor(Episode episode, uint8_t floor); bool floor_is_boss_arena(Episode episode, uint8_t floor); uint32_t class_flags_for_class(uint8_t char_class);