[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:
Alex King 2024-01-13 00:40:26 -05:00 committed by GitHub
parent 32659426ba
commit d7dc717249
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 1866 additions and 735 deletions

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_MERC_ARMORINFO_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_ARMORINFO_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_MERC_INVENTORY_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_INVENTORY_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_MERC_MERCHANT_ENTRIES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_MERCHANT_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_MERC_MERCHANT_TEMPLATE_ENTRIES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_MERCHANT_TEMPLATE_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_MERC_MERCHANT_TEMPLATES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_MERCHANT_TEMPLATES_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_MERC_NAME_TYPES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_NAME_TYPES_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_MERC_NPC_TYPES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_NPC_TYPES_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_MERC_SPELL_LIST_ENTRIES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_SPELL_LIST_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_MERC_SPELL_LISTS_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_SPELL_LISTS_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_MERC_STANCE_ENTRIES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_STANCE_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_MERC_STATS_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_STATS_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_MERC_SUBTYPES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_SUBTYPES_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_MERC_TEMPLATES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_TEMPLATES_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_MERC_TYPES_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_TYPES_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_MERC_WEAPONINFO_REPOSITORY_H #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); 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 #endif //EQEMU_BASE_MERC_WEAPONINFO_REPOSITORY_H

View File

@ -44,7 +44,38 @@ public:
*/ */
// Custom extended repository methods here // 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 #endif //EQEMU_MERC_STANCE_ENTRIES_REPOSITORY_H

View File

@ -44,7 +44,27 @@ public:
*/ */
// Custom extended repository methods here // 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 #endif //EQEMU_MERC_SUBTYPES_REPOSITORY_H

View File

@ -44,7 +44,23 @@ public:
*/ */
// Custom extended repository methods here // 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 #endif //EQEMU_MERCS_REPOSITORY_H

View File

@ -220,8 +220,8 @@ Json::Value ApiGetNpcListDetail(EQ::Net::WebsocketServerConnection *connection,
row["npc_spells_effects_id"] = npc->GetNPCSpellsEffectsID(); row["npc_spells_effects_id"] = npc->GetNPCSpellsEffectsID();
row["npc_spells_id"] = npc->GetNPCSpellsID(); row["npc_spells_id"] = npc->GetNPCSpellsID();
row["npchp_regen"] = npc->GetNPCHPRegen(); row["npchp_regen"] = npc->GetNPCHPRegen();
row["num_merc_types"] = npc->GetNumMercTypes(); row["num_merc_types"] = npc->GetNumMercenaryTypes();
row["num_mercs"] = npc->GetNumMercs(); row["num_mercs"] = npc->GetNumberOfMercenaries();
row["number_of_attacks"] = npc->GetNumberOfAttacks(); row["number_of_attacks"] = npc->GetNumberOfAttacks();
row["pet_spell_id"] = npc->GetPetSpellID(); row["pet_spell_id"] = npc->GetPetSpellID();
row["platinum"] = npc->GetPlatinum(); row["platinum"] = npc->GetPlatinum();
@ -734,11 +734,11 @@ Json::Value ApiGetClientListDetail(EQ::Net::WebsocketServerConnection *connectio
row["ls_account_id"] = client->LSAccountID(); row["ls_account_id"] = client->LSAccountID();
row["max_endurance"] = client->GetMaxEndurance(); row["max_endurance"] = client->GetMaxEndurance();
row["max_x_tars"] = client->GetMaxXTargets(); 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_only_or_no_group"] = client->MercOnlyOrNoGroup();
row["merc_slot"] = client->GetMercSlot(); row["merc_slot"] = client->GetMercSlot();
row["next_inv_snapshot_time"] = client->GetNextInvSnapshotTime(); 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_create"] = client->GetPendingAdventureCreate();
row["pending_adventure_door_click"] = client->GetPendingAdventureDoorClick(); row["pending_adventure_door_click"] = client->GetPendingAdventureDoorClick();
row["pending_adventure_leave"] = client->GetPendingAdventureLeave(); row["pending_adventure_leave"] = client->GetPendingAdventureLeave();

View File

@ -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 is a merc, add the merc client to the hate list
if (other->IsMerc()) { if (other->IsMerc()) {
if (other->CastToMerc()->GetMercOwner() && other->CastToMerc()->GetMercOwner()->CastToClient()->GetFeigned()) { if (other->CastToMerc()->GetMercenaryOwner() && other->CastToMerc()->GetMercenaryOwner()->CastToClient()->GetFeigned()) {
AddFeignMemory(other->CastToMerc()->GetMercOwner()->CastToClient()); AddFeignMemory(other->CastToMerc()->GetMercenaryOwner()->CastToClient());
} }
else { else {
if (!hate_list.IsEntOnHateList(other->CastToMerc()->GetMercOwner())) if (!hate_list.IsEntOnHateList(other->CastToMerc()->GetMercenaryOwner()))
hate_list.AddEntToHateList(other->CastToMerc()->GetMercOwner(), 0, 0, false, true); 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 // if mercs are reworked to include adding 'this' to owner's xtarget list, this should reflect bots code above
} }
} //MERC } //MERC

View File

@ -395,7 +395,7 @@ Client::~Client() {
if (horse) if (horse)
horse->Depop(); horse->Depop();
Mob* merc = entity_list.GetMob(GetMercID()); Mob* merc = entity_list.GetMob(GetMercenaryID());
if (merc) if (merc)
merc->Depop(); merc->Depop();

View File

@ -1554,14 +1554,14 @@ public:
bool CheckCanUnsuspendMerc(); bool CheckCanUnsuspendMerc();
bool DismissMerc(uint32 MercID); bool DismissMerc(uint32 MercID);
bool MercOnlyOrNoGroup(); bool MercOnlyOrNoGroup();
inline uint32 GetMercID() const { return mercid; } inline uint32 GetMercenaryID() const { return mercid; }
inline uint8 GetMercSlot() const { return mercSlot; } inline uint8 GetMercSlot() const { return mercSlot; }
void SetMercID( uint32 newmercid) { mercid = newmercid; } void SetMercID( uint32 newmercid) { mercid = newmercid; }
void SetMercSlot( uint8 newmercslot) { mercSlot = newmercslot; } void SetMercSlot( uint8 newmercslot) { mercSlot = newmercslot; }
Merc* GetMerc(); Merc* GetMerc();
MercInfo& GetMercInfo(uint8 slot) { return m_mercinfo[slot]; } MercInfo& GetMercInfo(uint8 slot) { return m_mercinfo[slot]; }
MercInfo& GetMercInfo() { return m_mercinfo[mercSlot]; } MercInfo& GetMercInfo() { return m_mercinfo[mercSlot]; }
uint8 GetNumMercs(); uint8 GetNumberOfMercenaries();
void SetMerc(Merc* newmerc); void SetMerc(Merc* newmerc);
void SendMercResponsePackets(uint32 ResponseType); void SendMercResponsePackets(uint32 ResponseType);
void SendMercMerchantResponsePacket(int32 response_type); void SendMercMerchantResponsePacket(int32 response_type);

View File

@ -6257,7 +6257,7 @@ void Client::Handle_OP_EnvDamage(const EQApplicationPacket *app)
return; return;
} }
} }
uint32 mod = spellbonuses.ReduceFallDamage + itembonuses.ReduceFallDamage + aabonuses.ReduceFallDamage; uint32 mod = spellbonuses.ReduceFallDamage + itembonuses.ReduceFallDamage + aabonuses.ReduceFallDamage;
damage -= damage * mod / 100; damage -= damage * mod / 100;
} }
@ -7337,7 +7337,7 @@ void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app)
} }
GroupInvite_Struct* gis = (GroupInvite_Struct*)app->pBuffer; GroupInvite_Struct* gis = (GroupInvite_Struct*)app->pBuffer;
Mob* invitee = nullptr; Mob* invitee = nullptr;
if (RuleB(Character, GroupInvitesRequireTarget)) { if (RuleB(Character, GroupInvitesRequireTarget)) {
@ -7385,7 +7385,7 @@ void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app)
} }
return; return;
} else { } else {
if (RuleB(Character, OnInviteReceiveAlreadyinGroupMessage)) { if (RuleB(Character, OnInviteReceiveAlreadyinGroupMessage)) {
if (!invitee->CastToClient()->MercOnlyOrNoGroup()) { if (!invitee->CastToClient()->MercOnlyOrNoGroup()) {
@ -10191,14 +10191,14 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app)
uint8 numStances = 0; uint8 numStances = 0;
//get number of available stances for the current merc //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(); auto iter = mercStanceList.begin();
while (iter != mercStanceList.end()) { while (iter != mercStanceList.end()) {
numStances++; numStances++;
++iter; ++iter;
} }
MercTemplate* mercTemplate = zone->GetMercTemplate(GetMerc()->GetMercTemplateID()); MercTemplate* mercTemplate = zone->GetMercTemplate(GetMerc()->GetMercenaryTemplateID());
if (mercTemplate) 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) //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; return;
} }
mercTypeCount = tar->GetNumMercTypes(static_cast<unsigned int>(ClientVersion())); mercTypeCount = tar->GetNumMercenaryTypes(static_cast<unsigned int>(ClientVersion()));
mercCount = tar->GetNumMercs(static_cast<unsigned int>(ClientVersion())); mercCount = tar->GetNumberOfMercenaries(static_cast<unsigned int>(ClientVersion()));
if (mercCount > MAX_MERC) if (mercCount > MAX_MERC)
return; return;
std::list<MercType> mercTypeList = tar->GetMercTypesList(static_cast<unsigned int>(ClientVersion())); std::list<MercType> mercTypeList = tar->GetMercenaryTypesList(static_cast<unsigned int>(ClientVersion()));
std::list<MercData> mercDataList = tar->GetMercsList(static_cast<unsigned int>(ClientVersion())); std::list<MercData> mercDataList = tar->GetMercenariesList(static_cast<unsigned int>(ClientVersion()));
int i = 0; int i = 0;
int StanceCount = 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()); Log(Logs::General, Logs::Mercenaries, "Data Update Request Received for %s.", GetName());
if (GetMercID()) if (GetMercenaryID())
{ {
SendMercPersonalInfo(); SendMercPersonalInfo();
} }
@ -10431,7 +10431,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app)
GetMercInfo().MercTimerRemaining = RuleI(Mercs, UpkeepIntervalMS); GetMercInfo().MercTimerRemaining = RuleI(Mercs, UpkeepIntervalMS);
// Get merc, assign it to client & spawn // 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) if (merc)
{ {
@ -10504,7 +10504,7 @@ void Client::Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app)
uint32 entityID = 0; uint32 entityID = 0;
uint32 mercState = 5; uint32 mercState = 5;
uint32 suspendedTime = 0; uint32 suspendedTime = 0;
if (GetMercID()) { if (GetMercenaryID()) {
Merc* merc = GetMerc(); Merc* merc = GetMerc();
if (merc) { if (merc) {

View File

@ -665,7 +665,7 @@ void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
} }
level_count++; level_count++;
if(GetMercID()) if(GetMercenaryID())
UpdateMercLevel(); UpdateMercLevel();
} }
//see if we lost any levels //see if we lost any levels
@ -676,7 +676,7 @@ void Client::SetEXP(uint64 set_exp, uint64 set_aaxp, bool isrezzexp) {
break; break;
} }
level_increase = false; level_increase = false;
if(GetMercID()) if(GetMercenaryID())
UpdateMercLevel(); UpdateMercLevel();
} }
check_level--; check_level--;

View File

@ -233,7 +233,7 @@ bool Group::AddMember(Mob* newmember, const char *NewMemberName, uint32 Characte
} }
if(newmember->IsMerc()) if(newmember->IsMerc())
{ {
Client* owner = newmember->CastToMerc()->GetMercOwner(); Client* owner = newmember->CastToMerc()->GetMercenaryOwner();
if(owner) if(owner)
{ {
CharacterID = owner->CastToClient()->CharacterID(); CharacterID = owner->CastToClient()->CharacterID();
@ -331,7 +331,7 @@ bool Group::AddMember(Mob* newmember, const char *NewMemberName, uint32 Characte
if(newmember->IsMerc()) if(newmember->IsMerc())
{ {
Client* owner = newmember->CastToMerc()->GetMercOwner(); Client* owner = newmember->CastToMerc()->GetMercenaryOwner();
if(owner) if(owner)
{ {
database.SetGroupID(NewMemberName, GetID(), owner->CharacterID(), true); database.SetGroupID(NewMemberName, GetID(), owner->CharacterID(), true);
@ -757,7 +757,7 @@ bool Group::DelMember(Mob* oldmember, bool ignoresender)
if(oldmember->IsMerc()) if(oldmember->IsMerc())
{ {
Client* owner = oldmember->CastToMerc()->GetMercOwner(); Client* owner = oldmember->CastToMerc()->GetMercenaryOwner();
if(owner) if(owner)
{ {
database.SetGroupID(oldmember->GetCleanName(), 0, owner->CharacterID(), true); database.SetGroupID(oldmember->GetCleanName(), 0, owner->CharacterID(), true);
@ -952,7 +952,7 @@ void Group::DisbandGroup(bool joinraid) {
if (members[i]->IsMerc()) if (members[i]->IsMerc())
{ {
Client* owner = members[i]->CastToMerc()->GetMercOwner(); Client* owner = members[i]->CastToMerc()->GetMercenaryOwner();
if(owner) if(owner)
{ {
database.SetGroupID(members[i]->GetCleanName(), 0, owner->CharacterID(), true); database.SetGroupID(members[i]->GetCleanName(), 0, owner->CharacterID(), true);

View File

@ -857,7 +857,7 @@ bool Merc::Process()
return false; return false;
} }
if(!GetMercOwner()) { if(!GetMercenaryOwner()) {
//p_depop = true; //this was causing a crash - removed merc from entity list, but not group //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 //return false; //merc can live after client dies, not sure how long
} }
@ -867,8 +867,8 @@ bool Merc::Process()
return false; return false;
} }
if (HasGroup() && GetMercOwner() && GetFollowID() == 0) { if (HasGroup() && GetMercenaryOwner() && GetFollowID() == 0) {
SetFollowID(GetMercOwner()->GetID()); SetFollowID(GetMercenaryOwner()->GetID());
} }
SpellProcess(); SpellProcess();
@ -1691,7 +1691,7 @@ bool Merc::AICastSpell(int8 iChance, uint32 iSpellTypes) {
continue; continue;
} }
if(hpr < checkHPR && g->members[i] == GetMercOwner()) { if(hpr < checkHPR && g->members[i] == GetMercenaryOwner()) {
if(!tar || (hpr < tar->GetHPRatio() || (tar->IsPet() && hpr < checkPetHPR))) if(!tar || (hpr < tar->GetHPRatio() || (tar->IsPet() && hpr < checkPetHPR)))
tar = g->members[i]; //check owner first tar = g->members[i]; //check owner first
} }
@ -4076,8 +4076,8 @@ void Merc::SetTarget(Mob* mob) {
Mob* Merc::GetOwnerOrSelf() { Mob* Merc::GetOwnerOrSelf() {
Mob* Result = nullptr; Mob* Result = nullptr;
if(GetMercOwner()) if(GetMercenaryOwner())
Result = GetMercOwner(); Result = GetMercenaryOwner();
else else
Result = this; Result = this;
@ -4108,7 +4108,7 @@ bool Merc::Death(Mob* killerMob, int64 damage, uint16 spell, EQ::skills::SkillTy
return true; return true;
} }
Client* Merc::GetMercOwner() { Client* Merc::GetMercenaryOwner() {
Client* mercOwner = nullptr; Client* mercOwner = nullptr;
if(GetOwner()) if(GetOwner())
@ -4230,7 +4230,7 @@ const char* Merc::GetRandomName(){
return name; return name;
} }
bool Merc::LoadMercSpells() { bool Merc::LoadMercenarySpells() {
// loads mercs spells into list // loads mercs spells into list
merc_spells.clear(); merc_spells.clear();
@ -4278,18 +4278,18 @@ bool Merc::LoadMercSpells() {
bool Merc::Save() { bool Merc::Save() {
if(database.SaveMerc(this)){ if(database.SaveMercenary(this)){
return true; return true;
} }
return false; 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)
{ {
if(c->GetMercID()) if(c->GetMercenaryID())
{ {
merc_template = zone->GetMercTemplate(c->GetMercInfo().MercTemplateID); 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; const NPCType* npc_type_to_copy = nullptr;
if (c) { 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) if(npc_type_to_copy != nullptr)
@ -4365,12 +4365,12 @@ Merc* Merc::LoadMerc(Client *c, MercTemplate* merc_template, uint32 merchant_id,
if(merc) if(merc)
{ {
merc->SetMercData( merc_template->MercTemplateID ); merc->SetMercData( merc_template->MercTemplateID );
database.LoadMercEquipment(merc); database.LoadMercenaryEquipment(merc);
merc->UpdateMercStats(c, true); merc->UpdateMercStats(c, true);
if(updateFromDB) if(updateFromDB)
{ {
database.LoadCurrentMerc(c); database.LoadCurrentMercenary(c);
merc->SetMercID(c->GetMercInfo().mercid); merc->SetMercID(c->GetMercInfo().mercid);
snprintf(merc->name, 64, "%s", c->GetMercInfo().merc_name); 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); merc->RandomizeFeatures(false, true);
} }
if(merc->GetMercID()) { if(merc->GetMercenaryID()) {
database.LoadMercBuffs(merc); database.LoadMercenaryBuffs(merc);
} }
merc->LoadMercSpells(); merc->LoadMercenarySpells();
} }
Log(Logs::General, Logs::Mercenaries, "LoadMerc Successful for %s (%s).", merc->GetName(), c->GetName()); 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) { void Merc::UpdateMercInfo(Client *c) {
snprintf(c->GetMercInfo().merc_name, 64, "%s", name); snprintf(c->GetMercInfo().merc_name, 64, "%s", name);
c->GetMercInfo().mercid = GetMercID(); c->GetMercInfo().mercid = GetMercenaryID();
c->GetMercInfo().IsSuspended = IsSuspended(); c->GetMercInfo().IsSuspended = IsSuspended();
c->GetMercInfo().Gender = GetGender(); c->GetMercInfo().Gender = GetGender();
c->GetMercInfo().MercSize = GetSize(); c->GetMercInfo().MercSize = GetSize();
@ -4438,7 +4438,7 @@ void Merc::UpdateMercStats(Client *c, bool setmax)
if (c->GetMercInfo().MercTemplateID > 0) { if (c->GetMercInfo().MercTemplateID > 0) {
Log(Logs::General, Logs::Mercenaries, "Updating Mercenary Stats for %s (%s).", GetName(), Log(Logs::General, Logs::Mercenaries, "Updating Mercenary Stats for %s (%s).", GetName(),
c->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()); zone->GetMercTemplate(c->GetMercInfo().MercTemplateID)->MercNPCID, GetRace(), c->GetLevel());
if (npc_type) { if (npc_type) {
max_hp = npc_type->max_hp; max_hp = npc_type->max_hp;
@ -4674,7 +4674,7 @@ bool Merc::Spawn(Client *owner) {
if(!owner) if(!owner)
return false; return false;
MercTemplate* merc_template = zone->GetMercTemplate(GetMercTemplateID()); MercTemplate* merc_template = zone->GetMercTemplate(GetMercenaryTemplateID());
if(!merc_template) if(!merc_template)
return false; return false;
@ -4841,7 +4841,7 @@ void Client::UpdateMercTimer()
{ {
if(GetMercTimer()->Check()) if(GetMercTimer()->Check())
{ {
uint32 upkeep = merc->CalcUpkeepCost(merc->GetMercTemplateID(), GetLevel()); uint32 upkeep = merc->CalcUpkeepCost(merc->GetMercenaryTemplateID(), GetLevel());
if(CheckCanRetainMerc(upkeep)) if(CheckCanRetainMerc(upkeep))
{ {
@ -4898,7 +4898,7 @@ bool Client::CheckCanHireMerc(Mob* merchant, uint32 template_id) {
} }
// Check if max number of mercs is already reached // Check if max number of mercs is already reached
if(GetNumMercs() >= MAXMERCS) { if(GetNumberOfMercenaries() >= MAXMERCS) {
SendMercResponsePackets(6); SendMercResponsePackets(6);
return false; return false;
} }
@ -5053,7 +5053,7 @@ void Client::SuspendMercCommand() {
} }
// Get merc, assign it to client & spawn // 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) if(merc)
{ {
SpawnMerc(merc, false); SpawnMerc(merc, false);
@ -5079,7 +5079,7 @@ void Client::SuspendMercCommand() {
} }
} }
if(CurrentMerc && GetMercID()) if(CurrentMerc && GetMercenaryID())
{ {
CurrentMerc->Suspend(); CurrentMerc->Suspend();
Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Successful Suspend for %s.", GetName()); Log(Logs::General, Logs::Mercenaries, "SuspendMercCommand Successful Suspend for %s.", GetName());
@ -5123,13 +5123,13 @@ void Client::SpawnMercOnZone() {
if (GetMerc()) if (GetMerc())
return; return;
if(database.LoadMercInfo(this)) if(database.LoadMercenaryInfo(this))
{ {
if(!GetMercInfo().IsSuspended) if(!GetMercInfo().IsSuspended)
{ {
GetMercInfo().SuspendedTime = 0; GetMercInfo().SuspendedTime = 0;
// Get merc, assign it to client & spawn // 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) if(merc)
{ {
SpawnMerc(merc, false); SpawnMerc(merc, false);
@ -5189,7 +5189,7 @@ void Client::SendMercTimer(Merc* merc) {
void Client::SpawnMerc(Merc* merc, bool setMaxStats) { void Client::SpawnMerc(Merc* merc, bool setMaxStats) {
if (!merc || !CheckCanSpawnMerc(merc->GetMercTemplateID())) if (!merc || !CheckCanSpawnMerc(merc->GetMercenaryTemplateID()))
{ {
if (merc) if (merc)
{ {
@ -5212,7 +5212,7 @@ void Client::SpawnMerc(Merc* merc, bool setMaxStats) {
bool Merc::Suspend() { bool Merc::Suspend() {
Client* mercOwner = GetMercOwner(); Client* mercOwner = GetMercenaryOwner();
if(!mercOwner) if(!mercOwner)
return false; return false;
@ -5261,8 +5261,8 @@ bool Merc::Unsuspend(bool setMaxStats) {
Client* mercOwner = nullptr; Client* mercOwner = nullptr;
if(GetMercOwner()) { if(GetMercenaryOwner()) {
mercOwner = GetMercOwner(); mercOwner = GetMercenaryOwner();
} }
if(!mercOwner) 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 // Set time remaining to max on unsuspend - there is a charge for unsuspending as well
SetSuspended(false); SetSuspended(false);
mercOwner->GetMercInfo().mercid = GetMercID(); mercOwner->GetMercInfo().mercid = GetMercenaryID();
mercOwner->GetMercInfo().IsSuspended = false; mercOwner->GetMercInfo().IsSuspended = false;
mercOwner->SendMercenaryUnsuspendPacket(0); mercOwner->SendMercenaryUnsuspendPacket(0);
@ -5299,7 +5299,7 @@ bool Merc::Unsuspend(bool setMaxStats) {
//check for sufficient funds and remove them last //check for sufficient funds and remove them last
if(RuleB(Mercs, ChargeMercUpkeepCost)) 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)) if(cost > 0 && !mercOwner->HasMoney(cost))
{ {
mercOwner->SendMercResponsePackets(1); mercOwner->SendMercResponsePackets(1);
@ -5317,7 +5317,7 @@ bool Merc::Unsuspend(bool setMaxStats) {
bool Client::DismissMerc(uint32 MercID) { bool Client::DismissMerc(uint32 MercID) {
bool Dismissed = true; 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()); Log(Logs::General, Logs::Mercenaries, "Dismiss Failed Database Query for MercID: %i, Client: %s.", MercID, GetName());
Dismissed = false; Dismissed = false;
@ -5390,9 +5390,9 @@ bool Merc::RemoveMercFromGroup(Merc* merc, Group* group) {
} }
else if(group->DelMember(merc, true)) 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; Client* mercOwner = nullptr;
if(GetMercOwner()) if(GetMercenaryOwner())
{ {
mercOwner = GetMercOwner(); mercOwner = GetMercenaryOwner();
} }
if(!mercOwner) 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 // Remove merc from current group if it's not the destination group
if(merc->HasGroup()) if(merc->HasGroup())
{ {
if(merc->GetGroup() == group && merc->GetMercOwner()) if(merc->GetGroup() == group && merc->GetMercenaryOwner())
{ {
// Merc is already in the destination group // Merc is already in the destination group
merc->SetFollowID(merc->GetMercOwner()->GetID()); merc->SetFollowID(merc->GetMercenaryOwner()->GetID());
return true; return true;
} }
merc->RemoveMercFromGroup(merc, merc->GetGroup()); merc->RemoveMercFromGroup(merc, merc->GetGroup());
} }
//Try and add the member, followed by checking if the merc owner exists. //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; Result = true;
} }
else else
@ -5551,13 +5551,13 @@ void Client::InitializeMercInfo() {
Merc* Client::GetMerc() { 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); return (nullptr);
} }
Merc* tmp = entity_list.GetMercByID(GetMercID()); Merc* tmp = entity_list.GetMercByID(GetMercenaryID());
if(tmp == nullptr) if(tmp == nullptr)
{ {
SetMercID(0); SetMercID(0);
@ -5575,7 +5575,7 @@ Merc* Client::GetMerc() {
return (tmp); return (tmp);
} }
uint8 Client::GetNumMercs() { uint8 Client::GetNumberOfMercenaries() {
uint8 numMercs = 0; uint8 numMercs = 0;
@ -5586,7 +5586,7 @@ uint8 Client::GetNumMercs() {
numMercs++; 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; return numMercs;
} }
@ -5636,8 +5636,8 @@ void Client::SetMerc(Merc* newmerc) {
newmerc->SetOwnerID(GetID()); newmerc->SetOwnerID(GetID());
newmerc->SetMercCharacterID(CharacterID()); newmerc->SetMercCharacterID(CharacterID());
newmerc->SetClientVersion((uint8)ClientVersion()); newmerc->SetClientVersion((uint8)ClientVersion());
GetMercInfo().mercid = newmerc->GetMercID(); GetMercInfo().mercid = newmerc->GetMercenaryID();
GetMercInfo().MercTemplateID = newmerc->GetMercTemplateID(); GetMercInfo().MercTemplateID = newmerc->GetMercenaryTemplateID();
GetMercInfo().myTemplate = zone->GetMercTemplate(GetMercInfo().MercTemplateID); GetMercInfo().myTemplate = zone->GetMercTemplate(GetMercInfo().MercTemplateID);
GetMercInfo().IsSuspended = newmerc->IsSuspended(); GetMercInfo().IsSuspended = newmerc->IsSuspended();
GetMercInfo().SuspendedTime = 0; 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()); 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); auto results = database.QueryDatabase(query);
if (!results.Success()) if (!results.Success()) {
{
LogError("Error in NPC::LoadMercTypes()");
return; return;
} }
for (auto row = results.begin(); row != results.end(); ++row) for (auto row = results.begin(); row != results.end(); ++row) {
{ MercType t;
MercType tempMercType;
tempMercType.Type = Strings::ToInt(row[0]); t.Type = Strings::ToInt(row[0]);
tempMercType.ClientVersion = Strings::ToInt(row[1]); 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); auto results = database.QueryDatabase(query);
if (!results.Success()) {
if (!results.Success())
{
LogError("Error in NPC::LoadMercTypes()");
return; return;
} }
for (auto row = results.begin(); row != results.end(); ++row) for (auto row = results.begin(); row != results.end(); ++row) {
{ MercData t;
MercData tempMerc;
tempMerc.MercTemplateID = Strings::ToInt(row[0]); t.MercTemplateID = Strings::ToInt(row[0]);
tempMerc.MercType = Strings::ToInt(row[1]); t.MercType = Strings::ToInt(row[1]);
tempMerc.MercSubType = Strings::ToInt(row[2]); t.MercSubType = Strings::ToInt(row[2]);
tempMerc.CostFormula = Strings::ToInt(row[3]); t.CostFormula = Strings::ToInt(row[3]);
tempMerc.ClientVersion = Strings::ToInt(row[4]); t.ClientVersion = Strings::ToInt(row[4]);
tempMerc.NPCID = Strings::ToInt(row[5]); 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; int count = 0;
std::list<MercType> mercTypeList = GetMercTypesList(); std::list<MercType> mercTypeList = GetMercenaryTypesList();
for (auto mercTypeListItr = mercTypeList.begin(); mercTypeListItr != mercTypeList.end(); ++mercTypeListItr) { for (auto mercTypeListItr = mercTypeList.begin(); mercTypeListItr != mercTypeList.end(); ++mercTypeListItr) {
if(mercTypeListItr->ClientVersion <= clientVersion) if(mercTypeListItr->ClientVersion <= clientVersion)
@ -5800,10 +5803,10 @@ int NPC::GetNumMercTypes(uint32 clientVersion) {
return count; return count;
} }
int NPC::GetNumMercs(uint32 clientVersion) { int NPC::GetNumberOfMercenaries(uint32 clientVersion) {
int count = 0; int count = 0;
std::list<MercData> mercDataList = GetMercsList(); std::list<MercData> mercDataList = GetMercenariesList();
for (auto mercListItr = mercDataList.begin(); mercListItr != mercDataList.end(); ++mercListItr) { for (auto mercListItr = mercDataList.begin(); mercListItr != mercDataList.end(); ++mercListItr) {
if(mercListItr->ClientVersion <= clientVersion) if(mercListItr->ClientVersion <= clientVersion)
@ -5813,11 +5816,11 @@ int NPC::GetNumMercs(uint32 clientVersion) {
return count; return count;
} }
std::list<MercType> NPC::GetMercTypesList(uint32 clientVersion) { std::list<MercType> NPC::GetMercenaryTypesList(uint32 clientVersion) {
std::list<MercType> result; std::list<MercType> result;
if(GetNumMercTypes() > 0) if(GetNumMercenaryTypes() > 0)
{ {
for (auto mercTypeListItr = mercTypeList.begin(); mercTypeListItr != mercTypeList.end(); for (auto mercTypeListItr = mercTypeList.begin(); mercTypeListItr != mercTypeList.end();
++mercTypeListItr) { ++mercTypeListItr) {
@ -5834,11 +5837,11 @@ std::list<MercType> NPC::GetMercTypesList(uint32 clientVersion) {
return result; return result;
} }
std::list<MercData> NPC::GetMercsList(uint32 clientVersion) { std::list<MercData> NPC::GetMercenariesList(uint32 clientVersion) {
std::list<MercData> result; std::list<MercData> result;
if(GetNumMercs() > 0) if(GetNumberOfMercenaries() > 0)
{ {
for (auto mercListItr = mercDataList.begin(); mercListItr != mercDataList.end(); ++mercListItr) { for (auto mercListItr = mercDataList.begin(); mercListItr != mercDataList.end(); ++mercListItr) {
if(mercListItr->ClientVersion <= clientVersion) if(mercListItr->ClientVersion <= clientVersion)

View File

@ -126,7 +126,7 @@ public:
bool IsOfClientBotMerc() const override { return true; } bool IsOfClientBotMerc() const override { return true; }
virtual void FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho); 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 UpdateMercInfo(Client *c);
void UpdateMercStats(Client *c, bool setmax = false); void UpdateMercStats(Client *c, bool setmax = false);
void UpdateMercAppearance(); void UpdateMercAppearance();
@ -151,13 +151,13 @@ public:
// "GET" Class Methods // "GET" Class Methods
virtual Mob* GetOwner(); virtual Mob* GetOwner();
Client* GetMercOwner(); Client* GetMercenaryOwner();
virtual Mob* GetOwnerOrSelf(); virtual Mob* GetOwnerOrSelf();
uint32 GetMercID() { return _MercID; } uint32 GetMercenaryID() { return _MercID; }
uint32 GetMercCharacterID( ) { return owner_char_id; } uint32 GetMercenaryCharacterID( ) { return owner_char_id; }
uint32 GetMercTemplateID() { return _MercTemplateID; } uint32 GetMercenaryTemplateID() { return _MercTemplateID; }
uint32 GetMercType() { return _MercType; } uint32 GetMercenaryType() { return _MercType; }
uint32 GetMercSubType() { return _MercSubType; } uint32 GetMercenarySubType() { return _MercSubType; }
uint8 GetProficiencyID() { return _ProficiencyID; } uint8 GetProficiencyID() { return _ProficiencyID; }
uint8 GetTierID() { return _TierID; } uint8 GetTierID() { return _TierID; }
uint32 GetCostFormula() { return _CostFormula; } uint32 GetCostFormula() { return _CostFormula; }
@ -327,7 +327,7 @@ private:
float GetDefaultSize(); float GetDefaultSize();
bool LoadMercSpells(); bool LoadMercenarySpells();
bool CheckStance(int16 stance); bool CheckStance(int16 stance);
std::vector<MercSpell> GetMercSpells() { return merc_spells; } std::vector<MercSpell> GetMercSpells() { return merc_spells; }

View File

@ -300,8 +300,8 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
m_record_loot_stats = false; m_record_loot_stats = false;
if (GetClass() == Class::MercenaryLiaison && RuleB(Mercs, AllowMercs)) { if (GetClass() == Class::MercenaryLiaison && RuleB(Mercs, AllowMercs)) {
LoadMercTypes(); LoadMercenaryTypes();
LoadMercs(); LoadMercenaries();
} }
SpellFocusDMG = 0; SpellFocusDMG = 0;

View File

@ -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); 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 //mercenary stuff
void LoadMercTypes(); void LoadMercenaryTypes();
void LoadMercs(); void LoadMercenaries();
std::list<MercType> GetMercTypesList() {return mercTypeList; }; std::list<MercType> GetMercenaryTypesList() {return mercTypeList; };
std::list<MercType> GetMercTypesList( uint32 expansion ); std::list<MercType> GetMercenaryTypesList( uint32 expansion );
std::list<MercData> GetMercsList() {return mercDataList; }; std::list<MercData> GetMercenariesList() {return mercDataList; };
std::list<MercData> GetMercsList( uint32 expansion ); std::list<MercData> GetMercenariesList( uint32 expansion );
int GetNumMercTypes() { return static_cast<int>(mercTypeList.size()); }; int GetNumMercenaryTypes() { return static_cast<int>(mercTypeList.size()); };
int GetNumMercTypes( uint32 expansion ); int GetNumMercenaryTypes( uint32 expansion );
int GetNumMercs() { return static_cast<int>(mercDataList.size()); }; int GetNumberOfMercenaries() { return static_cast<int>(mercDataList.size()); };
int GetNumMercs( uint32 expansion ); int GetNumberOfMercenaries( uint32 expansion );
inline bool GetNPCAggro() const { return npc_aggro; } inline bool GetNPCAggro() const { return npc_aggro; }
inline void SetNPCAggro(bool in_npc_aggro) { npc_aggro = in_npc_aggro; } inline void SetNPCAggro(bool in_npc_aggro) { npc_aggro = in_npc_aggro; }

View File

@ -64,6 +64,7 @@
#include "../common/repositories/respawn_times_repository.h" #include "../common/repositories/respawn_times_repository.h"
#include "../common/repositories/npc_emotes_repository.h" #include "../common/repositories/npc_emotes_repository.h"
#include "../common/serverinfo.h" #include "../common/serverinfo.h"
#include "../common/repositories/merc_stance_entries_repository.h"
#include <time.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(); 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]); const auto& l = MercStanceEntriesRepository::GetAllOrdered(database);
tempMercStanceInfo.ProficiencyID = Strings::ToInt(row[1]); if (l.empty()) {
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()");
return; 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]); const std::string& query = SQL(
tempMercTemplate.MercType = Strings::ToInt(row[1]); SELECT DISTINCT MTem.merc_template_id, MTyp.dbstring
tempMercTemplate.MercSubType = Strings::ToInt(row[2]); AS merc_type_id, MTem.dbstring
tempMercTemplate.RaceID = Strings::ToInt(row[3]); AS merc_subtype_id, MTyp.race_id, MS.class_id, MTyp.proficiency_id, MS.tier_id, 0
tempMercTemplate.ClassID = Strings::ToInt(row[4]); AS CostFormula, MTem.clientversion, MTem.merc_npc_type_id
tempMercTemplate.ProficiencyID = Strings::ToInt(row[5]); FROM merc_types MTyp, merc_templates MTem, merc_subtypes MS
tempMercTemplate.TierID = Strings::ToInt(row[6]); WHERE MTem.merc_type_id = MTyp.merc_type_id AND MTem.merc_subtype_id = MS.merc_subtype_id
tempMercTemplate.CostFormula = Strings::ToInt(row[7]); ORDER BY MTyp.race_id, MS.class_id, MTyp.proficiency_id
tempMercTemplate.ClientVersion = Strings::ToInt(row[8]); );
tempMercTemplate.MercNPCID = Strings::ToInt(row[9]); auto results = database.QueryDatabase(query);
if (!results.Success() || !results.RowCount()) {
return;
}
for(int i = 0; i < MaxMercStanceID; i++) for (auto row: results) {
tempMercTemplate.Stances[i] = 0; 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 (int i = 0; i < MaxMercStanceID; i++) {
for (auto mercStanceListItr = merc_stances.begin(); mercStanceListItr != merc_stances.end(); ++mercStanceListItr) { t.Stances[i] = 0;
if(mercStanceListItr->ClassID != tempMercTemplate.ClassID || mercStanceListItr->ProficiencyID != tempMercTemplate.ProficiencyID) }
continue;
zone->merc_stance_list[tempMercTemplate.MercTemplateID].push_back((*mercStanceListItr)); int stance_index = 0;
tempMercTemplate.Stances[stanceIndex] = mercStanceListItr->StanceID;
++stanceIndex;
}
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() void Zone::LoadLevelEXPMods()
@ -828,39 +829,39 @@ void Zone::LoadLevelEXPMods()
} }
} }
void Zone::LoadMercSpells(){ void Zone::LoadMercenarySpells()
{
merc_spells_list.clear(); 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 " const std::string& query = SQL(
"FROM merc_spell_lists msl, merc_spell_list_entries msle " SELECT msl.class_id, msl.proficiency_id, msle.spell_id, msle.spell_type,
"WHERE msle.merc_spell_list_id = msl.merc_spell_list_id " msle.stance_id, msle.minlevel, msle.maxlevel, msle.slot, msle.procChance
"ORDER BY msl.class_id, msl.proficiency_id, msle.spell_type, msle.minlevel, msle.slot;"; 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); auto results = database.QueryDatabase(query);
if (!results.Success()) { if (!results.Success() || !results.RowCount()) {
LogError("Error in Zone::LoadMercSpells()");
return; return;
} }
for (auto row = results.begin(); row != results.end(); ++row) { for (auto row: results) {
uint32 classid; const uint32 class_id = Strings::ToUnsignedInt(row[0]);
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());
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() { bool Zone::IsLoaded() {
@ -1198,8 +1199,8 @@ bool Zone::Init(bool is_static) {
// Merc data // Merc data
if (RuleB(Mercs, AllowMercs)) { if (RuleB(Mercs, AllowMercs)) {
LoadMercTemplates(); LoadMercenaryTemplates();
LoadMercSpells(); LoadMercenarySpells();
} }
if (RuleB(Zone, LevelBasedEXPMods)) { if (RuleB(Zone, LevelBasedEXPMods)) {

View File

@ -271,8 +271,8 @@ public:
void LoadLDoNTraps(); void LoadLDoNTraps();
void LoadLevelEXPMods(); void LoadLevelEXPMods();
void LoadGrids(); void LoadGrids();
void LoadMercSpells(); void LoadMercenarySpells();
void LoadMercTemplates(); void LoadMercenaryTemplates();
void LoadNewMerchantData(uint32 merchantid); void LoadNewMerchantData(uint32 merchantid);
void LoadNPCEmotes(std::vector<NPC_Emote_Struct*>* v); void LoadNPCEmotes(std::vector<NPC_Emote_Struct*>* v);
void LoadTempMerchantData(); void LoadTempMerchantData();

File diff suppressed because it is too large Load Diff

View File

@ -581,14 +581,14 @@ public:
void ClearBotSpells() { bot_spells_cache.clear(); bot_spells_loadtried.clear(); } void ClearBotSpells() { bot_spells_cache.clear(); bot_spells_loadtried.clear(); }
/* Mercs */ /* Mercs */
const NPCType* GetMercType(uint32 id, uint16 raceid, uint32 clientlevel); const NPCType* GetMercenaryType(uint32 id, uint16 race_id, uint32 owner_level);
void LoadMercEquipment(Merc *merc); void LoadMercenaryEquipment(Merc* m);
void SaveMercBuffs(Merc *merc); void SaveMercenaryBuffs(Merc* m);
void LoadMercBuffs(Merc *merc); void LoadMercenaryBuffs(Merc* m);
bool LoadMercInfo(Client *c); bool LoadMercenaryInfo(Client* c);
bool LoadCurrentMerc(Client *c); bool LoadCurrentMercenary(Client* c);
bool SaveMerc(Merc *merc); bool SaveMercenary(Merc* m);
bool DeleteMerc(uint32 merc_id); bool DeleteMercenary(uint32 mercenary_id);
/* Petitions */ /* Petitions */
void DeletePetitionFromDB(Petition* wpet); void DeletePetitionFromDB(Petition* wpet);