Fix the segfault on map change.

I had forgotten to call R_ClearTextures when I'd rearranged the code.
This commit is contained in:
Bill Currie 2012-01-09 10:16:54 +09:00
parent cd91fe7c8d
commit 12fd6bd390
3 changed files with 33 additions and 22 deletions

View file

@ -55,6 +55,7 @@ typedef struct elechain_s {
void R_ClearElements (void);
void R_DrawWorld (void);
void R_RegisterTextures (model_t **models, int num_models);
void R_BuildDisplayLists (model_t **models, int num_models);
void R_InitBsp (void);

View file

@ -198,12 +198,6 @@ R_AddTexture (texture_t *tex)
tex->elechain_tail = &tex->elechain;
}
void
R_ClearTextures (void)
{
r_num_texture_chains = 0;
}
void
R_InitSurfaceChains (model_t *model)
{
@ -282,6 +276,37 @@ register_textures (model_t *model)
}
}
void
R_ClearTextures (void)
{
r_num_texture_chains = 0;
}
void
R_RegisterTextures (model_t **models, int num_models)
{
int i;
model_t *m;
R_ClearTextures ();
R_InitSurfaceChains (r_worldentity.model);
R_AddTexture (r_notexture_mip);
register_textures (r_worldentity.model);
for (i = 0; i < num_models; i++) {
m = models[i];
if (!m)
continue;
// sub-models are done as part of the main model
if (*m->name == '*')
continue;
// world has already been done, not interested in non-brush models
if (m == r_worldentity.model || m->type != mod_brush)
continue;
m->numsubmodels = 1; // no support for submodels in non-world model
register_textures (m);
}
}
static elechain_t *
add_elechain (texture_t *tex, int ec_index)
{
@ -387,22 +412,6 @@ R_BuildDisplayLists (model_t **models, int num_models)
msurface_t *surf;
dstring_t *vertices;
R_InitSurfaceChains (r_worldentity.model);
R_AddTexture (r_notexture_mip);
register_textures (r_worldentity.model);
for (i = 0; i < num_models; i++) {
m = models[i];
if (!m)
continue;
// sub-models are done as part of the main model
if (*m->name == '*')
continue;
// world has already been done, not interested in non-brush models
if (m == r_worldentity.model || m->type != mod_brush)
continue;
m->numsubmodels = 1; // no support for submodels in non-world model
register_textures (m);
}
// now run through all surfaces, chaining them to their textures, thus
// effectively sorting the surfaces by texture (without worrying about
// surface order on the same texture chain).

View file

@ -222,6 +222,7 @@ R_NewMap (model_t *worldmodel, struct model_s **models, int num_models)
R_FreeAllEntities ();
R_ClearParticles ();
R_RegisterTextures (models, num_models);
R_BuildLightmaps (models, num_models);
R_BuildDisplayLists (models, num_models);
}