Bot Naming - View/Delete Databuckets

^bottitle
^botsuffix
^botsurname
#viewbuckets
#deletebucket
This commit is contained in:
kentai
2019-09-05 14:12:56 +10:00
parent eb4592c3ae
commit 8e1b6a23eb
9 changed files with 262 additions and 25 deletions
+27 -9
View File
@@ -163,12 +163,19 @@ bool BotDatabase::LoadQuestableSpawnCount(const uint32 owner_id, int& spawn_coun
return true;
}
bool BotDatabase::LoadBotsList(const uint32 owner_id, std::list<BotsAvailableList>& bots_list)
bool BotDatabase::LoadBotsList(const uint32 owner_id, std::list<BotsAvailableList>& bots_list, bool ByAccount)
{
if (!owner_id)
return false;
query = StringFormat("SELECT `bot_id`, `name`, `class`, `level`, `race`, `gender` FROM `bot_data` WHERE `owner_id` = '%u'", owner_id);
if (ByAccount == true)
query = StringFormat("SELECT bot_id, bd.`name`, bd.class, bd.`level`, bd.race, bd.gender, cd.`name` as owner, bd.owner_id, cd.account_id, cd.id"
" FROM bot_data as bd inner join character_data as cd on bd.owner_id = cd.id"
" WHERE cd.account_id = (select account_id from bot_data bd inner join character_data as cd on bd.owner_id = cd.id where bd.owner_id = '%u' LIMIT 1)"
" ORDER BY bd.owner_id", owner_id);
else
query = StringFormat("SELECT `bot_id`, `name`, `class`, `level`, `race`, `gender`, 'You' as owner, owner_id FROM `bot_data` WHERE `owner_id` = '%u'", owner_id);
auto results = database.QueryDatabase(query);
if (!results.Success())
return false;
@@ -186,12 +193,17 @@ bool BotDatabase::LoadBotsList(const uint32 owner_id, std::list<BotsAvailableLis
bot_name = bot_name.substr(0, 63);
if (!bot_name.empty())
strcpy(bot_entry.Name, bot_name.c_str());
memset(&bot_entry.Owner, 0, sizeof(bot_entry.Owner));
std::string bot_owner = row[6];
if (bot_owner.size() > 63)
bot_owner = bot_owner.substr(0, 63);
if (!bot_owner.empty())
strcpy(bot_entry.Owner, bot_owner.c_str());
bot_entry.Class = atoi(row[2]);
bot_entry.Level = atoi(row[3]);
bot_entry.Race = atoi(row[4]);
bot_entry.Gender = atoi(row[5]);
bot_entry.Owner_ID = atoi(row[7]);
bots_list.push_back(bot_entry);
}
@@ -266,8 +278,8 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot)
" `spells_id`,"
" `name`,"
" `last_name`,"
" `title`," /* planned use[4] */
" `suffix`," /* planned use[5] */
" `title`,"
" `suffix`,"
" `zone_id`,"
" `gender`,"
" `race`,"
@@ -364,7 +376,9 @@ bool BotDatabase::LoadBot(const uint32 bot_id, Bot*& loaded_bot)
loaded_bot = new Bot(bot_id, atoi(row[0]), atoi(row[1]), atof(row[14]), atoi(row[6]), tempNPCStruct);
if (loaded_bot) {
loaded_bot->SetShowHelm((atoi(row[43]) > 0 ? true : false));
loaded_bot->SetSurname(row[3]);//maintaining outside mob::lastname to cater to spaces
loaded_bot->SetTitle(row[4]);
loaded_bot->SetSuffix(row[5]);
uint32 bfd = atoi(row[44]);
if (bfd < 1)
bfd = 1;
@@ -573,12 +587,14 @@ bool BotDatabase::SaveBot(Bot* bot_inst)
" `corruption` = '%i',"
" `show_helm` = '%i',"
" `follow_distance` = '%i',"
" `stop_melee_level` = '%u'"
" `stop_melee_level` = '%u',"
" `title` = '%s',"
" `suffix` = '%s'"
" WHERE `bot_id` = '%u'",
bot_inst->GetBotOwnerCharacterID(),
bot_inst->GetBotSpellID(),
bot_inst->GetCleanName(),
bot_inst->GetLastName(),
bot_inst->GetSurname().c_str(),
bot_inst->GetLastZoneID(),
bot_inst->GetBaseGender(),
bot_inst->GetBaseRace(),
@@ -616,6 +632,8 @@ bool BotDatabase::SaveBot(Bot* bot_inst)
((bot_inst->GetShowHelm()) ? (1) : (0)),
bot_inst->GetFollowDistance(),
bot_inst->GetStopMeleeLevel(),
bot_inst->GetTitle().c_str(),
bot_inst->GetSuffix().c_str(),
bot_inst->GetBotID()
);
auto results = database.QueryDatabase(query);