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;
21 // #define PROP(public, fld, set, sv, cl)
22 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
23 PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
24 { WriteByte(chan, this.m_switchweapon.m_id); }, \
25 { (viewmodels[this.m_wepent_slot]).switchweapon = Weapons_from(ReadByte()); }) \
27 PROP(false, m_switchingweapon, WEPENT_SET_NORMAL, \
28 { WriteByte(chan, this.m_switchingweapon.m_id); }, \
29 { (viewmodels[this.m_wepent_slot]).switchingweapon = Weapons_from(ReadByte()); }) \
31 PROP(false, m_weapon, WEPENT_SET_NORMAL, \
32 { WriteByte(chan, this.m_weapon.m_id); }, \
33 { (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
35 PROP(false, m_alpha, WEPENT_SET_NORMAL, \
36 { WriteByte(chan, this.m_alpha * 16); }, \
37 { (viewmodels[this.m_wepent_slot]).alpha = ReadByte() / 16; }) \
39 PROP(false, vortex_charge, WEPENT_SET_NORMAL, \
40 { WriteByte(chan, this.vortex_charge * 16); }, \
41 { (viewmodels[this.m_wepent_slot]).vortex_charge = ReadByte() / 16; }) \
47 int WEPENT_PUBLICMASK = 0;
48 STATIC_INIT(WEPENT_PUBLICMASK)
51 #define X(public, fld, set, sv, cl) { \
53 WEPENT_PUBLICMASK |= BIT(i); \
59 if (i >= BITS(16 - 1)) LOG_FATAL("Exceeded WEPENT_NETPROPS limit");
62 bool _wepent_send(entity this, entity to, int sf, int chan)
64 sf |= this.m_forceupdate;
65 this.m_forceupdate = 0;
66 if (chan == MSG_ENTITY)
67 WriteHeader(chan, ENT_CLIENT_WEPENT);
69 WriteHeader(chan, CLIENT_WEPENT);
70 .entity weaponentity = this.weaponentity_fld;
71 WriteByte(chan, weaponslot(weaponentity));
74 #define X(public, fld, set, sv, cl) { \
85 bool wepent_send(entity this, entity to, int sf)
87 return _wepent_send(this, to, sf, MSG_ENTITY);
90 void wepent_update(entity this)
93 #define X(public, fld, set, sv, cl) { \
94 if (this.w_##fld != this.fld) { \
95 set(this.w_##fld, this.fld); \
96 this.SendFlags |= BIT(i); \
104 void wepent_link(entity wep)
106 Net_LinkEntity(wep, false, 0, wepent_send);
113 bool ReadWepent(entity this)
115 this.m_wepent_slot = ReadByte();
116 int sf = ReadShort();
118 #define X(public, fld, set, sv, cl) { \
129 NET_HANDLE(ENT_CLIENT_WEPENT, bool isnew)
134 this.classname = "wepent_receiver";
136 return ReadWepent(this);
139 NET_HANDLE(CLIENT_WEPENT, bool isnew)
141 return ReadWepent(NULL);