[Bots] Convert Bot Database Methods to Repositories (#4023)

* [Bots] Convert Bot Database Methods to Repositories

* Final push.

* Cleanup.

* Cleanup.

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp

* Update bot_database.cpp
This commit is contained in:
Alex King 2024-01-28 21:23:31 -05:00 committed by GitHub
parent 7a770e0e08
commit ce907c9519
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
31 changed files with 3570 additions and 2679 deletions

View File

@ -104,6 +104,25 @@ ALTER TABLE `bot_timers`
DROP PRIMARY KEY; DROP PRIMARY KEY;
ALTER TABLE `bot_timers` ALTER TABLE `bot_timers`
ADD PRIMARY KEY (`bot_id`, `timer_id`, `spell_id`, `item_id`); ADD PRIMARY KEY (`bot_id`, `timer_id`, `spell_id`, `item_id`);
)"
},
ManifestEntry{
.version = 9042,
.description = "2024_01_27_delete_bot_foreign_keys.sql",
.check = "SHOW CREATE TABLE `bot_stances`",
.condition = "contains",
.match = "FOREIGN",
.sql = R"(
ALTER TABLE `bot_buffs` DROP FOREIGN KEY `FK_bot_buffs_1`;
ALTER TABLE `bot_heal_rotations` DROP FOREIGN KEY `FK_bot_heal_rotations`;
ALTER TABLE `bot_heal_rotation_members` DROP FOREIGN KEY `FK_bot_heal_rotation_members_1`;
ALTER TABLE `bot_heal_rotation_members` DROP FOREIGN KEY `FK_bot_heal_rotation_members_2`;
ALTER TABLE `bot_heal_rotation_targets` DROP FOREIGN KEY `FK_bot_heal_rotation_targets`;
ALTER TABLE `bot_inventories` DROP FOREIGN KEY `FK_bot_inventories_1`;
ALTER TABLE `bot_pets` DROP FOREIGN KEY `FK_bot_pets_1`;
ALTER TABLE `bot_pet_buffs` DROP FOREIGN KEY `FK_bot_pet_buffs_1`;
ALTER TABLE `bot_pet_inventories` DROP FOREIGN KEY `FK_bot_pet_inventories_1`;
ALTER TABLE `bot_stances` DROP FOREIGN KEY `FK_bot_stances_1`;
)" )"
} }
// -- template; copy/paste this when you need to create a new entry // -- template; copy/paste this when you need to create a new entry

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_BUFFS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_BUFFS_REPOSITORY_H
@ -180,8 +180,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_buffs_id bot_buffs_id
) )
); );
@ -190,26 +191,26 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotBuffs e{}; BotBuffs e{};
e.buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = static_cast<uint8_t>(strtoul(row[3], nullptr, 10)); e.caster_level = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration_formula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.duration_formula = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.tics_remaining = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.tics_remaining = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.poison_counters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10)); e.poison_counters = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.disease_counters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10)); e.disease_counters = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
e.curse_counters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.curse_counters = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.corruption_counters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10)); e.corruption_counters = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.numhits = static_cast<uint32_t>(strtoul(row[10], nullptr, 10)); e.numhits = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
e.melee_rune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10)); e.melee_rune = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.magic_rune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.magic_rune = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.dot_rune = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.dot_rune = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.persistent = static_cast<int8_t>(atoi(row[14])); e.persistent = row[14] ? static_cast<int8_t>(atoi(row[14])) : 0;
e.caston_x = static_cast<int32_t>(atoi(row[15])); e.caston_x = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
e.caston_y = static_cast<int32_t>(atoi(row[16])); e.caston_y = row[16] ? static_cast<int32_t>(atoi(row[16])) : 0;
e.caston_z = static_cast<int32_t>(atoi(row[17])); e.caston_z = row[17] ? static_cast<int32_t>(atoi(row[17])) : 0;
e.extra_di_chance = static_cast<uint32_t>(strtoul(row[18], nullptr, 10)); e.extra_di_chance = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
e.instrument_mod = static_cast<int32_t>(atoi(row[19])); e.instrument_mod = row[19] ? static_cast<int32_t>(atoi(row[19])) : 10;
return e; return e;
} }
@ -385,26 +386,26 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotBuffs e{}; BotBuffs e{};
e.buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = static_cast<uint8_t>(strtoul(row[3], nullptr, 10)); e.caster_level = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration_formula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.duration_formula = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.tics_remaining = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.tics_remaining = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.poison_counters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10)); e.poison_counters = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.disease_counters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10)); e.disease_counters = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
e.curse_counters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.curse_counters = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.corruption_counters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10)); e.corruption_counters = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.numhits = static_cast<uint32_t>(strtoul(row[10], nullptr, 10)); e.numhits = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
e.melee_rune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10)); e.melee_rune = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.magic_rune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.magic_rune = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.dot_rune = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.dot_rune = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.persistent = static_cast<int8_t>(atoi(row[14])); e.persistent = row[14] ? static_cast<int8_t>(atoi(row[14])) : 0;
e.caston_x = static_cast<int32_t>(atoi(row[15])); e.caston_x = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
e.caston_y = static_cast<int32_t>(atoi(row[16])); e.caston_y = row[16] ? static_cast<int32_t>(atoi(row[16])) : 0;
e.caston_z = static_cast<int32_t>(atoi(row[17])); e.caston_z = row[17] ? static_cast<int32_t>(atoi(row[17])) : 0;
e.extra_di_chance = static_cast<uint32_t>(strtoul(row[18], nullptr, 10)); e.extra_di_chance = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
e.instrument_mod = static_cast<int32_t>(atoi(row[19])); e.instrument_mod = row[19] ? static_cast<int32_t>(atoi(row[19])) : 10;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -429,26 +430,26 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotBuffs e{}; BotBuffs e{};
e.buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = static_cast<uint8_t>(strtoul(row[3], nullptr, 10)); e.caster_level = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration_formula = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.duration_formula = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.tics_remaining = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.tics_remaining = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.poison_counters = static_cast<uint32_t>(strtoul(row[6], nullptr, 10)); e.poison_counters = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.disease_counters = static_cast<uint32_t>(strtoul(row[7], nullptr, 10)); e.disease_counters = row[7] ? static_cast<uint32_t>(strtoul(row[7], nullptr, 10)) : 0;
e.curse_counters = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.curse_counters = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.corruption_counters = static_cast<uint32_t>(strtoul(row[9], nullptr, 10)); e.corruption_counters = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.numhits = static_cast<uint32_t>(strtoul(row[10], nullptr, 10)); e.numhits = row[10] ? static_cast<uint32_t>(strtoul(row[10], nullptr, 10)) : 0;
e.melee_rune = static_cast<uint32_t>(strtoul(row[11], nullptr, 10)); e.melee_rune = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.magic_rune = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.magic_rune = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.dot_rune = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.dot_rune = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.persistent = static_cast<int8_t>(atoi(row[14])); e.persistent = row[14] ? static_cast<int8_t>(atoi(row[14])) : 0;
e.caston_x = static_cast<int32_t>(atoi(row[15])); e.caston_x = row[15] ? static_cast<int32_t>(atoi(row[15])) : 0;
e.caston_y = static_cast<int32_t>(atoi(row[16])); e.caston_y = row[16] ? static_cast<int32_t>(atoi(row[16])) : 0;
e.caston_z = static_cast<int32_t>(atoi(row[17])); e.caston_z = row[17] ? static_cast<int32_t>(atoi(row[17])) : 0;
e.extra_di_chance = static_cast<uint32_t>(strtoul(row[18], nullptr, 10)); e.extra_di_chance = row[18] ? static_cast<uint32_t>(strtoul(row[18], nullptr, 10)) : 0;
e.instrument_mod = static_cast<int32_t>(atoi(row[19])); e.instrument_mod = row[19] ? static_cast<int32_t>(atoi(row[19])) : 10;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -507,6 +508,100 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotBuffs &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.buffs_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back(std::to_string(e.duration_formula));
v.push_back(std::to_string(e.tics_remaining));
v.push_back(std::to_string(e.poison_counters));
v.push_back(std::to_string(e.disease_counters));
v.push_back(std::to_string(e.curse_counters));
v.push_back(std::to_string(e.corruption_counters));
v.push_back(std::to_string(e.numhits));
v.push_back(std::to_string(e.melee_rune));
v.push_back(std::to_string(e.magic_rune));
v.push_back(std::to_string(e.dot_rune));
v.push_back(std::to_string(e.persistent));
v.push_back(std::to_string(e.caston_x));
v.push_back(std::to_string(e.caston_y));
v.push_back(std::to_string(e.caston_z));
v.push_back(std::to_string(e.extra_di_chance));
v.push_back(std::to_string(e.instrument_mod));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotBuffs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.buffs_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back(std::to_string(e.duration_formula));
v.push_back(std::to_string(e.tics_remaining));
v.push_back(std::to_string(e.poison_counters));
v.push_back(std::to_string(e.disease_counters));
v.push_back(std::to_string(e.curse_counters));
v.push_back(std::to_string(e.corruption_counters));
v.push_back(std::to_string(e.numhits));
v.push_back(std::to_string(e.melee_rune));
v.push_back(std::to_string(e.magic_rune));
v.push_back(std::to_string(e.dot_rune));
v.push_back(std::to_string(e.persistent));
v.push_back(std::to_string(e.caston_x));
v.push_back(std::to_string(e.caston_y));
v.push_back(std::to_string(e.caston_z));
v.push_back(std::to_string(e.extra_di_chance));
v.push_back(std::to_string(e.instrument_mod));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_BUFFS_REPOSITORY_H #endif //EQEMU_BASE_BOT_BUFFS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_CREATE_COMBINATIONS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_CREATE_COMBINATIONS_REPOSITORY_H
@ -108,8 +108,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_create_combinations_id bot_create_combinations_id
) )
); );
@ -118,8 +119,8 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotCreateCombinations e{}; BotCreateCombinations e{};
e.race = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.race = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.classes = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.classes = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
return e; return e;
} }
@ -242,8 +243,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotCreateCombinations e{}; BotCreateCombinations e{};
e.race = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.race = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.classes = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.classes = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -268,8 +269,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotCreateCombinations e{}; BotCreateCombinations e{};
e.race = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.race = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.classes = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.classes = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -328,6 +329,64 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotCreateCombinations &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.classes));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotCreateCombinations> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.classes));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_CREATE_COMBINATIONS_REPOSITORY_H #endif //EQEMU_BASE_BOT_CREATE_COMBINATIONS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_DATA_REPOSITORY_H #ifndef EQEMU_BASE_BOT_DATA_REPOSITORY_H
@ -278,7 +278,7 @@ public:
e.expansion_bitmask = -1; e.expansion_bitmask = -1;
e.enforce_spell_settings = 0; e.enforce_spell_settings = 0;
e.archery_setting = 0; e.archery_setting = 0;
e.caster_range = 0; e.caster_range = 300;
return e; return e;
} }
@ -315,57 +315,57 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotData e{}; BotData e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.owner_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.owner_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spells_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spells_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : ""; e.name = row[3] ? row[3] : "";
e.last_name = row[4] ? row[4] : ""; e.last_name = row[4] ? row[4] : "";
e.title = row[5] ? row[5] : ""; e.title = row[5] ? row[5] : "";
e.suffix = row[6] ? row[6] : ""; e.suffix = row[6] ? row[6] : "";
e.zone_id = static_cast<int16_t>(atoi(row[7])); e.zone_id = row[7] ? static_cast<int16_t>(atoi(row[7])) : 0;
e.gender = static_cast<int8_t>(atoi(row[8])); e.gender = row[8] ? static_cast<int8_t>(atoi(row[8])) : 0;
e.race = static_cast<int16_t>(atoi(row[9])); e.race = row[9] ? static_cast<int16_t>(atoi(row[9])) : 0;
e.class_ = static_cast<int8_t>(atoi(row[10])); e.class_ = row[10] ? static_cast<int8_t>(atoi(row[10])) : 0;
e.level = static_cast<uint8_t>(strtoul(row[11], nullptr, 10)); e.level = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.deity = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.deity = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.creation_day = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.creation_day = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.last_spawn = static_cast<uint32_t>(strtoul(row[14], nullptr, 10)); e.last_spawn = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.time_spawned = static_cast<uint32_t>(strtoul(row[15], nullptr, 10)); e.time_spawned = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.size = strtof(row[16], nullptr); e.size = row[16] ? strtof(row[16], nullptr) : 0;
e.face = static_cast<int32_t>(atoi(row[17])); e.face = row[17] ? static_cast<int32_t>(atoi(row[17])) : 1;
e.hair_color = static_cast<int32_t>(atoi(row[18])); e.hair_color = row[18] ? static_cast<int32_t>(atoi(row[18])) : 1;
e.hair_style = static_cast<int32_t>(atoi(row[19])); e.hair_style = row[19] ? static_cast<int32_t>(atoi(row[19])) : 1;
e.beard = static_cast<int32_t>(atoi(row[20])); e.beard = row[20] ? static_cast<int32_t>(atoi(row[20])) : 0;
e.beard_color = static_cast<int32_t>(atoi(row[21])); e.beard_color = row[21] ? static_cast<int32_t>(atoi(row[21])) : 1;
e.eye_color_1 = static_cast<int32_t>(atoi(row[22])); e.eye_color_1 = row[22] ? static_cast<int32_t>(atoi(row[22])) : 1;
e.eye_color_2 = static_cast<int32_t>(atoi(row[23])); e.eye_color_2 = row[23] ? static_cast<int32_t>(atoi(row[23])) : 1;
e.drakkin_heritage = static_cast<int32_t>(atoi(row[24])); e.drakkin_heritage = row[24] ? static_cast<int32_t>(atoi(row[24])) : 0;
e.drakkin_tattoo = static_cast<int32_t>(atoi(row[25])); e.drakkin_tattoo = row[25] ? static_cast<int32_t>(atoi(row[25])) : 0;
e.drakkin_details = static_cast<int32_t>(atoi(row[26])); e.drakkin_details = row[26] ? static_cast<int32_t>(atoi(row[26])) : 0;
e.ac = static_cast<int16_t>(atoi(row[27])); e.ac = row[27] ? static_cast<int16_t>(atoi(row[27])) : 0;
e.atk = static_cast<int32_t>(atoi(row[28])); e.atk = row[28] ? static_cast<int32_t>(atoi(row[28])) : 0;
e.hp = static_cast<int32_t>(atoi(row[29])); e.hp = row[29] ? static_cast<int32_t>(atoi(row[29])) : 0;
e.mana = static_cast<int32_t>(atoi(row[30])); e.mana = row[30] ? static_cast<int32_t>(atoi(row[30])) : 0;
e.str = static_cast<int32_t>(atoi(row[31])); e.str = row[31] ? static_cast<int32_t>(atoi(row[31])) : 75;
e.sta = static_cast<int32_t>(atoi(row[32])); e.sta = row[32] ? static_cast<int32_t>(atoi(row[32])) : 75;
e.cha = static_cast<int32_t>(atoi(row[33])); e.cha = row[33] ? static_cast<int32_t>(atoi(row[33])) : 75;
e.dex = static_cast<int32_t>(atoi(row[34])); e.dex = row[34] ? static_cast<int32_t>(atoi(row[34])) : 75;
e.int_ = static_cast<int32_t>(atoi(row[35])); e.int_ = row[35] ? static_cast<int32_t>(atoi(row[35])) : 75;
e.agi = static_cast<int32_t>(atoi(row[36])); e.agi = row[36] ? static_cast<int32_t>(atoi(row[36])) : 75;
e.wis = static_cast<int32_t>(atoi(row[37])); e.wis = row[37] ? static_cast<int32_t>(atoi(row[37])) : 75;
e.fire = static_cast<int16_t>(atoi(row[38])); e.fire = row[38] ? static_cast<int16_t>(atoi(row[38])) : 0;
e.cold = static_cast<int16_t>(atoi(row[39])); e.cold = row[39] ? static_cast<int16_t>(atoi(row[39])) : 0;
e.magic = static_cast<int16_t>(atoi(row[40])); e.magic = row[40] ? static_cast<int16_t>(atoi(row[40])) : 0;
e.poison = static_cast<int16_t>(atoi(row[41])); e.poison = row[41] ? static_cast<int16_t>(atoi(row[41])) : 0;
e.disease = static_cast<int16_t>(atoi(row[42])); e.disease = row[42] ? static_cast<int16_t>(atoi(row[42])) : 0;
e.corruption = static_cast<int16_t>(atoi(row[43])); e.corruption = row[43] ? static_cast<int16_t>(atoi(row[43])) : 0;
e.show_helm = static_cast<uint32_t>(strtoul(row[44], nullptr, 10)); e.show_helm = row[44] ? static_cast<uint32_t>(strtoul(row[44], nullptr, 10)) : 0;
e.follow_distance = static_cast<uint32_t>(strtoul(row[45], nullptr, 10)); e.follow_distance = row[45] ? static_cast<uint32_t>(strtoul(row[45], nullptr, 10)) : 200;
e.stop_melee_level = static_cast<uint8_t>(strtoul(row[46], nullptr, 10)); e.stop_melee_level = row[46] ? static_cast<uint8_t>(strtoul(row[46], nullptr, 10)) : 255;
e.expansion_bitmask = static_cast<int32_t>(atoi(row[47])); e.expansion_bitmask = row[47] ? static_cast<int32_t>(atoi(row[47])) : -1;
e.enforce_spell_settings = static_cast<uint8_t>(strtoul(row[48], nullptr, 10)); e.enforce_spell_settings = row[48] ? static_cast<uint8_t>(strtoul(row[48], nullptr, 10)) : 0;
e.archery_setting = static_cast<uint8_t>(strtoul(row[49], nullptr, 10)); e.archery_setting = row[49] ? static_cast<uint8_t>(strtoul(row[49], nullptr, 10)) : 0;
e.caster_range = static_cast<uint32_t>(strtoul(row[50], nullptr, 10)); e.caster_range = row[50] ? static_cast<uint32_t>(strtoul(row[50], nullptr, 10)) : 300;
return e; return e;
} }
@ -634,57 +634,57 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotData e{}; BotData e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.owner_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.owner_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spells_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spells_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : ""; e.name = row[3] ? row[3] : "";
e.last_name = row[4] ? row[4] : ""; e.last_name = row[4] ? row[4] : "";
e.title = row[5] ? row[5] : ""; e.title = row[5] ? row[5] : "";
e.suffix = row[6] ? row[6] : ""; e.suffix = row[6] ? row[6] : "";
e.zone_id = static_cast<int16_t>(atoi(row[7])); e.zone_id = row[7] ? static_cast<int16_t>(atoi(row[7])) : 0;
e.gender = static_cast<int8_t>(atoi(row[8])); e.gender = row[8] ? static_cast<int8_t>(atoi(row[8])) : 0;
e.race = static_cast<int16_t>(atoi(row[9])); e.race = row[9] ? static_cast<int16_t>(atoi(row[9])) : 0;
e.class_ = static_cast<int8_t>(atoi(row[10])); e.class_ = row[10] ? static_cast<int8_t>(atoi(row[10])) : 0;
e.level = static_cast<uint8_t>(strtoul(row[11], nullptr, 10)); e.level = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.deity = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.deity = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.creation_day = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.creation_day = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.last_spawn = static_cast<uint32_t>(strtoul(row[14], nullptr, 10)); e.last_spawn = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.time_spawned = static_cast<uint32_t>(strtoul(row[15], nullptr, 10)); e.time_spawned = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.size = strtof(row[16], nullptr); e.size = row[16] ? strtof(row[16], nullptr) : 0;
e.face = static_cast<int32_t>(atoi(row[17])); e.face = row[17] ? static_cast<int32_t>(atoi(row[17])) : 1;
e.hair_color = static_cast<int32_t>(atoi(row[18])); e.hair_color = row[18] ? static_cast<int32_t>(atoi(row[18])) : 1;
e.hair_style = static_cast<int32_t>(atoi(row[19])); e.hair_style = row[19] ? static_cast<int32_t>(atoi(row[19])) : 1;
e.beard = static_cast<int32_t>(atoi(row[20])); e.beard = row[20] ? static_cast<int32_t>(atoi(row[20])) : 0;
e.beard_color = static_cast<int32_t>(atoi(row[21])); e.beard_color = row[21] ? static_cast<int32_t>(atoi(row[21])) : 1;
e.eye_color_1 = static_cast<int32_t>(atoi(row[22])); e.eye_color_1 = row[22] ? static_cast<int32_t>(atoi(row[22])) : 1;
e.eye_color_2 = static_cast<int32_t>(atoi(row[23])); e.eye_color_2 = row[23] ? static_cast<int32_t>(atoi(row[23])) : 1;
e.drakkin_heritage = static_cast<int32_t>(atoi(row[24])); e.drakkin_heritage = row[24] ? static_cast<int32_t>(atoi(row[24])) : 0;
e.drakkin_tattoo = static_cast<int32_t>(atoi(row[25])); e.drakkin_tattoo = row[25] ? static_cast<int32_t>(atoi(row[25])) : 0;
e.drakkin_details = static_cast<int32_t>(atoi(row[26])); e.drakkin_details = row[26] ? static_cast<int32_t>(atoi(row[26])) : 0;
e.ac = static_cast<int16_t>(atoi(row[27])); e.ac = row[27] ? static_cast<int16_t>(atoi(row[27])) : 0;
e.atk = static_cast<int32_t>(atoi(row[28])); e.atk = row[28] ? static_cast<int32_t>(atoi(row[28])) : 0;
e.hp = static_cast<int32_t>(atoi(row[29])); e.hp = row[29] ? static_cast<int32_t>(atoi(row[29])) : 0;
e.mana = static_cast<int32_t>(atoi(row[30])); e.mana = row[30] ? static_cast<int32_t>(atoi(row[30])) : 0;
e.str = static_cast<int32_t>(atoi(row[31])); e.str = row[31] ? static_cast<int32_t>(atoi(row[31])) : 75;
e.sta = static_cast<int32_t>(atoi(row[32])); e.sta = row[32] ? static_cast<int32_t>(atoi(row[32])) : 75;
e.cha = static_cast<int32_t>(atoi(row[33])); e.cha = row[33] ? static_cast<int32_t>(atoi(row[33])) : 75;
e.dex = static_cast<int32_t>(atoi(row[34])); e.dex = row[34] ? static_cast<int32_t>(atoi(row[34])) : 75;
e.int_ = static_cast<int32_t>(atoi(row[35])); e.int_ = row[35] ? static_cast<int32_t>(atoi(row[35])) : 75;
e.agi = static_cast<int32_t>(atoi(row[36])); e.agi = row[36] ? static_cast<int32_t>(atoi(row[36])) : 75;
e.wis = static_cast<int32_t>(atoi(row[37])); e.wis = row[37] ? static_cast<int32_t>(atoi(row[37])) : 75;
e.fire = static_cast<int16_t>(atoi(row[38])); e.fire = row[38] ? static_cast<int16_t>(atoi(row[38])) : 0;
e.cold = static_cast<int16_t>(atoi(row[39])); e.cold = row[39] ? static_cast<int16_t>(atoi(row[39])) : 0;
e.magic = static_cast<int16_t>(atoi(row[40])); e.magic = row[40] ? static_cast<int16_t>(atoi(row[40])) : 0;
e.poison = static_cast<int16_t>(atoi(row[41])); e.poison = row[41] ? static_cast<int16_t>(atoi(row[41])) : 0;
e.disease = static_cast<int16_t>(atoi(row[42])); e.disease = row[42] ? static_cast<int16_t>(atoi(row[42])) : 0;
e.corruption = static_cast<int16_t>(atoi(row[43])); e.corruption = row[43] ? static_cast<int16_t>(atoi(row[43])) : 0;
e.show_helm = static_cast<uint32_t>(strtoul(row[44], nullptr, 10)); e.show_helm = row[44] ? static_cast<uint32_t>(strtoul(row[44], nullptr, 10)) : 0;
e.follow_distance = static_cast<uint32_t>(strtoul(row[45], nullptr, 10)); e.follow_distance = row[45] ? static_cast<uint32_t>(strtoul(row[45], nullptr, 10)) : 200;
e.stop_melee_level = static_cast<uint8_t>(strtoul(row[46], nullptr, 10)); e.stop_melee_level = row[46] ? static_cast<uint8_t>(strtoul(row[46], nullptr, 10)) : 255;
e.expansion_bitmask = static_cast<int32_t>(atoi(row[47])); e.expansion_bitmask = row[47] ? static_cast<int32_t>(atoi(row[47])) : -1;
e.enforce_spell_settings = static_cast<uint8_t>(strtoul(row[48], nullptr, 10)); e.enforce_spell_settings = row[48] ? static_cast<uint8_t>(strtoul(row[48], nullptr, 10)) : 0;
e.archery_setting = static_cast<uint8_t>(strtoul(row[49], nullptr, 10)); e.archery_setting = row[49] ? static_cast<uint8_t>(strtoul(row[49], nullptr, 10)) : 0;
e.caster_range = static_cast<uint32_t>(strtoul(row[50], nullptr, 10)); e.caster_range = row[50] ? static_cast<uint32_t>(strtoul(row[50], nullptr, 10)) : 300;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -709,57 +709,57 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotData e{}; BotData e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.owner_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.owner_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spells_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spells_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : ""; e.name = row[3] ? row[3] : "";
e.last_name = row[4] ? row[4] : ""; e.last_name = row[4] ? row[4] : "";
e.title = row[5] ? row[5] : ""; e.title = row[5] ? row[5] : "";
e.suffix = row[6] ? row[6] : ""; e.suffix = row[6] ? row[6] : "";
e.zone_id = static_cast<int16_t>(atoi(row[7])); e.zone_id = row[7] ? static_cast<int16_t>(atoi(row[7])) : 0;
e.gender = static_cast<int8_t>(atoi(row[8])); e.gender = row[8] ? static_cast<int8_t>(atoi(row[8])) : 0;
e.race = static_cast<int16_t>(atoi(row[9])); e.race = row[9] ? static_cast<int16_t>(atoi(row[9])) : 0;
e.class_ = static_cast<int8_t>(atoi(row[10])); e.class_ = row[10] ? static_cast<int8_t>(atoi(row[10])) : 0;
e.level = static_cast<uint8_t>(strtoul(row[11], nullptr, 10)); e.level = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.deity = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.deity = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.creation_day = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.creation_day = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.last_spawn = static_cast<uint32_t>(strtoul(row[14], nullptr, 10)); e.last_spawn = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.time_spawned = static_cast<uint32_t>(strtoul(row[15], nullptr, 10)); e.time_spawned = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.size = strtof(row[16], nullptr); e.size = row[16] ? strtof(row[16], nullptr) : 0;
e.face = static_cast<int32_t>(atoi(row[17])); e.face = row[17] ? static_cast<int32_t>(atoi(row[17])) : 1;
e.hair_color = static_cast<int32_t>(atoi(row[18])); e.hair_color = row[18] ? static_cast<int32_t>(atoi(row[18])) : 1;
e.hair_style = static_cast<int32_t>(atoi(row[19])); e.hair_style = row[19] ? static_cast<int32_t>(atoi(row[19])) : 1;
e.beard = static_cast<int32_t>(atoi(row[20])); e.beard = row[20] ? static_cast<int32_t>(atoi(row[20])) : 0;
e.beard_color = static_cast<int32_t>(atoi(row[21])); e.beard_color = row[21] ? static_cast<int32_t>(atoi(row[21])) : 1;
e.eye_color_1 = static_cast<int32_t>(atoi(row[22])); e.eye_color_1 = row[22] ? static_cast<int32_t>(atoi(row[22])) : 1;
e.eye_color_2 = static_cast<int32_t>(atoi(row[23])); e.eye_color_2 = row[23] ? static_cast<int32_t>(atoi(row[23])) : 1;
e.drakkin_heritage = static_cast<int32_t>(atoi(row[24])); e.drakkin_heritage = row[24] ? static_cast<int32_t>(atoi(row[24])) : 0;
e.drakkin_tattoo = static_cast<int32_t>(atoi(row[25])); e.drakkin_tattoo = row[25] ? static_cast<int32_t>(atoi(row[25])) : 0;
e.drakkin_details = static_cast<int32_t>(atoi(row[26])); e.drakkin_details = row[26] ? static_cast<int32_t>(atoi(row[26])) : 0;
e.ac = static_cast<int16_t>(atoi(row[27])); e.ac = row[27] ? static_cast<int16_t>(atoi(row[27])) : 0;
e.atk = static_cast<int32_t>(atoi(row[28])); e.atk = row[28] ? static_cast<int32_t>(atoi(row[28])) : 0;
e.hp = static_cast<int32_t>(atoi(row[29])); e.hp = row[29] ? static_cast<int32_t>(atoi(row[29])) : 0;
e.mana = static_cast<int32_t>(atoi(row[30])); e.mana = row[30] ? static_cast<int32_t>(atoi(row[30])) : 0;
e.str = static_cast<int32_t>(atoi(row[31])); e.str = row[31] ? static_cast<int32_t>(atoi(row[31])) : 75;
e.sta = static_cast<int32_t>(atoi(row[32])); e.sta = row[32] ? static_cast<int32_t>(atoi(row[32])) : 75;
e.cha = static_cast<int32_t>(atoi(row[33])); e.cha = row[33] ? static_cast<int32_t>(atoi(row[33])) : 75;
e.dex = static_cast<int32_t>(atoi(row[34])); e.dex = row[34] ? static_cast<int32_t>(atoi(row[34])) : 75;
e.int_ = static_cast<int32_t>(atoi(row[35])); e.int_ = row[35] ? static_cast<int32_t>(atoi(row[35])) : 75;
e.agi = static_cast<int32_t>(atoi(row[36])); e.agi = row[36] ? static_cast<int32_t>(atoi(row[36])) : 75;
e.wis = static_cast<int32_t>(atoi(row[37])); e.wis = row[37] ? static_cast<int32_t>(atoi(row[37])) : 75;
e.fire = static_cast<int16_t>(atoi(row[38])); e.fire = row[38] ? static_cast<int16_t>(atoi(row[38])) : 0;
e.cold = static_cast<int16_t>(atoi(row[39])); e.cold = row[39] ? static_cast<int16_t>(atoi(row[39])) : 0;
e.magic = static_cast<int16_t>(atoi(row[40])); e.magic = row[40] ? static_cast<int16_t>(atoi(row[40])) : 0;
e.poison = static_cast<int16_t>(atoi(row[41])); e.poison = row[41] ? static_cast<int16_t>(atoi(row[41])) : 0;
e.disease = static_cast<int16_t>(atoi(row[42])); e.disease = row[42] ? static_cast<int16_t>(atoi(row[42])) : 0;
e.corruption = static_cast<int16_t>(atoi(row[43])); e.corruption = row[43] ? static_cast<int16_t>(atoi(row[43])) : 0;
e.show_helm = static_cast<uint32_t>(strtoul(row[44], nullptr, 10)); e.show_helm = row[44] ? static_cast<uint32_t>(strtoul(row[44], nullptr, 10)) : 0;
e.follow_distance = static_cast<uint32_t>(strtoul(row[45], nullptr, 10)); e.follow_distance = row[45] ? static_cast<uint32_t>(strtoul(row[45], nullptr, 10)) : 200;
e.stop_melee_level = static_cast<uint8_t>(strtoul(row[46], nullptr, 10)); e.stop_melee_level = row[46] ? static_cast<uint8_t>(strtoul(row[46], nullptr, 10)) : 255;
e.expansion_bitmask = static_cast<int32_t>(atoi(row[47])); e.expansion_bitmask = row[47] ? static_cast<int32_t>(atoi(row[47])) : -1;
e.enforce_spell_settings = static_cast<uint8_t>(strtoul(row[48], nullptr, 10)); e.enforce_spell_settings = row[48] ? static_cast<uint8_t>(strtoul(row[48], nullptr, 10)) : 0;
e.archery_setting = static_cast<uint8_t>(strtoul(row[49], nullptr, 10)); e.archery_setting = row[49] ? static_cast<uint8_t>(strtoul(row[49], nullptr, 10)) : 0;
e.caster_range = static_cast<uint32_t>(strtoul(row[50], nullptr, 10)); e.caster_range = row[50] ? static_cast<uint32_t>(strtoul(row[50], nullptr, 10)) : 300;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -818,6 +818,162 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotData &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.owner_id));
v.push_back(std::to_string(e.spells_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.last_name) + "'");
v.push_back("'" + Strings::Escape(e.title) + "'");
v.push_back("'" + Strings::Escape(e.suffix) + "'");
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.gender));
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.deity));
v.push_back(std::to_string(e.creation_day));
v.push_back(std::to_string(e.last_spawn));
v.push_back(std::to_string(e.time_spawned));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.face));
v.push_back(std::to_string(e.hair_color));
v.push_back(std::to_string(e.hair_style));
v.push_back(std::to_string(e.beard));
v.push_back(std::to_string(e.beard_color));
v.push_back(std::to_string(e.eye_color_1));
v.push_back(std::to_string(e.eye_color_2));
v.push_back(std::to_string(e.drakkin_heritage));
v.push_back(std::to_string(e.drakkin_tattoo));
v.push_back(std::to_string(e.drakkin_details));
v.push_back(std::to_string(e.ac));
v.push_back(std::to_string(e.atk));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.str));
v.push_back(std::to_string(e.sta));
v.push_back(std::to_string(e.cha));
v.push_back(std::to_string(e.dex));
v.push_back(std::to_string(e.int_));
v.push_back(std::to_string(e.agi));
v.push_back(std::to_string(e.wis));
v.push_back(std::to_string(e.fire));
v.push_back(std::to_string(e.cold));
v.push_back(std::to_string(e.magic));
v.push_back(std::to_string(e.poison));
v.push_back(std::to_string(e.disease));
v.push_back(std::to_string(e.corruption));
v.push_back(std::to_string(e.show_helm));
v.push_back(std::to_string(e.follow_distance));
v.push_back(std::to_string(e.stop_melee_level));
v.push_back(std::to_string(e.expansion_bitmask));
v.push_back(std::to_string(e.enforce_spell_settings));
v.push_back(std::to_string(e.archery_setting));
v.push_back(std::to_string(e.caster_range));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotData> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.owner_id));
v.push_back(std::to_string(e.spells_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back("'" + Strings::Escape(e.last_name) + "'");
v.push_back("'" + Strings::Escape(e.title) + "'");
v.push_back("'" + Strings::Escape(e.suffix) + "'");
v.push_back(std::to_string(e.zone_id));
v.push_back(std::to_string(e.gender));
v.push_back(std::to_string(e.race));
v.push_back(std::to_string(e.class_));
v.push_back(std::to_string(e.level));
v.push_back(std::to_string(e.deity));
v.push_back(std::to_string(e.creation_day));
v.push_back(std::to_string(e.last_spawn));
v.push_back(std::to_string(e.time_spawned));
v.push_back(std::to_string(e.size));
v.push_back(std::to_string(e.face));
v.push_back(std::to_string(e.hair_color));
v.push_back(std::to_string(e.hair_style));
v.push_back(std::to_string(e.beard));
v.push_back(std::to_string(e.beard_color));
v.push_back(std::to_string(e.eye_color_1));
v.push_back(std::to_string(e.eye_color_2));
v.push_back(std::to_string(e.drakkin_heritage));
v.push_back(std::to_string(e.drakkin_tattoo));
v.push_back(std::to_string(e.drakkin_details));
v.push_back(std::to_string(e.ac));
v.push_back(std::to_string(e.atk));
v.push_back(std::to_string(e.hp));
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.str));
v.push_back(std::to_string(e.sta));
v.push_back(std::to_string(e.cha));
v.push_back(std::to_string(e.dex));
v.push_back(std::to_string(e.int_));
v.push_back(std::to_string(e.agi));
v.push_back(std::to_string(e.wis));
v.push_back(std::to_string(e.fire));
v.push_back(std::to_string(e.cold));
v.push_back(std::to_string(e.magic));
v.push_back(std::to_string(e.poison));
v.push_back(std::to_string(e.disease));
v.push_back(std::to_string(e.corruption));
v.push_back(std::to_string(e.show_helm));
v.push_back(std::to_string(e.follow_distance));
v.push_back(std::to_string(e.stop_melee_level));
v.push_back(std::to_string(e.expansion_bitmask));
v.push_back(std::to_string(e.enforce_spell_settings));
v.push_back(std::to_string(e.archery_setting));
v.push_back(std::to_string(e.caster_range));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_DATA_REPOSITORY_H #endif //EQEMU_BASE_BOT_DATA_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_HEAL_ROTATION_MEMBERS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_HEAL_ROTATION_MEMBERS_REPOSITORY_H
@ -112,8 +112,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_heal_rotation_members_id bot_heal_rotation_members_id
) )
); );
@ -122,9 +123,9 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotHealRotationMembers e{}; BotHealRotationMembers e{};
e.member_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.member_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
return e; return e;
} }
@ -249,9 +250,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotationMembers e{}; BotHealRotationMembers e{};
e.member_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.member_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -276,9 +277,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotationMembers e{}; BotHealRotationMembers e{};
e.member_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.member_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -337,6 +338,66 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotHealRotationMembers &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.member_index));
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotHealRotationMembers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.member_index));
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_HEAL_ROTATION_MEMBERS_REPOSITORY_H #endif //EQEMU_BASE_BOT_HEAL_ROTATION_MEMBERS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_HEAL_ROTATION_TARGETS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_HEAL_ROTATION_TARGETS_REPOSITORY_H
@ -112,8 +112,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_heal_rotation_targets_id bot_heal_rotation_targets_id
) )
); );
@ -122,8 +123,8 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotHealRotationTargets e{}; BotHealRotationTargets e{};
e.target_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.target_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.target_name = row[2] ? row[2] : ""; e.target_name = row[2] ? row[2] : "";
return e; return e;
@ -249,8 +250,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotationTargets e{}; BotHealRotationTargets e{};
e.target_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.target_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.target_name = row[2] ? row[2] : ""; e.target_name = row[2] ? row[2] : "";
all_entries.push_back(e); all_entries.push_back(e);
@ -276,8 +277,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotationTargets e{}; BotHealRotationTargets e{};
e.target_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.target_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.heal_rotation_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.target_name = row[2] ? row[2] : ""; e.target_name = row[2] ? row[2] : "";
all_entries.push_back(e); all_entries.push_back(e);
@ -337,6 +338,66 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotHealRotationTargets &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.target_index));
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back("'" + Strings::Escape(e.target_name) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotHealRotationTargets> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.target_index));
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back("'" + Strings::Escape(e.target_name) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_HEAL_ROTATION_TARGETS_REPOSITORY_H #endif //EQEMU_BASE_BOT_HEAL_ROTATION_TARGETS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_HEAL_ROTATIONS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_HEAL_ROTATIONS_REPOSITORY_H
@ -19,22 +19,22 @@
class BaseBotHealRotationsRepository { class BaseBotHealRotationsRepository {
public: public:
struct BotHealRotations { struct BotHealRotations {
uint32_t heal_rotation_index; uint32_t heal_rotation_index;
uint32_t bot_id; uint32_t bot_id;
uint32_t interval; uint32_t interval_;
uint32_t fast_heals; uint32_t fast_heals;
uint32_t adaptive_targeting; uint32_t adaptive_targeting;
uint32_t casting_override; uint32_t casting_override;
std::string safe_hp_base; float safe_hp_base;
std::string safe_hp_cloth; float safe_hp_cloth;
std::string safe_hp_leather; float safe_hp_leather;
std::string safe_hp_chain; float safe_hp_chain;
std::string safe_hp_plate; float safe_hp_plate;
std::string critical_hp_base; float critical_hp_base;
std::string critical_hp_cloth; float critical_hp_cloth;
std::string critical_hp_leather; float critical_hp_leather;
std::string critical_hp_chain; float critical_hp_chain;
std::string critical_hp_plate; float critical_hp_plate;
}; };
static std::string PrimaryKey() static std::string PrimaryKey()
@ -47,7 +47,7 @@ public:
return { return {
"heal_rotation_index", "heal_rotation_index",
"bot_id", "bot_id",
"interval", "`interval`",
"fast_heals", "fast_heals",
"adaptive_targeting", "adaptive_targeting",
"casting_override", "casting_override",
@ -69,7 +69,7 @@ public:
return { return {
"heal_rotation_index", "heal_rotation_index",
"bot_id", "bot_id",
"interval", "`interval`",
"fast_heals", "fast_heals",
"adaptive_targeting", "adaptive_targeting",
"casting_override", "casting_override",
@ -125,7 +125,7 @@ public:
e.heal_rotation_index = 0; e.heal_rotation_index = 0;
e.bot_id = 0; e.bot_id = 0;
e.interval = 0; e.interval_ = 0;
e.fast_heals = 0; e.fast_heals = 0;
e.adaptive_targeting = 0; e.adaptive_targeting = 0;
e.casting_override = 0; e.casting_override = 0;
@ -164,8 +164,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_heal_rotations_id bot_heal_rotations_id
) )
); );
@ -174,12 +175,12 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotHealRotations e{}; BotHealRotations e{};
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.heal_rotation_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.interval = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.interval_ = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.fast_heals = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.fast_heals = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.adaptive_targeting = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.adaptive_targeting = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.casting_override = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.casting_override = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
return e; return e;
} }
@ -214,7 +215,7 @@ public:
auto columns = Columns(); auto columns = Columns();
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.interval)); v.push_back(columns[2] + " = " + std::to_string(e.interval_));
v.push_back(columns[3] + " = " + std::to_string(e.fast_heals)); v.push_back(columns[3] + " = " + std::to_string(e.fast_heals));
v.push_back(columns[4] + " = " + std::to_string(e.adaptive_targeting)); v.push_back(columns[4] + " = " + std::to_string(e.adaptive_targeting));
v.push_back(columns[5] + " = " + std::to_string(e.casting_override)); v.push_back(columns[5] + " = " + std::to_string(e.casting_override));
@ -251,7 +252,7 @@ public:
v.push_back(std::to_string(e.heal_rotation_index)); v.push_back(std::to_string(e.heal_rotation_index));
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.interval)); v.push_back(std::to_string(e.interval_));
v.push_back(std::to_string(e.fast_heals)); v.push_back(std::to_string(e.fast_heals));
v.push_back(std::to_string(e.adaptive_targeting)); v.push_back(std::to_string(e.adaptive_targeting));
v.push_back(std::to_string(e.casting_override)); v.push_back(std::to_string(e.casting_override));
@ -296,7 +297,7 @@ public:
v.push_back(std::to_string(e.heal_rotation_index)); v.push_back(std::to_string(e.heal_rotation_index));
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.interval)); v.push_back(std::to_string(e.interval_));
v.push_back(std::to_string(e.fast_heals)); v.push_back(std::to_string(e.fast_heals));
v.push_back(std::to_string(e.adaptive_targeting)); v.push_back(std::to_string(e.adaptive_targeting));
v.push_back(std::to_string(e.casting_override)); v.push_back(std::to_string(e.casting_override));
@ -343,12 +344,12 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotations e{}; BotHealRotations e{};
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.heal_rotation_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.interval = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.interval_ = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.fast_heals = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.fast_heals = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.adaptive_targeting = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.adaptive_targeting = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.casting_override = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.casting_override = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -373,12 +374,12 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotHealRotations e{}; BotHealRotations e{};
e.heal_rotation_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.heal_rotation_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.interval = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.interval_ = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.fast_heals = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.fast_heals = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.adaptive_targeting = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.adaptive_targeting = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
e.casting_override = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.casting_override = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -437,6 +438,92 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotHealRotations &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.interval_));
v.push_back(std::to_string(e.fast_heals));
v.push_back(std::to_string(e.adaptive_targeting));
v.push_back(std::to_string(e.casting_override));
v.push_back(std::to_string(e.safe_hp_base));
v.push_back(std::to_string(e.safe_hp_cloth));
v.push_back(std::to_string(e.safe_hp_leather));
v.push_back(std::to_string(e.safe_hp_chain));
v.push_back(std::to_string(e.safe_hp_plate));
v.push_back(std::to_string(e.critical_hp_base));
v.push_back(std::to_string(e.critical_hp_cloth));
v.push_back(std::to_string(e.critical_hp_leather));
v.push_back(std::to_string(e.critical_hp_chain));
v.push_back(std::to_string(e.critical_hp_plate));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotHealRotations> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.heal_rotation_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.interval_));
v.push_back(std::to_string(e.fast_heals));
v.push_back(std::to_string(e.adaptive_targeting));
v.push_back(std::to_string(e.casting_override));
v.push_back(std::to_string(e.safe_hp_base));
v.push_back(std::to_string(e.safe_hp_cloth));
v.push_back(std::to_string(e.safe_hp_leather));
v.push_back(std::to_string(e.safe_hp_chain));
v.push_back(std::to_string(e.safe_hp_plate));
v.push_back(std::to_string(e.critical_hp_base));
v.push_back(std::to_string(e.critical_hp_cloth));
v.push_back(std::to_string(e.critical_hp_leather));
v.push_back(std::to_string(e.critical_hp_chain));
v.push_back(std::to_string(e.critical_hp_plate));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_HEAL_ROTATIONS_REPOSITORY_H #endif //EQEMU_BASE_BOT_HEAL_ROTATIONS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_INSPECT_MESSAGES_REPOSITORY_H #ifndef EQEMU_BASE_BOT_INSPECT_MESSAGES_REPOSITORY_H
@ -108,8 +108,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_inspect_messages_id bot_inspect_messages_id
) )
); );
@ -118,7 +119,7 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotInspectMessages e{}; BotInspectMessages e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.inspect_message = row[1] ? row[1] : ""; e.inspect_message = row[1] ? row[1] : "";
return e; return e;
@ -242,7 +243,7 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotInspectMessages e{}; BotInspectMessages e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.inspect_message = row[1] ? row[1] : ""; e.inspect_message = row[1] ? row[1] : "";
all_entries.push_back(e); all_entries.push_back(e);
@ -268,7 +269,7 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotInspectMessages e{}; BotInspectMessages e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.inspect_message = row[1] ? row[1] : ""; e.inspect_message = row[1] ? row[1] : "";
all_entries.push_back(e); all_entries.push_back(e);
@ -328,6 +329,64 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotInspectMessages &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back("'" + Strings::Escape(e.inspect_message) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotInspectMessages> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back("'" + Strings::Escape(e.inspect_message) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_INSPECT_MESSAGES_REPOSITORY_H #endif //EQEMU_BASE_BOT_INSPECT_MESSAGES_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_INVENTORIES_REPOSITORY_H #ifndef EQEMU_BASE_BOT_INVENTORIES_REPOSITORY_H
@ -168,8 +168,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_inventories_id bot_inventories_id
) )
); );
@ -178,23 +179,23 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotInventories e{}; BotInventories e{};
e.inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.slot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.slot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.inst_charges = static_cast<uint16_t>(strtoul(row[4], nullptr, 10)); e.inst_charges = row[4] ? static_cast<uint16_t>(strtoul(row[4], nullptr, 10)) : 0;
e.inst_color = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.inst_color = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.inst_no_drop = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.inst_no_drop = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.inst_custom_data = row[7] ? row[7] : ""; e.inst_custom_data = row[7] ? row[7] : "";
e.ornament_icon = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.ornament_icon = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.ornament_id_file = static_cast<uint32_t>(strtoul(row[9], nullptr, 10)); e.ornament_id_file = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.ornament_hero_model = static_cast<int32_t>(atoi(row[10])); e.ornament_hero_model = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
e.augment_1 = static_cast<uint32_t>(strtoul(row[11], nullptr, 10)); e.augment_1 = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.augment_2 = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.augment_2 = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.augment_3 = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.augment_3 = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.augment_4 = static_cast<uint32_t>(strtoul(row[14], nullptr, 10)); e.augment_4 = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.augment_5 = static_cast<uint32_t>(strtoul(row[15], nullptr, 10)); e.augment_5 = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.augment_6 = static_cast<uint32_t>(strtoul(row[16], nullptr, 10)); e.augment_6 = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
return e; return e;
} }
@ -361,23 +362,23 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotInventories e{}; BotInventories e{};
e.inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.slot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.slot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.inst_charges = static_cast<uint16_t>(strtoul(row[4], nullptr, 10)); e.inst_charges = row[4] ? static_cast<uint16_t>(strtoul(row[4], nullptr, 10)) : 0;
e.inst_color = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.inst_color = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.inst_no_drop = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.inst_no_drop = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.inst_custom_data = row[7] ? row[7] : ""; e.inst_custom_data = row[7] ? row[7] : "";
e.ornament_icon = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.ornament_icon = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.ornament_id_file = static_cast<uint32_t>(strtoul(row[9], nullptr, 10)); e.ornament_id_file = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.ornament_hero_model = static_cast<int32_t>(atoi(row[10])); e.ornament_hero_model = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
e.augment_1 = static_cast<uint32_t>(strtoul(row[11], nullptr, 10)); e.augment_1 = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.augment_2 = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.augment_2 = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.augment_3 = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.augment_3 = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.augment_4 = static_cast<uint32_t>(strtoul(row[14], nullptr, 10)); e.augment_4 = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.augment_5 = static_cast<uint32_t>(strtoul(row[15], nullptr, 10)); e.augment_5 = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.augment_6 = static_cast<uint32_t>(strtoul(row[16], nullptr, 10)); e.augment_6 = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -402,23 +403,23 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotInventories e{}; BotInventories e{};
e.inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.bot_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.slot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.slot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.inst_charges = static_cast<uint16_t>(strtoul(row[4], nullptr, 10)); e.inst_charges = row[4] ? static_cast<uint16_t>(strtoul(row[4], nullptr, 10)) : 0;
e.inst_color = static_cast<uint32_t>(strtoul(row[5], nullptr, 10)); e.inst_color = row[5] ? static_cast<uint32_t>(strtoul(row[5], nullptr, 10)) : 0;
e.inst_no_drop = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.inst_no_drop = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.inst_custom_data = row[7] ? row[7] : ""; e.inst_custom_data = row[7] ? row[7] : "";
e.ornament_icon = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.ornament_icon = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
e.ornament_id_file = static_cast<uint32_t>(strtoul(row[9], nullptr, 10)); e.ornament_id_file = row[9] ? static_cast<uint32_t>(strtoul(row[9], nullptr, 10)) : 0;
e.ornament_hero_model = static_cast<int32_t>(atoi(row[10])); e.ornament_hero_model = row[10] ? static_cast<int32_t>(atoi(row[10])) : 0;
e.augment_1 = static_cast<uint32_t>(strtoul(row[11], nullptr, 10)); e.augment_1 = row[11] ? static_cast<uint32_t>(strtoul(row[11], nullptr, 10)) : 0;
e.augment_2 = static_cast<uint32_t>(strtoul(row[12], nullptr, 10)); e.augment_2 = row[12] ? static_cast<uint32_t>(strtoul(row[12], nullptr, 10)) : 0;
e.augment_3 = static_cast<uint32_t>(strtoul(row[13], nullptr, 10)); e.augment_3 = row[13] ? static_cast<uint32_t>(strtoul(row[13], nullptr, 10)) : 0;
e.augment_4 = static_cast<uint32_t>(strtoul(row[14], nullptr, 10)); e.augment_4 = row[14] ? static_cast<uint32_t>(strtoul(row[14], nullptr, 10)) : 0;
e.augment_5 = static_cast<uint32_t>(strtoul(row[15], nullptr, 10)); e.augment_5 = row[15] ? static_cast<uint32_t>(strtoul(row[15], nullptr, 10)) : 0;
e.augment_6 = static_cast<uint32_t>(strtoul(row[16], nullptr, 10)); e.augment_6 = row[16] ? static_cast<uint32_t>(strtoul(row[16], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -477,6 +478,94 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotInventories &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.inventories_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.inst_charges));
v.push_back(std::to_string(e.inst_color));
v.push_back(std::to_string(e.inst_no_drop));
v.push_back("'" + Strings::Escape(e.inst_custom_data) + "'");
v.push_back(std::to_string(e.ornament_icon));
v.push_back(std::to_string(e.ornament_id_file));
v.push_back(std::to_string(e.ornament_hero_model));
v.push_back(std::to_string(e.augment_1));
v.push_back(std::to_string(e.augment_2));
v.push_back(std::to_string(e.augment_3));
v.push_back(std::to_string(e.augment_4));
v.push_back(std::to_string(e.augment_5));
v.push_back(std::to_string(e.augment_6));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotInventories> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.inventories_index));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.inst_charges));
v.push_back(std::to_string(e.inst_color));
v.push_back(std::to_string(e.inst_no_drop));
v.push_back("'" + Strings::Escape(e.inst_custom_data) + "'");
v.push_back(std::to_string(e.ornament_icon));
v.push_back(std::to_string(e.ornament_id_file));
v.push_back(std::to_string(e.ornament_hero_model));
v.push_back(std::to_string(e.augment_1));
v.push_back(std::to_string(e.augment_2));
v.push_back(std::to_string(e.augment_3));
v.push_back(std::to_string(e.augment_4));
v.push_back(std::to_string(e.augment_5));
v.push_back(std::to_string(e.augment_6));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_INVENTORIES_REPOSITORY_H #endif //EQEMU_BASE_BOT_INVENTORIES_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_OWNER_OPTIONS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_OWNER_OPTIONS_REPOSITORY_H
@ -112,8 +112,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_owner_options_id bot_owner_options_id
) )
); );
@ -122,9 +123,9 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotOwnerOptions e{}; BotOwnerOptions e{};
e.owner_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.owner_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.option_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10)); e.option_type = row[1] ? static_cast<uint16_t>(strtoul(row[1], nullptr, 10)) : 0;
e.option_value = static_cast<uint16_t>(strtoul(row[2], nullptr, 10)); e.option_value = row[2] ? static_cast<uint16_t>(strtoul(row[2], nullptr, 10)) : 0;
return e; return e;
} }
@ -250,9 +251,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotOwnerOptions e{}; BotOwnerOptions e{};
e.owner_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.owner_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.option_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10)); e.option_type = row[1] ? static_cast<uint16_t>(strtoul(row[1], nullptr, 10)) : 0;
e.option_value = static_cast<uint16_t>(strtoul(row[2], nullptr, 10)); e.option_value = row[2] ? static_cast<uint16_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -277,9 +278,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotOwnerOptions e{}; BotOwnerOptions e{};
e.owner_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.owner_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.option_type = static_cast<uint16_t>(strtoul(row[1], nullptr, 10)); e.option_type = row[1] ? static_cast<uint16_t>(strtoul(row[1], nullptr, 10)) : 0;
e.option_value = static_cast<uint16_t>(strtoul(row[2], nullptr, 10)); e.option_value = row[2] ? static_cast<uint16_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -338,6 +339,66 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotOwnerOptions &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.owner_id));
v.push_back(std::to_string(e.option_type));
v.push_back(std::to_string(e.option_value));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotOwnerOptions> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.owner_id));
v.push_back(std::to_string(e.option_type));
v.push_back(std::to_string(e.option_value));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_OWNER_OPTIONS_REPOSITORY_H #endif //EQEMU_BASE_BOT_OWNER_OPTIONS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_PET_BUFFS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_PET_BUFFS_REPOSITORY_H
@ -120,8 +120,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_pet_buffs_id bot_pet_buffs_id
) )
); );
@ -130,11 +131,11 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotPetBuffs e{}; BotPetBuffs e{};
e.pet_buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pet_buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.caster_level = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.duration = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
return e; return e;
} }
@ -265,11 +266,11 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotPetBuffs e{}; BotPetBuffs e{};
e.pet_buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pet_buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.caster_level = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.duration = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -294,11 +295,11 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotPetBuffs e{}; BotPetBuffs e{};
e.pet_buffs_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pet_buffs_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.spell_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.caster_level = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.caster_level = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.duration = static_cast<uint32_t>(strtoul(row[4], nullptr, 10)); e.duration = row[4] ? static_cast<uint32_t>(strtoul(row[4], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -357,6 +358,70 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotPetBuffs &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.pet_buffs_index));
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back(std::to_string(e.duration));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotPetBuffs> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.pet_buffs_index));
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.caster_level));
v.push_back(std::to_string(e.duration));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_PET_BUFFS_REPOSITORY_H #endif //EQEMU_BASE_BOT_PET_BUFFS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_PET_INVENTORIES_REPOSITORY_H #ifndef EQEMU_BASE_BOT_PET_INVENTORIES_REPOSITORY_H
@ -112,8 +112,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_pet_inventories_id bot_pet_inventories_id
) )
); );
@ -122,9 +123,9 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotPetInventories e{}; BotPetInventories e{};
e.pet_inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pet_inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
return e; return e;
} }
@ -249,9 +250,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotPetInventories e{}; BotPetInventories e{};
e.pet_inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pet_inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -276,9 +277,9 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotPetInventories e{}; BotPetInventories e{};
e.pet_inventories_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pet_inventories_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.pets_index = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.pets_index = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.item_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -337,6 +338,66 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotPetInventories &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.pet_inventories_index));
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.item_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotPetInventories> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.pet_inventories_index));
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.item_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_PET_INVENTORIES_REPOSITORY_H #endif //EQEMU_BASE_BOT_PET_INVENTORIES_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_PETS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_PETS_REPOSITORY_H
@ -124,8 +124,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_pets_id bot_pets_id
) )
); );
@ -134,12 +135,12 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotPets e{}; BotPets e{};
e.pets_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pets_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.spell_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : ""; e.name = row[3] ? row[3] : "";
e.mana = static_cast<int32_t>(atoi(row[4])); e.mana = row[4] ? static_cast<int32_t>(atoi(row[4])) : 0;
e.hp = static_cast<int32_t>(atoi(row[5])); e.hp = row[5] ? static_cast<int32_t>(atoi(row[5])) : 0;
return e; return e;
} }
@ -273,12 +274,12 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotPets e{}; BotPets e{};
e.pets_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pets_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.spell_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : ""; e.name = row[3] ? row[3] : "";
e.mana = static_cast<int32_t>(atoi(row[4])); e.mana = row[4] ? static_cast<int32_t>(atoi(row[4])) : 0;
e.hp = static_cast<int32_t>(atoi(row[5])); e.hp = row[5] ? static_cast<int32_t>(atoi(row[5])) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -303,12 +304,12 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotPets e{}; BotPets e{};
e.pets_index = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.pets_index = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.spell_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.bot_id = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.bot_id = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.name = row[3] ? row[3] : ""; e.name = row[3] ? row[3] : "";
e.mana = static_cast<int32_t>(atoi(row[4])); e.mana = row[4] ? static_cast<int32_t>(atoi(row[4])) : 0;
e.hp = static_cast<int32_t>(atoi(row[5])); e.hp = row[5] ? static_cast<int32_t>(atoi(row[5])) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -367,6 +368,72 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotPets &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.bot_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.hp));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotPets> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.pets_index));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.bot_id));
v.push_back("'" + Strings::Escape(e.name) + "'");
v.push_back(std::to_string(e.mana));
v.push_back(std::to_string(e.hp));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_PETS_REPOSITORY_H #endif //EQEMU_BASE_BOT_PETS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_SPELL_CASTING_CHANCES_REPOSITORY_H #ifndef EQEMU_BASE_BOT_SPELL_CASTING_CHANCES_REPOSITORY_H
@ -180,8 +180,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_spell_casting_chances_id bot_spell_casting_chances_id
) )
); );
@ -190,26 +191,26 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotSpellCastingChances e{}; BotSpellCastingChances e{};
e.id = static_cast<int32_t>(atoi(row[0])); e.id = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.spell_type_index = static_cast<uint8_t>(strtoul(row[1], nullptr, 10)); e.spell_type_index = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
e.class_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10)); e.class_id = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
e.stance_index = static_cast<uint8_t>(strtoul(row[3], nullptr, 10)); e.stance_index = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.nHSND_value = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.nHSND_value = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.pH_value = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.pH_value = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.pS_value = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.pS_value = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.pHS_value = static_cast<uint8_t>(strtoul(row[7], nullptr, 10)); e.pHS_value = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.pN_value = static_cast<uint8_t>(strtoul(row[8], nullptr, 10)); e.pN_value = row[8] ? static_cast<uint8_t>(strtoul(row[8], nullptr, 10)) : 0;
e.pHN_value = static_cast<uint8_t>(strtoul(row[9], nullptr, 10)); e.pHN_value = row[9] ? static_cast<uint8_t>(strtoul(row[9], nullptr, 10)) : 0;
e.pSN_value = static_cast<uint8_t>(strtoul(row[10], nullptr, 10)); e.pSN_value = row[10] ? static_cast<uint8_t>(strtoul(row[10], nullptr, 10)) : 0;
e.pHSN_value = static_cast<uint8_t>(strtoul(row[11], nullptr, 10)); e.pHSN_value = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.pD_value = static_cast<uint8_t>(strtoul(row[12], nullptr, 10)); e.pD_value = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
e.pHD_value = static_cast<uint8_t>(strtoul(row[13], nullptr, 10)); e.pHD_value = row[13] ? static_cast<uint8_t>(strtoul(row[13], nullptr, 10)) : 0;
e.pSD_value = static_cast<uint8_t>(strtoul(row[14], nullptr, 10)); e.pSD_value = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
e.pHSD_value = static_cast<uint8_t>(strtoul(row[15], nullptr, 10)); e.pHSD_value = row[15] ? static_cast<uint8_t>(strtoul(row[15], nullptr, 10)) : 0;
e.pND_value = static_cast<uint8_t>(strtoul(row[16], nullptr, 10)); e.pND_value = row[16] ? static_cast<uint8_t>(strtoul(row[16], nullptr, 10)) : 0;
e.pHND_value = static_cast<uint8_t>(strtoul(row[17], nullptr, 10)); e.pHND_value = row[17] ? static_cast<uint8_t>(strtoul(row[17], nullptr, 10)) : 0;
e.pSND_value = static_cast<uint8_t>(strtoul(row[18], nullptr, 10)); e.pSND_value = row[18] ? static_cast<uint8_t>(strtoul(row[18], nullptr, 10)) : 0;
e.pHSND_value = static_cast<uint8_t>(strtoul(row[19], nullptr, 10)); e.pHSND_value = row[19] ? static_cast<uint8_t>(strtoul(row[19], nullptr, 10)) : 0;
return e; return e;
} }
@ -385,26 +386,26 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellCastingChances e{}; BotSpellCastingChances e{};
e.id = static_cast<int32_t>(atoi(row[0])); e.id = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.spell_type_index = static_cast<uint8_t>(strtoul(row[1], nullptr, 10)); e.spell_type_index = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
e.class_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10)); e.class_id = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
e.stance_index = static_cast<uint8_t>(strtoul(row[3], nullptr, 10)); e.stance_index = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.nHSND_value = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.nHSND_value = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.pH_value = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.pH_value = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.pS_value = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.pS_value = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.pHS_value = static_cast<uint8_t>(strtoul(row[7], nullptr, 10)); e.pHS_value = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.pN_value = static_cast<uint8_t>(strtoul(row[8], nullptr, 10)); e.pN_value = row[8] ? static_cast<uint8_t>(strtoul(row[8], nullptr, 10)) : 0;
e.pHN_value = static_cast<uint8_t>(strtoul(row[9], nullptr, 10)); e.pHN_value = row[9] ? static_cast<uint8_t>(strtoul(row[9], nullptr, 10)) : 0;
e.pSN_value = static_cast<uint8_t>(strtoul(row[10], nullptr, 10)); e.pSN_value = row[10] ? static_cast<uint8_t>(strtoul(row[10], nullptr, 10)) : 0;
e.pHSN_value = static_cast<uint8_t>(strtoul(row[11], nullptr, 10)); e.pHSN_value = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.pD_value = static_cast<uint8_t>(strtoul(row[12], nullptr, 10)); e.pD_value = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
e.pHD_value = static_cast<uint8_t>(strtoul(row[13], nullptr, 10)); e.pHD_value = row[13] ? static_cast<uint8_t>(strtoul(row[13], nullptr, 10)) : 0;
e.pSD_value = static_cast<uint8_t>(strtoul(row[14], nullptr, 10)); e.pSD_value = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
e.pHSD_value = static_cast<uint8_t>(strtoul(row[15], nullptr, 10)); e.pHSD_value = row[15] ? static_cast<uint8_t>(strtoul(row[15], nullptr, 10)) : 0;
e.pND_value = static_cast<uint8_t>(strtoul(row[16], nullptr, 10)); e.pND_value = row[16] ? static_cast<uint8_t>(strtoul(row[16], nullptr, 10)) : 0;
e.pHND_value = static_cast<uint8_t>(strtoul(row[17], nullptr, 10)); e.pHND_value = row[17] ? static_cast<uint8_t>(strtoul(row[17], nullptr, 10)) : 0;
e.pSND_value = static_cast<uint8_t>(strtoul(row[18], nullptr, 10)); e.pSND_value = row[18] ? static_cast<uint8_t>(strtoul(row[18], nullptr, 10)) : 0;
e.pHSND_value = static_cast<uint8_t>(strtoul(row[19], nullptr, 10)); e.pHSND_value = row[19] ? static_cast<uint8_t>(strtoul(row[19], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -429,26 +430,26 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellCastingChances e{}; BotSpellCastingChances e{};
e.id = static_cast<int32_t>(atoi(row[0])); e.id = row[0] ? static_cast<int32_t>(atoi(row[0])) : 0;
e.spell_type_index = static_cast<uint8_t>(strtoul(row[1], nullptr, 10)); e.spell_type_index = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
e.class_id = static_cast<uint8_t>(strtoul(row[2], nullptr, 10)); e.class_id = row[2] ? static_cast<uint8_t>(strtoul(row[2], nullptr, 10)) : 0;
e.stance_index = static_cast<uint8_t>(strtoul(row[3], nullptr, 10)); e.stance_index = row[3] ? static_cast<uint8_t>(strtoul(row[3], nullptr, 10)) : 0;
e.nHSND_value = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.nHSND_value = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.pH_value = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.pH_value = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.pS_value = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.pS_value = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 0;
e.pHS_value = static_cast<uint8_t>(strtoul(row[7], nullptr, 10)); e.pHS_value = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.pN_value = static_cast<uint8_t>(strtoul(row[8], nullptr, 10)); e.pN_value = row[8] ? static_cast<uint8_t>(strtoul(row[8], nullptr, 10)) : 0;
e.pHN_value = static_cast<uint8_t>(strtoul(row[9], nullptr, 10)); e.pHN_value = row[9] ? static_cast<uint8_t>(strtoul(row[9], nullptr, 10)) : 0;
e.pSN_value = static_cast<uint8_t>(strtoul(row[10], nullptr, 10)); e.pSN_value = row[10] ? static_cast<uint8_t>(strtoul(row[10], nullptr, 10)) : 0;
e.pHSN_value = static_cast<uint8_t>(strtoul(row[11], nullptr, 10)); e.pHSN_value = row[11] ? static_cast<uint8_t>(strtoul(row[11], nullptr, 10)) : 0;
e.pD_value = static_cast<uint8_t>(strtoul(row[12], nullptr, 10)); e.pD_value = row[12] ? static_cast<uint8_t>(strtoul(row[12], nullptr, 10)) : 0;
e.pHD_value = static_cast<uint8_t>(strtoul(row[13], nullptr, 10)); e.pHD_value = row[13] ? static_cast<uint8_t>(strtoul(row[13], nullptr, 10)) : 0;
e.pSD_value = static_cast<uint8_t>(strtoul(row[14], nullptr, 10)); e.pSD_value = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
e.pHSD_value = static_cast<uint8_t>(strtoul(row[15], nullptr, 10)); e.pHSD_value = row[15] ? static_cast<uint8_t>(strtoul(row[15], nullptr, 10)) : 0;
e.pND_value = static_cast<uint8_t>(strtoul(row[16], nullptr, 10)); e.pND_value = row[16] ? static_cast<uint8_t>(strtoul(row[16], nullptr, 10)) : 0;
e.pHND_value = static_cast<uint8_t>(strtoul(row[17], nullptr, 10)); e.pHND_value = row[17] ? static_cast<uint8_t>(strtoul(row[17], nullptr, 10)) : 0;
e.pSND_value = static_cast<uint8_t>(strtoul(row[18], nullptr, 10)); e.pSND_value = row[18] ? static_cast<uint8_t>(strtoul(row[18], nullptr, 10)) : 0;
e.pHSND_value = static_cast<uint8_t>(strtoul(row[19], nullptr, 10)); e.pHSND_value = row[19] ? static_cast<uint8_t>(strtoul(row[19], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -507,6 +508,100 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotSpellCastingChances &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.spell_type_index));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.stance_index));
v.push_back(std::to_string(e.nHSND_value));
v.push_back(std::to_string(e.pH_value));
v.push_back(std::to_string(e.pS_value));
v.push_back(std::to_string(e.pHS_value));
v.push_back(std::to_string(e.pN_value));
v.push_back(std::to_string(e.pHN_value));
v.push_back(std::to_string(e.pSN_value));
v.push_back(std::to_string(e.pHSN_value));
v.push_back(std::to_string(e.pD_value));
v.push_back(std::to_string(e.pHD_value));
v.push_back(std::to_string(e.pSD_value));
v.push_back(std::to_string(e.pHSD_value));
v.push_back(std::to_string(e.pND_value));
v.push_back(std::to_string(e.pHND_value));
v.push_back(std::to_string(e.pSND_value));
v.push_back(std::to_string(e.pHSND_value));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotSpellCastingChances> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.spell_type_index));
v.push_back(std::to_string(e.class_id));
v.push_back(std::to_string(e.stance_index));
v.push_back(std::to_string(e.nHSND_value));
v.push_back(std::to_string(e.pH_value));
v.push_back(std::to_string(e.pS_value));
v.push_back(std::to_string(e.pHS_value));
v.push_back(std::to_string(e.pN_value));
v.push_back(std::to_string(e.pHN_value));
v.push_back(std::to_string(e.pSN_value));
v.push_back(std::to_string(e.pHSN_value));
v.push_back(std::to_string(e.pD_value));
v.push_back(std::to_string(e.pHD_value));
v.push_back(std::to_string(e.pSD_value));
v.push_back(std::to_string(e.pHSD_value));
v.push_back(std::to_string(e.pND_value));
v.push_back(std::to_string(e.pHND_value));
v.push_back(std::to_string(e.pSND_value));
v.push_back(std::to_string(e.pHSND_value));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_SPELL_CASTING_CHANCES_REPOSITORY_H #endif //EQEMU_BASE_BOT_SPELL_CASTING_CHANCES_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_SPELL_SETTINGS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_SPELL_SETTINGS_REPOSITORY_H
@ -128,8 +128,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_spell_settings_id bot_spell_settings_id
) )
); );
@ -138,13 +139,13 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotSpellSettings e{}; BotSpellSettings e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<int32_t>(atoi(row[1])); e.bot_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spell_id = static_cast<int16_t>(atoi(row[2])); e.spell_id = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.priority = static_cast<int16_t>(atoi(row[3])); e.priority = row[3] ? static_cast<int16_t>(atoi(row[3])) : 0;
e.min_hp = static_cast<int16_t>(atoi(row[4])); e.min_hp = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
e.max_hp = static_cast<int16_t>(atoi(row[5])); e.max_hp = row[5] ? static_cast<int16_t>(atoi(row[5])) : 0;
e.is_enabled = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.is_enabled = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 1;
return e; return e;
} }
@ -281,13 +282,13 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellSettings e{}; BotSpellSettings e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<int32_t>(atoi(row[1])); e.bot_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spell_id = static_cast<int16_t>(atoi(row[2])); e.spell_id = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.priority = static_cast<int16_t>(atoi(row[3])); e.priority = row[3] ? static_cast<int16_t>(atoi(row[3])) : 0;
e.min_hp = static_cast<int16_t>(atoi(row[4])); e.min_hp = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
e.max_hp = static_cast<int16_t>(atoi(row[5])); e.max_hp = row[5] ? static_cast<int16_t>(atoi(row[5])) : 0;
e.is_enabled = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.is_enabled = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 1;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -312,13 +313,13 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellSettings e{}; BotSpellSettings e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.bot_id = static_cast<int32_t>(atoi(row[1])); e.bot_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spell_id = static_cast<int16_t>(atoi(row[2])); e.spell_id = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.priority = static_cast<int16_t>(atoi(row[3])); e.priority = row[3] ? static_cast<int16_t>(atoi(row[3])) : 0;
e.min_hp = static_cast<int16_t>(atoi(row[4])); e.min_hp = row[4] ? static_cast<int16_t>(atoi(row[4])) : 0;
e.max_hp = static_cast<int16_t>(atoi(row[5])); e.max_hp = row[5] ? static_cast<int16_t>(atoi(row[5])) : 0;
e.is_enabled = static_cast<uint8_t>(strtoul(row[6], nullptr, 10)); e.is_enabled = row[6] ? static_cast<uint8_t>(strtoul(row[6], nullptr, 10)) : 1;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -377,6 +378,74 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotSpellSettings &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.priority));
v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp));
v.push_back(std::to_string(e.is_enabled));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotSpellSettings> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.priority));
v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp));
v.push_back(std::to_string(e.is_enabled));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_SPELL_SETTINGS_REPOSITORY_H #endif //EQEMU_BASE_BOT_SPELL_SETTINGS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_SPELLS_ENTRIES_REPOSITORY_H #ifndef EQEMU_BASE_BOT_SPELLS_ENTRIES_REPOSITORY_H
@ -160,8 +160,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_spells_entries_id bot_spells_entries_id
) )
); );
@ -170,21 +171,21 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotSpellsEntries e{}; BotSpellsEntries e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.npc_spells_id = static_cast<int32_t>(atoi(row[1])); e.npc_spells_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spellid = static_cast<int16_t>(atoi(row[2])); e.spellid = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.type = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.minlevel = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.minlevel = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.maxlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.maxlevel = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 255;
e.manacost = static_cast<int16_t>(atoi(row[6])); e.manacost = row[6] ? static_cast<int16_t>(atoi(row[6])) : -1;
e.recast_delay = static_cast<int32_t>(atoi(row[7])); e.recast_delay = row[7] ? static_cast<int32_t>(atoi(row[7])) : -1;
e.priority = static_cast<int16_t>(atoi(row[8])); e.priority = row[8] ? static_cast<int16_t>(atoi(row[8])) : 0;
e.resist_adjust = static_cast<int32_t>(atoi(row[9])); e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = static_cast<int16_t>(atoi(row[10])); e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = static_cast<int16_t>(atoi(row[11])); e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.bucket_name = row[12] ? row[12] : ""; e.bucket_name = row[12] ? row[12] : "";
e.bucket_value = row[13] ? row[13] : ""; e.bucket_value = row[13] ? row[13] : "";
e.bucket_comparison = static_cast<uint8_t>(strtoul(row[14], nullptr, 10)); e.bucket_comparison = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
return e; return e;
} }
@ -345,21 +346,21 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellsEntries e{}; BotSpellsEntries e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.npc_spells_id = static_cast<int32_t>(atoi(row[1])); e.npc_spells_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spellid = static_cast<int16_t>(atoi(row[2])); e.spellid = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.type = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.minlevel = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.minlevel = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.maxlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.maxlevel = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 255;
e.manacost = static_cast<int16_t>(atoi(row[6])); e.manacost = row[6] ? static_cast<int16_t>(atoi(row[6])) : -1;
e.recast_delay = static_cast<int32_t>(atoi(row[7])); e.recast_delay = row[7] ? static_cast<int32_t>(atoi(row[7])) : -1;
e.priority = static_cast<int16_t>(atoi(row[8])); e.priority = row[8] ? static_cast<int16_t>(atoi(row[8])) : 0;
e.resist_adjust = static_cast<int32_t>(atoi(row[9])); e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = static_cast<int16_t>(atoi(row[10])); e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = static_cast<int16_t>(atoi(row[11])); e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.bucket_name = row[12] ? row[12] : ""; e.bucket_name = row[12] ? row[12] : "";
e.bucket_value = row[13] ? row[13] : ""; e.bucket_value = row[13] ? row[13] : "";
e.bucket_comparison = static_cast<uint8_t>(strtoul(row[14], nullptr, 10)); e.bucket_comparison = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -384,21 +385,21 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotSpellsEntries e{}; BotSpellsEntries e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.npc_spells_id = static_cast<int32_t>(atoi(row[1])); e.npc_spells_id = row[1] ? static_cast<int32_t>(atoi(row[1])) : 0;
e.spellid = static_cast<int16_t>(atoi(row[2])); e.spellid = row[2] ? static_cast<int16_t>(atoi(row[2])) : 0;
e.type = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.type = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.minlevel = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.minlevel = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.maxlevel = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.maxlevel = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 255;
e.manacost = static_cast<int16_t>(atoi(row[6])); e.manacost = row[6] ? static_cast<int16_t>(atoi(row[6])) : -1;
e.recast_delay = static_cast<int32_t>(atoi(row[7])); e.recast_delay = row[7] ? static_cast<int32_t>(atoi(row[7])) : -1;
e.priority = static_cast<int16_t>(atoi(row[8])); e.priority = row[8] ? static_cast<int16_t>(atoi(row[8])) : 0;
e.resist_adjust = static_cast<int32_t>(atoi(row[9])); e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = static_cast<int16_t>(atoi(row[10])); e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = static_cast<int16_t>(atoi(row[11])); e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.bucket_name = row[12] ? row[12] : ""; e.bucket_name = row[12] ? row[12] : "";
e.bucket_value = row[13] ? row[13] : ""; e.bucket_value = row[13] ? row[13] : "";
e.bucket_comparison = static_cast<uint8_t>(strtoul(row[14], nullptr, 10)); e.bucket_comparison = row[14] ? static_cast<uint8_t>(strtoul(row[14], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -457,6 +458,90 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotSpellsEntries &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.npc_spells_id));
v.push_back(std::to_string(e.spellid));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.manacost));
v.push_back(std::to_string(e.recast_delay));
v.push_back(std::to_string(e.priority));
v.push_back(std::to_string(e.resist_adjust));
v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp));
v.push_back("'" + Strings::Escape(e.bucket_name) + "'");
v.push_back("'" + Strings::Escape(e.bucket_value) + "'");
v.push_back(std::to_string(e.bucket_comparison));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotSpellsEntries> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.npc_spells_id));
v.push_back(std::to_string(e.spellid));
v.push_back(std::to_string(e.type));
v.push_back(std::to_string(e.minlevel));
v.push_back(std::to_string(e.maxlevel));
v.push_back(std::to_string(e.manacost));
v.push_back(std::to_string(e.recast_delay));
v.push_back(std::to_string(e.priority));
v.push_back(std::to_string(e.resist_adjust));
v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp));
v.push_back("'" + Strings::Escape(e.bucket_name) + "'");
v.push_back("'" + Strings::Escape(e.bucket_value) + "'");
v.push_back(std::to_string(e.bucket_comparison));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_SPELLS_ENTRIES_REPOSITORY_H #endif //EQEMU_BASE_BOT_SPELLS_ENTRIES_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_STANCES_REPOSITORY_H #ifndef EQEMU_BASE_BOT_STANCES_REPOSITORY_H
@ -108,8 +108,9 @@ public:
{ {
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
"{} WHERE id = {} LIMIT 1", "{} WHERE {} = {} LIMIT 1",
BaseSelect(), BaseSelect(),
PrimaryKey(),
bot_stances_id bot_stances_id
) )
); );
@ -118,8 +119,8 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotStances e{}; BotStances e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.stance_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10)); e.stance_id = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
return e; return e;
} }
@ -242,8 +243,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotStances e{}; BotStances e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.stance_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10)); e.stance_id = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -268,8 +269,8 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotStances e{}; BotStances e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.stance_id = static_cast<uint8_t>(strtoul(row[1], nullptr, 10)); e.stance_id = row[1] ? static_cast<uint8_t>(strtoul(row[1], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -328,6 +329,64 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotStances &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.stance_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotStances> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.stance_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_STANCES_REPOSITORY_H #endif //EQEMU_BASE_BOT_STANCES_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_STARTING_ITEMS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_STARTING_ITEMS_REPOSITORY_H
@ -16,7 +16,6 @@
#include "../../strings.h" #include "../../strings.h"
#include <ctime> #include <ctime>
class BaseBotStartingItemsRepository { class BaseBotStartingItemsRepository {
public: public:
struct BotStartingItems { struct BotStartingItems {
@ -25,6 +24,7 @@ public:
uint32_t classes; uint32_t classes;
uint32_t item_id; uint32_t item_id;
uint8_t item_charges; uint8_t item_charges;
uint8_t min_status;
int32_t slot_id; int32_t slot_id;
int8_t min_expansion; int8_t min_expansion;
int8_t max_expansion; int8_t max_expansion;
@ -45,6 +45,7 @@ public:
"classes", "classes",
"item_id", "item_id",
"item_charges", "item_charges",
"min_status",
"slot_id", "slot_id",
"min_expansion", "min_expansion",
"max_expansion", "max_expansion",
@ -61,6 +62,7 @@ public:
"classes", "classes",
"item_id", "item_id",
"item_charges", "item_charges",
"min_status",
"slot_id", "slot_id",
"min_expansion", "min_expansion",
"max_expansion", "max_expansion",
@ -111,6 +113,7 @@ public:
e.classes = 0; e.classes = 0;
e.item_id = 0; e.item_id = 0;
e.item_charges = 1; e.item_charges = 1;
e.min_status = 0;
e.slot_id = -1; e.slot_id = -1;
e.min_expansion = -1; e.min_expansion = -1;
e.max_expansion = -1; e.max_expansion = -1;
@ -152,16 +155,17 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotStartingItems e{}; BotStartingItems e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.races = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.races = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.classes = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.classes = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.item_charges = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.item_charges = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 1;
e.slot_id = static_cast<int32_t>(atoi(row[5])); e.min_status = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.min_expansion = static_cast<int8_t>(atoi(row[6])); e.slot_id = row[6] ? static_cast<int32_t>(atoi(row[6])) : -1;
e.max_expansion = static_cast<int8_t>(atoi(row[7])); e.min_expansion = row[7] ? static_cast<int8_t>(atoi(row[7])) : -1;
e.content_flags = row[8] ? row[8] : ""; e.max_expansion = row[8] ? static_cast<int8_t>(atoi(row[8])) : -1;
e.content_flags_disabled = row[9] ? row[9] : ""; e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
return e; return e;
} }
@ -199,11 +203,12 @@ public:
v.push_back(columns[2] + " = " + std::to_string(e.classes)); v.push_back(columns[2] + " = " + std::to_string(e.classes));
v.push_back(columns[3] + " = " + std::to_string(e.item_id)); v.push_back(columns[3] + " = " + std::to_string(e.item_id));
v.push_back(columns[4] + " = " + std::to_string(e.item_charges)); v.push_back(columns[4] + " = " + std::to_string(e.item_charges));
v.push_back(columns[5] + " = " + std::to_string(e.slot_id)); v.push_back(columns[5] + " = " + std::to_string(e.min_status));
v.push_back(columns[6] + " = " + std::to_string(e.min_expansion)); v.push_back(columns[6] + " = " + std::to_string(e.slot_id));
v.push_back(columns[7] + " = " + std::to_string(e.max_expansion)); v.push_back(columns[7] + " = " + std::to_string(e.min_expansion));
v.push_back(columns[8] + " = '" + Strings::Escape(e.content_flags) + "'"); v.push_back(columns[8] + " = " + std::to_string(e.max_expansion));
v.push_back(columns[9] + " = '" + Strings::Escape(e.content_flags_disabled) + "'"); v.push_back(columns[9] + " = '" + Strings::Escape(e.content_flags) + "'");
v.push_back(columns[10] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
@ -230,6 +235,7 @@ public:
v.push_back(std::to_string(e.classes)); v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.item_id)); v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_charges)); v.push_back(std::to_string(e.item_charges));
v.push_back(std::to_string(e.min_status));
v.push_back(std::to_string(e.slot_id)); v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.min_expansion)); v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion)); v.push_back(std::to_string(e.max_expansion));
@ -269,6 +275,7 @@ public:
v.push_back(std::to_string(e.classes)); v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.item_id)); v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_charges)); v.push_back(std::to_string(e.item_charges));
v.push_back(std::to_string(e.min_status));
v.push_back(std::to_string(e.slot_id)); v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.min_expansion)); v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion)); v.push_back(std::to_string(e.max_expansion));
@ -307,16 +314,17 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotStartingItems e{}; BotStartingItems e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.races = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.races = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.classes = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.classes = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.item_charges = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.item_charges = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 1;
e.slot_id = static_cast<int32_t>(atoi(row[5])); e.min_status = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.min_expansion = static_cast<int8_t>(atoi(row[6])); e.slot_id = row[6] ? static_cast<int32_t>(atoi(row[6])) : -1;
e.max_expansion = static_cast<int8_t>(atoi(row[7])); e.min_expansion = row[7] ? static_cast<int8_t>(atoi(row[7])) : -1;
e.content_flags = row[8] ? row[8] : ""; e.max_expansion = row[8] ? static_cast<int8_t>(atoi(row[8])) : -1;
e.content_flags_disabled = row[9] ? row[9] : ""; e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -341,16 +349,17 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotStartingItems e{}; BotStartingItems e{};
e.id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.races = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.races = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.classes = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.classes = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.item_id = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.item_charges = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.item_charges = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 1;
e.slot_id = static_cast<int32_t>(atoi(row[5])); e.min_status = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.min_expansion = static_cast<int8_t>(atoi(row[6])); e.slot_id = row[6] ? static_cast<int32_t>(atoi(row[6])) : -1;
e.max_expansion = static_cast<int8_t>(atoi(row[7])); e.min_expansion = row[7] ? static_cast<int8_t>(atoi(row[7])) : -1;
e.content_flags = row[8] ? row[8] : ""; e.max_expansion = row[8] ? static_cast<int8_t>(atoi(row[8])) : -1;
e.content_flags_disabled = row[9] ? row[9] : ""; e.content_flags = row[9] ? row[9] : "";
e.content_flags_disabled = row[10] ? row[10] : "";
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -409,6 +418,82 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotStartingItems &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.races));
v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_charges));
v.push_back(std::to_string(e.min_status));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotStartingItems> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.id));
v.push_back(std::to_string(e.races));
v.push_back(std::to_string(e.classes));
v.push_back(std::to_string(e.item_id));
v.push_back(std::to_string(e.item_charges));
v.push_back(std::to_string(e.min_status));
v.push_back(std::to_string(e.slot_id));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_STARTING_ITEMS_REPOSITORY_H #endif //EQEMU_BASE_BOT_STARTING_ITEMS_REPOSITORY_H

View File

@ -6,7 +6,7 @@
* Any modifications to base repositories are to be made by the generator only * Any modifications to base repositories are to be made by the generator only
* *
* @generator ./utils/scripts/generators/repository-generator.pl * @generator ./utils/scripts/generators/repository-generator.pl
* @docs https://eqemu.gitbook.io/server/in-development/developer-area/repositories * @docs https://docs.eqemu.io/developer/repositories
*/ */
#ifndef EQEMU_BASE_BOT_TIMERS_REPOSITORY_H #ifndef EQEMU_BASE_BOT_TIMERS_REPOSITORY_H
@ -16,7 +16,6 @@
#include "../../strings.h" #include "../../strings.h"
#include <ctime> #include <ctime>
class BaseBotTimersRepository { class BaseBotTimersRepository {
public: public:
struct BotTimers { struct BotTimers {
@ -148,15 +147,15 @@ public:
if (results.RowCount() == 1) { if (results.RowCount() == 1) {
BotTimers e{}; BotTimers e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.timer_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.timer_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.timer_value = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.timer_value = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.recast_time = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.recast_time = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.is_spell = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.is_spell = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.is_disc = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.is_disc = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10)); e.spell_id = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.is_item = static_cast<uint8_t>(strtoul(row[7], nullptr, 10)); e.is_item = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.item_id = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
return e; return e;
} }
@ -300,15 +299,15 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotTimers e{}; BotTimers e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.timer_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.timer_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.timer_value = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.timer_value = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.recast_time = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.recast_time = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.is_spell = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.is_spell = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.is_disc = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.is_disc = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10)); e.spell_id = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.is_item = static_cast<uint8_t>(strtoul(row[7], nullptr, 10)); e.is_item = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.item_id = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -333,15 +332,15 @@ public:
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row = results.begin(); row != results.end(); ++row) {
BotTimers e{}; BotTimers e{};
e.bot_id = static_cast<uint32_t>(strtoul(row[0], nullptr, 10)); e.bot_id = row[0] ? static_cast<uint32_t>(strtoul(row[0], nullptr, 10)) : 0;
e.timer_id = static_cast<uint32_t>(strtoul(row[1], nullptr, 10)); e.timer_id = row[1] ? static_cast<uint32_t>(strtoul(row[1], nullptr, 10)) : 0;
e.timer_value = static_cast<uint32_t>(strtoul(row[2], nullptr, 10)); e.timer_value = row[2] ? static_cast<uint32_t>(strtoul(row[2], nullptr, 10)) : 0;
e.recast_time = static_cast<uint32_t>(strtoul(row[3], nullptr, 10)); e.recast_time = row[3] ? static_cast<uint32_t>(strtoul(row[3], nullptr, 10)) : 0;
e.is_spell = static_cast<uint8_t>(strtoul(row[4], nullptr, 10)); e.is_spell = row[4] ? static_cast<uint8_t>(strtoul(row[4], nullptr, 10)) : 0;
e.is_disc = static_cast<uint8_t>(strtoul(row[5], nullptr, 10)); e.is_disc = row[5] ? static_cast<uint8_t>(strtoul(row[5], nullptr, 10)) : 0;
e.spell_id = static_cast<uint32_t>(strtoul(row[6], nullptr, 10)); e.spell_id = row[6] ? static_cast<uint32_t>(strtoul(row[6], nullptr, 10)) : 0;
e.is_item = static_cast<uint8_t>(strtoul(row[7], nullptr, 10)); e.is_item = row[7] ? static_cast<uint8_t>(strtoul(row[7], nullptr, 10)) : 0;
e.item_id = static_cast<uint32_t>(strtoul(row[8], nullptr, 10)); e.item_id = row[8] ? static_cast<uint32_t>(strtoul(row[8], nullptr, 10)) : 0;
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -400,6 +399,78 @@ public:
return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0); return (results.Success() && results.begin()[0] ? strtoll(results.begin()[0], nullptr, 10) : 0);
} }
static std::string BaseReplace()
{
return fmt::format(
"REPLACE INTO {} ({}) ",
TableName(),
ColumnsRaw()
);
}
static int ReplaceOne(
Database& db,
const BotTimers &e
)
{
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.timer_id));
v.push_back(std::to_string(e.timer_value));
v.push_back(std::to_string(e.recast_time));
v.push_back(std::to_string(e.is_spell));
v.push_back(std::to_string(e.is_disc));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.is_item));
v.push_back(std::to_string(e.item_id));
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES ({})",
BaseReplace(),
Strings::Implode(",", v)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
static int ReplaceMany(
Database& db,
const std::vector<BotTimers> &entries
)
{
std::vector<std::string> insert_chunks;
for (auto &e: entries) {
std::vector<std::string> v;
v.push_back(std::to_string(e.bot_id));
v.push_back(std::to_string(e.timer_id));
v.push_back(std::to_string(e.timer_value));
v.push_back(std::to_string(e.recast_time));
v.push_back(std::to_string(e.is_spell));
v.push_back(std::to_string(e.is_disc));
v.push_back(std::to_string(e.spell_id));
v.push_back(std::to_string(e.is_item));
v.push_back(std::to_string(e.item_id));
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
}
std::vector<std::string> v;
auto results = db.QueryDatabase(
fmt::format(
"{} VALUES {}",
BaseReplace(),
Strings::Implode(",", insert_chunks)
)
);
return (results.Success() ? results.RowsAffected() : 0);
}
}; };
#endif //EQEMU_BASE_BOT_TIMERS_REPOSITORY_H #endif //EQEMU_BASE_BOT_TIMERS_REPOSITORY_H

View File

@ -44,7 +44,46 @@ public:
*/ */
// Custom extended repository methods here // Custom extended repository methods here
static bool SaveAllHelmAppearances(Database& db, const uint32 owner_id, const bool show_flag)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `show_helm` = {} WHERE `owner_id` = {}",
TableName(),
show_flag ? 1 : 0,
owner_id
)
);
return results.Success();
}
static bool ToggleAllHelmAppearances(Database& db, const uint32 owner_id)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `show_helm` = (`show_helm` XOR '1') WHERE `owner_id` = {}",
TableName(),
owner_id
)
);
return results.Success();
}
static bool SaveAllFollowDistances(Database& db, const uint32 owner_id, const uint32 follow_distance)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `follow_distance` = {} WHERE `owner_id` = {}",
TableName(),
follow_distance,
owner_id
)
);
return results.Success();
}
}; };
#endif //EQEMU_BOT_DATA_REPOSITORY_H #endif //EQEMU_BOT_DATA_REPOSITORY_H

View File

@ -44,7 +44,36 @@ public:
*/ */
// Custom extended repository methods here // Custom extended repository methods here
static bool SaveAllInspectMessages(Database& db, const uint32 owner_id, const std::string& inspect_message)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
INSERT INTO `bot_inspect_messages` (`bot_id`, `inspect_message`) VALUES
(SELECT `bot_id`, '{}' inspect_message FROM `bot_data` WHERE `owner_id` = {})
),
inspect_message,
owner_id
)
);
return results.Success();
}
static bool DeleteAllInspectMessages(Database& db, const uint32 owner_id)
{
auto results = db.QueryDatabase(
fmt::format(
SQL(
DELETE FROM `bot_inspect_messages`
WHERE `bot_id` IN (SELECT `bot_id` FROM `bot_data` WHERE `owner_id` = {})
),
owner_id
)
);
return results.Success();
}
}; };
#endif //EQEMU_BOT_INSPECT_MESSAGES_REPOSITORY_H #endif //EQEMU_BOT_INSPECT_MESSAGES_REPOSITORY_H

View File

@ -44,7 +44,57 @@ public:
*/ */
// Custom extended repository methods here // Custom extended repository methods here
static bool UpdateItemColors(Database& db, const uint32 bot_id, const uint32 color, const std::string& where_clause)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `inst_color` = {} WHERE `bot_id` = {} AND `slot_id` {}",
TableName(),
color,
bot_id,
where_clause
)
);
return results.Success();
}
static bool SaveAllArmorColors(Database& db, const uint32 owner_id, const uint32 color)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `inst_color` = {} WHERE `slot_id` IN ({}, {}, {}, {}, {}, {}, {}) AND `bot_id` IN (SELECT `bot_id` FROM `bot_data` WHERE `owner_id` = {})",
TableName(),
color,
EQ::invslot::slotHead,
EQ::invslot::slotChest,
EQ::invslot::slotArms,
EQ::invslot::slotWrist1,
EQ::invslot::slotWrist2,
EQ::invslot::slotHands,
EQ::invslot::slotLegs,
EQ::invslot::slotFeet,
owner_id
)
);
return results.Success();
}
static bool SaveAllArmorColorsBySlot(Database& db, const uint32 owner_id, const int16 slot_id, const uint32 color)
{
auto results = db.QueryDatabase(
fmt::format(
"UPDATE `{}` SET `inst_color` = {} WHERE `slot_id` = {} AND `bot_id` IN (SELECT `bot_id` FROM `bot_data` WHERE `owner_id` = {})",
TableName(),
color,
slot_id,
owner_id
)
);
return results.Success();
}
}; };
#endif //EQEMU_BOT_INVENTORIES_REPOSITORY_H #endif //EQEMU_BOT_INVENTORIES_REPOSITORY_H

View File

@ -44,7 +44,7 @@
#define CURRENT_BINARY_DATABASE_VERSION 9256 #define CURRENT_BINARY_DATABASE_VERSION 9256
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9041 #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9042
#endif #endif

View File

@ -566,6 +566,9 @@ sub translate_mysql_data_type_to_c
elsif ($mysql_data_type =~ /int/) { elsif ($mysql_data_type =~ /int/) {
$struct_data_type = 'uint32_t'; $struct_data_type = 'uint32_t';
} }
elsif ($mysql_data_type =~ /float|decimal/) {
$struct_data_type = 'float';
}
} }
elsif ($mysql_data_type =~ /bigint/) { elsif ($mysql_data_type =~ /bigint/) {
$struct_data_type = 'int64_t'; $struct_data_type = 'int64_t';
@ -600,7 +603,8 @@ sub get_reserved_cpp_variable_names
"int", "int",
"key", "key",
"rank", "rank",
"range" "range",
"interval"
); );
} }

View File

@ -228,17 +228,10 @@ Bot::Bot(
strcpy(name, GetCleanName()); strcpy(name, GetCleanName());
memset(&_botInspectMessage, 0, sizeof(InspectMessage_Struct)); memset(&_botInspectMessage, 0, sizeof(InspectMessage_Struct));
if (!database.botdb.LoadInspectMessage(GetBotID(), _botInspectMessage) && bot_owner)
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::LoadInspectMessage(), GetCleanName());
std::string error_message; database.botdb.LoadInspectMessage(GetBotID(), _botInspectMessage);
EquipBot(&error_message); EquipBot();
if (!error_message.empty()) {
if (bot_owner)
bot_owner->Message(Chat::White, error_message.c_str());
error_message.clear();
}
if (GetClass() == Class::Rogue) { if (GetClass() == Class::Rogue) {
m_evade_timer.Start(); m_evade_timer.Start();
@ -252,17 +245,12 @@ Bot::Bot(
GenerateBaseStats(); GenerateBaseStats();
bot_timers.clear(); bot_timers.clear();
if (!database.botdb.LoadTimers(this) && bot_owner) {
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::LoadTimers(), GetCleanName()); database.botdb.LoadTimers(this);
}
LoadAAs(); LoadAAs();
if (!database.botdb.LoadBuffs(this)) { if (database.botdb.LoadBuffs(this)) {
if (bot_owner) {
bot_owner->Message(Chat::White, "&s for '%s'", BotDatabase::fail::LoadBuffs(), GetCleanName());
}
} else {
//reapply some buffs //reapply some buffs
uint32 buff_count = GetMaxBuffSlots(); uint32 buff_count = GetMaxBuffSlots();
for (uint32 j1 = 0; j1 < buff_count; j1++) { for (uint32 j1 = 0; j1 < buff_count; j1++) {
@ -1335,38 +1323,23 @@ bool Bot::Save()
if (!bot_owner) if (!bot_owner)
return false; return false;
std::string error_message;
if (!GetBotID()) { // New bot record if (!GetBotID()) { // New bot record
uint32 bot_id = 0; uint32 bot_id = 0;
if (!database.botdb.SaveNewBot(this, bot_id) || !bot_id) { if (!database.botdb.SaveNewBot(this, bot_id) || !bot_id) {
bot_owner->Message(Chat::White, "%s '%s'", BotDatabase::fail::SaveNewBot(), GetCleanName());
return false; return false;
} }
SetBotID(bot_id); SetBotID(bot_id);
} }
else { // Update existing bot record else { // Update existing bot record
if (!database.botdb.SaveBot(this)) { if (!database.botdb.SaveBot(this)) {
bot_owner->Message(Chat::White, "%s '%s'", BotDatabase::fail::SaveBot(), GetCleanName());
return false; return false;
} }
} }
// All of these continue to process if any fail // All of these continue to process if any fail
if (!database.botdb.SaveBuffs(this)) database.botdb.SaveBuffs(this);
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveBuffs(), GetCleanName()); database.botdb.SaveTimers(this);
if (!database.botdb.SaveTimers(this)) database.botdb.SaveStance(this);
bot_owner->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveTimers(), GetCleanName());
if (!database.botdb.SaveStance(this)) {
bot_owner->Message(
Chat::White,
fmt::format(
"Failed to save stance for '{}'.",
GetCleanName()
).c_str()
);
}
if (!SavePet()) if (!SavePet())
bot_owner->Message(Chat::White, "Failed to save pet for '%s'", GetCleanName()); bot_owner->Message(Chat::White, "Failed to save pet for '%s'", GetCleanName());
@ -1382,7 +1355,6 @@ bool Bot::DeleteBot()
} }
if (!database.botdb.DeleteHealRotation(GetBotID())) { if (!database.botdb.DeleteHealRotation(GetBotID())) {
bot_owner->Message(Chat::White, "%s", BotDatabase::fail::DeleteHealRotation());
return false; return false;
} }
@ -1413,65 +1385,23 @@ bool Bot::DeleteBot()
RemoveBotFromRaid(this); RemoveBotFromRaid(this);
} }
std::string error_message;
if (!database.botdb.DeleteItems(GetBotID())) { if (!database.botdb.DeleteItems(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteItems(),
GetCleanName()
).c_str()
);
return false; return false;
} }
if (!database.botdb.DeleteTimers(GetBotID())) { if (!database.botdb.DeleteTimers(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteTimers(),
GetCleanName()
).c_str()
);
return false; return false;
} }
if (!database.botdb.DeleteBuffs(GetBotID())) { if (!database.botdb.DeleteBuffs(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteBuffs(),
GetCleanName()
).c_str()
);
return false; return false;
} }
if (!database.botdb.DeleteStance(GetBotID())) { if (!database.botdb.DeleteStance(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} for '{}'.",
BotDatabase::fail::DeleteStance(),
GetCleanName()
).c_str()
);
return false; return false;
} }
if (!database.botdb.DeleteBot(GetBotID())) { if (!database.botdb.DeleteBot(GetBotID())) {
bot_owner->Message(
Chat::White,
fmt::format(
"{} '{}'",
BotDatabase::fail::DeleteBot(),
GetCleanName()
).c_str()
);
return false; return false;
} }
@ -1511,20 +1441,16 @@ bool Bot::LoadPet()
} }
} }
std::string error_message;
uint32 pet_index = 0; uint32 pet_index = 0;
if (!database.botdb.LoadPetIndex(GetBotID(), pet_index)) { if (!database.botdb.LoadPetIndex(GetBotID(), pet_index)) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetIndex(), GetCleanName());
return false; return false;
} }
if (!pet_index) if (!pet_index)
return true; return true;
uint32 saved_pet_spell_id = 0; uint32 saved_pet_spell_id = 0;
if (!database.botdb.LoadPetSpellID(GetBotID(), saved_pet_spell_id)) { database.botdb.LoadPetSpellID(GetBotID(), saved_pet_spell_id);
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetSpellID(), GetCleanName());
}
if (!IsValidSpell(saved_pet_spell_id)) { if (!IsValidSpell(saved_pet_spell_id)) {
bot_owner->Message(Chat::White, "Invalid spell id for %s's pet", GetCleanName()); bot_owner->Message(Chat::White, "Invalid spell id for %s's pet", GetCleanName());
DeletePet(); DeletePet();
@ -1537,7 +1463,6 @@ bool Bot::LoadPet()
uint32 pet_spell_id = 0; uint32 pet_spell_id = 0;
if (!database.botdb.LoadPetStats(GetBotID(), pet_name, pet_mana, pet_hp, pet_spell_id)) { if (!database.botdb.LoadPetStats(GetBotID(), pet_name, pet_mana, pet_hp, pet_spell_id)) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetStats(), GetCleanName());
return false; return false;
} }
@ -1551,13 +1476,11 @@ bool Bot::LoadPet()
SpellBuff_Struct pet_buffs[PET_BUFF_COUNT]; SpellBuff_Struct pet_buffs[PET_BUFF_COUNT];
memset(pet_buffs, 0, (sizeof(SpellBuff_Struct) * PET_BUFF_COUNT)); memset(pet_buffs, 0, (sizeof(SpellBuff_Struct) * PET_BUFF_COUNT));
if (!database.botdb.LoadPetBuffs(GetBotID(), pet_buffs)) database.botdb.LoadPetBuffs(GetBotID(), pet_buffs);
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetBuffs(), GetCleanName());
uint32 pet_items[EQ::invslot::EQUIPMENT_COUNT]; uint32 pet_items[EQ::invslot::EQUIPMENT_COUNT];
memset(pet_items, 0, (sizeof(uint32) * EQ::invslot::EQUIPMENT_COUNT)); memset(pet_items, 0, (sizeof(uint32) * EQ::invslot::EQUIPMENT_COUNT));
if (!database.botdb.LoadPetItems(GetBotID(), pet_items)) database.botdb.LoadPetItems(GetBotID(), pet_items);
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::LoadPetItems(), GetCleanName());
pet_inst->SetPetState(pet_buffs, pet_items); pet_inst->SetPetState(pet_buffs, pet_items);
pet_inst->CalcBonuses(); pet_inst->CalcBonuses();
@ -1596,17 +1519,12 @@ bool Bot::SavePet()
std::string pet_name_str = pet_name; std::string pet_name_str = pet_name;
safe_delete_array(pet_name) safe_delete_array(pet_name)
std::string error_message;
if (!database.botdb.SavePetStats(GetBotID(), pet_name_str, pet_inst->GetMana(), pet_inst->GetHP(), pet_inst->GetPetSpellID())) { if (!database.botdb.SavePetStats(GetBotID(), pet_name_str, pet_inst->GetMana(), pet_inst->GetHP(), pet_inst->GetPetSpellID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetStats(), GetCleanName());
return false; return false;
} }
if (!database.botdb.SavePetBuffs(GetBotID(), pet_buffs)) database.botdb.SavePetBuffs(GetBotID(), pet_buffs);
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetBuffs(), GetCleanName()); database.botdb.SavePetItems(GetBotID(), pet_items);
if (!database.botdb.SavePetItems(GetBotID(), pet_items))
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::SavePetItems(), GetCleanName());
return true; return true;
} }
@ -1617,18 +1535,13 @@ bool Bot::DeletePet()
if (!bot_owner) if (!bot_owner)
return false; return false;
std::string error_message;
if (!database.botdb.DeletePetItems(GetBotID())) { if (!database.botdb.DeletePetItems(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetItems(), GetCleanName());
return false; return false;
} }
if (!database.botdb.DeletePetBuffs(GetBotID())) { if (!database.botdb.DeletePetBuffs(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetBuffs(), GetCleanName());
return false; return false;
} }
if (!database.botdb.DeletePetStats(GetBotID())) { if (!database.botdb.DeletePetStats(GetBotID())) {
bot_owner->Message(Chat::White, "%s for %s's pet", BotDatabase::fail::DeletePetStats(), GetCleanName());
return false; return false;
} }
@ -3379,29 +3292,26 @@ bool Bot::Spawn(Client* botCharacterOwner) {
} }
// Deletes the inventory record for the specified item from the database for this bot. // Deletes the inventory record for the specified item from the database for this bot.
void Bot::RemoveBotItemBySlot(uint16 slot_id, std::string *error_message) void Bot::RemoveBotItemBySlot(uint16 slot_id)
{ {
if (!GetBotID()) { if (!GetBotID()) {
return; return;
} }
if (!database.botdb.DeleteItemBySlot(GetBotID(), slot_id)) { database.botdb.DeleteItemBySlot(GetBotID(), slot_id);
*error_message = BotDatabase::fail::DeleteItemBySlot();
}
m_inv.DeleteItem(slot_id); m_inv.DeleteItem(slot_id);
UpdateEquipmentLight(); UpdateEquipmentLight();
} }
// Retrieves all the inventory records from the database for this bot. // Retrieves all the inventory records from the database for this bot.
void Bot::GetBotItems(EQ::InventoryProfile &inv, std::string* error_message) void Bot::GetBotItems(EQ::InventoryProfile &inv)
{ {
if (!GetBotID()) { if (!GetBotID()) {
return; return;
} }
if (!database.botdb.LoadItems(GetBotID(), inv)) { if (!database.botdb.LoadItems(GetBotID(), inv)) {
*error_message = BotDatabase::fail::LoadItems();
return; return;
} }
@ -3732,7 +3642,7 @@ void Bot::BotRemoveEquipItem(uint16 slot_id)
} }
} }
void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::string* error_message, bool save_to_database) void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, bool save_to_database)
{ {
if (!inst) { if (!inst) {
return; return;
@ -3740,7 +3650,6 @@ void Bot::BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::str
if (save_to_database) { if (save_to_database) {
if (!database.botdb.SaveItemBySlot(this, slot_id, inst)) { if (!database.botdb.SaveItemBySlot(this, slot_id, inst)) {
*error_message = BotDatabase::fail::SaveItemBySlot();
return; return;
} }
@ -3848,21 +3757,7 @@ void Bot::RemoveBotItem(uint32 item_id) {
if (inst->GetID() == item_id) { if (inst->GetID() == item_id) {
std::string error_message; RemoveBotItemBySlot(slot_id);
RemoveBotItemBySlot(slot_id, &error_message);
if (!error_message.empty()) {
if (GetOwner()) {
GetOwner()->CastToClient()->Message(
Chat::White,
fmt::format(
"Database Error: {}",
error_message
).c_str()
);
}
return;
}
BotRemoveEquipItem(slot_id); BotRemoveEquipItem(slot_id);
CalcBotStats(GetOwner()->CastToClient()->GetBotOption(Client::booStatsUpdate)); CalcBotStats(GetOwner()->CastToClient()->GetBotOption(Client::booStatsUpdate));
return; return;
@ -5389,18 +5284,15 @@ bool Bot::IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined) {
return Result; return Result;
} }
void Bot::EquipBot(std::string* error_message) { void Bot::EquipBot() {
GetBotItems(m_inv, error_message); GetBotItems(m_inv);
const EQ::ItemInstance* inst = nullptr; const EQ::ItemInstance* inst = nullptr;
const EQ::ItemData* item = nullptr; const EQ::ItemData* item = nullptr;
for (int slot_id = EQ::invslot::EQUIPMENT_BEGIN; slot_id <= EQ::invslot::EQUIPMENT_END; ++slot_id) { for (int slot_id = EQ::invslot::EQUIPMENT_BEGIN; slot_id <= EQ::invslot::EQUIPMENT_END; ++slot_id) {
inst = GetBotItem(slot_id); inst = GetBotItem(slot_id);
if (inst) { if (inst) {
item = inst->GetItem(); item = inst->GetItem();
BotTradeAddItem(inst, slot_id, error_message, false); BotTradeAddItem(inst, slot_id, false);
if (!error_message->empty()) {
return;
}
} }
} }
UpdateEquipmentLight(); UpdateEquipmentLight();
@ -8131,8 +8023,6 @@ bool Bot::DyeArmor(int16 slot_id, uint32 rgb, bool all_flag, bool save_flag)
save_slot = -2; save_slot = -2;
if (!database.botdb.SaveEquipmentColor(GetBotID(), save_slot, rgb)) { if (!database.botdb.SaveEquipmentColor(GetBotID(), save_slot, rgb)) {
if (GetBotOwner() && GetBotOwner()->IsClient())
GetBotOwner()->CastToClient()->Message(Chat::White, "%s", BotDatabase::fail::SaveEquipmentColor());
return false; return false;
} }
} }

View File

@ -386,8 +386,8 @@ public:
bool CheckDataBucket(std::string bucket_name, const std::string& bucket_value, uint8 bucket_comparison); bool CheckDataBucket(std::string bucket_name, const std::string& bucket_value, uint8 bucket_comparison);
// Bot Equipment & Inventory Class Methods // Bot Equipment & Inventory Class Methods
void BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, std::string* error_message, bool save_to_database = true); void BotTradeAddItem(const EQ::ItemInstance* inst, uint16 slot_id, bool save_to_database = true);
void EquipBot(std::string* error_message); void EquipBot();
bool CheckLoreConflict(const EQ::ItemData* item); bool CheckLoreConflict(const EQ::ItemData* item);
void UpdateEquipmentLight() override void UpdateEquipmentLight() override
{ {
@ -704,7 +704,8 @@ public:
uint32 attack uint32 attack
); );
void BotRemoveEquipItem(uint16 slot_id); void BotRemoveEquipItem(uint16 slot_id);
void RemoveBotItemBySlot(uint16 slot_id, std::string* error_message); void RemoveBotItemBySlot(uint16 slot_id
);
void AddBotItem( void AddBotItem(
uint16 slot_id, uint16 slot_id,
uint32 item_id, uint32 item_id,
@ -938,7 +939,7 @@ private:
void SetReturningFlag(bool flag = true) { m_returning_flag = flag; } void SetReturningFlag(bool flag = true) { m_returning_flag = flag; }
// Private "Inventory" Methods // Private "Inventory" Methods
void GetBotItems(EQ::InventoryProfile &inv, std::string* error_message); void GetBotItems(EQ::InventoryProfile &inv);
void BotAddEquipItem(uint16 slot_id, uint32 item_id); void BotAddEquipItem(uint16 slot_id, uint32 item_id);
// Private "Pet" Methods // Private "Pet" Methods

View File

@ -5843,7 +5843,7 @@ void bot_subcommand_bot_clone(Client *c, const Seperator *sep)
} }
uint32 clone_id = 0; uint32 clone_id = 0;
if (!database.botdb.CreateCloneBot(c->CharacterID(), my_bot->GetBotID(), bot_name, clone_id) || !clone_id) { if (!database.botdb.CreateCloneBot(my_bot->GetBotID(), bot_name, clone_id) || !clone_id) {
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
@ -5875,7 +5875,7 @@ void bot_subcommand_bot_clone(Client *c, const Seperator *sep)
); );
} }
if (!database.botdb.CreateCloneBotInventory(c->CharacterID(), my_bot->GetBotID(), clone_id)) { if (!database.botdb.CreateCloneBotInventory(my_bot->GetBotID(), clone_id)) {
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
@ -6361,25 +6361,9 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) { if (ab_type == ActionableBots::ABT_All) {
if (dye_all) { if (dye_all) {
if (!database.botdb.SaveAllArmorColors(c->CharacterID(), rgb_value)) { database.botdb.SaveAllArmorColors(c->CharacterID(), rgb_value);
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::SaveAllArmorColors()
).c_str()
);
}
} else { } else {
if (!database.botdb.SaveAllArmorColorBySlot(c->CharacterID(), slot_id, rgb_value)) { database.botdb.SaveAllArmorColorBySlot(c->CharacterID(), slot_id, rgb_value);
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::SaveAllArmorColorBySlot()
).c_str()
);
}
} }
} }
} }
@ -6527,8 +6511,7 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep)
continue; continue;
bot_iter->SetFollowDistance(bfd); bot_iter->SetFollowDistance(bfd);
if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveFollowDistance(c->CharacterID(), bot_iter->GetBotID(), bfd)) { if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveFollowDistance(bot_iter->GetBotID(), bfd)) {
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveFollowDistance(), bot_iter->GetCleanName());
return; return;
} }
@ -6537,7 +6520,6 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) { if (ab_type == ActionableBots::ABT_All) {
if (!database.botdb.SaveAllFollowDistances(c->CharacterID(), bfd)) { if (!database.botdb.SaveAllFollowDistances(c->CharacterID(), bfd)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllFollowDistances());
return; return;
} }
@ -6706,7 +6688,6 @@ void bot_subcommand_bot_inspect_message(Client *c, const Seperator *sep)
memcpy(bot_message_struct, client_message_struct, sizeof(InspectMessage_Struct)); memcpy(bot_message_struct, client_message_struct, sizeof(InspectMessage_Struct));
if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveInspectMessage(bot_iter->GetBotID(), *bot_message_struct)) { if (ab_type != ActionableBots::ABT_All && !database.botdb.SaveInspectMessage(bot_iter->GetBotID(), *bot_message_struct)) {
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveInspectMessage(), bot_iter->GetCleanName());
return; return;
} }
@ -6720,7 +6701,6 @@ void bot_subcommand_bot_inspect_message(Client *c, const Seperator *sep)
memcpy(&bot_message_struct, client_message_struct, sizeof(InspectMessage_Struct)); memcpy(&bot_message_struct, client_message_struct, sizeof(InspectMessage_Struct));
if (!database.botdb.SaveAllInspectMessages(c->CharacterID(), bot_message_struct)) { if (!database.botdb.SaveAllInspectMessages(c->CharacterID(), bot_message_struct)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllInspectMessages());
return; return;
} }
@ -6800,7 +6780,6 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
std::list<BotsAvailableList> bots_list; std::list<BotsAvailableList> bots_list;
if (!database.botdb.LoadBotsList(c->CharacterID(), bots_list, Account)) { if (!database.botdb.LoadBotsList(c->CharacterID(), bots_list, Account)) {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadBotsList());
return; return;
} }
@ -6814,18 +6793,18 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
auto bot_number = 1; auto bot_number = 1;
for (auto bots_iter : bots_list) { for (auto bots_iter : bots_list) {
if (filter_mask) { if (filter_mask) {
if ((filter_mask & MaskClass) && filter_value[FilterClass] != bots_iter.Class) { if ((filter_mask & MaskClass) && filter_value[FilterClass] != bots_iter.class_) {
continue; continue;
} }
if ((filter_mask & MaskRace) && filter_value[FilterRace] != bots_iter.Race) { if ((filter_mask & MaskRace) && filter_value[FilterRace] != bots_iter.race) {
continue; continue;
} }
if (filter_mask & MaskName) { if (filter_mask & MaskName) {
std::string name_criteria = sep->arg[name_criteria_arg]; std::string name_criteria = sep->arg[name_criteria_arg];
std::transform(name_criteria.begin(), name_criteria.end(), name_criteria.begin(), ::tolower); std::transform(name_criteria.begin(), name_criteria.end(), name_criteria.begin(), ::tolower);
std::string name_check = bots_iter.Name; std::string name_check = bots_iter.bot_name;
std::transform(name_check.begin(), name_check.end(), name_check.begin(), ::tolower); std::transform(name_check.begin(), name_check.end(), name_check.begin(), ::tolower);
if (name_check.find(name_criteria) == std::string::npos) { if (name_check.find(name_criteria) == std::string::npos) {
continue; continue;
@ -6833,7 +6812,7 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
} }
} }
auto* bot = entity_list.GetBotByBotName(bots_iter.Name); auto* bot = entity_list.GetBotByBotName(bots_iter.bot_name);
c->Message( c->Message(
Chat::White, Chat::White,
@ -6841,22 +6820,22 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep)
"Bot {} | {} is a Level {} {} {} {} owned by {}.", "Bot {} | {} is a Level {} {} {} {} owned by {}.",
bot_number, bot_number,
( (
(c->CharacterID() == bots_iter.Owner_ID && !bot) ? (c->CharacterID() == bots_iter.owner_id && !bot) ?
Saylink::Silent( Saylink::Silent(
fmt::format("^spawn {}", bots_iter.Name), fmt::format("^spawn {}", bots_iter.bot_name),
bots_iter.Name bots_iter.bot_name
) : ) :
bots_iter.Name bots_iter.bot_name
), ),
bots_iter.Level, bots_iter.level,
GetGenderName(bots_iter.Gender), GetGenderName(bots_iter.gender),
GetRaceIDName(bots_iter.Race), GetRaceIDName(bots_iter.race),
GetClassIDName(bots_iter.Class), GetClassIDName(bots_iter.class_),
bots_iter.Owner bots_iter.owner_name
).c_str() ).c_str()
); );
if (c->CharacterID() == bots_iter.Owner_ID) { if (c->CharacterID() == bots_iter.owner_id) {
bots_owned++; bots_owned++;
} }
@ -6975,10 +6954,7 @@ void bot_subcommand_bot_surname(Client *c, const Seperator *sep)
std::replace(bot_surname.begin(), bot_surname.end(), '_', ' '); std::replace(bot_surname.begin(), bot_surname.end(), '_', ' ');
my_bot->SetSurname(bot_surname); my_bot->SetSurname(bot_surname);
if (!database.botdb.SaveBot(my_bot)) { if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
c->Message(Chat::White, "Bot Surname Saved."); c->Message(Chat::White, "Bot Surname Saved.");
} }
} }
@ -7003,10 +6979,7 @@ void bot_subcommand_bot_title(Client *c, const Seperator *sep)
std::replace(bot_title.begin(), bot_title.end(), '_', ' '); std::replace(bot_title.begin(), bot_title.end(), '_', ' ');
my_bot->SetTitle(bot_title); my_bot->SetTitle(bot_title);
if (!database.botdb.SaveBot(my_bot)) { if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
c->Message(Chat::White, "Bot Title Saved."); c->Message(Chat::White, "Bot Title Saved.");
} }
} }
@ -7031,10 +7004,7 @@ void bot_subcommand_bot_suffix(Client *c, const Seperator *sep)
std::replace(bot_suffix.begin(), bot_suffix.end(), '_', ' '); std::replace(bot_suffix.begin(), bot_suffix.end(), '_', ' ');
my_bot->SetSuffix(bot_suffix); my_bot->SetSuffix(bot_suffix);
if (!database.botdb.SaveBot(my_bot)) { if (database.botdb.SaveBot(my_bot)) {
c->Message(Chat::White, BotDatabase::fail::SaveBot());
}
else {
c->Message(Chat::White, "Bot Suffix Saved."); c->Message(Chat::White, "Bot Suffix Saved.");
} }
} }
@ -7149,7 +7119,7 @@ void bot_subcommand_bot_spawn(Client *c, const Seperator *sep)
uint32 bot_id = 0; uint32 bot_id = 0;
uint8 bot_class = Class::None; uint8 bot_class = Class::None;
if (!database.botdb.LoadBotID(c->CharacterID(), bot_name, bot_id, bot_class)) { if (!database.botdb.LoadBotID(bot_name, bot_id, bot_class)) {
c->Message( c->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
@ -7387,8 +7357,7 @@ void bot_subcommand_bot_stop_melee_level(Client *c, const Seperator *sep)
// [reset] falls through with initialization value // [reset] falls through with initialization value
my_bot->SetStopMeleeLevel(sml); my_bot->SetStopMeleeLevel(sml);
if (!database.botdb.SaveStopMeleeLevel(c->CharacterID(), my_bot->GetBotID(), sml)) database.botdb.SaveStopMeleeLevel(my_bot->GetBotID(), sml);
c->Message(Chat::White, "%s for '%s'", BotDatabase::fail::SaveStopMeleeLevel(), my_bot->GetCleanName());
c->Message(Chat::White, "Successfully set stop melee level for %s to %u", my_bot->GetCleanName(), sml); c->Message(Chat::White, "Successfully set stop melee level for %s to %u", my_bot->GetCleanName(), sml);
} }
@ -7587,8 +7556,7 @@ void bot_subcommand_bot_toggle_helm(Client *c, const Seperator *sep)
bot_iter->SetShowHelm(helm_state); bot_iter->SetShowHelm(helm_state);
if (ab_type != ActionableBots::ABT_All) { if (ab_type != ActionableBots::ABT_All) {
if (!database.botdb.SaveHelmAppearance(c->CharacterID(), bot_iter->GetBotID(), bot_iter->GetShowHelm())) { if (!database.botdb.SaveHelmAppearance(bot_iter->GetBotID(), bot_iter->GetShowHelm())) {
c->Message(Chat::White, "%s for '%s'", bot_iter->GetCleanName());
return; return;
} }
@ -7608,12 +7576,10 @@ void bot_subcommand_bot_toggle_helm(Client *c, const Seperator *sep)
if (ab_type == ActionableBots::ABT_All) { if (ab_type == ActionableBots::ABT_All) {
if (toggle_helm) { if (toggle_helm) {
if (!database.botdb.ToggleAllHelmAppearances(c->CharacterID())) database.botdb.ToggleAllHelmAppearances(c->CharacterID());
c->Message(Chat::White, "%s", BotDatabase::fail::ToggleAllHelmAppearances());
} }
else { else {
if (!database.botdb.SaveAllHelmAppearances(c->CharacterID(), helm_state)) database.botdb.SaveAllHelmAppearances(c->CharacterID(), helm_state);
c->Message(Chat::White, "%s", BotDatabase::fail::SaveAllHelmAppearances());
} }
c->Message(Chat::White, "%s all of your bot show helm flags", toggle_helm ? "Toggled" : (helm_state ? "Set" : "Cleared")); c->Message(Chat::White, "%s all of your bot show helm flags", toggle_helm ? "Toggled" : (helm_state ? "Set" : "Cleared"));
@ -8357,8 +8323,7 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
bool member_fail = false; bool member_fail = false;
bool target_fail = false; bool target_fail = false;
if (!database.botdb.LoadHealRotation(creator_member, member_list, target_list, load_flag, member_fail, target_fail)) database.botdb.LoadHealRotation(creator_member, member_list, target_list, load_flag, member_fail, target_fail);
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotation());
if (!load_flag) { if (!load_flag) {
c->Message(Chat::White, "Successfully added %s as a current member to a new Heal Rotation", creator_member->GetCleanName()); c->Message(Chat::White, "Successfully added %s as a current member to a new Heal Rotation", creator_member->GetCleanName());
@ -8387,9 +8352,6 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
c->Message(Chat::White, "Could not locate member with bot id '%u'", member_iter); c->Message(Chat::White, "Could not locate member with bot id '%u'", member_iter);
} }
} }
else {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotationMembers());
}
if (!target_fail) { if (!target_fail) {
for (auto target_iter : target_list) { for (auto target_iter : target_list) {
@ -8406,9 +8368,6 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep)
c->Message(Chat::White, "Failed to add target '%s'", target_mob->GetCleanName()); c->Message(Chat::White, "Failed to add target '%s'", target_mob->GetCleanName());
} }
} }
else {
c->Message(Chat::White, "%s", BotDatabase::fail::LoadHealRotationTargets());
}
c->Message(Chat::White, "Successfully loaded %s's Heal Rotation", creator_member->GetCleanName()); c->Message(Chat::White, "Successfully loaded %s's Heal Rotation", creator_member->GetCleanName());
} }
@ -8430,11 +8389,7 @@ void bot_subcommand_heal_rotation_delete(Client *c, const Seperator *sep)
} }
if (all_flag) { if (all_flag) {
if (database.botdb.DeleteAllHealRotations(c->CharacterID())) database.botdb.DeleteAllHealRotations(c->CharacterID());
c->Message(Chat::White, "Succeeded in deleting all heal rotations");
else
c->Message(Chat::White, "%s", BotDatabase::fail::DeleteAllHealRotations());
return; return;
} }
@ -8454,7 +8409,6 @@ void bot_subcommand_heal_rotation_delete(Client *c, const Seperator *sep)
} }
if (!database.botdb.DeleteHealRotation(current_member->GetBotID())) { if (!database.botdb.DeleteHealRotation(current_member->GetBotID())) {
c->Message(Chat::White, "%s", BotDatabase::fail::DeleteHealRotation());
return; return;
} }
@ -8741,7 +8695,6 @@ void bot_subcommand_heal_rotation_save(Client *c, const Seperator *sep)
bool member_fail = false; bool member_fail = false;
bool target_fail = false; bool target_fail = false;
if (!database.botdb.SaveHealRotation(current_member, member_fail, target_fail)) { if (!database.botdb.SaveHealRotation(current_member, member_fail, target_fail)) {
c->Message(Chat::White, "%s", BotDatabase::fail::SaveHealRotation());
return; return;
} }
if (member_fail) if (member_fail)
@ -8997,15 +8950,7 @@ void bot_subcommand_inventory_list(Client *c, const Seperator *sep)
} }
uint32 database_count = 0; uint32 database_count = 0;
if (!database.botdb.QueryInventoryCount(my_bot->GetBotID(), database_count)) { database.botdb.QueryInventoryCount(my_bot->GetBotID(), database_count);
c->Message(
Chat::White,
fmt::format(
"{}",
BotDatabase::fail::QueryInventoryCount()
).c_str()
);
}
if (inventory_count != database_count) { if (inventory_count != database_count) {
c->Message( c->Message(
@ -9114,7 +9059,6 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
return; return;
} }
std::string error_message;
if (itm) { if (itm) {
EQ::SayLinkEngine linker; EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemInst); linker.SetLinkType(EQ::saylink::SayLinkItemInst);
@ -9128,18 +9072,7 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
my_bot->SetBotArcherySetting(false, true); my_bot->SetBotArcherySetting(false, true);
} }
my_bot->RemoveBotItemBySlot(slot_id, &error_message); my_bot->RemoveBotItemBySlot(slot_id);
if (!error_message.empty()) {
c->Message(
Chat::White,
fmt::format(
"Database Error: {}",
error_message
).c_str()
);
return;
}
my_bot->BotRemoveEquipItem(slot_id); my_bot->BotRemoveEquipItem(slot_id);
my_bot->CalcBotStats(c->GetBotOption(Client::booStatsUpdate)); my_bot->CalcBotStats(c->GetBotOption(Client::booStatsUpdate));
@ -10671,16 +10604,7 @@ void bot_command_caster_range(Client* c, const Seperator* sep)
my_bot->SetBotCasterRange(crange); my_bot->SetBotCasterRange(crange);
++success_count; ++success_count;
if (!database.botdb.SaveBotCasterRange(c->CharacterID(), my_bot->GetBotID(), crange)) { database.botdb.SaveBotCasterRange(my_bot->GetBotID(), crange);
c->Message(
Chat::White,
fmt::format(
"{} for '{}'",
BotDatabase::fail::SaveBotCasterRange(),
my_bot->GetCleanName()
).c_str()
);
}
} }
} }
if (!current_check) { if (!current_check) {

File diff suppressed because it is too large Load Diff

View File

@ -50,31 +50,28 @@ public:
/* Bot functions */ /* Bot functions */
bool QueryNameAvailablity(const std::string& bot_name, bool& available_flag); bool QueryNameAvailablity(const std::string& bot_name, bool& available_flag);
bool QueryBotCount(const uint32 owner_id, int class_id, uint32& bot_count, uint32& bot_class_count); bool QueryBotCount(const uint32 owner_id, int class_id, uint32& bot_count, uint32& bot_class_count);
bool LoadBotsList(const uint32 owner_id, std::list<BotsAvailableList>& bots_list, bool ByAccount = false); bool LoadBotsList(const uint32 owner_id, std::list<BotsAvailableList>& bots_list, bool by_account = false);
bool LoadOwnerID(const std::string& bot_name, uint32& owner_id);
bool LoadOwnerID(const uint32 bot_id, uint32& owner_id);
uint32 GetOwnerID(const uint32 bot_id); uint32 GetOwnerID(const uint32 bot_id);
bool LoadBotID(const uint32 owner_id, const std::string& bot_name, uint32& bot_id); bool LoadBotID(const std::string& bot_name, uint32& bot_id, uint8& bot_class_id);
bool LoadBotID(const uint32 owner_id, const std::string& bot_name, uint32& bot_id, uint8& bot_class_id);
bool LoadBot(const uint32 bot_id, Bot*& loaded_bot); bool LoadBot(const uint32 bot_id, Bot*& loaded_bot);
bool SaveNewBot(Bot* bot_inst, uint32& bot_id); bool SaveNewBot(Bot* b, uint32& bot_id);
bool SaveBot(Bot* bot_inst); bool SaveBot(Bot* b);
bool DeleteBot(const uint32 bot_id); bool DeleteBot(const uint32 bot_id);
bool LoadBuffs(Bot* bot_inst); bool LoadBuffs(Bot* b);
bool SaveBuffs(Bot* bot_inst); bool SaveBuffs(Bot* b);
bool DeleteBuffs(const uint32 bot_id); bool DeleteBuffs(const uint32 bot_id);
bool LoadStance(const uint32 bot_id, int& bot_stance); bool LoadStance(const uint32 bot_id, int& bot_stance);
bool LoadStance(Bot* bot_inst, bool& stance_flag); bool LoadStance(Bot* b, bool& stance_flag);
bool SaveStance(const uint32 bot_id, const int bot_stance); bool SaveStance(const uint32 bot_id, const int bot_stance);
bool SaveStance(Bot* bot_inst); bool SaveStance(Bot* b);
bool DeleteStance(const uint32 bot_id); bool DeleteStance(const uint32 bot_id);
bool LoadTimers(Bot* bot_inst); bool LoadTimers(Bot* b);
bool SaveTimers(Bot* bot_inst); bool SaveTimers(Bot* b);
bool DeleteTimers(const uint32 bot_id); bool DeleteTimers(const uint32 bot_id);
@ -82,17 +79,14 @@ public:
bool QueryInventoryCount(const uint32 bot_id, uint32& item_count); bool QueryInventoryCount(const uint32 bot_id, uint32& item_count);
bool LoadItems(const uint32 bot_id, EQ::InventoryProfile &inventory_inst); bool LoadItems(const uint32 bot_id, EQ::InventoryProfile &inventory_inst);
bool SaveItems(Bot* bot_inst);
bool DeleteItems(const uint32 bot_id); bool DeleteItems(const uint32 bot_id);
bool LoadItemSlots(const uint32 bot_id, std::map<uint16, uint32>& m); bool LoadItemSlots(const uint32 bot_id, std::map<uint16, uint32>& m);
bool LoadItemBySlot(Bot* bot_inst);
bool LoadItemBySlot(const uint32 bot_id, const uint32 slot_id, uint32& item_id); bool LoadItemBySlot(const uint32 bot_id, const uint32 slot_id, uint32& item_id);
bool SaveItemBySlot(Bot* bot_inst, const uint32 slot_id, const EQ::ItemInstance* item_inst); bool SaveItemBySlot(Bot* b, const uint32 slot_id, const EQ::ItemInstance* inst);
bool DeleteItemBySlot(const uint32 bot_id, const uint32 slot_id); bool DeleteItemBySlot(const uint32 bot_id, const uint32 slot_id);
bool LoadEquipmentColor(const uint32 bot_id, const uint8 material_slot_id, uint32& rgb); bool SaveEquipmentColor(const uint32 bot_id, const int16 slot_id, const uint32 color);
bool SaveEquipmentColor(const uint32 bot_id, const int16 slot_id, const uint32 rgb);
bool SaveExpansionBitmask(const uint32 bot_id, const int expansion_bitmask); bool SaveExpansionBitmask(const uint32 bot_id, const int expansion_bitmask);
bool SaveEnforceSpellSetting(const uint32 bot_id, const bool enforce_spell_setting); bool SaveEnforceSpellSetting(const uint32 bot_id, const bool enforce_spell_setting);
@ -126,19 +120,18 @@ public:
bool SaveAllArmorColorBySlot(const uint32 owner_id, const int16 slot_id, const uint32 rgb_value); bool SaveAllArmorColorBySlot(const uint32 owner_id, const int16 slot_id, const uint32 rgb_value);
bool SaveAllArmorColors(const uint32 owner_id, const uint32 rgb_value); bool SaveAllArmorColors(const uint32 owner_id, const uint32 rgb_value);
bool SaveHelmAppearance(const uint32 owner_id, const uint32 bot_id, const bool show_flag = true); bool SaveHelmAppearance(const uint32 bot_id, const bool show_flag = true);
bool SaveAllHelmAppearances(const uint32 owner_id, const bool show_flag = true); bool SaveAllHelmAppearances(const uint32 owner_id, const bool show_flag = true);
bool ToggleHelmAppearance(const uint32 owner_id, const uint32 bot_id);
bool ToggleAllHelmAppearances(const uint32 owner_id); bool ToggleAllHelmAppearances(const uint32 owner_id);
bool SaveFollowDistance(const uint32 owner_id, const uint32 bot_id, const uint32 follow_distance); bool SaveFollowDistance(const uint32 bot_id, const uint32 follow_distance);
bool SaveAllFollowDistances(const uint32 owner_id, const uint32 follow_distance); bool SaveAllFollowDistances(const uint32 owner_id, const uint32 follow_distance);
bool CreateCloneBot(const uint32 owner_id, const uint32 bot_id, const std::string& clone_name, uint32& clone_id); bool CreateCloneBot(const uint32 bot_id, const std::string& clone_name, uint32& clone_id);
bool CreateCloneBotInventory(const uint32 owner_id, const uint32 bot_id, const uint32 clone_id); bool CreateCloneBotInventory(const uint32 bot_id, const uint32 clone_id);
bool SaveStopMeleeLevel(const uint32 owner_id, const uint32 bot_id, const uint8 sml_value); bool SaveStopMeleeLevel(const uint32 bot_id, const uint8 sml_value);
bool SaveBotArcherSetting(const uint32 bot_id, const bool bot_archer_setting); bool SaveBotArcherSetting(const uint32 bot_id, const bool bot_archer_setting);
@ -146,7 +139,7 @@ public:
bool SaveOwnerOption(const uint32 owner_id, size_t type, const bool flag); bool SaveOwnerOption(const uint32 owner_id, size_t type, const bool flag);
bool SaveOwnerOption(const uint32 owner_id, const std::pair<size_t, size_t> type, const std::pair<bool, bool> flag); bool SaveOwnerOption(const uint32 owner_id, const std::pair<size_t, size_t> type, const std::pair<bool, bool> flag);
bool SaveBotCasterRange(const uint32 owner_id, const uint32 bot_id, const uint32 bot_caster_range_value); bool SaveBotCasterRange(const uint32 bot_id, const uint32 bot_caster_range_value);
/* Bot group functions */ /* Bot group functions */
bool LoadGroupedBotsByGroupID(const uint32 owner_id, const uint32 group_id, std::list<uint32>& group_list); bool LoadGroupedBotsByGroupID(const uint32 owner_id, const uint32 group_id, std::list<uint32>& group_list);
@ -164,16 +157,12 @@ public:
/* Bot miscellaneous functions */ /* Bot miscellaneous functions */
uint8 GetSpellCastingChance(uint8 spell_type_index, uint8 class_index, uint8 stance_index, uint8 conditional_index); uint8 GetSpellCastingChance(uint8 spell_type_index, uint8 class_index, uint8 stance_index, uint8 conditional_index);
std::string GetBotNameByID(const uint32 bot_id);
uint16 GetRaceClassBitmask(uint16 bot_race); uint32 GetRaceClassBitmask(uint32 bot_race);
class fail { class fail {
public: public:
/* fail::Bot functions */ /* fail::Bot functions */
static const char* LoadBotsList();
static const char* LoadOwnerID();
static const char* LoadBotID();
static const char* LoadBot(); static const char* LoadBot();
static const char* SaveNewBot(); static const char* SaveNewBot();
static const char* SaveBot(); static const char* SaveBot();
@ -189,11 +178,9 @@ public:
/* fail::Bot inventory functions */ /* fail::Bot inventory functions */
static const char* QueryInventoryCount(); static const char* QueryInventoryCount();
static const char* LoadItems(); static const char* LoadItems();
static const char* SaveItems();
static const char* DeleteItems(); static const char* DeleteItems();
static const char* SaveItemBySlot(); static const char* SaveItemBySlot();
static const char* DeleteItemBySlot(); static const char* DeleteItemBySlot();
static const char* LoadEquipmentColor();
static const char* SaveEquipmentColor(); static const char* SaveEquipmentColor();
/* fail::Bot pet functions */ /* fail::Bot pet functions */
@ -212,34 +199,23 @@ public:
/* fail::Bot command functions */ /* fail::Bot command functions */
static const char* LoadInspectMessage(); static const char* LoadInspectMessage();
static const char* SaveInspectMessage(); static const char* SaveInspectMessage();
static const char* DeleteInspectMessage();
static const char* SaveAllInspectMessages(); static const char* SaveAllInspectMessages();
static const char* DeleteAllInspectMessages();
static const char* SaveAllArmorColorBySlot(); static const char* SaveAllArmorColorBySlot();
static const char* SaveAllArmorColors(); static const char* SaveAllArmorColors();
static const char* SaveHelmAppearance();
static const char* SaveAllHelmAppearances(); static const char* SaveAllHelmAppearances();
static const char* ToggleHelmAppearance();
static const char* ToggleAllHelmAppearances(); static const char* ToggleAllHelmAppearances();
static const char* SaveFollowDistance(); static const char* SaveFollowDistance();
static const char* SaveAllFollowDistances(); static const char* SaveAllFollowDistances();
static const char* SaveStopMeleeLevel(); static const char* SaveStopMeleeLevel();
static const char* SaveBotCasterRange(); static const char* SaveBotCasterRange();
/* fail::Bot group functions */
static const char* LoadGroupedBotsByGroupID();
/* fail::Bot heal rotation functions */ /* fail::Bot heal rotation functions */
static const char* LoadHealRotationIDByBotID();
static const char* LoadHealRotation(); static const char* LoadHealRotation();
static const char* LoadHealRotationMembers(); static const char* LoadHealRotationMembers();
static const char* LoadHealRotationTargets(); static const char* LoadHealRotationTargets();
static const char* SaveHealRotation(); static const char* SaveHealRotation();
static const char* DeleteHealRotation(); static const char* DeleteHealRotation();
static const char* DeleteAllHealRotations(); static const char* DeleteAllHealRotations();
/* fail::Bot miscellaneous functions */
static const char* GetBotNameByID();
}; };
private: private:

View File

@ -25,7 +25,7 @@
#include "quest_parser_collection.h" #include "quest_parser_collection.h"
#include "../common/data_verification.h" #include "../common/data_verification.h"
std::vector<RaidMember> Raid::GetRaidGroupMembers(uint32 gid) std::vector<RaidMember> Raid::GetRaidGroupMembers(uint32 gid)
{ {
std::vector<RaidMember> raid_group_members; std::vector<RaidMember> raid_group_members;
raid_group_members.clear(); raid_group_members.clear();
@ -126,9 +126,9 @@ void Raid::HandleOfflineBots(uint32 owner) {
} }
for (const auto& b: bots_list) { for (const auto& b: bots_list) {
if (IsRaidMember(b.Name)) { if (IsRaidMember(b.bot_name)) {
for (const auto& m: members) { for (const auto& m: members) {
if (m.is_bot && strcmp(m.member_name, b.Name) == 0) { if (m.is_bot && strcmp(m.member_name, b.bot_name) == 0) {
uint32 gid = GetGroup(m.member_name); uint32 gid = GetGroup(m.member_name);
SendRaidGroupRemove(m.member_name, gid); SendRaidGroupRemove(m.member_name, gid);
RemoveMember(m.member_name); RemoveMember(m.member_name);
@ -313,7 +313,7 @@ void Client::SpawnRaidBotsOnConnect(Raid* raid) {
if (strlen(m.member_name) != 0) { if (strlen(m.member_name) != 0) {
for (const auto& b: bots_list) { for (const auto& b: bots_list) {
if (strcmp(m.member_name, b.Name) == 0) { if (strcmp(m.member_name, b.bot_name) == 0) {
std::string buffer = "^spawn "; std::string buffer = "^spawn ";
buffer.append(m.member_name); buffer.append(m.member_name);
bot_command_real_dispatch(this, buffer.c_str()); bot_command_real_dispatch(this, buffer.c_str());

View File

@ -24,14 +24,14 @@
#include <sstream> #include <sstream>
struct BotsAvailableList { struct BotsAvailableList {
uint32 ID; uint32 bot_id;
char Name[64]; char bot_name[64];
uint16 Class; uint16 class_;
uint8 Level; uint8 level;
uint16 Race; uint16 race;
uint8 Gender; uint8 gender;
char Owner[64]; char owner_name[64];
uint32 Owner_ID; uint32 owner_id;
}; };
struct BotSpell { struct BotSpell {