]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use SPAWN_PURE TimePath/spawn2
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 18 Feb 2018 10:52:04 +0000 (21:52 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 18 Feb 2018 10:52:04 +0000 (21:52 +1100)
Entities are allocated outside the normal pool, for full qc control

qcsrc/common/mutators/base.qh
qcsrc/common/notifications/all.qc
qcsrc/lib/oo.qh
qcsrc/server/client.qc
qcsrc/server/command/vote.qc
qcsrc/server/g_world.qc
qcsrc/server/scores.qc
qcsrc/server/weapons/accuracy.qc

index 4f940c42b3c016f3e9131e0c6d3b213bc4d5497a..934dc7b852c5ba893dc3fb7eaba4d4c5e1bde5ec 100644 (file)
@@ -152,7 +152,7 @@ enum {
 
 USING(mutatorfunc_t, bool(int));
 
-CLASS(Mutator, Object)
+CLASS(Mutator, RealObject)
     ATTRIB(Mutator, m_id, int, 0);
     ATTRIB(Mutator, m_name, string);
     ATTRIB(Mutator, mutatorfunc, mutatorfunc_t);
index b9350758a115fb6ab3558c86e867a5e62d549c73..53eabcd04d7c5a648ae5e3f6b01f3ab18123ccfc 100644 (file)
@@ -1646,7 +1646,7 @@ void Send_Notification(
        }
        else
        {
-               entity net_notif = new_pure(net_notification);
+               entity net_notif = new(net_notification);
                IL_PUSH(g_notifications, net_notif);
                net_notif.owner = notif;
                net_notif.nent_broadcast = broadcast;
index f57bf8e909c4e7d1a594a0e36f2415b715483fda..260595f5901104f400c042d894cd336dde95a6c9 100644 (file)
@@ -25,7 +25,7 @@
 entity _spawn();
 
 #ifndef SPAWN_PURE
-#define SPAWN_PURE 0
+#define SPAWN_PURE 1
 #endif
 
 // pure entities: need no .origin
@@ -42,12 +42,14 @@ entity __spawn(string _classname, string _sourceLoc, bool pure)
        this.sourceLoc = _sourceLoc;
        if (pure) {
                make_pure(this);
-               #ifdef CSQC
-               setorigin(this, (world.mins + world.maxs) * 0.5);
-               #endif
-               #ifdef SVQC
+#if !SPAWN_PURE
+#ifdef CSQC
+        setorigin(this, (world.mins + world.maxs) * 0.5);
+#endif
+#ifdef SVQC
         setorigin(this, (world.mins + world.maxs) * 0.5);
-        #endif
+#endif
+#endif
        }
        return this;
 }
@@ -111,7 +113,7 @@ void clearentity(entity e)
 // Macros to hide this implementation detail:
 #ifdef __STDC__
        #define NEW(cname, ...) \
-               OVERLOAD_(spawn##cname, new_pure(cname) P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__))
+               OVERLOAD_(spawn##cname, (spawn##cname##Pure ? new_pure(cname) : new(cname)) P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__))
 
     #define _TRANSMUTE(cname, this, ...) \
         OVERLOAD_(spawn##cname, this P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__))
@@ -120,7 +122,7 @@ void clearentity(entity e)
                OVERLOAD_(spawn##cname, this P99_IF_EMPTY(__VA_ARGS__)()(, __VA_ARGS__))
 #else
        #define NEW(cname, ...) \
-               OVERLOAD(spawn##cname, new_pure(cname),##__VA_ARGS__)
+               OVERLOAD(spawn##cname, (spawn##cname##Pure ? new_pure(cname) : new(cname)),##__VA_ARGS__)
 
     #define _TRANSMUTE(cname, this, ...) \
         OVERLOAD(spawn##cname, this,##__VA_ARGS__)
@@ -181,6 +183,7 @@ STATIC_INIT(RegisterClasses)
 
 
 #define CLASS(cname, base)                  \
+    const bool spawn##cname##Pure = spawn##base##Pure; \
        entityclass(cname, base);               \
        class(cname).bool instanceOf##cname;    \
        DEBUG_STUFF(cname)                      \
@@ -286,12 +289,15 @@ STATIC_INIT(RegisterClasses)
 
 #define SUPER(cname) (cname##_vtbl.vtblbase)
 
+#define remove(this) delete(this)
+
 #define spawn_static(this)
 #define spawn_1(this)
 #define _vtbl NULL
+
+#define spawnPure true
 CLASS(Object, );
     DESTRUCTOR(Object) { builtin_remove(this); }
-    #define remove(this) delete(this)
        METHOD(Object, describe, string(Object this))
        {
            TC(Object, this);
@@ -312,6 +318,13 @@ CLASS(Object, );
                returns(sprintf("entity %i", this), "nopreview_map");
        }
 ENDCLASS(Object)
+#undef spawnpure
+
+#define spawnObjectPure false
+CLASS(RealObject, Object);
+ENDCLASS(RealObject)
+#undef spawnObjectPure
+
 #undef spawn_static
 #undef spawn_1
 #undef _vtbl
index f64935330a9567f19b29485ff5ebbfa835e1f5e7..420ecce0b70b4a4a842594ac0e8e3a1381d6c75e 100644 (file)
@@ -139,7 +139,7 @@ bool ClientData_Send(entity this, entity to, int sf)
 
 void ClientData_Attach(entity this)
 {
-       Net_LinkEntity(CS(this).clientdata = new_pure(clientdata), false, 0, ClientData_Send);
+       Net_LinkEntity(CS(this).clientdata = new(clientdata), false, 0, ClientData_Send);
        CS(this).clientdata.drawonlytoclient = this;
        CS(this).clientdata.owner = this;
 }
@@ -835,7 +835,7 @@ void ClientInit_CheckUpdate(entity this)
 
 void ClientInit_Spawn()
 {
-       entity e = new_pure(clientinit);
+       entity e = new(clientinit);
        setthink(e, ClientInit_CheckUpdate);
        Net_LinkEntity(e, false, 0, ClientInit_SendEntity);
 
index 7ed7d6b4eae3435478c111dde86799b25afdf77a..7a721fc1ef3d7dc7da3dcc4c752590a3ffa475e2 100644 (file)
@@ -93,7 +93,7 @@ bool Nagger_SendEntity(entity this, entity to, float sendflags)
 
 void Nagger_Init()
 {
-       Net_LinkEntity(nagger = new_pure(nagger), false, 0, Nagger_SendEntity);
+       Net_LinkEntity(nagger = new(nagger), false, 0, Nagger_SendEntity);
 }
 
 void Nagger_VoteChanged()
index 16303bd39f8a1092df21f37ef3bda62a8b950408..39631f240b9555235c9511c95d9b522ea0d4db2b 100644 (file)
@@ -556,7 +556,7 @@ void RandomSeed_Think(entity this)
 }
 void RandomSeed_Spawn()
 {
-       randomseed = new_pure(randomseed);
+       randomseed = new(randomseed);
        setthink(randomseed, RandomSeed_Think);
        Net_LinkEntity(randomseed, false, 0, RandomSeed_Send);
 
index c9948660efe1165c7ed8654dac1ba770e6763277..5acf31caa3b48e2fa124571ad3e2e678972eba2b 100644 (file)
@@ -87,7 +87,7 @@ bool TeamScore_SendEntity(entity this, entity to, float sendflags)
 
 void TeamScore_Spawn(float t, string name)
 {
-       entity ts = new_pure(csqc_score_team);
+       entity ts = new(csqc_score_team);
        ts.netname = name; // not used yet, FIXME
        ts.team = t;
        Net_LinkEntity(ts, false, 0, TeamScore_SendEntity);
@@ -208,7 +208,7 @@ void ScoreInfo_Init(int teams)
        }
        else
        {
-               scores_initialized = new_pure(ent_client_scoreinfo);
+               scores_initialized = new(ent_client_scoreinfo);
                Net_LinkEntity(scores_initialized, false, 0, ScoreInfo_SendEntity);
        }
        if(teams & BIT(0))
@@ -308,7 +308,7 @@ void PlayerScore_Attach(entity player)
 {
        if(CS(player).scorekeeper)
                error("player already has a scorekeeper");
-       entity sk = new_pure(scorekeeper);
+       entity sk = new(scorekeeper);
        sk.owner = player;
        Net_LinkEntity(sk, false, 0, PlayerScore_SendEntity);
        CS(player).scorekeeper = sk;
index f1800ae00eeda41b69bf8f8d1cbc24fbb90f002b..a62b50a50697022bb6976b8b57c0d3f4b4e2d9de 100644 (file)
@@ -40,7 +40,7 @@ bool accuracy_send(entity this, entity to, int sf)
 // init/free
 void accuracy_init(entity e)
 {
-       entity a = CS(e).accuracy = new_pure(accuracy);
+       entity a = CS(e).accuracy = new(accuracy);
        a.owner = e;
        a.drawonlytoclient = e;
        Net_LinkEntity(a, false, 0, accuracy_send);