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 // #define PROP(public, fld, set, sv, cl)
20 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
21 PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
22 { WriteByte(chan, this.m_switchweapon.m_id); }, \
23 { (viewmodels[this.m_wepent_slot]).switchweapon = Weapons_from(ReadByte()); }) \
25 PROP(false, m_switchingweapon, WEPENT_SET_NORMAL, \
26 { WriteByte(chan, this.m_switchingweapon.m_id); }, \
27 { (viewmodels[this.m_wepent_slot]).switchingweapon = Weapons_from(ReadByte()); }) \
29 PROP(false, m_weapon, WEPENT_SET_NORMAL, \
30 { WriteByte(chan, this.m_weapon.m_id); }, \
31 { (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
37 int WEPENT_PUBLICMASK = 0;
38 STATIC_INIT(WEPENT_PUBLICMASK)
41 #define X(public, fld, set, sv, cl) { \
43 WEPENT_PUBLICMASK |= BIT(i); \
49 if (i >= BITS(16 - 1)) LOG_FATAL("Exceeded WEPENT_NETPROPS limit");
52 bool _wepent_send(entity this, entity to, int sf, int chan)
54 sf |= this.m_forceupdate;
55 this.m_forceupdate = 0;
56 if (chan == MSG_ENTITY)
57 WriteHeader(chan, ENT_CLIENT_WEPENT);
59 WriteHeader(chan, CLIENT_WEPENT);
60 .entity weaponentity = this.weaponentity_fld;
61 WriteByte(chan, weaponslot(weaponentity));
64 #define X(public, fld, set, sv, cl) { \
75 bool wepent_send(entity this, entity to, int sf)
77 return _wepent_send(this, to, sf, MSG_ENTITY);
80 void wepent_update(entity this)
83 #define X(public, fld, set, sv, cl) { \
84 if (this.w_##fld != this.fld) { \
85 set(this.w_##fld, this.fld); \
86 this.SendFlags |= BIT(i); \
94 void wepent_link(entity wep)
96 Net_LinkEntity(wep, false, 0, wepent_send);
103 bool ReadWepent(entity this)
105 this.m_wepent_slot = ReadByte();
106 int sf = ReadShort();
108 #define X(public, fld, set, sv, cl) { \
119 NET_HANDLE(ENT_CLIENT_WEPENT, bool isnew)
124 this.classname = "wepent_receiver";
126 return ReadWepent(this);
129 NET_HANDLE(CLIENT_WEPENT, bool isnew)
131 return ReadWepent(NULL);