From 5cb9126b0ebd2e7ed0ad3a0222603cb99e7594c5 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 8 Mar 2021 18:14:21 +0100 Subject: [PATCH] Make pure more entities and don't link them into the world --- qcsrc/common/effects/qc/damageeffects.qc | 6 ++++-- qcsrc/common/effects/qc/gibs.qc | 6 ++++-- qcsrc/lib/warpzone/common.qc | 3 --- qcsrc/server/bot/default/bot.qc | 4 ++-- qcsrc/server/bot/default/navigation.qc | 8 ++++---- qcsrc/server/bot/default/waypoints.qc | 19 +++++++++++++++---- qcsrc/server/bot/default/waypoints.qh | 2 ++ qcsrc/server/command/cmd.qc | 2 +- 8 files changed, 32 insertions(+), 18 deletions(-) diff --git a/qcsrc/common/effects/qc/damageeffects.qc b/qcsrc/common/effects/qc/damageeffects.qc index c532e6a29..3ef63b138 100644 --- a/qcsrc/common/effects/qc/damageeffects.qc +++ b/qcsrc/common/effects/qc/damageeffects.qc @@ -28,8 +28,10 @@ void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad if(!sound_allowed(MSG_BROADCAST, dmgowner)) deathtype |= 0x8000; - e = new(damageinfo); - setorigin(e, org); + e = new_pure(damageinfo); + // origin is just data to be sent + //setorigin(e, org); + e.origin = org; e.projectiledeathtype = deathtype; e.dmg = coredamage; e.dmg_edge = edgedamage; diff --git a/qcsrc/common/effects/qc/gibs.qc b/qcsrc/common/effects/qc/gibs.qc index 5500e85ae..ac69e9e01 100644 --- a/qcsrc/common/effects/qc/gibs.qc +++ b/qcsrc/common/effects/qc/gibs.qc @@ -25,7 +25,7 @@ void Violence_GibSplash_At(vector org, vector dir, float type, float amount, ent if(g_cts) // no gibs in CTS return; - entity e = new(gibsplash); + entity e = new_pure(gibsplash); e.cnt = amount; e.state = type; // should stay smaller than 15 if(!sound_allowed(MSG_BROADCAST, gibowner) || !sound_allowed(MSG_BROADCAST, attacker)) @@ -39,7 +39,9 @@ void Violence_GibSplash_At(vector org, vector dir, float type, float amount, ent else e.team = etof(gibowner); - setorigin(e, org); + // origin is just data to be sent + //setorigin(e, org); + e.origin = org; e.velocity = dir; e.oldorigin_x = compressShortVector(e.velocity); diff --git a/qcsrc/lib/warpzone/common.qc b/qcsrc/lib/warpzone/common.qc index 38e0e37d9..b5198c08d 100644 --- a/qcsrc/lib/warpzone/common.qc +++ b/qcsrc/lib/warpzone/common.qc @@ -582,9 +582,6 @@ bool WarpZoneLib_BadEntity(entity e) case "weaponentity": case "exteriorweaponentity": case "sprite_waypoint": - case "waypoint": - case "gibsplash": - case "damageinfo": case "spawnfunc": case "weaponchild": case "chatbubbleentity": diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index 9ba2a333b..59bf07a7a 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -749,7 +749,7 @@ void bot_serverframe() localcmd("quit\n"); } - if (currentbots > 0 || autocvar_g_waypointeditor || autocvar_g_waypointeditor_auto) + if (currentbots > 0 || waypointeditor_enabled || autocvar_g_waypointeditor_auto) if (botframe_spawnedwaypoints) { if(botframe_cachedwaypointlinks) @@ -814,7 +814,7 @@ void bot_serverframe() } } - if (autocvar_g_waypointeditor) + if (waypointeditor_enabled) botframe_showwaypointlinks(); if (autocvar_g_waypointeditor_auto) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index e26c219a7..87bb5c0cd 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -923,7 +923,7 @@ entity navigation_findnearestwaypoint_withdist_except(entity ent, float walkfrom vector pm1 = ent.origin + ent.mins; vector pm2 = ent.origin + ent.maxs; - if (autocvar_g_waypointeditor && !IS_BOT_CLIENT(ent)) + if (waypointeditor_enabled && !IS_BOT_CLIENT(ent)) { // this code allows removing waypoints in the air and seeing jumppad/telepport waypoint links // FIXME it causes a bug where a waypoint spawned really close to another one (max 16 qu) @@ -1372,7 +1372,7 @@ void navigation_routerating(entity this, entity e, float f, float rangebias) } else { - if(autocvar_g_waypointeditor && e.nearestwaypointtimeout >= 0 && time > e.nearestwaypointtimeout) + if(waypointeditor_enabled && e.nearestwaypointtimeout >= 0 && time > e.nearestwaypointtimeout) e.nearestwaypoint = NULL; if ((!e.nearestwaypoint || e.navigation_dynamicgoal) @@ -1398,7 +1398,7 @@ void navigation_routerating(entity this, entity e, float f, float rangebias) if(e.navigation_dynamicgoal) e.nearestwaypointtimeout = time + 2; - else if(autocvar_g_waypointeditor) + else if(waypointeditor_enabled) e.nearestwaypointtimeout = time + 3 + random() * 2; } nwp = e.nearestwaypoint; @@ -1487,7 +1487,7 @@ bool navigation_routetogoal(entity this, entity e, vector startposition) if(nearest_wp && nearest_wp.enemy && !(nearest_wp.enemy.wpflags & WPFLAGMASK_NORELINK)) { // often path can be optimized by not adding the nearest waypoint - if (this.goalentity.navigation_dynamicgoal || autocvar_g_waypointeditor) + if (this.goalentity.navigation_dynamicgoal || waypointeditor_enabled) { if (nearest_wp.enemy.wpcost < autocvar_bot_ai_strategyinterval_movingtarget) { diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index 4d36cb2e0..c1afab673 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -20,6 +20,10 @@ #include #include +STATIC_INIT(waypoints) +{ + waypointeditor_enabled = autocvar_g_waypointeditor; +} .entity spawnpointmodel; void waypoint_unreachable(entity pl) { @@ -355,7 +359,7 @@ void waypoint_restore_hardwiredlinks(entity wp) void waypoint_setupmodel(entity wp) { - if (autocvar_g_waypointeditor) + if (waypointeditor_enabled) { // TODO: add some sort of visible box in edit mode for box waypoints vector m1 = wp.mins; @@ -449,7 +453,11 @@ entity waypoint_spawn(vector m1, vector m2, float f) w.wpflags = f; w.solid = SOLID_TRIGGER; w.createdtime = time; - setorigin(w, (m1 + m2) * 0.5); + w.origin = (m1 + m2) * 0.5; + if (waypointeditor_enabled) + setorigin(w, w.origin); + else // don't link into the world, only bots are aware of waypoints + make_pure(w); setsize(w, m1 - w.origin, m2 - w.origin); if (w.size) w.wpisbox = true; @@ -1287,7 +1295,10 @@ spawnfunc(waypoint) { IL_PUSH(g_waypoints, this); - setorigin(this, this.origin); + if (waypointeditor_enabled) + setorigin(this, this.origin); + else + make_pure(this); // schedule a relink after other waypoints have had a chance to spawn waypoint_clearlinks(this); //waypoint_schedulerelink(this); @@ -1909,7 +1920,7 @@ float waypoint_loadall() waypoint_version_loaded = ver; LOG_TRACE("loaded ", ftos(cwp), " waypoints and ", ftos(cwb), " wayboxes from maps/", mapname, ".waypoints"); - if (autocvar_g_waypointeditor && autocvar_g_waypointeditor_symmetrical_allowload) + if (waypointeditor_enabled && autocvar_g_waypointeditor_symmetrical_allowload) { string sym_str = ""; cvar_set("g_waypointeditor_symmetrical", ftos(sym)); diff --git a/qcsrc/server/bot/default/waypoints.qh b/qcsrc/server/bot/default/waypoints.qh index bcaa80dbc..a38752615 100644 --- a/qcsrc/server/bot/default/waypoints.qh +++ b/qcsrc/server/bot/default/waypoints.qh @@ -1,5 +1,7 @@ #pragma once +bool waypointeditor_enabled; + bool autocvar_g_waypointeditor; bool autocvar_g_waypointeditor_symmetrical; bool autocvar_g_waypointeditor_symmetrical_allowload = true; diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 570b8e5fc..dd96a9c90 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -164,7 +164,7 @@ void ClientCommand_wpeditor(entity caller, int request, int argc) { case CMD_REQUEST_COMMAND: { - if (!autocvar_g_waypointeditor) + if (!waypointeditor_enabled) { sprint(caller, "ERROR: this command works only if the waypoint editor is on\n"); return; -- 2.39.2