3 #define WEPENT_SET_NORMAL(var, x) MACRO_BEGIN \
7 /** the engine player name strings are mutable! */
8 #define WEPENT_SET_MUTABLE_STRING(var, x) MACRO_BEGIN \
9 if (var) strunzone(var); \
14 .Weapon w_m_switchweapon;
15 .Weapon w_m_switchingweapon;
17 //.float w_weapon_nextthink;
19 .float w_vortex_charge;
22 // #define PROP(public, fld, set, sv, cl)
23 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
24 PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
25 { WriteByte(chan, this.m_switchweapon.m_id); }, \
26 { (viewmodels[this.m_wepent_slot]).switchweapon = Weapons_from(ReadByte()); }) \
28 PROP(false, m_switchingweapon, WEPENT_SET_NORMAL, \
29 { WriteByte(chan, this.m_switchingweapon.m_id); }, \
30 { (viewmodels[this.m_wepent_slot]).switchingweapon = Weapons_from(ReadByte()); }) \
32 PROP(false, m_weapon, WEPENT_SET_NORMAL, \
33 { WriteByte(chan, this.m_weapon.m_id); }, \
34 { (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
36 PROP(false, m_alpha, WEPENT_SET_NORMAL, \
37 { WriteByte(chan, this.m_alpha * 16); }, \
38 { (viewmodels[this.m_wepent_slot]).alpha = ReadByte() / 16; }) \
40 PROP(false, vortex_charge, WEPENT_SET_NORMAL, \
41 { WriteByte(chan, this.vortex_charge * 16); }, \
42 { (viewmodels[this.m_wepent_slot]).vortex_charge = ReadByte() / 16; }) \
44 PROP(false, m_gunalign, WEPENT_SET_NORMAL, \
45 { WriteByte(chan, this.m_gunalign); }, \
46 { (viewmodels[this.m_wepent_slot]).m_gunalign = ReadByte(); }) \
52 int WEPENT_PUBLICMASK = 0;
53 STATIC_INIT(WEPENT_PUBLICMASK)
56 #define X(public, fld, set, sv, cl) { \
58 WEPENT_PUBLICMASK |= BIT(i); \
64 if (i >= BITS(16 - 1)) LOG_FATAL("Exceeded WEPENT_NETPROPS limit");
67 bool _wepent_send(entity this, entity to, int sf, int chan)
69 sf |= this.m_forceupdate;
70 this.m_forceupdate = 0;
71 if (chan == MSG_ENTITY)
72 WriteHeader(chan, ENT_CLIENT_WEPENT);
74 WriteHeader(chan, CLIENT_WEPENT);
75 .entity weaponentity = this.weaponentity_fld;
76 WriteByte(chan, weaponslot(weaponentity));
79 #define X(public, fld, set, sv, cl) { \
90 bool wepent_send(entity this, entity to, int sf)
92 return _wepent_send(this, to, sf, MSG_ENTITY);
95 void wepent_update(entity this)
98 #define X(public, fld, set, sv, cl) { \
99 if (this.w_##fld != this.fld) { \
100 set(this.w_##fld, this.fld); \
101 this.SendFlags |= BIT(i); \
109 void wepent_link(entity wep)
111 Net_LinkEntity(wep, false, 0, wepent_send);
118 bool ReadWepent(entity this)
120 this.m_wepent_slot = ReadByte();
121 int sf = ReadShort();
123 #define X(public, fld, set, sv, cl) { \
134 NET_HANDLE(ENT_CLIENT_WEPENT, bool isnew)
139 this.classname = "wepent_receiver";
141 return ReadWepent(this);
144 NET_HANDLE(CLIENT_WEPENT, bool isnew)
146 return ReadWepent(NULL);