Player: Streamline networking code by using the new macros Nuclide provides
This commit is contained in:
parent
ab31ae0242
commit
cf50584211
1 changed files with 87 additions and 161 deletions
|
@ -124,52 +124,42 @@ player::ReceiveEntity
|
|||
=================
|
||||
*/
|
||||
void
|
||||
player::ReceiveEntity(float new, float fl)
|
||||
player::ReceiveEntity(float new, float flChanged)
|
||||
{
|
||||
/* the generic client attributes */
|
||||
NSClientPlayer::ReceiveEntity(new, fl);
|
||||
NSClientPlayer::ReceiveEntity(new, flChanged);
|
||||
|
||||
/* animation */
|
||||
if (fl & PLAYER_TOPFRAME) {
|
||||
anim_top = readbyte();
|
||||
anim_top_time = readfloat();
|
||||
anim_top_delay = readfloat();
|
||||
}
|
||||
if (fl & PLAYER_BOTTOMFRAME) {
|
||||
anim_bottom = readbyte();
|
||||
anim_bottom_time = readfloat();
|
||||
}
|
||||
READENTITY_BYTE(anim_top, PLAYER_TOPFRAME)
|
||||
READENTITY_FLOAT(anim_top_time, PLAYER_TOPFRAME)
|
||||
READENTITY_FLOAT(anim_top_delay, PLAYER_TOPFRAME)
|
||||
READENTITY_BYTE(anim_bottom, PLAYER_BOTTOMFRAME)
|
||||
READENTITY_FLOAT(anim_bottom_time, PLAYER_BOTTOMFRAME)
|
||||
|
||||
if (fl & PLAYER_AMMO1) {
|
||||
glock_mag = readbyte();
|
||||
mp5_mag = readbyte();
|
||||
python_mag = readbyte();
|
||||
shotgun_mag = readbyte();
|
||||
crossbow_mag = readbyte();
|
||||
rpg_mag = readbyte();
|
||||
satchel_chg = readbyte();
|
||||
}
|
||||
|
||||
if (fl & PLAYER_AMMO2) {
|
||||
ammo_9mm = readbyte();
|
||||
ammo_357 = readbyte();
|
||||
ammo_buckshot = readbyte();
|
||||
ammo_bolt = readbyte();
|
||||
ammo_rocket = readbyte();
|
||||
ammo_uranium = readbyte();
|
||||
ammo_handgrenade = readbyte();
|
||||
ammo_satchel = readbyte();
|
||||
ammo_tripmine = readbyte();
|
||||
ammo_snark = readbyte();
|
||||
ammo_hornet = readbyte();
|
||||
}
|
||||
READENTITY_BYTE(glock_mag, PLAYER_AMMO1)
|
||||
READENTITY_BYTE(mp5_mag, PLAYER_AMMO1)
|
||||
READENTITY_BYTE(python_mag, PLAYER_AMMO1)
|
||||
READENTITY_BYTE(shotgun_mag, PLAYER_AMMO1)
|
||||
READENTITY_BYTE(crossbow_mag, PLAYER_AMMO1)
|
||||
READENTITY_BYTE(rpg_mag, PLAYER_AMMO1)
|
||||
READENTITY_BYTE(satchel_chg, PLAYER_AMMO1)
|
||||
|
||||
if (fl & PLAYER_AMMO3) {
|
||||
ammo_m203_grenade = readbyte();
|
||||
ammo_gauss_volume = readbyte();
|
||||
ammo_rpg_state = readbyte();
|
||||
mode_tempstate = readbyte();
|
||||
}
|
||||
READENTITY_BYTE(ammo_9mm, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_357, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_buckshot, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_bolt, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_rocket, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_uranium, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_handgrenade, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_satchel, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_tripmine, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_snark, PLAYER_AMMO2)
|
||||
READENTITY_BYTE(ammo_hornet, PLAYER_AMMO2)
|
||||
|
||||
READENTITY_BYTE(ammo_m203_grenade, PLAYER_AMMO3)
|
||||
READENTITY_BYTE(ammo_gauss_volume, PLAYER_AMMO3)
|
||||
READENTITY_BYTE(ammo_rpg_state, PLAYER_AMMO3)
|
||||
READENTITY_BYTE(mode_tempstate, PLAYER_AMMO3)
|
||||
|
||||
setorigin(this, origin);
|
||||
|
||||
|
@ -179,15 +169,15 @@ player::ReceiveEntity(float new, float fl)
|
|||
return;
|
||||
|
||||
/* do not notify us of updates when spawning initially */
|
||||
if (fl == UPDATE_ALL)
|
||||
if (flChanged == UPDATE_ALL)
|
||||
PredictPreFrame();
|
||||
|
||||
if (fl & PLAYER_AMMO1 || fl & PLAYER_AMMO2 || fl & PLAYER_AMMO3) {
|
||||
if (flChanged & PLAYER_AMMO1 || flChanged & PLAYER_AMMO2 || flChanged & PLAYER_AMMO3) {
|
||||
Weapons_AmmoUpdate(this);
|
||||
HUD_AmmoNotify_Check(this);
|
||||
}
|
||||
|
||||
if (fl & PLAYER_ITEMS || fl & PLAYER_HEALTH)
|
||||
if (flChanged & PLAYER_ITEMS || flChanged & PLAYER_HEALTH)
|
||||
HUD_ItemNotify_Check(this);
|
||||
}
|
||||
|
||||
|
@ -423,90 +413,36 @@ player::EvaluateEntity(void)
|
|||
/* the generic client attributes */
|
||||
NSClientPlayer::EvaluateEntity();
|
||||
|
||||
/* animation */
|
||||
if (ATTR_CHANGED(anim_bottom) || ATTR_CHANGED(anim_bottom_time))
|
||||
SendFlags |= PLAYER_BOTTOMFRAME;
|
||||
if (ATTR_CHANGED(anim_top) || ATTR_CHANGED(anim_top_time) || ATTR_CHANGED(anim_top_delay))
|
||||
SendFlags |= PLAYER_TOPFRAME;
|
||||
EVALUATE_FIELD(anim_top, PLAYER_TOPFRAME);
|
||||
EVALUATE_FIELD(anim_top_time, PLAYER_TOPFRAME);
|
||||
EVALUATE_FIELD(anim_top_delay, PLAYER_TOPFRAME |