From 0194636efd5ba1d282165dfd29f3314da5d1cc6d Mon Sep 17 00:00:00 2001 From: MirceaKitsune Date: Tue, 19 Apr 2011 17:19:53 +0300 Subject: [PATCH] Some rather major changes to the model setting system. Basically, we no longer attempt to customize the player entities per client (and their weapon models) each frame, but only when they are changed. Also reduce some useless code and improve it. Needs testing. --- data/qcsrc/server/cl_client.qc | 34 +++++++++++++++------------- data/qcsrc/server/cl_player.qc | 11 +++++++++ data/qcsrc/server/cl_weaponsystem.qc | 19 ++++++++++------ 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/data/qcsrc/server/cl_client.qc b/data/qcsrc/server/cl_client.qc index b096334c..49d1ea05 100644 --- a/data/qcsrc/server/cl_client.qc +++ b/data/qcsrc/server/cl_client.qc @@ -470,7 +470,7 @@ void Client_uncustomizeentityforclient() float Client_customizeentityforclient() { entity modelsource; - string applymodel; + string stomachmodel; if(self.modelindex == 0) return TRUE; @@ -512,28 +512,30 @@ float Client_customizeentityforclient() // now change the predator's player model into a stomach model for the prey // in other words, when a player is swallowed by another player, the predator becomes an inward stomach model so the prey can see theirself in the stomach // this is only visible to the prey however, otherwise players would appear as a floating stomach to everyone (ewww) + stomachmodel = strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_stomach.md3"); // 4 is the extension length - // don't do this if we have chase_active enabled, as we'd be seeing a floating stomach from third person view - if(other.cvar_chase_active > 0 || other.classname == "observer") // the classname check prevents a bug - { - Client_setmodel(setmodel_state()); - if not(self.predator.classname == "player" || self.fakeprey) - self.alpha = default_player_alpha; - return TRUE; - } if(other.spectatee_status) other = other.enemy; // also do this for the player we are spectating + + // don't do this if we have chase_active enabled, as we'd be seeing a floating stomach from third person view + if not(other.cvar_chase_active || other.classname == "observer") // the observer check prevents a bug if(other.predator == self || other.fakepredator == self) { - applymodel = strcat(substring(self.playermodel, 0, strlen(self.playermodel) - 4), "_stomach.md3"); // 4 is the extension length - Client_setmodel(applymodel); - self.frame = 0; // don't use any animations as a stomach - self.alpha = other.cvar_cl_vore_stomachmodel; + if(self.model != stomachmodel) // don't execute each frame + { + Client_setmodel(stomachmodel); + self.frame = 0; // don't use any animations as a stomach + self.alpha = other.cvar_cl_vore_stomachmodel; + } return TRUE; } - Client_setmodel(setmodel_state()); - if not(self.predator.classname == "player" || self.fakeprey) - self.alpha = default_player_alpha; + + if(self.model != setmodel_state()) // don't execute each frame + { + Client_setmodel(setmodel_state()); + if not(self.predator.classname == "player" || self.fakeprey) + self.alpha = default_player_alpha; + } return TRUE; } diff --git a/data/qcsrc/server/cl_player.qc b/data/qcsrc/server/cl_player.qc index 3997e3de..3d2cf7a3 100644 --- a/data/qcsrc/server/cl_player.qc +++ b/data/qcsrc/server/cl_player.qc @@ -218,6 +218,10 @@ float player_getspecies() void player_setupanimsformodel() { + // if this is the stomach model (or any model that can't be animated), don't attempt to animate + if(substring(self.model, strlen(self.model) - 3, 3) == "md3") // check model extension + return; + local string animfilename; local float animfile; // defaults for legacy .zym models without animinfo files @@ -281,6 +285,13 @@ void player_setupanimsformodel() } else dprint("File ", animfilename, " not found, assuming legacy .zym model animation timings\n"); + + // the line below is disabled due to issues with the stomach model, which cannot be animated. + // customizeentityforclient cannot let this part of the code know whether it's the stomach model or normal + // player model we're using. Attempting to animate the stomach model causes BIG issues, and must not be allowed. + + // reset animstate now + //setanim(self, self.anim_idle, TRUE, FALSE, TRUE); }; void player_anim (void) diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 9716e985..0ac64046 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -255,19 +255,24 @@ float CL_ExteriorWeaponentity_CustomizeEntityForClient() // otherwise, the stomach model the predator is transformed in (see Client_customizeentityforclient) will have a weapon model attached to it if(self.owner.weaponname == "" || self.owner.deadflag != DEAD_NO) return TRUE; - if(other.cvar_chase_active > 0 || other.classname == "observer") // the classname check prevents a bug - { - setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); - return TRUE; - } + if(other.spectatee_status) other = other.enemy; // also do this for the player we are spectating + + if not(other.cvar_chase_active || other.classname == "observer") // the observer check prevents a bug if(other.predator == self.owner || other.fakepredator == self.owner) { - setmodel(self, ""); + if(self.model != "") // don't execute each frame + { + setmodel(self, ""); + } return TRUE; } - setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); + + if(self.model != strcat("models/weapons/v_", self.owner.weaponname, ".md3")) // don't execute each frame + { + setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); + } return TRUE; } -- 2.39.2