From dbe30c7adb9ec683e386586d8dce5944a9728daa Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Mon, 15 May 2023 17:48:53 +0000 Subject: [PATCH] Fix some bmodels not being linked/unlinked correctly with sv_areagrid_link_SOLID_NOT 0 --- qcsrc/common/mapobjects/func/breakable.qc | 11 +++++---- qcsrc/common/mapobjects/func/rainsnow.qc | 2 +- qcsrc/common/mapobjects/models.qc | 28 ++++++++++++++++------- qcsrc/common/mapobjects/subs.qc | 2 ++ 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/qcsrc/common/mapobjects/func/breakable.qc b/qcsrc/common/mapobjects/func/breakable.qc index 606460359..5f72e2a29 100644 --- a/qcsrc/common/mapobjects/func/breakable.qc +++ b/qcsrc/common/mapobjects/func/breakable.qc @@ -99,8 +99,13 @@ void func_breakable_look_destroyed(entity this) if(this.solid == SOLID_BSP) // in case a misc_follow moved me, save the current origin first this.dropped_origin = this.origin; + this.solid = SOLID_NOT; // before setorigin/_setmodel to prevent area grid linking + if(this.mdl_dead == "") + { + setorigin (this, this.origin); // unlink this.effects |= EF_NODRAW; + } else { if (this.origin == '0 0 0') { // probably no origin brush, so don't spawn in the middle of the map.. floorZ = this.absmin.z; @@ -111,20 +116,18 @@ void func_breakable_look_destroyed(entity this) ApplyMinMaxScaleAngles(this); this.effects &= ~EF_NODRAW; } - - this.solid = SOLID_NOT; } void func_breakable_look_restore(entity this) { + this.solid = SOLID_BSP; // before _setmodel/setorigin to ensure area grid linking + _setmodel(this, this.mdl); ApplyMinMaxScaleAngles(this); this.effects &= ~EF_NODRAW; if(this.mdl_dead != "") // only do this if we use mdl_dead, to behave better with misc_follow setorigin(this, this.dropped_origin); - - this.solid = SOLID_BSP; } void func_breakable_behave_destroyed(entity this) diff --git a/qcsrc/common/mapobjects/func/rainsnow.qc b/qcsrc/common/mapobjects/func/rainsnow.qc index de49f1e36..9e9dc64e2 100644 --- a/qcsrc/common/mapobjects/func/rainsnow.qc +++ b/qcsrc/common/mapobjects/func/rainsnow.qc @@ -134,9 +134,9 @@ NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew) this.maxs = 0.5 * this.maxs; this.origin = this.origin - this.mins; + this.solid = SOLID_NOT; // before setorigin/setsize to prevent area grid linking setorigin(this, this.origin); setsize(this, this.mins, this.maxs); - this.solid = SOLID_NOT; if (isnew) IL_PUSH(g_drawables, this); this.draw = Draw_RainSnow; } diff --git a/qcsrc/common/mapobjects/models.qc b/qcsrc/common/mapobjects/models.qc index f342ebb25..dfc96666e 100644 --- a/qcsrc/common/mapobjects/models.qc +++ b/qcsrc/common/mapobjects/models.qc @@ -44,12 +44,20 @@ void g_clientmodel_use(entity this, entity actor, entity trigger) if (this.antiwall_flag == 1) { this.inactive = 1; - this.solid = SOLID_NOT; + if (this.solid != SOLID_NOT) + { + this.solid = SOLID_NOT; + setorigin(this, this.origin); // unlink + } } else if (this.antiwall_flag == 2) { this.inactive = 0; - this.solid = this.default_solid; + if (this.solid != this.default_solid) + { + this.solid = this.default_solid; + setorigin(this, this.origin); // link + } } g_clientmodel_setcolormaptoactivator(this, actor, trigger); } @@ -167,25 +175,29 @@ void g_model_init(entity ent, float sol) { if(ent.geomtype && autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS); if(!ent.scale) ent.scale = ent.modelscale; - SetBrushEntityModel(ent,true); - ent.use = g_model_setcolormaptoactivator; - InitializeEntity(ent, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); + if(!ent.solid) ent.solid = (sol); else if(ent.solid < 0) ent.solid = SOLID_NOT; + SetBrushEntityModel(ent,true); // called after setting .solid to ensure correct area grid linking/unlinking + + ent.use = g_model_setcolormaptoactivator; + InitializeEntity(ent, g_model_dropbyspawnflags, INITPRIO_DROPTOFLOOR); } void g_clientmodel_init(entity ent, float sol) { if(ent.geomtype && autocvar_physics_ode && checkextension("DP_PHYSICS_ODE")) set_movetype(ent, MOVETYPE_PHYSICS); if(!ent.scale) ent.scale = ent.modelscale; - SetBrushEntityModel(ent,true); + + if(!ent.solid) ent.solid = (sol); + else if(ent.solid < 0) ent.solid = SOLID_NOT; + SetBrushEntityModel(ent,true); // called after setting .solid to ensure correct area grid linking/unlinking + ent.use = g_clientmodel_use; setthink(ent, g_clientmodel_think); ent.nextthink = time; ent.oldorigin = ent.origin; // don't run an initial double update InitializeEntity(ent, g_clientmodel_dropbyspawnflags, INITPRIO_DROPTOFLOOR); - if(!ent.solid) ent.solid = (sol); - else if(ent.solid < 0) ent.solid = SOLID_NOT; if(!ent.bgmscriptsustain) ent.bgmscriptsustain = 1; else if(ent.bgmscriptsustain < 0) ent.bgmscriptsustain = 0; Net_LinkEntity(ent, true, 0, g_clientmodel_genericsendentity); diff --git a/qcsrc/common/mapobjects/subs.qc b/qcsrc/common/mapobjects/subs.qc index 31ffee064..fbcb4b39a 100644 --- a/qcsrc/common/mapobjects/subs.qc +++ b/qcsrc/common/mapobjects/subs.qc @@ -412,6 +412,8 @@ void ApplyMinMaxScaleAngles(entity e) void SetBrushEntityModel(entity this, bool with_lod) { + // Ensure .solid is set correctly before calling this (for area grid linking/unlinking) + if(this.model != "") { precache_model(this.model); -- 2.39.2