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); \
15 .Weapon w_m_switchweapon;
16 .Weapon w_m_switchingweapon;
18 //.float w_weapon_nextthink;
20 .float w_vortex_charge;
22 .bool w_porto_v_angle_held;
25 // #define PROP(public, fld, set, sv, cl)
26 #define WEPENT_NETPROPS(PROP) PROP(false, sv_entnum, WEPENT_SET_NORMAL, {}, {}) /* sentinel */ \
27 PROP(false, m_switchweapon, WEPENT_SET_NORMAL, \
28 { WriteByte(chan, this.m_switchweapon.m_id); }, \
29 { (viewmodels[this.m_wepent_slot]).switchweapon = Weapons_from(ReadByte()); }) \
31 PROP(false, m_switchingweapon, WEPENT_SET_NORMAL, \
32 { WriteByte(chan, this.m_switchingweapon.m_id); }, \
33 { (viewmodels[this.m_wepent_slot]).switchingweapon = Weapons_from(ReadByte()); }) \
35 PROP(false, m_weapon, WEPENT_SET_NORMAL, \
36 { WriteByte(chan, this.m_weapon.m_id); }, \
37 { (viewmodels[this.m_wepent_slot]).activeweapon = Weapons_from(ReadByte()); }) \
39 PROP(false, m_alpha, WEPENT_SET_NORMAL, \
40 { WriteByte(chan, this.m_alpha * 16); }, \
41 { (viewmodels[this.m_wepent_slot]).alpha = ReadByte() / 16; }) \
43 PROP(false, vortex_charge, WEPENT_SET_NORMAL, \
44 { WriteByte(chan, this.vortex_charge * 16); }, \
45 { (viewmodels[this.m_wepent_slot]).vortex_charge = ReadByte() / 16; }) \
47 PROP(false, m_gunalign, WEPENT_SET_NORMAL, \
48 { WriteByte(chan, this.m_gunalign); }, \
49 { (viewmodels[this.m_wepent_slot]).m_gunalign = ReadByte(); }) \
51 PROP(false, porto_v_angle_held, WEPENT_SET_NORMAL, \
52 { WriteByte(chan, this.porto_v_angle_held); if(this.porto_v_angle_held) { \
53 WriteAngle(chan, this.porto_v_angle.x); WriteAngle(chan, this.porto_v_angle.y); \
55 { (viewmodels[this.m_wepent_slot]).angles_held_status = ReadByte(); if((viewmodels[this.m_wepent_slot]).angles_held_status) { \
56 (viewmodels[this.m_wepent_slot]).angles_held_x = ReadAngle(); (viewmodels[this.m_wepent_slot]).angles_held_y = ReadAngle(); (viewmodels[this.m_wepent_slot]).angles_held_z = 0; } \
57 else { (viewmodels[this.m_wepent_slot]).angles_held = '0 0 0'; } }) \
63 int WEPENT_PUBLICMASK = 0;
64 STATIC_INIT(WEPENT_PUBLICMASK)
67 #define X(public, fld, set, sv, cl) { \
69 WEPENT_PUBLICMASK |= BIT(i); \
75 if (i >= BITS(16 - 1)) LOG_FATAL("Exceeded WEPENT_NETPROPS limit");
78 bool _wepent_send(entity this, entity to, int sf, int chan)
80 sf |= this.m_forceupdate;
81 this.m_forceupdate = 0;
82 if (chan == MSG_ENTITY)
83 WriteHeader(chan, ENT_CLIENT_WEPENT);
85 WriteHeader(chan, CLIENT_WEPENT);
86 .entity weaponentity = this.weaponentity_fld;
87 WriteByte(chan, weaponslot(weaponentity));
90 #define X(public, fld, set, sv, cl) { \
101 bool wepent_send(entity this, entity to, int sf)
103 return _wepent_send(this, to, sf, MSG_ENTITY);
106 void wepent_update(entity this)
109 #define X(public, fld, set, sv, cl) { \
110 if (this.w_##fld != this.fld) { \
111 set(this.w_##fld, this.fld); \
112 this.SendFlags |= BIT(i); \
120 void wepent_link(entity wep)
122 Net_LinkEntity(wep, false, 0, wepent_send);
129 bool ReadWepent(entity this)
131 this.m_wepent_slot = ReadByte();
132 int sf = ReadShort();
134 #define X(public, fld, set, sv, cl) { \
145 NET_HANDLE(ENT_CLIENT_WEPENT, bool isnew)
150 this.classname = "wepent_receiver";
152 return ReadWepent(this);
155 NET_HANDLE(CLIENT_WEPENT, bool isnew)
157 return ReadWepent(NULL);