From d65360731961db3374609c79300e226a8432e27c Mon Sep 17 00:00:00 2001 From: meag Date: Wed, 1 Jun 2016 15:53:57 +0100 Subject: [PATCH] GL_RMAIN/VX_STUFF: Stop corrupting command list when gl_no24bit toggled 1>0 VX_STUFF was registering commands (gl_checkmodels/gl_inferno/gl_setmode) in a function only called when gl_no24bit was set to 0. The commands use Hunk_Alloc(), so the newly added commands at the front of the linked list were being allocated in memory that was free'd on the next map change, and the client would inevitably crash when next finding commands in the list. Fixes bug https://github.com/ezQuake/ezquake-source/issues/73 --- gl_rmain.c | 3 +++ gl_rpart.c | 6 +++++- vx_stuff.c | 10 ++++++---- vx_stuff.h | 2 ++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index e51d6a9c5..ee90e97ca 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1898,6 +1898,9 @@ void R_Init(void) #ifndef CLIENTONLY Cmd_AddCommand ("pointfile", R_ReadPointFile_f); #endif + Cmd_AddCommand ("gl_checkmodels", CheckModels_f); + Cmd_AddCommand ("gl_inferno", InfernoFire_f); + Cmd_AddCommand ("gl_setmode", Amf_SetMode_f); Cvar_SetCurrentGroup(CVAR_GROUP_EYECANDY); Cvar_Register (&r_bloom); diff --git a/gl_rpart.c b/gl_rpart.c index 4ff4b7235..eceb473fe 100644 --- a/gl_rpart.c +++ b/gl_rpart.c @@ -2585,11 +2585,15 @@ void FuelRodExplosion (vec3_t org) //VULT PARTICLES void InfernoFire_f (void) { - vec3_t forward, right, up; vec3_t ang, dir; vec3_t org; + if (!qmb_initialized) { + Com_Printf ("Particle system not initialized\n"); + return; + } + ang[0] = cl.simangles[0]; ang[1] = cl.simangles[1]; ang[2] = 0; diff --git a/vx_stuff.c b/vx_stuff.c index ce2175125..aaa789f42 100644 --- a/vx_stuff.c +++ b/vx_stuff.c @@ -342,9 +342,14 @@ void Amf_SetMode_f(void) char mode[32]; if (Cmd_Argc() != 2) { - Com_Printf("Usage: %s [modename]\n", Cmd_Argv(0)); + Com_Printf("Usage: %s [modename: newtrails or vultwah]\n", Cmd_Argv(0)); return; } + if (!qmb_initialized) { + Com_Printf ("Particle system not initialized\n"); + return; + } + snprintf(mode, sizeof (mode), "%s", Cmd_Argv(1)); if (!strcmp(mode, "newtrails")) { @@ -492,9 +497,6 @@ void InitVXStuff(void) Cvar_Register (&amf_inferno_speed); Cvar_Register (&amf_cutf_tesla_effect); Cvar_ResetCurrentGroup(); - Cmd_AddCommand ("gl_checkmodels", CheckModels_f); - Cmd_AddCommand ("gl_inferno", InfernoFire_f); - Cmd_AddCommand ("gl_setmode", Amf_SetMode_f); } diff --git a/vx_stuff.h b/vx_stuff.h index 4f742681f..ec23a0e3a 100644 --- a/vx_stuff.h +++ b/vx_stuff.h @@ -154,6 +154,8 @@ void FireballTrailWave (vec3_t start, vec3_t end, vec3_t *trail_origin, byte col void DrawMuzzleflash (vec3_t start, vec3_t angle, vec3_t vel); void VXNailhit (vec3_t org, float count); void InfernoFire_f (void); +void CheckModels_f (void); +void Amf_SetMode_f (void); void CL_FakeExplosion (vec3_t pos); void CL_FakeRocketLight(vec3_t org); void FuelRodExplosion (vec3_t org);