From 6031028ff3f1edd2d709b58e91664482d46c991c Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 24 Jul 2016 17:01:08 +1000 Subject: [PATCH] Improve FPS by a lot --- qcsrc/client/view.qc | 10 ++++++++-- qcsrc/common/mutators/mutator/itemstime.qc | 14 ++++++++++---- qcsrc/common/turrets/sv_turrets.qc | 2 +- qcsrc/lib/warpzone/server.qc | 9 +++++---- qcsrc/server/mutators/mutator/gamemode_assault.qc | 8 ++++++-- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 4ca30d4a8..3b52de90d 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1847,7 +1847,10 @@ void CSQC_UpdateView(entity this, float w, float h) mousepos = mousepos*0.5 + getmousepos(); */ - FOREACH_ENTITY(it.draw, it.draw(it)); + FOREACH_ENTITY_FLOAT(pure_data, false, + { + if(it.draw) { it.draw(it); } + }); addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS); renderscene(); @@ -2177,7 +2180,10 @@ void CSQC_UpdateView(entity this, float w, float h) } else */ // draw 2D entities - FOREACH_ENTITY(it.draw2d, it.draw2d(it)); + FOREACH_ENTITY_FLOAT(pure_data, false, + { + if(it.draw2d) { it.draw2d(it); } + }); Draw_ShowNames_All(); Debug_Draw(); diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc index 1c4de9a4e..a504c9b1e 100644 --- a/qcsrc/common/mutators/mutator/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -136,13 +136,16 @@ void Item_ItemsTime_SetTimesForAllPlayers() float Item_ItemsTime_UpdateTime(entity e, float t) { bool isavailable = (t == 0); - FOREACH_ENTITY(it.itemdef == e.itemdef || ((e.weapons & WEPSET_SUPERWEAPONS) && (it.weapons & WEPSET_SUPERWEAPONS) && clienttype(it) == CLIENTTYPE_NOTACLIENT), LAMBDA( + FOREACH_ENTITY_FLOAT(pure_data, false, + { + if(!(it.itemdef == e.itemdef || ((e.weapons & WEPSET_SUPERWEAPONS) && (it.weapons & WEPSET_SUPERWEAPONS) && clienttype(it) == CLIENTTYPE_NOTACLIENT))) + continue; if (e == it) continue; if (it.scheduledrespawntime <= time) isavailable = true; else if (t == 0 || it.scheduledrespawntime < t) t = it.scheduledrespawntime; - )); + }); if (isavailable) t = -t; // let know the client there's another available item return t; @@ -153,9 +156,12 @@ MUTATOR_HOOKFUNCTION(itemstime, reset_map_global) Item_ItemsTime_ResetTimes(); // ALL the times need to be reset before .reset()ing each item // since Item_Reset schedules respawn of superweapons and powerups - FOREACH_ENTITY(IS_NOT_A_CLIENT(it), LAMBDA( + FOREACH_ENTITY_FLOAT(pure_data, false, + { + if(IS_CLIENT(it)) + continue; if (it.reset) Item_ItemsTime_SetTime(it, 0); - )); + }); Item_ItemsTime_SetTimesForAllPlayers(); } diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index b5dde01e9..71181f209 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -1199,7 +1199,7 @@ void turrets_manager_think(entity this) if (autocvar_g_turrets_reloadcvars == 1) { - FOREACH_ENTITY(IS_TURRET(it), { + FOREACH_ENTITY_FLAGS(turret_flags, TUR_FLAG_ISTURRET, { load_unit_settings(it, true); Turret tur = get_turretinfo(it.m_id); tur.tr_think(tur, it); diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 0b83f05bf..f1bd0e524 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -803,7 +803,7 @@ void WarpZone_StartFrame() WarpZone_PostInitialize_Callback(); } - FOREACH_ENTITY(!is_pure(it), + FOREACH_ENTITY_FLOAT(pure_data, false, { if(warpzone_warpzones_exist) WarpZone_StoreProjectileData(it); @@ -835,9 +835,10 @@ void WarpZone_StartFrame() .float warpzone_reconnecting; bool visible_to_some_client(entity ent) { - FOREACH_ENTITY(!IS_NOT_A_CLIENT(it), LAMBDA( - if (IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent)) return true; - )); + FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && checkpvs(it.origin + it.view_ofs, ent), + { + return true; + }); return false; } void trigger_warpzone_reconnect_use(entity this, entity actor, entity trigger) diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index 20b3b54c0..cab30262a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -273,10 +273,14 @@ void assault_new_round(entity this) else assault_attacker_team = NUM_TEAM_1; - FOREACH_ENTITY(IS_NOT_A_CLIENT(it), LAMBDA( + FOREACH_ENTITY_FLOAT(pure_data, false, + { + if(IS_CLIENT(it)) + continue; + if (it.team_saved == NUM_TEAM_1) it.team_saved = NUM_TEAM_2; else if (it.team_saved == NUM_TEAM_2) it.team_saved = NUM_TEAM_1; - )); + }); // reset the level with a countdown cvar_set("timelimit", ftos(ceil(time - game_starttime) / 60)); -- 2.39.2