From d107226ced48a9f43c1336dcf5ebe5c177d16d44 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sat, 2 Jul 2022 22:51:03 -0400 Subject: [PATCH] [Telnet] Add guildsay to console commands and Guild Channel to QueueMessage. (#2263) * [Telnet] Add guildsay to console commands and Guild Channel to QueueMessage. - Will allow you to send guild-specific messages from things like Discord EQ. - Add Guild support in `EQ::Net::ConsoleServerConnection::SendChannelMessage` so guild ID can be parsed out. * Fix auction ChannelMessage by adding to condition. * Update console.cpp * Update console.cpp --- common/net/console_server_connection.cpp | 53 ++++++++++++------------ world/console.cpp | 34 +++++++++++++++ world/zoneserver.cpp | 1 + 3 files changed, 61 insertions(+), 27 deletions(-) diff --git a/common/net/console_server_connection.cpp b/common/net/console_server_connection.cpp index 9e245a8f8..e53058f67 100644 --- a/common/net/console_server_connection.cpp +++ b/common/net/console_server_connection.cpp @@ -116,43 +116,42 @@ bool EQ::Net::ConsoleServerConnection::SendChannelMessage(const ServerChannelMes } switch (scm->chan_num) { - case 4: { - if (RuleB(Chat, ServerWideAuction)) { - QueueMessage(fmt::format("{0} auctions, '{1}'", scm->from, scm->message)); - break; - } else { // I think we want default action in this case? - return false; - } - } - - case 5: { - if (RuleB(Chat, ServerWideOOC)) { - QueueMessage(fmt::format("{0} says ooc, '{1}'", scm->from, scm->message)); - break; - } else { // I think we want default action in this case? - return false; - } - } - - case 6: { - QueueMessage(fmt::format("{0} BROADCASTS, '{1}'", scm->from, scm->message)); + case ChatChannel_Guild: { + QueueMessage(fmt::format("{} tells the guild [{}], '{}'", scm->from, scm->guilddbid, scm->message)); break; } - - case 7: { - QueueMessage(fmt::format("[{0}] tells you, '{1}'", scm->from, scm->message)); + case ChatChannel_Auction: { + if (RuleB(Chat, ServerWideAuction)) { + QueueMessage(fmt::format("{} auctions, '{}'", scm->from, scm->message)); + break; + } else { // I think we want default action in this case? + return false; + } + } + case ChatChannel_OOC: { + if (RuleB(Chat, ServerWideOOC)) { + QueueMessage(fmt::format("{} says ooc, '{}'", scm->from, scm->message)); + break; + } else { // I think we want default action in this case? + return false; + } + } + case ChatChannel_Broadcast: { + QueueMessage(fmt::format("{} BROADCASTS, '{}'", scm->from, scm->message)); + break; + } + case ChatChannel_Tell: { + QueueMessage(fmt::format("[{}] tells {}, '{}'", scm->from, scm->to, scm->message)); if (onTell) { onTell(); } break; } - - case 11: { - QueueMessage(fmt::format("{0} GMSAYS, '{1}'", scm->from, scm->message)); + case ChatChannel_GMSAY: { + QueueMessage(fmt::format("{} GMSAYS, '{}'", scm->from, scm->message)); break; } - default: { return false; } diff --git a/world/console.cpp b/world/console.cpp index 7afc0b073..cf57bdbfd 100644 --- a/world/console.cpp +++ b/world/console.cpp @@ -406,6 +406,39 @@ void ConsoleGMSay( zoneserver_list.SendChannelMessage(tmpname, 0, 11, 0, JoinString(args, " ").c_str()); } +/** + * @param connection + * @param command + * @param args + */ +void ConsoleGuildSay( + EQ::Net::ConsoleServerConnection *connection, + const std::string &command, + const std::vector &args +) +{ + if (args.size() < 1) { + return; + } + + auto from = args[0]; + auto guild_id = StringIsNumber(args[1]) ? std::stoul(args[1]) : 0; + if (!guild_id) { + return; + } + + auto join_args = args; + join_args.erase(join_args.begin(), join_args.begin() + 2); + + auto message = fmt::format( + "{} tells the guild, '{}'", + from, + JoinString(join_args, " ") + ); + + zoneserver_list.SendEmoteMessage(0, guild_id, AccountStatus::Player, Chat::Guild, message.c_str()); +} + /** * @param connection * @param command @@ -951,6 +984,7 @@ void RegisterConsoleFunctions(std::unique_ptr& console) console->RegisterCall("emote", 50, "emote [zonename or charname or world] [type] [message]", std::bind(ConsoleEmote, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("flag", 200, "flag [status] [accountname]", std::bind(ConsoleFlag, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("gmsay", 50, "gmsay [message]", std::bind(ConsoleGMSay, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + console->RegisterCall("guildsay", 50, "guildsay [Character Name] [Guild ID] [Message]", std::bind(ConsoleGuildSay, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("iplookup", 50, "IPLookup [name]", std::bind(ConsoleIpLookup, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("kick", 150, "kick [charname]", std::bind(ConsoleKick, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); console->RegisterCall("lock", 150, "lock", std::bind(ConsoleLock, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index 583023a68..1f1284ccf 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -527,6 +527,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) { } } else { if ( + scm->chan_num == ChatChannel_Auction || scm->chan_num == ChatChannel_OOC || scm->chan_num == ChatChannel_Broadcast || scm->chan_num == ChatChannel_GMSAY