From eb9928e029cba6148aef0ff8bf2850264ce1eca3 Mon Sep 17 00:00:00 2001 From: Sahin Serdar Kocdemir Date: Fri, 9 Oct 2020 07:28:15 +0100 Subject: [PATCH] fix for fbx files using stringray materials; --- code/AssetLib/FBX/FBXProperties.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/FBX/FBXProperties.cpp b/code/AssetLib/FBX/FBXProperties.cpp index 25282b637..a3a95228e 100644 --- a/code/AssetLib/FBX/FBXProperties.cpp +++ b/code/AssetLib/FBX/FBXProperties.cpp @@ -76,23 +76,30 @@ Property* ReadTypedProperty(const Element& element) ai_assert(element.KeyToken().StringContents() == "P"); const TokenList& tok = element.Tokens(); - ai_assert(tok.size() >= 5); + if (tok.size() < 2) { + return nullptr; + } const std::string& s = ParseTokenAsString(*tok[1]); const char* const cs = s.c_str(); if (!strcmp(cs,"KString")) { + ai_assert(tok.size() >= 5); return new TypedProperty(ParseTokenAsString(*tok[4])); } else if (!strcmp(cs,"bool") || !strcmp(cs,"Bool")) { + ai_assert(tok.size() >= 5); return new TypedProperty(ParseTokenAsInt(*tok[4]) != 0); } else if (!strcmp(cs, "int") || !strcmp(cs, "Int") || !strcmp(cs, "enum") || !strcmp(cs, "Enum")) { + ai_assert(tok.size() >= 5); return new TypedProperty(ParseTokenAsInt(*tok[4])); } else if (!strcmp(cs, "ULongLong")) { + ai_assert(tok.size() >= 5); return new TypedProperty(ParseTokenAsID(*tok[4])); } else if (!strcmp(cs, "KTime")) { + ai_assert(tok.size() >= 5); return new TypedProperty(ParseTokenAsInt64(*tok[4])); } else if (!strcmp(cs,"Vector3D") || @@ -103,6 +110,7 @@ Property* ReadTypedProperty(const Element& element) !strcmp(cs,"Lcl Rotation") || !strcmp(cs,"Lcl Scaling") ) { + ai_assert(tok.size() >= 7); return new TypedProperty(aiVector3D( ParseTokenAsFloat(*tok[4]), ParseTokenAsFloat(*tok[5]), @@ -110,6 +118,7 @@ Property* ReadTypedProperty(const Element& element) ); } else if (!strcmp(cs,"double") || !strcmp(cs,"Number") || !strcmp(cs,"Float") || !strcmp(cs,"FieldOfView") || !strcmp( cs, "UnitScaleFactor" ) ) { + ai_assert(tok.size() >= 5); return new TypedProperty(ParseTokenAsFloat(*tok[4])); } return nullptr;