From f9f6d1f9634adf61151129457adfc50a28ea2e4c Mon Sep 17 00:00:00 2001 From: Aruki Date: Sun, 14 May 2017 21:30:50 -0600 Subject: [PATCH] Fixed bug where asset properties on new instances are created with the wrong length --- src/Core/Resource/Script/IProperty.cpp | 6 ++++++ src/Core/Resource/Script/IProperty.h | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Core/Resource/Script/IProperty.cpp b/src/Core/Resource/Script/IProperty.cpp index c73fd152..0fca29de 100644 --- a/src/Core/Resource/Script/IProperty.cpp +++ b/src/Core/Resource/Script/IProperty.cpp @@ -94,6 +94,12 @@ bool IProperty::MatchesDefault() else return pkValue->Matches(pkDefault); } +// ************ TAssetProperty ************ +TAssetProperty::TAssetProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent) + : TTypedProperty(pTemp, pInstance, pParent, CAssetID::InvalidID( pTemp->Game() )) +{ +} + // ************ CPropertyStruct ************ void CPropertyStruct::Copy(const IProperty *pkProp) { diff --git a/src/Core/Resource/Script/IProperty.h b/src/Core/Resource/Script/IProperty.h index 2a5831d4..1756d726 100644 --- a/src/Core/Resource/Script/IProperty.h +++ b/src/Core/Resource/Script/IProperty.h @@ -150,7 +150,10 @@ public: class TAssetProperty : public TTypedProperty { public: - IMPLEMENT_PROPERTY_CTORS(TAssetProperty, CAssetID) + TAssetProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent); // Can't be in the header because needs to check the template to set the correct ID length + TAssetProperty(IPropertyTemplate *pTemp, CScriptObject *pInstance, CPropertyStruct *pParent, CAssetID v) + : TTypedProperty(pTemp, pInstance, pParent, v) {} + IMPLEMENT_PROPERTY_CLONE(TAssetProperty) virtual bool MatchesDefault() { return !Get().IsValid(); } virtual bool ShouldCook() { return true; }