From ec4ea5db427b238f043d3dd0bbebe2be276ec5fe Mon Sep 17 00:00:00 2001 From: David Goldstein Date: Mon, 9 Nov 2026 04:27:30 -0500 Subject: [PATCH] Row 3021: /trade asks someone on the map to trade, as in v83 v83's chat bar takes /trade and /Game Trade with a name (FUN_0052fad4), the routine behind the character info's Trade button: it looks the name up among the map's other characters and sends the trade's create and invite, or says "Unable to find the character.". The admin refusal now comes before the open-dialog one, in v83's order. /CashTrade is left out: RustMS has no cash trades. --- HeavenClient/Gameplay/MapleMap/MapChars.cpp | 18 ++++++++++++++++++ HeavenClient/Gameplay/MapleMap/MapChars.h | 3 +++ HeavenClient/IO/UITypes/UIChatBar.cpp | 9 +++++++++ HeavenClient/IO/UITypes/UITradingRoom.cpp | 8 ++++---- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/HeavenClient/Gameplay/MapleMap/MapChars.cpp b/HeavenClient/Gameplay/MapleMap/MapChars.cpp index 1e409dc96..85a0685cd 100644 --- a/HeavenClient/Gameplay/MapleMap/MapChars.cpp +++ b/HeavenClient/Gameplay/MapleMap/MapChars.cpp @@ -17,6 +17,9 @@ ////////////////////////////////////////////////////////////////////////////////// #include "MapChars.h" +#include +#include + namespace ms { void MapChars::draw(Layer::Id layer, double viewx, double viewy, float alpha) const @@ -95,6 +98,21 @@ namespace ms } } + int32_t MapChars::find(const std::string &name) const + { + auto same = [](unsigned char a, unsigned char b) { return std::tolower(a) == std::tolower(b); }; + + for (auto &[oid, object] : chars) + { + std::string other = static_cast(*object).get_name(); + + if (other.size() == name.size() && std::equal(other.begin(), other.end(), name.begin(), same)) + return oid; + } + + return 0; + } + std::vector MapChars::ring_wearers(RingKind kind) const { std::vector wearers; diff --git a/HeavenClient/Gameplay/MapleMap/MapChars.h b/HeavenClient/Gameplay/MapleMap/MapChars.h index e051aeb7e..7a207f0a7 100644 --- a/HeavenClient/Gameplay/MapleMap/MapChars.h +++ b/HeavenClient/Gameplay/MapleMap/MapChars.h @@ -74,6 +74,9 @@ namespace ms Optional get_char(int32_t cid); + // The id of the character on the map with a name, ignoring case, or 0. + int32_t find(const std::string &name) const; + // Draw HP bars over the heads of the player's party members. void draw_party_hp(const Party &party, int32_t self, int32_t mapid, double viewx, double viewy, float alpha) const; diff --git a/HeavenClient/IO/UITypes/UIChatBar.cpp b/HeavenClient/IO/UITypes/UIChatBar.cpp index 0161ca41b..f5f379eec 100644 --- a/HeavenClient/IO/UITypes/UIChatBar.cpp +++ b/HeavenClient/IO/UITypes/UIChatBar.cpp @@ -22,6 +22,7 @@ #include #include "UIGroupPicker.h" +#include "UITradingRoom.h" #include "UINotice.h" #include "UIWhisperPrompt.h" #include "UIStatusBar.h" @@ -390,6 +391,14 @@ namespace ms { send_whisper(target, ""); } + // A trade with someone on the map, as from their + // character info (FUN_0052fad4). v83's /CashTrade asks + // for a cash trade, which RustMS doesn't have. + else if (parse_command_argument(msg, "/trade", target) + || parse_command_argument(msg, "/Game Trade", target)) + { + UITradingRoom::request(Stage::get().get_chars().find(target)); + } else if (PartyCommands::run(msg)) { } diff --git a/HeavenClient/IO/UITypes/UITradingRoom.cpp b/HeavenClient/IO/UITypes/UITradingRoom.cpp index a6d541d6b..2c8bef56a 100644 --- a/HeavenClient/IO/UITypes/UITradingRoom.cpp +++ b/HeavenClient/IO/UITypes/UITradingRoom.cpp @@ -410,11 +410,11 @@ namespace ms const char *refusal = nullptr; - // Nor while a dialog is open, nor from a GM's account. - if (UI::get().dialog_open()) - refusal = "Not available"; - else if (Configuration::get().get_grade().gm()) + // Nor from a GM's account, nor while a dialog is open. + if (Configuration::get().get_grade().gm()) refusal = account_grade::NOT_FOR_ADMIN; + else if (UI::get().dialog_open()) + refusal = "Not available"; else if (Stage::get().is_player(cid) || !Stage::get().get_character(cid)) refusal = "Unable to find the character.";