Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions HeavenClient/Gameplay/MapleMap/MapChars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
//////////////////////////////////////////////////////////////////////////////////
#include "MapChars.h"

#include <algorithm>
#include <cctype>

namespace ms
{
void MapChars::draw(Layer::Id layer, double viewx, double viewy, float alpha) const
Expand Down Expand Up @@ -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<const OtherChar &>(*object).get_name();

if (other.size() == name.size() && std::equal(other.begin(), other.end(), name.begin(), same))
return oid;
}

return 0;
}

std::vector<RingWearer> MapChars::ring_wearers(RingKind kind) const
{
std::vector<RingWearer> wearers;
Expand Down
3 changes: 3 additions & 0 deletions HeavenClient/Gameplay/MapleMap/MapChars.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ namespace ms

Optional<OtherChar> 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;

Expand Down
9 changes: 9 additions & 0 deletions HeavenClient/IO/UITypes/UIChatBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <cstdlib>

#include "UIGroupPicker.h"
#include "UITradingRoom.h"
#include "UINotice.h"
#include "UIWhisperPrompt.h"
#include "UIStatusBar.h"
Expand Down Expand Up @@ -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))
{
}
Expand Down
8 changes: 4 additions & 4 deletions HeavenClient/IO/UITypes/UITradingRoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.";

Expand Down
Loading