- fixed some crashes in the .def parser and texture initialization code.

This commit is contained in:
Christoph Oelckers 2020-09-25 20:51:02 +02:00
parent 73c57af9ca
commit 3344e73fed
2 changed files with 29 additions and 14 deletions

View file

@ -13,40 +13,55 @@ using scriptfile = FScanner;
inline int32_t scriptfile_getnumber(scriptfile *sf, int32_t *num) inline int32_t scriptfile_getnumber(scriptfile *sf, int32_t *num)
{ {
bool res = sf->GetNumber(); bool res = sf->GetNumber();
if (res) *num = sf->Number; if (num)
else *num = 0; {
if (res) *num = sf->Number;
else *num = 0;
}
return !res; return !res;
} }
inline int32_t scriptfile_getdouble(scriptfile *sf, double *num) inline int32_t scriptfile_getdouble(scriptfile *sf, double *num)
{ {
bool res = sf->GetFloat(); bool res = sf->GetFloat();
if (res) *num = sf->Float; if (num)
else *num = 0; {
if (res) *num = sf->Float;
else *num = 0;
}
return !res; return !res;
} }
inline int32_t scriptfile_getstring(scriptfile *sf, FString *st) inline int32_t scriptfile_getstring(scriptfile *sf, FString *st)
{ {
bool res = sf->GetString(); bool res = sf->GetString();
if (res) *st = sf->String; if (st)
else *st = ""; {
if (res) *st = sf->String;
else *st = "";
}
return !res; return !res;
} }
inline int32_t scriptfile_getsymbol(scriptfile *sf, int32_t *num) inline int32_t scriptfile_getsymbol(scriptfile *sf, int32_t *num)
{ {
bool res = sf->GetNumber(true); bool res = sf->GetNumber(true);
if (res) *num = sf->Number; if (num)
else *num = 0; {
if (res) *num = sf->Number;
else *num = 0;
}
return !res; return !res;
} }
inline int32_t scriptfile_getsymbol(scriptfile* sf, int64_t* num) inline int32_t scriptfile_getsymbol(scriptfile* sf, int64_t* num)
{ {
bool res = sf->GetNumber(true); bool res = sf->GetNumber(true);
if (res) *num = sf->BigNumber; if (num)
else *num = 0; {
if (res) *num = sf->BigNumber;
else *num = 0;
}
return !res; return !res;
} }

View file

@ -542,10 +542,10 @@ void BuildTiles::PostLoadSetup()
auto tex = rep.faces[0]; 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. // 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 = MakeGameTexture(tex->GetTexture(), "", ETextureType::Any);
tex->SetGlowmap(glowTex->GetTexture()); if (glowTex) tex->SetGlowmap(glowTex->GetTexture());
tex->SetDetailmap(detailTex->GetTexture()); if (detailTex) tex->SetDetailmap(detailTex->GetTexture());
tex->SetNormalmap(normalTex->GetTexture()); if (normalTex) tex->SetNormalmap(normalTex->GetTexture());
tex->SetSpecularmap(specTex->GetTexture()); if (specTex) tex->SetSpecularmap(specTex->GetTexture());
tex->SetDetailScale(scalex, scaley); tex->SetDetailScale(scalex, scaley);
rep.faces[0] = tex; rep.faces[0] = tex;
} }