From: Mario Date: Mon, 3 Oct 2016 08:42:33 +0000 (+1000) Subject: Clean up the use of slots on some things that could be weapon X-Git-Tag: xonotic-v0.8.2~326^2~72^2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=590f996c6db674629b6e4410338d0f93b4e936d8;p=xonotic%2Fxonotic-data.pk3dir.git Clean up the use of slots on some things that could be weapon --- diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index b0eafdc08..06d784af2 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -102,7 +102,7 @@ const int ARC_SF_LOCALMASK = ARC_SF_START | ARC_SF_WANTDIR | ARC_SF_BEAMDIR; #endif #ifdef SVQC .entity arc_beam; -.bool arc_BUTTON_ATCK_prev[MAX_WEAPONSLOTS]; // for better animation control +.bool arc_BUTTON_ATCK_prev; // for better animation control .float beam_prev; .float beam_initialized; .float beam_bursting; @@ -765,13 +765,12 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i Arc_Smoke(actor, weaponentity); bool beam_fire2 = ((fire & 2) && !WEP_CVAR(arc, bolt)); - int slot = weaponslot(weaponentity); if (time >= actor.arc_overheat) if ((fire & 1) || beam_fire2 || actor.(weaponentity).arc_beam.beam_bursting) { - if(actor.arc_BUTTON_ATCK_prev[slot]) + if(actor.(weaponentity).arc_BUTTON_ATCK_prev) { #if 0 if(actor.animstate_startframe == actor.anim_shoot.x && actor.animstate_numframes == actor.anim_shoot.y) @@ -787,10 +786,10 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i { W_Arc_Beam(boolean(beam_fire2), actor, weaponentity); - if(!actor.arc_BUTTON_ATCK_prev[slot]) + if(!actor.(weaponentity).arc_BUTTON_ATCK_prev) { weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); - actor.arc_BUTTON_ATCK_prev[slot] = true; + actor.(weaponentity).arc_BUTTON_ATCK_prev = true; } } } @@ -806,13 +805,14 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i } } - if(actor.arc_BUTTON_ATCK_prev[slot]) + if(actor.(weaponentity).arc_BUTTON_ATCK_prev) { + int slot = weaponslot(weaponentity); sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor); } - actor.arc_BUTTON_ATCK_prev[slot] = false; + actor.(weaponentity).arc_BUTTON_ATCK_prev = false; #if 0 if(fire & 2) @@ -864,8 +864,7 @@ METHOD(Arc, wr_drop, void(entity thiswep, entity actor, .entity weaponentity)) weapon_dropevent_item.arc_cooldown = actor.arc_cooldown; actor.arc_overheat = 0; actor.arc_cooldown = 0; - for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - actor.arc_BUTTON_ATCK_prev[slot] = false; + actor.(weaponentity).arc_BUTTON_ATCK_prev = false; } METHOD(Arc, wr_pickup, void(entity thiswep, entity actor, .entity weaponentity)) { @@ -881,14 +880,16 @@ METHOD(Arc, wr_resetplayer, void(entity thiswep, entity actor)) actor.arc_overheat = 0; actor.arc_cooldown = 0; for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - actor.arc_BUTTON_ATCK_prev[slot] = false; + { + .entity weaponentity = weaponentities[slot]; + actor.(weaponentity).arc_BUTTON_ATCK_prev = false; + } } METHOD(Arc, wr_playerdeath, void(entity thiswep, entity actor, .entity weaponentity)) { actor.arc_overheat = 0; actor.arc_cooldown = 0; - int slot = weaponslot(weaponentity); - actor.arc_BUTTON_ATCK_prev[slot] = false; + actor.(weaponentity).arc_BUTTON_ATCK_prev = false; } #endif #ifdef CSQC diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index db014bb86..821ffb8ed 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -62,7 +62,7 @@ ENDCLASS(Devastator) REGISTER_WEAPON(DEVASTATOR, devastator, NEW(Devastator)); #ifdef SVQC -.float rl_release[MAX_WEAPONSLOTS]; +.float rl_release; .float rl_detonate_later; #endif #endif @@ -286,10 +286,8 @@ void W_Devastator_Think(entity this) .entity weaponentity = this.weaponentity_fld; if(this.realowner.(weaponentity).m_weapon == WEP_DEVASTATOR) { - int slot = weaponslot(weaponentity); - if(this == this.realowner.(weaponentity).lastrocket) - if(!this.realowner.rl_release[slot]) + if(!this.realowner.(weaponentity).rl_release) if(!PHYS_INPUT_BUTTON_ATCK2(this)) if(WEP_CVAR(devastator, guiderate)) if(time > this.pushltime) @@ -501,19 +499,18 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen if(WEP_CVAR(devastator, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(devastator, ammo)) { // forced reload thiswep.wr_reload(thiswep, actor, weaponentity); } else { - int slot = weaponslot(weaponentity); if(fire & 1) { - if(actor.rl_release[slot] || WEP_CVAR(devastator, guidestop)) + if(actor.(weaponentity).rl_release || WEP_CVAR(devastator, guidestop)) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire))) { W_Devastator_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready); - actor.rl_release[slot] = 0; + actor.(weaponentity).rl_release = 0; } } else - actor.rl_release[slot] = 1; + actor.(weaponentity).rl_release = 1; if(fire & 2) if(actor.(weaponentity).m_switchweapon == WEP_DEVASTATOR) @@ -535,7 +532,10 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen METHOD(Devastator, wr_setup, void(entity thiswep, entity actor)) { for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - actor.rl_release[slot] = 1; + { + .entity weaponentity = weaponentities[slot]; + actor.(weaponentity).rl_release = 1; + } } METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { @@ -583,7 +583,7 @@ METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor)) { .entity weaponentity = weaponentities[slot]; actor.(weaponentity).lastrocket = NULL; // stop rocket guiding, no revenge from the grave! - actor.rl_release[slot] = 0; + actor.(weaponentity).rl_release = 0; } } METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index 4010def84..54fbb0949 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -56,7 +56,7 @@ REGISTER_WEAPON(FIREBALL, fireball, NEW(Fireball)); #ifdef SVQC .float bot_primary_fireballmooth; // whatever a mooth is .vector fireball_impactvec; -.float fireball_primarytime[MAX_WEAPONSLOTS]; +.float fireball_primarytime; #endif #endif #ifdef IMPLEMENTATION @@ -389,12 +389,11 @@ METHOD(Fireball, wr_think, void(entity thiswep, entity actor, .entity weaponenti { if(fire & 1) { - int slot = weaponslot(weaponentity); - if(time >= actor.fireball_primarytime[slot]) + if(time >= actor.(weaponentity).fireball_primarytime) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(fireball, refire))) { W_Fireball_Attack1_Frame0(thiswep, actor, weaponentity, fire); - actor.fireball_primarytime[slot] = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(actor); + actor.(weaponentity).fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(actor); } } else if(fire & 2) @@ -417,7 +416,10 @@ METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor, .entity weapo METHOD(Fireball, wr_resetplayer, void(entity thiswep, entity actor)) { for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) - actor.fireball_primarytime[slot] = time; + { + .entity weaponentity = weaponentities[slot]; + actor.(weaponentity).fireball_primarytime = time; + } } METHOD(Fireball, wr_suicidemessage, Notification(entity thiswep)) { diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 26784db88..b33f5890f 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -225,7 +225,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame2); } -.float shotgun_primarytime[MAX_WEAPONSLOTS]; +.float shotgun_primarytime; METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor)) { @@ -247,26 +247,24 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit { if(fire & 1) { - int slot = weaponslot(weaponentity); - if(time >= actor.shotgun_primarytime[slot]) // handle refire separately so the secondary can be fired straight after a primary + if(time >= actor.(weaponentity).shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(shotgun, animtime))) { W_Shotgun_Attack(thiswep, actor, weaponentity, true); - actor.shotgun_primarytime[slot] = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(actor); + actor.(weaponentity).shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready); } } } else if((fire & 2) && WEP_CVAR(shotgun, secondary) == 2) { - int slot = weaponslot(weaponentity); - if(time >= actor.shotgun_primarytime[slot]) // handle refire separately so the secondary can be fired straight after a primary + if(time >= actor.(weaponentity).shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(shotgun, alt_animtime))) { W_Shotgun_Attack(thiswep, actor, weaponentity, false); - actor.shotgun_primarytime[slot] = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(actor); + actor.(weaponentity).shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1); } }