From 28fab953f54a1e0c819dc4b5d40ab9afda70752d Mon Sep 17 00:00:00 2001 From: Sven Eberhardt Date: Tue, 22 Sep 2015 23:46:26 -0400 Subject: [PATCH] Do not try to load a definition directly from within .ocf and .ocs folders. Definitions should be only in .ocd files. Although it might be nice e.g. to have mesh material directly in the scenario instead of in a .ocd subfolder, the engine tried to load the map image files as potential textures. It was also undocumented behavior. --- src/object/C4DefList.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/object/C4DefList.cpp b/src/object/C4DefList.cpp index 6ef49d85d..3e81cfd7d 100644 --- a/src/object/C4DefList.cpp +++ b/src/object/C4DefList.cpp @@ -83,10 +83,11 @@ int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat, C4Group hChild; bool fPrimaryDef=false; bool fThisSearchMessage=false; + bool can_be_primary_def = SEqualNoCase(GetExtension(hGroup.GetName()), "ocd"); // This search message if (fSearchMessage) - if (SEqualNoCase(GetExtension(hGroup.GetName()),"ocd") + if (can_be_primary_def || SEqualNoCase(GetExtension(hGroup.GetName()),"ocs") || SEqualNoCase(GetExtension(hGroup.GetName()),"ocf")) { @@ -97,12 +98,19 @@ int32_t C4DefList::Load(C4Group &hGroup, DWORD dwLoadWhat, if (fThisSearchMessage) { LogF("%s...",GetFilename(hGroup.GetName())); } // Load primary definition - if ((nDef=new C4Def)) + if (can_be_primary_def) { - if (nDef->Load(hGroup, *SkeletonLoader, dwLoadWhat, szLanguage, pSoundSystem) && Add(nDef, fOverload)) - { iResult++; fPrimaryDef=true; } - else - { delete nDef; } + if ((nDef = new C4Def)) + { + if (nDef->Load(hGroup, *SkeletonLoader, dwLoadWhat, szLanguage, pSoundSystem) && Add(nDef, fOverload)) + { + iResult++; fPrimaryDef = true; + } + else + { + delete nDef; + } + } } // Load sub definitions