From: Mario Date: Tue, 21 Feb 2017 15:40:42 +0000 (+1000) Subject: Remove a weird array hack that's no longer required (frees up 127 virtually unused... X-Git-Tag: xonotic-v0.8.2~27^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=afca5e2ad7cb94bed2519c872d8e246e46b11303;p=xonotic%2Fxonotic-data.pk3dir.git Remove a weird array hack that's no longer required (frees up 127 virtually unused globals) --- diff --git a/qcsrc/common/mutators/base.qh b/qcsrc/common/mutators/base.qh index ee5dc4ab12..92e6323b32 100644 --- a/qcsrc/common/mutators/base.qh +++ b/qcsrc/common/mutators/base.qh @@ -162,10 +162,10 @@ ENDCLASS(Mutator) REGISTRY(Mutators, BITS(7)) #define Mutators_from(i) _Mutators_from(i, NULL) -Mutator loaded_mutators[Mutators_MAX]; bool Mutator_Add(Mutator mut); void Mutator_Remove(Mutator mut); bool mutator_log = false; +.bool m_added; #ifdef GAMEQC /** server mutators activate corresponding client mutators for all clients */ @@ -211,18 +211,10 @@ NET_HANDLE(Mutator, bool isNew) bool Mutator_Add(Mutator mut) { - int j = -1; - for (int i = 0; i < Mutators_MAX; ++i) { - if (loaded_mutators[i] == mut) - return true; // already added - if (!(loaded_mutators[i])) - j = i; - } - if (j < 0) { - backtrace("WARNING: too many mutators, cannot add any more\n"); - return false; - } - loaded_mutators[j] = mut; + if(mut.m_added) + return true; // already added + + mut.m_added = true; mutatorfunc_t func = mut.mutatorfunc; if (!func(MUTATOR_ADDING)) { // good @@ -242,15 +234,7 @@ bool Mutator_Add(Mutator mut) void Mutator_Remove(Mutator mut) { - int i; - for (i = 0; i < Mutators_MAX; ++i) - if (loaded_mutators[i] == mut) - break; - if (i >= Mutators_MAX) { - backtrace("WARNING: removing not-added mutator\n"); - return; - } - loaded_mutators[i] = NULL; + mut.m_added = false; mutatorfunc_t func = mut.mutatorfunc; if (func(MUTATOR_REMOVING)) { // baaaaad