Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
wepent.qc File Reference
#include "wepent.qh"
Include dependency graph for wepent.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WEPENT_NETPROPS(PROP)
#define WEPENT_SET_NORMAL(var, x)
#define X(public, fld, set, sv, cl)
#define X(public, fld, set, sv, cl)
#define X(public, fld, set, sv, cl)
#define X(public, fld, set, sv, cl)

Functions

bool _wepent_send (entity this, entity to, int sf, int chan)
 NET_HANDLE (CLIENT_WEPENT, bool isnew)
 NET_HANDLE (ENT_CLIENT_WEPENT, bool isnew)
bool ReadWepent (entity this)
 STATIC_INIT (WEPENT_PUBLICMASK)
bool wepent_customize (entity this, entity client)
void wepent_link (entity wep)
bool wepent_send (entity this, entity to, int sf)
void wepent_think (entity this)

Variables

int WEPENT_PUBLICMASK = 0

Macro Definition Documentation

◆ WEPENT_NETPROPS

#define WEPENT_NETPROPS ( PROP)

Definition at line 8 of file wepent.qc.

8#define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
9 PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
10 { WriteByte(chan, this.m_switchweapon.m_id); }, \
11 { (viewmodels[this.m_wepent_slot]).switchweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
12 \
13 PROP(false, m_switchingweapon, WEPENT_SET_NORMAL, \
14 { WriteByte(chan, this.m_switchingweapon.m_id); }, \
15 { (viewmodels[this.m_wepent_slot]).switchingweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
16 \
17 PROP(false, m_weapon, WEPENT_SET_NORMAL, \
18 { WriteByte(chan, this.m_weapon.m_id); }, \
19 { (viewmodels[this.m_wepent_slot]).activeweapon = REGISTRY_GET(Weapons, ReadByte()); }) \
20 \
21 PROP(false, m_alpha, WEPENT_SET_NORMAL, \
22 { WriteByte(chan, rint(bound(-1, 254 * this.m_alpha, 254) - -1)); }, \
23 { (viewmodels[this.m_wepent_slot]).m_alpha = (ReadByte() + -1) / 254; }) \
24 \
25 PROP(false, vortex_charge, WEPENT_SET_NORMAL, \
26 { WriteByte(chan, this.vortex_charge * 255); }, \
27 { (viewmodels[this.m_wepent_slot]).vortex_charge = ReadByte() / 255; }) \
28 \
29 PROP(false, oknex_charge, WEPENT_SET_NORMAL, \
30 { WriteByte(chan, this.oknex_charge * 16); }, \
31 { (viewmodels[this.m_wepent_slot]).oknex_charge = ReadByte() / 16; }) \
32 \
33 PROP(false, m_gunalign, WEPENT_SET_NORMAL, \
34 { WriteByte(chan, this.m_gunalign); }, \
35 { (viewmodels[this.m_wepent_slot]).m_gunalign = ReadByte(); }) \
36 \
37 PROP(false, porto_v_angle_held, WEPENT_SET_NORMAL, \
38 { WriteByte(chan, this.porto_v_angle_held); if(this.porto_v_angle_held) { \
39 WriteAngleVector2D(chan, this.owner.porto_v_angle); \
40 } }, \
41 { (viewmodels[this.m_wepent_slot]).angles_held_status = ReadByte(); if((viewmodels[this.m_wepent_slot]).angles_held_status) { \
42 (viewmodels[this.m_wepent_slot]).angles_held = ReadAngleVector2D(); } \
43 else { (viewmodels[this.m_wepent_slot]).angles_held = '0 0 0'; } }) \
44 \
45 PROP(false, tuba_instrument, WEPENT_SET_NORMAL, \
46 { WriteByte(chan, this.tuba_instrument); }, \
47 { (viewmodels[this.m_wepent_slot]).tuba_instrument = ReadByte(); }) \
48 \
49 PROP(false, hagar_load, WEPENT_SET_NORMAL, \
50 { WriteByte(chan, this.hagar_load); }, \
51 { (viewmodels[this.m_wepent_slot]).hagar_load = ReadByte(); }) \
52 \
53 PROP(false, minelayer_mines, WEPENT_SET_NORMAL, \
54 { WriteByte(chan, this.minelayer_mines); }, \
55 { (viewmodels[this.m_wepent_slot]).minelayer_mines = ReadByte(); }) \
56 \
57 PROP(false, arc_heat_percent, WEPENT_SET_NORMAL, \
58 { WriteByte(chan, this.arc_heat_percent * 255); }, \
59 { (viewmodels[this.m_wepent_slot]).arc_heat_percent = ReadByte() / 255; }) \
60 \
61 PROP(false, vortex_chargepool_ammo, WEPENT_SET_NORMAL, \
62 { WriteByte(chan, this.vortex_chargepool_ammo * 16); }, \
63 { (viewmodels[this.m_wepent_slot]).vortex_chargepool_ammo = ReadByte() / 16; }) \
64 \
65 PROP(false, oknex_chargepool_ammo, WEPENT_SET_NORMAL, \
66 { WriteByte(chan, this.oknex_chargepool_ammo * 16); }, \
67 { (viewmodels[this.m_wepent_slot]).oknex_chargepool_ammo = ReadByte() / 16; }) \
68 \
69 PROP(false, clip_load, WEPENT_SET_NORMAL, \
70 { WriteShort(chan, this.clip_load); }, \
71 { (viewmodels[this.m_wepent_slot]).clip_load = ReadShort(); }) \
72 \
73 PROP(false, clip_size, WEPENT_SET_NORMAL, \
74 { WriteShort(chan, this.clip_size); }, \
75 { (viewmodels[this.m_wepent_slot]).clip_size = ReadShort(); }) \
76 \
77 PROP(false, skin, WEPENT_SET_NORMAL, \
78 { WriteShort(chan, this.skin); }, \
79 { (viewmodels[this.m_wepent_slot]).m_skin = ReadShort(); }) \
80 \
81 /**/

Referenced by _wepent_send(), ReadWepent(), STATIC_INIT(), and wepent_think().

◆ WEPENT_SET_NORMAL

#define WEPENT_SET_NORMAL ( var,
x )
Value:
MACRO_BEGIN \
var = x; \
#define MACRO_END
Definition macro.qh:7

Definition at line 3 of file wepent.qc.

3#define WEPENT_SET_NORMAL(var, x) MACRO_BEGIN \
4 var = x; \
5MACRO_END

◆ X [1/4]

#define X ( public,
fld,
set,
sv,
cl )
Value:
{ \
if (public) { \
} \
i += 1; \
}
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
Definition bits.qh:8
int WEPENT_PUBLICMASK
Definition wepent.qc:85

◆ X [2/4]

#define X ( public,
fld,
set,
sv,
cl )
Value:
{ \
if (sf & BIT(i)) { \
sv; \
} \
i += 1; \
}

◆ X [3/4]

#define X ( public,
fld,
set,
sv,
cl )
Value:
{ \
if (this.fld != o.fld) { \
set(this.fld, o.fld); \
this.SendFlags |= BIT(i); \
} \
i += 1; \
}
int SendFlags
Definition net.qh:118

◆ X [4/4]

#define X ( public,
fld,
set,
sv,
cl )
Value:
{ \
if (sf & BIT(i)) { \
cl; \
} \
i += 1; \
}

Function Documentation

◆ _wepent_send()

bool _wepent_send ( entity this,
entity to,
int sf,
int chan )

Definition at line 100 of file wepent.qc.

101 {
102 sf |= this.m_forceupdate;
103 this.m_forceupdate = 0;
104 if (chan == MSG_ENTITY)
105 WriteHeader(chan, ENT_CLIENT_WEPENT);
106 else
107 WriteHeader(chan, CLIENT_WEPENT);
108 .entity weaponentity = this.owner.weaponentity_fld;
109 WriteByte(chan, weaponslot(weaponentity));
110 WriteInt24_t(chan, sf);
111 int i = 0;
112 #define X(public, fld, set, sv, cl) { \
113 if (sf & BIT(i)) { \
114 sv; \
115 } \
116 i += 1; \
117 }
119 #undef X
120 return true;
121 }
entity owner
Definition main.qh:87
int m_forceupdate
Definition ent_cs.qh:44
#define X()
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
void WriteByte(float data, float dest, float desto)
int weaponslot(.entity weaponentity)
Definition weapon.qh:19
#define WEPENT_NETPROPS(PROP)
Definition wepent.qc:8

References entity(), m_forceupdate, MSG_ENTITY, owner, weaponslot(), WEPENT_NETPROPS, WriteByte(), WriteHeader, and X.

Referenced by wepent_send().

◆ NET_HANDLE() [1/2]

NET_HANDLE ( CLIENT_WEPENT ,
bool isnew )

Definition at line 197 of file wepent.qc.

198 {
199 return ReadWepent(NULL);
200 }
#define NULL
Definition post.qh:14
bool ReadWepent(entity this)
Definition wepent.qc:174

References NULL, and ReadWepent().

◆ NET_HANDLE() [2/2]

NET_HANDLE ( ENT_CLIENT_WEPENT ,
bool isnew )

Definition at line 192 of file wepent.qc.

193 {
194 return ReadWepent(this);
195 }

References ReadWepent().

◆ ReadWepent()

bool ReadWepent ( entity this)

Definition at line 174 of file wepent.qc.

175 {
176 int slot = ReadByte();
177 this.m_wepent_slot = slot;
178 viewmodels[slot].m_wepent_slot = slot;
179 int sf = ReadInt24_t();
180 int i = 0;
181 #define X(public, fld, set, sv, cl) { \
182 if (sf & BIT(i)) { \
183 cl; \
184 } \
185 i += 1; \
186 }
188 #undef X
189 return true;
190 }
int ReadInt24_t()
Definition net.qh:355
int ReadByte()
entity viewmodels[MAX_WEAPONSLOTS]
Definition view.qh:108
int m_wepent_slot
Definition wepent.qh:32

References entity(), m_wepent_slot, ReadByte(), ReadInt24_t(), viewmodels, WEPENT_NETPROPS, and X.

Referenced by NET_HANDLE(), and NET_HANDLE().

◆ STATIC_INIT()

STATIC_INIT ( WEPENT_PUBLICMASK )

Definition at line 86 of file wepent.qc.

87 {
88 int i = 0;
89 #define X(public, fld, set, sv, cl) { \
90 if (public) { \
91 WEPENT_PUBLICMASK |= BIT(i); \
92 } \
93 i += 1; \
94 }
96 #undef X
97 if (i >= BITS(24 - 1)) LOG_FATAL("Exceeded WEPENT_NETPROPS limit");
98 }
#define BITS(n)
Definition bits.qh:9
#define LOG_FATAL(...)
Definition log.qh:53

References BITS, LOG_FATAL, WEPENT_NETPROPS, WEPENT_PUBLICMASK, and X.

◆ wepent_customize()

bool wepent_customize ( entity this,
entity client )

Definition at line 152 of file wepent.qc.

153 {
155 .entity weaponentity = this.owner.weaponentity_fld;
156 return e.(weaponentity) == this.owner;
157 }
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity WaypointSprite_getviewentity(entity e)

References entity(), owner, and WaypointSprite_getviewentity().

Referenced by wepent_link().

◆ wepent_link()

void wepent_link ( entity wep)

Definition at line 159 of file wepent.qc.

160 {
161 entity e = new_pure(wepent_sender);
162 e.owner = wep;
164 e.nextthink = time;
165 //e.drawonlytoclient = wep.owner;
167 Net_LinkEntity(e, false, 0, wepent_send);
168 }
float time
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
Definition net.qh:123
#define new_pure(class)
purely logical entities (not linked to the area grid)
Definition oo.qh:67
#define setthink(e, f)
#define setcefc(e, f)
void wepent_think(entity this)
Definition wepent.qc:128
bool wepent_send(entity this, entity to, int sf)
Definition wepent.qc:123
bool wepent_customize(entity this, entity client)
Definition wepent.qc:152

References entity(), Net_LinkEntity(), new_pure, setcefc, setthink, time, wepent_customize(), wepent_send(), and wepent_think().

Referenced by CL_SpawnWeaponentity().

◆ wepent_send()

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

Definition at line 123 of file wepent.qc.

124 {
125 return _wepent_send(this, to, sf, MSG_ENTITY);
126 }
bool _wepent_send(entity this, entity to, int sf, int chan)
Definition wepent.qc:100

References _wepent_send(), entity(), and MSG_ENTITY.

Referenced by wepent_link().

◆ wepent_think()

void wepent_think ( entity this)

Definition at line 128 of file wepent.qc.

129 {
130 if(wasfreed(this.owner) || !this.owner)
131 {
132 delete(this);
133 return;
134 }
135
136 this.nextthink = time;
137
138 entity o = this.owner;
139
140 int i = 0;
141 #define X(public, fld, set, sv, cl) { \
142 if (this.fld != o.fld) { \
143 set(this.fld, o.fld); \
144 this.SendFlags |= BIT(i); \
145 } \
146 i += 1; \
147 }
149 #undef X
150 }
float nextthink

References entity(), nextthink, owner, time, WEPENT_NETPROPS, and X.

Referenced by wepent_link().

Variable Documentation

◆ WEPENT_PUBLICMASK

int WEPENT_PUBLICMASK = 0

Definition at line 85 of file wepent.qc.

Referenced by STATIC_INIT().