From 976bd3c41b7fcd0262db40b010c365449bb9c94e Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Tue, 16 Aug 2022 20:53:28 -0500 Subject: [PATCH] Selective saving for map and location (#732) * Don't save the map and char location info if we are in an instanced * LUP worlds will be handled in a future PR * simplify check --- dGame/Character.cpp | 4 ++-- .../ControllablePhysicsComponent.cpp | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/dGame/Character.cpp b/dGame/Character.cpp index 0b92f0aa..440c30c1 100644 --- a/dGame/Character.cpp +++ b/dGame/Character.cpp @@ -301,9 +301,9 @@ void Character::SaveXMLToDatabase() { character->SetAttribute("gm", m_GMLevel); character->SetAttribute("cc", m_Coins); + auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID(); // lzid garbage, binary concat of zoneID, zoneInstance and zoneClone - if (Game::server->GetZoneID() != 0) { - auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID(); + if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) { uint64_t lzidConcat = zoneInfo.GetCloneID(); lzidConcat = (lzidConcat << 16) | uint16_t(zoneInfo.GetInstanceID()); lzidConcat = (lzidConcat << 16) | uint16_t(zoneInfo.GetMapID()); diff --git a/dGame/dComponents/ControllablePhysicsComponent.cpp b/dGame/dComponents/ControllablePhysicsComponent.cpp index 19c17035..471b9ca1 100644 --- a/dGame/dComponents/ControllablePhysicsComponent.cpp +++ b/dGame/dComponents/ControllablePhysicsComponent.cpp @@ -11,6 +11,7 @@ #include "CDClientManager.h" #include "EntityManager.h" #include "Character.h" +#include "dZoneManager.h" ControllablePhysicsComponent::ControllablePhysicsComponent(Entity* entity) : Component(entity) { m_Position = {}; @@ -163,13 +164,17 @@ void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) { return; } - character->SetAttribute("lzx", m_Position.x); - character->SetAttribute("lzy", m_Position.y); - character->SetAttribute("lzz", m_Position.z); - character->SetAttribute("lzrx", m_Rotation.x); - character->SetAttribute("lzry", m_Rotation.y); - character->SetAttribute("lzrz", m_Rotation.z); - character->SetAttribute("lzrw", m_Rotation.w); + auto zoneInfo = dZoneManager::Instance()->GetZone()->GetZoneID(); + + if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) { + character->SetAttribute("lzx", m_Position.x); + character->SetAttribute("lzy", m_Position.y); + character->SetAttribute("lzz", m_Position.z); + character->SetAttribute("lzrx", m_Rotation.x); + character->SetAttribute("lzry", m_Rotation.y); + character->SetAttribute("lzrz", m_Rotation.z); + character->SetAttribute("lzrw", m_Rotation.w); + } } void ControllablePhysicsComponent::SetPosition(const NiPoint3& pos) {