From c5afd7d4a34b09c1e18524d24dfcf229a2609aa6 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Sat, 13 May 2023 03:55:12 -0700 Subject: [PATCH] Fix deserialization errors for MovingPlatforms - Fixes deserialization errors for MovingPlatforms that did not have an attached_path, but had a MovingPlatform component >= id 0. --- dGame/Entity.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/dGame/Entity.cpp b/dGame/Entity.cpp index b9fc79fb..fdd7ce6f 100644 --- a/dGame/Entity.cpp +++ b/dGame/Entity.cpp @@ -690,23 +690,11 @@ void Entity::Initialize() { } std::string pathName = GetVarAsString(u"attached_path"); - const Path* path = dZoneManager::Instance()->GetZone()->GetPath(pathName); - //Check to see if we have an attached path and add the appropiate component to handle it: - if (path){ - // if we have a moving platform path, then we need a moving platform component - if (path->pathType == PathType::MovingPlatform) { - MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName); - m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat)); - // else if we are a movement path - } /*else if (path->pathType == PathType::Movement) { - auto movementAIcomp = GetComponent(); - if (movementAIcomp){ - // TODO: set path in existing movementAIComp - } else { - // TODO: create movementAIcomp and set path - } - }*/ + int32_t movingPlatformComponentId = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::MOVING_PLATFORM, -1); + if (movingPlatformComponentId >= 0 || !pathName.empty()) { + MovingPlatformComponent* plat = new MovingPlatformComponent(this, pathName); + m_Components.insert(std::make_pair(eReplicaComponentType::MOVING_PLATFORM, plat)); } int proximityMonitorID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::PROXIMITY_MONITOR);