From 5a4a5a17db9c612f5265d19aaa5dd22ae408cf34 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 23 Jan 2017 01:56:15 +0100 Subject: [PATCH] - added core lump checks for ZScript. - load internal shaders only from file 0. This does not contain aborts, like most of the other checks,but it will now refuse to load any core shader file from anything but gzdoom.pk3. --- src/gl/shaders/gl_shader.cpp | 6 +++--- src/gl/shaders/gl_shaderprogram.cpp | 2 +- src/scripting/zscript/zcc_parser.cpp | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index b7d8335f8..327ac5fd4 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -60,15 +60,15 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * static char buffer[10000]; FString error; - int i_lump = Wads.CheckNumForFullName("shaders/glsl/shaderdefs.i"); + int i_lump = Wads.CheckNumForFullName("shaders/glsl/shaderdefs.i", 0); if (i_lump == -1) I_Error("Unable to load 'shaders/glsl/shaderdefs.i'"); FMemLump i_data = Wads.ReadLump(i_lump); - int vp_lump = Wads.CheckNumForFullName(vert_prog_lump); + int vp_lump = Wads.CheckNumForFullName(vert_prog_lump, 0); if (vp_lump == -1) I_Error("Unable to load '%s'", vert_prog_lump); FMemLump vp_data = Wads.ReadLump(vp_lump); - int fp_lump = Wads.CheckNumForFullName(frag_prog_lump); + int fp_lump = Wads.CheckNumForFullName(frag_prog_lump, 0); if (fp_lump == -1) I_Error("Unable to load '%s'", frag_prog_lump); FMemLump fp_data = Wads.ReadLump(fp_lump); diff --git a/src/gl/shaders/gl_shaderprogram.cpp b/src/gl/shaders/gl_shaderprogram.cpp index 1ed19913a..7a4690874 100644 --- a/src/gl/shaders/gl_shaderprogram.cpp +++ b/src/gl/shaders/gl_shaderprogram.cpp @@ -89,7 +89,7 @@ void FShaderProgram::CreateShader(ShaderType type) void FShaderProgram::Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion) { - int lump = Wads.CheckNumForFullName(lumpName); + int lump = Wads.CheckNumForFullName(lumpName, 0); if (lump == -1) I_FatalError("Unable to load '%s'", lumpName); FString code = Wads.ReadLump(lump).GetString().GetChars(); Compile(type, lumpName, code, defines, maxGlslVersion); diff --git a/src/scripting/zscript/zcc_parser.cpp b/src/scripting/zscript/zcc_parser.cpp index 78458876a..872ab2cc8 100644 --- a/src/scripting/zscript/zcc_parser.cpp +++ b/src/scripting/zscript/zcc_parser.cpp @@ -316,6 +316,8 @@ static void DoParse(int lumpnum) FScanner sc; void *parser; ZCCToken value; + auto baselump = lumpnum; + auto fileno = Wads.GetLumpFile(lumpnum); parser = ZCCParseAlloc(malloc); ZCCParseState state; @@ -344,6 +346,13 @@ static void DoParse(int lumpnum) } else { + auto fileno2 = Wads.GetLumpFile(lumpnum); + if (fileno == 0 && fileno2 != 0) + { + I_FatalError("File %s is overriding core lump %s.", + Wads.GetWadFullName(Wads.GetLumpFile(baselump)), Includes[i].GetChars()); + } + ParseSingleFile(nullptr, lumpnum, parser, state); } }