From 253f4c07e0b889ea2fabe05bd03676f9dc4a4ae5 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Sat, 26 Nov 2022 19:28:28 -0500 Subject: [PATCH] [Commands] Cleanup #chat Command. (#2581) - Cleanup messages and logic. --- zone/command.cpp | 2 +- zone/gm_commands/chat.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index fc324042d..305eeb03d 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -108,7 +108,7 @@ int command_init(void) command_add("camerashake", "[Duration (Milliseconds)] [Intensity (1-10)] - Shakes the camera on everyone's screen globally.", AccountStatus::QuestTroupe, command_camerashake) || command_add("castspell", "[Spell ID] [Instant (0 = False, 1 = True, Default is 1 if Unused)] - Cast a spell", AccountStatus::Guide, command_castspell) || - command_add("chat", "[channel num] [message] - Send a channel message to all zones", AccountStatus::GMMgmt, command_chat) || + command_add("chat", "[Channel ID] [Message] - Send a channel message to all zones", AccountStatus::GMMgmt, command_chat) || command_add("checklos", "Check for line of sight to your target", AccountStatus::Guide, command_checklos) || command_add("copycharacter", "[source_char_name] [dest_char_name] [dest_account_name] - Copies character to destination account", AccountStatus::GMImpossible, command_copycharacter) || command_add("corpse", "Manipulate corpses, use with no arguments for help", AccountStatus::Guide, command_corpse) || diff --git a/zone/gm_commands/chat.cpp b/zone/gm_commands/chat.cpp index 4b511ec84..30bbe11d7 100755 --- a/zone/gm_commands/chat.cpp +++ b/zone/gm_commands/chat.cpp @@ -5,11 +5,16 @@ extern WorldServer worldserver; void command_chat(Client *c, const Seperator *sep) { - if (sep->arg[2][0] == 0) { - c->Message(Chat::White, "Usage: #chat [channum] [message]"); + auto arguments = sep->argnum; + if (arguments < 2 || !sep->IsNumber(1)) { + c->Message(Chat::White, "Usage: #chat [Channel ID] [Message]"); + return; } - else if (!worldserver.SendChannelMessage(0, 0, (uint8) atoi(sep->arg[1]), 0, 0, 100, sep->argplus[2])) { - c->Message(Chat::White, "Error: World server disconnected"); + + auto channel_id = static_cast(std::stoul(sep->arg[1])); + std::string message = sep->argplus[2]; + if (!worldserver.SendChannelMessage(0, 0, channel_id, 0, 0, 100, message.c_str())) { + c->Message(Chat::White, "World server is disconnected."); } }