mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-22 03:18:22 +00:00
[Commands] Cleanup #emote Command. (#2535)
* [Commands] Cleanup #emote Command. - Cleanup messages and logic. - Allow `^` separator to send multiple messages by name, world, or zone. * Update emote.cpp
This commit is contained in:
+37
-25
@@ -5,41 +5,53 @@ extern WorldServer worldserver;
|
||||
|
||||
void command_emote(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (sep->arg[3][0] == 0) {
|
||||
c->Message(Chat::White, "Usage: #emote [name | world | zone] type# message");
|
||||
auto arguments = sep->argnum;
|
||||
if (arguments < 3 || !sep->IsNumber(2)) {
|
||||
c->Message(Chat::White, "Usage: #emote [Name] [Type] [Message]");
|
||||
c->Message(Chat::White, "Usage: #emote world [Type] [Message]");
|
||||
c->Message(Chat::White, "Usage: #emote zone [Type] [Message]");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (strcasecmp(sep->arg[1], "zone") == 0) {
|
||||
char *newmessage = 0;
|
||||
if (strstr(sep->arg[3], "^") == 0) {
|
||||
entity_list.Message(0, atoi(sep->arg[2]), sep->argplus[3]);
|
||||
}
|
||||
else {
|
||||
for (newmessage = strtok((char *) sep->arg[3], "^");
|
||||
newmessage != nullptr;
|
||||
newmessage = strtok(nullptr, "^"))
|
||||
entity_list.Message(0, atoi(sep->arg[2]), newmessage);
|
||||
}
|
||||
|
||||
if (!worldserver.Connected()) {
|
||||
c->Message(Chat::White, "Error: World server disconnected!");
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_world = !strcasecmp(sep->arg[1], "world");
|
||||
bool is_zone = !strcasecmp(sep->arg[1], "zone");
|
||||
|
||||
const std::string emote_message = sep->argplus[3];
|
||||
const auto emote_type = std::stoul(sep->arg[2]);
|
||||
|
||||
if (is_zone) {
|
||||
if (!Strings::Contains(emote_message, "^")) {
|
||||
entity_list.Message(0, emote_type, emote_message.c_str());
|
||||
return;
|
||||
}
|
||||
else if (!worldserver.Connected()) {
|
||||
c->Message(Chat::White, "Error: World server disconnected");
|
||||
|
||||
for (const auto& m : Strings::Split(emote_message, "^")) {
|
||||
entity_list.Message(0, emote_type, m.c_str());
|
||||
}
|
||||
else if (!strcasecmp(sep->arg[1], "world")) {
|
||||
} else {
|
||||
if (!Strings::Contains(emote_message, "^")) {
|
||||
worldserver.SendEmoteMessage(
|
||||
is_world ? 0 : sep->arg[1],
|
||||
0,
|
||||
0,
|
||||
atoi(sep->arg[2]),
|
||||
sep->argplus[3]
|
||||
emote_type,
|
||||
emote_message.c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
||||
for (const auto& m : Strings::Split(emote_message, "^")) {
|
||||
worldserver.SendEmoteMessage(
|
||||
sep->arg[1],
|
||||
is_world ? 0 : sep->arg[1],
|
||||
0,
|
||||
atoi(sep->arg[2]),
|
||||
sep->argplus[3]
|
||||
emote_type,
|
||||
m.c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user