X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Ftriggers%2Ffunc%2Fconveyor.qc;h=acb6529ff3c196a1853b3213f500b47e29eb5c54;hb=6d4c6c37741b30553230ca5a27e6ebb8c6b885ac;hp=375a6adb867bca7c02d800a7a26c05b43548b31d;hpb=48d21b537ad85a66c05076afde4c33615da868b7;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/triggers/func/conveyor.qc b/qcsrc/common/triggers/func/conveyor.qc index 375a6adb8..acb6529ff 100644 --- a/qcsrc/common/triggers/func/conveyor.qc +++ b/qcsrc/common/triggers/func/conveyor.qc @@ -17,9 +17,9 @@ void conveyor_think(entity this) IL_REMOVE(g_conveyed, it); }); - if(this.state) + if(this.active) { - FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.conveyor.state && isPushable(it), + FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.conveyor.active && isPushable(it), { vector emin = it.absmin; vector emax = it.absmax; @@ -63,18 +63,49 @@ void conveyor_think(entity this) #ifdef SVQC -void conveyor_use(entity this, entity actor, entity trigger) +void conveyor_setactive(entity this, int act) { - this.state = !this.state; + int old_status = this.active; + if(act == ACTIVE_TOGGLE) + { + if(this.active == ACTIVE_ACTIVE) + { + this.active = ACTIVE_NOT; + } + else + { + this.active = ACTIVE_ACTIVE; + } + } + else + { + this.active = act; + } - this.SendFlags |= SF_TRIGGER_UPDATE; + if (this.active != old_status) + { + this.SendFlags |= SF_TRIGGER_UPDATE; + } +} + +// Compatibility with old maps +void conveyor_use(entity this, entity actor, entity trigger) +{ + conveyor_setactive(this, ACTIVE_TOGGLE); } void conveyor_reset(entity this) { - if(this.spawnflags & CONVEYOR_START_ENABLED) + IFTARGETED { - this.state = STATE_ON; + if(this.spawnflags & CONVEYOR_START_ENABLED) + { + this.active = ACTIVE_ACTIVE; + } + } + else + { + this.active = ACTIVE_ACTIVE; } this.SendFlags |= SF_TRIGGER_UPDATE; @@ -96,14 +127,14 @@ bool conveyor_send(entity this, entity to, int sendflags) WriteVector(MSG_ENTITY, this.movedir); WriteByte(MSG_ENTITY, this.speed); - WriteByte(MSG_ENTITY, this.state); + WriteByte(MSG_ENTITY, this.active); WriteString(MSG_ENTITY, this.targetname); WriteString(MSG_ENTITY, this.target); } if(sendflags & SF_TRIGGER_UPDATE) - WriteByte(MSG_ENTITY, this.state); + WriteByte(MSG_ENTITY, this.active); return true; } @@ -114,14 +145,14 @@ void conveyor_init(entity this) this.movedir *= this.speed; setthink(this, conveyor_think); this.nextthink = time; + this.setactive = conveyor_setactive; IFTARGETED { + // backwards compatibility this.use = conveyor_use; - this.reset = conveyor_reset; - this.reset(this); } - else - this.state = STATE_ON; + this.reset = conveyor_reset; + this.reset(this); FixSize(this); @@ -179,7 +210,7 @@ NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew) this.movedir = ReadVector(); this.speed = ReadByte(); - this.state = ReadByte(); + this.active = ReadByte(); this.targetname = strzone(ReadString()); this.target = strzone(ReadString()); @@ -188,7 +219,7 @@ NET_HANDLE(ENT_CLIENT_CONVEYOR, bool isnew) } if(sendflags & SF_TRIGGER_UPDATE) - this.state = ReadByte(); + this.active = ReadByte(); return true; }