From 934a2ec1fa9681784a05b9e76ffbe45ab13aa9f0 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Sun, 27 Dec 2020 07:08:23 -0700 Subject: [PATCH] Switch railroad tracks when an actor with the RR sign makes a legal move --- js/tiletypes.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/tiletypes.js b/js/tiletypes.js index 67dc2dd..8454ebb 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -482,12 +482,19 @@ const TILE_TYPES = { return me.type._is_affected(me, other) && ! me.type.has_opening(me, direction); }, on_arrive(me, level, other) { - // FIXME actually this happens even if you have the sign so it shouldn't ignore!! level._set_tile_prop(me, 'entered_direction', other.direction); }, on_depart(me, level, other) { if (! level.is_tile_wired(me, false)) { - me.type._switch_track(me, level); + // Only switch if both the entering and the leaving are CURRENTLY valid directions + // (which has some quirky implications for the railroad sign) + if (me.track_switch === null) + return; + + let track = this.track_order[me.track_switch]; + if (track.indexOf(DIRECTIONS[me.entered_direction].opposite) >= 0 && track.indexOf(other.direction) >= 0) { + me.type._switch_track(me, level); + } } }, on_power(me, level) {