]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make pure more entities and don't link them into the world
authorterencehill <piuntn@gmail.com>
Mon, 8 Mar 2021 17:14:21 +0000 (18:14 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 9 Mar 2021 18:25:42 +0000 (19:25 +0100)
qcsrc/common/effects/qc/damageeffects.qc
qcsrc/common/effects/qc/gibs.qc
qcsrc/lib/warpzone/common.qc
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/waypoints.qc
qcsrc/server/bot/default/waypoints.qh
qcsrc/server/command/cmd.qc

index c532e6a29a7cc9392f62d5695cff3087e71c2896..3ef63b138aee0740bb80706a5a4c0f8e7e307b3a 100644 (file)
@@ -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;
index 5500e85ae8a8cbf3ca4184f09ffdcc479f7cc863..ac69e9e0176609593299585480564813856085de 100644 (file)
@@ -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);
index 38e0e37d9b63fa1e2a1d45fbc9911e10a5a14187..b5198c08d1bc5b7db57e1d293ec5eb7d80cbf76e 100644 (file)
@@ -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":
index 9ba2a333b3d57ccfc5b893af9fe59232052211c4..59bf07a7a9e07f48fd0149ef9978866a0dff4e5e 100644 (file)
@@ -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)
index e26c219a7500223ad24cf1f963af9e97a0061496..87bb5c0cd18246bbcbd16b5678776a3364860338 100644 (file)
@@ -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)
                        {
index 4d36cb2e0ceaddd88e26d61f53c6e77fc300b2e6..c1afab673f8d358d35bb04c6c6f97bca4f9c38ee 100644 (file)
 #include <server/spawnpoints.qh>
 #include <server/weapons/tracing.qh>
 
+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));
index bcaa80dbc8268b6a52a492791ff4c6f0a7e4ea0a..a38752615224c25da70e4d061ee4bce72a6c2f67 100644 (file)
@@ -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;
index 570b8e5fc0bfcf180cb2fb61526e3b025a624182..dd96a9c90930a36a7d4304ecbe6c49e71c60488b 100644 (file)
@@ -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;