Merge pull request #9 from ScatterBox/main

Fix map crash if there is no skybox specified
This commit is contained in:
Ian 2023-01-15 15:29:13 -05:00 committed by GitHub
commit 461909e146
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 69 additions and 83 deletions

View file

@ -865,7 +865,7 @@ void Draw_ConsoleBackground (void)
//GL_SetCanvas (CANVAS_CONSOLE); //in case this is called from weird places
Draw_FillByColor (0, 0, vid.conwidth, vid.conheight, 0, 0, 0, 1);
Draw_FillByColor (0, 0, vid.conwidth, vid.conheight, 0, 0, 0, 0);
}
/*
@ -1205,10 +1205,10 @@ gltexture_t *loadtextureimage (char* filename)
int w, h;
data = Image_LoadImage (filename, &w, &h);
if(data == NULL)
if(!data)
{
Sys_Error("loadtextureimage: Cannot load the image %s\n", filename);
return 0;
//return 0;
}
gl.gltexture = TexMgr_LoadImage (NULL, filename, w, h, SRC_RGBA, data, filename, sizeof(int)*2, TEXPREF_ALPHA | TEXPREF_NEAREST | TEXPREF_NOPICMIP);

View file

@ -337,6 +337,8 @@ qmodel_t *Mod_LoadModel (qmodel_t *mod, qboolean crash)
buf = (unsigned*)COM_LoadStackFile ("models/missing_model.mdl", stackbuf, sizeof(stackbuf), NULL);
if (buf){
Con_Printf ("Missing model %s substituted\n", mod->name);
}else if(!buf){
Con_Printf ("Missing model could not be substituted", mod->name);
}
return mod;
}
@ -702,7 +704,7 @@ void Mod_LoadTextures (lump_t *l)
}
}
strcpy(loading_name, mt->name);
//free (pixels);
//free (tx_pixels);
loading_cur_step++;
SCR_UpdateScreen();
//johnfitz

View file

@ -225,14 +225,14 @@ void Sky_NewMap (void)
skybox_name[0] = 0;
for (i=0; i<6; i++)
skybox_textures[i] = NULL;
skyfog = r_skyfog.value;
//skyfog = r_skyfog.value;
//
// read worldspawn (this is so ugly, and shouldn't it be done on the server?)
//
data = cl.worldmodel->entities;
if (!data)
return; //FIXME: how could this possibly ever happen? -- if there's no
Sys_Error("Could not init Sky_NewMap"); //FIXME: how could this possibly ever happen? -- if there's no
// worldspawn then the sever wouldn't send the loadmap message to the client
data = COM_Parse(data);
@ -261,8 +261,8 @@ void Sky_NewMap (void)
if (!strcmp("sky", key))
Sky_LoadSkyBox(value);
if (!strcmp("skyfog", key))
skyfog = atof(value);
//if (!strcmp("skyfog", key))
//skyfog = atof(value);
#if 1 //also accept non-standard keys
else if (!strcmp("skyname", key)) //half-life
@ -808,7 +808,7 @@ void Sky_DrawFaceQuad (glpoly_t *p)
float *v;
int i;
if (gl_mtexable && r_skyalpha.value >= 1.0)
if (gl_mtexable) // && r_skyalpha.value >= 1.0
{
GL_Bind (solidskytexture);
GL_EnableMultitexture();
@ -836,7 +836,7 @@ void Sky_DrawFaceQuad (glpoly_t *p)
GL_Bind (solidskytexture);
//if (r_skyalpha.value < 1.0)
glColor3f (1, 1, 1);
//glColor3f (1, 1, 1);
glBegin (GL_QUADS);
for (i=0, v=p->verts[0] ; i<4 ; i++, v+=VERTEXSIZE)
@ -847,22 +847,22 @@ void Sky_DrawFaceQuad (glpoly_t *p)
}
glEnd ();
//GL_Bind (alphaskytexture);
//glEnable (GL_BLEND);
GL_Bind (alphaskytexture);
glEnable (GL_BLEND);
//if (r_skyalpha.value < 1.0)
//glColor4f (1, 1, 1, r_skyalpha.value);
//glBegin (GL_QUADS);
//for (i=0, v=p->verts[0] ; i<4 ; i++, v+=VERTEXSIZE)
//{
//Sky_GetTexCoord (v, 16, &s, &t);
//glTexCoord2f (s, t);
//glVertex3fv (v);
//}
//glEnd ();
glBegin (GL_QUADS);
for (i=0, v=p->verts[0] ; i<4 ; i++, v+=VERTEXSIZE)
{
Sky_GetTexCoord (v, 16, &s, &t);
glTexCoord2f (s, t);
glVertex3fv (v);
}
glEnd ();
//glDisable (GL_BLEND);
glDisable (GL_BLEND);
rs_skypolys++;
rs_skypasses += 2;
@ -959,15 +959,15 @@ void Sky_DrawSkyLayers (void)
{
int i;
//if (r_skyalpha.value < 1.0)
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if (r_skyalpha.value < 1.0)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
for (i=0 ; i<6 ; i++)
if (skymins[0][i] < skymaxs[0][i] && skymins[1][i] < skymaxs[1][i])
Sky_DrawFace (i);
//if (r_skyalpha.value < 1.0)
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
if (r_skyalpha.value < 1.0)
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
}
/*
@ -1002,18 +1002,18 @@ void Sky_DrawSky (void)
/*if (Fog_GetDensity() > 0)
glColor3fv (Fog_GetColor());
else*/
//glColor3fv (skyflatcolor);
//glColor3fv (skyflatcolor);
//glColor3fv (Fog_GetColor());
Sky_ProcessTextureChains ();
Sky_ProcessEntities ();
glColor3f (1, 1, 1);
//glColor3f (1, 1, 1);
glEnable (GL_TEXTURE_2D);
//
// render slow sky: cloud layers or skybox
//
/*if (!r_fastsky.value && !(Fog_GetDensity() > 0))
if (!r_fastsky.value)
{
glDepthFunc(GL_GEQUAL);
glDepthMask(0);
@ -1025,11 +1025,6 @@ void Sky_DrawSky (void)
glDepthMask(1);
glDepthFunc(GL_LEQUAL);
}*/
glDepthFunc(GL_GEQUAL);
glDepthMask(0);
Sky_DrawSkyBox ();
glDepthMask(1);
glDepthFunc(GL_LEQUAL);
}
Fog_EnableGFog ();
}

View file

@ -1191,9 +1191,9 @@ void R_DrawAliasModel (entity_t *e)
glBlendFunc (GL_ONE, GL_ONE);
glDepthMask(GL_FALSE);
glColor3f(entalpha,entalpha,entalpha);
//Fog_StartAdditive ();
Fog_StartAdditive ();
GL_DrawAliasFrame (paliashdr, lerpdata);
//Fog_StopAdditive ();
Fog_StopAdditive ();
glDepthMask(GL_TRUE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
@ -1254,9 +1254,9 @@ void R_DrawAliasModel (entity_t *e)
glDepthMask(GL_FALSE);
shading = false;
glColor3f(entalpha,entalpha,entalpha);
//Fog_StartAdditive ();
Fog_StartAdditive ();
GL_DrawAliasFrame (paliashdr, lerpdata);
//Fog_StopAdditive ();
Fog_StopAdditive ();
glDepthMask(GL_TRUE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
@ -1273,9 +1273,9 @@ void R_DrawAliasModel (entity_t *e)
glEnable(GL_BLEND);
glBlendFunc (GL_ONE, GL_ONE);
glDepthMask(GL_FALSE);
//Fog_StartAdditive ();
Fog_StartAdditive ();
GL_DrawAliasFrame (paliashdr, lerpdata);
//Fog_StopAdditive ();
Fog_StopAdditive ();
glDepthMask(GL_TRUE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -1290,9 +1290,9 @@ void R_DrawAliasModel (entity_t *e)
glDepthMask(GL_FALSE);
shading = false;
glColor3f(entalpha,entalpha,entalpha);
//Fog_StartAdditive ();
Fog_StartAdditive ();
GL_DrawAliasFrame (paliashdr, lerpdata);
//Fog_StopAdditive ();
Fog_StopAdditive ();
glDepthMask(GL_TRUE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
@ -1331,9 +1331,9 @@ void R_DrawAliasModel (entity_t *e)
glDepthMask(GL_FALSE);
shading = false;
glColor3f(entalpha,entalpha,entalpha);
//Fog_StartAdditive ();
Fog_StartAdditive ();
GL_DrawAliasFrame (paliashdr, lerpdata);
//Fog_StopAdditive ();
Fog_StopAdditive ();
glDepthMask(GL_TRUE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);

View file

@ -373,7 +373,7 @@ void R_DrawSequentialPoly (msurface_t *s)
Fog_DisableGFog ();
GL_Bind (t->gltexture);
DrawGLPoly (s->polys);
//
Fog_EnableGFog ();
rs_brushpasses++;
//second pass -- lightmap with black fog, modulate blended
@ -382,7 +382,7 @@ void R_DrawSequentialPoly (msurface_t *s)
glDepthMask (GL_FALSE);
glEnable (GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR); //2x modulate
//Fog_StartAdditive ();
Fog_StartAdditive ();
#ifdef VITA
glBegin(GL_TRIANGLE_FAN);
#else
@ -395,11 +395,11 @@ void R_DrawSequentialPoly (msurface_t *s)
glVertex3fv (v);
}
glEnd ();
//Fog_StopAdditive ();
Fog_StopAdditive ();
rs_brushpasses++;
//third pass -- black geo with normal fog, additive blended
/*if (Fog_GetDensity() > 0)
if (Fog_GetDensity() > 0)
{
glBlendFunc(GL_ONE, GL_ONE); //add
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@ -408,19 +408,17 @@ void R_DrawSequentialPoly (msurface_t *s)
glColor3f(1,1,1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
rs_brushpasses++;
}*/
}
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable (GL_BLEND);
glDepthMask (GL_TRUE);
Fog_EnableGFog ();
}
}
else
{
if (gl_mtexable) //case 4: texture and lightmap in one pass, regular modulation
{
Fog_DisableGFog ();
GL_DisableMultitexture(); // selects TEXTURE0
GL_Bind (t->gltexture);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@ -443,15 +441,12 @@ void R_DrawSequentialPoly (msurface_t *s)
glEnd ();
GL_DisableMultitexture ();
rs_brushpasses++;
Fog_EnableGFog ();
}
else if (entalpha < 1 || (s->flags & SURF_DRAWFENCE)) //case 5: can't do multipass if entity has alpha, so just draw the texture
{
Fog_DisableGFog ();
GL_Bind (t->gltexture);
DrawGLPoly (s->polys);
rs_brushpasses++;
Fog_EnableGFog ();
}
else //case 6: texture in one pass, lightmap in a second pass, fog in third pass
{
@ -459,7 +454,7 @@ void R_DrawSequentialPoly (msurface_t *s)
Fog_DisableGFog ();
GL_Bind (t->gltexture);
DrawGLPoly (s->polys);
//
Fog_EnableGFog ();
rs_brushpasses++;
//second pass -- lightmap with black fog, modulate blended
@ -468,7 +463,7 @@ void R_DrawSequentialPoly (msurface_t *s)
glDepthMask (GL_FALSE);
glEnable (GL_BLEND);
glBlendFunc (GL_ZERO, GL_SRC_COLOR); //modulate
//Fog_StartAdditive ();
Fog_StartAdditive ();
#ifdef VITA
glBegin(GL_TRIANGLE_FAN);
#else
@ -481,11 +476,11 @@ void R_DrawSequentialPoly (msurface_t *s)
glVertex3fv (v);
}
glEnd ();
//Fog_StopAdditive ();
Fog_StopAdditive ();
rs_brushpasses++;
//third pass -- black geo with normal fog, additive blended
/*if (Fog_GetDensity() > 0)
if (Fog_GetDensity() > 0)
{
glBlendFunc(GL_ONE, GL_ONE); //add
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
@ -494,13 +489,11 @@ void R_DrawSequentialPoly (msurface_t *s)
glColor3f(1,1,1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
rs_brushpasses++;
}*/
}
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable (GL_BLEND);
glDepthMask (GL_TRUE);
Fog_EnableGFog ();
}
}
@ -524,9 +517,9 @@ fullbrights:
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor3f (entalpha, entalpha, entalpha);
GL_Bind (t->fullbright);
//Fog_StartAdditive ();
Fog_StartAdditive ();
DrawGLPoly (s->polys);
//Fog_StopAdditive ();
Fog_StopAdditive ();
glColor3f(1, 1, 1);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

View file

@ -139,8 +139,6 @@ void R_DrawSpriteModel (entity_t *e)
default:
return;
}
Fog_DisableGFog ();
//johnfitz: offset decals
if (psprite->type == SPR_ORIENTED)
@ -181,6 +179,4 @@ void R_DrawSpriteModel (entity_t *e)
//johnfitz: offset decals
if (psprite->type == SPR_ORIENTED)
GL_PolygonOffset (OFFSET_NONE);
Fog_EnableGFog ();
}

View file

@ -1197,21 +1197,21 @@ void R_DrawTextureChains (qmodel_t *model, entity_t *ent, texchain_t chain)
//to make fog work with multipass lightmapping, need to do one pass
//with no fog, one modulate pass with black fog, and one additive
//pass with black geometry and normal fog
//Fog_DisableGFog ();
Fog_DisableGFog ();
R_DrawTextureChains_TextureOnly (model, ent, chain);
//Fog_EnableGFog ();
Fog_EnableGFog ();
glDepthMask (GL_FALSE);
glEnable (GL_BLEND);
glBlendFunc (GL_DST_COLOR, GL_SRC_COLOR); //2x modulate
//Fog_StartAdditive ();
Fog_StartAdditive ();
R_DrawLightmapChains ();
//Fog_StopAdditive ();
Fog_StopAdditive ();
//if (Fog_GetDensity() > 0)
//{
//glBlendFunc(GL_ONE, GL_ONE); //add
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
//glColor3f(0,0,0);
R_DrawTextureChains_TextureOnly (model, ent, chain);
//R_DrawTextureChains_TextureOnly (model, ent, chain);
//glColor3f(1,1,1);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
//}
@ -1239,21 +1239,21 @@ void R_DrawTextureChains (qmodel_t *model, entity_t *ent, texchain_t chain)
//to make fog work with multipass lightmapping, need to do one pass
//with no fog, one modulate pass with black fog, and one additive
//pass with black geometry and normal fog
//Fog_DisableGFog ();
Fog_DisableGFog ();
R_DrawTextureChains_TextureOnly (model, ent, chain);
//Fog_EnableGFog ();
Fog_EnableGFog ();
glDepthMask (GL_FALSE);
glEnable (GL_BLEND);
glBlendFunc(GL_ZERO, GL_SRC_COLOR); //modulate
//Fog_StartAdditive ();
Fog_StartAdditive ();
R_DrawLightmapChains ();
//Fog_StopAdditive ();
Fog_StopAdditive ();
//if (Fog_GetDensity() > 0)
//{
//glBlendFunc(GL_ONE, GL_ONE); //add
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
//glColor3f(0,0,0);
R_DrawTextureChains_TextureOnly (model, ent, chain);
//R_DrawTextureChains_TextureOnly (model, ent, chain);
//glColor3f(1,1,1);
//glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
//}
@ -1273,9 +1273,9 @@ fullbrights:
glBlendFunc (GL_ONE, GL_ONE);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor3f (entalpha, entalpha, entalpha);
//Fog_StartAdditive ();
Fog_StartAdditive ();
R_DrawTextureChains_Glow (model, ent, chain);
//Fog_StopAdditive ();
Fog_StopAdditive ();
glColor3f (1, 1, 1);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

View file

@ -1676,13 +1676,13 @@ void SV_Physics (void)
//
ent = sv.edicts;
/* if (sv_freezenonclients.value)
if (sv_freezenonclients.value)
entity_cap = svs.maxclients + 1; // Only run physics on clients and the world
else
entity_cap = sv.num_edicts;
*/
for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
//for (i=0 ; i<entity_cap ; i++, ent = NEXT_EDICT(ent))
//for (i=0 ; i<sv.num_edicts ; i++, ent = NEXT_EDICT(ent))
for (i=0 ; i<entity_cap ; i++, ent = NEXT_EDICT(ent))
{
if (ent->free)
continue;