mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-21 18:58:21 +00:00
Change char_id to character_id for bot_settings
This commit is contained in:
@@ -171,7 +171,7 @@ CHANGE COLUMN `spellid` `spell_id` smallint(5) UNSIGNED NOT NULL DEFAULT 0 AFTER
|
|||||||
.match = "",
|
.match = "",
|
||||||
.sql = R"(
|
.sql = R"(
|
||||||
CREATE TABLE `bot_settings` (
|
CREATE TABLE `bot_settings` (
|
||||||
`char_id` INT(10) UNSIGNED NOT NULL,
|
`character_id` INT(10) UNSIGNED NOT NULL,
|
||||||
`bot_id` INT(10) UNSIGNED NOT NULL,
|
`bot_id` INT(10) UNSIGNED NOT NULL,
|
||||||
`stance` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
`stance` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
`setting_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
|
`setting_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0',
|
||||||
@@ -179,7 +179,7 @@ CREATE TABLE `bot_settings` (
|
|||||||
`value` INT(10) UNSIGNED NOT NULL,
|
`value` INT(10) UNSIGNED NOT NULL,
|
||||||
`category_name` VARCHAR(64) NULL DEFAULT '' COLLATE 'utf8mb4_general_ci',
|
`category_name` VARCHAR(64) NULL DEFAULT '' COLLATE 'utf8mb4_general_ci',
|
||||||
`setting_name` VARCHAR(64) NULL DEFAULT '' COLLATE 'utf8mb4_general_ci',
|
`setting_name` VARCHAR(64) NULL DEFAULT '' COLLATE 'utf8mb4_general_ci',
|
||||||
PRIMARY KEY (`char_id`, `bot_id`, `stance`, `setting_id`, `setting_type`) USING BTREE
|
PRIMARY KEY (`character_id`, `bot_id`, `stance`, `setting_id`, `setting_type`) USING BTREE
|
||||||
)
|
)
|
||||||
COLLATE='utf8mb4_general_ci'
|
COLLATE='utf8mb4_general_ci'
|
||||||
ENGINE=InnoDB
|
ENGINE=InnoDB
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
class BaseBotSettingsRepository {
|
class BaseBotSettingsRepository {
|
||||||
public:
|
public:
|
||||||
struct BotSettings {
|
struct BotSettings {
|
||||||
uint32_t char_id;
|
uint32_t character_id;
|
||||||
uint32_t bot_id;
|
uint32_t bot_id;
|
||||||
uint8_t stance;
|
uint8_t stance;
|
||||||
uint16_t setting_id;
|
uint16_t setting_id;
|
||||||
@@ -31,13 +31,13 @@ public:
|
|||||||
|
|
||||||
static std::string PrimaryKey()
|
static std::string PrimaryKey()
|
||||||
{
|
{
|
||||||
return std::string("char_id");
|
return std::string("character_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<std::string> Columns()
|
static std::vector<std::string> Columns()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"char_id",
|
"character_id",
|
||||||
"bot_id",
|
"bot_id",
|
||||||
"stance",
|
"stance",
|
||||||
"setting_id",
|
"setting_id",
|
||||||
@@ -51,7 +51,7 @@ public:
|
|||||||
static std::vector<std::string> SelectColumns()
|
static std::vector<std::string> SelectColumns()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
"char_id",
|
"character_id",
|
||||||
"bot_id",
|
"bot_id",
|
||||||
"stance",
|
"stance",
|
||||||
"setting_id",
|
"setting_id",
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
{
|
{
|
||||||
BotSettings e{};
|
BotSettings e{};
|
||||||
|
|
||||||
e.char_id = 0;
|
e.character_id = 0;
|
||||||
e.bot_id = 0;
|
e.bot_id = 0;
|
||||||
e.stance = 0;
|
e.stance = 0;
|
||||||
e.setting_id = 0;
|
e.setting_id = 0;
|
||||||
@@ -117,7 +117,7 @@ public:
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
for (auto &bot_settings : bot_settingss) {
|
for (auto &bot_settings : bot_settingss) {
|
||||||
if (bot_settings.char_id == bot_settings_id) {
|
if (bot_settings.character_id == bot_settings_id) {
|
||||||
return bot_settings;
|
return bot_settings;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +143,7 @@ public:
|
|||||||
if (results.RowCount() == 1) {
|
if (results.RowCount() == 1) {
|
||||||
BotSettings e{};
|
BotSettings e{};
|
||||||
|
|
||||||
e.char_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
e.character_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||||
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||||
e.stance = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
|
e.stance = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||||
e.setting_id = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
e.setting_id = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||||
@@ -184,7 +184,7 @@ public:
|
|||||||
|
|
||||||
auto columns = Columns();
|
auto columns = Columns();
|
||||||
|
|
||||||
v.push_back(columns[0] + " = " + std::to_string(e.char_id));
|
v.push_back(columns[0] + " = " + std::to_string(e.character_id));
|
||||||
v.push_back(columns[1] + " = " + std::to_string(e.bot_id));
|
v.push_back(columns[1] + " = " + std::to_string(e.bot_id));
|
||||||
v.push_back(columns[2] + " = " + std::to_string(e.stance));
|
v.push_back(columns[2] + " = " + std::to_string(e.stance));
|
||||||
v.push_back(columns[3] + " = " + std::to_string(e.setting_id));
|
v.push_back(columns[3] + " = " + std::to_string(e.setting_id));
|
||||||
@@ -199,7 +199,7 @@ public:
|
|||||||
TableName(),
|
TableName(),
|
||||||
Strings::Implode(", ", v),
|
Strings::Implode(", ", v),
|
||||||
PrimaryKey(),
|
PrimaryKey(),
|
||||||
e.char_id
|
e.character_id
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::vector<std::string> v;
|
std::vector<std::string> v;
|
||||||
|
|
||||||
v.push_back(std::to_string(e.char_id));
|
v.push_back(std::to_string(e.character_id));
|
||||||
v.push_back(std::to_string(e.bot_id));
|
v.push_back(std::to_string(e.bot_id));
|
||||||
v.push_back(std::to_string(e.stance));
|
v.push_back(std::to_string(e.stance));
|
||||||
v.push_back(std::to_string(e.setting_id));
|
v.push_back(std::to_string(e.setting_id));
|
||||||
@@ -231,7 +231,7 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (results.Success()) {
|
if (results.Success()) {
|
||||||
e.char_id = results.LastInsertedID();
|
e.character_id = results.LastInsertedID();
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +250,7 @@ public:
|
|||||||
for (auto &e: entries) {
|
for (auto &e: entries) {
|
||||||
std::vector<std::string> v;
|
std::vector<std::string> v;
|
||||||
|
|
||||||
v.push_back(std::to_string(e.char_id));
|
v.push_back(std::to_string(e.character_id));
|
||||||
v.push_back(std::to_string(e.bot_id));
|
v.push_back(std::to_string(e.bot_id));
|
||||||
v.push_back(std::to_string(e.stance));
|
v.push_back(std::to_string(e.stance));
|
||||||
v.push_back(std::to_string(e.setting_id));
|
v.push_back(std::to_string(e.setting_id));
|
||||||
@@ -291,7 +291,7 @@ public:
|
|||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
BotSettings e{};
|
BotSettings e{};
|
||||||
|
|
||||||
e.char_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
e.character_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||||
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||||
e.stance = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
|
e.stance = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||||
e.setting_id = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
e.setting_id = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||||
@@ -323,7 +323,7 @@ public:
|
|||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
BotSettings e{};
|
BotSettings e{};
|
||||||
|
|
||||||
e.char_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
e.character_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
|
||||||
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
|
||||||
e.stance = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
|
e.stance = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
|
||||||
e.setting_id = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
e.setting_id = row[3] ? static_cast<uint16_t>(strtoul(row[3], nullptr, 10)) : 0;
|
||||||
@@ -405,7 +405,7 @@ public:
|
|||||||
{
|
{
|
||||||
std::vector<std::string> v;
|
std::vector<std::string> v;
|
||||||
|
|
||||||
v.push_back(std::to_string(e.char_id));
|
v.push_back(std::to_string(e.character_id));
|
||||||
v.push_back(std::to_string(e.bot_id));
|
v.push_back(std::to_string(e.bot_id));
|
||||||
v.push_back(std::to_string(e.stance));
|
v.push_back(std::to_string(e.stance));
|
||||||
v.push_back(std::to_string(e.setting_id));
|
v.push_back(std::to_string(e.setting_id));
|
||||||
@@ -435,7 +435,7 @@ public:
|
|||||||
for (auto &e: entries) {
|
for (auto &e: entries) {
|
||||||
std::vector<std::string> v;
|
std::vector<std::string> v;
|
||||||
|
|
||||||
v.push_back(std::to_string(e.char_id));
|
v.push_back(std::to_string(e.character_id));
|
||||||
v.push_back(std::to_string(e.bot_id));
|
v.push_back(std::to_string(e.bot_id));
|
||||||
v.push_back(std::to_string(e.stance));
|
v.push_back(std::to_string(e.stance));
|
||||||
v.push_back(std::to_string(e.setting_id));
|
v.push_back(std::to_string(e.setting_id));
|
||||||
|
|||||||
@@ -2220,7 +2220,7 @@ bool BotDatabase::LoadBotSettings(Mob* m)
|
|||||||
std::string query = "";
|
std::string query = "";
|
||||||
|
|
||||||
if (m->IsClient()) {
|
if (m->IsClient()) {
|
||||||
query = fmt::format("`char_id` = {} AND `stance` = {}", mob_id, stance_id);
|
query = fmt::format("`character_id` = {} AND `stance` = {}", mob_id, stance_id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
query = fmt::format("`bot_id` = {} AND `stance` = {}", mob_id, stance_id);
|
query = fmt::format("`bot_id` = {} AND `stance` = {}", mob_id, stance_id);
|
||||||
@@ -2274,7 +2274,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 bot_id = (m->IsBot() ? m->CastToBot()->GetBotID() : 0);
|
uint32 bot_id = (m->IsBot() ? m->CastToBot()->GetBotID() : 0);
|
||||||
uint32 char_id = (m->IsClient() ? m->CastToClient()->CharacterID() : 0);
|
uint32 character_id = (m->IsClient() ? m->CastToClient()->CharacterID() : 0);
|
||||||
uint8 stance_id = (m->IsBot() ? m->CastToBot()->GetBotStance() : 0);
|
uint8 stance_id = (m->IsBot() ? m->CastToBot()->GetBotStance() : 0);
|
||||||
|
|
||||||
if (stance_id == Stance::Passive) {
|
if (stance_id == Stance::Passive) {
|
||||||
@@ -2285,7 +2285,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
|||||||
std::string query = "";
|
std::string query = "";
|
||||||
|
|
||||||
if (m->IsClient()) {
|
if (m->IsClient()) {
|
||||||
query = fmt::format("`char_id` = {} AND `stance` = {}", char_id, stance_id);
|
query = fmt::format("`character_id` = {} AND `stance` = {}", character_id, stance_id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
query = fmt::format("`bot_id` = {} AND `stance` = {}", bot_id, stance_id);
|
query = fmt::format("`bot_id` = {} AND `stance` = {}", bot_id, stance_id);
|
||||||
@@ -2301,7 +2301,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
|||||||
for (uint16 i = BotBaseSettings::START_ALL; i <= BotBaseSettings::END; ++i) {
|
for (uint16 i = BotBaseSettings::START_ALL; i <= BotBaseSettings::END; ++i) {
|
||||||
if (m->CastToBot()->GetBotBaseSetting(i) != m->CastToBot()->GetDefaultBotBaseSetting(i, bot_stance)) {
|
if (m->CastToBot()->GetBotBaseSetting(i) != m->CastToBot()->GetDefaultBotBaseSetting(i, bot_stance)) {
|
||||||
auto e = BotSettingsRepository::BotSettings{
|
auto e = BotSettingsRepository::BotSettings{
|
||||||
.char_id = char_id,
|
.character_id = character_id,
|
||||||
.bot_id = bot_id,
|
.bot_id = bot_id,
|
||||||
.stance = stance_id,
|
.stance = stance_id,
|
||||||
.setting_id = static_cast<uint16_t>(i),
|
.setting_id = static_cast<uint16_t>(i),
|
||||||
@@ -2321,7 +2321,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
|||||||
for (uint16 x = BotSpellTypes::START; x <= BotSpellTypes::END; ++x) {
|
for (uint16 x = BotSpellTypes::START; x <= BotSpellTypes::END; ++x) {
|
||||||
if (m->CastToBot()->GetSetting(i, x) != m->CastToBot()->GetDefaultSetting(i, x, bot_stance)) {
|
if (m->CastToBot()->GetSetting(i, x) != m->CastToBot()->GetDefaultSetting(i, x, bot_stance)) {
|
||||||
auto e = BotSettingsRepository::BotSettings{
|
auto e = BotSettingsRepository::BotSettings{
|
||||||
.char_id = char_id,
|
.character_id = character_id,
|
||||||
.bot_id = bot_id,
|
.bot_id = bot_id,
|
||||||
.stance = stance_id,
|
.stance = stance_id,
|
||||||
.setting_id = static_cast<uint16_t>(x),
|
.setting_id = static_cast<uint16_t>(x),
|
||||||
@@ -2342,7 +2342,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
|||||||
if (m->IsClient()) {
|
if (m->IsClient()) {
|
||||||
if (m->CastToClient()->GetDefaultBotSettings(BotSettingCategories::BaseSetting, BotBaseSettings::IllusionBlock) != m->GetIllusionBlock()) { // Only illusion block supported
|
if (m->CastToClient()->GetDefaultBotSettings(BotSettingCategories::BaseSetting, BotBaseSettings::IllusionBlock) != m->GetIllusionBlock()) { // Only illusion block supported
|
||||||
auto e = BotSettingsRepository::BotSettings{
|
auto e = BotSettingsRepository::BotSettings{
|
||||||
.char_id = char_id,
|
.character_id = character_id,
|
||||||
.bot_id = bot_id,
|
.bot_id = bot_id,
|
||||||
.stance = stance_id,
|
.stance = stance_id,
|
||||||
.setting_id = static_cast<uint16_t>(BotBaseSettings::IllusionBlock),
|
.setting_id = static_cast<uint16_t>(BotBaseSettings::IllusionBlock),
|
||||||
@@ -2362,7 +2362,7 @@ bool BotDatabase::SaveBotSettings(Mob* m)
|
|||||||
LogBotSettings("{} says, 'Checking {} {} [{}] - set to [{}] default [{}].'", m->GetCleanName(), m->GetBotSpellCategoryName(i), m->CastToBot()->GetSpellTypeNameByID(x), x, m->CastToClient()->GetBotSetting(i, x), m->CastToClient()->GetDefaultBotSettings(i, x));
|
LogBotSettings("{} says, 'Checking {} {} [{}] - set to [{}] default [{}].'", m->GetCleanName(), m->GetBotSpellCategoryName(i), m->CastToBot()->GetSpellTypeNameByID(x), x, m->CastToClient()->GetBotSetting(i, x), m->CastToClient()->GetDefaultBotSettings(i, x));
|
||||||
if (m->CastToClient()->GetBotSetting(i, x) != m->CastToClient()->GetDefaultBotSettings(i, x)) {
|
if (m->CastToClient()->GetBotSetting(i, x) != m->CastToClient()->GetDefaultBotSettings(i, x)) {
|
||||||
auto e = BotSettingsRepository::BotSettings{
|
auto e = BotSettingsRepository::BotSettings{
|
||||||
.char_id = char_id,
|
.character_id = character_id,
|
||||||
.bot_id = bot_id,
|
.bot_id = bot_id,
|
||||||
.stance = stance_id,
|
.stance = stance_id,
|
||||||
.setting_id = static_cast<uint16_t>(x),
|
.setting_id = static_cast<uint16_t>(x),
|
||||||
|
|||||||
Reference in New Issue
Block a user