From 123b8faad91aa21fb4e87d48f0f776dd77735b2e Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 15 Feb 2019 18:40:29 +0100 Subject: [PATCH 1/1] Some minor cleanups and optimizations --- .../common/gamemodes/gamemode/clanarena/sv_clanarena.qc | 2 +- .../common/mutators/mutator/waypoints/waypointsprites.qc | 2 +- qcsrc/common/weapons/all.qh | 4 ++-- qcsrc/menu/xonotic/gametypelist.qc | 9 +++++---- qcsrc/menu/xonotic/util.qc | 3 ++- qcsrc/server/miscfunctions.qc | 7 +------ 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc index 88540baf60..56cfabc501 100644 --- a/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc +++ b/qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc @@ -163,7 +163,7 @@ entity CA_SpectateNext(entity player, entity start) { if (SAME_TEAM(player, e)) return e; } - // restart from begining + // restart from the beginning for (entity e = NULL; (e = find(e, classname, STR_PLAYER)); ) { if (SAME_TEAM(player, e)) return e; diff --git a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc index c2984aea5a..4192185dce 100644 --- a/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc +++ b/qcsrc/common/mutators/mutator/waypoints/waypointsprites.qc @@ -348,7 +348,7 @@ vector drawspritearrow(vector o, float ang, vector rgb, float a, float t) float border = 1.5 * t; float margin = 4.0 * t; - float borderDiag = border * 1.414; + float borderDiag = border * M_SQRT2; vector arrowX = eX * size; vector arrowY = eY * (size+borderDiag); vector borderX = eX * (size+borderDiag); diff --git a/qcsrc/common/weapons/all.qh b/qcsrc/common/weapons/all.qh index 9a32b42778..42805b3a08 100644 --- a/qcsrc/common/weapons/all.qh +++ b/qcsrc/common/weapons/all.qh @@ -144,9 +144,9 @@ X(weaponstart, float) X(weaponthrowable, float) #ifdef SVQC X(reload_ammo, float) -.float reloading_ammo = reload_ammo; +const .float reloading_ammo = reload_ammo; X(reload_time, float) -.float reloading_time = reload_time; +const .float reloading_time = reload_time; #endif #undef X diff --git a/qcsrc/menu/xonotic/gametypelist.qc b/qcsrc/menu/xonotic/gametypelist.qc index 3703393789..2de655940f 100644 --- a/qcsrc/menu/xonotic/gametypelist.qc +++ b/qcsrc/menu/xonotic/gametypelist.qc @@ -31,16 +31,17 @@ void XonoticGametypeList_setSelected(entity me, float i) void XonoticGametypeList_loadCvars(entity me) { Gametype t = MapInfo_CurrentGametype(); + int cnt = GameType_GetCount(); float i; - for(i = 0; i < GameType_GetCount(); ++i) + for(i = 0; i < cnt; ++i) if(t == GameType_GetID(i)) break; - if(i >= GameType_GetCount()) + if(i >= cnt) { - for(i = 0; i < GameType_GetCount(); ++i) + for(i = 0; i < cnt; ++i) if(t == MAPINFO_TYPE_DEATHMATCH) break; - if(i >= GameType_GetCount()) + if(i >= cnt) i = 0; } me.setSelected(me, i); diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index 69f506e6e0..7340564126 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -712,10 +712,11 @@ Gametype GameType_GetID(int cnt) int GameType_GetCount() { int i = 0; + int dev = cvar("developer"); #define GAMETYPE(id) ++i; GAMETYPES #undef GAMETYPE - #define GAMETYPE(it) if (cvar("developer")) ++i; + #define GAMETYPE(it) if (dev) ++i; HIDDEN_GAMETYPES #undef GAMETYPE return i; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 6e722797b5..9c1596f5d0 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -499,12 +499,7 @@ float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still ne allow_mutatorblocked = M_ARGV(3, bool); if(allguns) - { - if(weaponinfo.spawnflags & WEP_FLAG_NORMAL) - d = true; - else - d = false; - } + d = boolean(weaponinfo.spawnflags & WEP_FLAG_NORMAL); else if(!mutator_returnvalue) d = !(!weaponinfo.weaponstart); -- 2.39.2