From 0cb425b6ddc68051821dea1f650b0c4d860aac82 Mon Sep 17 00:00:00 2001 From: Uleat Date: Fri, 13 Dec 2019 20:59:10 -0500 Subject: [PATCH] Tweaked bot title and suffix code a little --- zone/bot.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++-- zone/bot_command.cpp | 19 +++-------------- 2 files changed, 51 insertions(+), 18 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 4322f150f..42adfddac 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -433,15 +433,61 @@ void Bot::SetBotSpellID(uint32 newSpellID) { } void Bot::SetSurname(std::string bot_surname) { + _surname = bot_surname.substr(0, 31); + + if (spawned) { + + auto outapp = new EQApplicationPacket(OP_GMLastName, sizeof(GMLastName_Struct)); + GMLastName_Struct* gmn = (GMLastName_Struct*)outapp->pBuffer; + + strcpy(gmn->name, GetCleanName()); + strcpy(gmn->gmname, GetCleanName()); + strcpy(gmn->lastname, GetSurname().c_str()); + gmn->unknown[0] = 1; + gmn->unknown[1] = 1; + gmn->unknown[2] = 1; + gmn->unknown[3] = 1; + + entity_list.QueueClients(this, outapp); + safe_delete(outapp); + } } void Bot::SetTitle(std::string bot_title) { - _title = bot_title.substr(0, 31); + + _title = bot_title.substr(0, 31); + + if (spawned) { + + auto outapp = new EQApplicationPacket(OP_SetTitleReply, sizeof(SetTitleReply_Struct)); + SetTitleReply_Struct* strs = (SetTitleReply_Struct*)outapp->pBuffer; + + strs->is_suffix = 0; + strn0cpy(strs->title, _title.c_str(), sizeof(strs->title)); + strs->entity_id = GetID(); + + entity_list.QueueClients(this, outapp, false); + safe_delete(outapp); + } } void Bot::SetSuffix(std::string bot_suffix) { - _suffix = bot_suffix.substr(0, 31); + + _suffix = bot_suffix.substr(0, 31); + + if (spawned) { + + auto outapp = new EQApplicationPacket(OP_SetTitleReply, sizeof(SetTitleReply_Struct)); + SetTitleReply_Struct* strs = (SetTitleReply_Struct*)outapp->pBuffer; + + strs->is_suffix = 1; + strn0cpy(strs->title, _suffix.c_str(), sizeof(strs->title)); + strs->entity_id = GetID(); + + entity_list.QueueClients(this, outapp, false); + safe_delete(outapp); + } } uint32 Bot::GetBotArcheryRange() { diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index baa4818ac..1a0c415db 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -5839,23 +5839,12 @@ void bot_subcommand_bot_surname(Client *c, const Seperator *sep) std::string bot_surname = sep->arg[1]; bot_surname = (bot_surname == "-remove") ? "" : bot_surname; std::replace(bot_surname.begin(), bot_surname.end(), '_', ' '); + my_bot->SetSurname(bot_surname); if (!database.botdb.SaveBot(my_bot)) { c->Message(Chat::Red, BotDatabase::fail::SaveBot()); - return; } else { - auto outapp = new EQApplicationPacket(OP_GMLastName, sizeof(GMLastName_Struct)); - GMLastName_Struct * gmn = (GMLastName_Struct*)outapp->pBuffer; - strcpy(gmn->name, my_bot->GetCleanName()); - strcpy(gmn->gmname, my_bot->GetCleanName()); - strcpy(gmn->lastname, my_bot->GetSurname().c_str()); - gmn->unknown[0] = 1; - gmn->unknown[1] = 1; - gmn->unknown[2] = 1; - gmn->unknown[3] = 1; - entity_list.QueueClients(my_bot->CastToClient(), outapp); - safe_delete(outapp); c->Message(Chat::Yellow, "Bot Surname Saved."); } } @@ -5878,13 +5867,12 @@ void bot_subcommand_bot_title(Client *c, const Seperator *sep) std::string bot_title = sep->arg[1]; bot_title = (bot_title == "-remove") ? "" : bot_title; std::replace(bot_title.begin(), bot_title.end(), '_', ' '); + my_bot->SetTitle(bot_title); if (!database.botdb.SaveBot(my_bot)) { c->Message(Chat::Red, BotDatabase::fail::SaveBot()); - return; } else { - my_bot->CastToClient()->SetAATitle(my_bot->GetTitle().c_str()); c->Message(Chat::Yellow, "Bot Title Saved."); } } @@ -5907,13 +5895,12 @@ void bot_subcommand_bot_suffix(Client *c, const Seperator *sep) std::string bot_suffix = sep->arg[1]; bot_suffix = (bot_suffix == "-remove") ? "" : bot_suffix; std::replace(bot_suffix.begin(), bot_suffix.end(), '_', ' '); + my_bot->SetSuffix(bot_suffix); if (!database.botdb.SaveBot(my_bot)) { c->Message(Chat::Red, BotDatabase::fail::SaveBot()); - return; } else { - my_bot->CastToClient()->SetTitleSuffix(my_bot->GetSuffix().c_str()); c->Message(Chat::Yellow, "Bot Suffix Saved."); } }