From 3344e73fedd4957d3988894ef80d0f8e4f32668f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Sep 2020 20:51:02 +0200 Subject: [PATCH] - fixed some crashes in the .def parser and texture initialization code. --- source/build/include/scriptfile.h | 35 ++++++++++++++++++++--------- source/core/textures/buildtiles.cpp | 8 +++---- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/source/build/include/scriptfile.h b/source/build/include/scriptfile.h index 383b31805..c7aaf4fa8 100644 --- a/source/build/include/scriptfile.h +++ b/source/build/include/scriptfile.h @@ -13,40 +13,55 @@ using scriptfile = FScanner; inline int32_t scriptfile_getnumber(scriptfile *sf, int32_t *num) { bool res = sf->GetNumber(); - if (res) *num = sf->Number; - else *num = 0; + if (num) + { + if (res) *num = sf->Number; + else *num = 0; + } return !res; } inline int32_t scriptfile_getdouble(scriptfile *sf, double *num) { bool res = sf->GetFloat(); - if (res) *num = sf->Float; - else *num = 0; + if (num) + { + if (res) *num = sf->Float; + else *num = 0; + } return !res; } inline int32_t scriptfile_getstring(scriptfile *sf, FString *st) { bool res = sf->GetString(); - if (res) *st = sf->String; - else *st = ""; + if (st) + { + if (res) *st = sf->String; + else *st = ""; + } return !res; } inline int32_t scriptfile_getsymbol(scriptfile *sf, int32_t *num) { bool res = sf->GetNumber(true); - if (res) *num = sf->Number; - else *num = 0; + if (num) + { + if (res) *num = sf->Number; + else *num = 0; + } return !res; } inline int32_t scriptfile_getsymbol(scriptfile* sf, int64_t* num) { bool res = sf->GetNumber(true); - if (res) *num = sf->BigNumber; - else *num = 0; + if (num) + { + if (res) *num = sf->BigNumber; + else *num = 0; + } return !res; } diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index fe2816442..331f57604 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -542,10 +542,10 @@ void BuildTiles::PostLoadSetup() auto tex = rep.faces[0]; // Make a copy so that multiple appearances of the same texture can be handled. They will all refer to the same internal texture anyway. tex = MakeGameTexture(tex->GetTexture(), "", ETextureType::Any); - tex->SetGlowmap(glowTex->GetTexture()); - tex->SetDetailmap(detailTex->GetTexture()); - tex->SetNormalmap(normalTex->GetTexture()); - tex->SetSpecularmap(specTex->GetTexture()); + if (glowTex) tex->SetGlowmap(glowTex->GetTexture()); + if (detailTex) tex->SetDetailmap(detailTex->GetTexture()); + if (normalTex) tex->SetNormalmap(normalTex->GetTexture()); + if (specTex) tex->SetSpecularmap(specTex->GetTexture()); tex->SetDetailScale(scalex, scaley); rep.faces[0] = tex; }