Compare commits

...

7 Commits

Author SHA1 Message Date
Chris Miles ca8ed458c3 Update task_manager.cpp 2025-05-17 16:33:51 -05:00
Chris Miles 429d8cdf6d Revert a few changes until later 2025-05-17 16:18:33 -05:00
Chris Miles 5ca4430f47 Update zonedb.cpp 2025-05-17 16:15:54 -05:00
Chris Miles f5f666062b Character tribute 2025-05-17 16:06:42 -05:00
Chris Miles 01fd2611e6 Cut down on task saves 2025-05-17 16:06:00 -05:00
Chris Miles 2c1cb55f14 exp modifiers, pets, timers 2025-05-17 15:43:31 -05:00
Chris Miles 36fc7b6e7f Keyring, Unmem, Auras 2025-05-17 14:35:42 -05:00
10 changed files with 164 additions and 190 deletions
@@ -7109,6 +7109,17 @@ ALTER TABLE `npc_types`
ALTER TABLE `character_data`
CHANGE COLUMN `firstlogon` `ingame` tinyint(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `xtargets`,
ADD COLUMN `first_login` int(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `xtargets`;
)",
.content_schema_update = false
},
ManifestEntry{
.version = 9324,
.description = "2025_05_17_keyring_index.sql",
.check = "SHOW CREATE TABLE keyring",
.condition = "missing",
.match = "idx_charid_itemid",
.sql = R"(
ALTER TABLE keyring ADD INDEX idx_charid_itemid (char_id, item_id);
)",
.content_schema_update = false
},
+24 -37
View File
@@ -22,6 +22,7 @@
#include "ptimer.h"
#include "database.h"
#include "strings.h"
#include "repositories/timers_repository.h"
#ifdef _WINDOWS
#include <winsock2.h>
@@ -149,27 +150,6 @@ bool PersistentTimer::Load(Database *db) {
return true;
}
bool PersistentTimer::Store(Database *db) {
if(Expired(db, false)) //dont need to store expired timers.
return true;
std::string query = StringFormat("REPLACE INTO timers "
" (char_id, type, start, duration, enable) "
" VALUES (%lu, %u, %lu, %lu, %d)",
(unsigned long)_char_id, _type, (unsigned long)start_time,
(unsigned long)timer_time, enabled ? 1: 0);
#ifdef DEBUG_PTIMERS
printf("Storing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query.c_str());
#endif
auto results = db->QueryDatabase(query);
if (!results.Success()) {
return false;
}
return true;
}
bool PersistentTimer::Clear(Database *db) {
std::string query = StringFormat("DELETE FROM timers "
@@ -304,27 +284,34 @@ bool PTimerList::Load(Database *db) {
return true;
}
bool PTimerList::Store(Database *db) {
#ifdef DEBUG_PTIMERS
printf("Storing all timers for char %lu\n", (unsigned long)_char_id);
#endif
bool PTimerList::Store(Database *db)
{
auto e = TimersRepository::NewEntity();
std::vector<TimersRepository::Timers> entries;
std::map<pTimerType, PersistentTimer *>::iterator s;
s = _list.begin();
bool res = true;
while(s != _list.end()) {
if(s->second != nullptr) {
#ifdef DEBUG_PTIMERS
printf("Storing timer %u for char %lu\n", s->first, (unsigned long)_char_id);
#endif
if(!s->second->Store(db))
res = false;
for (auto &[type, timer] : _list) {
if (!timer) {
continue;
}
++s;
e.char_id = _char_id;
e.type = type;
e.start = timer->GetStartTime();
e.duration = timer->GetTimerTime();
e.enable = timer->Enabled() ? 1 : 0;
entries.emplace_back(e);
}
return(res);
if (!entries.empty()) {
Expired(db, false);
TimersRepository::ReplaceMany(*db, entries);
}
return true;
}
bool PTimerList::Clear(Database *db) {
_list.clear();
-1
View File
@@ -91,7 +91,6 @@ public:
inline bool Enabled() { return enabled; }
bool Load(Database *db);
bool Store(Database *db);
bool Clear(Database *db);
protected:
@@ -115,8 +115,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;
@@ -231,8 +231,8 @@ public:
"lfg",
"mailkey",
"xtargets",
"ingame",
"first_login",
"ingame",
"e_aa_effects",
"e_percent_to_aa",
"e_expended_aa_spent",
@@ -343,8 +343,8 @@ public:
"lfg",
"mailkey",
"xtargets",
"ingame",
"first_login",
"ingame",
"e_aa_effects",
"e_percent_to_aa",
"e_expended_aa_spent",
@@ -489,8 +489,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;
@@ -631,8 +631,8 @@ public:
e.lfg = row[93] ? static_cast<uint8_t>(strtoul(row[93], nullptr, 10)) : 0;
e.mailkey = row[94] ? row[94] : "";
e.xtargets = row[95] ? static_cast<uint8_t>(strtoul(row[95], nullptr, 10)) : 5;
e.ingame = row[96] ? static_cast<uint8_t>(strtoul(row[96], nullptr, 10)) : 0;
e.first_login = row[97] ? static_cast<uint32_t>(strtoul(row[97], nullptr, 10)) : 0;
e.first_login = row[96] ? static_cast<uint32_t>(strtoul(row[96], nullptr, 10)) : 0;
e.ingame = row[97] ? static_cast<uint8_t>(strtoul(row[97], nullptr, 10)) : 0;
e.e_aa_effects = row[98] ? static_cast<uint32_t>(strtoul(row[98], nullptr, 10)) : 0;
e.e_percent_to_aa = row[99] ? static_cast<uint32_t>(strtoul(row[99], nullptr, 10)) : 0;
e.e_expended_aa_spent = row[100] ? static_cast<uint32_t>(strtoul(row[100], nullptr, 10)) : 0;
@@ -769,8 +769,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));
@@ -896,8 +896,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));
@@ -1031,8 +1031,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));
@@ -1170,8 +1170,8 @@ public:
e.lfg = row[93] ? static_cast<uint8_t>(strtoul(row[93], nullptr, 10)) : 0;
e.mailkey = row[94] ? row[94] : "";
e.xtargets = row[95] ? static_cast<uint8_t>(strtoul(row[95], nullptr, 10)) : 5;
e.ingame = row[96] ? static_cast<uint8_t>(strtoul(row[96], nullptr, 10)) : 0;
e.first_login = row[97] ? static_cast<uint32_t>(strtoul(row[97], nullptr, 10)) : 0;
e.first_login = row[96] ? static_cast<uint32_t>(strtoul(row[96], nullptr, 10)) : 0;
e.ingame = row[97] ? static_cast<uint8_t>(strtoul(row[97], nullptr, 10)) : 0;
e.e_aa_effects = row[98] ? static_cast<uint32_t>(strtoul(row[98], nullptr, 10)) : 0;
e.e_percent_to_aa = row[99] ? static_cast<uint32_t>(strtoul(row[99], nullptr, 10)) : 0;
e.e_expended_aa_spent = row[100] ? static_cast<uint32_t>(strtoul(row[100], nullptr, 10)) : 0;
@@ -1300,8 +1300,8 @@ public:
e.lfg = row[93] ? static_cast<uint8_t>(strtoul(row[93], nullptr, 10)) : 0;
e.mailkey = row[94] ? row[94] : "";
e.xtargets = row[95] ? static_cast<uint8_t>(strtoul(row[95], nullptr, 10)) : 5;
e.ingame = row[96] ? static_cast<uint8_t>(strtoul(row[96], nullptr, 10)) : 0;
e.first_login = row[97] ? static_cast<uint32_t>(strtoul(row[97], nullptr, 10)) : 0;
e.first_login = row[96] ? static_cast<uint32_t>(strtoul(row[96], nullptr, 10)) : 0;
e.ingame = row[97] ? static_cast<uint8_t>(strtoul(row[97], nullptr, 10)) : 0;
e.e_aa_effects = row[98] ? static_cast<uint32_t>(strtoul(row[98], nullptr, 10)) : 0;
e.e_percent_to_aa = row[99] ? static_cast<uint32_t>(strtoul(row[99], nullptr, 10)) : 0;
e.e_expended_aa_spent = row[100] ? static_cast<uint32_t>(strtoul(row[100], nullptr, 10)) : 0;
@@ -1480,8 +1480,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));
@@ -1608,8 +1608,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));
+1 -1
View File
@@ -42,7 +42,7 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/
#define CURRENT_BINARY_DATABASE_VERSION 9323
#define CURRENT_BINARY_DATABASE_VERSION 9324
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9054
#define CUSTOM_BINARY_DATABASE_VERSION 0
-1
View File
@@ -11479,7 +11479,6 @@ void Client::SaveSpells()
}
CharacterSpellsRepository::DeleteWhere(database, fmt::format("id = {}", CharacterID()));
if (!character_spells.empty()) {
CharacterSpellsRepository::InsertMany(database, character_spells);
}
+23 -25
View File
@@ -827,6 +827,8 @@ void Client::CompleteConnect()
parse->EventPlayer(EVENT_CONNECT, this, export_string, 0);
}
RecordStats();
if (is_first_login) {
e.first_login = time(nullptr);
TraderRepository::DeleteWhere(database, fmt::format("`char_id` = '{}'", CharacterID()));
@@ -1002,7 +1004,6 @@ void Client::CompleteConnect()
safe_delete(p);
}
RecordStats();
AutoGrantAAPoints();
// set initial position for mob tracking
@@ -1366,22 +1367,22 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
// set to full support in case they're a gm with items in disabled expansion slots...but, have their gm flag off...
// item loss will occur when they use the 'empty' slots, if this is not done
m_inv.SetGMInventory(true);
loaditems = database.GetInventory(this); /* Load Character Inventory */
database.LoadCharacterBandolier(cid, &m_pp); /* Load Character Bandolier */
database.LoadCharacterBindPoint(cid, &m_pp); /* Load Character Bind */
database.LoadCharacterMaterialColor(cid, &m_pp); /* Load Character Material */
database.LoadCharacterPotionBelt(cid, &m_pp); /* Load Character Potion Belt */
database.LoadCharacterCurrency(cid, &m_pp); /* Load Character Currency into PP */
database.LoadCharacterData(cid, &m_pp, &m_epp); /* Load Character Data from DB into PP as well as E_PP */
database.LoadCharacterSkills(cid, &m_pp); /* Load Character Skills */
database.LoadCharacterInspectMessage(cid, &m_inspect_message); /* Load Character Inspect Message */
database.LoadCharacterSpellBook(cid, &m_pp); /* Load Character Spell Book */
database.LoadCharacterMemmedSpells(cid, &m_pp); /* Load Character Memorized Spells */
database.LoadCharacterLanguages(cid, &m_pp); /* Load Character Languages */
database.LoadCharacterLeadershipAbilities(cid, &m_pp); /* Load Character Leadership AA's */
database.LoadCharacterTribute(this); /* Load CharacterTribute */
database.LoadCharacterEXPModifier(this); /* Load Character EXP Modifier */
database.LoadCharacterTitleSets(this); /* Load Character Title Sets */
loaditems = database.GetInventory(this);
database.LoadCharacterData(cid, &m_pp, &m_epp);
database.LoadCharacterBandolier(cid, &m_pp);
database.LoadCharacterBindPoint(cid, &m_pp);
database.LoadCharacterMaterialColor(cid, &m_pp);
database.LoadCharacterPotionBelt(cid, &m_pp);
database.LoadCharacterCurrency(cid, &m_pp);
database.LoadCharacterSkills(cid, &m_pp);
database.LoadCharacterInspectMessage(cid, &m_inspect_message);
database.LoadCharacterSpellBook(cid, &m_pp);
database.LoadCharacterMemmedSpells(cid, &m_pp);
database.LoadCharacterLanguages(cid, &m_pp);
database.LoadCharacterLeadershipAbilities(cid, &m_pp);
database.LoadCharacterTribute(this);
database.LoadCharacterEXPModifier(this);
database.LoadCharacterTitleSets(this);
// this pattern is strange
// this is remnants of the old way of doing things
@@ -1553,10 +1554,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
}
if (SPDAT_RECORDS > 0) {
for (uint32 z = 0; z < EQ::spells::SPELL_GEM_COUNT; z++) {
if (m_pp.mem_spells[z] >= (uint32)SPDAT_RECORDS)
UnmemSpell(z, false);
}
UnmemSpellAll(false);
database.LoadBuffs(this);
uint32 max_slots = GetMaxBuffSlots();
@@ -10241,11 +10239,11 @@ void Client::Handle_OP_LoadSpellSet(const EQApplicationPacket *app)
printf("Wrong size of LoadSpellSet_Struct! Expected: %zu, Got: %i\n", sizeof(LoadSpellSet_Struct), app->size);
return;
}
int i;
LoadSpellSet_Struct* ss = (LoadSpellSet_Struct*)app->pBuffer;
for (i = 0; i < EQ::spells::SPELL_GEM_COUNT; i++) {
if (ss->spell[i] != 0xFFFFFFFF)
LoadSpellSet_Struct *ss = (LoadSpellSet_Struct *) app->pBuffer;
for (int i = 0; i < EQ::spells::SPELL_GEM_COUNT; i++) {
if (ss->spell[i] != 0xFFFFFFFF) {
UnmemSpell(i, true);
}
}
}
+23 -3
View File
@@ -78,6 +78,7 @@ Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
#include "../common/misc_functions.h"
#include "../common/events/player_event_logs.h"
#include "../common/repositories/character_corpses_repository.h"
#include "../common/repositories/character_memmed_spells_repository.h"
#include "../common/repositories/spell_buckets_repository.h"
#include "data_bucket.h"
@@ -5953,11 +5954,30 @@ void Client::UnmemSpellBySpellID(int32 spell_id)
void Client::UnmemSpellAll(bool update_client)
{
for (int spell_gem = 0; spell_gem < EQ::spells::SPELL_GEM_COUNT; spell_gem++) {
if (IsValidSpell(m_pp.mem_spells[spell_gem])) {
UnmemSpell(spell_gem, update_client);
bool has_spells = false;
for (int slot = 0; slot < EQ::spells::SPELL_GEM_COUNT; slot++) {
if (IsValidSpell(m_pp.mem_spells[slot])) {
if (slot >= EQ::spells::SPELL_GEM_COUNT || slot < 0) {
return;
}
LogSpells("Spell [{}] forgotten from slot [{}]", m_pp.mem_spells[slot], slot);
if (update_client) {
MemorizeSpell(slot, m_pp.mem_spells[slot], memSpellForget);
}
m_pp.mem_spells[slot] = UINT32_MAX;
has_spells = true;
}
}
if (has_spells) {
CharacterMemmedSpellsRepository::DeleteWhere(
database,
fmt::format("`id` = {}", character_id)
);
}
}
uint32 Client::GetSpellIDByBookSlot(int book_slot) {
+42 -87
View File
@@ -290,6 +290,12 @@ bool TaskManager::SaveClientState(Client *client, ClientTaskState *cts)
LogTasks("character_id [{}]", character_id);
auto ct = CharacterTasksRepository::NewEntity();
std::vector<CharacterTasksRepository::CharacterTasks> ct_entries;
auto cta = CharacterActivitiesRepository::NewEntity();
std::vector<CharacterActivitiesRepository::CharacterActivities> cta_entries;
if (cts->m_active_task_count > 0 ||
cts->m_active_task.task_id != TASKSLOTEMPTY ||
cts->m_active_shared_task.task_id != TASKSLOTEMPTY) {
@@ -303,7 +309,6 @@ bool TaskManager::SaveClientState(Client *client, ClientTaskState *cts)
int slot = active_task.slot;
if (active_task.updated) {
LogTasks(
"character_id [{}] updating task_index [{}] task_id [{}]",
character_id,
@@ -311,32 +316,15 @@ bool TaskManager::SaveClientState(Client *client, ClientTaskState *cts)
task_id
);
std::string query = StringFormat(
"REPLACE INTO character_tasks (charid, taskid, slot, type, acceptedtime, was_rewarded) "
"VALUES (%i, %i, %i, %i, %i, %d)",
character_id,
task_id,
slot,
static_cast<int>(task_data->type),
active_task.accepted_time,
active_task.was_rewarded
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str());
}
else {
active_task.updated = false;
}
ct.charid = character_id;
ct.taskid = task_id;
ct.slot = slot;
ct.type = static_cast<int>(task_data->type);
ct.acceptedtime = active_task.accepted_time;
ct.was_rewarded = active_task.was_rewarded;
ct_entries.emplace_back(ct);
}
std::string query =
"REPLACE INTO character_activities (charid, taskid, activityid, donecount, completed) "
"VALUES ";
int updated_activity_count = 0;
for (int activity_index = 0; activity_index < task_data->activity_count; ++activity_index) {
if (!active_task.activity[activity_index].updated) {
continue;
@@ -350,54 +338,31 @@ bool TaskManager::SaveClientState(Client *client, ClientTaskState *cts)
activity_index
);
if (updated_activity_count == 0) {
query +=
StringFormat(
"(%i, %i, %i, %i, %i)", character_id, task_id, activity_index,
active_task.activity[activity_index].done_count,
active_task.activity[activity_index].activity_state ==
ActivityCompleted
);
}
else {
query +=
StringFormat(
", (%i, %i, %i, %i, %i)", character_id, task_id, activity_index,
active_task.activity[activity_index].done_count,
active_task.activity[activity_index].activity_state ==
ActivityCompleted
);
}
updated_activity_count++;
}
if (updated_activity_count == 0) {
continue;
}
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str());
continue;
}
active_task.updated = false;
for (int activity_index = 0; activity_index < task_data->activity_count; ++activity_index) {
active_task.activity[activity_index].updated = false;
cta.charid = character_id;
cta.taskid = task_id;
cta.activityid = activity_index;
cta.donecount = active_task.activity[activity_index].done_count;
cta.completed = active_task.activity[activity_index].activity_state == ActivityCompleted ? 1 : 0;
cta_entries.emplace_back(cta);
}
}
}
if (!ct_entries.empty()) {
CharacterTasksRepository::ReplaceMany(database, ct_entries);
}
if (!cta_entries.empty()) {
CharacterActivitiesRepository::ReplaceMany(database, cta_entries);
}
if (!RuleB(TaskSystem, RecordCompletedTasks) || (cts->m_completed_tasks.size() <=
(unsigned int) cts->m_last_completed_task_loaded)) {
cts->m_last_completed_task_loaded = cts->m_completed_tasks.size();
return true;
}
const char *completed_task_query = "REPLACE INTO completed_tasks (charid, completedtime, taskid, activityid) "
"VALUES (%i, %i, %i, %i)";
auto completed_task = CompletedTasksRepository::NewEntity();
std::vector<CompletedTasksRepository::CompletedTasks> completed_task_entries;
for (
unsigned int task_index = cts->m_last_completed_task_loaded;
@@ -423,19 +388,11 @@ bool TaskManager::SaveClientState(Client *client, ClientTaskState *cts)
// This indicates this task was completed at the given time. We infer that all
// none optional activities were completed.
//
std::string query = StringFormat(
completed_task_query,
character_id,
t.completed_time,
task_id,
-1
);
auto results = database.QueryDatabase(query);
if (!results.Success()) {
LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str());
continue;
}
completed_task.charid = character_id;
completed_task.completedtime = t.completed_time;
completed_task.taskid = task_id;
completed_task.activityid = -1;
completed_task_entries.emplace_back(completed_task);
// If the Rule to record non-optional task completion is not enabled, don't save it
if (!RuleB(TaskSystem, RecordCompletedOptionalActivities)) {
@@ -449,20 +406,18 @@ bool TaskManager::SaveClientState(Client *client, ClientTaskState *cts)
continue;
}
query = StringFormat(
completed_task_query,
character_id,
t.completed_time,
task_id, activity_id
);
results = database.QueryDatabase(query);
if (!results.Success()) {
LogError(ERR_MYSQLERROR, results.ErrorMessage().c_str());
}
completed_task.charid = character_id;
completed_task.completedtime = t.completed_time;
completed_task.taskid = task_id;
completed_task.activityid = activity_id;
completed_task_entries.emplace_back(completed_task);
}
}
if (!completed_task_entries.empty()) {
CompletedTasksRepository::ReplaceMany(database, completed_task_entries);
}
cts->m_last_completed_task_loaded = cts->m_completed_tasks.size();
return true;
}
+24 -19
View File
@@ -642,8 +642,8 @@ bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Str
return false;
}
for (int i = 0; i < MAX_PP_LANGUAGE; ++i) { // Initialize Languages
pp->languages[i] = 0;
for (unsigned char & language : pp->languages) { // Initialize Languages
language = 0;
}
for (const auto& e : l) {
@@ -689,8 +689,8 @@ bool ZoneDatabase::LoadCharacterDisciplines(Client* c)
return false;
}
for (int slot_id = 0; slot_id < MAX_PP_DISCIPLINES; slot_id++) {
c->GetPP().disciplines.values[slot_id] = 0;
for (unsigned int & value : c->GetPP().disciplines.values) {
value = 0;
}
for (const auto& e : l) {
@@ -982,7 +982,6 @@ void ZoneDatabase::SaveCharacterTribute(Client* c)
}
CharacterTributeRepository::DeleteWhere(database, fmt::format("character_id = {}", c->CharacterID()));
if (tribute_count > 0) {
CharacterTributeRepository::InsertMany(database, tributes);
}
@@ -2879,14 +2878,6 @@ void ZoneDatabase::UpdateAltCurrencyValue(uint32 char_id, uint32 currency_id, ui
void ZoneDatabase::SaveBuffs(Client *client)
{
CharacterBuffsRepository::DeleteWhere(
database,
fmt::format(
"`character_id` = {}",
client->CharacterID()
)
);
auto buffs = client->GetBuffs();
const int max_buff_slots = client->GetMaxBuffSlots();
@@ -2904,6 +2895,16 @@ void ZoneDatabase::SaveBuffs(Client *client)
character_buff_count++;
}
if (character_buff_count) {
CharacterBuffsRepository::DeleteWhere(
database,
fmt::format(
"`character_id` = {}",
client->CharacterID()
)
);
}
v.reserve(character_buff_count);
for (int slot_id = 0; slot_id < max_buff_slots; slot_id++) {
@@ -3027,14 +3028,14 @@ void ZoneDatabase::LoadBuffs(Client *client)
void ZoneDatabase::SaveAuras(Client *c)
{
CharacterAurasRepository::DeleteOne(database, c->CharacterID());
const auto& auras = c->GetAuraMgr();
if (!auras.count) {
return;
}
std::vector<CharacterAurasRepository::CharacterAuras> v;
CharacterAurasRepository::DeleteOne(database, c->CharacterID());
auto e = CharacterAurasRepository::NewEntity();
const auto& auras = c->GetAuraMgr();
for (int slot_id = 0; slot_id < auras.count; ++slot_id) {
Aura* a = auras.auras[slot_id].aura;
if (a && a->AuraZones()) {
@@ -3177,7 +3178,6 @@ void ZoneDatabase::SavePetInfo(Client *client)
client->CharacterID()
)
);
if (!pet_infos.empty()) {
CharacterPetInfoRepository::InsertMany(database, pet_infos);
}
@@ -4261,6 +4261,11 @@ void ZoneDatabase::SaveCharacterEXPModifier(Client* c)
EXPModifier m = zone->exp_modifiers[c->CharacterID()];
// if both modifiers are 0, we don't need to save
if (m.aa_modifier == 0 && m.exp_modifier == 0) {
return;
}
CharacterExpModifiersRepository::ReplaceOne(
*this,
CharacterExpModifiersRepository::CharacterExpModifiers{