]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
func_plat: don't spawn a "start moving" trigger when .targetname is set on Q3 maps
authorbones_was_here <bones_was_here@xonotic.au>
Thu, 13 Oct 2022 15:29:23 +0000 (01:29 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 16 Feb 2023 11:07:29 +0000 (21:07 +1000)
qcsrc/common/mapobjects/func/plat.qc
qcsrc/common/mapobjects/platforms.qc

index 2376c5956de1adbdc227654e30b819c8d5137b0f..ae9c121ab32cea5d943f24d6f5d138932bab7505 100644 (file)
@@ -7,7 +7,9 @@ void plat_link(entity this);
 void plat_delayedinit(entity this)
 {
        plat_link(this);
-       plat_spawn_inside_trigger(this); // the "start moving" trigger
+       // Q3 uses only a truth check of .targetname to decide whether to spawn a trigger
+       if(!Q3COMPAT_COMMON || this.targetname == "")
+               plat_spawn_inside_trigger(this); // the "start moving" trigger
 }
 
 float plat_send(entity this, entity to, float sf)
@@ -186,7 +188,8 @@ NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
                set_movetype(this, MOVETYPE_PUSH);
                this.move_time = time;
 
-               plat_spawn_inside_trigger(this);
+               if(!Q3COMPAT_COMMON || this.targetname == "")
+                       plat_spawn_inside_trigger(this);
        }
 
        if(sf & SF_TRIGGER_RESET)
index 2773845334149969e53a0758f22c7ee53396605a..9e1f635b32c9982ab594d10c3036bad243f6e00e 100644 (file)
@@ -173,6 +173,14 @@ void plat_use(entity this, entity actor, entity trigger)
        plat_go_down(this);
 }
 
+void plat_target_use(entity this, entity actor, entity trigger)
+{
+       if (this.state == STATE_TOP)
+               this.nextthink = this.ltime + 1;
+       else if (this.state != STATE_UP)
+               plat_go_up(this);
+}
+
 // WARNING: backwards compatibility because people don't use already existing fields :(
 // TODO: Check if any maps use these fields and remove these fields if it doesn't break maps
 .string sound1, sound2;
@@ -189,7 +197,7 @@ void plat_reset(entity this)
        {
                setorigin(this, this.pos2);
                this.state = STATE_BOTTOM;
-               this.use = plat_trigger_use;
+               this.use = (this.targetname != "" && Q3COMPAT_COMMON) ? plat_target_use : plat_trigger_use;
        }
 
 #ifdef SVQC