From cd783c4adef69b583d14f18258b47610dd55e034 Mon Sep 17 00:00:00 2001 From: George Tokmaji Date: Sun, 5 May 2024 18:15:04 +0200 Subject: [PATCH] C4Section: Don't load the material enumeration and reinitialize the texture map if the materials and textures were copied from another section This allows `CPattern` to reuse the cached patterns, massively cutting down on RAM costs - with 2000 20x20 sections, 10 GB of RAM were previously used just for cached patterns. --- src/C4Section.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/C4Section.cpp b/src/C4Section.cpp index 546cd77f9..7640bf79f 100644 --- a/src/C4Section.cpp +++ b/src/C4Section.cpp @@ -229,16 +229,16 @@ bool C4Section::InitMaterialTexture(C4Section *const fallback) // Logs Log(C4ResStrTableKey::IDS_PRC_TEXTURES, tex_count); Log(C4ResStrTableKey::IDS_PRC_MATERIALS, mat_count); - } - // Load material enumeration - if (!Material.LoadEnumeration(Group)) - { - LogFatal(C4ResStrTableKey::IDS_PRC_NOMATENUM); return false; - } + // Load material enumeration + if (!Material.LoadEnumeration(Group)) + { + LogFatal(C4ResStrTableKey::IDS_PRC_NOMATENUM); return false; + } - // Initialize texture map - TextureMap.Init(); + // Initialize texture map + TextureMap.Init(); + } // Cross map mats (after texture init, because Material-Texture-combinations are used) Material.CrossMapMaterials();