From b3548de7da93f6bdbc6af4105df7c99c465540f6 Mon Sep 17 00:00:00 2001 From: David Markowitz Date: Sat, 18 May 2024 03:52:36 -0700 Subject: [PATCH] debug logs and spacing --- dGame/dComponents/ModelComponent.cpp | 7 +++++-- dGame/dComponents/PropertyManagementComponent.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dGame/dComponents/ModelComponent.cpp b/dGame/dComponents/ModelComponent.cpp index 733b17ee..91680987 100644 --- a/dGame/dComponents/ModelComponent.cpp +++ b/dGame/dComponents/ModelComponent.cpp @@ -21,9 +21,11 @@ void ModelComponent::LoadBehaviors() { auto behaviors = GeneralUtils::SplitString(m_Parent->GetVar(u"userModelBehaviors"), ','); for (const auto& behavior : behaviors) { if (behavior.empty()) continue; + const auto behaviorId = GeneralUtils::TryParse(behavior); if (!behaviorId.has_value() || behaviorId.value() == 0) continue; - LOG("Loading behavior %d", behaviorId.value()); + + LOG_DEBUG("Loading behavior %d", behaviorId.value()); auto& inserted = m_Behaviors.emplace_back(); inserted.SetBehaviorId(*behaviorId); @@ -31,7 +33,7 @@ void ModelComponent::LoadBehaviors() { tinyxml2::XMLDocument behaviorXml; auto res = behaviorXml.Parse(behaviorStr.c_str(), behaviorStr.size()); - LOG("Behavior %i %d: %s", res, behaviorId.value(), behaviorStr.c_str()); + LOG_DEBUG("Behavior %i %d: %s", res, behaviorId.value(), behaviorStr.c_str()); const auto* const behaviorRoot = behaviorXml.FirstChildElement("Behavior"); if (!behaviorRoot) { @@ -108,6 +110,7 @@ std::array, 5> ModelComponent::GetBehaviorsForSa if (behavior.GetBehaviorId() == -1) continue; auto& [id, behaviorData] = toReturn[i]; id = behavior.GetBehaviorId(); + tinyxml2::XMLDocument doc; auto* root = doc.NewElement("Behavior"); behavior.Serialize(*root); diff --git a/dGame/dComponents/PropertyManagementComponent.cpp b/dGame/dComponents/PropertyManagementComponent.cpp index ae046a26..d7be22ac 100644 --- a/dGame/dComponents/PropertyManagementComponent.cpp +++ b/dGame/dComponents/PropertyManagementComponent.cpp @@ -597,8 +597,11 @@ void PropertyManagementComponent::Load() { std::ostringstream userModelBehavior; bool firstAdded = false; - for (const auto& behavior : databaseModel.behaviors) { - if (behavior == LWOOBJID_EMPTY) continue; + for (auto behavior : databaseModel.behaviors) { + if (behavior < 0) { + LOG("Invalid behavior ID: %d, removing behavior reference from model", behavior); + behavior = 0; + } if (firstAdded) userModelBehavior << ","; userModelBehavior << behavior; firstAdded = true;