Xonotic
sv_model.qc File Reference
#include "sv_model.qh"
#include "common.qh"
+ Include dependency graph for sv_model.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CSQCMODEL_ENDIF   }
 
#define CSQCMODEL_ENDIF   }
 
#define CSQCMODEL_IF(cond)   if(cond) {
 
#define CSQCMODEL_IF(cond)   if(cond) {
 
#define CSQCMODEL_PROPERTY(flag, t, r, w, f)
 
#define CSQCMODEL_PROPERTY(flag, t, r, w, f)
 
#define CSQCMODEL_PROPERTY_SCALED(flag, t, r, w, f, s, mi, ma)
 
#define CSQCMODEL_PROPERTY_SCALED(flag, t, r, w, f, s, mi, ma)
 

Functions

void CSQCModel_CheckUpdate (entity e)
 
void CSQCModel_LinkEntity (entity e)
 
bool CSQCModel_Send (entity this, entity to, int sf)
 
void CSQCModel_UnlinkEntity (entity e)
 

Variables

float csqcmodel_nextforcedupdate
 

Macro Definition Documentation

◆ CSQCMODEL_ENDIF [1/2]

#define CSQCMODEL_ENDIF   }

◆ CSQCMODEL_ENDIF [2/2]

#define CSQCMODEL_ENDIF   }

◆ CSQCMODEL_IF [1/2]

#define CSQCMODEL_IF (   cond)    if(cond) {

◆ CSQCMODEL_IF [2/2]

#define CSQCMODEL_IF (   cond)    if(cond) {

◆ CSQCMODEL_PROPERTY [1/2]

#define CSQCMODEL_PROPERTY (   flag,
  t,
  r,
  w,
 
)
Value:
if(sf & flag) \
{ \
w(MSG_ENTITY, this.csqcmodel_##f); \
}

◆ CSQCMODEL_PROPERTY [2/2]

#define CSQCMODEL_PROPERTY (   flag,
  t,
  r,
  w,
 
)
Value:
{ \
t tmp = e.f; \
if(tmp != e.csqcmodel_##f) \
{ \
e.csqcmodel_##f = tmp; \
e.SendFlags |= flag; \
} \
}

◆ CSQCMODEL_PROPERTY_SCALED [1/2]

#define CSQCMODEL_PROPERTY_SCALED (   flag,
  t,
  r,
  w,
  f,
  s,
  mi,
  ma 
)
Value:
if(sf & flag) \
{ \
w(MSG_ENTITY, this.csqcmodel_##f); \
}

◆ CSQCMODEL_PROPERTY_SCALED [2/2]

#define CSQCMODEL_PROPERTY_SCALED (   flag,
  t,
  r,
  w,
  f,
  s,
  mi,
  ma 
)
Value:
{ \
t tmp = rint(bound(mi, s * e.f, ma) - mi); \
if(tmp != e.csqcmodel_##f) \
{ \
e.csqcmodel_##f = tmp; \
e.SendFlags |= flag; \
} \
}

Function Documentation

◆ CSQCModel_CheckUpdate()

void CSQCModel_CheckUpdate ( entity  e)

Definition at line 68 of file sv_model.qc.

References ALLPROPERTIES, CSQCMODEL_PROPERTY_FRAME, CSQCMODEL_PROPERTY_FRAME2, CSQCMODEL_PROPERTY_ORIGIN, CSQCMODEL_PROPERTY_TELEPORTED, CSQCPLAYER_FORCE_UPDATES, EF_RESTARTANIM_BIT, EF_TELEPORT_BIT, IS_CLIENT, random(), and time.

Referenced by CSQCModel_LinkEntity().

69 {
70  // some nice flags for CSQCMODEL_IF
71  noref float isplayer = IS_CLIENT(e);
72  noref float islocalplayer = isplayer; // we set BOTH to 1 here as we need the sendflags
73  noref float isnolocalplayer = isplayer; // we set BOTH to 1 here as we need the sendflags
74 
75 #if CSQCPLAYER_FORCE_UPDATES
76  if(isplayer && time > e.csqcmodel_nextforcedupdate)
77  {
78  e.SendFlags |= CSQCMODEL_PROPERTY_ORIGIN;
79  e.csqcmodel_nextforcedupdate = time + (1 / (CSQCPLAYER_FORCE_UPDATES)) * (0.5 + random()); // ensure about 4 origin sends per sec
80  }
81 #endif
82 
83  if(e.effects & EF_RESTARTANIM_BIT)
84  {
85  e.SendFlags |= CSQCMODEL_PROPERTY_FRAME | CSQCMODEL_PROPERTY_FRAME2; // full anim resend please
86  e.effects &= ~EF_RESTARTANIM_BIT;
87  }
88 
89  if(e.effects & EF_TELEPORT_BIT)
90  {
91  e.SendFlags |= CSQCMODEL_PROPERTY_TELEPORTED; // no interpolation please
92  e.effects &= ~EF_TELEPORT_BIT;
93  }
94 
95 #define CSQCMODEL_IF(cond) if(cond) {
96 #define CSQCMODEL_ENDIF }
97 #define CSQCMODEL_PROPERTY(flag,t,r,w,f) \
98  { \
99  t tmp = e.f; \
100  if(tmp != e.csqcmodel_##f) \
101  { \
102  e.csqcmodel_##f = tmp; \
103  e.SendFlags |= flag; \
104  } \
105  }
106 #define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) \
107  { \
108  t tmp = rint(bound(mi, s * e.f, ma) - mi); \
109  if(tmp != e.csqcmodel_##f) \
110  { \
111  e.csqcmodel_##f = tmp; \
112  e.SendFlags |= flag; \
113  } \
114  }
116 #undef CSQCMODEL_PROPERTY_SCALED
117 #undef CSQCMODEL_PROPERTY
118 #undef CSQCMODEL_ENDIF
119 #undef CSQCMODEL_IF
120 }
#define CSQCPLAYER_FORCE_UPDATES
#define IS_CLIENT(v)
Definition: utils.qh:13
const int EF_RESTARTANIM_BIT
const int CSQCMODEL_PROPERTY_ORIGIN
Definition: common.qh:64
const int CSQCMODEL_PROPERTY_FRAME2
Definition: common.qh:67
#define ALLPROPERTIES
Definition: common.qh:93
const int EF_TELEPORT_BIT
const int CSQCMODEL_PROPERTY_FRAME
Definition: common.qh:61
const int CSQCMODEL_PROPERTY_TELEPORTED
Definition: common.qh:62
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCModel_LinkEntity()

void CSQCModel_LinkEntity ( entity  e)

Definition at line 122 of file sv_model.qc.

References CSQCModel_CheckUpdate(), CSQCModel_Send(), and setSendEntity.

123 {
125  e.SendFlags = 0xFFFFFF;
127 }
bool CSQCModel_Send(entity this, entity to, int sf)
Definition: sv_model.qc:28
void CSQCModel_CheckUpdate(entity e)
Definition: sv_model.qc:68
#define setSendEntity(e, f)
Definition: self.qh:97
+ Here is the call graph for this function:

◆ CSQCModel_Send()

bool CSQCModel_Send ( entity  this,
entity  to,
int  sf 
)

Definition at line 28 of file sv_model.qc.

References ALLPROPERTIES, BITSET, IS_CLIENT, IS_PLAYER, ISPLAYER_CLIENT, ISPLAYER_LOCAL, ISPLAYER_PLAYER, to, and WriteByte().

Referenced by CSQCModel_LinkEntity().

29 {
30  // some nice flags for CSQCMODEL_IF
31  noref bool isplayer = IS_CLIENT(this);
32  noref bool islocalplayer = (this == to);
33  noref bool isnolocalplayer = (isplayer && (this != to));
34 
35  int psf = 0;
36  psf = BITSET(psf, ISPLAYER_CLIENT, isplayer);
37  psf = BITSET(psf, ISPLAYER_LOCAL, islocalplayer);
38  psf = BITSET(psf, ISPLAYER_PLAYER, IS_PLAYER(this));
39 
40  WriteHeader(MSG_ENTITY, ENT_CLIENT_MODEL);
41  WriteInt24_t(MSG_ENTITY, sf);
42  WriteByte(MSG_ENTITY, psf);
43 
44 #define CSQCMODEL_IF(cond) if(cond) {
45 #define CSQCMODEL_ENDIF }
46 #define CSQCMODEL_PROPERTY(flag,t,r,w,f) \
47  if(sf & flag) \
48  { \
49  w(MSG_ENTITY, this.csqcmodel_##f); \
50  }
51 #define CSQCMODEL_PROPERTY_SCALED(flag,t,r,w,f,s,mi,ma) \
52  if(sf & flag) \
53  { \
54  w(MSG_ENTITY, this.csqcmodel_##f); \
55  }
57 #undef CSQCMODEL_PROPERTY_SCALED
58 #undef CSQCMODEL_PROPERTY
59 #undef CSQCMODEL_ENDIF
60 #undef CSQCMODEL_IF
61 
62  return true;
63 }
const int ISPLAYER_PLAYER
Definition: common.qh:59
#define IS_CLIENT(v)
Definition: utils.qh:13
entity to
Definition: self.qh:96
#define ALLPROPERTIES
Definition: common.qh:93
const int ISPLAYER_LOCAL
Definition: common.qh:58
#define BITSET(var, mask, flag)
Definition: bits.qh:11
const int ISPLAYER_CLIENT
Definition: common.qh:57
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CSQCModel_UnlinkEntity()

void CSQCModel_UnlinkEntity ( entity  e)

Definition at line 129 of file sv_model.qc.

References func_null(), and setSendEntity.

Referenced by Monster_Dead(), and vehicles_enter().

130 {
132 }
#define setSendEntity(e, f)
Definition: self.qh:97
var void func_null()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ csqcmodel_nextforcedupdate

float csqcmodel_nextforcedupdate

Definition at line 66 of file sv_model.qc.