Rename all instances of ::ammo_handgrenade_state to ::mode_tempstate as

it's used in plenty of other instances, by other weapons, as it's not
meant to be persistent.
This commit is contained in:
Marco Cawthorne 2021-03-04 02:07:08 +01:00
parent 8a6cf34179
commit 0eeb27a65a
8 changed files with 65 additions and 53 deletions

View file

@ -135,8 +135,8 @@ class player:base_player
int ammo_egon_state_net;
int ammo_rpg_state;
int ammo_rpg_state_net;
int ammo_handgrenade_state;
int ammo_handgrenade_state_net;
int mode_tempstate;
int mode_tempstate_net;
/* gearbox */
int eagle_mag; int eagle_mag_net;
@ -312,7 +312,7 @@ player::ReceiveEntity(float new)
ammo_gauss_volume = readbyte();
ammo_egon_state = readbyte();
ammo_rpg_state = readbyte();
ammo_handgrenade_state = readbyte();
mode_tempstate = readbyte();
/* gearbox */
mode_displacer = readbyte();
@ -364,7 +364,7 @@ player::PredictPreFrame(void)
ammo_gauss_volume_net = ammo_gauss_volume;
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
ammo_handgrenade_state_net = ammo_handgrenade_state;
mode_tempstate_net = mode_tempstate;
/* gearbox */
eagle_mag_net = eagle_mag;
@ -419,7 +419,7 @@ player::PredictPostFrame(void)
ammo_gauss_volume = ammo_gauss_volume_net;
ammo_egon_state = ammo_egon_state_net;
ammo_rpg_state = ammo_rpg_state_net;
ammo_handgrenade_state = ammo_handgrenade_state_net;
mode_tempstate = mode_tempstate_net;
/* gearbox */
eagle_mag = eagle_mag_net;
@ -580,7 +580,7 @@ player::EvaluateEntity(void)
if (ammo_rpg_state != ammo_rpg_state_net) {
SendFlags |= PLAYER_AMMO3;
}
if (ammo_handgrenade_state != ammo_handgrenade_state_net) {
if (mode_tempstate != mode_tempstate_net) {
SendFlags |= PLAYER_AMMO3;
}
@ -627,7 +627,7 @@ player::EvaluateEntity(void)
ammo_gauss_volume_net = ammo_gauss_volume;
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
ammo_handgrenade_state_net = ammo_handgrenade_state;
mode_tempstate_net = mode_tempstate;
/* gearbox */
if (eagle_mag_net != eagle_mag)
@ -790,7 +790,7 @@ player::SendEntity(entity ePEnt, float fChanged)
WriteByte(MSG_ENTITY, ammo_gauss_volume);
WriteByte(MSG_ENTITY, ammo_egon_state);
WriteByte(MSG_ENTITY, ammo_rpg_state);
WriteByte(MSG_ENTITY, ammo_handgrenade_state);
WriteByte(MSG_ENTITY, mode_tempstate);
/* gearbox */
WriteByte(MSG_ENTITY, mode_displacer);

View file

@ -135,8 +135,8 @@ class player:base_player
int ammo_egon_state_net;
int ammo_rpg_state;
int ammo_rpg_state_net;
int ammo_handgrenade_state;
int ammo_handgrenade_state_net;
int mode_tempstate;
int mode_tempstate_net;
/* hunger */
int sniper_mag; int sniper_mag_net;
@ -311,7 +311,7 @@ player::ReceiveEntity(float new)
ammo_gauss_volume = readbyte();
ammo_egon_state = readbyte();
ammo_rpg_state = readbyte();
ammo_handgrenade_state = readbyte();
mode_tempstate = readbyte();
mode_silencer = readbyte();
}
@ -357,7 +357,7 @@ player::PredictPreFrame(void)
ammo_gauss_volume_net = ammo_gauss_volume;
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
ammo_handgrenade_state_net = ammo_handgrenade_state;
mode_tempstate_net = mode_tempstate;
/* gearbox */
sniper_mag_net = sniper_mag;
@ -411,7 +411,7 @@ player::PredictPostFrame(void)
ammo_gauss_volume = ammo_gauss_volume_net;
ammo_egon_state = ammo_egon_state_net;
ammo_rpg_state = ammo_rpg_state_net;
ammo_handgrenade_state = ammo_handgrenade_state_net;
mode_tempstate = mode_tempstate_net;
/* hunger */
sniper_mag = sniper_mag_net;
@ -571,7 +571,7 @@ player::EvaluateEntity(void)
if (ammo_rpg_state != ammo_rpg_state_net) {
SendFlags |= PLAYER_AMMO3;
}
if (ammo_handgrenade_state != ammo_handgrenade_state_net) {
if (mode_tempstate != mode_tempstate_net) {
SendFlags |= PLAYER_AMMO3;
}
@ -618,7 +618,7 @@ player::EvaluateEntity(void)
ammo_gauss_volume_net = ammo_gauss_volume;
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
ammo_handgrenade_state_net = ammo_handgrenade_state;
mode_tempstate_net = mode_tempstate;
/* hunger */
if (sniper_mag != sniper_mag_net)
@ -776,7 +776,7 @@ player::SendEntity(entity ePEnt, float fChanged)
WriteByte(MSG_ENTITY, ammo_gauss_volume);
WriteByte(MSG_ENTITY, ammo_egon_state);
WriteByte(MSG_ENTITY, ammo_rpg_state);
WriteByte(MSG_ENTITY, ammo_handgrenade_state);
WriteByte(MSG_ENTITY, mode_tempstate);
WriteByte(MSG_ENTITY, mode_silencer);
}

View file

@ -88,6 +88,9 @@ void
w_chaingun_draw(void)
{
#ifdef CLIENT
player pl = (player)self;
pl.mode_tempstate = 0;
Weapons_SetModel("models/v_tfac.mdl");
Weapons_ViewAnimation(CHAINGUN_DRAW);
#endif
@ -116,8 +119,8 @@ w_chaingun_release(void)
}
/* end firing */
if (pl.ammo_handgrenade_state == 1) {
pl.ammo_handgrenade_state = 0;
if (pl.mode_tempstate == 1) {
pl.mode_tempstate = 0;
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_chaingun.spindown");
#endif
@ -128,8 +131,8 @@ w_chaingun_release(void)
}
/* end reload */
if (pl.ammo_handgrenade_state == 2) {
pl.ammo_handgrenade_state = 0;
if (pl.mode_tempstate == 2) {
pl.mode_tempstate = 0;
Weapons_ViewAnimation(CHAINGUN_DRAW);
pl.w_attack_next = 1.0f;
pl.w_idle_next = pl.w_attack_next;
@ -152,7 +155,7 @@ w_chaingun_primary(void)
player pl = (player)self;
/* in case we're spamming primary while reloading */
if (pl.ammo_handgrenade_state == 2) {
if (pl.mode_tempstate == 2) {
w_chaingun_release();
return;
}
@ -167,8 +170,8 @@ w_chaingun_primary(void)
}
/* spin up first */
if (pl.ammo_handgrenade_state == 0) {
pl.ammo_handgrenade_state = 1;
if (pl.mode_tempstate == 0) {
pl.mode_tempstate = 1;
Weapons_ViewAnimation(CHAINGUN_SPINUP);
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_chaingun.spinup");
@ -217,7 +220,7 @@ w_chaingun_reload(void)
Weapons_ReloadWeapon(pl, player::chaingun_mag, player::ammo_9mm, 100);
#endif
pl.ammo_handgrenade_state = 2;
pl.mode_tempstate = 2;
pl.w_attack_next = 10.0f;
pl.w_idle_next = 1.5f;
}

View file

@ -84,6 +84,9 @@ void
w_sniper_draw(void)
{
#ifdef CLIENT
player pl = (player)self;
pl.mode_tempstate = 0;
Weapons_SetModel("models/v_tfc_sniper.mdl");
Weapons_ViewAnimation(SNIPER_DRAW);
#endif
@ -113,9 +116,9 @@ w_sniper_release(void)
return;
}
if (pl.ammo_handgrenade_state == 1) {
if (pl.mode_tempstate == 1) {
Weapons_ViewAnimation(SNIPER_DRAW);
pl.ammo_handgrenade_state = 0;
pl.mode_tempstate = 0;
pl.w_attack_next = 0.0f;
pl.w_idle_next = 15.0f;
return;
@ -213,7 +216,7 @@ w_sniper_reload(void)
Weapons_ReloadWeapon(pl, player::sniper_mag, player::ammo_sniper, 5);
#endif
pl.ammo_handgrenade_state = 1;
pl.mode_tempstate = 1;
pl.w_attack_next = 2.5f;
pl.w_idle_next = 2.0f;
}

View file

@ -120,6 +120,9 @@ void w_tnt_throw(void)
void w_tnt_draw(void)
{
#ifdef CLIENT
player pl = (player)self;
pl.mode_tempstate = 0;
Weapons_SetModel("models/v_tnt.mdl");
Weapons_ViewAnimation(HANDGRENADE_DRAW);
#endif
@ -152,7 +155,7 @@ void w_tnt_release(void)
return;
}
if (pl.ammo_handgrenade_state == 1) {
if (pl.mode_tempstate == 1) {
#ifdef CLIENT
pl.ammo_handgrenade--;
Weapons_ViewAnimation(HANDGRENADE_THROW1);
@ -160,10 +163,10 @@ void w_tnt_release(void)
pl.ammo_handgrenade--;
w_tnt_throw();
#endif
pl.ammo_handgrenade_state = 2;
pl.mode_tempstate = 2;
pl.w_attack_next = 1.0f;
pl.w_idle_next = 0.5f;
} else if (pl.ammo_handgrenade_state == 2) {
} else if (pl.mode_tempstate == 2) {
#ifdef CLIENT
Weapons_ViewAnimation(HANDGRENADE_DRAW);
#else
@ -173,7 +176,7 @@ void w_tnt_release(void)
#endif
pl.w_attack_next = 0.5f;
pl.w_idle_next = 0.5f;
pl.ammo_handgrenade_state = 0;
pl.mode_tempstate = 0;
} else {
int r = (float)input_sequence % 8;
if (r == 1) {

View file

@ -140,8 +140,8 @@ class player:base_player
int ammo_egon_state_net;
int ammo_rpg_state;
int ammo_rpg_state_net;
int ammo_handgrenade_state;
int ammo_handgrenade_state_net;
int mode_tempstate;
int mode_tempstate_net;
int ammo_chainsaw_state;
int ammo_chainsaw_state_net;
int ammo_hammer_state;
@ -297,7 +297,7 @@ player::ReceiveEntity(float new)
ammo_gauss_volume = readbyte();
ammo_egon_state = readbyte();
ammo_rpg_state = readbyte();
ammo_handgrenade_state = readbyte();
mode_tempstate = readbyte();
ammo_chainsaw_state = readbyte();
ammo_hammer_state = readbyte();
}
@ -345,7 +345,7 @@ player::PredictPreFrame(void)
ammo_gauss_volume_net = ammo_gauss_volume;
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
ammo_handgrenade_state_net = ammo_handgrenade_state;
mode_tempstate_net = mode_tempstate;
ammo_chainsaw_state_net = ammo_chainsaw_state;
ammo_hammer_state_net = ammo_hammer_state;
}
@ -388,7 +388,7 @@ player::PredictPostFrame(void)
ammo_gauss_volume = ammo_gauss_volume_net;
ammo_egon_state = ammo_egon_state_net;
ammo_rpg_state = ammo_rpg_state_net;
ammo_handgrenade_state = ammo_handgrenade_state_net;
mode_tempstate = mode_tempstate_net;
ammo_chainsaw_state = ammo_chainsaw_state_net;
ammo_hammer_state = ammo_hammer_state_net;
}
@ -538,7 +538,7 @@ player::EvaluateEntity(void)
if (ammo_rpg_state != ammo_rpg_state_net) {
SendFlags |= PLAYER_AMMO3;
}
if (ammo_handgrenade_state != ammo_handgrenade_state_net) {
if (mode_tempstate != mode_tempstate_net) {
SendFlags |= PLAYER_AMMO3;
}
if (ammo_chainsaw_state != ammo_chainsaw_state_net) {
@ -592,7 +592,7 @@ player::EvaluateEntity(void)
ammo_gauss_volume_net = ammo_gauss_volume;
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
ammo_handgrenade_state_net = ammo_handgrenade_state;
mode_tempstate_net = mode_tempstate;
ammo_chainsaw_state_net = ammo_chainsaw_state;
ammo_hammer_state_net = ammo_hammer_state;
}
@ -700,7 +700,7 @@ player::SendEntity(entity ePEnt, float fChanged)
WriteByte(MSG_ENTITY, ammo_gauss_volume);
WriteByte(MSG_ENTITY, ammo_egon_state);
WriteByte(MSG_ENTITY, ammo_rpg_state);
WriteByte(MSG_ENTITY, ammo_handgrenade_state);
WriteByte(MSG_ENTITY, mode_tempstate);
WriteByte(MSG_ENTITY, ammo_chainsaw_state);
WriteByte(MSG_ENTITY, ammo_hammer_state);
}

View file

@ -135,8 +135,8 @@ class player:base_player
int ammo_egon_state_net;
int ammo_rpg_state;
int ammo_rpg_state_net;
int ammo_handgrenade_state;
int ammo_handgrenade_state_net;
int mode_tempstate;
int mode_tempstate_net;
#ifdef CLIENT
/* External model */
@ -283,7 +283,7 @@ player::ReceiveEntity(float new)
ammo_gauss_volume = readbyte();
ammo_egon_state = readbyte();
ammo_rpg_state = readbyte();
ammo_handgrenade_state = readbyte();
mode_tempstate = readbyte();
}
if (fl & PLAYER_AMMO1 || fl & PLAYER_AMMO2 || fl & PLAYER_AMMO3)
@ -328,7 +328,7 @@ player::PredictPreFrame(void)
ammo_gauss_volume_net = ammo_gauss_volume;
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
ammo_handgrenade_state_net = ammo_handgrenade_state;
mode_tempstate_net = mode_tempstate;
}
/*
@ -367,7 +367,7 @@ player::PredictPostFrame(void)
ammo_gauss_volume = ammo_gauss_volume_net;
ammo_egon_state = ammo_egon_state_net;
ammo_rpg_state = ammo_rpg_state_net;
ammo_handgrenade_state = ammo_handgrenade_state_net;
mode_tempstate = mode_tempstate_net;
}
#else
@ -512,7 +512,7 @@ player::EvaluateEntity(void)
if (ammo_rpg_state != ammo_rpg_state_net) {
SendFlags |= PLAYER_AMMO3;
}
if (ammo_handgrenade_state != ammo_handgrenade_state_net) {
if (mode_tempstate != mode_tempstate_net) {
SendFlags |= PLAYER_AMMO3;
}
@ -559,7 +559,7 @@ player::EvaluateEntity(void)
ammo_gauss_volume_net = ammo_gauss_volume;
ammo_egon_state_net = ammo_egon_state;
ammo_rpg_state_net = ammo_rpg_state;
ammo_handgrenade_state_net = ammo_handgrenade_state;
mode_tempstate_net = mode_tempstate;
}
/*
@ -664,7 +664,7 @@ player::SendEntity(entity ePEnt, float fChanged)
WriteByte(MSG_ENTITY, ammo_gauss_volume);
WriteByte(MSG_ENTITY, ammo_egon_state);
WriteByte(MSG_ENTITY, ammo_rpg_state);
WriteByte(MSG_ENTITY, ammo_handgrenade_state);
WriteByte(MSG_ENTITY, mode_tempstate);
}
return TRUE;

View file

@ -134,6 +134,9 @@ void w_handgrenade_throw(void)
void w_handgrenade_draw(void)
{
#ifdef CLIENT
player pl = (player)self;
pl.mode_tempstate = 0;
Weapons_SetModel("models/v_grenade.mdl");
Weapons_ViewAnimation(HANDGRENADE_DRAW);
#endif
@ -151,7 +154,7 @@ void w_handgrenade_primary(void)
}
/* We're abusing this network variable for the holding check */
if (pl.ammo_handgrenade_state > 0) {
if (pl.mode_tempstate > 0) {
return;
}
@ -164,7 +167,7 @@ void w_handgrenade_primary(void)
Weapons_ViewAnimation(HANDGRENADE_PULLPIN);
#endif
pl.ammo_handgrenade_state = 1;
pl.mode_tempstate = 1;
pl.w_attack_next = 0.5f;
pl.w_idle_next = 0.5f;
}
@ -186,17 +189,17 @@ void w_handgrenade_release(void)
return;
}
if (pl.ammo_handgrenade_state == 1) {
if (pl.mode_tempstate == 1) {
#ifdef CLIENT
Weapons_ViewAnimation(HANDGRENADE_THROW1);
#else
w_handgrenade_throw();
#endif
pl.ammo_handgrenade--;
pl.ammo_handgrenade_state = 2;
pl.mode_tempstate = 2;
pl.w_attack_next = 1.0f;
pl.w_idle_next = 0.5f;
} else if (pl.ammo_handgrenade_state == 2) {
} else if (pl.mode_tempstate == 2) {
#ifdef CLIENT
Weapons_ViewAnimation(HANDGRENADE_DRAW);
#else
@ -206,7 +209,7 @@ void w_handgrenade_release(void)
#endif
pl.w_attack_next = 0.5f;
pl.w_idle_next = 0.5f;
pl.ammo_handgrenade_state = 0;
pl.mode_tempstate = 0;
} else {
int r = (float)input_sequence % 8;
if (r == 1) {