From: TimePath Date: Thu, 5 Nov 2015 21:40:55 +0000 (+1100) Subject: Rubble: move to qc effects X-Git-Tag: xonotic-v0.8.2~1704 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=89a159e3c55b771605802d76c125c800cf3dea7b;p=xonotic%2Fxonotic-data.pk3dir.git Rubble: move to qc effects --- diff --git a/qcsrc/client/progs.inc b/qcsrc/client/progs.inc index e2cd0d689..4e127917a 100644 --- a/qcsrc/client/progs.inc +++ b/qcsrc/client/progs.inc @@ -13,7 +13,6 @@ #include "miscfunctions.qc" #include "movelib.qc" #include "player_skeleton.qc" -#include "rubble.qc" #include "scoreboard.qc" #include "shownames.qc" #include "teamradar.qc" diff --git a/qcsrc/client/rubble.qc b/qcsrc/client/rubble.qc deleted file mode 100644 index 3a0d3430d..000000000 --- a/qcsrc/client/rubble.qc +++ /dev/null @@ -1,53 +0,0 @@ -#include "rubble.qh" - -// LordHavoc: rewrote this file, it was really bad code - -void RubbleLimit(string cname, float limit, void() deleteproc) -{SELFPARAM(); - entity e; - entity oldest; - float c; - float oldesttime; - - // remove rubble of the same type if it's at the limit - // remove multiple rubble if the limit has been decreased - while(1) - { - e = findchain(classname,cname); - if (e == world) - break; - // walk the list and count the entities, find the oldest - // initialize our search with the first entity - c = 1; - oldest = e; - oldesttime = e.creationtime; - e = e.chain; - // compare to all other matching entities - while (e) - { - c = c + 1; - if (oldesttime > e.creationtime) - { - oldesttime = e.creationtime; - oldest = e; - } - e = e.chain; - } - - // stop if there are less than the limit already - if (c <= limit) - break; - - // delete this oldest one and search again - WITH(entity, self, oldest, deleteproc()); - } -} - -entity RubbleNew(string cname) -{ - // spawn a new entity and return it - entity e = spawn(); - e.classname = cname; - e.creationtime = time; - return e; -} diff --git a/qcsrc/client/rubble.qh b/qcsrc/client/rubble.qh deleted file mode 100644 index 944116802..000000000 --- a/qcsrc/client/rubble.qh +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef CLIENT_RUBBLE_H -#define CLIENT_RUBBLE_H -entityclass(Rubble); -class(Rubble) .float creationtime; -void RubbleLimit(string cname, float limit, void() deleteproc); -entity RubbleNew(string cname); -#endif diff --git a/qcsrc/common/effects/qc/casings.qc b/qcsrc/common/effects/qc/casings.qc index e79300cb0..815555df6 100644 --- a/qcsrc/common/effects/qc/casings.qc +++ b/qcsrc/common/effects/qc/casings.qc @@ -4,7 +4,7 @@ #ifdef CSQC #include "../../movetypes/movetypes.qh" -#include "../../../client/rubble.qh" +#include "rubble.qh" #endif REGISTER_NET_TEMP(casings) diff --git a/qcsrc/common/effects/qc/rubble.qh b/qcsrc/common/effects/qc/rubble.qh new file mode 100644 index 000000000..1a7cad850 --- /dev/null +++ b/qcsrc/common/effects/qc/rubble.qh @@ -0,0 +1,60 @@ +#ifndef RUBBLE_H +#define RUBBLE_H + +#ifdef CSQC + +entityclass(Rubble); +class(Rubble).float creationtime; + +void RubbleLimit(string cname, float limit, void() deleteproc) +{ + SELFPARAM(); + entity e; + entity oldest; + float c; + float oldesttime; + + // remove rubble of the same type if it's at the limit + // remove multiple rubble if the limit has been decreased + while (1) + { + e = findchain(classname, cname); + if (e == world) break; + // walk the list and count the entities, find the oldest + // initialize our search with the first entity + c = 1; + oldest = e; + oldesttime = e.creationtime; + e = e.chain; + // compare to all other matching entities + while (e) + { + c = c + 1; + if (oldesttime > e.creationtime) + { + oldesttime = e.creationtime; + oldest = e; + } + e = e.chain; + } + + // stop if there are less than the limit already + if (c <= limit) break; + + // delete this oldest one and search again + WITH(entity, self, oldest, deleteproc()); + } +} + +entity RubbleNew(string cname) +{ + // spawn a new entity and return it + entity e = spawn(); + e.classname = cname; + e.creationtime = time; + return e; +} + +#endif + +#endif