X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Flib%2Fcsqcmodel%2Fcl_model.qc;h=c07f94954bc97a4682f7e458e8947d31edddb853;hp=a656fb7908bb39cb6e5a4cf03b1486ec4b0f196a;hb=6c1b876763dcb2d7e9e8d24c581b655ccce87a6f;hpb=a014f99742b4ce9131bb4571e52be59a073d1871 diff --git a/qcsrc/lib/csqcmodel/cl_model.qc b/qcsrc/lib/csqcmodel/cl_model.qc index a656fb7908..c07f94954b 100644 --- a/qcsrc/lib/csqcmodel/cl_model.qc +++ b/qcsrc/lib/csqcmodel/cl_model.qc @@ -24,10 +24,10 @@ #include "cl_player.qh" #include "common.qh" #include "interpolate.qh" -#include "../../client/defs.qh" -#include "../../common/animdecide.qh" -#include "../../common/csqcmodel_settings.qh" -#include "../../common/util.qh" +#include +#include +#include +#include float autocvar_cl_lerpanim_maxdelta_framegroups = 0.1; float autocvar_cl_nolerp = 0; @@ -179,34 +179,40 @@ void CSQCModel_InterpolateAnimation_Do() #endif } -void CSQCModel_Draw() -{SELFPARAM(); +void CSQCModel_Draw(entity this) +{ // some nice flags for CSQCMODEL_IF and the hooks - bool isplayer = (self.entnum >= 1 && self.entnum <= maxclients); - noref bool islocalplayer = (self.entnum == player_localnum + 1); - noref bool isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1)); + bool isplayer = (this.entnum >= 1 && this.entnum <= maxclients); + noref bool islocalplayer = (this.entnum == player_localnum + 1); + noref bool isnolocalplayer = (isplayer && (this.entnum != player_localnum + 1)); // we don't do this for the local player as that one is already handled // by CSQCPlayer_SetCamera() - if(!CSQCPlayer_IsLocalPlayer()) - InterpolateOrigin_Do(); + if (!CSQCPlayer_IsLocalPlayer(this)) InterpolateOrigin_Do(this); - CSQCModel_InterpolateAnimation_Do(); + WITH(entity, self, this, CSQCModel_InterpolateAnimation_Do()); { CSQCMODEL_HOOK_PREDRAW } // inherit draw flags easily - entity root = self; + entity root = this; while(root.tag_entity) root = root.tag_entity; - if(self != root) + if(this != root) { - self.renderflags &= ~(RF_EXTERNALMODEL | RF_VIEWMODEL); - self.renderflags |= (root.renderflags & (RF_EXTERNALMODEL | RF_VIEWMODEL)); + this.renderflags &= ~(RF_EXTERNALMODEL | RF_VIEWMODEL); + this.renderflags |= (root.renderflags & (RF_EXTERNALMODEL | RF_VIEWMODEL)); } // we're drawn, now teleporting is over - self.csqcmodel_teleported = 0; + this.csqcmodel_teleported = 0; +} + +entity CSQCModel_players[255]; // 255 is engine limit on maxclients + +void CSQCModel_remove(entity this) +{ + CSQCModel_players[this.entnum - 1] = NULL; } NET_HANDLE(ENT_CLIENT_MODEL, bool isnew) @@ -214,29 +220,34 @@ NET_HANDLE(ENT_CLIENT_MODEL, bool isnew) int sf = ReadInt24_t(); // some nice flags for CSQCMODEL_IF and the hooks - bool isplayer = (self.entnum >= 1 && self.entnum <= maxclients); - bool islocalplayer = (self.entnum == player_localnum + 1); - noref bool isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1)); + bool isplayer = (this.entnum >= 1 && this.entnum <= maxclients); + if (isnew && isplayer) + { + CSQCModel_players[this.entnum - 1] = this; + this.entremove = CSQCModel_remove; + } + bool islocalplayer = (this.entnum == player_localnum + 1); + noref bool isnolocalplayer = (isplayer && (this.entnum != player_localnum + 1)); - self.classname = "csqcmodel"; - self.iflags |= IFLAG_ORIGIN; // interpolate origin too - self.iflags |= IFLAG_ANGLES; // interpolate angles too - self.iflags |= IFLAG_VELOCITY | IFLAG_AUTOVELOCITY; // let's calculate velocity automatically + this.classname = "csqcmodel"; + this.iflags |= IFLAG_ORIGIN; // interpolate origin too + this.iflags |= IFLAG_ANGLES; // interpolate angles too + this.iflags |= IFLAG_VELOCITY | IFLAG_AUTOVELOCITY; // let's calculate velocity automatically { CSQCMODEL_HOOK_PREUPDATE } - CSQCPlayer_PreUpdate(); - InterpolateOrigin_Undo(); + CSQCPlayer_PreUpdate(this); + InterpolateOrigin_Undo(this); CSQCModel_InterpolateAnimation_PreNote(sf); #define CSQCMODEL_IF(cond) if(cond) { #define CSQCMODEL_ENDIF } #define CSQCMODEL_PROPERTY(flag,t,r,w,f) \ if(sf & flag) \ - self.f = r(); + this.f = r(); #define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) \ if(sf & flag) \ - self.f = (r() + mi) / s; + this.f = (r() + mi) / s; ALLPROPERTIES #undef CSQCMODEL_PROPERTY_SCALED #undef CSQCMODEL_PROPERTY @@ -245,44 +256,50 @@ NET_HANDLE(ENT_CLIENT_MODEL, bool isnew) if(sf & CSQCMODEL_PROPERTY_MODELINDEX) { - vector pmin = self.mins, pmax = self.maxs; - setmodelindex(self, self.modelindex); // this retrieves the .model key and sets mins/maxs/absmin/absmax - setsize(self, pmin, pmax); + vector pmin = this.mins, pmax = this.maxs; + setmodelindex(this, this.modelindex); // this retrieves the .model key and sets mins/maxs/absmin/absmax + setsize(this, pmin, pmax); } if(sf & CSQCMODEL_PROPERTY_TELEPORTED) { - self.iflags |= IFLAG_TELEPORTED; - self.csqcmodel_teleported = 1; + this.iflags |= IFLAG_TELEPORTED; + this.csqcmodel_teleported = 1; } CSQCModel_InterpolateAnimation_Note(sf); - InterpolateOrigin_Note(); - CSQCPlayer_PostUpdate(); + InterpolateOrigin_Note(this); + CSQCPlayer_PostUpdate(this); { CSQCMODEL_HOOK_POSTUPDATE } #ifdef CSQCMODEL_SUPPORT_GETTAGINFO_BEFORE_DRAW - InterpolateOrigin_Do(); + InterpolateOrigin_Do(this); CSQCModel_InterpolateAnimation_Do(); #endif // relink - setorigin(self, self.origin); + setorigin(this, this.origin); // set obvious render flags - if(self.entnum == player_localentnum) - self.renderflags |= RF_EXTERNALMODEL; + if(this.entnum == player_localentnum) + this.renderflags |= RF_EXTERNALMODEL; else - self.renderflags &= ~RF_EXTERNALMODEL; + this.renderflags &= ~RF_EXTERNALMODEL; // draw it - self.drawmask = MASK_NORMAL; - self.predraw = CSQCModel_Draw; + this.drawmask = MASK_NORMAL; + setpredraw(this, CSQCModel_Draw); return true; } -entity CSQCModel_server2csqc(float pl) +/** + * @param i zero indexed player + */ +entity CSQCModel_server2csqc(int i) { - return findfloat(world, entnum, pl); // FIXME optimize this using an array + if (i < maxclients) return CSQCModel_players[i]; + ++i; + LOG_DEBUGF("player out of bounds: %d\n", i); + return findfloat(NULL, entnum, i); }