self.csqcmodel_teleported = 0;
}
+entity CSQCModel_players[255]; // 255 is engine limit on maxclients
+
+void CSQCModel_remove()
+{
+ SELFPARAM();
+ CSQCModel_players[this.entnum - 1] = NULL;
+}
+
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 }
#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
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);
#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;
+ this.predraw = CSQCModel_Draw;
return true;
}
-entity CSQCModel_server2csqc(float pl)
+entity CSQCModel_server2csqc(int pl)
{
- return findfloat(world, entnum, pl); // FIXME optimize this using an array
+ if (pl <= maxclients) return CSQCModel_players[pl - 1];
+ LOG_WARNINGF("player out of bounds: %d\n", pl);
+ return findfloat(NULL, entnum, pl);
}