From: TimePath Date: Sun, 25 Jan 2015 03:33:33 +0000 (+1100) Subject: Kill uses of `local` and `noref` X-Git-Tag: xonotic-v0.8.1~133^2~36 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b026bbce3d7647ff39556b12ffd159f53dcc191e;p=xonotic%2Fxonotic-data.pk3dir.git Kill uses of `local` and `noref` --- diff --git a/qcsrc/client/vehicles/vehicles.qc b/qcsrc/client/vehicles/vehicles.qc index f5e470ce0..9119318e6 100644 --- a/qcsrc/client/vehicles/vehicles.qc +++ b/qcsrc/client/vehicles/vehicles.qc @@ -208,13 +208,13 @@ void Net_VehicleSetup() } } #define HUD_GETSTATS \ - local noref int vh_health = getstati(STAT_VEHICLESTAT_HEALTH); \ - local noref int shield = getstati(STAT_VEHICLESTAT_SHIELD); \ - local noref int energy = getstati(STAT_VEHICLESTAT_ENERGY); \ - local noref int ammo1 = getstati(STAT_VEHICLESTAT_AMMO1); \ - local noref int reload1 = getstati(STAT_VEHICLESTAT_RELOAD1); \ - local noref int ammo2 = getstati(STAT_VEHICLESTAT_AMMO2); \ - local noref int reload2 = getstati(STAT_VEHICLESTAT_RELOAD2); + int vh_health = getstati(STAT_VEHICLESTAT_HEALTH); \ + int shield = getstati(STAT_VEHICLESTAT_SHIELD); \ + noref int energy = getstati(STAT_VEHICLESTAT_ENERGY); \ + noref int ammo1 = getstati(STAT_VEHICLESTAT_AMMO1); \ + noref int reload1 = getstati(STAT_VEHICLESTAT_RELOAD1); \ + noref int ammo2 = getstati(STAT_VEHICLESTAT_AMMO2); \ + noref int reload2 = getstati(STAT_VEHICLESTAT_RELOAD2); void CSQC_BUMBLE_HUD() { diff --git a/qcsrc/csqcmodellib/cl_model.qc b/qcsrc/csqcmodellib/cl_model.qc index 2be2c728b..6cf2ced39 100644 --- a/qcsrc/csqcmodellib/cl_model.qc +++ b/qcsrc/csqcmodellib/cl_model.qc @@ -173,9 +173,9 @@ void CSQCModel_InterpolateAnimation_Do() void CSQCModel_Draw() { // some nice flags for CSQCMODEL_IF and the hooks - local noref bool isplayer = (self.entnum >= 1 && self.entnum <= maxclients); - local noref bool islocalplayer = (self.entnum == player_localnum + 1); - local noref bool isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1)); + bool isplayer = (self.entnum >= 1 && self.entnum <= maxclients); + noref bool islocalplayer = (self.entnum == player_localnum + 1); + noref bool isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1)); // we don't do this for the local player as that one is already handled // by CSQCPlayer_SetCamera() @@ -205,9 +205,9 @@ void CSQCModel_Read(float isnew) int sf = ReadInt24_t(); // some nice flags for CSQCMODEL_IF and the hooks - local noref bool isplayer = (self.entnum >= 1 && self.entnum <= maxclients); - local noref bool islocalplayer = (self.entnum == player_localnum + 1); - local noref bool isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1)); + bool isplayer = (self.entnum >= 1 && self.entnum <= maxclients); + bool islocalplayer = (self.entnum == player_localnum + 1); + noref bool isnolocalplayer = (isplayer && (self.entnum != player_localnum + 1)); self.classname = "csqcmodel"; self.iflags |= IFLAG_ORIGIN; // interpolate origin too diff --git a/qcsrc/dpdefs/csprogsdefs.qc b/qcsrc/dpdefs/csprogsdefs.qc index 9c138add7..b849379d1 100644 --- a/qcsrc/dpdefs/csprogsdefs.qc +++ b/qcsrc/dpdefs/csprogsdefs.qc @@ -1267,7 +1267,7 @@ float(float modlindex, float framenum) frameduration = #277; // returns the inte //"leftarm" (which is a child of "torso") which would return 2 instead... float(float skel, float bonenum, string g1, string g2, string g3, string g4, string g5, string g6) example_skel_findbonegroup = { - local string bonename; + string bonename; while (bonenum >= 0) { bonename = skel_get_bonename(skel, bonenum); @@ -1307,8 +1307,6 @@ void(float animmodelindex, float framegroup, float framegroupstarttime) example_ // apply a different framegroup animation to bones with a specified parent void(float animmodelindex, float framegroup, float framegroupstarttime, float blendalpha, string groupbonename, string excludegroupname1, string excludegroupname2) example_skel_player_update_applyoverride = { - local float bonenum; - local float numbones; self.frame = framegroup; self.frame2 = 0; self.frame3 = 0; @@ -1320,8 +1318,8 @@ void(float animmodelindex, float framegroup, float framegroupstarttime, float bl self.lerpfrac = 0; self.lerpfrac3 = 0; self.lerpfrac4 = 0; - bonenum = 0; - numbones = skel_get_numbones(self.skeletonindex); + float bonenum = 0; + float numbones = skel_get_numbones(self.skeletonindex); while (bonenum < numbones) { if (example_skel_findbonegroup(self.skeletonindex, bonenum, groupbonename, excludegroupname1, excludegroupname2, "", "", "") == 1) @@ -1332,45 +1330,38 @@ void(float animmodelindex, float framegroup, float framegroupstarttime, float bl // make eyes point at a target location, be sure v_forward, v_right, v_up are set correctly before calling void(vector eyetarget, string bonename) example_skel_player_update_eyetarget = { - local float bonenum; - local vector ang; - local vector oldforward, oldright, oldup; - local vector relforward, relright, relup, relorg; - local vector boneforward, boneright, boneup, boneorg; - local vector parentforward, parentright, parentup, parentorg; - local vector u, v; - local vector modeleyetarget; - bonenum = skel_find_bone(self.skeletonindex, bonename) - 1; + float bonenum = skel_find_bone(self.skeletonindex, bonename) - 1; if (bonenum < 0) return; - oldforward = v_forward; - oldright = v_right; - oldup = v_up; - v = eyetarget - self.origin; + vector oldforward = v_forward; + vector oldright = v_right; + vector oldup = v_up; + vector v = eyetarget - self.origin; + vector modeleyetarget; modeleyetarget_x = v * v_forward; modeleyetarget_y = 0-v * v_right; modeleyetarget_z = v * v_up; // this is an eyeball, make it point at the target location // first get all the data we can... - relorg = skel_get_bonerel(self.skeletonindex, bonenum); - relforward = v_forward; - relright = v_right; - relup = v_up; - boneorg = skel_get_boneabs(self.skeletonindex, bonenum); - boneforward = v_forward; - boneright = v_right; - boneup = v_up; - parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum)); - parentforward = v_forward; - parentright = v_right; - parentup = v_up; + vector relorg = skel_get_bonerel(self.skeletonindex, bonenum); + vector relforward = v_forward; + vector relright = v_right; + vector relup = v_up; + vector boneorg = skel_get_boneabs(self.skeletonindex, bonenum); + vector boneforward = v_forward; + vector boneright = v_right; + vector boneup = v_up; + vector parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum)); + vector parentforward = v_forward; + vector parentright = v_right; + vector parentup = v_up; // get the vector from the eyeball to the target - u = modeleyetarget - boneorg; + vector u = modeleyetarget - boneorg; // now transform it inversely by the parent matrix to produce new rel vectors v_x = u * parentforward; v_y = u * parentright; v_z = u * parentup; - ang = vectoangles2(v, relup); + vector ang = vectoangles2(v, relup); ang_x = 0 - ang_x; makevectors(ang); // set the relative bone matrix diff --git a/qcsrc/dpdefs/dpextensions.qc b/qcsrc/dpdefs/dpextensions.qc index c176eb4c3..624442539 100644 --- a/qcsrc/dpdefs/dpextensions.qc +++ b/qcsrc/dpdefs/dpextensions.qc @@ -2188,10 +2188,9 @@ float(float modlindex, float framenum) frameduration = #277; // returns the inte //"leftarm" (which is a child of "torso") which would return 2 instead... float(float skel, float bonenum, string g1, string g2, string g3, string g4, string g5, string g6) example_skel_findbonegroup = { - local string bonename; while (bonenum >= 0) { - bonename = skel_get_bonename(skel, bonenum); + string bonename = skel_get_bonename(skel, bonenum); if (bonename == g1) return 1; if (bonename == g2) return 2; if (bonename == g3) return 3; @@ -2228,8 +2227,6 @@ void(float animmodelindex, float framegroup, float framegroupstarttime) example_ // apply a different framegroup animation to bones with a specified parent void(float animmodelindex, float framegroup, float framegroupstarttime, float blendalpha, string groupbonename, string excludegroupname1, string excludegroupname2) example_skel_player_update_applyoverride = { - local float bonenum; - local float numbones; self.frame = framegroup; self.frame2 = 0; self.frame3 = 0; @@ -2241,8 +2238,8 @@ void(float animmodelindex, float framegroup, float framegroupstarttime, float bl self.lerpfrac = 0; self.lerpfrac3 = 0; self.lerpfrac4 = 0; - bonenum = 0; - numbones = skel_get_numbones(self.skeletonindex); + float bonenum = 0; + float numbones = skel_get_numbones(self.skeletonindex); while (bonenum < numbones) { if (example_skel_findbonegroup(self.skeletonindex, bonenum, groupbonename, excludegroupname1, excludegroupname2, "", "", "") == 1) @@ -2253,45 +2250,38 @@ void(float animmodelindex, float framegroup, float framegroupstarttime, float bl // make eyes point at a target location, be sure v_forward, v_right, v_up are set correctly before calling void(vector eyetarget, string bonename) example_skel_player_update_eyetarget = { - local float bonenum; - local vector ang; - local vector oldforward, oldright, oldup; - local vector relforward, relright, relup, relorg; - local vector boneforward, boneright, boneup, boneorg; - local vector parentforward, parentright, parentup, parentorg; - local vector u, v; - local vector modeleyetarget; - bonenum = skel_find_bone(self.skeletonindex, bonename) - 1; + float bonenum = skel_find_bone(self.skeletonindex, bonename) - 1; if (bonenum < 0) return; - oldforward = v_forward; - oldright = v_right; - oldup = v_up; - v = eyetarget - self.origin; + vector oldforward = v_forward; + vector oldright = v_right; + vector oldup = v_up; + vector v = eyetarget - self.origin; + vector modeleyetarget; modeleyetarget_x = v * v_forward; modeleyetarget_y = 0-v * v_right; modeleyetarget_z = v * v_up; // this is an eyeball, make it point at the target location // first get all the data we can... - relorg = skel_get_bonerel(self.skeletonindex, bonenum); - relforward = v_forward; - relright = v_right; - relup = v_up; - boneorg = skel_get_boneabs(self.skeletonindex, bonenum); - boneforward = v_forward; - boneright = v_right; - boneup = v_up; - parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum)); - parentforward = v_forward; - parentright = v_right; - parentup = v_up; + vector relorg = skel_get_bonerel(self.skeletonindex, bonenum); + vector relforward = v_forward; + vector relright = v_right; + vector relup = v_up; + vector boneorg = skel_get_boneabs(self.skeletonindex, bonenum); + vector boneforward = v_forward; + vector boneright = v_right; + vector boneup = v_up; + vector parentorg = skel_get_boneabs(self.skeletonindex, skel_get_boneparent(self.skeletonindex, bonenum)); + vector parentforward = v_forward; + vector parentright = v_right; + vector parentup = v_up; // get the vector from the eyeball to the target - u = modeleyetarget - boneorg; + vector u = modeleyetarget - boneorg; // now transform it inversely by the parent matrix to produce new rel vectors v_x = u * parentforward; v_y = u * parentright; v_z = u * parentup; - ang = vectoangles2(v, relup); + vector ang = vectoangles2(v, relup); ang_x = 0 - ang_x; makevectors(ang); // set the relative bone matrix diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 648d11297..de5aa0bec 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -795,7 +795,7 @@ float autocvar_g_nades_nade_edgedamage; float autocvar_g_nades_nade_radius; float autocvar_g_nades_nade_force; float autocvar_g_nades_nade_newton_style; -float autocvar_g_nades_napalm_ball_count; +int autocvar_g_nades_napalm_ball_count; float autocvar_g_nades_napalm_ball_spread; float autocvar_g_nades_napalm_ball_damage; float autocvar_g_nades_napalm_ball_damageforcescale; diff --git a/qcsrc/server/func_breakable.qc b/qcsrc/server/func_breakable.qc index 0bf71059e..0b936a1d1 100644 --- a/qcsrc/server/func_breakable.qc +++ b/qcsrc/server/func_breakable.qc @@ -39,9 +39,7 @@ void func_breakable_damage(entity inflictor, entity attacker, float damage, floa // void LaunchDebris (string debrisname, vector force) { - local entity dbr; - - dbr = spawn(); + entity dbr = spawn(); setorigin(dbr, self.absmin + '1 0 0' * random() * (self.absmax_x - self.absmin_x) + '0 1 0' * random() * (self.absmax_y - self.absmin_y) diff --git a/qcsrc/server/g_lights.qc b/qcsrc/server/g_lights.qc index 98429f7d7..da53fbe64 100644 --- a/qcsrc/server/g_lights.qc +++ b/qcsrc/server/g_lights.qc @@ -84,8 +84,6 @@ void dynlight_use() } void spawnfunc_dynlight() { - local entity targ; - if (!self.light_lev) self.light_lev = 200; if (!self.color) diff --git a/qcsrc/server/item_key.qc b/qcsrc/server/item_key.qc index 79003853a..964f065e3 100644 --- a/qcsrc/server/item_key.qc +++ b/qcsrc/server/item_key.qc @@ -7,7 +7,7 @@ TODO: - should keys have a trigger? */ -float item_keys_usekey(entity l, entity p) { +bool item_keys_usekey(entity l, entity p) { float valid = l.itemkeys & p.itemkeys; if (!valid) { @@ -140,8 +140,8 @@ This is the only correct way to put keys on the map! itemkeys MUST always have exactly one bit set. */ void spawnfunc_item_key() { - local string _model, _netname; - local vector _colormod; + string _netname; + vector _colormod; // reject this entity if more than one key was set! if (self.itemkeys>0 && (self.itemkeys & (self.itemkeys-1)) != 0) { @@ -196,9 +196,7 @@ void spawnfunc_item_key() { } // find default model -#ifdef GMQCC - _model = string_null; -#endif + string _model = string_null; if (self.itemkeys <= ITEM_KEY_BIT(2)) { _model = "models/keys/key.md3"; } else if (self.itemkeys >= ITEM_KEY_BIT(3) && self.itemkeys <= ITEM_KEY_BIT(5)) { @@ -282,13 +280,11 @@ trigger_keylock * trigger givent targets */ void trigger_keylock_trigger(string s) { - local entity t, stemp, otemp, atemp; - - stemp = self; - otemp = other; - atemp = activator; - + entity stemp = self; + entity otemp = other; + entity atemp = activator; + entity t; for(t = world; (t = find(t, targetname, s)); ) if (t.use) { self = t; @@ -306,16 +302,14 @@ void trigger_keylock_trigger(string s) { * kill killtarget of trigger keylock. */ void trigger_keylock_kill(string s) { - local entity t; + entity t; for(t = world; (t = find(t, targetname, s)); ) remove(t); }; void trigger_keylock_touch(void) { - local float key_used, started_delay; - - key_used = FALSE; - started_delay = FALSE; + bool key_used = FALSE; + bool started_delay = FALSE; // only player may trigger the lock if (!IS_PLAYER(other)) diff --git a/qcsrc/server/mutators/mutator_nades.qc b/qcsrc/server/mutators/mutator_nades.qc index 91bd53e5a..921544411 100644 --- a/qcsrc/server/mutators/mutator_nades.qc +++ b/qcsrc/server/mutators/mutator_nades.qc @@ -185,8 +185,8 @@ void napalm_fountain_think() void nade_napalm_boom() { entity fountain; - local float c; - for (c = 0; c < autocvar_g_nades_napalm_ball_count; c ++) + int c; + for (c = 0; c < autocvar_g_nades_napalm_ball_count; c++) nade_napalm_ball(); diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index e3e962a1d..b6bf68e77 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -991,13 +991,7 @@ ACTIVATION FUNCTIONS */ float door_check_keys(void) { - local entity door; - - - if (self.owner) - door = self.owner; - else - door = self; + entity door = self.owner ? self.owner : self; // no key needed if (!door.itemkeys)