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;
20 // #define PROP(public, fld, set, sv, cl)
21 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
22 PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
23 { WriteByte(chan, this.m_switchweapon.m_id); }, \
24 { (viewmodels[this.m_wepent_slot]).switchweapon = Weapons_from(ReadByte()); }) \
26 PROP(false, m_switchingweapon, WEPENT_SET_NORMAL, \
27 { WriteByte(chan, this.m_switchingweapon.m_id); }, \
28 { (viewmodels[this.m_wepent_slot]).switchingweapon = Weapons_from(ReadByte()); }) \
30 PROP(false, m_weapon, WEPENT_SET_NORMAL, \
31 { WriteByte(chan, this.m_weapon.m_id); }, \
32 { (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
34 PROP(false, m_alpha, WEPENT_SET_NORMAL, \
35 { WriteByte(chan, this.m_alpha * 16); }, \
36 { (viewmodels[this.m_wepent_slot]).alpha = ReadByte() / 16; }) \
42 int WEPENT_PUBLICMASK = 0;
43 STATIC_INIT(WEPENT_PUBLICMASK)
46 #define X(public, fld, set, sv, cl) { \
48 WEPENT_PUBLICMASK |= BIT(i); \
54 if (i >= BITS(16 - 1)) LOG_FATAL("Exceeded WEPENT_NETPROPS limit");
57 bool _wepent_send(entity this, entity to, int sf, int chan)
59 sf |= this.m_forceupdate;
60 this.m_forceupdate = 0;
61 if (chan == MSG_ENTITY)
62 WriteHeader(chan, ENT_CLIENT_WEPENT);
64 WriteHeader(chan, CLIENT_WEPENT);
65 .entity weaponentity = this.weaponentity_fld;
66 WriteByte(chan, weaponslot(weaponentity));
69 #define X(public, fld, set, sv, cl) { \
80 bool wepent_send(entity this, entity to, int sf)
82 return _wepent_send(this, to, sf, MSG_ENTITY);
85 void wepent_update(entity this)
88 #define X(public, fld, set, sv, cl) { \
89 if (this.w_##fld != this.fld) { \
90 set(this.w_##fld, this.fld); \
91 this.SendFlags |= BIT(i); \
99 void wepent_link(entity wep)
101 Net_LinkEntity(wep, false, 0, wepent_send);
108 bool ReadWepent(entity this)
110 this.m_wepent_slot = ReadByte();
111 int sf = ReadShort();
113 #define X(public, fld, set, sv, cl) { \
124 NET_HANDLE(ENT_CLIENT_WEPENT, bool isnew)
129 this.classname = "wepent_receiver";
131 return ReadWepent(this);
134 NET_HANDLE(CLIENT_WEPENT, bool isnew)
136 return ReadWepent(NULL);