From: terencehill Date: Sun, 9 Aug 2020 15:16:01 +0000 (+0200) Subject: Improve indentation consistency in weapon code X-Git-Tag: xonotic-v0.8.5~777 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d87e55939b27a63c84577c87af8a087be6d02843;p=xonotic%2Fxonotic-data.pk3dir.git Improve indentation consistency in weapon code --- diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index bb4ae216a..7c089ba70 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -18,29 +18,29 @@ #elif defined(MENUQC) #elif defined(SVQC) #include - #include - #include - #include - #include - #include "../constants.qh" - #include "../stats.qh" - #include "../teams.qh" - #include - #include "../monsters/_mod.qh" - #include "config.qh" - #include - #include - #include - #include - #include - #include "../notifications/all.qh" - #include "../deathtypes/all.qh" - #include - #include "../mapinfo.qh" - #include - #include - #include - #include + #include + #include + #include + #include + #include "../constants.qh" + #include "../stats.qh" + #include "../teams.qh" + #include + #include "../monsters/_mod.qh" + #include "config.qh" + #include + #include + #include + #include + #include + #include "../notifications/all.qh" + #include "../deathtypes/all.qh" + #include + #include "../mapinfo.qh" + #include + #include + #include +#include #endif #ifdef GAMEQC #include "calculations.qc" @@ -159,12 +159,9 @@ float W_FixWeaponOrder_BuildImpulseList_cmp(int i, int j, entity pass) Weapon e2 = REGISTRY_GET(Weapons, sj); int d = (e1.impulse + 9) % 10 - (e2.impulse + 9) % 10; if (d != 0) return -d; // high impulse first! - return strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), - sprintf(" %d ", si), 0) - - - strstrofs(strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "), - sprintf(" %d ", sj), 0) - ; // low char index first! + string s = strcat(" ", W_FixWeaponOrder_BuildImpulseList_order, " "); + return strstrofs(s, sprintf(" %d ", si), 0) + - strstrofs(s, sprintf(" %d ", sj), 0); // low char index first! } string W_FixWeaponOrder_BuildImpulseList(string o) { @@ -475,7 +472,7 @@ void CL_WeaponEntity_SetModel(entity this, string name, bool _anim) int idx = 0; // v_ model attached to invisible h_ model if (this.weaponchild - && ((idx = gettagindex(this.weaponchild, "shell")) || (idx = gettagindex(this.weaponchild, "tag_shell")))) + && ((idx = gettagindex(this.weaponchild, "shell")) || (idx = gettagindex(this.weaponchild, "tag_shell")))) { this.spawnorigin = gettaginfo(this.weaponchild, idx); } @@ -541,12 +538,10 @@ void CL_WeaponEntity_SetModel(entity this, string name, bool _anim) int compressed_shotorg = compressShotOrigin(this.movedir); // make them match perfectly #ifdef SVQC - // null during init - if (this.owner) STAT(SHOTORG, this.owner) = compressed_shotorg; - this.movedir = decompressShotOrigin(compressed_shotorg); -#else - this.movedir = decompressShotOrigin(compressed_shotorg); + // null during init + if (this.owner) STAT(SHOTORG, this.owner) = compressed_shotorg; #endif + this.movedir = decompressShotOrigin(compressed_shotorg); this.spawnorigin += this.view_ofs; // offset the casings origin by the same amount @@ -567,7 +562,7 @@ NET_HANDLE(wframe, bool isNew) { WFRAME fr = ReadByte(); float t = ReadFloat(); - int slot = ReadByte(); + int slot = ReadByte(); bool restartanim = ReadByte(); entity wepent = viewmodels[slot]; if(fr == WFRAME_IDLE) @@ -596,9 +591,9 @@ NET_HANDLE(wframe, bool isNew) case WS_DROP: wepent.weapon_switchdelay = wepent.activeweapon.switchdelay_drop; break; - default: - wepent.weapon_switchdelay = 0; - break; + default: + wepent.weapon_switchdelay = 0; + break; } return true; } @@ -776,11 +771,11 @@ NET_HANDLE(w_muzzleflash, bool isNew) { return = true; int weapon_id = ReadByte(); - int slot = ReadByte(); - vector sv_shotorg = ReadVector(); + int slot = ReadByte(); + vector sv_shotorg = ReadVector(); Weapon thiswep = REGISTRY_GET(Weapons, weapon_id); - vector viewangles = getpropertyvec(VF_CL_VIEWANGLES); + vector viewangles = getpropertyvec(VF_CL_VIEWANGLES); vector forward, right, up; MAKE_VECTORS(viewangles, forward, right, up); @@ -791,7 +786,7 @@ NET_HANDLE(w_muzzleflash, bool isNew) pointparticles(thiswep.m_muzzleeffect, sv_shotorg, forward * 1000, 1); return; } - if(!autocvar_r_drawviewmodel) return; + if(!autocvar_r_drawviewmodel) return; entity wepent = viewmodels[slot]; // get the local player entity to calculate shot origin diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 5f79c8ccf..3af9a18da 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -931,9 +931,7 @@ void Draw_ArcBeam(entity this) if(!v_shot_idx || this.beam_usevieworigin != 2) { this.beam_shotorigin = wepent.movedir; - origin_offset = - right * -this.beam_shotorigin.y - + up * this.beam_shotorigin.z; + origin_offset = right * -this.beam_shotorigin.y + up * this.beam_shotorigin.z; } else this.beam_shotorigin = '0 0 0'; diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index abed4209f..51d175750 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -505,7 +505,7 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity) proj.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, proj); IL_PUSH(g_bot_dodge, proj); - proj.missile_flags = MIF_SPLASH; + proj.missile_flags = MIF_SPLASH; CSQCProjectile(proj, true, (proj.cnt ? PROJECTILE_CRYLINK_BOUNCING : PROJECTILE_CRYLINK), true); diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index edbdecf0f..279643837 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -165,7 +165,7 @@ void W_Fireball_Attack1(entity actor, .entity weaponentity) proj.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, proj); IL_PUSH(g_bot_dodge, proj); - proj.missile_flags = MIF_SPLASH | MIF_PROXY; + proj.missile_flags = MIF_SPLASH | MIF_PROXY; CSQCProjectile(proj, true, PROJECTILE_FIREBALL, true); @@ -297,7 +297,7 @@ void W_Fireball_Attack2(entity actor, .entity weaponentity) proj.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, proj); IL_PUSH(g_bot_dodge, proj); - proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC; + proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC; CSQCProjectile(proj, true, PROJECTILE_FIREMINE, true); diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 3bc225820..f3a0463cc 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -21,14 +21,13 @@ void W_HLAC_Touch(entity this, entity toucher) void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; - float spread; W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hlac, ammo), weaponentity); - spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * actor.(weaponentity).misc_bulletcounter); - spread = min(spread,WEP_CVAR_PRI(hlac, spread_max)); - if(IS_DUCKED(actor)) - spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod); + float spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * actor.(weaponentity).misc_bulletcounter); + spread = min(spread,WEP_CVAR_PRI(hlac, spread_max)); + if(IS_DUCKED(actor)) + spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod); W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_PRI(hlac, damage), thiswep.m_id); W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir); @@ -42,7 +41,7 @@ void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity) missile.owner = missile.realowner = actor; missile.bot_dodge = true; - missile.bot_dodgerating = WEP_CVAR_PRI(hlac, damage); + missile.bot_dodgerating = WEP_CVAR_PRI(hlac, damage); set_movetype(missile, MOVETYPE_FLY); PROJECTILE_MAKETRIGGER(missile); @@ -56,7 +55,7 @@ void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity) settouch(missile, W_HLAC_Touch); setthink(missile, SUB_Remove); - missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime); + missile.nextthink = time + WEP_CVAR_PRI(hlac, lifetime); missile.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, missile); @@ -72,13 +71,10 @@ void W_HLAC_Attack(Weapon thiswep, entity actor, .entity weaponentity) void W_HLAC_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { entity missile; - float spread; + float spread = WEP_CVAR_SEC(hlac, spread); - spread = WEP_CVAR_SEC(hlac, spread); - - - if(IS_DUCKED(actor)) - spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod); + if(IS_DUCKED(actor)) + spread = spread * WEP_CVAR_SEC(hlac, spread_crouchmod); W_SetupShot(actor, weaponentity, false, 3, SND_LASERGUN_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hlac, damage), thiswep.m_id | HITTYPE_SECONDARY); W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir); @@ -87,7 +83,7 @@ void W_HLAC_Attack2(Weapon thiswep, entity actor, .entity weaponentity) missile.owner = missile.realowner = actor; missile.bot_dodge = true; - missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage); + missile.bot_dodgerating = WEP_CVAR_SEC(hlac, damage); set_movetype(missile, MOVETYPE_FLY); PROJECTILE_MAKETRIGGER(missile); @@ -101,7 +97,7 @@ void W_HLAC_Attack2(Weapon thiswep, entity actor, .entity weaponentity) settouch(missile, W_HLAC_Touch); setthink(missile, SUB_Remove); - missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime); + missile.nextthink = time + WEP_CVAR_SEC(hlac, lifetime); missile.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, missile); @@ -137,7 +133,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int ATTACK_FINISHED(actor, weaponentity) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor); W_HLAC_Attack(thiswep, actor, weaponentity); actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1; - weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); } else { @@ -147,12 +143,10 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity) { - float i; - W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hlac, ammo), weaponentity); - for(i=WEP_CVAR_SEC(hlac, shots);i>0;--i) - W_HLAC_Attack2(thiswep, actor, weaponentity); + for(float i = WEP_CVAR_SEC(hlac, shots); i > 0; --i) + W_HLAC_Attack2(thiswep, actor, weaponentity); if(!autocvar_g_norecoil) { diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 9f4bdc15e..3efa61102 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -22,10 +22,10 @@ void W_Rifle_FireBullet(Weapon thiswep, .entity weaponentity, float pSpread, flo fireBullet(actor, weaponentity, w_shotorg, w_shotdir, pSpread, pSolidPenetration, pDamage, pHeadshotDamage, pForce, deathtype, (pTracer ? EFFECT_RIFLE : EFFECT_RIFLE_WEAK)); if(autocvar_g_casings >= 2) - { - makevectors(actor.v_angle); // for some reason, this is lost + { + makevectors(actor.v_angle); // for some reason, this is lost SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity); - } + } } void W_Rifle_Attack(Weapon thiswep, entity actor, .entity weaponentity) diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 3e25800cc..dcde58a30 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -27,7 +27,7 @@ void W_Shotgun_Attack(Weapon thiswep, entity actor, .entity weaponentity, float for(int sc = 0;sc < bullets;sc = sc + 1) fireBullet_antilag(actor, weaponentity, w_shotorg, w_shotdir, spread, solidpenetration, damage, 0, force, thiswep.m_id, bullet_trail_effect, false); - + if(lag && bullets > 0) antilag_restore_all(actor); diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 5a1cd1a92..b20f6bda3 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -51,8 +51,8 @@ void SendCSQCVortexBeamParticle(float charge) { NET_HANDLE(TE_CSQC_VORTEXBEAMPARTICLE, bool isNew) { float charge; - vector shotorg = ReadVector(); - vector endpos = ReadVector(); + vector shotorg = ReadVector(); + vector endpos = ReadVector(); charge = ReadByte() / 255.0; //pointparticles(EFFECT_VORTEX_MUZZLEFLASH, shotorg, normalize(endpos - shotorg) * 1000, 1); @@ -112,9 +112,9 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i myforcehalflife = WEP_CVAR_BOTH(vortex, !issecondary, damagefalloff_forcehalflife); myammo = WEP_CVAR_BOTH(vortex, !issecondary, ammo); - float dtype = thiswep.m_id; - if(WEP_CVAR_BOTH(vortex, !issecondary, armorpierce)) - dtype |= HITTYPE_ARMORPIERCE; + float dtype = thiswep.m_id; + if(WEP_CVAR_BOTH(vortex, !issecondary, armorpierce)) + dtype |= HITTYPE_ARMORPIERCE; float flying; flying = IsFlying(actor); // do this BEFORE to make the trace values from FireRailgunBullet last @@ -152,7 +152,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i actor.vortex_lasthit = damage_goodhits; //beam done on client - vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); + vector v = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, normalize(v - w_shotorg)); SendCSQCVortexBeamParticle(charge);