From 78515ffc548f21c93bc9de1656b2c310d696a814 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 27 Feb 2021 16:49:07 +0000 Subject: [PATCH] Improve server performance by making pure entities that don't have models --- qcsrc/common/ent_cs.qc | 2 +- qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc | 2 +- qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc | 2 +- qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc | 2 +- qcsrc/common/mapobjects/func/bobbing.qc | 4 ++-- qcsrc/common/mapobjects/func/fourier.qc | 4 ++-- qcsrc/common/mapobjects/func/pendulum.qc | 2 +- qcsrc/common/mapobjects/func/vectormamamam.qc | 2 +- qcsrc/common/mapobjects/subs.qc | 2 +- qcsrc/common/mapobjects/trigger/gravity.qc | 2 +- qcsrc/common/mapobjects/triggers.qc | 4 ++-- qcsrc/common/monsters/sv_monsters.qc | 2 +- qcsrc/common/mutators/mutator/buffs/sv_buffs.qc | 2 +- qcsrc/common/mutators/mutator/superspec/sv_superspec.qc | 2 +- .../mutator/weaponarena_random/sv_weaponarena_random.qc | 4 +++- .../mutator/weaponarena_random/sv_weaponarena_random.qh | 2 -- qcsrc/common/turrets/sv_turrets.qc | 2 +- qcsrc/common/wepent.qc | 2 +- qcsrc/lib/stats.qh | 4 ++-- qcsrc/server/elimination.qc | 2 +- qcsrc/server/round_handler.qc | 2 +- qcsrc/server/teamplay.qc | 2 +- qcsrc/server/world.qc | 2 +- 23 files changed, 28 insertions(+), 28 deletions(-) diff --git a/qcsrc/common/ent_cs.qc b/qcsrc/common/ent_cs.qc index d5815c01e..93c871043 100644 --- a/qcsrc/common/ent_cs.qc +++ b/qcsrc/common/ent_cs.qc @@ -240,7 +240,7 @@ ENTCS_PROP(SOLID, true, sv_solid, solid, ENTCS_SET_NORMAL, void entcs_attach(entity player) { - entity e = CS(player).entcs = new(entcs_sender); + entity e = CS(player).entcs = new_pure(entcs_sender); e.owner = player; setthink(e, entcs_think); e.nextthink = time; diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc index 0dfd1091d..7239f9e7a 100644 --- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc +++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc @@ -267,7 +267,7 @@ void ka_Handler_CheckBall(entity this) void ka_Initialize() // run at the start of a match, initiates game mode { - ka_Handler = new(ka_Handler); + ka_Handler = new_pure(ka_Handler); setthink(ka_Handler, ka_Handler_CheckBall); ka_Handler.nextthink = time; } diff --git a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc index 1c2eacffd..379eb2ee9 100644 --- a/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc +++ b/qcsrc/common/gamemodes/gamemode/keyhunt/sv_keyhunt.qc @@ -981,7 +981,7 @@ void kh_Initialize() // sets up th KH environment kh_teams = BITS(bound(2, kh_teams, 4)); // make a KH entity for controlling the game - kh_controller = new(kh_controller); + kh_controller = new_pure(kh_controller); setthink(kh_controller, kh_Controller_Think); kh_Controller_SetThink(0, kh_WaitForPlayers); diff --git a/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc index b98a8a917..ca5f1a32d 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/sv_nexball.qc @@ -461,7 +461,7 @@ spawnfunc(nexball_team) void nb_spawnteam(string teamname, float teamcolor) { LOG_TRACE("^2spawned team ", teamname); - entity e = new(nexball_team); + entity e = new_pure(nexball_team); e.netname = teamname; e.cnt = teamcolor; e.team = e.cnt + 1; diff --git a/qcsrc/common/mapobjects/func/bobbing.qc b/qcsrc/common/mapobjects/func/bobbing.qc index 3c4229a09..d010a8758 100644 --- a/qcsrc/common/mapobjects/func/bobbing.qc +++ b/qcsrc/common/mapobjects/func/bobbing.qc @@ -54,7 +54,7 @@ spawnfunc(func_bobbing) setblocked(this, generic_plat_blocked); if(this.dmg && (this.message == "")) this.message = " was squished"; - if(this.dmg && (this.message2 == "")) + if(this.dmg && (this.message2 == "")) this.message2 = "was squished by"; if(this.dmg && (!this.dmgtime)) this.dmgtime = 0.25; @@ -72,7 +72,7 @@ spawnfunc(func_bobbing) return; // wait for targets to spawn - controller = new(func_bobbing_controller); + controller = new_pure(func_bobbing_controller); controller.owner = this; controller.nextthink = time + 1; setthink(controller, func_bobbing_controller_think); diff --git a/qcsrc/common/mapobjects/func/fourier.qc b/qcsrc/common/mapobjects/func/fourier.qc index 73bb60536..2aad3f3bf 100644 --- a/qcsrc/common/mapobjects/func/fourier.qc +++ b/qcsrc/common/mapobjects/func/fourier.qc @@ -59,7 +59,7 @@ spawnfunc(func_fourier) setblocked(this, generic_plat_blocked); if(this.dmg && (this.message == "")) this.message = " was squished"; - if(this.dmg && (this.message2 == "")) + if(this.dmg && (this.message2 == "")) this.message2 = "was squished by"; if(this.dmg && (!this.dmgtime)) this.dmgtime = 0.25; @@ -74,7 +74,7 @@ spawnfunc(func_fourier) this.active = ACTIVE_ACTIVE; // wait for targets to spawn - controller = new(func_fourier_controller); + controller = new_pure(func_fourier_controller); controller.owner = this; controller.nextthink = time + 1; setthink(controller, func_fourier_controller_think); diff --git a/qcsrc/common/mapobjects/func/pendulum.qc b/qcsrc/common/mapobjects/func/pendulum.qc index c582f47f6..b47064000 100644 --- a/qcsrc/common/mapobjects/func/pendulum.qc +++ b/qcsrc/common/mapobjects/func/pendulum.qc @@ -63,7 +63,7 @@ spawnfunc(func_pendulum) this.cnt = this.angles_z; // wait for targets to spawn - controller = new(func_pendulum_controller); + controller = new_pure(func_pendulum_controller); controller.owner = this; controller.nextthink = time + 1; setthink(controller, func_pendulum_controller_think); diff --git a/qcsrc/common/mapobjects/func/vectormamamam.qc b/qcsrc/common/mapobjects/func/vectormamamam.qc index bd1e14fb1..53226a3c6 100644 --- a/qcsrc/common/mapobjects/func/vectormamamam.qc +++ b/qcsrc/common/mapobjects/func/vectormamamam.qc @@ -89,7 +89,7 @@ void func_vectormamamam_findtarget(entity this) this.destvec = this.origin - func_vectormamamam_origin(this, 0); - entity controller = new(func_vectormamamam_controller); + entity controller = new_pure(func_vectormamamam_controller); controller.owner = this; controller.nextthink = time + 1; setthink(controller, func_vectormamamam_controller_think); diff --git a/qcsrc/common/mapobjects/subs.qc b/qcsrc/common/mapobjects/subs.qc index 847deca6e..c0b137404 100644 --- a/qcsrc/common/mapobjects/subs.qc +++ b/qcsrc/common/mapobjects/subs.qc @@ -232,7 +232,7 @@ void SUB_CalcMove_Bezier (entity this, vector tcontrol, vector tdest, float tspe { delete(this.move_controller); } - controller = new(SUB_CalcMove_controller); + controller = new_pure(SUB_CalcMove_controller); controller.owner = this; this.move_controller = controller; controller.platmovetype = this.platmovetype; diff --git a/qcsrc/common/mapobjects/trigger/gravity.qc b/qcsrc/common/mapobjects/trigger/gravity.qc index ea63c9a74..33e10ea09 100644 --- a/qcsrc/common/mapobjects/trigger/gravity.qc +++ b/qcsrc/common/mapobjects/trigger/gravity.qc @@ -68,7 +68,7 @@ void trigger_gravity_touch(entity this, entity toucher) else return; } - toucher.trigger_gravity_check = new(trigger_gravity_checker); + toucher.trigger_gravity_check = new_pure(trigger_gravity_checker); toucher.trigger_gravity_check.enemy = this; toucher.trigger_gravity_check.owner = toucher; toucher.trigger_gravity_check.gravity = toucher.gravity; diff --git a/qcsrc/common/mapobjects/triggers.qc b/qcsrc/common/mapobjects/triggers.qc index 54550dcb2..39fa89c42 100644 --- a/qcsrc/common/mapobjects/triggers.qc +++ b/qcsrc/common/mapobjects/triggers.qc @@ -274,8 +274,8 @@ void SUB_UseTargets_Ex(entity this, entity actor, entity trigger, bool preventRe // if (this.delay) { - // create a temp object to fire at a later time - entity t = new(DelayedUse); + // create a temp object to fire at a later time + entity t = new_pure(DelayedUse); t.nextthink = time + this.delay; setthink(t, DelayThink); t.enemy = actor; diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 0ce51f21a..b7e4d20a3 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -218,7 +218,7 @@ void Monster_Delay_Action(entity this) void Monster_Delay(entity this, int repeat_count, float defer_amnt, void(entity) func) { // deferred attacking, checks if monster is still alive and target is still valid before attacking - entity e = new(Monster_Delay); + entity e = new_pure(Monster_Delay); setthink(e, Monster_Delay_Action); e.nextthink = time + defer_amnt; diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index 38345efcf..6fa6e8d05 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -473,7 +473,7 @@ MUTATOR_HOOKFUNCTION(buffs, Damage_Calculate) if(frag_attacker != frag_target) if(!ITEM_DAMAGE_NEEDKILL(frag_deathtype)) { - entity dmgent = new(dmgent); + entity dmgent = new_pure(dmgent); dmgent.dmg = frag_damage * autocvar_g_buffs_vengeance_damage_multiplier; dmgent.enemy = frag_attacker; diff --git a/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc b/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc index add4bec01..5328be79c 100644 --- a/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc +++ b/qcsrc/common/mutators/mutator/superspec/sv_superspec.qc @@ -401,7 +401,7 @@ MUTATOR_HOOKFUNCTION(superspec, ClientConnect) player.superspec_flags = SSF_VERBOSE; player.superspec_itemfilter = ""; - entity _hello = new(superspec_delayed_hello); + entity _hello = new_pure(superspec_delayed_hello); _hello.enemy = player; setthink(_hello, superspec_hello); _hello.nextthink = time + 5; diff --git a/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc b/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc index 32b6f3930..3932734d0 100644 --- a/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc +++ b/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qc @@ -45,9 +45,11 @@ MUTATOR_HOOKFUNCTION(weaponarena_random, GiveFragsForKill) } else { + + static entity GiveFrags_randomweapons; if(!GiveFrags_randomweapons) { - GiveFrags_randomweapons = new(GiveFrags_randomweapons); + GiveFrags_randomweapons = new_pure(GiveFrags_randomweapons); } if(warmup_stage) diff --git a/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qh b/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qh index 4af3cf036..7fb9581bb 100644 --- a/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qh +++ b/qcsrc/common/mutators/mutator/weaponarena_random/sv_weaponarena_random.qh @@ -1,5 +1,3 @@ #pragma once float g_weaponarena_random_with_blaster; - -entity GiveFrags_randomweapons; diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index 180981d8c..1b5e7cdb8 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -1256,7 +1256,7 @@ void turret_findtarget(entity this) entity e = find(NULL, classname, "turret_manager"); if(!e) { - e = new(turret_manager); + e = new_pure(turret_manager); setthink(e, turrets_manager_think); e.nextthink = time + 2; } diff --git a/qcsrc/common/wepent.qc b/qcsrc/common/wepent.qc index da2b0539d..c673b0980 100644 --- a/qcsrc/common/wepent.qc +++ b/qcsrc/common/wepent.qc @@ -158,7 +158,7 @@ MACRO_END void wepent_link(entity wep) { - entity e = new(wepent_sender); + entity e = new_pure(wepent_sender); e.owner = wep; setthink(e, wepent_think); e.nextthink = time; diff --git a/qcsrc/lib/stats.qh b/qcsrc/lib/stats.qh index 9bd4a3af9..f0ea92d63 100644 --- a/qcsrc/lib/stats.qh +++ b/qcsrc/lib/stats.qh @@ -125,8 +125,8 @@ int g_magic_stats_hole = 0; .int __stat_null; STATIC_INIT(stats) { - STATS = new(stats); - // Prevent engine stats being sent + STATS = new_pure(stats); + // Prevent engine stats being sent int r = STATS_ENGINE_RESERVE; for (int i = 0, n = 256 - r; i < n; ++i) { #define X(_, name, id) if (i == id) continue; diff --git a/qcsrc/server/elimination.qc b/qcsrc/server/elimination.qc index 8024c9a5c..b081c91a7 100644 --- a/qcsrc/server/elimination.qc +++ b/qcsrc/server/elimination.qc @@ -31,6 +31,6 @@ void EliminatedPlayers_Init(float(entity) isEliminated_func) backtrace("Can't spawn eliminatedPlayers again!"); return; } - Net_LinkEntity(eliminatedPlayers = spawn(), false, 0, EliminatedPlayers_SendEntity); + Net_LinkEntity(eliminatedPlayers = new_pure(), false, 0, EliminatedPlayers_SendEntity); eliminatedPlayers.isEliminated = isEliminated_func; } diff --git a/qcsrc/server/round_handler.qc b/qcsrc/server/round_handler.qc index 369e75708..93c383527 100644 --- a/qcsrc/server/round_handler.qc +++ b/qcsrc/server/round_handler.qc @@ -93,7 +93,7 @@ void round_handler_Spawn(bool() canRoundStart_func, bool() canRoundEnd_func, voi backtrace("Can't spawn round_handler again!"); return; } - entity this = round_handler = new(round_handler); + entity this = round_handler = new_pure(round_handler); setthink(this, round_handler_FirstThink); this.canRoundStart = canRoundStart_func; diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 59fa95afa..7b2027589 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -50,7 +50,7 @@ STATIC_INIT(g_team_entities) { for (int i = 0; i < NUM_TEAMS; ++i) { - g_team_entities[i] = spawn(); + g_team_entities[i] = new_pure(); } } diff --git a/qcsrc/server/world.qc b/qcsrc/server/world.qc index 2cacbac1a..93845d8a2 100644 --- a/qcsrc/server/world.qc +++ b/qcsrc/server/world.qc @@ -1833,7 +1833,7 @@ void readplayerstartcvars() start_ammo_plasma = 0; if (random_start_ammo == NULL) { - random_start_ammo = new(random_start_ammo); + random_start_ammo = new_pure(random_start_ammo); } start_health = cvar("g_balance_health_start"); start_armorvalue = cvar("g_balance_armor_start"); -- 2.39.2