mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Mercenaries] Convert Mercenaries to Repositories (#3947)
* [Mercenaries] Convert Mercenaries to Repositories - Convert all Mercenary methods to repositories aside from inner join queries that cannot be converted. * Update base_merc_subtypes_repository.h * Update base_merc_subtypes_repository.h * Regenerate repositories
This commit is contained in:
parent
32659426ba
commit
d7dc717249
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_ARMORINFO_REPOSITORY_H
|
||||
@ -409,6 +409,80 @@ public:
|
||||
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 MercArmorinfo &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||
v.push_back(std::to_string(e.minlevel));
|
||||
v.push_back(std::to_string(e.maxlevel));
|
||||
v.push_back(std::to_string(e.texture));
|
||||
v.push_back(std::to_string(e.helmtexture));
|
||||
v.push_back(std::to_string(e.armortint_id));
|
||||
v.push_back(std::to_string(e.armortint_red));
|
||||
v.push_back(std::to_string(e.armortint_green));
|
||||
v.push_back(std::to_string(e.armortint_blue));
|
||||
|
||||
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<MercArmorinfo> &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.merc_npc_type_id));
|
||||
v.push_back(std::to_string(e.minlevel));
|
||||
v.push_back(std::to_string(e.maxlevel));
|
||||
v.push_back(std::to_string(e.texture));
|
||||
v.push_back(std::to_string(e.helmtexture));
|
||||
v.push_back(std::to_string(e.armortint_id));
|
||||
v.push_back(std::to_string(e.armortint_red));
|
||||
v.push_back(std::to_string(e.armortint_green));
|
||||
v.push_back(std::to_string(e.armortint_blue));
|
||||
|
||||
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_MERC_ARMORINFO_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_INVENTORY_REPOSITORY_H
|
||||
@ -359,6 +359,70 @@ public:
|
||||
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 MercInventory &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_inventory_id));
|
||||
v.push_back(std::to_string(e.merc_subtype_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.min_level));
|
||||
v.push_back(std::to_string(e.max_level));
|
||||
|
||||
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<MercInventory> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_inventory_id));
|
||||
v.push_back(std::to_string(e.merc_subtype_id));
|
||||
v.push_back(std::to_string(e.item_id));
|
||||
v.push_back(std::to_string(e.min_level));
|
||||
v.push_back(std::to_string(e.max_level));
|
||||
|
||||
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_MERC_INVENTORY_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_MERCHANT_ENTRIES_REPOSITORY_H
|
||||
@ -339,6 +339,66 @@ public:
|
||||
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 MercMerchantEntries &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_merchant_entry_id));
|
||||
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||
v.push_back(std::to_string(e.merchant_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<MercMerchantEntries> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_merchant_entry_id));
|
||||
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||
v.push_back(std::to_string(e.merchant_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_MERC_MERCHANT_ENTRIES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
|
||||
@ -339,6 +339,66 @@ public:
|
||||
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 MercMerchantTemplateEntries &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_merchant_template_entry_id));
|
||||
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||
v.push_back(std::to_string(e.merc_template_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<MercMerchantTemplateEntries> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_merchant_template_entry_id));
|
||||
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||
v.push_back(std::to_string(e.merc_template_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_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
|
||||
@ -339,6 +339,66 @@ public:
|
||||
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 MercMerchantTemplates &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.qglobal) + "'");
|
||||
|
||||
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<MercMerchantTemplates> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_merchant_template_id));
|
||||
v.push_back("'" + Strings::Escape(e.name) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.qglobal) + "'");
|
||||
|
||||
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_MERC_MERCHANT_TEMPLATES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_NAME_TYPES_REPOSITORY_H
|
||||
@ -350,6 +350,68 @@ public:
|
||||
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 MercNameTypes &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.name_type_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back("'" + Strings::Escape(e.prefix) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.suffix) + "'");
|
||||
|
||||
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<MercNameTypes> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.name_type_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back("'" + Strings::Escape(e.prefix) + "'");
|
||||
v.push_back("'" + Strings::Escape(e.suffix) + "'");
|
||||
|
||||
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_MERC_NAME_TYPES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_NPC_TYPES_REPOSITORY_H
|
||||
@ -359,6 +359,70 @@ public:
|
||||
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 MercNpcTypes &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||
v.push_back(std::to_string(e.proficiency_id));
|
||||
v.push_back(std::to_string(e.tier_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back("'" + Strings::Escape(e.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<MercNpcTypes> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||
v.push_back(std::to_string(e.proficiency_id));
|
||||
v.push_back(std::to_string(e.tier_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back("'" + Strings::Escape(e.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_MERC_NPC_TYPES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
|
||||
@ -399,6 +399,78 @@ public:
|
||||
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 MercSpellListEntries &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_spell_list_entry_id));
|
||||
v.push_back(std::to_string(e.merc_spell_list_id));
|
||||
v.push_back(std::to_string(e.spell_id));
|
||||
v.push_back(std::to_string(e.spell_type));
|
||||
v.push_back(std::to_string(e.stance_id));
|
||||
v.push_back(std::to_string(e.minlevel));
|
||||
v.push_back(std::to_string(e.maxlevel));
|
||||
v.push_back(std::to_string(e.slot));
|
||||
v.push_back(std::to_string(e.procChance));
|
||||
|
||||
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<MercSpellListEntries> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_spell_list_entry_id));
|
||||
v.push_back(std::to_string(e.merc_spell_list_id));
|
||||
v.push_back(std::to_string(e.spell_id));
|
||||
v.push_back(std::to_string(e.spell_type));
|
||||
v.push_back(std::to_string(e.stance_id));
|
||||
v.push_back(std::to_string(e.minlevel));
|
||||
v.push_back(std::to_string(e.maxlevel));
|
||||
v.push_back(std::to_string(e.slot));
|
||||
v.push_back(std::to_string(e.procChance));
|
||||
|
||||
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_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_SPELL_LISTS_REPOSITORY_H
|
||||
@ -349,6 +349,68 @@ public:
|
||||
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 MercSpellLists &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_spell_list_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back(std::to_string(e.proficiency_id));
|
||||
v.push_back("'" + Strings::Escape(e.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<MercSpellLists> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_spell_list_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back(std::to_string(e.proficiency_id));
|
||||
v.push_back("'" + Strings::Escape(e.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_MERC_SPELL_LISTS_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||
@ -359,6 +359,70 @@ public:
|
||||
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 MercStanceEntries &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_stance_entry_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back(std::to_string(e.proficiency_id));
|
||||
v.push_back(std::to_string(e.stance_id));
|
||||
v.push_back(std::to_string(e.isdefault));
|
||||
|
||||
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<MercStanceEntries> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_stance_entry_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back(std::to_string(e.proficiency_id));
|
||||
v.push_back(std::to_string(e.stance_id));
|
||||
v.push_back(std::to_string(e.isdefault));
|
||||
|
||||
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_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_STATS_REPOSITORY_H
|
||||
@ -640,6 +640,126 @@ public:
|
||||
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 MercStats &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||
v.push_back(std::to_string(e.clientlevel));
|
||||
v.push_back(std::to_string(e.level));
|
||||
v.push_back(std::to_string(e.hp));
|
||||
v.push_back(std::to_string(e.mana));
|
||||
v.push_back(std::to_string(e.AC));
|
||||
v.push_back(std::to_string(e.ATK));
|
||||
v.push_back(std::to_string(e.STR));
|
||||
v.push_back(std::to_string(e.STA));
|
||||
v.push_back(std::to_string(e.DEX));
|
||||
v.push_back(std::to_string(e.AGI));
|
||||
v.push_back(std::to_string(e._INT));
|
||||
v.push_back(std::to_string(e.WIS));
|
||||
v.push_back(std::to_string(e.CHA));
|
||||
v.push_back(std::to_string(e.MR));
|
||||
v.push_back(std::to_string(e.CR));
|
||||
v.push_back(std::to_string(e.DR));
|
||||
v.push_back(std::to_string(e.FR));
|
||||
v.push_back(std::to_string(e.PR));
|
||||
v.push_back(std::to_string(e.Corrup));
|
||||
v.push_back(std::to_string(e.mindmg));
|
||||
v.push_back(std::to_string(e.maxdmg));
|
||||
v.push_back(std::to_string(e.attack_count));
|
||||
v.push_back(std::to_string(e.attack_speed));
|
||||
v.push_back(std::to_string(e.attack_delay));
|
||||
v.push_back("'" + Strings::Escape(e.special_abilities) + "'");
|
||||
v.push_back(std::to_string(e.Accuracy));
|
||||
v.push_back(std::to_string(e.hp_regen_rate));
|
||||
v.push_back(std::to_string(e.mana_regen_rate));
|
||||
v.push_back(std::to_string(e.runspeed));
|
||||
v.push_back(std::to_string(e.statscale));
|
||||
v.push_back(std::to_string(e.spellscale));
|
||||
v.push_back(std::to_string(e.healscale));
|
||||
|
||||
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<MercStats> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||
v.push_back(std::to_string(e.clientlevel));
|
||||
v.push_back(std::to_string(e.level));
|
||||
v.push_back(std::to_string(e.hp));
|
||||
v.push_back(std::to_string(e.mana));
|
||||
v.push_back(std::to_string(e.AC));
|
||||
v.push_back(std::to_string(e.ATK));
|
||||
v.push_back(std::to_string(e.STR));
|
||||
v.push_back(std::to_string(e.STA));
|
||||
v.push_back(std::to_string(e.DEX));
|
||||
v.push_back(std::to_string(e.AGI));
|
||||
v.push_back(std::to_string(e._INT));
|
||||
v.push_back(std::to_string(e.WIS));
|
||||
v.push_back(std::to_string(e.CHA));
|
||||
v.push_back(std::to_string(e.MR));
|
||||
v.push_back(std::to_string(e.CR));
|
||||
v.push_back(std::to_string(e.DR));
|
||||
v.push_back(std::to_string(e.FR));
|
||||
v.push_back(std::to_string(e.PR));
|
||||
v.push_back(std::to_string(e.Corrup));
|
||||
v.push_back(std::to_string(e.mindmg));
|
||||
v.push_back(std::to_string(e.maxdmg));
|
||||
v.push_back(std::to_string(e.attack_count));
|
||||
v.push_back(std::to_string(e.attack_speed));
|
||||
v.push_back(std::to_string(e.attack_delay));
|
||||
v.push_back("'" + Strings::Escape(e.special_abilities) + "'");
|
||||
v.push_back(std::to_string(e.Accuracy));
|
||||
v.push_back(std::to_string(e.hp_regen_rate));
|
||||
v.push_back(std::to_string(e.mana_regen_rate));
|
||||
v.push_back(std::to_string(e.runspeed));
|
||||
v.push_back(std::to_string(e.statscale));
|
||||
v.push_back(std::to_string(e.spellscale));
|
||||
v.push_back(std::to_string(e.healscale));
|
||||
|
||||
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_MERC_STATS_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_SUBTYPES_REPOSITORY_H
|
||||
@ -349,6 +349,68 @@ public:
|
||||
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 MercSubtypes &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_subtype_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back(std::to_string(e.tier_id));
|
||||
v.push_back(std::to_string(e.confidence_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<MercSubtypes> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_subtype_id));
|
||||
v.push_back(std::to_string(e.class_id));
|
||||
v.push_back(std::to_string(e.tier_id));
|
||||
v.push_back(std::to_string(e.confidence_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_MERC_SUBTYPES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_TEMPLATES_REPOSITORY_H
|
||||
@ -379,6 +379,74 @@ public:
|
||||
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 MercTemplates &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_template_id));
|
||||
v.push_back(std::to_string(e.merc_type_id));
|
||||
v.push_back(std::to_string(e.merc_subtype_id));
|
||||
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
|
||||
v.push_back(std::to_string(e.name_type_id));
|
||||
v.push_back(std::to_string(e.clientversion));
|
||||
|
||||
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<MercTemplates> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_template_id));
|
||||
v.push_back(std::to_string(e.merc_type_id));
|
||||
v.push_back(std::to_string(e.merc_subtype_id));
|
||||
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
|
||||
v.push_back(std::to_string(e.name_type_id));
|
||||
v.push_back(std::to_string(e.clientversion));
|
||||
|
||||
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_MERC_TEMPLATES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_TYPES_REPOSITORY_H
|
||||
@ -359,6 +359,70 @@ public:
|
||||
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 MercTypes &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_type_id));
|
||||
v.push_back(std::to_string(e.race_id));
|
||||
v.push_back(std::to_string(e.proficiency_id));
|
||||
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
|
||||
v.push_back(std::to_string(e.clientversion));
|
||||
|
||||
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<MercTypes> &entries
|
||||
)
|
||||
{
|
||||
std::vector<std::string> insert_chunks;
|
||||
|
||||
for (auto &e: entries) {
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.merc_type_id));
|
||||
v.push_back(std::to_string(e.race_id));
|
||||
v.push_back(std::to_string(e.proficiency_id));
|
||||
v.push_back("'" + Strings::Escape(e.dbstring) + "'");
|
||||
v.push_back(std::to_string(e.clientversion));
|
||||
|
||||
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_MERC_TYPES_REPOSITORY_H
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Any modifications to base repositories are to be made by the generator only
|
||||
*
|
||||
* @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_MERC_WEAPONINFO_REPOSITORY_H
|
||||
@ -389,6 +389,76 @@ public:
|
||||
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 MercWeaponinfo &e
|
||||
)
|
||||
{
|
||||
std::vector<std::string> v;
|
||||
|
||||
v.push_back(std::to_string(e.id));
|
||||
v.push_back(std::to_string(e.merc_npc_type_id));
|
||||
v.push_back(std::to_string(e.minlevel));
|
||||
v.push_back(std::to_string(e.maxlevel));
|
||||
v.push_back(std::to_string(e.d_melee_texture1));
|
||||
v.push_back(std::to_string(e.d_melee_texture2));
|
||||
v.push_back(std::to_string(e.prim_melee_type));
|
||||
v.push_back(std::to_string(e.sec_melee_type));
|
||||
|
||||
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<MercWeaponinfo> &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.merc_npc_type_id));
|
||||
v.push_back(std::to_string(e.minlevel));
|
||||
v.push_back(std::to_string(e.maxlevel));
|
||||
v.push_back(std::to_string(e.d_melee_texture1));
|
||||
v.push_back(std::to_string(e.d_melee_texture2));
|
||||
v.push_back(std::to_string(e.prim_melee_type));
|
||||
v.push_back(std::to_string(e.sec_melee_type));
|
||||
|
||||
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_MERC_WEAPONINFO_REPOSITORY_H
|
||||
|
||||
@ -44,7 +44,38 @@ public:
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
static std::vector<MercStanceEntriesRepository::MercStanceEntries> GetAllOrdered(Database& db)
|
||||
{
|
||||
std::vector<MercStanceEntriesRepository::MercStanceEntries> v;
|
||||
|
||||
auto results = db.QueryDatabase(
|
||||
fmt::format(
|
||||
"SELECT {} FROM {} ORDER BY `class_id`, `proficiency_id`, `stance_id`",
|
||||
SelectColumnsRaw(),
|
||||
TableName()
|
||||
)
|
||||
);
|
||||
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return v;
|
||||
}
|
||||
|
||||
v.reserve(results.RowCount());
|
||||
|
||||
auto e = MercStanceEntriesRepository::NewEntity();
|
||||
|
||||
for (auto row : results) {
|
||||
e.merc_stance_entry_id = Strings::ToUnsignedInt(row[0]);
|
||||
e.class_id = Strings::ToUnsignedInt(row[1]);
|
||||
e.proficiency_id = static_cast<uint8_t>(Strings::ToUnsignedInt(row[2]));
|
||||
e.stance_id = static_cast<uint8_t>(Strings::ToUnsignedInt(row[3]));
|
||||
e.isdefault = static_cast<int8_t>(Strings::ToInt(row[4]));
|
||||
|
||||
v.emplace_back(e);
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_MERC_STANCE_ENTRIES_REPOSITORY_H
|
||||
|
||||
@ -44,7 +44,27 @@ public:
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
static int GetSubtype(
|
||||
Database& db,
|
||||
uint8 class_id,
|
||||
uint8 tier_id
|
||||
)
|
||||
{
|
||||
const auto& l = GetWhere(
|
||||
db,
|
||||
fmt::format(
|
||||
"`class_id` = {} AND `tier_id` = {}",
|
||||
class_id,
|
||||
tier_id
|
||||
)
|
||||
);
|
||||
|
||||
if (l.empty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return l[0].merc_subtype_id;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_MERC_SUBTYPES_REPOSITORY_H
|
||||
|
||||
@ -44,7 +44,23 @@ public:
|
||||
*/
|
||||
|
||||
// Custom extended repository methods here
|
||||
static MercsRepository::Mercs GetMercenaryBySlot(Database& db, Client* c)
|
||||
{
|
||||
const auto& l = MercsRepository::GetWhere(
|
||||
db,
|
||||
fmt::format(
|
||||
"`OwnerCharacterID` = {} AND `Slot` = {}",
|
||||
c->CharacterID(),
|
||||
c->GetMercSlot()
|
||||
)
|
||||
);
|
||||
|
||||
if (l.empty()) {
|
||||
return MercsRepository::NewEntity();
|
||||
}
|
||||
|
||||
return l[0];
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EQEMU_MERCS_REPOSITORY_H
|
||||
|
||||
@ -220,8 +220,8 @@ Json::Value ApiGetNpcListDetail(EQ::Net::WebsocketServerConnection *connection,
|
||||
row["npc_spells_effects_id"] = npc->GetNPCSpellsEffectsID();
|
||||
row["npc_spells_id"] = npc->GetNPCSpellsID();
|
||||
row["npchp_regen"] = npc->GetNPCHPRegen();
|
||||
row["num_merc_types"] = npc->GetNumMercTypes();
|
||||
row["num_mercs"] = npc->GetNumMercs();
|
||||
row["num_merc_types"] = npc->GetNumMercenaryTypes();
|
||||
row["num_mercs"] = npc->GetNumberOfMercenaries();
|
||||
row["number_of_attacks"] = npc->GetNumberOfAttacks();
|
||||
row["pet_spell_id"] = npc->GetPetSpellID();
|
||||
row["platinum"] = npc->GetPlatinum();
|
||||
@ -734,11 +734,11 @@ Json::Value ApiGetClientListDetail(EQ::Net::WebsocketServerConnection *connectio
|
||||
row["ls_account_id"] = client->LSAccountID();
|
||||
row["max_endurance"] = client->GetMaxEndurance();
|
||||
row["max_x_tars"] = client->GetMaxXTargets();
|
||||
row["merc_id"] = client->GetMercID();
|
||||
row["merc_id"] = client->GetMercenaryID();
|
||||
row["merc_only_or_no_group"] = client->MercOnlyOrNoGroup();
|
||||
row["merc_slot"] = client->GetMercSlot();
|
||||
row["next_inv_snapshot_time"] = client->GetNextInvSnapshotTime();
|
||||
row["num_mercs"] = client->GetNumMercs();
|
||||
row["num_mercs"] = client->GetNumberOfMercenaries();
|
||||
row["pending_adventure_create"] = client->GetPendingAdventureCreate();
|
||||
row["pending_adventure_door_click"] = client->GetPendingAdventureDoorClick();
|
||||
row["pending_adventure_leave"] = client->GetPendingAdventureLeave();
|
||||
|
||||
@ -3036,12 +3036,12 @@ void Mob::AddToHateList(Mob* other, int64 hate /*= 0*/, int64 damage /*= 0*/, bo
|
||||
|
||||
// if other is a merc, add the merc client to the hate list
|
||||
if (other->IsMerc()) {
|
||||
if (other->CastToMerc()->GetMercOwner() && other->CastToMerc()->GetMercOwner()->CastToClient()->GetFeigned()) {
|
||||
AddFeignMemory(other->CastToMerc()->GetMercOwner()->CastToClient());
|
||||
if (other->CastToMerc()->GetMercenaryOwner() && other->CastToMerc()->GetMercenaryOwner()->CastToClient()->GetFeigned()) {
|
||||
AddFeignMemory(other->CastToMerc()->GetMercenaryOwner()->CastToClient());
|
||||
}
|
||||
else {
|
||||
if (!hate_list.IsEntOnHateList(other->CastToMerc()->GetMercOwner()))
|
||||
hate_list.AddEntToHateList(other->CastToMerc()->GetMercOwner(), 0, 0, false, true);
|
||||
if (!hate_list.IsEntOnHateList(other->CastToMerc()->GetMercenaryOwner()))
|
||||
hate_list.AddEntToHateList(other->CastToMerc()->GetMercenaryOwner(), 0, 0, false, true);
|
||||
// if mercs are reworked to include adding 'this' to owner's xtarget list, this should reflect bots code above
|
||||
}
|
||||
} //MERC
|
||||
|
||||
@ -395,7 +395,7 @@ Client::~Client() {
|
||||
if (horse)
|
||||
horse->Depop();
|
||||
|
||||
Mob* merc = entity_list.GetMob(GetMercID());
|
||||
Mob* merc = entity_list.GetMob(GetMercenaryID());
|
||||
if (merc)
|
||||
merc->Depop();
|
||||
|
||||
|
||||
@ -1554,14 +1554,14 @@ public:
|
||||
bool CheckCanUnsuspendMerc();
|
||||
bool DismissMerc(uint32 MercID);
|
||||
bool MercOnlyOrNoGroup();
|
||||
inline uint32 GetMercID() const { return mercid; }
|
||||
inline uint32 GetMercenaryID() const { return mercid; }
|
||||
inline uint8 GetMercSlot() const { return mercSlot; }
|
||||
void SetMercID( uint32 newmercid) { mercid = newmercid; }
|
||||
void SetMercSlot( uint8 newmercslot) { mercSlot = newmercslot; }
|
||||
Merc* GetMerc();
|
||||
MercInfo& GetMercInfo(uint8 slot) { return m_mercinfo[slot]; }
|
||||
MercInfo& GetMercInfo() { return m_mercinfo[mercSlot]; }
|
||||
uint8 GetNumMercs();
|
||||
uint8 GetNumberOfMercenaries();
|
||||
void SetMerc(Merc* newmerc);
|
||||
void SendMercResponsePackets(uint32 ResponseType);
|
||||
void SendMercMerchantResponsePacket(int32 response_type);
|
||||
|
||||
@ -6257,7 +6257,7 @@ void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint32 mod = spellbonuses.ReduceFallDamage + itembonuses.ReduceFallDamage + aabonuses.ReduceFallDamage;
|
||||
damage -= damage * mod / 100;
|
||||
}
|
||||
@ -7337,7 +7337,7 @@ void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
GroupInvite_Struct* gis = (GroupInvite_Struct*)app->pBuffer;
|
||||
|
||||
|
||||
Mob* invitee = nullptr;
|
||||
|
||||
if (RuleB(Character, GroupInvitesRequireTarget)) {
|
||||
@ -7385,7 +7385,7 @@ void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
|
||||
} else {
|
||||
if (RuleB(Character, OnInviteReceiveAlreadyinGroupMessage)) {
|
||||
if (!invitee->CastToClient()->MercOnlyOrNoGroup()) {
|
||||
@ -10191,14 +10191,14 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app)
|
||||
uint8 numStances = 0;
|
||||
|
||||
//get number of available stances for the current merc
|
||||
std::list<MercStanceInfo> mercStanceList = zone->merc_stance_list[merc->GetMercTemplateID()];
|
||||
std::list<MercStanceInfo> mercStanceList = zone->merc_stance_list[merc->GetMercenaryTemplateID()];
|
||||
auto iter = mercStanceList.begin();
|
||||
while (iter != mercStanceList.end()) {
|
||||
numStances++;
|
||||
++iter;
|
||||
}
|
||||
|
||||
MercTemplate* mercTemplate = zone->GetMercTemplate(GetMerc()->GetMercTemplateID());
|
||||
MercTemplate* mercTemplate = zone->GetMercTemplate(GetMerc()->GetMercenaryTemplateID());
|
||||
if (mercTemplate)
|
||||
{
|
||||
//check to see if selected option is a valid stance slot (option is the slot the stance is in, not the actual stance)
|
||||
@ -10264,14 +10264,14 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
mercTypeCount = tar->GetNumMercTypes(static_cast<unsigned int>(ClientVersion()));
|
||||
mercCount = tar->GetNumMercs(static_cast<unsigned int>(ClientVersion()));
|
||||
mercTypeCount = tar->GetNumMercenaryTypes(static_cast<unsigned int>(ClientVersion()));
|
||||
mercCount = tar->GetNumberOfMercenaries(static_cast<unsigned int>(ClientVersion()));
|
||||
|
||||
if (mercCount > MAX_MERC)
|
||||
return;
|
||||
|
||||
std::list<MercType> mercTypeList = tar->GetMercTypesList(static_cast<unsigned int>(ClientVersion()));
|
||||
std::list<MercData> mercDataList = tar->GetMercsList(static_cast<unsigned int>(ClientVersion()));
|
||||
std::list<MercType> mercTypeList = tar->GetMercenaryTypesList(static_cast<unsigned int>(ClientVersion()));
|
||||
std::list<MercData> mercDataList = tar->GetMercenariesList(static_cast<unsigned int>(ClientVersion()));
|
||||
|
||||
int i = 0;
|
||||
int StanceCount = 0;
|
||||
@ -10358,7 +10358,7 @@ void Client::Handle_OP_MercenaryDataUpdateRequest(const EQApplicationPacket *app
|
||||
|
||||
Log(Logs::General, Logs::Mercenaries, "Data Update Request Received for %s.", GetName());
|
||||
|
||||
if (GetMercID())
|
||||
if (GetMercenaryID())
|
||||
{
|
||||
SendMercPersonalInfo();
|
||||
}
|
||||
@ -10431,7 +10431,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app)
|
||||
GetMercInfo().MercTimerRemaining = RuleI(Mercs, UpkeepIntervalMS);
|
||||
|
||||
// Get merc, assign it to client & spawn
|
||||
Merc* merc = Merc::LoadMerc(this, merc_template, merchant_id, false);
|
||||
Merc* merc = Merc::LoadMercenary(this, merc_template, merchant_id, false);
|
||||
|
||||
if (merc)
|
||||
{
|
||||
@ -10504,7 +10504,7 @@ void Client::Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app)
|
||||
uint32 entityID = 0;
|
||||
uint32 mercState = 5;
|
||||
uint32 suspendedTime = 0;
|
||||
if (GetMercID()) {
|
||||
if (GetMercenaryID()) {
|
||||
Merc* merc = GetMerc();
|
||||
|
||||
if (merc) {
|
||||
|
||||
@ -665,7 +665,7 @@ void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
|
||||
}
|
||||
level_count++;
|
||||
|
||||
if(GetMercID())
|
||||
if(GetMercenaryID())
|
||||
UpdateMercLevel();
|
||||
}
|
||||
//see if we lost any levels
|
||||
@ -676,7 +676,7 @@ void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
|
||||
break;
|
||||
}
|
||||
level_increase = false;
|
||||
if(GetMercID())
|
||||
if(GetMercenaryID())
|
||||
UpdateMercLevel();
|
||||
}
|
||||
check_level--;
|
||||
|
||||
@ -233,7 +233,7 @@ bool Group::AddMember(Mob* newmember, const char *NewMemberName, uint32 Characte
|
||||
}
|
||||
if(newmember->IsMerc())
|
||||
{
|
||||
Client* owner = newmember->CastToMerc()->GetMercOwner();
|
||||
Client* owner = newmember->CastToMerc()->GetMercenaryOwner();
|
||||
if(owner)
|
||||
{
|
||||
CharacterID = owner->CastToClient()->CharacterID();
|
||||
@ -331,7 +331,7 @@ bool Group::AddMember(Mob* newmember, const char *NewMemberName, uint32 Characte
|
||||
|
||||
if(newmember->IsMerc())
|
||||
{
|
||||
Client* owner = newmember->CastToMerc()->GetMercOwner();
|
||||
Client* owner = newmember->CastToMerc()->GetMercenaryOwner();
|
||||
if(owner)
|
||||
{
|
||||
database.SetGroupID(NewMemberName, GetID(), owner->CharacterID(), true);
|
||||
@ -757,7 +757,7 @@ bool Group::DelMember(Mob* oldmember, bool ignoresender)
|
||||
|
||||
if(oldmember->IsMerc())
|
||||
{
|
||||
Client* owner = oldmember->CastToMerc()->GetMercOwner();
|
||||
Client* owner = oldmember->CastToMerc()->GetMercenaryOwner();
|
||||
if(owner)
|
||||
{
|
||||
database.SetGroupID(oldmember->GetCleanName(), 0, owner->CharacterID(), true);
|
||||
@ -952,7 +952,7 @@ void Group::DisbandGroup(bool joinraid) {
|
||||
|
||||
if (members[i]->IsMerc())
|
||||
{
|
||||
Client* owner = members[i]->CastToMerc()->GetMercOwner();
|
||||
Client* owner = members[i]->CastToMerc()->GetMercenaryOwner();
|
||||
if(owner)
|
||||
{
|
||||
database.SetGroupID(members[i]->GetCleanName(), 0, owner->CharacterID(), true);
|
||||
|
||||
205
zone/merc.cpp
205
zone/merc.cpp
@ -857,7 +857,7 @@ bool Merc::Process()
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!GetMercOwner()) {
|
||||
if(!GetMercenaryOwner()) {
|
||||
//p_depop = true; //this was causing a crash - removed merc from entity list, but not group
|
||||
//return false; //merc can live after client dies, not sure how long
|
||||
}
|
||||
@ -867,8 +867,8 @@ bool Merc::Process()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (HasGroup() && GetMercOwner() && GetFollowID() == 0) {
|
||||
SetFollowID(GetMercOwner()->GetID());
|
||||
if (HasGroup() && GetMercenaryOwner() && GetFollowID() == 0) {
|
||||
SetFollowID(GetMercenaryOwner()->GetID());
|
||||
}
|
||||
|
||||
SpellProcess();
|
||||
@ -1691,7 +1691,7 @@ bool Merc::AICastSpell(int8 iChance, uint32 iSpellTypes) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(hpr < checkHPR && g->members[i] == GetMercOwner()) {
|
||||
if(hpr < checkHPR && g->members[i] == GetMercenaryOwner()) {
|
||||
if(!tar || (hpr < tar->GetHPRatio() || (tar->IsPet() && hpr < checkPetHPR)))
|
||||
tar = g->members[i]; //check owner first
|
||||
}
|
||||
@ -4076,8 +4076,8 @@ void Merc::SetTarget(Mob* mob) {
|
||||
Mob* Merc::GetOwnerOrSelf() {
|
||||
Mob* Result = nullptr;
|
||||
|
||||
if(GetMercOwner())
|
||||
Result = GetMercOwner();
|
||||
if(GetMercenaryOwner())
|
||||
Result = GetMercenaryOwner();
|
||||
else
|
||||
Result = this;
|
||||
|
||||
@ -4108,7 +4108,7 @@ bool Merc::Death(Mob* killerMob, int64 damage, uint16 spell, EQ::skills::SkillTy
|
||||
return true;
|
||||
}
|
||||
|
||||
Client* Merc::GetMercOwner() {
|
||||
Client* Merc::GetMercenaryOwner() {
|
||||
Client* mercOwner = nullptr;
|
||||
|
||||
if(GetOwner())
|
||||
@ -4230,7 +4230,7 @@ const char* Merc::GetRandomName(){
|
||||
return name;
|
||||
}
|
||||
|
||||
bool Merc::LoadMercSpells() {
|
||||
bool Merc::LoadMercenarySpells() {
|
||||
// loads mercs spells into list
|
||||
merc_spells.clear();
|
||||
|
||||
@ -4278,18 +4278,18 @@ bool Merc::LoadMercSpells() {
|
||||
|
||||
bool Merc::Save() {
|
||||
|
||||
if(database.SaveMerc(this)){
|
||||
if(database.SaveMercenary(this)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id, bool updateFromDB) {
|
||||
Merc* Merc::LoadMercenary(Client *c, MercTemplate* merc_template, uint32 merchant_id, bool updateFromDB) {
|
||||
|
||||
if(c)
|
||||
{
|
||||
if(c->GetMercID())
|
||||
if(c->GetMercenaryID())
|
||||
{
|
||||
merc_template = zone->GetMercTemplate(c->GetMercInfo().MercTemplateID);
|
||||
}
|
||||
@ -4302,7 +4302,7 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id,
|
||||
|
||||
const NPCType* npc_type_to_copy = nullptr;
|
||||
if (c) {
|
||||
npc_type_to_copy = content_db.GetMercType(merc_template->MercNPCID, merc_template->RaceID, c->GetLevel());
|
||||
npc_type_to_copy = content_db.GetMercenaryType(merc_template->MercNPCID, merc_template->RaceID, c->GetLevel());
|
||||
}
|
||||
|
||||
if(npc_type_to_copy != nullptr)
|
||||
@ -4365,12 +4365,12 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id,
|
||||
if(merc)
|
||||
{
|
||||
merc->SetMercData( merc_template->MercTemplateID );
|
||||
database.LoadMercEquipment(merc);
|
||||
database.LoadMercenaryEquipment(merc);
|
||||
merc->UpdateMercStats(c, true);
|
||||
|
||||
if(updateFromDB)
|
||||
{
|
||||
database.LoadCurrentMerc(c);
|
||||
database.LoadCurrentMercenary(c);
|
||||
|
||||
merc->SetMercID(c->GetMercInfo().mercid);
|
||||
snprintf(merc->name, 64, "%s", c->GetMercInfo().merc_name);
|
||||
@ -4397,11 +4397,11 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id,
|
||||
merc->RandomizeFeatures(false, true);
|
||||
}
|
||||
|
||||
if(merc->GetMercID()) {
|
||||
database.LoadMercBuffs(merc);
|
||||
if(merc->GetMercenaryID()) {
|
||||
database.LoadMercenaryBuffs(merc);
|
||||
}
|
||||
|
||||
merc->LoadMercSpells();
|
||||
merc->LoadMercenarySpells();
|
||||
}
|
||||
|
||||
Log(Logs::General, Logs::Mercenaries, "LoadMerc Successful for %s (%s).", merc->GetName(), c->GetName());
|
||||
@ -4414,7 +4414,7 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id,
|
||||
|
||||
void Merc::UpdateMercInfo(Client *c) {
|
||||
snprintf(c->GetMercInfo().merc_name, 64, "%s", name);
|
||||
c->GetMercInfo().mercid = GetMercID();
|
||||
c->GetMercInfo().mercid = GetMercenaryID();
|
||||
c->GetMercInfo().IsSuspended = IsSuspended();
|
||||
c->GetMercInfo().Gender = GetGender();
|
||||
c->GetMercInfo().MercSize = GetSize();
|
||||
@ -4438,7 +4438,7 @@ void Merc::UpdateMercStats(Client *c, bool setmax)
|
||||
if (c->GetMercInfo().MercTemplateID > 0) {
|
||||
Log(Logs::General, Logs::Mercenaries, "Updating Mercenary Stats for %s (%s).", GetName(),
|
||||
c->GetName());
|
||||
const NPCType *npc_type = content_db.GetMercType(
|
||||
const NPCType *npc_type = content_db.GetMercenaryType(
|
||||
zone->GetMercTemplate(c->GetMercInfo().MercTemplateID)->MercNPCID, GetRace(), c->GetLevel());
|
||||
if (npc_type) {
|
||||
max_hp = npc_type->max_hp;
|
||||
@ -4674,7 +4674,7 @@ bool Merc::Spawn(Client *owner) {
|
||||
if(!owner)
|
||||
return false;
|
||||
|
||||
MercTemplate* merc_template = zone->GetMercTemplate(GetMercTemplateID());
|
||||
MercTemplate* merc_template = zone->GetMercTemplate(GetMercenaryTemplateID());
|
||||
|
||||
if(!merc_template)
|
||||
return false;
|
||||
@ -4841,7 +4841,7 @@ void Client::UpdateMercTimer()
|
||||
{
|
||||
if(GetMercTimer()->Check())
|
||||
{
|
||||
uint32 upkeep = merc->CalcUpkeepCost(merc->GetMercTemplateID(), GetLevel());
|
||||
uint32 upkeep = merc->CalcUpkeepCost(merc->GetMercenaryTemplateID(), GetLevel());
|
||||
|
||||
if(CheckCanRetainMerc(upkeep))
|
||||
{
|
||||
@ -4898,7 +4898,7 @@ bool Client::CheckCanHireMerc(Mob* merchant, uint32 template_id) {
|
||||
}
|
||||
|
||||
// Check if max number of mercs is already reached
|
||||
if(GetNumMercs() >= MAXMERCS) {
|
||||
if(GetNumberOfMercenaries() >= MAXMERCS) {
|
||||
SendMercResponsePackets(6);
|
||||
return false;
|
||||
}
|
||||
@ -5053,7 +5053,7 @@ void Client::SuspendMercCommand() {
|
||||
}
|
||||
|
||||
// Get merc, assign it to client & spawn
|
||||
Merc* merc = Merc::LoadMerc(this, &zone->merc_templates[GetMercInfo().MercTemplateID], 0, true);
|
||||
Merc* merc = Merc::LoadMercenary(this, &zone->merc_templates[GetMercInfo().MercTemplateID], 0, true);
|
||||
if(merc)
|
||||
{
|
||||
SpawnMerc(merc, false);
|
||||
@ -5079,7 +5079,7 @@ void Client::SuspendMercCommand() {
|
||||
}
|
||||
}
|
||||
|
||||
if(CurrentMerc && GetMercID())
|
||||
if(CurrentMerc && GetMercenaryID())
|
||||
{
|
||||
CurrentMerc->Suspend();
|
||||
Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Successful Suspend for %s.", GetName());
|
||||
@ -5123,13 +5123,13 @@ void Client::SpawnMercOnZone() {
|
||||
if (GetMerc())
|
||||
return;
|
||||
|
||||
if(database.LoadMercInfo(this))
|
||||
if(database.LoadMercenaryInfo(this))
|
||||
{
|
||||
if(!GetMercInfo().IsSuspended)
|
||||
{
|
||||
GetMercInfo().SuspendedTime = 0;
|
||||
// Get merc, assign it to client & spawn
|
||||
Merc* merc = Merc::LoadMerc(this, &zone->merc_templates[GetMercInfo().MercTemplateID], 0, true);
|
||||
Merc* merc = Merc::LoadMercenary(this, &zone->merc_templates[GetMercInfo().MercTemplateID], 0, true);
|
||||
if(merc)
|
||||
{
|
||||
SpawnMerc(merc, false);
|
||||
@ -5189,7 +5189,7 @@ void Client::SendMercTimer(Merc* merc) {
|
||||
|
||||
void Client::SpawnMerc(Merc* merc, bool setMaxStats) {
|
||||
|
||||
if (!merc || !CheckCanSpawnMerc(merc->GetMercTemplateID()))
|
||||
if (!merc || !CheckCanSpawnMerc(merc->GetMercenaryTemplateID()))
|
||||
{
|
||||
if (merc)
|
||||
{
|
||||
@ -5212,7 +5212,7 @@ void Client::SpawnMerc(Merc* merc, bool setMaxStats) {
|
||||
|
||||
bool Merc::Suspend() {
|
||||
|
||||
Client* mercOwner = GetMercOwner();
|
||||
Client* mercOwner = GetMercenaryOwner();
|
||||
|
||||
if(!mercOwner)
|
||||
return false;
|
||||
@ -5261,8 +5261,8 @@ bool Merc::Unsuspend(bool setMaxStats) {
|
||||
|
||||
Client* mercOwner = nullptr;
|
||||
|
||||
if(GetMercOwner()) {
|
||||
mercOwner = GetMercOwner();
|
||||
if(GetMercenaryOwner()) {
|
||||
mercOwner = GetMercenaryOwner();
|
||||
}
|
||||
|
||||
if(!mercOwner)
|
||||
@ -5273,7 +5273,7 @@ bool Merc::Unsuspend(bool setMaxStats) {
|
||||
// Set time remaining to max on unsuspend - there is a charge for unsuspending as well
|
||||
SetSuspended(false);
|
||||
|
||||
mercOwner->GetMercInfo().mercid = GetMercID();
|
||||
mercOwner->GetMercInfo().mercid = GetMercenaryID();
|
||||
mercOwner->GetMercInfo().IsSuspended = false;
|
||||
|
||||
mercOwner->SendMercenaryUnsuspendPacket(0);
|
||||
@ -5299,7 +5299,7 @@ bool Merc::Unsuspend(bool setMaxStats) {
|
||||
//check for sufficient funds and remove them last
|
||||
if(RuleB(Mercs, ChargeMercUpkeepCost))
|
||||
{
|
||||
uint32 cost = CalcUpkeepCost(GetMercTemplateID(), GetLevel()) * 100; // Cost is in gold
|
||||
uint32 cost = CalcUpkeepCost(GetMercenaryTemplateID(), GetLevel()) * 100; // Cost is in gold
|
||||
if(cost > 0 && !mercOwner->HasMoney(cost))
|
||||
{
|
||||
mercOwner->SendMercResponsePackets(1);
|
||||
@ -5317,7 +5317,7 @@ bool Merc::Unsuspend(bool setMaxStats) {
|
||||
bool Client::DismissMerc(uint32 MercID) {
|
||||
|
||||
bool Dismissed = true;
|
||||
if (!database.DeleteMerc(MercID))
|
||||
if (!database.DeleteMercenary(MercID))
|
||||
{
|
||||
Log(Logs::General, Logs::Mercenaries, "Dismiss Failed Database Query for MercID: %i, Client: %s.", MercID, GetName());
|
||||
Dismissed = false;
|
||||
@ -5390,9 +5390,9 @@ bool Merc::RemoveMercFromGroup(Merc* merc, Group* group) {
|
||||
}
|
||||
else if(group->DelMember(merc, true))
|
||||
{
|
||||
if(merc->GetMercCharacterID() != 0)
|
||||
if(merc->GetMercenaryCharacterID() != 0)
|
||||
{
|
||||
database.SetGroupID(merc->GetName(), 0, merc->GetMercCharacterID(), true);
|
||||
database.SetGroupID(merc->GetName(), 0, merc->GetMercenaryCharacterID(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5433,9 +5433,9 @@ bool Merc::MercJoinClientGroup() {
|
||||
|
||||
Client* mercOwner = nullptr;
|
||||
|
||||
if(GetMercOwner())
|
||||
if(GetMercenaryOwner())
|
||||
{
|
||||
mercOwner = GetMercOwner();
|
||||
mercOwner = GetMercenaryOwner();
|
||||
}
|
||||
|
||||
if(!mercOwner)
|
||||
@ -5516,18 +5516,18 @@ bool Merc::AddMercToGroup(Merc* merc, Group* group) {
|
||||
// Remove merc from current group if it's not the destination group
|
||||
if(merc->HasGroup())
|
||||
{
|
||||
if(merc->GetGroup() == group && merc->GetMercOwner())
|
||||
if(merc->GetGroup() == group && merc->GetMercenaryOwner())
|
||||
{
|
||||
// Merc is already in the destination group
|
||||
merc->SetFollowID(merc->GetMercOwner()->GetID());
|
||||
merc->SetFollowID(merc->GetMercenaryOwner()->GetID());
|
||||
return true;
|
||||
}
|
||||
merc->RemoveMercFromGroup(merc, merc->GetGroup());
|
||||
}
|
||||
//Try and add the member, followed by checking if the merc owner exists.
|
||||
if(group->AddMember(merc) && merc->GetMercOwner())
|
||||
if(group->AddMember(merc) && merc->GetMercenaryOwner())
|
||||
{
|
||||
merc->SetFollowID(merc->GetMercOwner()->GetID());
|
||||
merc->SetFollowID(merc->GetMercenaryOwner()->GetID());
|
||||
Result = true;
|
||||
}
|
||||
else
|
||||
@ -5551,13 +5551,13 @@ void Client::InitializeMercInfo() {
|
||||
|
||||
Merc* Client::GetMerc() {
|
||||
|
||||
if(GetMercID() == 0)
|
||||
if(GetMercenaryID() == 0)
|
||||
{
|
||||
Log(Logs::Detail, Logs::Mercenaries, "GetMerc - GetMercID: 0 for %s.", GetName());
|
||||
Log(Logs::Detail, Logs::Mercenaries, "GetMerc - GetMercenaryID: 0 for %s.", GetName());
|
||||
return (nullptr);
|
||||
}
|
||||
|
||||
Merc* tmp = entity_list.GetMercByID(GetMercID());
|
||||
Merc* tmp = entity_list.GetMercByID(GetMercenaryID());
|
||||
if(tmp == nullptr)
|
||||
{
|
||||
SetMercID(0);
|
||||
@ -5575,7 +5575,7 @@ Merc* Client::GetMerc() {
|
||||
return (tmp);
|
||||
}
|
||||
|
||||
uint8 Client::GetNumMercs() {
|
||||
uint8 Client::GetNumberOfMercenaries() {
|
||||
|
||||
uint8 numMercs = 0;
|
||||
|
||||
@ -5586,7 +5586,7 @@ uint8 Client::GetNumMercs() {
|
||||
numMercs++;
|
||||
}
|
||||
}
|
||||
Log(Logs::General, Logs::Mercenaries, "GetNumMercs Number: %i for %s.", numMercs, GetName());
|
||||
Log(Logs::General, Logs::Mercenaries, "GetNumberOfMercenaries Number: %i for %s.", numMercs, GetName());
|
||||
|
||||
return numMercs;
|
||||
}
|
||||
@ -5636,8 +5636,8 @@ void Client::SetMerc(Merc* newmerc) {
|
||||
newmerc->SetOwnerID(GetID());
|
||||
newmerc->SetMercCharacterID(CharacterID());
|
||||
newmerc->SetClientVersion((uint8)ClientVersion());
|
||||
GetMercInfo().mercid = newmerc->GetMercID();
|
||||
GetMercInfo().MercTemplateID = newmerc->GetMercTemplateID();
|
||||
GetMercInfo().mercid = newmerc->GetMercenaryID();
|
||||
GetMercInfo().MercTemplateID = newmerc->GetMercenaryTemplateID();
|
||||
GetMercInfo().myTemplate = zone->GetMercTemplate(GetMercInfo().MercTemplateID);
|
||||
GetMercInfo().IsSuspended = newmerc->IsSuspended();
|
||||
GetMercInfo().SuspendedTime = 0;
|
||||
@ -5722,75 +5722,78 @@ void Client::SendMercAssignPacket(uint32 entityID, uint32 unk01, uint32 unk02) {
|
||||
Log(Logs::Detail, Logs::Mercenaries, "Sent SendMercAssignPacket EndID: %i, Unk1: %i, Unk2: %i, Client: %s.", entityID, unk01, unk02, GetName());
|
||||
}
|
||||
|
||||
void NPC::LoadMercTypes() {
|
||||
void NPC::LoadMercenaryTypes()
|
||||
{
|
||||
const std::string& query = fmt::format(
|
||||
SQL(
|
||||
SELECT DISTINCT MTyp.dbstring, MTyp.clientversion
|
||||
FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE,
|
||||
merc_types MTyp, merc_templates MTem
|
||||
WHERE MME.merchant_id = {}
|
||||
AND MME.merc_merchant_template_id = MMTE.merc_merchant_template_id
|
||||
AND MMTE.merc_template_id = MTem.merc_template_id
|
||||
AND MTem.merc_type_id = MTyp.merc_type_id
|
||||
),
|
||||
GetNPCTypeID()
|
||||
);
|
||||
|
||||
std::string query = StringFormat("SELECT DISTINCT MTyp.dbstring, MTyp.clientversion "
|
||||
"FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE, "
|
||||
"merc_types MTyp, merc_templates MTem "
|
||||
"WHERE MME.merchant_id = %i "
|
||||
"AND MME.merc_merchant_template_id = MMTE.merc_merchant_template_id "
|
||||
"AND MMTE.merc_template_id = MTem.merc_template_id "
|
||||
"AND MTem.merc_type_id = MTyp.merc_type_id;", GetNPCTypeID());
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
LogError("Error in NPC::LoadMercTypes()");
|
||||
if (!results.Success()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
MercType tempMercType;
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
MercType t;
|
||||
|
||||
tempMercType.Type = Strings::ToInt(row[0]);
|
||||
tempMercType.ClientVersion = Strings::ToInt(row[1]);
|
||||
t.Type = Strings::ToInt(row[0]);
|
||||
t.ClientVersion = Strings::ToInt(row[1]);
|
||||
|
||||
mercTypeList.push_back(tempMercType);
|
||||
mercTypeList.push_back(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NPC::LoadMercs() {
|
||||
void NPC::LoadMercenaries()
|
||||
{
|
||||
const std::string& query = fmt::format(
|
||||
SQL(
|
||||
SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring AS merc_type_id,
|
||||
MTem.dbstring AS merc_subtype_id, 0 AS CostFormula,
|
||||
CASE WHEN MTem.clientversion > MTyp.clientversion
|
||||
THEN MTem.clientversion
|
||||
ELSE MTyp.clientversion END AS clientversion, MTem.merc_npc_type_id
|
||||
FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE,
|
||||
merc_types MTyp, merc_templates MTem
|
||||
WHERE MME.merchant_id = {} AND
|
||||
MME.merc_merchant_template_id = MMTE.merc_merchant_template_id
|
||||
AND MMTE.merc_template_id = MTem.merc_template_id
|
||||
AND MTem.merc_type_id = MTyp.merc_type_id
|
||||
),
|
||||
GetNPCTypeID()
|
||||
);
|
||||
|
||||
std::string query = StringFormat("SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring AS merc_type_id, "
|
||||
"MTem.dbstring AS merc_subtype_id, 0 AS CostFormula, "
|
||||
"CASE WHEN MTem.clientversion > MTyp.clientversion "
|
||||
"THEN MTem.clientversion "
|
||||
"ELSE MTyp.clientversion END AS clientversion, MTem.merc_npc_type_id "
|
||||
"FROM merc_merchant_entries MME, merc_merchant_template_entries MMTE, "
|
||||
"merc_types MTyp, merc_templates MTem "
|
||||
"WHERE MME.merchant_id = %i AND "
|
||||
"MME.merc_merchant_template_id = MMTE.merc_merchant_template_id "
|
||||
"AND MMTE.merc_template_id = MTem.merc_template_id "
|
||||
"AND MTem.merc_type_id = MTyp.merc_type_id;", GetNPCTypeID());
|
||||
auto results = database.QueryDatabase(query);
|
||||
|
||||
if (!results.Success())
|
||||
{
|
||||
LogError("Error in NPC::LoadMercTypes()");
|
||||
if (!results.Success()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row)
|
||||
{
|
||||
MercData tempMerc;
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
MercData t;
|
||||
|
||||
tempMerc.MercTemplateID = Strings::ToInt(row[0]);
|
||||
tempMerc.MercType = Strings::ToInt(row[1]);
|
||||
tempMerc.MercSubType = Strings::ToInt(row[2]);
|
||||
tempMerc.CostFormula = Strings::ToInt(row[3]);
|
||||
tempMerc.ClientVersion = Strings::ToInt(row[4]);
|
||||
tempMerc.NPCID = Strings::ToInt(row[5]);
|
||||
t.MercTemplateID = Strings::ToInt(row[0]);
|
||||
t.MercType = Strings::ToInt(row[1]);
|
||||
t.MercSubType = Strings::ToInt(row[2]);
|
||||
t.CostFormula = Strings::ToInt(row[3]);
|
||||
t.ClientVersion = Strings::ToInt(row[4]);
|
||||
t.NPCID = Strings::ToInt(row[5]);
|
||||
|
||||
mercDataList.push_back(tempMerc);
|
||||
mercDataList.push_back(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int NPC::GetNumMercTypes(uint32 clientVersion) {
|
||||
int NPC::GetNumMercenaryTypes(uint32 clientVersion) {
|
||||
|
||||
int count = 0;
|
||||
std::list<MercType> mercTypeList = GetMercTypesList();
|
||||
std::list<MercType> mercTypeList = GetMercenaryTypesList();
|
||||
|
||||
for (auto mercTypeListItr = mercTypeList.begin(); mercTypeListItr != mercTypeList.end(); ++mercTypeListItr) {
|
||||
if(mercTypeListItr->ClientVersion <= clientVersion)
|
||||
@ -5800,10 +5803,10 @@ int NPC::GetNumMercTypes(uint32 clientVersion) {
|
||||
return count;
|
||||
}
|
||||
|
||||
int NPC::GetNumMercs(uint32 clientVersion) {
|
||||
int NPC::GetNumberOfMercenaries(uint32 clientVersion) {
|
||||
|
||||
int count = 0;
|
||||
std::list<MercData> mercDataList = GetMercsList();
|
||||
std::list<MercData> mercDataList = GetMercenariesList();
|
||||
|
||||
for (auto mercListItr = mercDataList.begin(); mercListItr != mercDataList.end(); ++mercListItr) {
|
||||
if(mercListItr->ClientVersion <= clientVersion)
|
||||
@ -5813,11 +5816,11 @@ int NPC::GetNumMercs(uint32 clientVersion) {
|
||||
return count;
|
||||
}
|
||||
|
||||
std::list<MercType> NPC::GetMercTypesList(uint32 clientVersion) {
|
||||
std::list<MercType> NPC::GetMercenaryTypesList(uint32 clientVersion) {
|
||||
|
||||
std::list<MercType> result;
|
||||
|
||||
if(GetNumMercTypes() > 0)
|
||||
if(GetNumMercenaryTypes() > 0)
|
||||
{
|
||||
for (auto mercTypeListItr = mercTypeList.begin(); mercTypeListItr != mercTypeList.end();
|
||||
++mercTypeListItr) {
|
||||
@ -5834,11 +5837,11 @@ std::list<MercType> NPC::GetMercTypesList(uint32 clientVersion) {
|
||||
return result;
|
||||
}
|
||||
|
||||
std::list<MercData> NPC::GetMercsList(uint32 clientVersion) {
|
||||
std::list<MercData> NPC::GetMercenariesList(uint32 clientVersion) {
|
||||
|
||||
std::list<MercData> result;
|
||||
|
||||
if(GetNumMercs() > 0)
|
||||
if(GetNumberOfMercenaries() > 0)
|
||||
{
|
||||
for (auto mercListItr = mercDataList.begin(); mercListItr != mercDataList.end(); ++mercListItr) {
|
||||
if(mercListItr->ClientVersion <= clientVersion)
|
||||
|
||||
16
zone/merc.h
16
zone/merc.h
@ -126,7 +126,7 @@ public:
|
||||
bool IsOfClientBotMerc() const override { return true; }
|
||||
|
||||
virtual void FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho);
|
||||
static Merc* LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id, bool updateFromDB = false);
|
||||
static Merc* LoadMercenary(Client *c, MercTemplate* merc_template, uint32 merchant_id, bool updateFromDB = false);
|
||||
void UpdateMercInfo(Client *c);
|
||||
void UpdateMercStats(Client *c, bool setmax = false);
|
||||
void UpdateMercAppearance();
|
||||
@ -151,13 +151,13 @@ public:
|
||||
|
||||
// "GET" Class Methods
|
||||
virtual Mob* GetOwner();
|
||||
Client* GetMercOwner();
|
||||
Client* GetMercenaryOwner();
|
||||
virtual Mob* GetOwnerOrSelf();
|
||||
uint32 GetMercID() { return _MercID; }
|
||||
uint32 GetMercCharacterID( ) { return owner_char_id; }
|
||||
uint32 GetMercTemplateID() { return _MercTemplateID; }
|
||||
uint32 GetMercType() { return _MercType; }
|
||||
uint32 GetMercSubType() { return _MercSubType; }
|
||||
uint32 GetMercenaryID() { return _MercID; }
|
||||
uint32 GetMercenaryCharacterID( ) { return owner_char_id; }
|
||||
uint32 GetMercenaryTemplateID() { return _MercTemplateID; }
|
||||
uint32 GetMercenaryType() { return _MercType; }
|
||||
uint32 GetMercenarySubType() { return _MercSubType; }
|
||||
uint8 GetProficiencyID() { return _ProficiencyID; }
|
||||
uint8 GetTierID() { return _TierID; }
|
||||
uint32 GetCostFormula() { return _CostFormula; }
|
||||
@ -327,7 +327,7 @@ private:
|
||||
|
||||
float GetDefaultSize();
|
||||
|
||||
bool LoadMercSpells();
|
||||
bool LoadMercenarySpells();
|
||||
bool CheckStance(int16 stance);
|
||||
std::vector<MercSpell> GetMercSpells() { return merc_spells; }
|
||||
|
||||
|
||||
@ -300,8 +300,8 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
|
||||
m_record_loot_stats = false;
|
||||
|
||||
if (GetClass() == Class::MercenaryLiaison && RuleB(Mercs, AllowMercs)) {
|
||||
LoadMercTypes();
|
||||
LoadMercs();
|
||||
LoadMercenaryTypes();
|
||||
LoadMercenaries();
|
||||
}
|
||||
|
||||
SpellFocusDMG = 0;
|
||||
|
||||
20
zone/npc.h
20
zone/npc.h
@ -383,16 +383,16 @@ public:
|
||||
void AI_SetRoambox(float distance, float max_x, float min_x, float max_y, float min_y, uint32 delay = 2500, uint32 min_delay = 2500);
|
||||
|
||||
//mercenary stuff
|
||||
void LoadMercTypes();
|
||||
void LoadMercs();
|
||||
std::list<MercType> GetMercTypesList() {return mercTypeList; };
|
||||
std::list<MercType> GetMercTypesList( uint32 expansion );
|
||||
std::list<MercData> GetMercsList() {return mercDataList; };
|
||||
std::list<MercData> GetMercsList( uint32 expansion );
|
||||
int GetNumMercTypes() { return static_cast<int>(mercTypeList.size()); };
|
||||
int GetNumMercTypes( uint32 expansion );
|
||||
int GetNumMercs() { return static_cast<int>(mercDataList.size()); };
|
||||
int GetNumMercs( uint32 expansion );
|
||||
void LoadMercenaryTypes();
|
||||
void LoadMercenaries();
|
||||
std::list<MercType> GetMercenaryTypesList() {return mercTypeList; };
|
||||
std::list<MercType> GetMercenaryTypesList( uint32 expansion );
|
||||
std::list<MercData> GetMercenariesList() {return mercDataList; };
|
||||
std::list<MercData> GetMercenariesList( uint32 expansion );
|
||||
int GetNumMercenaryTypes() { return static_cast<int>(mercTypeList.size()); };
|
||||
int GetNumMercenaryTypes( uint32 expansion );
|
||||
int GetNumberOfMercenaries() { return static_cast<int>(mercDataList.size()); };
|
||||
int GetNumberOfMercenaries( uint32 expansion );
|
||||
|
||||
inline bool GetNPCAggro() const { return npc_aggro; }
|
||||
inline void SetNPCAggro(bool in_npc_aggro) { npc_aggro = in_npc_aggro; }
|
||||
|
||||
167
zone/zone.cpp
167
zone/zone.cpp
@ -64,6 +64,7 @@
|
||||
#include "../common/repositories/respawn_times_repository.h"
|
||||
#include "../common/repositories/npc_emotes_repository.h"
|
||||
#include "../common/serverinfo.h"
|
||||
#include "../common/repositories/merc_stance_entries_repository.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
@ -746,74 +747,74 @@ void Zone::GetMerchantDataForZoneLoad() {
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::LoadMercTemplates(){
|
||||
void Zone::LoadMercenaryTemplates()
|
||||
{
|
||||
std::list<MercStanceInfo> mercenary_stances;
|
||||
|
||||
std::list<MercStanceInfo> merc_stances;
|
||||
merc_templates.clear();
|
||||
std::string query = "SELECT `class_id`, `proficiency_id`, `stance_id`, `isdefault` FROM "
|
||||
"`merc_stance_entries` ORDER BY `class_id`, `proficiency_id`, `stance_id`";
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogError("Error in ZoneDatabase::LoadMercTemplates()");
|
||||
}
|
||||
else {
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
MercStanceInfo tempMercStanceInfo;
|
||||
|
||||
tempMercStanceInfo.ClassID = Strings::ToInt(row[0]);
|
||||
tempMercStanceInfo.ProficiencyID = Strings::ToInt(row[1]);
|
||||
tempMercStanceInfo.StanceID = Strings::ToInt(row[2]);
|
||||
tempMercStanceInfo.IsDefault = Strings::ToInt(row[3]);
|
||||
|
||||
merc_stances.push_back(tempMercStanceInfo);
|
||||
}
|
||||
}
|
||||
|
||||
query = "SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring "
|
||||
"AS merc_type_id, MTem.dbstring "
|
||||
"AS merc_subtype_id, MTyp.race_id, MS.class_id, MTyp.proficiency_id, MS.tier_id, 0 "
|
||||
"AS CostFormula, MTem.clientversion, MTem.merc_npc_type_id "
|
||||
"FROM merc_types MTyp, merc_templates MTem, merc_subtypes MS "
|
||||
"WHERE MTem.merc_type_id = MTyp.merc_type_id AND MTem.merc_subtype_id = MS.merc_subtype_id "
|
||||
"ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id;";
|
||||
results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogError("Error in ZoneDatabase::LoadMercTemplates()");
|
||||
const auto& l = MercStanceEntriesRepository::GetAllOrdered(database);
|
||||
if (l.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
for (const auto& e : l) {
|
||||
MercStanceInfo t{
|
||||
.ProficiencyID = e.proficiency_id,
|
||||
.ClassID = static_cast<uint8>(e.class_id),
|
||||
.StanceID = e.stance_id,
|
||||
.IsDefault = static_cast<uint8>(e.isdefault)
|
||||
};
|
||||
|
||||
MercTemplate tempMercTemplate;
|
||||
mercenary_stances.push_back(t);
|
||||
}
|
||||
|
||||
tempMercTemplate.MercTemplateID = Strings::ToInt(row[0]);
|
||||
tempMercTemplate.MercType = Strings::ToInt(row[1]);
|
||||
tempMercTemplate.MercSubType = Strings::ToInt(row[2]);
|
||||
tempMercTemplate.RaceID = Strings::ToInt(row[3]);
|
||||
tempMercTemplate.ClassID = Strings::ToInt(row[4]);
|
||||
tempMercTemplate.ProficiencyID = Strings::ToInt(row[5]);
|
||||
tempMercTemplate.TierID = Strings::ToInt(row[6]);
|
||||
tempMercTemplate.CostFormula = Strings::ToInt(row[7]);
|
||||
tempMercTemplate.ClientVersion = Strings::ToInt(row[8]);
|
||||
tempMercTemplate.MercNPCID = Strings::ToInt(row[9]);
|
||||
const std::string& query = SQL(
|
||||
SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring
|
||||
AS merc_type_id, MTem.dbstring
|
||||
AS merc_subtype_id, MTyp.race_id, MS.class_id, MTyp.proficiency_id, MS.tier_id, 0
|
||||
AS CostFormula, MTem.clientversion, MTem.merc_npc_type_id
|
||||
FROM merc_types MTyp, merc_templates MTem, merc_subtypes MS
|
||||
WHERE MTem.merc_type_id = MTyp.merc_type_id AND MTem.merc_subtype_id = MS.merc_subtype_id
|
||||
ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id
|
||||
);
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for(int i = 0; i < MaxMercStanceID; i++)
|
||||
tempMercTemplate.Stances[i] = 0;
|
||||
for (auto row: results) {
|
||||
MercTemplate t{
|
||||
.MercTemplateID = Strings::ToUnsignedInt(row[0]),
|
||||
.MercType = Strings::ToUnsignedInt(row[1]),
|
||||
.MercSubType = Strings::ToUnsignedInt(row[2]),
|
||||
.RaceID = static_cast<uint16>(Strings::ToUnsignedInt(row[3])),
|
||||
.ClassID = static_cast<uint8>(Strings::ToUnsignedInt(row[4])),
|
||||
.MercNPCID = Strings::ToUnsignedInt(row[9]),
|
||||
.ProficiencyID = static_cast<uint8>(Strings::ToUnsignedInt(row[5])),
|
||||
.TierID = static_cast<uint8>(Strings::ToUnsignedInt(row[6])),
|
||||
.CostFormula = static_cast<uint8>(Strings::ToUnsignedInt(row[7])),
|
||||
.ClientVersion = Strings::ToUnsignedInt(row[8])
|
||||
};
|
||||
|
||||
int stanceIndex = 0;
|
||||
for (auto mercStanceListItr = merc_stances.begin(); mercStanceListItr != merc_stances.end(); ++mercStanceListItr) {
|
||||
if(mercStanceListItr->ClassID != tempMercTemplate.ClassID || mercStanceListItr->ProficiencyID != tempMercTemplate.ProficiencyID)
|
||||
continue;
|
||||
for (int i = 0; i < MaxMercStanceID; i++) {
|
||||
t.Stances[i] = 0;
|
||||
}
|
||||
|
||||
zone->merc_stance_list[tempMercTemplate.MercTemplateID].push_back((*mercStanceListItr));
|
||||
tempMercTemplate.Stances[stanceIndex] = mercStanceListItr->StanceID;
|
||||
++stanceIndex;
|
||||
}
|
||||
int stance_index = 0;
|
||||
|
||||
merc_templates[tempMercTemplate.MercTemplateID] = tempMercTemplate;
|
||||
for (auto i = mercenary_stances.begin(); i != mercenary_stances.end(); ++i) {
|
||||
if (i->ClassID != t.ClassID || i->ProficiencyID != t.ProficiencyID) {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
zone->merc_stance_list[t.MercTemplateID].push_back((*i));
|
||||
t.Stances[stance_index] = i->StanceID;
|
||||
++stance_index;
|
||||
}
|
||||
|
||||
merc_templates[t.MercTemplateID] = t;
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::LoadLevelEXPMods()
|
||||
@ -828,39 +829,39 @@ void Zone::LoadLevelEXPMods()
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::LoadMercSpells(){
|
||||
|
||||
void Zone::LoadMercenarySpells()
|
||||
{
|
||||
merc_spells_list.clear();
|
||||
const std::string query = "SELECT msl.class_id, msl.proficiency_id, msle.spell_id, msle.spell_type, "
|
||||
"msle.stance_id, msle.minlevel, msle.maxlevel, msle.slot, msle.procChance "
|
||||
"FROM merc_spell_lists msl, merc_spell_list_entries msle "
|
||||
"WHERE msle.merc_spell_list_id = msl.merc_spell_list_id "
|
||||
"ORDER BY msl.class_id, msl.proficiency_id, msle.spell_type, msle.minlevel, msle.slot;";
|
||||
|
||||
const std::string& query = SQL(
|
||||
SELECT msl.class_id, msl.proficiency_id, msle.spell_id, msle.spell_type,
|
||||
msle.stance_id, msle.minlevel, msle.maxlevel, msle.slot, msle.procChance
|
||||
FROM merc_spell_lists msl, merc_spell_list_entries msle
|
||||
WHERE msle.merc_spell_list_id = msl.merc_spell_list_id
|
||||
ORDER BY msl.class_id, msl.proficiency_id, msle.spell_type, msle.minlevel, msle.slot
|
||||
);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogError("Error in Zone::LoadMercSpells()");
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
uint32 classid;
|
||||
MercSpellEntry tempMercSpellEntry;
|
||||
|
||||
classid = Strings::ToInt(row[0]);
|
||||
tempMercSpellEntry.proficiencyid = Strings::ToInt(row[1]);
|
||||
tempMercSpellEntry.spellid = Strings::ToInt(row[2]);
|
||||
tempMercSpellEntry.type = Strings::ToInt(row[3]);
|
||||
tempMercSpellEntry.stance = Strings::ToInt(row[4]);
|
||||
tempMercSpellEntry.minlevel = Strings::ToInt(row[5]);
|
||||
tempMercSpellEntry.maxlevel = Strings::ToInt(row[6]);
|
||||
tempMercSpellEntry.slot = Strings::ToInt(row[7]);
|
||||
tempMercSpellEntry.proc_chance = Strings::ToInt(row[8]);
|
||||
|
||||
merc_spells_list[classid].push_back(tempMercSpellEntry);
|
||||
}
|
||||
|
||||
Log(Logs::General, Logs::Mercenaries, "Loaded %i merc spells.", merc_spells_list[1].size() + merc_spells_list[2].size() + merc_spells_list[9].size() + merc_spells_list[12].size());
|
||||
for (auto row: results) {
|
||||
const uint32 class_id = Strings::ToUnsignedInt(row[0]);
|
||||
|
||||
merc_spells_list[class_id].push_back(
|
||||
MercSpellEntry{
|
||||
.proficiencyid = static_cast<uint8>(Strings::ToUnsignedInt(row[1])),
|
||||
.spellid = static_cast<uint16>(Strings::ToUnsignedInt(row[2])),
|
||||
.type = Strings::ToUnsignedInt(row[3]),
|
||||
.stance = static_cast<int16>(Strings::ToInt(row[4])),
|
||||
.minlevel = static_cast<uint8>(Strings::ToUnsignedInt(row[5])),
|
||||
.maxlevel = static_cast<uint8>(Strings::ToUnsignedInt(row[6])),
|
||||
.slot = static_cast<int16>(Strings::ToInt(row[7])),
|
||||
.proc_chance = static_cast<uint16>(Strings::ToUnsignedInt(row[8]))
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
bool Zone::IsLoaded() {
|
||||
@ -1198,8 +1199,8 @@ bool Zone::Init(bool is_static) {
|
||||
|
||||
// Merc data
|
||||
if (RuleB(Mercs, AllowMercs)) {
|
||||
LoadMercTemplates();
|
||||
LoadMercSpells();
|
||||
LoadMercenaryTemplates();
|
||||
LoadMercenarySpells();
|
||||
}
|
||||
|
||||
if (RuleB(Zone, LevelBasedEXPMods)) {
|
||||
|
||||
@ -271,8 +271,8 @@ public:
|
||||
void LoadLDoNTraps();
|
||||
void LoadLevelEXPMods();
|
||||
void LoadGrids();
|
||||
void LoadMercSpells();
|
||||
void LoadMercTemplates();
|
||||
void LoadMercenarySpells();
|
||||
void LoadMercenaryTemplates();
|
||||
void LoadNewMerchantData(uint32 merchantid);
|
||||
void LoadNPCEmotes(std::vector<NPC_Emote_Struct*>* v);
|
||||
void LoadTempMerchantData();
|
||||
|
||||
988
zone/zonedb.cpp
988
zone/zonedb.cpp
File diff suppressed because it is too large
Load Diff
@ -581,14 +581,14 @@ public:
|
||||
void ClearBotSpells() { bot_spells_cache.clear(); bot_spells_loadtried.clear(); }
|
||||
|
||||
/* Mercs */
|
||||
const NPCType* GetMercType(uint32 id, uint16 raceid, uint32 clientlevel);
|
||||
void LoadMercEquipment(Merc *merc);
|
||||
void SaveMercBuffs(Merc *merc);
|
||||
void LoadMercBuffs(Merc *merc);
|
||||
bool LoadMercInfo(Client *c);
|
||||
bool LoadCurrentMerc(Client *c);
|
||||
bool SaveMerc(Merc *merc);
|
||||
bool DeleteMerc(uint32 merc_id);
|
||||
const NPCType* GetMercenaryType(uint32 id, uint16 race_id, uint32 owner_level);
|
||||
void LoadMercenaryEquipment(Merc* m);
|
||||
void SaveMercenaryBuffs(Merc* m);
|
||||
void LoadMercenaryBuffs(Merc* m);
|
||||
bool LoadMercenaryInfo(Client* c);
|
||||
bool LoadCurrentMercenary(Client* c);
|
||||
bool SaveMercenary(Merc* m);
|
||||
bool DeleteMercenary(uint32 mercenary_id);
|
||||
|
||||
/* Petitions */
|
||||
void DeletePetitionFromDB(Petition* wpet);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user