diff --git a/zone/client.cpp b/zone/client.cpp index 786ecbfaf..91cdcb4fa 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -995,6 +995,8 @@ bool Client::Save(uint8 iCommitNow) { if(!ClientDataLoaded()) return false; + BenchTimer timer; + /* Wrote current basics to PP for saves */ if (!m_lock_save_position) { m_pp.x = m_Position.x; @@ -1022,6 +1024,8 @@ bool Client::Save(uint8 iCommitNow) { m_pp.endurance = current_endurance; } + database.TransactionBegin(); + /* Save Character Currency */ database.SaveCharacterCurrency(CharacterID(), &m_pp); @@ -1105,6 +1109,10 @@ bool Client::Save(uint8 iCommitNow) { database.botdb.SaveBotSettings(this); } + database.TransactionCommit(); + + LogInfo("Save for [{}] took [{}]", GetCleanName(), timer.elapsed()); + return true; } diff --git a/zone/client.h b/zone/client.h index 6b6cb15ed..c56815d90 100644 --- a/zone/client.h +++ b/zone/client.h @@ -483,6 +483,9 @@ public: virtual bool Save() { return Save(0); } bool Save(uint8 iCommitNow); // 0 = delayed, 1=async now, 2=sync now + inline void SaveCharacterData() { + database.SaveCharacterData(this, &m_pp, &m_epp); + }; /* New PP Save Functions */ bool SaveCurrency(){ return database.SaveCharacterCurrency(this->CharacterID(), &m_pp); } diff --git a/zone/client_process.cpp b/zone/client_process.cpp index 46783eb52..c9de4c160 100644 --- a/zone/client_process.cpp +++ b/zone/client_process.cpp @@ -217,6 +217,8 @@ bool Client::Process() { GetMerc()->Depop(); } instalog = true; + + camp_timer.Disable(); } if (IsStunned() && stunned_timer.Check()) diff --git a/zone/mob.cpp b/zone/mob.cpp index 16978d3e3..cb4171b38 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -4621,8 +4621,12 @@ void Mob::SetZone(uint32 zone_id, uint32 instance_id) { CastToClient()->GetPP().zone_id = zone_id; CastToClient()->GetPP().zoneInstance = instance_id; + CastToClient()->SaveCharacterData(); + } + + if (!IsClient()) { + Save(); // bots or other things might be covered here for some reason } - Save(); } void Mob::Kill() { diff --git a/zone/zoning.cpp b/zone/zoning.cpp index f7a32e502..e8a4b5461 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -528,8 +528,12 @@ void Client::DoZoneSuccess(ZoneChange_Struct *zc, uint16 zone_id, uint32 instanc m_pp.zone_id = zone_id; m_pp.zoneInstance = instance_id; - //Force a save so its waiting for them when they zone - Save(2); + // save character position + m_pp.x = m_Position.x; + m_pp.y = m_Position.y; + m_pp.z = m_Position.z; + m_pp.heading = m_Position.w; + SaveCharacterData(); m_lock_save_position = true;