Implemented bot owner options

This commit is contained in:
Uleat
2018-10-09 22:04:47 -04:00
parent a836baac32
commit 43aaaf7f26
12 changed files with 124 additions and 1 deletions
+46
View File
@@ -25,6 +25,7 @@
#include "bot_database.h"
#include "bot.h"
#include "client.h"
BotDatabase botdb;
@@ -2185,6 +2186,51 @@ bool BotDatabase::SaveStopMeleeLevel(const uint32 owner_id, const uint32 bot_id,
return true;
}
bool BotDatabase::LoadOwnerOptions(Client *owner)
{
if (!owner || !owner->CharacterID())
return false;
query = StringFormat(
"SELECT `death_marquee` FROM `bot_owner_options`"
" WHERE `owner_id` = '%u'",
owner->CharacterID()
);
auto results = QueryDatabase(query);
if (!results.Success())
return false;
if (!results.RowCount()) {
query = StringFormat("REPLACE INTO `bot_owner_options` (`owner_id`) VALUES ('%u')", owner->CharacterID());
results = QueryDatabase(query);
return false;
}
auto row = results.begin();
owner->SetBotOptionDeathMarquee((atoi(row[0]) != 0));
return true;
}
bool BotDatabase::SaveOwnerOptionDeathMarquee(const uint32 owner_id, const bool flag)
{
if (!owner_id)
return false;
query = StringFormat(
"UPDATE `bot_owner_options`"
" SET `death_marquee` = '%u'"
" WHERE `owner_id` = '%u'",
(flag == true ? 1 : 0),
owner_id
);
auto results = QueryDatabase(query);
if (!results.Success())
return false;
return true;
}
/* Bot bot-group functions */
bool BotDatabase::QueryBotGroupExistence(const std::string& group_name, bool& extant_flag)