From b5cb45aa9108dba6805d64468dbf0d81de4c574e Mon Sep 17 00:00:00 2001 From: TimePath Date: Sat, 12 Mar 2016 22:18:14 +1100 Subject: [PATCH] _Movetype_UnstickEntity: micro-optimize --- qcsrc/common/physics/movetypes/movetypes.qc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/qcsrc/common/physics/movetypes/movetypes.qc b/qcsrc/common/physics/movetypes/movetypes.qc index de623b503..ce469ed6a 100644 --- a/qcsrc/common/physics/movetypes/movetypes.qc +++ b/qcsrc/common/physics/movetypes/movetypes.qc @@ -411,9 +411,10 @@ void _Movetype_LinkEdict(entity this, bool touch_triggers) // SV_LinkEdict _Movetype_LinkEdict_TouchAreaGrid(this); } -bool _Movetype_TestEntityPosition(/*entity this, */ vector ofs) // SV_TestEntityPosition +entity _Movetype_TestEntityPosition_ent; +bool _Movetype_TestEntityPosition(vector ofs) // SV_TestEntityPosition { - SELFPARAM(); // XXX: performance + entity this = _Movetype_TestEntityPosition_ent; // vector org = this.move_origin + ofs; int cont = this.dphitcontentsmask; @@ -431,13 +432,11 @@ bool _Movetype_TestEntityPosition(/*entity this, */ vector ofs) // SV_TestEntit bool _Movetype_UnstickEntity(entity this) // SV_UnstickEntity { - entity oldself = this; - setself(this); - if (!_Movetype_TestEntityPosition(/* this, */ ' 0 0 0')) { - setself(oldself); + _Movetype_TestEntityPosition_ent = this; + if (!_Movetype_TestEntityPosition(' 0 0 0')) { return true; } - #define X(v) if (_Movetype_TestEntityPosition(/* this, */ v)) + #define X(v) if (_Movetype_TestEntityPosition(v)) X('-1 0 0') X(' 1 0 0') X(' 0 -1 0') X(' 0 1 0') X('-1 -1 0') X(' 1 -1 0') @@ -445,20 +444,18 @@ bool _Movetype_UnstickEntity(entity this) // SV_UnstickEntity #undef X { #define X(i) \ - if (_Movetype_TestEntityPosition(/* this, */ '0 0 -1' * i)) \ - if (_Movetype_TestEntityPosition(/* this, */ '0 0 1' * i)) + if (_Movetype_TestEntityPosition('0 0 -1' * i)) \ + if (_Movetype_TestEntityPosition('0 0 1' * i)) X(01) X(02) X(03) X(04) X(05) X(06) X(07) X(08) X(09) X(10) X(11) X(12) X(13) X(14) X(15) X(16) X(17) #undef X { - setself(oldself); LOG_DEBUGF("Can't unstick an entity (edict: %d, classname: %s, origin: %s)\n", etof(this), this.classname, vtos(this.move_origin)); return false; } } - setself(oldself); LOG_DEBUGF("Sucessfully unstuck an entity (edict: %d, classname: %s, origin: %s)\n", etof(this), this.classname, vtos(this.move_origin)); _Movetype_LinkEdict(this, true); -- 2.39.2