diff --git a/common/database/database_update.cpp b/common/database/database_update.cpp index 704426fee..a3d3c1f5a 100644 --- a/common/database/database_update.cpp +++ b/common/database/database_update.cpp @@ -28,6 +28,7 @@ #include "common/strings.h" #include +#include constexpr int BREAK_LENGTH = 70; @@ -73,35 +74,38 @@ void DatabaseUpdate::CheckDbUpdates() return; } - if (UpdateManifest(manifest_entries, v.server_database_version, b.server_database_version)) { + int server_database_version = UpdateManifest(manifest_entries, v.server_database_version, b.server_database_version); + if (server_database_version > v.server_database_version) { LogInfo( "Updates ran successfully, setting database version to [{}] from [{}]", - b.server_database_version, + server_database_version, v.server_database_version ); - m_database->QueryDatabase(fmt::format("UPDATE `db_version` SET `version` = {}", b.server_database_version)); + m_database->QueryDatabase(fmt::format("UPDATE `db_version` SET `version` = {}", server_database_version)); } - if (UpdateManifest(manifest_entries_custom, v.custom_database_version, b.custom_database_version)) { + int custom_database_version = UpdateManifest(manifest_entries_custom, v.custom_database_version, b.custom_database_version); + if (custom_database_version > v.server_database_version) { LogInfo( "Updates ran successfully, setting database version to [{}] from [{}]", - b.custom_database_version, + custom_database_version, v.custom_database_version ); - m_database->QueryDatabase(fmt::format("UPDATE `db_version` SET `custom_version` = {}", b.custom_database_version)); + m_database->QueryDatabase(fmt::format("UPDATE `db_version` SET `custom_version` = {}", custom_database_version)); } if (b.bots_database_version > 0) { - if (UpdateManifest(bot_manifest_entries, v.bots_database_version, b.bots_database_version)) { + int bots_database_version = UpdateManifest(bot_manifest_entries, v.bots_database_version, b.bots_database_version); + if (bots_database_version > v.bots_database_version) { LogInfo( "Updates ran successfully, setting database version to [{}] from [{}]", - b.bots_database_version, + bots_database_version, v.bots_database_version ); m_database->QueryDatabase( fmt::format( "UPDATE `db_version` SET `bots_version` = {}", - b.bots_database_version + bots_database_version ) ); } @@ -131,7 +135,7 @@ std::string DatabaseUpdate::GetQueryResult(const ManifestEntry& e) return Strings::Join(result_lines, "\n"); } -bool DatabaseUpdate::ShouldRunMigration(ManifestEntry &e, std::string query_result) +bool DatabaseUpdate::ShouldRunMigration(const ManifestEntry& e, std::string& query_result) { std::string r = Strings::Trim(query_result); if (e.condition == "contains") { @@ -163,53 +167,52 @@ bool is_atty() #endif } -// return true if we ran updates -bool DatabaseUpdate::UpdateManifest( - std::vector entries, +std::string DisplayPrompt(const std::string& prompt) +{ + std::string input; + if (is_atty()) { + LogInfo("{} (Timeout 60s)", prompt); + + // user input + bool gave_input = false; + time_t start_time = time(nullptr); + time_t wait_time_seconds = 60; + + // spawn a concurrent thread that waits for input from std::cin + std::thread t1( + [&]() { + std::cin >> input; + gave_input = true; + } + ); + t1.detach(); + + // check the inputReceived flag once every 50ms for 10 seconds + while (time(nullptr) < start_time + wait_time_seconds && !gave_input) { + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + } + } + + return Strings::Trim(input); +} + +// return last successful version updated +int DatabaseUpdate::UpdateManifest( + std::vector& entries, int version_low, int version_high ) { - std::vector missing_migrations = {}; + int latest_version = version_low; if (version_low != version_high) { + // assume at this point that we have a migration to do because there is a version number difference. If a + // migration for a specific manifest entry does not happen because of a missing test, then log it and + // continue (the assumption here is that the user has manually fixed the database at this point). If a force + // interactive flag is set, then stop for each query. Fail the migration if the user says no or it times out + // because it means the database isn't going to have a correct state to continue. Start with backing up the + // database as per user options. - EQEmuLogSys::Instance()->DisableMySQLErrorLogs(); - bool force_interactive = false; - for (int version = version_low + 1; version <= version_high; ++version) { - for (auto &e: entries) { - if (e.version == version) { - bool has_migration = true; - std::string r = GetQueryResult(e); - if (ShouldRunMigration(e, r)) { - has_migration = false; - missing_migrations.emplace_back(e.version); - } - - std::string prefix = fmt::format( - "[{}]", - has_migration ? "ok" : "missing" - ); - - LogInfo( - "[{}] {:>10} | [{}]", - e.version, - prefix, - e.description - ); - - if (!has_migration && e.force_interactive) { - force_interactive = true; - } - } - } - } - EQEmuLogSys::Instance()->EnableMySQLErrorLogs(); - LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); - - if (!missing_migrations.empty() && m_skip_backup) { - LogInfo("Skipping database backup"); - } - else if (!missing_migrations.empty()) { + if (!m_skip_backup) { LogInfo("Automatically backing up database before applying updates"); LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); auto s = DatabaseDumpService(); @@ -217,120 +220,73 @@ bool DatabaseUpdate::UpdateManifest( s.SetDumpWithCompression(true); s.DatabaseDump(); LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); + } else { + LogInfo("Skipping database backup"); } - if (!missing_migrations.empty()) { - LogInfo("Running database migrations. Please wait..."); - LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); - } + LogInfo("Running database migrations. Please wait..."); + LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); - if (force_interactive && !std::getenv("FORCE_INTERACTIVE")) { - LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); - LogInfo("Some migrations require user input. Running interactively"); - LogInfo("This is usually due to a major change that could cause data loss"); - LogInfo("Your server is automatically backed up before these updates are applied"); - LogInfo("but you should also make sure you take a backup prior to running this update"); - LogInfo("Would you like to run this update? [y/n] (Timeout 60s)"); - LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); + auto filtered_entries = entries | std::views::filter( + [version_low, version_high](const ManifestEntry& entry) + { return entry.version > version_low && entry.version <= version_high; }); - // user input - std::string input; - bool gave_input = false; - time_t start_time = time(nullptr); - time_t wait_time_seconds = 60; + std::vector sorted_entries{filtered_entries.begin(), filtered_entries.end()}; + std::ranges::sort(sorted_entries, {}, &ManifestEntry::version); - // spawn a concurrent thread that waits for input from std::cin - std::thread t1( - [&]() { - std::cin >> input; - gave_input = true; - } - ); - t1.detach(); + for (const auto& entry : sorted_entries) { + // this is the test to run this individual migration. If the test fails, then it is safe to assume + // that this migration has already happened manually or otherwise and it's safe to skip + // suppress error messages here, it's all tested in the following function + EQEmuLogSys::Instance()->DisableMySQLErrorLogs(); + std::string result = GetQueryResult(entry); + EQEmuLogSys::Instance()->EnableMySQLErrorLogs(); - // check the inputReceived flag once every 50ms for 10 seconds - while (time(nullptr) < start_time + wait_time_seconds && !gave_input) { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - } + if (ShouldRunMigration(entry, result)) { + if (entry.force_interactive && !std::getenv("FORCE_INTERACTIVE")) { + LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); + LogInfo("This migration requires user input. Running interactively"); + LogInfo("This is usually due to a major change that could cause data loss"); + LogInfo("Your server is automatically backed up before these updates are applied"); + LogInfo("but you should also make sure you take a backup prior to running this update"); + LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); - // prompt for user skip - if (Strings::Trim(input) != "y") { - LogInfo("Exiting due to user input"); - std::exit(1); - } - } - - for (auto &m: missing_migrations) { - for (auto &e: entries) { - if (e.version == m) { - bool errored_migration = false; - - auto r = (e.content_schema_update ? m_content_database : m_database)->QueryDatabaseMulti(e.sql); - - // ignore empty query result "errors" - if (r.ErrorNumber() != 1065 && !r.ErrorMessage().empty()) { - LogError("(#{}) [{}]", r.ErrorNumber(), r.ErrorMessage()); - errored_migration = true; - - LogInfo("Required database update failed. This could be a problem"); - - // if terminal attached then prompt for skip - if (is_atty()) { - LogInfo("Would you like to skip this update? [y/n] (Timeout 60s)"); - - // user input - std::string input; - bool gave_input = false; - time_t start_time = time(nullptr); - time_t wait_time_seconds = 60; - - // spawn a concurrent thread that waits for input from std::cin - std::thread t1( - [&]() { - std::cin >> input; - gave_input = true; - } - ); - t1.detach(); - - // check the inputReceived flag once every 50ms for 10 seconds - while (time(nullptr) < start_time + wait_time_seconds && !gave_input) { - std::this_thread::sleep_for(std::chrono::milliseconds(50)); - } - - // prompt for user skip - if (Strings::Trim(input) == "y") { - errored_migration = false; - LogInfo("Skipping update [{}] [{}]", e.version, e.description); - } - } else { - errored_migration = true; - LogInfo("Skipping update [{}] [{}]", e.version, e.description); - } + // prompt for user skip + if (DisplayPrompt("Would you like to run this update? [y/n]") != "y") { + LogInfo("Exiting due to user input"); + return latest_version; } + } - LogInfo( - "[{}] [{}] [{}]", - e.version, - e.description, - (errored_migration ? "error" : "ok") - ); + auto r = (entry.content_schema_update ? m_content_database : m_database)->QueryDatabaseMulti(entry.sql); - if (errored_migration) { - LogError("Fatal | Database migration [{}] failed to run", e.description); + // ignore empty query result "errors" + if (r.ErrorNumber() != 1065 && !r.ErrorMessage().empty()) { + LogError("(#{}) [{}]", r.ErrorNumber(), r.ErrorMessage()); + LogInfo("Required database update failed."); + + // if terminal attached then prompt for skip + if (DisplayPrompt("Would you like to skip this update? [y/n]") == "y") { + LogInfo("Skipping update [{}] [{}]", entry.version, entry.description); + } else { + LogError("Fatal | Database migration [{}] failed to run", entry.description); LogError("Fatal | Shutting down"); - std::exit(1); + return latest_version; } + + LogInfo("[{}] [{}] [error]", entry.version, entry.description); + } else { + LogInfo("[{}] [{}] [ok]", entry.version, entry.description); } + + latest_version = entry.version; } } LogInfo("{}", Strings::Repeat("-", BREAK_LENGTH)); - - return true; } - return false; + return latest_version; } DatabaseUpdate *DatabaseUpdate::SetDatabase(Database *db) diff --git a/common/database/database_update.h b/common/database/database_update.h index 90b3371d8..978a87b9f 100644 --- a/common/database/database_update.h +++ b/common/database/database_update.h @@ -42,8 +42,8 @@ public: DatabaseVersion GetBinaryDatabaseVersions(); void CheckDbUpdates(); std::string GetQueryResult(const ManifestEntry& e); - static bool ShouldRunMigration(ManifestEntry &e, std::string query_result); - bool UpdateManifest(std::vector entries, int version_low, int version_high); + static bool ShouldRunMigration(const ManifestEntry& e, std::string& query_result); + int UpdateManifest(std::vector& entries, int version_low, int version_high); DatabaseUpdate *SetDatabase(Database *db); DatabaseUpdate *SetContentDatabase(Database *db); diff --git a/common/database/database_update_manifest.h b/common/database/database_update_manifest.h index 5cbddf453..816adf556 100644 --- a/common/database/database_update_manifest.h +++ b/common/database/database_update_manifest.h @@ -7226,6 +7226,45 @@ ALTER TABLE `npc_spells_entries` MODIFY COLUMN `spellid` INTEGER NOT NULL DEFAUL ALTER TABLE `spell_buckets` MODIFY COLUMN `spell_id` INTEGER NOT NULL; )" }, + ManifestEntry{ + .version = 9330, + .description = "2026_04_30_buffdurations.sql", + .check = "SHOW COLUMNS FROM `character_buffs` LIKE 'initialduration'", + .condition = "empty", + .match = "", + .sql = R"( +ALTER TABLE `character_buffs` + ADD COLUMN `initialduration` INT(11) SIGNED NOT NULL DEFAULT 0 AFTER `ticsremaining`, + CHANGE COLUMN `dot_rune` `dot_rune` INT(10) UNSIGNED NOT NULL DEFAULT 0; +UPDATE `character_buffs` SET `initialduration` = `ticsremaining` WHERE TRUE; + +ALTER TABLE IF EXISTS `merc_buffs` + CHANGE COLUMN `dot_rune` `dot_rune` INT(10) UNSIGNED NOT NULL DEFAULT 0, + ADD COLUMN `InitialDuration` INT(11) SIGNED NOT NULL DEFAULT 0 AFTER `TicsRemaining`, + ADD COLUMN `instrument_mod` INT(10) UNSIGNED NOT NULL DEFAULT 10 AFTER `ExtraDIChance`; +IF EXISTS( + SELECT 1 FROM `information_schema`.`TABLES` WHERE `table_schema` = DATABASE() AND `table_name` = 'merc_buffs' +) THEN UPDATE `merc_buffs` SET `InitialDuration` = `TicsRemaining` WHERE TRUE; END IF; + +ALTER TABLE `character_pet_buffs` + CHANGE COLUMN `char_id` `character_id` INT(11) UNSIGNED NOT NULL, + CHANGE COLUMN `slot` `slot_id` TINYINT(3) UNSIGNED NOT NULL, + CHANGE COLUMN `caster_level` `caster_level` TINYINT(3) UNSIGNED NOT NULL, + RENAME COLUMN `castername` TO `caster_name`, + ADD COLUMN `initialduration` INT(11) SIGNED NOT NULL DEFAULT 0 AFTER `ticsremaining`, + CHANGE COLUMN `counters` `counters` INT(10) UNSIGNED NOT NULL DEFAULT 0, + CHANGE COLUMN `numhits` `numhits` INT(10) UNSIGNED NOT NULL DEFAULT 0, + CHANGE COLUMN `rune` `melee_rune` INT(10) UNSIGNED NOT NULL DEFAULT 0, + ADD COLUMN `magic_rune` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `melee_rune`, + ADD COLUMN `persistent` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0 AFTER `magic_rune`, + ADD COLUMN `dot_rune` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `persistent`, + ADD COLUMN `caston_x` INT(10) NOT NULL DEFAULT 0 AFTER `dot_rune`, + ADD COLUMN `caston_y` INT(10) NOT NULL DEFAULT 0 AFTER `caston_x`, + ADD COLUMN `caston_z` INT(10) NOT NULL DEFAULT 0 AFTER `caston_y`, + ADD COLUMN `ExtraDIChance` INT(10) NOT NULL DEFAULT 0 AFTER `caston_z`, + CHANGE COLUMN `instrument_mod` `instrument_mod` INT(10) UNSIGNED NOT NULL DEFAULT 10 AFTER `ExtraDIChance`; +)", + }, // -- template; copy/paste this when you need to create a new entry // ManifestEntry{ // .version = 9228, diff --git a/common/database/database_update_manifest_bots.h b/common/database/database_update_manifest_bots.h index eebdae70f..5a88040cf 100644 --- a/common/database/database_update_manifest_bots.h +++ b/common/database/database_update_manifest_bots.h @@ -2191,6 +2191,36 @@ ALTER TABLE `bot_spells_entries` MODIFY COLUMN `spell_id` INTEGER NOT NULL DEFAU ALTER TABLE `bot_timers` MODIFY COLUMN `spell_id` INTEGER NOT NULL DEFAULT 0; )" }, + ManifestEntry{ + .version = 9057, + .description = "2026_04_30_buffdurations.sql", + .check = "SHOW COLUMNS FROM `bot_buffs` LIKE 'initial_duration'", + .condition = "empty", + .match = "", + .sql = R"( +ALTER TABLE `bot_buffs` + ADD COLUMN `caster_name` VARCHAR(64) NOT NULL DEFAULT '' AFTER `caster_level`, + ADD COLUMN `initial_duration` INT(11) SIGNED NOT NULL DEFAULT 0 AFTER `tics_remaining`; +UPDATE `bot_buffs` SET `initial_duration` = `tics_remaining` WHERE TRUE; + +ALTER TABLE `bot_pet_buffs` + ADD COLUMN `caster_name` VARCHAR(64) NOT NULL DEFAULT '' AFTER `caster_level`, + CHANGE COLUMN `duration` `tics_remaining` INT(11) SIGNED NOT NULL DEFAULT 0 AFTER `caster_name`, + ADD COLUMN `initial_duration` INT(11) SIGNED NOT NULL DEFAULT 0 AFTER `tics_remaining`, + ADD COLUMN `counters` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `initial_duration`, + ADD COLUMN `numhits` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `counters`, + ADD COLUMN `melee_rune` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `numhits`, + ADD COLUMN `magic_rune` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `melee_rune`, + ADD COLUMN `dot_rune` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `magic_rune`, + ADD COLUMN `persistent` TINYINT(3) UNSIGNED NOT NULL DEFAULT 0 AFTER `dot_rune`, + ADD COLUMN `caston_x` INT(10) NOT NULL DEFAULT 0 AFTER `persistent`, + ADD COLUMN `caston_y` INT(10) NOT NULL DEFAULT 0 AFTER `caston_x`, + ADD COLUMN `caston_z` INT(10) NOT NULL DEFAULT 0 AFTER `caston_y`, + ADD COLUMN `extra_di_chance` INT(10) NOT NULL DEFAULT 0 AFTER `caston_z`, + ADD COLUMN `instrument_mod` INT(10) UNSIGNED NOT NULL DEFAULT 10 AFTER `extra_di_chance`; +UPDATE `bot_pet_buffs` SET `initial_duration` = `tics_remaining` WHERE TRUE; +)", + }, // -- template; copy/paste this when you need to create a new entry // ManifestEntry{ // .version = 9228, diff --git a/common/repositories/base/base_adventure_template_repository.h b/common/repositories/base/base_adventure_template_repository.h index 144b2dcbe..811201aba 100644 --- a/common/repositories/base/base_adventure_template_repository.h +++ b/common/repositories/base/base_adventure_template_repository.h @@ -23,7 +23,7 @@ * Any modifications to base repositories are to be made by the generator only * * @generator ./utils/scripts/generators/repository-generator.pl - * @docs https://docs.eqemu.io/developer/repositories + * @docs https://docs.eqemu.dev/developer/repositories */ #pragma once @@ -68,7 +68,7 @@ public: float graveyard_x; float graveyard_y; float graveyard_z; - std::string graveyard_radius; + float graveyard_radius; }; static std::string PrimaryKey() @@ -292,6 +292,7 @@ public: e.graveyard_x = row[29] ? strtof(row[29], nullptr) : 0; e.graveyard_y = row[30] ? strtof(row[30], nullptr) : 0; e.graveyard_z = row[31] ? strtof(row[31], nullptr) : 0; + e.graveyard_radius = row[32] ? (strtof(row[32], nullptr) > 0.0f ? strtof(row[32], nullptr) : 0) : 0; return e; } @@ -539,6 +540,7 @@ public: e.graveyard_x = row[29] ? strtof(row[29], nullptr) : 0; e.graveyard_y = row[30] ? strtof(row[30], nullptr) : 0; e.graveyard_z = row[31] ? strtof(row[31], nullptr) : 0; + e.graveyard_radius = row[32] ? (strtof(row[32], nullptr) > 0.0f ? strtof(row[32], nullptr) : 0) : 0; all_entries.push_back(e); } @@ -595,6 +597,7 @@ public: e.graveyard_x = row[29] ? strtof(row[29], nullptr) : 0; e.graveyard_y = row[30] ? strtof(row[30], nullptr) : 0; e.graveyard_z = row[31] ? strtof(row[31], nullptr) : 0; + e.graveyard_radius = row[32] ? (strtof(row[32], nullptr) > 0.0f ? strtof(row[32], nullptr) : 0) : 0; all_entries.push_back(e); } diff --git a/common/repositories/base/base_blocked_spells_repository.h b/common/repositories/base/base_blocked_spells_repository.h index 1ba7b1970..10ffd6110 100644 --- a/common/repositories/base/base_blocked_spells_repository.h +++ b/common/repositories/base/base_blocked_spells_repository.h @@ -193,7 +193,7 @@ public: BlockedSpells e{}; e.id = row[0] ? static_cast(atoi(row[0])) : 0; - e.spellid = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spellid = row[1] ? static_cast(atoi(row[1])) : 0; e.type = row[2] ? static_cast(atoi(row[2])) : 0; e.zoneid = row[3] ? static_cast(atoi(row[3])) : 0; e.x = row[4] ? strtof(row[4], nullptr) : 0; @@ -372,7 +372,7 @@ public: BlockedSpells e{}; e.id = row[0] ? static_cast(atoi(row[0])) : 0; - e.spellid = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spellid = row[1] ? static_cast(atoi(row[1])) : 0; e.type = row[2] ? static_cast(atoi(row[2])) : 0; e.zoneid = row[3] ? static_cast(atoi(row[3])) : 0; e.x = row[4] ? strtof(row[4], nullptr) : 0; @@ -412,7 +412,7 @@ public: BlockedSpells e{}; e.id = row[0] ? static_cast(atoi(row[0])) : 0; - e.spellid = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spellid = row[1] ? static_cast(atoi(row[1])) : 0; e.type = row[2] ? static_cast(atoi(row[2])) : 0; e.zoneid = row[3] ? static_cast(atoi(row[3])) : 0; e.x = row[4] ? strtof(row[4], nullptr) : 0; diff --git a/common/repositories/base/base_bot_blocked_buffs_repository.h b/common/repositories/base/base_bot_blocked_buffs_repository.h index 7af99fe69..a7ee5f297 100644 --- a/common/repositories/base/base_bot_blocked_buffs_repository.h +++ b/common/repositories/base/base_bot_blocked_buffs_repository.h @@ -144,10 +144,10 @@ public: if (results.RowCount() == 1) { BotBlockedBuffs e{}; - e.bot_id = row[0] ? static_cast(atoi(row[0])) : 0; - e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.blocked = row[2] ? static_cast(atoi(row[2])) : 0; - e.blocked_pet = row[3] ? static_cast(atoi(row[3])) : 0; + e.bot_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; + e.blocked = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.blocked_pet = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; return e; } @@ -276,10 +276,10 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { BotBlockedBuffs e{}; - e.bot_id = row[0] ? static_cast(atoi(row[0])) : 0; - e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.blocked = row[2] ? static_cast(atoi(row[2])) : 0; - e.blocked_pet = row[3] ? static_cast(atoi(row[3])) : 0; + e.bot_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; + e.blocked = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.blocked_pet = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; all_entries.push_back(e); } @@ -304,10 +304,10 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { BotBlockedBuffs e{}; - e.bot_id = row[0] ? static_cast(atoi(row[0])) : 0; - e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.blocked = row[2] ? static_cast(atoi(row[2])) : 0; - e.blocked_pet = row[3] ? static_cast(atoi(row[3])) : 0; + e.bot_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; + e.blocked = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.blocked_pet = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; all_entries.push_back(e); } diff --git a/common/repositories/base/base_bot_buffs_repository.h b/common/repositories/base/base_bot_buffs_repository.h index 689184fd7..f34100488 100644 --- a/common/repositories/base/base_bot_buffs_repository.h +++ b/common/repositories/base/base_bot_buffs_repository.h @@ -36,26 +36,28 @@ class BaseBotBuffsRepository { public: struct BotBuffs { - uint32_t buffs_index; - uint32_t bot_id; - int32_t spell_id; - uint8_t caster_level; - uint32_t duration_formula; - uint32_t tics_remaining; - uint32_t poison_counters; - uint32_t disease_counters; - uint32_t curse_counters; - uint32_t corruption_counters; - uint32_t numhits; - uint32_t melee_rune; - uint32_t magic_rune; - uint32_t dot_rune; - int8_t persistent; - int32_t caston_x; - int32_t caston_y; - int32_t caston_z; - uint32_t extra_di_chance; - int32_t instrument_mod; + uint32_t buffs_index; + uint32_t bot_id; + int32_t spell_id; + uint8_t caster_level; + std::string caster_name; + uint32_t duration_formula; + uint32_t tics_remaining; + int32_t initial_duration; + uint32_t poison_counters; + uint32_t disease_counters; + uint32_t curse_counters; + uint32_t corruption_counters; + uint32_t numhits; + uint32_t melee_rune; + uint32_t magic_rune; + uint32_t dot_rune; + int8_t persistent; + int32_t caston_x; + int32_t caston_y; + int32_t caston_z; + uint32_t extra_di_chance; + int32_t instrument_mod; }; static std::string PrimaryKey() @@ -70,8 +72,10 @@ public: "bot_id", "spell_id", "caster_level", + "caster_name", "duration_formula", "tics_remaining", + "initial_duration", "poison_counters", "disease_counters", "curse_counters", @@ -96,8 +100,10 @@ public: "bot_id", "spell_id", "caster_level", + "caster_name", "duration_formula", "tics_remaining", + "initial_duration", "poison_counters", "disease_counters", "curse_counters", @@ -156,8 +162,10 @@ public: e.bot_id = 0; e.spell_id = 0; e.caster_level = 0; + e.caster_name = ""; e.duration_formula = 0; e.tics_remaining = 0; + e.initial_duration = 0; e.poison_counters = 0; e.disease_counters = 0; e.curse_counters = 0; @@ -210,24 +218,26 @@ public: e.buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.duration_formula = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; - e.tics_remaining = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; - e.poison_counters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.disease_counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.curse_counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.corruption_counters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.numhits = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.melee_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; - e.magic_rune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; - e.dot_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; - e.persistent = row[14] ? static_cast(atoi(row[14])) : 0; - e.caston_x = row[15] ? static_cast(atoi(row[15])) : 0; - e.caston_y = row[16] ? static_cast(atoi(row[16])) : 0; - e.caston_z = row[17] ? static_cast(atoi(row[17])) : 0; - e.extra_di_chance = row[18] ? static_cast(strtoul(row[18], nullptr, 10)) : 0; - e.instrument_mod = row[19] ? static_cast(atoi(row[19])) : 10; + e.caster_name = row[4] ? row[4] : ""; + e.duration_formula = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.tics_remaining = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; + e.initial_duration = row[7] ? static_cast(atoi(row[7])) : 0; + e.poison_counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.disease_counters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.curse_counters = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.corruption_counters = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.numhits = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.melee_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.magic_rune = row[14] ? static_cast(strtoul(row[14], nullptr, 10)) : 0; + e.dot_rune = row[15] ? static_cast(strtoul(row[15], nullptr, 10)) : 0; + e.persistent = row[16] ? static_cast(atoi(row[16])) : 0; + e.caston_x = row[17] ? static_cast(atoi(row[17])) : 0; + e.caston_y = row[18] ? static_cast(atoi(row[18])) : 0; + e.caston_z = row[19] ? static_cast(atoi(row[19])) : 0; + e.extra_di_chance = row[20] ? static_cast(strtoul(row[20], nullptr, 10)) : 0; + e.instrument_mod = row[21] ? static_cast(atoi(row[21])) : 10; return e; } @@ -264,22 +274,24 @@ public: v.push_back(columns[1] + " = " + std::to_string(e.bot_id)); v.push_back(columns[2] + " = " + std::to_string(e.spell_id)); v.push_back(columns[3] + " = " + std::to_string(e.caster_level)); - v.push_back(columns[4] + " = " + std::to_string(e.duration_formula)); - v.push_back(columns[5] + " = " + std::to_string(e.tics_remaining)); - v.push_back(columns[6] + " = " + std::to_string(e.poison_counters)); - v.push_back(columns[7] + " = " + std::to_string(e.disease_counters)); - v.push_back(columns[8] + " = " + std::to_string(e.curse_counters)); - v.push_back(columns[9] + " = " + std::to_string(e.corruption_counters)); - v.push_back(columns[10] + " = " + std::to_string(e.numhits)); - v.push_back(columns[11] + " = " + std::to_string(e.melee_rune)); - v.push_back(columns[12] + " = " + std::to_string(e.magic_rune)); - v.push_back(columns[13] + " = " + std::to_string(e.dot_rune)); - v.push_back(columns[14] + " = " + std::to_string(e.persistent)); - v.push_back(columns[15] + " = " + std::to_string(e.caston_x)); - v.push_back(columns[16] + " = " + std::to_string(e.caston_y)); - v.push_back(columns[17] + " = " + std::to_string(e.caston_z)); - v.push_back(columns[18] + " = " + std::to_string(e.extra_di_chance)); - v.push_back(columns[19] + " = " + std::to_string(e.instrument_mod)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.caster_name) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.duration_formula)); + v.push_back(columns[6] + " = " + std::to_string(e.tics_remaining)); + v.push_back(columns[7] + " = " + std::to_string(e.initial_duration)); + v.push_back(columns[8] + " = " + std::to_string(e.poison_counters)); + v.push_back(columns[9] + " = " + std::to_string(e.disease_counters)); + v.push_back(columns[10] + " = " + std::to_string(e.curse_counters)); + v.push_back(columns[11] + " = " + std::to_string(e.corruption_counters)); + v.push_back(columns[12] + " = " + std::to_string(e.numhits)); + v.push_back(columns[13] + " = " + std::to_string(e.melee_rune)); + v.push_back(columns[14] + " = " + std::to_string(e.magic_rune)); + v.push_back(columns[15] + " = " + std::to_string(e.dot_rune)); + v.push_back(columns[16] + " = " + std::to_string(e.persistent)); + v.push_back(columns[17] + " = " + std::to_string(e.caston_x)); + v.push_back(columns[18] + " = " + std::to_string(e.caston_y)); + v.push_back(columns[19] + " = " + std::to_string(e.caston_z)); + v.push_back(columns[20] + " = " + std::to_string(e.extra_di_chance)); + v.push_back(columns[21] + " = " + std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -305,8 +317,10 @@ public: v.push_back(std::to_string(e.bot_id)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.duration_formula)); v.push_back(std::to_string(e.tics_remaining)); + v.push_back(std::to_string(e.initial_duration)); v.push_back(std::to_string(e.poison_counters)); v.push_back(std::to_string(e.disease_counters)); v.push_back(std::to_string(e.curse_counters)); @@ -354,8 +368,10 @@ public: v.push_back(std::to_string(e.bot_id)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.duration_formula)); v.push_back(std::to_string(e.tics_remaining)); + v.push_back(std::to_string(e.initial_duration)); v.push_back(std::to_string(e.poison_counters)); v.push_back(std::to_string(e.disease_counters)); v.push_back(std::to_string(e.curse_counters)); @@ -405,24 +421,26 @@ public: e.buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.duration_formula = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; - e.tics_remaining = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; - e.poison_counters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.disease_counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.curse_counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.corruption_counters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.numhits = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.melee_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; - e.magic_rune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; - e.dot_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; - e.persistent = row[14] ? static_cast(atoi(row[14])) : 0; - e.caston_x = row[15] ? static_cast(atoi(row[15])) : 0; - e.caston_y = row[16] ? static_cast(atoi(row[16])) : 0; - e.caston_z = row[17] ? static_cast(atoi(row[17])) : 0; - e.extra_di_chance = row[18] ? static_cast(strtoul(row[18], nullptr, 10)) : 0; - e.instrument_mod = row[19] ? static_cast(atoi(row[19])) : 10; + e.caster_name = row[4] ? row[4] : ""; + e.duration_formula = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.tics_remaining = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; + e.initial_duration = row[7] ? static_cast(atoi(row[7])) : 0; + e.poison_counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.disease_counters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.curse_counters = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.corruption_counters = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.numhits = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.melee_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.magic_rune = row[14] ? static_cast(strtoul(row[14], nullptr, 10)) : 0; + e.dot_rune = row[15] ? static_cast(strtoul(row[15], nullptr, 10)) : 0; + e.persistent = row[16] ? static_cast(atoi(row[16])) : 0; + e.caston_x = row[17] ? static_cast(atoi(row[17])) : 0; + e.caston_y = row[18] ? static_cast(atoi(row[18])) : 0; + e.caston_z = row[19] ? static_cast(atoi(row[19])) : 0; + e.extra_di_chance = row[20] ? static_cast(strtoul(row[20], nullptr, 10)) : 0; + e.instrument_mod = row[21] ? static_cast(atoi(row[21])) : 10; all_entries.push_back(e); } @@ -449,24 +467,26 @@ public: e.buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.duration_formula = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; - e.tics_remaining = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; - e.poison_counters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.disease_counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.curse_counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.corruption_counters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.numhits = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.melee_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; - e.magic_rune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; - e.dot_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; - e.persistent = row[14] ? static_cast(atoi(row[14])) : 0; - e.caston_x = row[15] ? static_cast(atoi(row[15])) : 0; - e.caston_y = row[16] ? static_cast(atoi(row[16])) : 0; - e.caston_z = row[17] ? static_cast(atoi(row[17])) : 0; - e.extra_di_chance = row[18] ? static_cast(strtoul(row[18], nullptr, 10)) : 0; - e.instrument_mod = row[19] ? static_cast(atoi(row[19])) : 10; + e.caster_name = row[4] ? row[4] : ""; + e.duration_formula = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.tics_remaining = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; + e.initial_duration = row[7] ? static_cast(atoi(row[7])) : 0; + e.poison_counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.disease_counters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.curse_counters = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.corruption_counters = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.numhits = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.melee_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.magic_rune = row[14] ? static_cast(strtoul(row[14], nullptr, 10)) : 0; + e.dot_rune = row[15] ? static_cast(strtoul(row[15], nullptr, 10)) : 0; + e.persistent = row[16] ? static_cast(atoi(row[16])) : 0; + e.caston_x = row[17] ? static_cast(atoi(row[17])) : 0; + e.caston_y = row[18] ? static_cast(atoi(row[18])) : 0; + e.caston_z = row[19] ? static_cast(atoi(row[19])) : 0; + e.extra_di_chance = row[20] ? static_cast(strtoul(row[20], nullptr, 10)) : 0; + e.instrument_mod = row[21] ? static_cast(atoi(row[21])) : 10; all_entries.push_back(e); } @@ -545,8 +565,10 @@ public: v.push_back(std::to_string(e.bot_id)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.duration_formula)); v.push_back(std::to_string(e.tics_remaining)); + v.push_back(std::to_string(e.initial_duration)); v.push_back(std::to_string(e.poison_counters)); v.push_back(std::to_string(e.disease_counters)); v.push_back(std::to_string(e.curse_counters)); @@ -587,8 +609,10 @@ public: v.push_back(std::to_string(e.bot_id)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.duration_formula)); v.push_back(std::to_string(e.tics_remaining)); + v.push_back(std::to_string(e.initial_duration)); v.push_back(std::to_string(e.poison_counters)); v.push_back(std::to_string(e.disease_counters)); v.push_back(std::to_string(e.curse_counters)); diff --git a/common/repositories/base/base_bot_create_combinations_repository.h b/common/repositories/base/base_bot_create_combinations_repository.h index f76916865..47e4b7ddd 100644 --- a/common/repositories/base/base_bot_create_combinations_repository.h +++ b/common/repositories/base/base_bot_create_combinations_repository.h @@ -32,6 +32,7 @@ #include "common/strings.h" #include + class BaseBotCreateCombinationsRepository { public: struct BotCreateCombinations { diff --git a/common/repositories/base/base_bot_heal_rotations_repository.h b/common/repositories/base/base_bot_heal_rotations_repository.h index 5c2403ff1..201a8aa59 100644 --- a/common/repositories/base/base_bot_heal_rotations_repository.h +++ b/common/repositories/base/base_bot_heal_rotations_repository.h @@ -198,6 +198,16 @@ public: e.fast_heals = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.adaptive_targeting = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.casting_override = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.safe_hp_base = row[6] ? (strtof(row[6], nullptr) > 0.0f ? strtof(row[6], nullptr) : 0) : 0; + e.safe_hp_cloth = row[7] ? (strtof(row[7], nullptr) > 0.0f ? strtof(row[7], nullptr) : 0) : 0; + e.safe_hp_leather = row[8] ? (strtof(row[8], nullptr) > 0.0f ? strtof(row[8], nullptr) : 0) : 0; + e.safe_hp_chain = row[9] ? (strtof(row[9], nullptr) > 0.0f ? strtof(row[9], nullptr) : 0) : 0; + e.safe_hp_plate = row[10] ? (strtof(row[10], nullptr) > 0.0f ? strtof(row[10], nullptr) : 0) : 0; + e.critical_hp_base = row[11] ? (strtof(row[11], nullptr) > 0.0f ? strtof(row[11], nullptr) : 0) : 0; + e.critical_hp_cloth = row[12] ? (strtof(row[12], nullptr) > 0.0f ? strtof(row[12], nullptr) : 0) : 0; + e.critical_hp_leather = row[13] ? (strtof(row[13], nullptr) > 0.0f ? strtof(row[13], nullptr) : 0) : 0; + e.critical_hp_chain = row[14] ? (strtof(row[14], nullptr) > 0.0f ? strtof(row[14], nullptr) : 0) : 0; + e.critical_hp_plate = row[15] ? (strtof(row[15], nullptr) > 0.0f ? strtof(row[15], nullptr) : 0) : 0; return e; } @@ -367,6 +377,16 @@ public: e.fast_heals = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.adaptive_targeting = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.casting_override = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.safe_hp_base = row[6] ? (strtof(row[6], nullptr) > 0.0f ? strtof(row[6], nullptr) : 0) : 0; + e.safe_hp_cloth = row[7] ? (strtof(row[7], nullptr) > 0.0f ? strtof(row[7], nullptr) : 0) : 0; + e.safe_hp_leather = row[8] ? (strtof(row[8], nullptr) > 0.0f ? strtof(row[8], nullptr) : 0) : 0; + e.safe_hp_chain = row[9] ? (strtof(row[9], nullptr) > 0.0f ? strtof(row[9], nullptr) : 0) : 0; + e.safe_hp_plate = row[10] ? (strtof(row[10], nullptr) > 0.0f ? strtof(row[10], nullptr) : 0) : 0; + e.critical_hp_base = row[11] ? (strtof(row[11], nullptr) > 0.0f ? strtof(row[11], nullptr) : 0) : 0; + e.critical_hp_cloth = row[12] ? (strtof(row[12], nullptr) > 0.0f ? strtof(row[12], nullptr) : 0) : 0; + e.critical_hp_leather = row[13] ? (strtof(row[13], nullptr) > 0.0f ? strtof(row[13], nullptr) : 0) : 0; + e.critical_hp_chain = row[14] ? (strtof(row[14], nullptr) > 0.0f ? strtof(row[14], nullptr) : 0) : 0; + e.critical_hp_plate = row[15] ? (strtof(row[15], nullptr) > 0.0f ? strtof(row[15], nullptr) : 0) : 0; all_entries.push_back(e); } @@ -397,6 +417,16 @@ public: e.fast_heals = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.adaptive_targeting = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.casting_override = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.safe_hp_base = row[6] ? (strtof(row[6], nullptr) > 0.0f ? strtof(row[6], nullptr) : 0) : 0; + e.safe_hp_cloth = row[7] ? (strtof(row[7], nullptr) > 0.0f ? strtof(row[7], nullptr) : 0) : 0; + e.safe_hp_leather = row[8] ? (strtof(row[8], nullptr) > 0.0f ? strtof(row[8], nullptr) : 0) : 0; + e.safe_hp_chain = row[9] ? (strtof(row[9], nullptr) > 0.0f ? strtof(row[9], nullptr) : 0) : 0; + e.safe_hp_plate = row[10] ? (strtof(row[10], nullptr) > 0.0f ? strtof(row[10], nullptr) : 0) : 0; + e.critical_hp_base = row[11] ? (strtof(row[11], nullptr) > 0.0f ? strtof(row[11], nullptr) : 0) : 0; + e.critical_hp_cloth = row[12] ? (strtof(row[12], nullptr) > 0.0f ? strtof(row[12], nullptr) : 0) : 0; + e.critical_hp_leather = row[13] ? (strtof(row[13], nullptr) > 0.0f ? strtof(row[13], nullptr) : 0) : 0; + e.critical_hp_chain = row[14] ? (strtof(row[14], nullptr) > 0.0f ? strtof(row[14], nullptr) : 0) : 0; + e.critical_hp_plate = row[15] ? (strtof(row[15], nullptr) > 0.0f ? strtof(row[15], nullptr) : 0) : 0; all_entries.push_back(e); } diff --git a/common/repositories/base/base_bot_inspect_messages_repository.h b/common/repositories/base/base_bot_inspect_messages_repository.h index ab11ab84c..0168ffc6e 100644 --- a/common/repositories/base/base_bot_inspect_messages_repository.h +++ b/common/repositories/base/base_bot_inspect_messages_repository.h @@ -32,6 +32,7 @@ #include "common/strings.h" #include + class BaseBotInspectMessagesRepository { public: struct BotInspectMessages { diff --git a/common/repositories/base/base_bot_pet_buffs_repository.h b/common/repositories/base/base_bot_pet_buffs_repository.h index fc391e27c..9d197402c 100644 --- a/common/repositories/base/base_bot_pet_buffs_repository.h +++ b/common/repositories/base/base_bot_pet_buffs_repository.h @@ -36,11 +36,24 @@ class BaseBotPetBuffsRepository { public: struct BotPetBuffs { - uint32_t pet_buffs_index; - uint32_t pets_index; - int32_t spell_id; - uint32_t caster_level; - uint32_t duration; + uint32_t pet_buffs_index; + uint32_t pets_index; + int32_t spell_id; + uint32_t caster_level; + std::string caster_name; + int32_t tics_remaining; + int32_t initial_duration; + uint32_t counters; + uint32_t numhits; + uint32_t melee_rune; + uint32_t magic_rune; + uint32_t dot_rune; + uint8_t persistent; + int32_t caston_x; + int32_t caston_y; + int32_t caston_z; + int32_t extra_di_chance; + uint32_t instrument_mod; }; static std::string PrimaryKey() @@ -55,7 +68,20 @@ public: "pets_index", "spell_id", "caster_level", - "duration", + "caster_name", + "tics_remaining", + "initial_duration", + "counters", + "numhits", + "melee_rune", + "magic_rune", + "dot_rune", + "persistent", + "caston_x", + "caston_y", + "caston_z", + "extra_di_chance", + "instrument_mod", }; } @@ -66,7 +92,20 @@ public: "pets_index", "spell_id", "caster_level", - "duration", + "caster_name", + "tics_remaining", + "initial_duration", + "counters", + "numhits", + "melee_rune", + "magic_rune", + "dot_rune", + "persistent", + "caston_x", + "caston_y", + "caston_z", + "extra_di_chance", + "instrument_mod", }; } @@ -107,11 +146,24 @@ public: { BotPetBuffs e{}; - e.pet_buffs_index = 0; - e.pets_index = 0; - e.spell_id = 0; - e.caster_level = 0; - e.duration = 0; + e.pet_buffs_index = 0; + e.pets_index = 0; + e.spell_id = 0; + e.caster_level = 0; + e.caster_name = ""; + e.tics_remaining = 0; + e.initial_duration = 0; + e.counters = 0; + e.numhits = 0; + e.melee_rune = 0; + e.magic_rune = 0; + e.dot_rune = 0; + e.persistent = 0; + e.caston_x = 0; + e.caston_y = 0; + e.caston_z = 0; + e.extra_di_chance = 0; + e.instrument_mod = 10; return e; } @@ -148,11 +200,24 @@ public: if (results.RowCount() == 1) { BotPetBuffs e{}; - e.pet_buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.pets_index = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; - e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.duration = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.pet_buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.pets_index = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.caster_name = row[4] ? row[4] : ""; + e.tics_remaining = row[5] ? static_cast(atoi(row[5])) : 0; + e.initial_duration = row[6] ? static_cast(atoi(row[6])) : 0; + e.counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.numhits = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.melee_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.magic_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.dot_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.persistent = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.caston_x = row[13] ? static_cast(atoi(row[13])) : 0; + e.caston_y = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_z = row[15] ? static_cast(atoi(row[15])) : 0; + e.extra_di_chance = row[16] ? static_cast(atoi(row[16])) : 0; + e.instrument_mod = row[17] ? static_cast(strtoul(row[17], nullptr, 10)) : 10; return e; } @@ -189,7 +254,20 @@ public: v.push_back(columns[1] + " = " + std::to_string(e.pets_index)); v.push_back(columns[2] + " = " + std::to_string(e.spell_id)); v.push_back(columns[3] + " = " + std::to_string(e.caster_level)); - v.push_back(columns[4] + " = " + std::to_string(e.duration)); + v.push_back(columns[4] + " = '" + Strings::Escape(e.caster_name) + "'"); + v.push_back(columns[5] + " = " + std::to_string(e.tics_remaining)); + v.push_back(columns[6] + " = " + std::to_string(e.initial_duration)); + v.push_back(columns[7] + " = " + std::to_string(e.counters)); + v.push_back(columns[8] + " = " + std::to_string(e.numhits)); + v.push_back(columns[9] + " = " + std::to_string(e.melee_rune)); + v.push_back(columns[10] + " = " + std::to_string(e.magic_rune)); + v.push_back(columns[11] + " = " + std::to_string(e.dot_rune)); + v.push_back(columns[12] + " = " + std::to_string(e.persistent)); + v.push_back(columns[13] + " = " + std::to_string(e.caston_x)); + v.push_back(columns[14] + " = " + std::to_string(e.caston_y)); + v.push_back(columns[15] + " = " + std::to_string(e.caston_z)); + v.push_back(columns[16] + " = " + std::to_string(e.extra_di_chance)); + v.push_back(columns[17] + " = " + std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -215,7 +293,20 @@ public: v.push_back(std::to_string(e.pets_index)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); - v.push_back(std::to_string(e.duration)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); + v.push_back(std::to_string(e.tics_remaining)); + v.push_back(std::to_string(e.initial_duration)); + v.push_back(std::to_string(e.counters)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.extra_di_chance)); + v.push_back(std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -249,7 +340,20 @@ public: v.push_back(std::to_string(e.pets_index)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); - v.push_back(std::to_string(e.duration)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); + v.push_back(std::to_string(e.tics_remaining)); + v.push_back(std::to_string(e.initial_duration)); + v.push_back(std::to_string(e.counters)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.extra_di_chance)); + v.push_back(std::to_string(e.instrument_mod)); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } @@ -283,11 +387,24 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { BotPetBuffs e{}; - e.pet_buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.pets_index = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; - e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.duration = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.pet_buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.pets_index = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.caster_name = row[4] ? row[4] : ""; + e.tics_remaining = row[5] ? static_cast(atoi(row[5])) : 0; + e.initial_duration = row[6] ? static_cast(atoi(row[6])) : 0; + e.counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.numhits = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.melee_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.magic_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.dot_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.persistent = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.caston_x = row[13] ? static_cast(atoi(row[13])) : 0; + e.caston_y = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_z = row[15] ? static_cast(atoi(row[15])) : 0; + e.extra_di_chance = row[16] ? static_cast(atoi(row[16])) : 0; + e.instrument_mod = row[17] ? static_cast(strtoul(row[17], nullptr, 10)) : 10; all_entries.push_back(e); } @@ -312,11 +429,24 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { BotPetBuffs e{}; - e.pet_buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.pets_index = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; - e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.duration = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.pet_buffs_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.pets_index = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.caster_name = row[4] ? row[4] : ""; + e.tics_remaining = row[5] ? static_cast(atoi(row[5])) : 0; + e.initial_duration = row[6] ? static_cast(atoi(row[6])) : 0; + e.counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.numhits = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.melee_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.magic_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.dot_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.persistent = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.caston_x = row[13] ? static_cast(atoi(row[13])) : 0; + e.caston_y = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_z = row[15] ? static_cast(atoi(row[15])) : 0; + e.extra_di_chance = row[16] ? static_cast(atoi(row[16])) : 0; + e.instrument_mod = row[17] ? static_cast(strtoul(row[17], nullptr, 10)) : 10; all_entries.push_back(e); } @@ -395,7 +525,20 @@ public: v.push_back(std::to_string(e.pets_index)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); - v.push_back(std::to_string(e.duration)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); + v.push_back(std::to_string(e.tics_remaining)); + v.push_back(std::to_string(e.initial_duration)); + v.push_back(std::to_string(e.counters)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.extra_di_chance)); + v.push_back(std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -422,7 +565,20 @@ public: v.push_back(std::to_string(e.pets_index)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); - v.push_back(std::to_string(e.duration)); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); + v.push_back(std::to_string(e.tics_remaining)); + v.push_back(std::to_string(e.initial_duration)); + v.push_back(std::to_string(e.counters)); + v.push_back(std::to_string(e.numhits)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.extra_di_chance)); + v.push_back(std::to_string(e.instrument_mod)); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } diff --git a/common/repositories/base/base_bot_pets_repository.h b/common/repositories/base/base_bot_pets_repository.h index 66f17a76a..a5d0c4a3b 100644 --- a/common/repositories/base/base_bot_pets_repository.h +++ b/common/repositories/base/base_bot_pets_repository.h @@ -153,7 +153,7 @@ public: BotPets e{}; e.pets_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.spell_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; e.bot_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.name = row[3] ? row[3] : ""; e.mana = row[4] ? static_cast(atoi(row[4])) : 0; @@ -292,7 +292,7 @@ public: BotPets e{}; e.pets_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.spell_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; e.bot_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.name = row[3] ? row[3] : ""; e.mana = row[4] ? static_cast(atoi(row[4])) : 0; @@ -322,7 +322,7 @@ public: BotPets e{}; e.pets_index = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.spell_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[1] ? static_cast(atoi(row[1])) : 0; e.bot_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.name = row[3] ? row[3] : ""; e.mana = row[4] ? static_cast(atoi(row[4])) : 0; diff --git a/common/repositories/base/base_bot_settings_repository.h b/common/repositories/base/base_bot_settings_repository.h index aebc5c8d9..9029340c7 100644 --- a/common/repositories/base/base_bot_settings_repository.h +++ b/common/repositories/base/base_bot_settings_repository.h @@ -41,7 +41,7 @@ public: uint8_t stance; uint16_t setting_id; uint8_t setting_type; - int32_t value; + int64_t value; std::string category_name; std::string setting_name; }; @@ -116,7 +116,7 @@ public: { BotSettings e{}; - e.character_id = 0; + e.character_id = 0; e.bot_id = 0; e.stance = 0; e.setting_id = 0; @@ -160,12 +160,12 @@ public: if (results.RowCount() == 1) { BotSettings e{}; - e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; e.stance = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.setting_id = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.setting_type = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; - e.value = row[5] ? static_cast(atoi(row[5])) : 0; + e.value = row[5] ? strtoll(row[5], nullptr, 10) : 0; e.category_name = row[6] ? row[6] : ""; e.setting_name = row[7] ? row[7] : ""; @@ -308,12 +308,12 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { BotSettings e{}; - e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; e.stance = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.setting_id = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.setting_type = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; - e.value = row[5] ? static_cast(atoi(row[5])) : 0; + e.value = row[5] ? strtoll(row[5], nullptr, 10) : 0; e.category_name = row[6] ? row[6] : ""; e.setting_name = row[7] ? row[7] : ""; @@ -340,12 +340,12 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { BotSettings e{}; - e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; e.stance = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; e.setting_id = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.setting_type = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; - e.value = row[5] ? static_cast(atoi(row[5])) : 0; + e.value = row[5] ? strtoll(row[5], nullptr, 10) : 0; e.category_name = row[6] ? row[6] : ""; e.setting_name = row[7] ? row[7] : ""; diff --git a/common/repositories/base/base_bot_spell_settings_repository.h b/common/repositories/base/base_bot_spell_settings_repository.h index 7526c31b1..e6910b911 100644 --- a/common/repositories/base/base_bot_spell_settings_repository.h +++ b/common/repositories/base/base_bot_spell_settings_repository.h @@ -158,7 +158,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.priority = row[3] ? static_cast(atoi(row[3])) : 0; e.min_hp = row[4] ? static_cast(atoi(row[4])) : 0; e.max_hp = row[5] ? static_cast(atoi(row[5])) : 0; @@ -301,7 +301,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.priority = row[3] ? static_cast(atoi(row[3])) : 0; e.min_hp = row[4] ? static_cast(atoi(row[4])) : 0; e.max_hp = row[5] ? static_cast(atoi(row[5])) : 0; @@ -332,7 +332,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.bot_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.priority = row[3] ? static_cast(atoi(row[3])) : 0; e.min_hp = row[4] ? static_cast(atoi(row[4])) : 0; e.max_hp = row[5] ? static_cast(atoi(row[5])) : 0; diff --git a/common/repositories/base/base_bot_spells_entries_repository.h b/common/repositories/base/base_bot_spells_entries_repository.h index 02da648c6..bd222dd42 100644 --- a/common/repositories/base/base_bot_spells_entries_repository.h +++ b/common/repositories/base/base_bot_spells_entries_repository.h @@ -190,7 +190,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; @@ -365,7 +365,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; @@ -404,7 +404,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; diff --git a/common/repositories/base/base_bot_timers_repository.h b/common/repositories/base/base_bot_timers_repository.h index 5786f7890..a6c289568 100644 --- a/common/repositories/base/base_bot_timers_repository.h +++ b/common/repositories/base/base_bot_timers_repository.h @@ -170,7 +170,7 @@ public: e.recast_time = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.is_spell = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.is_disc = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; - e.spell_id = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; + e.spell_id = row[6] ? static_cast(atoi(row[6])) : 0; e.is_item = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; e.item_id = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; @@ -322,7 +322,7 @@ public: e.recast_time = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.is_spell = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.is_disc = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; - e.spell_id = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; + e.spell_id = row[6] ? static_cast(atoi(row[6])) : 0; e.is_item = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; e.item_id = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; @@ -355,7 +355,7 @@ public: e.recast_time = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.is_spell = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.is_disc = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; - e.spell_id = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; + e.spell_id = row[6] ? static_cast(atoi(row[6])) : 0; e.is_item = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; e.item_id = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; diff --git a/common/repositories/base/base_character_buffs_repository.h b/common/repositories/base/base_character_buffs_repository.h index d91c31f07..a02f90c62 100644 --- a/common/repositories/base/base_character_buffs_repository.h +++ b/common/repositories/base/base_character_buffs_repository.h @@ -42,12 +42,13 @@ public: uint8_t caster_level; std::string caster_name; int32_t ticsremaining; + int32_t initialduration; uint32_t counters; uint32_t numhits; uint32_t melee_rune; uint32_t magic_rune; uint8_t persistent; - int32_t dot_rune; + uint32_t dot_rune; int32_t caston_x; int32_t caston_y; int32_t caston_z; @@ -69,6 +70,7 @@ public: "caster_level", "caster_name", "ticsremaining", + "initialduration", "counters", "numhits", "melee_rune", @@ -92,6 +94,7 @@ public: "caster_level", "caster_name", "ticsremaining", + "initialduration", "counters", "numhits", "melee_rune", @@ -143,23 +146,24 @@ public: { CharacterBuffs e{}; - e.character_id = 0; - e.slot_id = 0; - e.spell_id = 0; - e.caster_level = 0; - e.caster_name = ""; - e.ticsremaining = 0; - e.counters = 0; - e.numhits = 0; - e.melee_rune = 0; - e.magic_rune = 0; - e.persistent = 0; - e.dot_rune = 0; - e.caston_x = 0; - e.caston_y = 0; - e.caston_z = 0; - e.ExtraDIChance = 0; - e.instrument_mod = 10; + e.character_id = 0; + e.slot_id = 0; + e.spell_id = 0; + e.caster_level = 0; + e.caster_name = ""; + e.ticsremaining = 0; + e.initialduration = 0; + e.counters = 0; + e.numhits = 0; + e.melee_rune = 0; + e.magic_rune = 0; + e.persistent = 0; + e.dot_rune = 0; + e.caston_x = 0; + e.caston_y = 0; + e.caston_z = 0; + e.ExtraDIChance = 0; + e.instrument_mod = 10; return e; } @@ -196,23 +200,24 @@ public: if (results.RowCount() == 1) { CharacterBuffs e{}; - e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; - e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.caster_name = row[4] ? row[4] : ""; - e.ticsremaining = row[5] ? static_cast(atoi(row[5])) : 0; - e.counters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.numhits = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.melee_rune = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.magic_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.persistent = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.dot_rune = row[11] ? static_cast(atoi(row[11])) : 0; - e.caston_x = row[12] ? static_cast(atoi(row[12])) : 0; - e.caston_y = row[13] ? static_cast(atoi(row[13])) : 0; - e.caston_z = row[14] ? static_cast(atoi(row[14])) : 0; - e.ExtraDIChance = row[15] ? static_cast(atoi(row[15])) : 0; - e.instrument_mod = row[16] ? static_cast(atoi(row[16])) : 10; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.caster_name = row[4] ? row[4] : ""; + e.ticsremaining = row[5] ? static_cast(atoi(row[5])) : 0; + e.initialduration = row[6] ? static_cast(atoi(row[6])) : 0; + e.counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.numhits = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.melee_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.magic_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.persistent = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.dot_rune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.caston_x = row[13] ? static_cast(atoi(row[13])) : 0; + e.caston_y = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_z = row[15] ? static_cast(atoi(row[15])) : 0; + e.ExtraDIChance = row[16] ? static_cast(atoi(row[16])) : 0; + e.instrument_mod = row[17] ? static_cast(atoi(row[17])) : 10; return e; } @@ -252,17 +257,18 @@ public: v.push_back(columns[3] + " = " + std::to_string(e.caster_level)); v.push_back(columns[4] + " = '" + Strings::Escape(e.caster_name) + "'"); v.push_back(columns[5] + " = " + std::to_string(e.ticsremaining)); - v.push_back(columns[6] + " = " + std::to_string(e.counters)); - v.push_back(columns[7] + " = " + std::to_string(e.numhits)); - v.push_back(columns[8] + " = " + std::to_string(e.melee_rune)); - v.push_back(columns[9] + " = " + std::to_string(e.magic_rune)); - v.push_back(columns[10] + " = " + std::to_string(e.persistent)); - v.push_back(columns[11] + " = " + std::to_string(e.dot_rune)); - v.push_back(columns[12] + " = " + std::to_string(e.caston_x)); - v.push_back(columns[13] + " = " + std::to_string(e.caston_y)); - v.push_back(columns[14] + " = " + std::to_string(e.caston_z)); - v.push_back(columns[15] + " = " + std::to_string(e.ExtraDIChance)); - v.push_back(columns[16] + " = " + std::to_string(e.instrument_mod)); + v.push_back(columns[6] + " = " + std::to_string(e.initialduration)); + v.push_back(columns[7] + " = " + std::to_string(e.counters)); + v.push_back(columns[8] + " = " + std::to_string(e.numhits)); + v.push_back(columns[9] + " = " + std::to_string(e.melee_rune)); + v.push_back(columns[10] + " = " + std::to_string(e.magic_rune)); + v.push_back(columns[11] + " = " + std::to_string(e.persistent)); + v.push_back(columns[12] + " = " + std::to_string(e.dot_rune)); + v.push_back(columns[13] + " = " + std::to_string(e.caston_x)); + v.push_back(columns[14] + " = " + std::to_string(e.caston_y)); + v.push_back(columns[15] + " = " + std::to_string(e.caston_z)); + v.push_back(columns[16] + " = " + std::to_string(e.ExtraDIChance)); + v.push_back(columns[17] + " = " + std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -290,6 +296,7 @@ public: v.push_back(std::to_string(e.caster_level)); v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.initialduration)); v.push_back(std::to_string(e.counters)); v.push_back(std::to_string(e.numhits)); v.push_back(std::to_string(e.melee_rune)); @@ -336,6 +343,7 @@ public: v.push_back(std::to_string(e.caster_level)); v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.initialduration)); v.push_back(std::to_string(e.counters)); v.push_back(std::to_string(e.numhits)); v.push_back(std::to_string(e.melee_rune)); @@ -380,23 +388,24 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { CharacterBuffs e{}; - e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; - e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.caster_name = row[4] ? row[4] : ""; - e.ticsremaining = row[5] ? static_cast(atoi(row[5])) : 0; - e.counters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.numhits = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.melee_rune = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.magic_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.persistent = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.dot_rune = row[11] ? static_cast(atoi(row[11])) : 0; - e.caston_x = row[12] ? static_cast(atoi(row[12])) : 0; - e.caston_y = row[13] ? static_cast(atoi(row[13])) : 0; - e.caston_z = row[14] ? static_cast(atoi(row[14])) : 0; - e.ExtraDIChance = row[15] ? static_cast(atoi(row[15])) : 0; - e.instrument_mod = row[16] ? static_cast(atoi(row[16])) : 10; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.caster_name = row[4] ? row[4] : ""; + e.ticsremaining = row[5] ? static_cast(atoi(row[5])) : 0; + e.initialduration = row[6] ? static_cast(atoi(row[6])) : 0; + e.counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.numhits = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.melee_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.magic_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.persistent = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.dot_rune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.caston_x = row[13] ? static_cast(atoi(row[13])) : 0; + e.caston_y = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_z = row[15] ? static_cast(atoi(row[15])) : 0; + e.ExtraDIChance = row[16] ? static_cast(atoi(row[16])) : 0; + e.instrument_mod = row[17] ? static_cast(atoi(row[17])) : 10; all_entries.push_back(e); } @@ -421,23 +430,24 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { CharacterBuffs e{}; - e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; - e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; - e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; - e.caster_name = row[4] ? row[4] : ""; - e.ticsremaining = row[5] ? static_cast(atoi(row[5])) : 0; - e.counters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.numhits = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.melee_rune = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.magic_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.persistent = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.dot_rune = row[11] ? static_cast(atoi(row[11])) : 0; - e.caston_x = row[12] ? static_cast(atoi(row[12])) : 0; - e.caston_y = row[13] ? static_cast(atoi(row[13])) : 0; - e.caston_z = row[14] ? static_cast(atoi(row[14])) : 0; - e.ExtraDIChance = row[15] ? static_cast(atoi(row[15])) : 0; - e.instrument_mod = row[16] ? static_cast(atoi(row[16])) : 10; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.caster_level = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.caster_name = row[4] ? row[4] : ""; + e.ticsremaining = row[5] ? static_cast(atoi(row[5])) : 0; + e.initialduration = row[6] ? static_cast(atoi(row[6])) : 0; + e.counters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.numhits = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.melee_rune = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.magic_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.persistent = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.dot_rune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.caston_x = row[13] ? static_cast(atoi(row[13])) : 0; + e.caston_y = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_z = row[15] ? static_cast(atoi(row[15])) : 0; + e.ExtraDIChance = row[16] ? static_cast(atoi(row[16])) : 0; + e.instrument_mod = row[17] ? static_cast(atoi(row[17])) : 10; all_entries.push_back(e); } @@ -518,6 +528,7 @@ public: v.push_back(std::to_string(e.caster_level)); v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.initialduration)); v.push_back(std::to_string(e.counters)); v.push_back(std::to_string(e.numhits)); v.push_back(std::to_string(e.melee_rune)); @@ -557,6 +568,7 @@ public: v.push_back(std::to_string(e.caster_level)); v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.initialduration)); v.push_back(std::to_string(e.counters)); v.push_back(std::to_string(e.numhits)); v.push_back(std::to_string(e.melee_rune)); diff --git a/common/repositories/base/base_character_data_repository.h b/common/repositories/base/base_character_data_repository.h index ec2b4c8bb..a85917a07 100644 --- a/common/repositories/base/base_character_data_repository.h +++ b/common/repositories/base/base_character_data_repository.h @@ -132,8 +132,8 @@ public: uint8_t lfg; std::string mailkey; uint8_t xtargets; - uint8_t ingame; uint32_t first_login; + uint8_t ingame; uint32_t e_aa_effects; uint32_t e_percent_to_aa; uint32_t e_expended_aa_spent; @@ -248,8 +248,8 @@ public: "lfg", "mailkey", "xtargets", - "ingame", "first_login", + "ingame", "e_aa_effects", "e_percent_to_aa", "e_expended_aa_spent", @@ -360,8 +360,8 @@ public: "lfg", "mailkey", "xtargets", - "ingame", "first_login", + "ingame", "e_aa_effects", "e_percent_to_aa", "e_expended_aa_spent", @@ -506,8 +506,8 @@ public: e.lfg = 0; e.mailkey = ""; e.xtargets = 5; - e.ingame = 0; e.first_login = 0; + e.ingame = 0; e.e_aa_effects = 0; e.e_percent_to_aa = 0; e.e_expended_aa_spent = 0; @@ -648,8 +648,8 @@ public: e.lfg = row[93] ? static_cast(strtoul(row[93], nullptr, 10)) : 0; e.mailkey = row[94] ? row[94] : ""; e.xtargets = row[95] ? static_cast(strtoul(row[95], nullptr, 10)) : 5; - e.ingame = row[96] ? static_cast(strtoul(row[96], nullptr, 10)) : 0; - e.first_login = row[97] ? static_cast(strtoul(row[97], nullptr, 10)) : 0; + e.first_login = row[96] ? static_cast(strtoul(row[96], nullptr, 10)) : 0; + e.ingame = row[97] ? static_cast(strtoul(row[97], nullptr, 10)) : 0; e.e_aa_effects = row[98] ? static_cast(strtoul(row[98], nullptr, 10)) : 0; e.e_percent_to_aa = row[99] ? static_cast(strtoul(row[99], nullptr, 10)) : 0; e.e_expended_aa_spent = row[100] ? static_cast(strtoul(row[100], nullptr, 10)) : 0; @@ -786,8 +786,8 @@ public: v.push_back(columns[93] + " = " + std::to_string(e.lfg)); v.push_back(columns[94] + " = '" + Strings::Escape(e.mailkey) + "'"); v.push_back(columns[95] + " = " + std::to_string(e.xtargets)); - v.push_back(columns[96] + " = " + std::to_string(e.ingame)); - v.push_back(columns[97] + " = " + std::to_string(e.first_login)); + v.push_back(columns[96] + " = " + std::to_string(e.first_login)); + v.push_back(columns[97] + " = " + std::to_string(e.ingame)); v.push_back(columns[98] + " = " + std::to_string(e.e_aa_effects)); v.push_back(columns[99] + " = " + std::to_string(e.e_percent_to_aa)); v.push_back(columns[100] + " = " + std::to_string(e.e_expended_aa_spent)); @@ -913,8 +913,8 @@ public: v.push_back(std::to_string(e.lfg)); v.push_back("'" + Strings::Escape(e.mailkey) + "'"); v.push_back(std::to_string(e.xtargets)); - v.push_back(std::to_string(e.ingame)); v.push_back(std::to_string(e.first_login)); + v.push_back(std::to_string(e.ingame)); v.push_back(std::to_string(e.e_aa_effects)); v.push_back(std::to_string(e.e_percent_to_aa)); v.push_back(std::to_string(e.e_expended_aa_spent)); @@ -1048,8 +1048,8 @@ public: v.push_back(std::to_string(e.lfg)); v.push_back("'" + Strings::Escape(e.mailkey) + "'"); v.push_back(std::to_string(e.xtargets)); - v.push_back(std::to_string(e.ingame)); v.push_back(std::to_string(e.first_login)); + v.push_back(std::to_string(e.ingame)); v.push_back(std::to_string(e.e_aa_effects)); v.push_back(std::to_string(e.e_percent_to_aa)); v.push_back(std::to_string(e.e_expended_aa_spent)); @@ -1187,8 +1187,8 @@ public: e.lfg = row[93] ? static_cast(strtoul(row[93], nullptr, 10)) : 0; e.mailkey = row[94] ? row[94] : ""; e.xtargets = row[95] ? static_cast(strtoul(row[95], nullptr, 10)) : 5; - e.ingame = row[96] ? static_cast(strtoul(row[96], nullptr, 10)) : 0; - e.first_login = row[97] ? static_cast(strtoul(row[97], nullptr, 10)) : 0; + e.first_login = row[96] ? static_cast(strtoul(row[96], nullptr, 10)) : 0; + e.ingame = row[97] ? static_cast(strtoul(row[97], nullptr, 10)) : 0; e.e_aa_effects = row[98] ? static_cast(strtoul(row[98], nullptr, 10)) : 0; e.e_percent_to_aa = row[99] ? static_cast(strtoul(row[99], nullptr, 10)) : 0; e.e_expended_aa_spent = row[100] ? static_cast(strtoul(row[100], nullptr, 10)) : 0; @@ -1317,8 +1317,8 @@ public: e.lfg = row[93] ? static_cast(strtoul(row[93], nullptr, 10)) : 0; e.mailkey = row[94] ? row[94] : ""; e.xtargets = row[95] ? static_cast(strtoul(row[95], nullptr, 10)) : 5; - e.ingame = row[96] ? static_cast(strtoul(row[96], nullptr, 10)) : 0; - e.first_login = row[97] ? static_cast(strtoul(row[97], nullptr, 10)) : 0; + e.first_login = row[96] ? static_cast(strtoul(row[96], nullptr, 10)) : 0; + e.ingame = row[97] ? static_cast(strtoul(row[97], nullptr, 10)) : 0; e.e_aa_effects = row[98] ? static_cast(strtoul(row[98], nullptr, 10)) : 0; e.e_percent_to_aa = row[99] ? static_cast(strtoul(row[99], nullptr, 10)) : 0; e.e_expended_aa_spent = row[100] ? static_cast(strtoul(row[100], nullptr, 10)) : 0; @@ -1497,8 +1497,8 @@ public: v.push_back(std::to_string(e.lfg)); v.push_back("'" + Strings::Escape(e.mailkey) + "'"); v.push_back(std::to_string(e.xtargets)); - v.push_back(std::to_string(e.ingame)); v.push_back(std::to_string(e.first_login)); + v.push_back(std::to_string(e.ingame)); v.push_back(std::to_string(e.e_aa_effects)); v.push_back(std::to_string(e.e_percent_to_aa)); v.push_back(std::to_string(e.e_expended_aa_spent)); @@ -1625,8 +1625,8 @@ public: v.push_back(std::to_string(e.lfg)); v.push_back("'" + Strings::Escape(e.mailkey) + "'"); v.push_back(std::to_string(e.xtargets)); - v.push_back(std::to_string(e.ingame)); v.push_back(std::to_string(e.first_login)); + v.push_back(std::to_string(e.ingame)); v.push_back(std::to_string(e.e_aa_effects)); v.push_back(std::to_string(e.e_percent_to_aa)); v.push_back(std::to_string(e.e_expended_aa_spent)); diff --git a/common/repositories/base/base_character_exp_modifiers_repository.h b/common/repositories/base/base_character_exp_modifiers_repository.h index a627b432a..533e90d03 100644 --- a/common/repositories/base/base_character_exp_modifiers_repository.h +++ b/common/repositories/base/base_character_exp_modifiers_repository.h @@ -110,8 +110,8 @@ public: e.character_id = 0; e.zone_id = 0; e.instance_version = -1; - e.aa_modifier = 0; - e.exp_modifier = 0; + e.aa_modifier = 1; + e.exp_modifier = 1; return e; } @@ -151,8 +151,8 @@ public: e.character_id = row[0] ? static_cast(atoi(row[0])) : 0; e.zone_id = row[1] ? static_cast(atoi(row[1])) : 0; e.instance_version = row[2] ? static_cast(atoi(row[2])) : -1; - e.aa_modifier = row[3] ? strtof(row[3], nullptr) : 0; - e.exp_modifier = row[4] ? strtof(row[4], nullptr) : 0; + e.aa_modifier = row[3] ? strtof(row[3], nullptr) : 1; + e.exp_modifier = row[4] ? strtof(row[4], nullptr) : 1; return e; } @@ -287,8 +287,8 @@ public: e.character_id = row[0] ? static_cast(atoi(row[0])) : 0; e.zone_id = row[1] ? static_cast(atoi(row[1])) : 0; e.instance_version = row[2] ? static_cast(atoi(row[2])) : -1; - e.aa_modifier = row[3] ? strtof(row[3], nullptr) : 0; - e.exp_modifier = row[4] ? strtof(row[4], nullptr) : 0; + e.aa_modifier = row[3] ? strtof(row[3], nullptr) : 1; + e.exp_modifier = row[4] ? strtof(row[4], nullptr) : 1; all_entries.push_back(e); } @@ -316,8 +316,8 @@ public: e.character_id = row[0] ? static_cast(atoi(row[0])) : 0; e.zone_id = row[1] ? static_cast(atoi(row[1])) : 0; e.instance_version = row[2] ? static_cast(atoi(row[2])) : -1; - e.aa_modifier = row[3] ? strtof(row[3], nullptr) : 0; - e.exp_modifier = row[4] ? strtof(row[4], nullptr) : 0; + e.aa_modifier = row[3] ? strtof(row[3], nullptr) : 1; + e.exp_modifier = row[4] ? strtof(row[4], nullptr) : 1; all_entries.push_back(e); } diff --git a/common/repositories/base/base_character_memmed_spells_repository.h b/common/repositories/base/base_character_memmed_spells_repository.h index 22d6caf8e..64ae4dcb3 100644 --- a/common/repositories/base/base_character_memmed_spells_repository.h +++ b/common/repositories/base/base_character_memmed_spells_repository.h @@ -142,7 +142,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; return e; } @@ -270,7 +270,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; all_entries.push_back(e); } @@ -297,7 +297,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; all_entries.push_back(e); } diff --git a/common/repositories/base/base_character_pet_buffs_repository.h b/common/repositories/base/base_character_pet_buffs_repository.h index b977fa7ca..ac82804f1 100644 --- a/common/repositories/base/base_character_pet_buffs_repository.h +++ b/common/repositories/base/base_character_pet_buffs_repository.h @@ -36,37 +36,53 @@ class BaseCharacterPetBuffsRepository { public: struct CharacterPetBuffs { - int32_t char_id; + uint32_t character_id; int32_t pet; - int32_t slot; + uint8_t slot_id; int32_t spell_id; - int8_t caster_level; - std::string castername; + uint8_t caster_level; + std::string caster_name; int32_t ticsremaining; - int32_t counters; - int32_t numhits; - int32_t rune; - uint8_t instrument_mod; + int32_t initialduration; + uint32_t counters; + uint32_t numhits; + uint32_t melee_rune; + uint32_t magic_rune; + uint8_t persistent; + uint32_t dot_rune; + int32_t caston_x; + int32_t caston_y; + int32_t caston_z; + int32_t ExtraDIChance; + uint32_t instrument_mod; }; static std::string PrimaryKey() { - return std::string("char_id"); + return std::string("character_id"); } static std::vector Columns() { return { - "char_id", + "character_id", "pet", - "slot", + "slot_id", "spell_id", "caster_level", - "castername", + "caster_name", "ticsremaining", + "initialduration", "counters", "numhits", - "rune", + "melee_rune", + "magic_rune", + "persistent", + "dot_rune", + "caston_x", + "caston_y", + "caston_z", + "ExtraDIChance", "instrument_mod", }; } @@ -74,16 +90,24 @@ public: static std::vector SelectColumns() { return { - "char_id", + "character_id", "pet", - "slot", + "slot_id", "spell_id", "caster_level", - "castername", + "caster_name", "ticsremaining", + "initialduration", "counters", "numhits", - "rune", + "melee_rune", + "magic_rune", + "persistent", + "dot_rune", + "caston_x", + "caston_y", + "caston_z", + "ExtraDIChance", "instrument_mod", }; } @@ -125,17 +149,25 @@ public: { CharacterPetBuffs e{}; - e.char_id = 0; - e.pet = 0; - e.slot = 0; - e.spell_id = 0; - e.caster_level = 0; - e.castername = ""; - e.ticsremaining = 0; - e.counters = 0; - e.numhits = 0; - e.rune = 0; - e.instrument_mod = 10; + e.character_id = 0; + e.pet = 0; + e.slot_id = 0; + e.spell_id = 0; + e.caster_level = 0; + e.caster_name = ""; + e.ticsremaining = 0; + e.initialduration = 0; + e.counters = 0; + e.numhits = 0; + e.melee_rune = 0; + e.magic_rune = 0; + e.persistent = 0; + e.dot_rune = 0; + e.caston_x = 0; + e.caston_y = 0; + e.caston_z = 0; + e.ExtraDIChance = 0; + e.instrument_mod = 10; return e; } @@ -146,7 +178,7 @@ public: ) { for (auto &character_pet_buffs : character_pet_buffss) { - if (character_pet_buffs.char_id == character_pet_buffs_id) { + if (character_pet_buffs.character_id == character_pet_buffs_id) { return character_pet_buffs; } } @@ -172,17 +204,25 @@ public: if (results.RowCount() == 1) { CharacterPetBuffs e{}; - e.char_id = row[0] ? static_cast(atoi(row[0])) : 0; - e.pet = row[1] ? static_cast(atoi(row[1])) : 0; - e.slot = row[2] ? static_cast(atoi(row[2])) : 0; - e.spell_id = row[3] ? static_cast(atoi(row[3])) : 0; - e.caster_level = row[4] ? static_cast(atoi(row[4])) : 0; - e.castername = row[5] ? row[5] : ""; - e.ticsremaining = row[6] ? static_cast(atoi(row[6])) : 0; - e.counters = row[7] ? static_cast(atoi(row[7])) : 0; - e.numhits = row[8] ? static_cast(atoi(row[8])) : 0; - e.rune = row[9] ? static_cast(atoi(row[9])) : 0; - e.instrument_mod = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 10; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.pet = row[1] ? static_cast(atoi(row[1])) : 0; + e.slot_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[3] ? static_cast(atoi(row[3])) : 0; + e.caster_level = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.caster_name = row[5] ? row[5] : ""; + e.ticsremaining = row[6] ? static_cast(atoi(row[6])) : 0; + e.initialduration = row[7] ? static_cast(atoi(row[7])) : 0; + e.counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.numhits = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.melee_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.magic_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.persistent = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.dot_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.caston_x = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_y = row[15] ? static_cast(atoi(row[15])) : 0; + e.caston_z = row[16] ? static_cast(atoi(row[16])) : 0; + e.ExtraDIChance = row[17] ? static_cast(atoi(row[17])) : 0; + e.instrument_mod = row[18] ? static_cast(strtoul(row[18], nullptr, 10)) : 10; return e; } @@ -216,17 +256,25 @@ public: auto columns = Columns(); - v.push_back(columns[0] + " = " + std::to_string(e.char_id)); + v.push_back(columns[0] + " = " + std::to_string(e.character_id)); v.push_back(columns[1] + " = " + std::to_string(e.pet)); - v.push_back(columns[2] + " = " + std::to_string(e.slot)); + v.push_back(columns[2] + " = " + std::to_string(e.slot_id)); v.push_back(columns[3] + " = " + std::to_string(e.spell_id)); v.push_back(columns[4] + " = " + std::to_string(e.caster_level)); - v.push_back(columns[5] + " = '" + Strings::Escape(e.castername) + "'"); + v.push_back(columns[5] + " = '" + Strings::Escape(e.caster_name) + "'"); v.push_back(columns[6] + " = " + std::to_string(e.ticsremaining)); - v.push_back(columns[7] + " = " + std::to_string(e.counters)); - v.push_back(columns[8] + " = " + std::to_string(e.numhits)); - v.push_back(columns[9] + " = " + std::to_string(e.rune)); - v.push_back(columns[10] + " = " + std::to_string(e.instrument_mod)); + v.push_back(columns[7] + " = " + std::to_string(e.initialduration)); + v.push_back(columns[8] + " = " + std::to_string(e.counters)); + v.push_back(columns[9] + " = " + std::to_string(e.numhits)); + v.push_back(columns[10] + " = " + std::to_string(e.melee_rune)); + v.push_back(columns[11] + " = " + std::to_string(e.magic_rune)); + v.push_back(columns[12] + " = " + std::to_string(e.persistent)); + v.push_back(columns[13] + " = " + std::to_string(e.dot_rune)); + v.push_back(columns[14] + " = " + std::to_string(e.caston_x)); + v.push_back(columns[15] + " = " + std::to_string(e.caston_y)); + v.push_back(columns[16] + " = " + std::to_string(e.caston_z)); + v.push_back(columns[17] + " = " + std::to_string(e.ExtraDIChance)); + v.push_back(columns[18] + " = " + std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -234,7 +282,7 @@ public: TableName(), Strings::Implode(", ", v), PrimaryKey(), - e.char_id + e.character_id ) ); @@ -248,16 +296,24 @@ public: { std::vector v; - v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.character_id)); v.push_back(std::to_string(e.pet)); - v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.slot_id)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); - v.push_back("'" + Strings::Escape(e.castername) + "'"); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.initialduration)); v.push_back(std::to_string(e.counters)); v.push_back(std::to_string(e.numhits)); - v.push_back(std::to_string(e.rune)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.ExtraDIChance)); v.push_back(std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( @@ -269,7 +325,7 @@ public: ); if (results.Success()) { - e.char_id = results.LastInsertedID(); + e.character_id = results.LastInsertedID(); return e; } @@ -288,16 +344,24 @@ public: for (auto &e: entries) { std::vector v; - v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.character_id)); v.push_back(std::to_string(e.pet)); - v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.slot_id)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); - v.push_back("'" + Strings::Escape(e.castername) + "'"); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.initialduration)); v.push_back(std::to_string(e.counters)); v.push_back(std::to_string(e.numhits)); - v.push_back(std::to_string(e.rune)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.ExtraDIChance)); v.push_back(std::to_string(e.instrument_mod)); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); @@ -332,17 +396,25 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { CharacterPetBuffs e{}; - e.char_id = row[0] ? static_cast(atoi(row[0])) : 0; - e.pet = row[1] ? static_cast(atoi(row[1])) : 0; - e.slot = row[2] ? static_cast(atoi(row[2])) : 0; - e.spell_id = row[3] ? static_cast(atoi(row[3])) : 0; - e.caster_level = row[4] ? static_cast(atoi(row[4])) : 0; - e.castername = row[5] ? row[5] : ""; - e.ticsremaining = row[6] ? static_cast(atoi(row[6])) : 0; - e.counters = row[7] ? static_cast(atoi(row[7])) : 0; - e.numhits = row[8] ? static_cast(atoi(row[8])) : 0; - e.rune = row[9] ? static_cast(atoi(row[9])) : 0; - e.instrument_mod = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 10; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.pet = row[1] ? static_cast(atoi(row[1])) : 0; + e.slot_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[3] ? static_cast(atoi(row[3])) : 0; + e.caster_level = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.caster_name = row[5] ? row[5] : ""; + e.ticsremaining = row[6] ? static_cast(atoi(row[6])) : 0; + e.initialduration = row[7] ? static_cast(atoi(row[7])) : 0; + e.counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.numhits = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.melee_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.magic_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.persistent = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.dot_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.caston_x = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_y = row[15] ? static_cast(atoi(row[15])) : 0; + e.caston_z = row[16] ? static_cast(atoi(row[16])) : 0; + e.ExtraDIChance = row[17] ? static_cast(atoi(row[17])) : 0; + e.instrument_mod = row[18] ? static_cast(strtoul(row[18], nullptr, 10)) : 10; all_entries.push_back(e); } @@ -367,17 +439,25 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { CharacterPetBuffs e{}; - e.char_id = row[0] ? static_cast(atoi(row[0])) : 0; - e.pet = row[1] ? static_cast(atoi(row[1])) : 0; - e.slot = row[2] ? static_cast(atoi(row[2])) : 0; - e.spell_id = row[3] ? static_cast(atoi(row[3])) : 0; - e.caster_level = row[4] ? static_cast(atoi(row[4])) : 0; - e.castername = row[5] ? row[5] : ""; - e.ticsremaining = row[6] ? static_cast(atoi(row[6])) : 0; - e.counters = row[7] ? static_cast(atoi(row[7])) : 0; - e.numhits = row[8] ? static_cast(atoi(row[8])) : 0; - e.rune = row[9] ? static_cast(atoi(row[9])) : 0; - e.instrument_mod = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 10; + e.character_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.pet = row[1] ? static_cast(atoi(row[1])) : 0; + e.slot_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[3] ? static_cast(atoi(row[3])) : 0; + e.caster_level = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.caster_name = row[5] ? row[5] : ""; + e.ticsremaining = row[6] ? static_cast(atoi(row[6])) : 0; + e.initialduration = row[7] ? static_cast(atoi(row[7])) : 0; + e.counters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.numhits = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.melee_rune = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.magic_rune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.persistent = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.dot_rune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.caston_x = row[14] ? static_cast(atoi(row[14])) : 0; + e.caston_y = row[15] ? static_cast(atoi(row[15])) : 0; + e.caston_z = row[16] ? static_cast(atoi(row[16])) : 0; + e.ExtraDIChance = row[17] ? static_cast(atoi(row[17])) : 0; + e.instrument_mod = row[18] ? static_cast(strtoul(row[18], nullptr, 10)) : 10; all_entries.push_back(e); } @@ -452,16 +532,24 @@ public: { std::vector v; - v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.character_id)); v.push_back(std::to_string(e.pet)); - v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.slot_id)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); - v.push_back("'" + Strings::Escape(e.castername) + "'"); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.initialduration)); v.push_back(std::to_string(e.counters)); v.push_back(std::to_string(e.numhits)); - v.push_back(std::to_string(e.rune)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.ExtraDIChance)); v.push_back(std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( @@ -485,16 +573,24 @@ public: for (auto &e: entries) { std::vector v; - v.push_back(std::to_string(e.char_id)); + v.push_back(std::to_string(e.character_id)); v.push_back(std::to_string(e.pet)); - v.push_back(std::to_string(e.slot)); + v.push_back(std::to_string(e.slot_id)); v.push_back(std::to_string(e.spell_id)); v.push_back(std::to_string(e.caster_level)); - v.push_back("'" + Strings::Escape(e.castername) + "'"); + v.push_back("'" + Strings::Escape(e.caster_name) + "'"); v.push_back(std::to_string(e.ticsremaining)); + v.push_back(std::to_string(e.initialduration)); v.push_back(std::to_string(e.counters)); v.push_back(std::to_string(e.numhits)); - v.push_back(std::to_string(e.rune)); + v.push_back(std::to_string(e.melee_rune)); + v.push_back(std::to_string(e.magic_rune)); + v.push_back(std::to_string(e.persistent)); + v.push_back(std::to_string(e.dot_rune)); + v.push_back(std::to_string(e.caston_x)); + v.push_back(std::to_string(e.caston_y)); + v.push_back(std::to_string(e.caston_z)); + v.push_back(std::to_string(e.ExtraDIChance)); v.push_back(std::to_string(e.instrument_mod)); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); diff --git a/common/repositories/base/base_character_spells_repository.h b/common/repositories/base/base_character_spells_repository.h index f920e8d35..83df6ead1 100644 --- a/common/repositories/base/base_character_spells_repository.h +++ b/common/repositories/base/base_character_spells_repository.h @@ -142,7 +142,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; return e; } @@ -269,7 +269,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; all_entries.push_back(e); } @@ -296,7 +296,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.slot_id = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; all_entries.push_back(e); } diff --git a/common/repositories/base/base_damageshieldtypes_repository.h b/common/repositories/base/base_damageshieldtypes_repository.h index b3740efb1..f8c3fb4ed 100644 --- a/common/repositories/base/base_damageshieldtypes_repository.h +++ b/common/repositories/base/base_damageshieldtypes_repository.h @@ -36,8 +36,8 @@ class BaseDamageshieldtypesRepository { public: struct Damageshieldtypes { - int32_t spellid; - uint8_t type; + int32_t spellid; + uint8_t type; }; static std::string PrimaryKey() @@ -136,7 +136,7 @@ public: if (results.RowCount() == 1) { Damageshieldtypes e{}; - e.spellid = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spellid = row[0] ? static_cast(atoi(row[0])) : 0; e.type = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; return e; @@ -260,7 +260,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Damageshieldtypes e{}; - e.spellid = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spellid = row[0] ? static_cast(atoi(row[0])) : 0; e.type = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; all_entries.push_back(e); @@ -286,7 +286,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { Damageshieldtypes e{}; - e.spellid = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spellid = row[0] ? static_cast(atoi(row[0])) : 0; e.type = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; all_entries.push_back(e); diff --git a/common/repositories/base/base_data_buckets_repository.h b/common/repositories/base/base_data_buckets_repository.h index 5026e1aff..262161b1c 100644 --- a/common/repositories/base/base_data_buckets_repository.h +++ b/common/repositories/base/base_data_buckets_repository.h @@ -31,8 +31,9 @@ #include "common/database.h" #include "common/strings.h" +#include "cereal/cereal.hpp" #include -#include + class BaseDataBucketsRepository { public: struct DataBuckets { diff --git a/common/repositories/base/base_doors_repository.h b/common/repositories/base/base_doors_repository.h index 665c96321..dd96cda41 100644 --- a/common/repositories/base/base_doors_repository.h +++ b/common/repositories/base/base_doors_repository.h @@ -67,7 +67,7 @@ public: float buffer; uint32_t client_version_mask; int16_t is_ldon_door; - int16_t close_timer_ms; + uint16_t close_timer_ms; int32_t dz_switch_id; int8_t min_expansion; int8_t max_expansion; @@ -307,7 +307,7 @@ public: e.buffer = row[28] ? strtof(row[28], nullptr) : 0; e.client_version_mask = row[29] ? static_cast(strtoul(row[29], nullptr, 10)) : 4294967295; e.is_ldon_door = row[30] ? static_cast(atoi(row[30])) : 0; - e.close_timer_ms = row[31] ? static_cast(atoi(row[31])) : 5000; + e.close_timer_ms = row[31] ? static_cast(strtoul(row[31], nullptr, 10)) : 5000; e.dz_switch_id = row[32] ? static_cast(atoi(row[32])) : 0; e.min_expansion = row[33] ? static_cast(atoi(row[33])) : -1; e.max_expansion = row[34] ? static_cast(atoi(row[34])) : -1; @@ -570,7 +570,7 @@ public: e.buffer = row[28] ? strtof(row[28], nullptr) : 0; e.client_version_mask = row[29] ? static_cast(strtoul(row[29], nullptr, 10)) : 4294967295; e.is_ldon_door = row[30] ? static_cast(atoi(row[30])) : 0; - e.close_timer_ms = row[31] ? static_cast(atoi(row[31])) : 5000; + e.close_timer_ms = row[31] ? static_cast(strtoul(row[31], nullptr, 10)) : 5000; e.dz_switch_id = row[32] ? static_cast(atoi(row[32])) : 0; e.min_expansion = row[33] ? static_cast(atoi(row[33])) : -1; e.max_expansion = row[34] ? static_cast(atoi(row[34])) : -1; @@ -631,7 +631,7 @@ public: e.buffer = row[28] ? strtof(row[28], nullptr) : 0; e.client_version_mask = row[29] ? static_cast(strtoul(row[29], nullptr, 10)) : 4294967295; e.is_ldon_door = row[30] ? static_cast(atoi(row[30])) : 0; - e.close_timer_ms = row[31] ? static_cast(atoi(row[31])) : 5000; + e.close_timer_ms = row[31] ? static_cast(strtoul(row[31], nullptr, 10)) : 5000; e.dz_switch_id = row[32] ? static_cast(atoi(row[32])) : 0; e.min_expansion = row[33] ? static_cast(atoi(row[33])) : -1; e.max_expansion = row[34] ? static_cast(atoi(row[34])) : -1; diff --git a/common/repositories/base/base_guild_permissions_repository.h b/common/repositories/base/base_guild_permissions_repository.h index 10e33355b..da89ee626 100644 --- a/common/repositories/base/base_guild_permissions_repository.h +++ b/common/repositories/base/base_guild_permissions_repository.h @@ -33,7 +33,6 @@ #include - class BaseGuildPermissionsRepository { public: struct GuildPermissions { @@ -145,10 +144,10 @@ public: if (results.RowCount() == 1) { GuildPermissions e{}; - e.id = static_cast(atoi(row[0])); - e.perm_id = static_cast(atoi(row[1])); - e.guild_id = static_cast(atoi(row[2])); - e.permission = static_cast(atoi(row[3])); + e.id = row[0] ? static_cast(atoi(row[0])) : 0; + e.perm_id = row[1] ? static_cast(atoi(row[1])) : 0; + e.guild_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.permission = row[3] ? static_cast(atoi(row[3])) : 0; return e; } @@ -276,10 +275,10 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { GuildPermissions e{}; - e.id = static_cast(atoi(row[0])); - e.perm_id = static_cast(atoi(row[1])); - e.guild_id = static_cast(atoi(row[2])); - e.permission = static_cast(atoi(row[3])); + e.id = row[0] ? static_cast(atoi(row[0])) : 0; + e.perm_id = row[1] ? static_cast(atoi(row[1])) : 0; + e.guild_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.permission = row[3] ? static_cast(atoi(row[3])) : 0; all_entries.push_back(e); } @@ -304,10 +303,10 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { GuildPermissions e{}; - e.id = static_cast(atoi(row[0])); - e.perm_id = static_cast(atoi(row[1])); - e.guild_id = static_cast(atoi(row[2])); - e.permission = static_cast(atoi(row[3])); + e.id = row[0] ? static_cast(atoi(row[0])) : 0; + e.perm_id = row[1] ? static_cast(atoi(row[1])) : 0; + e.guild_id = row[2] ? static_cast(atoi(row[2])) : 0; + e.permission = row[3] ? static_cast(atoi(row[3])) : 0; all_entries.push_back(e); } diff --git a/common/repositories/base/base_guild_tributes_repository.h b/common/repositories/base/base_guild_tributes_repository.h index 836c7dd1e..6497d8222 100644 --- a/common/repositories/base/base_guild_tributes_repository.h +++ b/common/repositories/base/base_guild_tributes_repository.h @@ -33,7 +33,6 @@ #include - class BaseGuildTributesRepository { public: struct GuildTributes { @@ -157,13 +156,13 @@ public: if (results.RowCount() == 1) { GuildTributes e{}; - e.guild_id = static_cast(strtoul(row[0], nullptr, 10)); - e.tribute_id_1 = static_cast(strtoul(row[1], nullptr, 10)); - e.tribute_id_1_tier = static_cast(strtoul(row[2], nullptr, 10)); - e.tribute_id_2 = static_cast(strtoul(row[3], nullptr, 10)); - e.tribute_id_2_tier = static_cast(strtoul(row[4], nullptr, 10)); - e.time_remaining = static_cast(strtoul(row[5], nullptr, 10)); - e.enabled = static_cast(strtoul(row[6], nullptr, 10)); + e.guild_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.tribute_id_1 = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.tribute_id_1_tier = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.tribute_id_2 = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.tribute_id_2_tier = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.time_remaining = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.enabled = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; return e; } @@ -301,13 +300,13 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { GuildTributes e{}; - e.guild_id = static_cast(strtoul(row[0], nullptr, 10)); - e.tribute_id_1 = static_cast(strtoul(row[1], nullptr, 10)); - e.tribute_id_1_tier = static_cast(strtoul(row[2], nullptr, 10)); - e.tribute_id_2 = static_cast(strtoul(row[3], nullptr, 10)); - e.tribute_id_2_tier = static_cast(strtoul(row[4], nullptr, 10)); - e.time_remaining = static_cast(strtoul(row[5], nullptr, 10)); - e.enabled = static_cast(strtoul(row[6], nullptr, 10)); + e.guild_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.tribute_id_1 = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.tribute_id_1_tier = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.tribute_id_2 = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.tribute_id_2_tier = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.time_remaining = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.enabled = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; all_entries.push_back(e); } @@ -332,13 +331,13 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { GuildTributes e{}; - e.guild_id = static_cast(strtoul(row[0], nullptr, 10)); - e.tribute_id_1 = static_cast(strtoul(row[1], nullptr, 10)); - e.tribute_id_1_tier = static_cast(strtoul(row[2], nullptr, 10)); - e.tribute_id_2 = static_cast(strtoul(row[3], nullptr, 10)); - e.tribute_id_2_tier = static_cast(strtoul(row[4], nullptr, 10)); - e.time_remaining = static_cast(strtoul(row[5], nullptr, 10)); - e.enabled = static_cast(strtoul(row[6], nullptr, 10)); + e.guild_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.tribute_id_1 = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 0; + e.tribute_id_1_tier = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.tribute_id_2 = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; + e.tribute_id_2_tier = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; + e.time_remaining = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 0; + e.enabled = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; all_entries.push_back(e); } diff --git a/common/repositories/base/base_guilds_repository.h b/common/repositories/base/base_guilds_repository.h index ac5deea59..3225da002 100644 --- a/common/repositories/base/base_guilds_repository.h +++ b/common/repositories/base/base_guilds_repository.h @@ -33,7 +33,6 @@ #include - class BaseGuildsRepository { public: struct Guilds { diff --git a/common/repositories/base/base_ldon_trap_templates_repository.h b/common/repositories/base/base_ldon_trap_templates_repository.h index 7c5a28786..70a0b0cce 100644 --- a/common/repositories/base/base_ldon_trap_templates_repository.h +++ b/common/repositories/base/base_ldon_trap_templates_repository.h @@ -150,7 +150,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.type = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 1; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.skill = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.locked = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; @@ -286,7 +286,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.type = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 1; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.skill = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.locked = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; @@ -315,7 +315,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.type = row[1] ? static_cast(strtoul(row[1], nullptr, 10)) : 1; - e.spell_id = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spell_id = row[2] ? static_cast(atoi(row[2])) : 0; e.skill = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.locked = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; diff --git a/common/repositories/base/base_merc_buffs_repository.h b/common/repositories/base/base_merc_buffs_repository.h index efd18859a..e24cebeb1 100644 --- a/common/repositories/base/base_merc_buffs_repository.h +++ b/common/repositories/base/base_merc_buffs_repository.h @@ -38,10 +38,11 @@ public: struct MercBuffs { uint32_t MercBuffId; uint32_t MercId; - int32_t SpellId; + uint32_t SpellId; uint32_t CasterLevel; uint32_t DurationFormula; int32_t TicsRemaining; + int32_t InitialDuration; uint32_t PoisonCounters; uint32_t DiseaseCounters; uint32_t CurseCounters; @@ -49,12 +50,13 @@ public: uint32_t HitCount; uint32_t MeleeRune; uint32_t MagicRune; - int32_t dot_rune; + uint32_t dot_rune; int32_t caston_x; int8_t Persistent; int32_t caston_y; int32_t caston_z; int32_t ExtraDIChance; + int32_t instrument_mod; }; static std::string PrimaryKey() @@ -71,6 +73,7 @@ public: "CasterLevel", "DurationFormula", "TicsRemaining", + "InitialDuration", "PoisonCounters", "DiseaseCounters", "CurseCounters", @@ -84,6 +87,7 @@ public: "caston_y", "caston_z", "ExtraDIChance", + "instrument_mod", }; } @@ -96,6 +100,7 @@ public: "CasterLevel", "DurationFormula", "TicsRemaining", + "InitialDuration", "PoisonCounters", "DiseaseCounters", "CurseCounters", @@ -109,6 +114,7 @@ public: "caston_y", "caston_z", "ExtraDIChance", + "instrument_mod", }; } @@ -155,6 +161,7 @@ public: e.CasterLevel = 0; e.DurationFormula = 0; e.TicsRemaining = 0; + e.InitialDuration = 0; e.PoisonCounters = 0; e.DiseaseCounters = 0; e.CurseCounters = 0; @@ -168,6 +175,7 @@ public: e.caston_y = 0; e.caston_z = 0; e.ExtraDIChance = 0; + e.instrument_mod = 10; return e; } @@ -210,19 +218,21 @@ public: e.CasterLevel = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.DurationFormula = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.TicsRemaining = row[5] ? static_cast(atoi(row[5])) : 0; - e.PoisonCounters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.DiseaseCounters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.CurseCounters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.CorruptionCounters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.HitCount = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.MeleeRune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; - e.MagicRune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; - e.dot_rune = row[13] ? static_cast(atoi(row[13])) : 0; - e.caston_x = row[14] ? static_cast(atoi(row[14])) : 0; - e.Persistent = row[15] ? static_cast(atoi(row[15])) : 0; - e.caston_y = row[16] ? static_cast(atoi(row[16])) : 0; - e.caston_z = row[17] ? static_cast(atoi(row[17])) : 0; - e.ExtraDIChance = row[18] ? static_cast(atoi(row[18])) : 0; + e.InitialDuration = row[6] ? static_cast(atoi(row[6])) : 0; + e.PoisonCounters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.DiseaseCounters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.CurseCounters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.CorruptionCounters = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.HitCount = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.MeleeRune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.MagicRune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.dot_rune = row[14] ? static_cast(strtoul(row[14], nullptr, 10)) : 0; + e.caston_x = row[15] ? static_cast(atoi(row[15])) : 0; + e.Persistent = row[16] ? static_cast(atoi(row[16])) : 0; + e.caston_y = row[17] ? static_cast(atoi(row[17])) : 0; + e.caston_z = row[18] ? static_cast(atoi(row[18])) : 0; + e.ExtraDIChance = row[19] ? static_cast(atoi(row[19])) : 0; + e.instrument_mod = row[20] ? static_cast(atoi(row[20])) : 10; return e; } @@ -261,19 +271,21 @@ public: v.push_back(columns[3] + " = " + std::to_string(e.CasterLevel)); v.push_back(columns[4] + " = " + std::to_string(e.DurationFormula)); v.push_back(columns[5] + " = " + std::to_string(e.TicsRemaining)); - v.push_back(columns[6] + " = " + std::to_string(e.PoisonCounters)); - v.push_back(columns[7] + " = " + std::to_string(e.DiseaseCounters)); - v.push_back(columns[8] + " = " + std::to_string(e.CurseCounters)); - v.push_back(columns[9] + " = " + std::to_string(e.CorruptionCounters)); - v.push_back(columns[10] + " = " + std::to_string(e.HitCount)); - v.push_back(columns[11] + " = " + std::to_string(e.MeleeRune)); - v.push_back(columns[12] + " = " + std::to_string(e.MagicRune)); - v.push_back(columns[13] + " = " + std::to_string(e.dot_rune)); - v.push_back(columns[14] + " = " + std::to_string(e.caston_x)); - v.push_back(columns[15] + " = " + std::to_string(e.Persistent)); - v.push_back(columns[16] + " = " + std::to_string(e.caston_y)); - v.push_back(columns[17] + " = " + std::to_string(e.caston_z)); - v.push_back(columns[18] + " = " + std::to_string(e.ExtraDIChance)); + v.push_back(columns[6] + " = " + std::to_string(e.InitialDuration)); + v.push_back(columns[7] + " = " + std::to_string(e.PoisonCounters)); + v.push_back(columns[8] + " = " + std::to_string(e.DiseaseCounters)); + v.push_back(columns[9] + " = " + std::to_string(e.CurseCounters)); + v.push_back(columns[10] + " = " + std::to_string(e.CorruptionCounters)); + v.push_back(columns[11] + " = " + std::to_string(e.HitCount)); + v.push_back(columns[12] + " = " + std::to_string(e.MeleeRune)); + v.push_back(columns[13] + " = " + std::to_string(e.MagicRune)); + v.push_back(columns[14] + " = " + std::to_string(e.dot_rune)); + v.push_back(columns[15] + " = " + std::to_string(e.caston_x)); + v.push_back(columns[16] + " = " + std::to_string(e.Persistent)); + v.push_back(columns[17] + " = " + std::to_string(e.caston_y)); + v.push_back(columns[18] + " = " + std::to_string(e.caston_z)); + v.push_back(columns[19] + " = " + std::to_string(e.ExtraDIChance)); + v.push_back(columns[20] + " = " + std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -301,6 +313,7 @@ public: v.push_back(std::to_string(e.CasterLevel)); v.push_back(std::to_string(e.DurationFormula)); v.push_back(std::to_string(e.TicsRemaining)); + v.push_back(std::to_string(e.InitialDuration)); v.push_back(std::to_string(e.PoisonCounters)); v.push_back(std::to_string(e.DiseaseCounters)); v.push_back(std::to_string(e.CurseCounters)); @@ -314,6 +327,7 @@ public: v.push_back(std::to_string(e.caston_y)); v.push_back(std::to_string(e.caston_z)); v.push_back(std::to_string(e.ExtraDIChance)); + v.push_back(std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -349,6 +363,7 @@ public: v.push_back(std::to_string(e.CasterLevel)); v.push_back(std::to_string(e.DurationFormula)); v.push_back(std::to_string(e.TicsRemaining)); + v.push_back(std::to_string(e.InitialDuration)); v.push_back(std::to_string(e.PoisonCounters)); v.push_back(std::to_string(e.DiseaseCounters)); v.push_back(std::to_string(e.CurseCounters)); @@ -362,6 +377,7 @@ public: v.push_back(std::to_string(e.caston_y)); v.push_back(std::to_string(e.caston_z)); v.push_back(std::to_string(e.ExtraDIChance)); + v.push_back(std::to_string(e.instrument_mod)); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } @@ -401,19 +417,21 @@ public: e.CasterLevel = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.DurationFormula = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.TicsRemaining = row[5] ? static_cast(atoi(row[5])) : 0; - e.PoisonCounters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.DiseaseCounters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.CurseCounters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.CorruptionCounters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.HitCount = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.MeleeRune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; - e.MagicRune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; - e.dot_rune = row[13] ? static_cast(atoi(row[13])) : 0; - e.caston_x = row[14] ? static_cast(atoi(row[14])) : 0; - e.Persistent = row[15] ? static_cast(atoi(row[15])) : 0; - e.caston_y = row[16] ? static_cast(atoi(row[16])) : 0; - e.caston_z = row[17] ? static_cast(atoi(row[17])) : 0; - e.ExtraDIChance = row[18] ? static_cast(atoi(row[18])) : 0; + e.InitialDuration = row[6] ? static_cast(atoi(row[6])) : 0; + e.PoisonCounters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.DiseaseCounters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.CurseCounters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.CorruptionCounters = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.HitCount = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.MeleeRune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.MagicRune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.dot_rune = row[14] ? static_cast(strtoul(row[14], nullptr, 10)) : 0; + e.caston_x = row[15] ? static_cast(atoi(row[15])) : 0; + e.Persistent = row[16] ? static_cast(atoi(row[16])) : 0; + e.caston_y = row[17] ? static_cast(atoi(row[17])) : 0; + e.caston_z = row[18] ? static_cast(atoi(row[18])) : 0; + e.ExtraDIChance = row[19] ? static_cast(atoi(row[19])) : 0; + e.instrument_mod = row[20] ? static_cast(atoi(row[20])) : 10; all_entries.push_back(e); } @@ -444,19 +462,21 @@ public: e.CasterLevel = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.DurationFormula = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.TicsRemaining = row[5] ? static_cast(atoi(row[5])) : 0; - e.PoisonCounters = row[6] ? static_cast(strtoul(row[6], nullptr, 10)) : 0; - e.DiseaseCounters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; - e.CurseCounters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; - e.CorruptionCounters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; - e.HitCount = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; - e.MeleeRune = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; - e.MagicRune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; - e.dot_rune = row[13] ? static_cast(atoi(row[13])) : 0; - e.caston_x = row[14] ? static_cast(atoi(row[14])) : 0; - e.Persistent = row[15] ? static_cast(atoi(row[15])) : 0; - e.caston_y = row[16] ? static_cast(atoi(row[16])) : 0; - e.caston_z = row[17] ? static_cast(atoi(row[17])) : 0; - e.ExtraDIChance = row[18] ? static_cast(atoi(row[18])) : 0; + e.InitialDuration = row[6] ? static_cast(atoi(row[6])) : 0; + e.PoisonCounters = row[7] ? static_cast(strtoul(row[7], nullptr, 10)) : 0; + e.DiseaseCounters = row[8] ? static_cast(strtoul(row[8], nullptr, 10)) : 0; + e.CurseCounters = row[9] ? static_cast(strtoul(row[9], nullptr, 10)) : 0; + e.CorruptionCounters = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; + e.HitCount = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; + e.MeleeRune = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.MagicRune = row[13] ? static_cast(strtoul(row[13], nullptr, 10)) : 0; + e.dot_rune = row[14] ? static_cast(strtoul(row[14], nullptr, 10)) : 0; + e.caston_x = row[15] ? static_cast(atoi(row[15])) : 0; + e.Persistent = row[16] ? static_cast(atoi(row[16])) : 0; + e.caston_y = row[17] ? static_cast(atoi(row[17])) : 0; + e.caston_z = row[18] ? static_cast(atoi(row[18])) : 0; + e.ExtraDIChance = row[19] ? static_cast(atoi(row[19])) : 0; + e.instrument_mod = row[20] ? static_cast(atoi(row[20])) : 10; all_entries.push_back(e); } @@ -537,6 +557,7 @@ public: v.push_back(std::to_string(e.CasterLevel)); v.push_back(std::to_string(e.DurationFormula)); v.push_back(std::to_string(e.TicsRemaining)); + v.push_back(std::to_string(e.InitialDuration)); v.push_back(std::to_string(e.PoisonCounters)); v.push_back(std::to_string(e.DiseaseCounters)); v.push_back(std::to_string(e.CurseCounters)); @@ -550,6 +571,7 @@ public: v.push_back(std::to_string(e.caston_y)); v.push_back(std::to_string(e.caston_z)); v.push_back(std::to_string(e.ExtraDIChance)); + v.push_back(std::to_string(e.instrument_mod)); auto results = db.QueryDatabase( fmt::format( @@ -578,6 +600,7 @@ public: v.push_back(std::to_string(e.CasterLevel)); v.push_back(std::to_string(e.DurationFormula)); v.push_back(std::to_string(e.TicsRemaining)); + v.push_back(std::to_string(e.InitialDuration)); v.push_back(std::to_string(e.PoisonCounters)); v.push_back(std::to_string(e.DiseaseCounters)); v.push_back(std::to_string(e.CurseCounters)); @@ -591,6 +614,7 @@ public: v.push_back(std::to_string(e.caston_y)); v.push_back(std::to_string(e.caston_z)); v.push_back(std::to_string(e.ExtraDIChance)); + v.push_back(std::to_string(e.instrument_mod)); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } diff --git a/common/repositories/base/base_npc_spells_entries_repository.h b/common/repositories/base/base_npc_spells_entries_repository.h index d5c1995f8..9f7b3948c 100644 --- a/common/repositories/base/base_npc_spells_entries_repository.h +++ b/common/repositories/base/base_npc_spells_entries_repository.h @@ -194,7 +194,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spellid = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spellid = row[2] ? static_cast(atoi(row[2])) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; @@ -373,7 +373,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spellid = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spellid = row[2] ? static_cast(atoi(row[2])) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; @@ -413,7 +413,7 @@ public: e.id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; e.npc_spells_id = row[1] ? static_cast(atoi(row[1])) : 0; - e.spellid = row[2] ? static_cast(strtoul(row[2], nullptr, 10)) : 0; + e.spellid = row[2] ? static_cast(atoi(row[2])) : 0; e.type = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; e.minlevel = row[4] ? static_cast(strtoul(row[4], nullptr, 10)) : 0; e.maxlevel = row[5] ? static_cast(strtoul(row[5], nullptr, 10)) : 255; diff --git a/common/repositories/base/base_player_event_log_settings_repository.h b/common/repositories/base/base_player_event_log_settings_repository.h index 47d9f5c1e..d133330d5 100644 --- a/common/repositories/base/base_player_event_log_settings_repository.h +++ b/common/repositories/base/base_player_event_log_settings_repository.h @@ -31,8 +31,9 @@ #include "common/database.h" #include "common/strings.h" +#include "cereal/cereal.hpp" #include -#include + class BasePlayerEventLogSettingsRepository { public: struct PlayerEventLogSettings { diff --git a/common/repositories/base/base_player_event_logs_repository.h b/common/repositories/base/base_player_event_logs_repository.h index 23223c159..3446282ef 100644 --- a/common/repositories/base/base_player_event_logs_repository.h +++ b/common/repositories/base/base_player_event_logs_repository.h @@ -31,8 +31,9 @@ #include "common/database.h" #include "common/strings.h" +#include "cereal/cereal.hpp" #include -#include + class BasePlayerEventLogsRepository { public: struct PlayerEventLogs { diff --git a/common/repositories/base/base_player_event_npc_handin_entries_repository.h b/common/repositories/base/base_player_event_npc_handin_entries_repository.h index 9f2b07a32..62dbec4ec 100644 --- a/common/repositories/base/base_player_event_npc_handin_entries_repository.h +++ b/common/repositories/base/base_player_event_npc_handin_entries_repository.h @@ -49,6 +49,7 @@ public: uint32_t augment_4_id; uint32_t augment_5_id; uint32_t augment_6_id; + time_t created_at; }; static std::string PrimaryKey() @@ -72,6 +73,7 @@ public: "augment_4_id", "augment_5_id", "augment_6_id", + "created_at", }; } @@ -91,6 +93,7 @@ public: "augment_4_id", "augment_5_id", "augment_6_id", + "UNIX_TIMESTAMP(created_at)", }; } @@ -144,6 +147,7 @@ public: e.augment_4_id = 0; e.augment_5_id = 0; e.augment_6_id = 0; + e.created_at = 0; return e; } @@ -193,6 +197,7 @@ public: e.augment_4_id = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; e.augment_5_id = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; e.augment_6_id = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.created_at = strtoll(row[13] ? row[13] : "-1", nullptr, 10); return e; } @@ -238,6 +243,7 @@ public: v.push_back(columns[10] + " = " + std::to_string(e.augment_4_id)); v.push_back(columns[11] + " = " + std::to_string(e.augment_5_id)); v.push_back(columns[12] + " = " + std::to_string(e.augment_6_id)); + v.push_back(columns[13] + " = FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -272,6 +278,7 @@ public: v.push_back(std::to_string(e.augment_4_id)); v.push_back(std::to_string(e.augment_5_id)); v.push_back(std::to_string(e.augment_6_id)); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -314,6 +321,7 @@ public: v.push_back(std::to_string(e.augment_4_id)); v.push_back(std::to_string(e.augment_5_id)); v.push_back(std::to_string(e.augment_6_id)); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } @@ -360,6 +368,7 @@ public: e.augment_4_id = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; e.augment_5_id = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; e.augment_6_id = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.created_at = strtoll(row[13] ? row[13] : "-1", nullptr, 10); all_entries.push_back(e); } @@ -397,6 +406,7 @@ public: e.augment_4_id = row[10] ? static_cast(strtoul(row[10], nullptr, 10)) : 0; e.augment_5_id = row[11] ? static_cast(strtoul(row[11], nullptr, 10)) : 0; e.augment_6_id = row[12] ? static_cast(strtoul(row[12], nullptr, 10)) : 0; + e.created_at = strtoll(row[13] ? row[13] : "-1", nullptr, 10); all_entries.push_back(e); } @@ -484,6 +494,7 @@ public: v.push_back(std::to_string(e.augment_4_id)); v.push_back(std::to_string(e.augment_5_id)); v.push_back(std::to_string(e.augment_6_id)); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); auto results = db.QueryDatabase( fmt::format( @@ -519,6 +530,7 @@ public: v.push_back(std::to_string(e.augment_4_id)); v.push_back(std::to_string(e.augment_5_id)); v.push_back(std::to_string(e.augment_6_id)); + v.push_back("FROM_UNIXTIME(" + (e.created_at > 0 ? std::to_string(e.created_at) : "null") + ")"); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); } diff --git a/common/repositories/base/base_spell_buckets_repository.h b/common/repositories/base/base_spell_buckets_repository.h index d8e633447..80a7f3095 100644 --- a/common/repositories/base/base_spell_buckets_repository.h +++ b/common/repositories/base/base_spell_buckets_repository.h @@ -144,7 +144,7 @@ public: if (results.RowCount() == 1) { SpellBuckets e{}; - e.spell_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spell_id = row[0] ? static_cast(atoi(row[0])) : 0; e.bucket_name = row[1] ? row[1] : ""; e.bucket_value = row[2] ? row[2] : ""; e.bucket_comparison = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; @@ -276,7 +276,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { SpellBuckets e{}; - e.spell_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spell_id = row[0] ? static_cast(atoi(row[0])) : 0; e.bucket_name = row[1] ? row[1] : ""; e.bucket_value = row[2] ? row[2] : ""; e.bucket_comparison = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; @@ -304,7 +304,7 @@ public: for (auto row = results.begin(); row != results.end(); ++row) { SpellBuckets e{}; - e.spell_id = row[0] ? static_cast(strtoul(row[0], nullptr, 10)) : 0; + e.spell_id = row[0] ? static_cast(atoi(row[0])) : 0; e.bucket_name = row[1] ? row[1] : ""; e.bucket_value = row[2] ? row[2] : ""; e.bucket_comparison = row[3] ? static_cast(strtoul(row[3], nullptr, 10)) : 0; diff --git a/common/repositories/base/base_zone_repository.h b/common/repositories/base/base_zone_repository.h index 3751e3b5c..3eb1d001b 100644 --- a/common/repositories/base/base_zone_repository.h +++ b/common/repositories/base/base_zone_repository.h @@ -128,7 +128,7 @@ public: int32_t fast_regen_mana; int32_t fast_regen_endurance; int32_t npc_max_aggro_dist; - uint32_t client_update_range; + int32_t client_update_range; int32_t underworld_teleport_index; int32_t lava_damage; int32_t min_lava_damage; @@ -616,7 +616,7 @@ public: e.fast_regen_mana = row[89] ? static_cast(atoi(row[89])) : 180; e.fast_regen_endurance = row[90] ? static_cast(atoi(row[90])) : 180; e.npc_max_aggro_dist = row[91] ? static_cast(atoi(row[91])) : 600; - e.client_update_range = row[92] ? static_cast(strtoul(row[92], nullptr, 10)) : 600; + e.client_update_range = row[92] ? static_cast(atoi(row[92])) : 600; e.underworld_teleport_index = row[93] ? static_cast(atoi(row[93])) : 0; e.lava_damage = row[94] ? static_cast(atoi(row[94])) : 50; e.min_lava_damage = row[95] ? static_cast(atoi(row[95])) : 10; @@ -1127,7 +1127,7 @@ public: e.fast_regen_mana = row[89] ? static_cast(atoi(row[89])) : 180; e.fast_regen_endurance = row[90] ? static_cast(atoi(row[90])) : 180; e.npc_max_aggro_dist = row[91] ? static_cast(atoi(row[91])) : 600; - e.client_update_range = row[92] ? static_cast(strtoul(row[92], nullptr, 10)) : 600; + e.client_update_range = row[92] ? static_cast(atoi(row[92])) : 600; e.underworld_teleport_index = row[93] ? static_cast(atoi(row[93])) : 0; e.lava_damage = row[94] ? static_cast(atoi(row[94])) : 50; e.min_lava_damage = row[95] ? static_cast(atoi(row[95])) : 10; @@ -1250,7 +1250,7 @@ public: e.fast_regen_mana = row[89] ? static_cast(atoi(row[89])) : 180; e.fast_regen_endurance = row[90] ? static_cast(atoi(row[90])) : 180; e.npc_max_aggro_dist = row[91] ? static_cast(atoi(row[91])) : 600; - e.client_update_range = row[92] ? static_cast(strtoul(row[92], nullptr, 10)) : 600; + e.client_update_range = row[92] ? static_cast(atoi(row[92])) : 600; e.underworld_teleport_index = row[93] ? static_cast(atoi(row[93])) : 0; e.lava_damage = row[94] ? static_cast(atoi(row[94])) : 50; e.min_lava_damage = row[95] ? static_cast(atoi(row[95])) : 10; diff --git a/common/repositories/template/base_repository.template b/common/repositories/template/base_repository.template index be28ac208..4e3badb47 100644 --- a/common/repositories/template/base_repository.template +++ b/common/repositories/template/base_repository.template @@ -1,3 +1,20 @@ +/* EQEmu: EQEmulator + + Copyright (C) 2001-2026 EQEmu Development Team + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ /** * DO NOT MODIFY THIS FILE * diff --git a/common/version.h b/common/version.h index 91fbeb52e..5f3745d6b 100644 --- a/common/version.h +++ b/common/version.h @@ -38,6 +38,6 @@ * Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt */ -#define CURRENT_BINARY_DATABASE_VERSION 9329 -#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9056 +#define CURRENT_BINARY_DATABASE_VERSION 9330 +#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9057 #define CUSTOM_BINARY_DATABASE_VERSION 0 diff --git a/utils/scripts/generators/repository-generator.pl b/utils/scripts/generators/repository-generator.pl index 104f30761..537a811ae 100644 --- a/utils/scripts/generators/repository-generator.pl +++ b/utils/scripts/generators/repository-generator.pl @@ -152,18 +152,18 @@ foreach my $table_to_generate (@tables) { ); foreach my $category (@categories) { - if ($table_to_generate ~~ $database_schema->{$category}) { + if ( grep { $_ eq $table_to_generate } @{$database_schema->{$category}}) { $table_found_in_schema = 1; } } - if ($table_to_generate ~~ @table_ignore_list) { + if ( grep { $_ eq $table_to_generate } @table_ignore_list) { print "Table [$table_to_generate] is on ignore list... skipping...\n"; $table_found_in_schema = 0; } my $cereal_enabled = 0; - if ($table_to_generate ~~ @cereal_enabled_tables) { + if ( grep { $_ eq $table_to_generate } @cereal_enabled_tables ) { $cereal_enabled = 1; } @@ -425,7 +425,7 @@ foreach my $table_to_generate (@tables) { my $primary_key = ($table_primary_key{$table_to_generate} ? $table_primary_key{$table_to_generate} : ""); my $database_connection = "database"; - if ($table_to_generate ~~ $database_schema->{"content_tables"}) { + if ( grep { $_ eq $table_to_generate } $database_schema->{"content_tables"} ) { $database_connection = "content_db"; } @@ -442,7 +442,7 @@ foreach my $table_to_generate (@tables) { { ar(\n" . $cereal_columns . "\n\t\t\t);\n\t\t}"; - $additional_includes .= "#include \"cereal/cereal.hpp\""; + $additional_includes .= "#include \"cereal/cereal.hpp\"\n"; } chomp($column_names_quoted); diff --git a/utils/sql/merc_tables_bootstrap.sql b/utils/sql/merc_tables_bootstrap.sql index 463ca3ae0..6b6345ebd 100644 --- a/utils/sql/merc_tables_bootstrap.sql +++ b/utils/sql/merc_tables_bootstrap.sql @@ -77,6 +77,7 @@ CREATE TABLE `merc_buffs` `CasterLevel` int(10) UNSIGNED NOT NULL DEFAULT 0, `DurationFormula` int(10) UNSIGNED NOT NULL DEFAULT 0, `TicsRemaining` int(11) NOT NULL DEFAULT 0, + `InitialDuration` int(11) NOT NULL DEFAULT 0, `PoisonCounters` int(11) UNSIGNED NOT NULL DEFAULT 0, `DiseaseCounters` int(11) UNSIGNED NOT NULL DEFAULT 0, `CurseCounters` int(11) UNSIGNED NOT NULL DEFAULT 0, diff --git a/zone/bot.cpp b/zone/bot.cpp index 40c4801af..280904315 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1568,7 +1568,7 @@ bool Bot::LoadPet() NPC *pet_inst = GetPet()->CastToNPC(); - SpellBuff_Struct pet_buffs[PET_BUFF_COUNT]; + Buffs_Struct pet_buffs[PET_BUFF_COUNT]; memset(pet_buffs, 0, (sizeof(SpellBuff_Struct) * PET_BUFF_COUNT)); database.botdb.LoadPetBuffs(GetBotID(), pet_buffs); @@ -1576,7 +1576,7 @@ bool Bot::LoadPet() memset(pet_items, 0, (sizeof(uint32) * EQ::invslot::EQUIPMENT_COUNT)); database.botdb.LoadPetItems(GetBotID(), pet_items); - pet_inst->SetPetState(pet_buffs, pet_items); + pet_inst->RestorePetState(pet_buffs, pet_items); pet_inst->CalcBonuses(); pet_inst->SetHP(pet_hp); pet_inst->SetMana(pet_mana); @@ -1601,14 +1601,14 @@ bool Bot::SavePet() } auto pet_name = new char[64]; - SpellBuff_Struct pet_buffs[PET_BUFF_COUNT]; + Buffs_Struct pet_buffs[PET_BUFF_COUNT]; uint32 pet_items[EQ::invslot::EQUIPMENT_COUNT]; memset(pet_name, 0, 64); - memset(pet_buffs, 0, (sizeof(SpellBuff_Struct) * PET_BUFF_COUNT)); + memset(pet_buffs, 0, (sizeof(Buffs_Struct) * PET_BUFF_COUNT)); memset(pet_items, 0, (sizeof(uint32) * EQ::invslot::EQUIPMENT_COUNT)); - pet_inst->GetPetState(pet_buffs, pet_items, pet_name); + pet_inst->SavePetState(pet_buffs, pet_items, pet_name); std::string pet_name_str = pet_name; safe_delete_array(pet_name) diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index 287eae502..e583496e6 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -622,41 +622,70 @@ bool BotDatabase::LoadBuffs(Bot* b) buffs[index].spellid = SPELL_UNKNOWN; } - uint32 buff_count = 0; + uint32 buff_index = 0; for (const auto& e : l) { - if (buff_count >= BUFF_COUNT) { + if (buff_index >= BUFF_COUNT) { continue; } - buffs[buff_count].spellid = e.spell_id; - buffs[buff_count].casterlevel = e.caster_level; - buffs[buff_count].ticsremaining = e.tics_remaining; - buffs[buff_count].counters = 0; + Client* c = entity_list.GetClientByName(e.caster_name.c_str()); - if (CalculatePoisonCounters(buffs[buff_count].spellid) > 0) { - buffs[buff_count].counters = e.poison_counters; - } else if (CalculateDiseaseCounters(buffs[buff_count].spellid) > 0) { - buffs[buff_count].counters = e.disease_counters; - } else if (CalculateCurseCounters(buffs[buff_count].spellid) > 0) { - buffs[buff_count].counters = e.curse_counters; - } else if (CalculateCorruptionCounters(buffs[buff_count].spellid) > 0) { - buffs[buff_count].counters = e.corruption_counters; + buffs[buff_index].spellid = e.spell_id; + buffs[buff_index].casterlevel = e.caster_level; + + if (c) { + buffs[buff_index].casterid = c->GetID(); + buffs[buff_index].client = true; + + strncpy(buffs[buff_index].caster_name, c->GetName(), 64); + } else { + buffs[buff_index].casterid = 0; + buffs[buff_index].client = false; + + strncpy(buffs[buff_index].caster_name, "", 64); } - buffs[buff_count].hit_number = e.numhits; - buffs[buff_count].melee_rune = e.melee_rune; - buffs[buff_count].magic_rune = e.magic_rune; - buffs[buff_count].dot_rune = e.dot_rune; - buffs[buff_count].persistant_buff = e.persistent; - buffs[buff_count].caston_x = e.caston_x; - buffs[buff_count].caston_y = e.caston_y; - buffs[buff_count].caston_z = e.caston_z; - buffs[buff_count].ExtraDIChance = e.extra_di_chance; - buffs[buff_count].instrument_mod = e.instrument_mod; - buffs[buff_count].casterid = 0; + buffs[buff_index].ticsremaining = e.tics_remaining; + buffs[buff_index].initialduration = e.initial_duration; + buffs[buff_index].counters = 0; + buffs[buff_index].hit_number = e.numhits; + buffs[buff_index].melee_rune = e.melee_rune; + buffs[buff_index].magic_rune = e.magic_rune; + buffs[buff_index].persistent_buff = e.persistent ? true : false; + buffs[buff_index].dot_rune = e.dot_rune; + buffs[buff_index].caston_x = e.caston_x; + buffs[buff_index].caston_y = e.caston_y; + buffs[buff_index].caston_z = e.caston_z; + buffs[buff_index].ExtraDIChance = e.extra_di_chance; + buffs[buff_index].RootBreakChance = 0; + buffs[buff_index].virus_spread_time = 0; + buffs[buff_index].UpdateClient = false; + buffs[buff_index].instrument_mod = e.instrument_mod; - ++buff_count; + if (CalculatePoisonCounters(buffs[buff_index].spellid) > 0) { + buffs[buff_index].counters = e.poison_counters; + } else if (CalculateDiseaseCounters(buffs[buff_index].spellid) > 0) { + buffs[buff_index].counters = e.disease_counters; + } else if (CalculateCurseCounters(buffs[buff_index].spellid) > 0) { + buffs[buff_index].counters = e.curse_counters; + } else if (CalculateCorruptionCounters(buffs[buff_index].spellid) > 0) { + buffs[buff_index].counters = e.corruption_counters; + } + + buffs[buff_index].hit_number = e.numhits; + buffs[buff_index].melee_rune = e.melee_rune; + buffs[buff_index].magic_rune = e.magic_rune; + buffs[buff_index].dot_rune = e.dot_rune; + buffs[buff_index].persistent_buff = e.persistent; + buffs[buff_index].caston_x = e.caston_x; + buffs[buff_index].caston_y = e.caston_y; + buffs[buff_index].caston_z = e.caston_z; + buffs[buff_index].ExtraDIChance = e.extra_di_chance; + buffs[buff_index].instrument_mod = e.instrument_mod; + buffs[buff_index].casterid = 0; + + ++buff_index; } return true; @@ -691,8 +720,10 @@ bool BotDatabase::SaveBuffs(Bot* b) e.spell_id = buffs[buff_index].spellid; e.caster_level = buffs[buff_index].casterlevel; + e.caster_name = buffs[buff_index].caster_name; e.duration_formula = spells[buffs[buff_index].spellid].buff_duration_formula; e.tics_remaining = buffs[buff_index].ticsremaining; + e.initial_duration = buffs[buff_index].initialduration; e.poison_counters = CalculatePoisonCounters(buffs[buff_index].spellid) > 0 ? buffs[buff_index].counters : 0; e.disease_counters = CalculateDiseaseCounters(buffs[buff_index].spellid) > 0 ? buffs[buff_index].counters : 0; e.curse_counters = CalculateCurseCounters(buffs[buff_index].spellid) > 0 ? buffs[buff_index].counters : 0; @@ -701,7 +732,7 @@ bool BotDatabase::SaveBuffs(Bot* b) e.melee_rune = buffs[buff_index].melee_rune; e.magic_rune = buffs[buff_index].magic_rune; e.dot_rune = buffs[buff_index].dot_rune; - e.persistent = buffs[buff_index].persistant_buff ? 1 : 0; + e.persistent = buffs[buff_index].persistent_buff ? 1 : 0; e.caston_x = buffs[buff_index].caston_x; e.caston_y = buffs[buff_index].caston_y; e.caston_z = buffs[buff_index].caston_z; @@ -1360,7 +1391,7 @@ bool BotDatabase::DeletePetStats(const uint32 bot_id) return BotPetsRepository::DeleteOne(database, saved_pet_index) == 1; } -bool BotDatabase::LoadPetBuffs(const uint32 bot_id, SpellBuff_Struct* pet_buffs) +bool BotDatabase::LoadPetBuffs(const uint32 bot_id, Buffs_Struct* pet_buffs) { if (!bot_id) { return false; @@ -1395,27 +1426,47 @@ bool BotDatabase::LoadPetBuffs(const uint32 bot_id, SpellBuff_Struct* pet_buffs) break; } - pet_buffs[buff_index].spellid = e.spell_id; - pet_buffs[buff_index].level = e.caster_level; - pet_buffs[buff_index].duration = e.duration; + Client* c = entity_list.GetClientByName(e.caster_name.c_str()); - if (CalculatePoisonCounters(pet_buffs[buff_index].spellid) > 0) { - pet_buffs[buff_index].counters = CalculatePoisonCounters(pet_buffs[buff_index].spellid); - } else if (CalculateDiseaseCounters(pet_buffs[buff_index].spellid) > 0) { - pet_buffs[buff_index].counters = CalculateDiseaseCounters(pet_buffs[buff_index].spellid); - } else if (CalculateCurseCounters(pet_buffs[buff_index].spellid) > 0) { - pet_buffs[buff_index].counters = CalculateCurseCounters(pet_buffs[buff_index].spellid); - } else if (CalculateCorruptionCounters(pet_buffs[buff_index].spellid) > 0) { - pet_buffs[buff_index].counters = CalculateCorruptionCounters(pet_buffs[buff_index].spellid); + pet_buffs[buff_index].spellid = e.spell_id; + pet_buffs[buff_index].casterlevel = e.caster_level; + + if (c) { + pet_buffs[buff_index].casterid = c->GetID(); + pet_buffs[buff_index].client = true; + + strncpy(pet_buffs[buff_index].caster_name, c->GetName(), 64); + } else { + pet_buffs[buff_index].casterid = 0; + pet_buffs[buff_index].client = false; + + strncpy(pet_buffs[buff_index].caster_name, "", 64); } + pet_buffs[buff_index].ticsremaining = e.tics_remaining; + pet_buffs[buff_index].initialduration = e.initial_duration; + pet_buffs[buff_index].counters = e.counters; + pet_buffs[buff_index].hit_number = e.numhits; + pet_buffs[buff_index].melee_rune = e.melee_rune; + pet_buffs[buff_index].magic_rune = e.magic_rune; + pet_buffs[buff_index].persistent_buff = e.persistent ? true : false; + pet_buffs[buff_index].dot_rune = e.dot_rune; + pet_buffs[buff_index].caston_x = e.caston_x; + pet_buffs[buff_index].caston_y = e.caston_y; + pet_buffs[buff_index].caston_z = e.caston_z; + pet_buffs[buff_index].ExtraDIChance = e.extra_di_chance; + pet_buffs[buff_index].RootBreakChance = 0; + pet_buffs[buff_index].virus_spread_time = 0; + pet_buffs[buff_index].UpdateClient = false; + pet_buffs[buff_index].instrument_mod = e.instrument_mod; + ++buff_index; } return true; } -bool BotDatabase::SavePetBuffs(const uint32 bot_id, const SpellBuff_Struct* pet_buffs, bool delete_flag) +bool BotDatabase::SavePetBuffs(const uint32 bot_id, const Buffs_Struct* pet_buffs, bool delete_flag) { if ( !bot_id || @@ -1446,9 +1497,22 @@ bool BotDatabase::SavePetBuffs(const uint32 bot_id, const SpellBuff_Struct* pet_ continue; } - e.spell_id = pet_buffs[buff_index].spellid; - e.caster_level = pet_buffs[buff_index].level; - e.duration = pet_buffs[buff_index].duration; + e.spell_id = pet_buffs[buff_index].spellid; + e.caster_level = pet_buffs[buff_index].casterlevel; + e.caster_name = pet_buffs[buff_index].caster_name; + e.tics_remaining = pet_buffs[buff_index].ticsremaining; + e.initial_duration = pet_buffs[buff_index].initialduration; + e.counters = pet_buffs[buff_index].counters; + e.numhits = pet_buffs[buff_index].hit_number; + e.melee_rune = pet_buffs[buff_index].melee_rune; + e.magic_rune = pet_buffs[buff_index].magic_rune; + e.persistent = pet_buffs[buff_index].persistent_buff; + e.dot_rune = pet_buffs[buff_index].dot_rune; + e.caston_x = pet_buffs[buff_index].caston_x; + e.caston_y = pet_buffs[buff_index].caston_y; + e.caston_z = pet_buffs[buff_index].caston_z; + e.extra_di_chance = pet_buffs[buff_index].ExtraDIChance; + e.instrument_mod = pet_buffs[buff_index].instrument_mod; v.emplace_back(e); } diff --git a/zone/bot_database.h b/zone/bot_database.h index 9f5cd95c9..a23c8e0d0 100644 --- a/zone/bot_database.h +++ b/zone/bot_database.h @@ -96,8 +96,8 @@ public: bool SavePetStats(const uint32 bot_id, const std::string& pet_name, const uint32 pet_mana, const uint32 pet_hp, const int32 pet_spell_id); bool DeletePetStats(const uint32 bot_id); - bool LoadPetBuffs(const uint32 bot_id, SpellBuff_Struct* pet_buffs); - bool SavePetBuffs(const uint32 bot_id, const SpellBuff_Struct* pet_buffs, bool delete_flag = false); + bool LoadPetBuffs(const uint32 bot_id, Buffs_Struct* pet_buffs); + bool SavePetBuffs(const uint32 bot_id, const Buffs_Struct* pet_buffs, bool delete_flag = false); bool DeletePetBuffs(const uint32 bot_id); bool LoadPetItems(const uint32 bot_id, uint32* pet_items); diff --git a/zone/client.cpp b/zone/client.cpp index 030515807..389a5d230 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -1048,7 +1048,7 @@ bool Client::Save(uint8 iCommitNow) { m_petinfo.SpellID = pet->CastToNPC()->GetPetSpellID(); m_petinfo.HP = pet->GetHP(); m_petinfo.Mana = pet->GetMana(); - pet->GetPetState(m_petinfo.Buffs, m_petinfo.Items, m_petinfo.Name); + pet->SavePetState(m_petinfo.Buffs, m_petinfo.Items, m_petinfo.Name); m_petinfo.petpower = pet->GetPetPower(); m_petinfo.size = pet->GetSize(); m_petinfo.taunting = pet->CastToNPC()->IsTaunting(); @@ -6325,7 +6325,7 @@ void Client::SuspendMinion(int value) if(value >= 1) { - CurrentPet->SetPetState(m_suspendedminion.Buffs, m_suspendedminion.Items); + CurrentPet->RestorePetState(m_suspendedminion.Buffs, m_suspendedminion.Items); ClientPatch::SendFullBuffRefresh(CurrentPet); } CurrentPet->CalcBonuses(); @@ -6392,7 +6392,7 @@ void Client::SuspendMinion(int value) m_suspendedminion.size = CurrentPet->GetSize(); if(value >= 1) - CurrentPet->GetPetState(m_suspendedminion.Buffs, m_suspendedminion.Items, m_suspendedminion.Name); + CurrentPet->SavePetState(m_suspendedminion.Buffs, m_suspendedminion.Items, m_suspendedminion.Name); else strn0cpy(m_suspendedminion.Name, CurrentPet->GetName(), 64); // Name stays even at rank 1 diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 768a63ba6..bc1d71799 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -663,7 +663,7 @@ void Client::CompleteConnect() break; } - if (buffs[j1].persistant_buff) { + if (buffs[j1].persistent_buff) { Mob *caster = entity_list.GetMobID(buffs[j1].casterid); ApplySpellEffectIllusion(spell.id, caster, j1, spell.base_value[x1], spell.limit_value[x1], spell.max_value[x1]); } @@ -1715,13 +1715,13 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) if (RuleB(NPC, PetZoneWithOwner)) { /* Load Pet */ - database.LoadPetInfo(this); + database.LoadPetInfo(this); // TODO: Is the pet loading correctly? I don't get any buffs if (m_petinfo.SpellID > 1 && !GetPet() && m_petinfo.SpellID <= SPDAT_RECORDS) { MakePoweredPet(m_petinfo.SpellID, spells[m_petinfo.SpellID].teleport_zone, m_petinfo.petpower, m_petinfo.Name, m_petinfo.size); if (GetPet() && GetPet()->IsNPC()) { NPC *pet = GetPet()->CastToNPC(); - pet->SetPetState(m_petinfo.Buffs, m_petinfo.Items); + pet->RestorePetState(m_petinfo.Buffs, m_petinfo.Items); pet->CalcBonuses(); pet->SetHP(m_petinfo.HP); pet->SetMana(m_petinfo.Mana); diff --git a/zone/common.h b/zone/common.h index 66effd484..a54167ef7 100644 --- a/zone/common.h +++ b/zone/common.h @@ -241,7 +241,7 @@ struct Buffs_Struct { int16 RootBreakChance; //Not saved to dbase uint32 instrument_mod; int32 virus_spread_time; //time till next attempted viral spread - bool persistant_buff; + bool persistent_buff; bool client; //True if the caster is a client bool UpdateClient; // This is for legacy client support only. Newer clients take refresh packets for the entire buff list @@ -261,6 +261,7 @@ struct Buffs_Struct { CEREAL_NVP(casterid), CEREAL_NVP(caster_name_str), CEREAL_NVP(ticsremaining), + CEREAL_NVP(initialduration), CEREAL_NVP(counters), CEREAL_NVP(hit_number), CEREAL_NVP(melee_rune), @@ -273,7 +274,7 @@ struct Buffs_Struct { CEREAL_NVP(RootBreakChance), CEREAL_NVP(instrument_mod), CEREAL_NVP(virus_spread_time), - CEREAL_NVP(persistant_buff), + CEREAL_NVP(persistent_buff), CEREAL_NVP(client), CEREAL_NVP(UpdateClient) ); diff --git a/zone/lua_buff.cpp b/zone/lua_buff.cpp index f001aa48c..9b8d20da5 100644 --- a/zone/lua_buff.cpp +++ b/zone/lua_buff.cpp @@ -134,7 +134,7 @@ bool Lua_Buff::IsCasterClient() bool Lua_Buff::IsPersistentBuff() { Lua_Safe_Call_Bool(); - return self->persistant_buff; + return self->persistent_buff; } bool Lua_Buff::SendsClientUpdate() diff --git a/zone/npc.h b/zone/npc.h index 1516dcd04..431b81e37 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -184,8 +184,8 @@ public: void GoToBind(uint8 bind_number = 0) { GMMove(m_SpawnPoint.x, m_SpawnPoint.y, m_SpawnPoint.z, m_SpawnPoint.w); } void Gate(uint8 bind_number = 0); - void GetPetState(SpellBuff_Struct *buffs, uint32 *items, char *name); - void SetPetState(SpellBuff_Struct *buffs, uint32 *items); + void SavePetState(Buffs_Struct* buffs, uint32 *items, char *name) const; + void RestorePetState(const Buffs_Struct* pet_buffs, const uint32* items); virtual void SpellProcess(); virtual void FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho); @@ -611,6 +611,7 @@ public: buffs[i].casterid = b.casterid; strncpy(buffs[i].caster_name, b.caster_name, 64); buffs[i].ticsremaining = b.ticsremaining; + buffs[i].initialduration = b.initialduration; buffs[i].counters = b.counters; buffs[i].hit_number = b.hit_number; buffs[i].melee_rune = b.melee_rune; @@ -623,7 +624,7 @@ public: buffs[i].RootBreakChance = b.RootBreakChance; buffs[i].instrument_mod = b.instrument_mod; buffs[i].virus_spread_time = b.virus_spread_time; - buffs[i].persistant_buff = b.persistant_buff; + buffs[i].persistent_buff = b.persistent_buff; buffs[i].client = b.client; buffs[i].UpdateClient = b.UpdateClient; i++; diff --git a/zone/perl_buff.cpp b/zone/perl_buff.cpp index c90843d41..ee102bbbe 100644 --- a/zone/perl_buff.cpp +++ b/zone/perl_buff.cpp @@ -114,7 +114,7 @@ bool Perl_Buff_IsCasterClient(Buffs_Struct* self) bool Perl_Buff_IsPersistentBuff(Buffs_Struct* self) { - return self->persistant_buff; + return self->persistent_buff; } bool Perl_Buff_SendsClientUpdate(Buffs_Struct* self) diff --git a/zone/pets.cpp b/zone/pets.cpp index 84c29f75f..7e7c6a9f8 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -471,7 +471,8 @@ void Mob::SetPetID(uint16 NewPetID) { } } -void NPC::GetPetState(SpellBuff_Struct *pet_buffs, uint32 *items, char *name) { +void NPC::SavePetState(Buffs_Struct* pet_buffs, uint32 *items, char *name) const +{ //save the pet name strn0cpy(name, GetName(), 64); @@ -479,102 +480,71 @@ void NPC::GetPetState(SpellBuff_Struct *pet_buffs, uint32 *items, char *name) { memcpy(items, equipment, sizeof(uint32) * EQ::invslot::EQUIPMENT_COUNT); //save their buffs. - for (int i=EQ::invslot::EQUIPMENT_BEGIN; i < GetPetMaxTotalSlots(); i++) { - if (IsValidSpell(buffs[i].spellid)) { - pet_buffs[i].spellid = buffs[i].spellid; - pet_buffs[i].effect_type = i+1; - pet_buffs[i].duration = buffs[i].ticsremaining; - pet_buffs[i].level = buffs[i].casterlevel; - pet_buffs[i].bard_modifier = 10; - pet_buffs[i].counters = buffs[i].counters; - pet_buffs[i].bard_modifier = buffs[i].instrument_mod; - } - else { - pet_buffs[i].spellid = SPELL_UNKNOWN; - pet_buffs[i].duration = 0; - pet_buffs[i].level = 0; - pet_buffs[i].bard_modifier = 10; - pet_buffs[i].counters = 0; - } - } + memcpy(pet_buffs, buffs, sizeof(Buffs_Struct) * GetPetMaxTotalSlots()); } -void NPC::SetPetState(SpellBuff_Struct *pet_buffs, uint32 *items) { +void NPC::RestorePetState(const Buffs_Struct* pet_buffs, const uint32* items) { //restore their buffs... + memcpy(buffs, pet_buffs, sizeof(Buffs_Struct) * GetPetMaxTotalSlots()); - int i; - for (i = 0; i < GetPetMaxTotalSlots(); i++) { - for(int z = 0; z < GetPetMaxTotalSlots(); z++) { - // check for duplicates - if(IsValidSpell(buffs[z].spellid) && buffs[z].spellid == pet_buffs[i].spellid) { - buffs[z].spellid = SPELL_UNKNOWN; - pet_buffs[i].spellid = 0xFFFFFFFF; - } - } - - if (pet_buffs[i].spellid <= (uint32)SPDAT_RECORDS && pet_buffs[i].spellid != 0 && (pet_buffs[i].duration > 0 || pet_buffs[i].duration == -1)) { - if(pet_buffs[i].level == 0 || pet_buffs[i].level > 100) - pet_buffs[i].level = 1; - buffs[i].spellid = pet_buffs[i].spellid; - buffs[i].ticsremaining = pet_buffs[i].duration; - buffs[i].casterlevel = pet_buffs[i].level; - buffs[i].casterid = 0; - buffs[i].counters = pet_buffs[i].counters; - buffs[i].hit_number = spells[pet_buffs[i].spellid].hit_number; - buffs[i].instrument_mod = pet_buffs[i].bard_modifier; - } - else { - buffs[i].spellid = SPELL_UNKNOWN; - pet_buffs[i].spellid = 0xFFFFFFFF; - pet_buffs[i].effect_type = 0; - pet_buffs[i].level = 0; - pet_buffs[i].duration = 0; - pet_buffs[i].bard_modifier = 0; - } - } - for (int j1=0; j1 < GetPetMaxTotalSlots(); j1++) { - if (buffs[j1].spellid <= (uint32)SPDAT_RECORDS) { - for (int x1=0; x1 < EFFECT_COUNT; x1++) { - switch (spells[buffs[j1].spellid].effect_id[x1]) { - case SpellEffect::AddMeleeProc: - case SpellEffect::WeaponProc: - // We need to reapply buff based procs - // We need to do this here so suspended pets also regain their procs. - AddProcToWeapon(GetProcID(buffs[j1].spellid,x1), false, 100+spells[buffs[j1].spellid].limit_value[x1], buffs[j1].spellid, buffs[j1].casterlevel, GetSpellProcLimitTimer(buffs[j1].spellid, ProcType::MELEE_PROC)); - break; - case SpellEffect::DefensiveProc: - AddDefensiveProc(GetProcID(buffs[j1].spellid, x1), 100 + spells[buffs[j1].spellid].limit_value[x1], buffs[j1].spellid, GetSpellProcLimitTimer(buffs[j1].spellid, ProcType::DEFENSIVE_PROC)); - break; - case SpellEffect::RangedProc: - AddRangedProc(GetProcID(buffs[j1].spellid, x1), 100 + spells[buffs[j1].spellid].limit_value[x1], buffs[j1].spellid, GetSpellProcLimitTimer(buffs[j1].spellid, ProcType::RANGED_PROC)); - break; - case SpellEffect::Charm: - case SpellEffect::Rune: - case SpellEffect::NegateAttacks: - case SpellEffect::Illusion: - buffs[j1].spellid = SPELL_UNKNOWN; - pet_buffs[j1].spellid = SPELL_UNKNOWN; - pet_buffs[j1].effect_type = 0; - pet_buffs[j1].level = 0; - pet_buffs[j1].duration = 0; - pet_buffs[j1].bard_modifier = 0; - x1 = EFFECT_COUNT; - break; - // We can't send appearance packets yet, put down at CompleteConnect + for (int slot = 0; slot < GetPetMaxTotalSlots(); ++slot) { + if (IsValidSpell(buffs[slot].spellid)) { + // check for duplicates of valid spells, keep the lowest one + for (int slot2 = slot + 1; slot2 < GetPetMaxTotalSlots(); ++slot2) { + if (IsValidSpell(buffs[slot2].spellid) && buffs[slot].spellid == buffs[slot2].spellid) { + buffs[slot2].spellid = SPELL_UNKNOWN; + buffs[slot2].ticsremaining = 0; } } + + // re-add any specific passive effects that need to be added + for (int effect = 0; effect < EFFECT_COUNT; ++effect) { + switch (spells[buffs[slot].spellid].effect_id[effect]) { + case SpellEffect::AddMeleeProc: + case SpellEffect::WeaponProc: + // We need to reapply buff based procs + // We need to do this here so suspended pets also regain their procs. + AddProcToWeapon(GetProcID(buffs[slot].spellid, effect), false, + 100 + spells[buffs[slot].spellid].limit_value[effect], buffs[slot].spellid, + buffs[slot].casterlevel, GetSpellProcLimitTimer(buffs[slot].spellid, ProcType::MELEE_PROC)); + break; + case SpellEffect::DefensiveProc: + AddDefensiveProc(GetProcID(buffs[slot].spellid, effect), + 100 + spells[buffs[slot].spellid].limit_value[effect], buffs[slot].spellid, + GetSpellProcLimitTimer(buffs[slot].spellid, ProcType::DEFENSIVE_PROC)); + break; + case SpellEffect::RangedProc: + AddRangedProc(GetProcID(buffs[slot].spellid, effect), + 100 + spells[buffs[slot].spellid].limit_value[effect], buffs[slot].spellid, + GetSpellProcLimitTimer(buffs[slot].spellid, ProcType::RANGED_PROC)); + break; + case SpellEffect::Charm: + case SpellEffect::Rune: + case SpellEffect::NegateAttacks: + case SpellEffect::Illusion: + buffs[slot].spellid = SPELL_UNKNOWN; + buffs[slot].ticsremaining = 0; + effect = EFFECT_COUNT; // don't process any more effects, this buff is gone + break; + // We can't send appearance packets yet, put down at CompleteConnect + default: + break; + } + } + } else { + // ensure this buff isn't going to stick around + buffs[slot].spellid = SPELL_UNKNOWN; + buffs[slot].ticsremaining = 0; } } //restore their equipment... - for (i = EQ::invslot::EQUIPMENT_BEGIN; i <= EQ::invslot::EQUIPMENT_END; i++) { - if (items[i] == 0) { + for (int equip = EQ::invslot::EQUIPMENT_BEGIN; equip <= EQ::invslot::EQUIPMENT_END; equip++) { + if (items[equip] == 0) { continue; } - const EQ::ItemData *item2 = database.GetItem(items[i]); - - if (item2) { + if (const EQ::ItemData *item2 = database.GetItem(items[equip])) { bool noDrop = (item2->NoDrop == 0); // Field is reverse logic bool petCanHaveNoDrop = (RuleB(Pets, CanTakeNoDrop) && _CLIENTPET(this) && GetPetType() <= PetType::Normal); diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index ae2163c31..8d4e906df 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -10532,10 +10532,10 @@ void Mob::ApplySpellEffectIllusion(int32 spell_id, Mob *caster, int buffslot, in RuleB(Spells, IllusionsAlwaysPersist) ) ) { - buffs[buffslot].persistant_buff = 1; + buffs[buffslot].persistent_buff = 1; } else { - buffs[buffslot].persistant_buff = 0; + buffs[buffslot].persistent_buff = 0; } } } @@ -10654,6 +10654,7 @@ int Mob::GetBuffStatValueBySlot(uint8 slot, const char* stat_identifier) else if (id == "spell_id") { return buffs[slot].spellid; } else if (id == "caster_id") { return buffs[slot].spellid; } else if (id == "ticsremaining") { return buffs[slot].ticsremaining; } + else if (id == "initialduration") { return buffs[slot].initialduration; } else if (id == "counters") { return buffs[slot].counters; } else if (id == "hit_number") { return buffs[slot].hit_number; } else if (id == "melee_rune") { return buffs[slot].melee_rune; } @@ -10663,7 +10664,7 @@ int Mob::GetBuffStatValueBySlot(uint8 slot, const char* stat_identifier) else if (id == "caston_y") { return buffs[slot].caston_y; } else if (id == "caston_z") { return buffs[slot].caston_z; } else if (id == "instrument_mod") { return buffs[slot].instrument_mod; } - else if (id == "persistant_buff") { return buffs[slot].persistant_buff; } + else if (id == "persistant_buff") { return buffs[slot].persistent_buff; } else if (id == "client") { return buffs[slot].client; } else if (id == "extra_di_chance") { return buffs[slot].ExtraDIChance; } else if (id == "root_break_chance") { return buffs[slot].RootBreakChance; } diff --git a/zone/spells.cpp b/zone/spells.cpp index 2471ae602..0a6f2aff8 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -3724,7 +3724,7 @@ int Mob::AddBuff(Mob *caster, int32 spell_id, int duration, int32 level_override buffs[emptyslot].counters = CalculateCounters(spell_id); buffs[emptyslot].hit_number = spells[spell_id].hit_number; buffs[emptyslot].client = caster ? caster->IsClient() : 0; - buffs[emptyslot].persistant_buff = 0; + buffs[emptyslot].persistent_buff = 0; buffs[emptyslot].caston_x = 0; buffs[emptyslot].caston_y = 0; buffs[emptyslot].caston_z = 0; @@ -4574,11 +4574,9 @@ bool Mob::SpellOnTarget( // if SpellEffect returned false there's a problem applying the // spell. It's most likely a buff that can't stack. LogSpells("Spell [{}] could not apply its effects [{}] -> [{}]\n", spell_id, GetName(), spelltar->GetName()); - if (casting_spell_aa_id) { - MessageString(Chat::SpellFailure, SPELL_NO_HOLD); - if (RuleB(Spells, LegacyManaburn) && IsClient() && casting_spell_aa_id == aaManaBurn) { - StopCasting(); - } + MessageString(Chat::SpellFailure, SPELL_NO_HOLD); + if (casting_spell_aa_id && RuleB(Spells, LegacyManaburn) && IsClient() && casting_spell_aa_id == aaManaBurn) { + StopCasting(); } safe_delete(action_packet); return false; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 0236c4ef4..c6a92ea97 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -2381,6 +2381,7 @@ void ZoneDatabase::SaveMercenaryBuffs(Merc* m) e.CasterLevel = buffs[slot_id].casterlevel; e.DurationFormula = spells[buffs[slot_id].spellid].buff_duration_formula; e.TicsRemaining = buffs[slot_id].ticsremaining; + e.InitialDuration = buffs[slot_id].initialduration; e.PoisonCounters = CalculatePoisonCounters(buffs[slot_id].spellid) > 0 ? buffs[slot_id].counters : 0; e.DiseaseCounters = CalculateDiseaseCounters(buffs[slot_id].spellid) > 0 ? buffs[slot_id].counters : 0; e.CurseCounters = CalculateCurseCounters(buffs[slot_id].spellid) > 0 ? buffs[slot_id].counters : 0; @@ -2392,8 +2393,9 @@ void ZoneDatabase::SaveMercenaryBuffs(Merc* m) e.caston_x = buffs[slot_id].caston_x; e.caston_y = buffs[slot_id].caston_y; e.caston_z = buffs[slot_id].caston_z; - e.Persistent = buffs[slot_id].persistant_buff ? 1 : 0; + e.Persistent = buffs[slot_id].persistent_buff ? 1 : 0; e.ExtraDIChance = buffs[slot_id].ExtraDIChance; + e.instrument_mod = buffs[slot_id].instrument_mod; v.emplace_back(e); } @@ -2430,6 +2432,7 @@ void ZoneDatabase::LoadMercenaryBuffs(Merc* m) buffs[slot_id].spellid = e.SpellId; buffs[slot_id].casterlevel = e.CasterLevel; buffs[slot_id].ticsremaining = e.TicsRemaining; + buffs[slot_id].initialduration = e.InitialDuration; buffs[slot_id].hit_number = e.HitCount; buffs[slot_id].melee_rune = e.MeleeRune; buffs[slot_id].magic_rune = e.MagicRune; @@ -2439,7 +2442,8 @@ void ZoneDatabase::LoadMercenaryBuffs(Merc* m) buffs[slot_id].caston_z = e.caston_z; buffs[slot_id].casterid = 0; buffs[slot_id].ExtraDIChance = e.ExtraDIChance; - buffs[slot_id].persistant_buff = e.Persistent; + buffs[slot_id].persistent_buff = e.Persistent; + buffs[slot_id].instrument_mod = e.instrument_mod; if (CalculatePoisonCounters(buffs[slot_id].spellid) > 0) { buffs[slot_id].counters = e.PoisonCounters; @@ -2926,23 +2930,24 @@ void ZoneDatabase::SaveBuffs(Client *client) continue; } - e.character_id = client->CharacterID(); - e.slot_id = slot_id; - e.spell_id = buffs[slot_id].spellid; - e.caster_level = buffs[slot_id].casterlevel; - e.caster_name = buffs[slot_id].caster_name; - e.ticsremaining = buffs[slot_id].ticsremaining; - e.counters = buffs[slot_id].counters; - e.numhits = buffs[slot_id].hit_number; - e.melee_rune = buffs[slot_id].melee_rune; - e.magic_rune = buffs[slot_id].magic_rune; - e.persistent = buffs[slot_id].persistant_buff; - e.dot_rune = buffs[slot_id].dot_rune; - e.caston_x = buffs[slot_id].caston_x; - e.caston_y = buffs[slot_id].caston_y; - e.caston_z = buffs[slot_id].caston_z; - e.ExtraDIChance = buffs[slot_id].ExtraDIChance; - e.instrument_mod = buffs[slot_id].instrument_mod; + e.character_id = client->CharacterID(); + e.slot_id = slot_id; + e.spell_id = buffs[slot_id].spellid; + e.caster_level = buffs[slot_id].casterlevel; + e.caster_name = buffs[slot_id].caster_name; + e.ticsremaining = buffs[slot_id].ticsremaining; + e.initialduration = buffs[slot_id].initialduration; + e.counters = buffs[slot_id].counters; + e.numhits = buffs[slot_id].hit_number; + e.melee_rune = buffs[slot_id].melee_rune; + e.magic_rune = buffs[slot_id].magic_rune; + e.persistent = buffs[slot_id].persistent_buff; + e.dot_rune = buffs[slot_id].dot_rune; + e.caston_x = buffs[slot_id].caston_x; + e.caston_y = buffs[slot_id].caston_y; + e.caston_z = buffs[slot_id].caston_z; + e.ExtraDIChance = buffs[slot_id].ExtraDIChance; + e.instrument_mod = buffs[slot_id].instrument_mod; v.emplace_back(e); } @@ -3000,11 +3005,12 @@ void ZoneDatabase::LoadBuffs(Client *client) } buffs[e.slot_id].ticsremaining = e.ticsremaining; + buffs[e.slot_id].initialduration = e.initialduration; buffs[e.slot_id].counters = e.counters; buffs[e.slot_id].hit_number = e.numhits; buffs[e.slot_id].melee_rune = e.melee_rune; buffs[e.slot_id].magic_rune = e.magic_rune; - buffs[e.slot_id].persistant_buff = e.persistent ? true : false; + buffs[e.slot_id].persistent_buff = e.persistent ? true : false; buffs[e.slot_id].dot_rune = e.dot_rune; buffs[e.slot_id].caston_x = e.caston_x; buffs[e.slot_id].caston_y = e.caston_y; @@ -3030,7 +3036,7 @@ void ZoneDatabase::LoadBuffs(Client *client) } if (IsEffectInSpell(buffs[slot_id].spellid, SpellEffect::Illusion)) { - if (buffs[slot_id].persistant_buff) { + if (buffs[slot_id].persistent_buff) { break; } @@ -3139,14 +3145,25 @@ void ZoneDatabase::SavePetInfo(Client *client) continue; } - pet_buff.char_id = client->CharacterID(); - pet_buff.pet = pet_info_type; - pet_buff.slot = slot_id; - pet_buff.spell_id = p->Buffs[slot_id].spellid; - pet_buff.caster_level = p->Buffs[slot_id].level; - pet_buff.ticsremaining = p->Buffs[slot_id].duration; - pet_buff.counters = p->Buffs[slot_id].counters; - pet_buff.instrument_mod = p->Buffs[slot_id].bard_modifier; + pet_buff.character_id = client->CharacterID(); + pet_buff.pet = pet_info_type; + pet_buff.slot_id = slot_id; + pet_buff.spell_id = p->Buffs[slot_id].spellid; + pet_buff.caster_level = p->Buffs[slot_id].casterlevel; + pet_buff.caster_name = p->Buffs[slot_id].caster_name; + pet_buff.ticsremaining = p->Buffs[slot_id].ticsremaining; + pet_buff.initialduration = p->Buffs[slot_id].initialduration; + pet_buff.counters = p->Buffs[slot_id].counters; + pet_buff.numhits = p->Buffs[slot_id].hit_number; + pet_buff.melee_rune = p->Buffs[slot_id].melee_rune; + pet_buff.magic_rune = p->Buffs[slot_id].magic_rune; + pet_buff.persistent = p->Buffs[slot_id].persistent_buff; + pet_buff.dot_rune = p->Buffs[slot_id].dot_rune; + pet_buff.caston_x = p->Buffs[slot_id].caston_x; + pet_buff.caston_y = p->Buffs[slot_id].caston_y; + pet_buff.caston_z = p->Buffs[slot_id].caston_z; + pet_buff.ExtraDIChance = p->Buffs[slot_id].ExtraDIChance; + pet_buff.instrument_mod = p->Buffs[slot_id].instrument_mod; pet_buffs.push_back(pet_buff); } @@ -3200,7 +3217,7 @@ void ZoneDatabase::SavePetInfo(Client *client) CharacterPetBuffsRepository::DeleteWhere( database, fmt::format( - "`char_id` = {}", + "`character_id` = {}", client->CharacterID() ) ); @@ -3299,7 +3316,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) const auto& buffs = CharacterPetBuffsRepository::GetWhere( database, fmt::format( - "`char_id` = {}", + "`character_id` = {}", client->CharacterID() ) ); @@ -3314,7 +3331,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) continue; } - if (e.slot >= RuleI(Spells, MaxTotalSlotsPET)) { + if (e.slot_id >= RuleI(Spells, MaxTotalSlotsPET)) { continue; } @@ -3322,13 +3339,39 @@ void ZoneDatabase::LoadPetInfo(Client *client) continue; } - p->Buffs[e.slot].spellid = e.spell_id; - p->Buffs[e.slot].level = e.caster_level; - p->Buffs[e.slot].player_id = 0; - p->Buffs[e.slot].effect_type = BuffEffectType::Buff; - p->Buffs[e.slot].duration = e.ticsremaining; - p->Buffs[e.slot].counters = e.counters; - p->Buffs[e.slot].bard_modifier = e.instrument_mod; + Client* c = entity_list.GetClientByName(e.caster_name.c_str()); + + p->Buffs[e.slot_id].spellid = e.spell_id; + p->Buffs[e.slot_id].casterlevel = e.caster_level; + + if (c) { + p->Buffs[e.slot_id].casterid = c->GetID(); + p->Buffs[e.slot_id].client = true; + + strncpy(p->Buffs[e.slot_id].caster_name, c->GetName(), 64); + } else { + p->Buffs[e.slot_id].casterid = 0; + p->Buffs[e.slot_id].client = false; + + strncpy(p->Buffs[e.slot_id].caster_name, "", 64); + } + + p->Buffs[e.slot_id].ticsremaining = e.ticsremaining; + p->Buffs[e.slot_id].initialduration = e.initialduration; + p->Buffs[e.slot_id].counters = e.counters; + p->Buffs[e.slot_id].hit_number = e.numhits; + p->Buffs[e.slot_id].melee_rune = e.melee_rune; + p->Buffs[e.slot_id].magic_rune = e.magic_rune; + p->Buffs[e.slot_id].persistent_buff = e.persistent ? true : false; + p->Buffs[e.slot_id].dot_rune = e.dot_rune; + p->Buffs[e.slot_id].caston_x = e.caston_x; + p->Buffs[e.slot_id].caston_y = e.caston_y; + p->Buffs[e.slot_id].caston_z = e.caston_z; + p->Buffs[e.slot_id].ExtraDIChance = e.ExtraDIChance; + p->Buffs[e.slot_id].RootBreakChance = 0; + p->Buffs[e.slot_id].virus_spread_time = 0; + p->Buffs[e.slot_id].UpdateClient = false; + p->Buffs[e.slot_id].instrument_mod = e.instrument_mod; } } diff --git a/zone/zonedb.h b/zone/zonedb.h index 6cf9aacee..b7a598172 100644 --- a/zone/zonedb.h +++ b/zone/zonedb.h @@ -209,7 +209,7 @@ struct PetInfo { uint32 HP; uint32 Mana; float size; - SpellBuff_Struct Buffs[PET_BUFF_COUNT]; + Buffs_Struct Buffs[PET_BUFF_COUNT]; uint32 Items[EQ::invslot::EQUIPMENT_COUNT]; char Name[64]; bool taunting;