From: bones_was_here Date: Fri, 7 Oct 2022 12:37:58 +0000 (+1000) Subject: func_door: fix erratic behaviour of spawned trigger field X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=93b0e9a582573edfc9eb11225e03fc835e3c39fb;p=xonotic%2Fxonotic-data.pk3dir.git func_door: fix erratic behaviour of spawned trigger field This was most noticeable with door .wait <= 1 but would eventually occur at higher wait values if players hang around in the trigger field. Also the door(s) usually did not stay open for the full .wait time after the player left the trigger field, as some time had passed since the .door_finished timestamp was set. To make this reliable AND efficient requires updating the state of the door(s), instead of maintaining a separate state in the trigger field entity. --- diff --git a/qcsrc/common/mapobjects/func/door.qc b/qcsrc/common/mapobjects/func/door.qc index 1316c32830..aed02cf3d7 100644 --- a/qcsrc/common/mapobjects/func/door.qc +++ b/qcsrc/common/mapobjects/func/door.qc @@ -369,14 +369,25 @@ void door_trigger_touch(entity this, entity toucher) #endif return; - if (time < this.door_finished) + if (this.owner.state == STATE_UP) return; // check if door is locked if (!door_check_keys(this, toucher)) return; - this.door_finished = time + 1; + if (this.owner.state == STATE_TOP) + { + if (this.owner.nextthink < this.owner.ltime + this.owner.wait) + { + entity e = this.owner; + do { + e.nextthink = e.ltime + e.wait; + e = e.enemy; + } while (e != this.owner); + } + return; + } door_use(this.owner, toucher, NULL); }