[client] Pre-cache temp entity data after clearing memory

This is a particularly ancient bug, sort of introduced by rhamph when he
optimized temp entity model handling and later exacerbated by me.
However, I suspect the actual problem is limited to nq as qw's gamedir
handling would have caused the models to be reloaded, but nq doesn't
ever change game directories once running.
This commit is contained in:
Bill Currie 2022-05-13 21:24:45 +09:00
parent 3639ee3d2d
commit bc82241e1c
4 changed files with 17 additions and 7 deletions

View file

@ -103,6 +103,7 @@ struct msg_s;
struct entity_s; struct entity_s;
void CL_TEnts_Init (void); void CL_TEnts_Init (void);
void CL_TEnts_Precache (void);
void CL_Init_Entity (struct entity_s *ent); void CL_Init_Entity (struct entity_s *ent);
void CL_ClearTEnts (void); void CL_ClearTEnts (void);
void CL_UpdateTEnts (double time, TEntContext_t *ctx); void CL_UpdateTEnts (double time, TEntContext_t *ctx);

View file

@ -107,12 +107,9 @@ static model_t *cl_spike;
static vec4f_t beam_rolls[360]; static vec4f_t beam_rolls[360];
static void void
CL_TEnts_Precache (int phase) CL_TEnts_Precache (void)
{ {
if (!phase) {
return;
}
cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav"); cl_sfx_wizhit = S_PrecacheSound ("wizard/hit.wav");
cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav"); cl_sfx_knighthit = S_PrecacheSound ("hknight/hit.wav");
cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav"); cl_sfx_tink1 = S_PrecacheSound ("weapons/tink1.wav");
@ -134,11 +131,19 @@ CL_TEnts_Precache (int phase)
} }
} }
static void
cl_tents_precache (int phase)
{
if (!phase) {
return;
}
CL_TEnts_Precache ();
}
void void
CL_TEnts_Init (void) CL_TEnts_Init (void)
{ {
QFS_GamedirCallback (CL_TEnts_Precache); QFS_GamedirCallback (cl_tents_precache);
CL_TEnts_Precache (1);
for (int i = 0; i < 360; i++) { for (int i = 0; i < 360; i++) {
float ang = i * M_PI / 360; float ang = i * M_PI / 360;
beam_rolls[i] = (vec4f_t) { sin (ang), 0, 0, cos (ang) }; beam_rolls[i] = (vec4f_t) { sin (ang), 0, 0, cos (ang) };

View file

@ -300,6 +300,8 @@ CL_ClearState (void)
cl.viewstate.weapon_entity = Scene_CreateEntity (cl_world.scene); cl.viewstate.weapon_entity = Scene_CreateEntity (cl_world.scene);
CL_Init_Entity (cl.viewstate.weapon_entity); CL_Init_Entity (cl.viewstate.weapon_entity);
r_data->view_model = cl.viewstate.weapon_entity; r_data->view_model = cl.viewstate.weapon_entity;
CL_TEnts_Precache ();
} }
/* /*

View file

@ -693,6 +693,8 @@ CL_ClearState (void)
CL_Init_Entity (cl.viewstate.weapon_entity); CL_Init_Entity (cl.viewstate.weapon_entity);
r_data->view_model = cl.viewstate.weapon_entity; r_data->view_model = cl.viewstate.weapon_entity;
CL_TEnts_Precache ();
SCR_NewScene (0); SCR_NewScene (0);
SZ_Clear (&cls.netchan.message); SZ_Clear (&cls.netchan.message);