aboutsummaryrefslogtreecommitdiffstats
path: root/code/renderer
diff options
context:
space:
mode:
Diffstat (limited to 'code/renderer')
-rw-r--r--code/renderer/tr_bsp.c3
-rw-r--r--code/renderer/tr_local.h10
-rw-r--r--code/renderer/tr_shader.c7
3 files changed, 14 insertions, 6 deletions
diff --git a/code/renderer/tr_bsp.c b/code/renderer/tr_bsp.c
index c340e13..72e88f3 100644
--- a/code/renderer/tr_bsp.c
+++ b/code/renderer/tr_bsp.c
@@ -1321,6 +1321,9 @@ static void R_LoadSubmodels( lump_t *l ) {
model = R_AllocModel();
assert( model != NULL ); // this should never happen
+ if ( model == NULL ) {
+ ri.Error(ERR_DROP, "R_LoadSubmodels: R_AllocModel() failed");
+ }
model->type = MOD_BRUSH;
model->bmodel = out;
diff --git a/code/renderer/tr_local.h b/code/renderer/tr_local.h
index 52a9e37..0da894e 100644
--- a/code/renderer/tr_local.h
+++ b/code/renderer/tr_local.h
@@ -322,10 +322,12 @@ typedef struct {
struct shaderCommands_s;
-#define LIGHTMAP_2D -4 // shader is for 2D rendering
-#define LIGHTMAP_BY_VERTEX -3 // pre-lit triangle models
-#define LIGHTMAP_WHITEIMAGE -2
-#define LIGHTMAP_NONE -1
+// any change in the LIGHTMAP_* defines here MUST be reflected in
+// R_FindShader() in tr_bsp.c
+#define LIGHTMAP_2D -4 // shader is for 2D rendering
+#define LIGHTMAP_BY_VERTEX -3 // pre-lit triangle models
+#define LIGHTMAP_WHITEIMAGE -2
+#define LIGHTMAP_NONE -1
typedef enum {
CT_FRONT_SIDED,
diff --git a/code/renderer/tr_shader.c b/code/renderer/tr_shader.c
index a714873..7a44d35 100644
--- a/code/renderer/tr_shader.c
+++ b/code/renderer/tr_shader.c
@@ -1432,7 +1432,6 @@ static qboolean ParseShader( char **text )
// stage definition
else if ( token[0] == '{' )
{
- // 20051019 misantropia -- fix buffer overrun.
if ( s >= MAX_SHADER_STAGES ) {
ri.Printf( PRINT_WARNING, "WARNING: too many stages in shader %s\n", shader.name );
return qfalse;
@@ -2447,6 +2446,10 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag
// lightmaps
if ( lightmapIndex >= 0 && lightmapIndex >= tr.numLightmaps ) {
lightmapIndex = LIGHTMAP_BY_VERTEX;
+ } else if ( lightmapIndex < LIGHTMAP_2D ) {
+ // negative lightmap indexes cause stray pointers (think tr.lightmaps[lightmapIndex])
+ ri.Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndex );
+ lightmapIndex = LIGHTMAP_BY_VERTEX;
}
COM_StripExtension(name, strippedName, sizeof(strippedName));
@@ -2581,7 +2584,7 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_
hash = generateHashValue(name, FILE_HASH_SIZE);
- // 20051020 misantropia -- probably not necessary since this function
+ // probably not necessary since this function
// only gets called from tr_font.c with lightmapIndex == LIGHTMAP_2D
// but better safe than sorry.
if ( lightmapIndex >= tr.numLightmaps ) {