From d626d9d5f28a380e4dc50645e8c609cdb4d55ca6 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Sat, 2 Apr 2016 23:51:12 +0100 Subject: [PATCH] fix removing of fences for normal tracks Building track and track designs did not use correct flag for ghosts therefore always attempting to remove fences and the removing of intersecting fences also did not work correctly. Fix both issues. --- src/ride/track.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/ride/track.c b/src/ride/track.c index e65a19a354..71ecf9af9e 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -4596,19 +4596,18 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in // push baseZ and clearanceZ int cur_z = baseZ * 8; - if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED)) { + if ((flags & GAME_COMMAND_FLAG_APPLY) && !(flags & GAME_COMMAND_FLAG_GHOST)) { footpath_remove_litter(x, y, z); - // push bl bh?? if (rideTypeFlags & RIDE_TYPE_FLAG_18) { map_remove_walls_at(x, y, baseZ * 8, clearanceZ * 8); - } - else { - uint8 _bl = *RCT2_GLOBAL(0x00F44054, uint8*); - _bl ^= 0x0F; - - for (int dl = bitscanforward(_bl); dl != -1; dl = bitscanforward(_bl)){ - _bl &= ~(1 << dl); - map_remove_intersecting_walls(x, y, baseZ, clearanceZ, direction & 3); + } else { + // Remove walls in the directions this track intersects + uint8 intersectingDirections = *RCT2_GLOBAL(0x00F44054, uint8*); + intersectingDirections ^= 0x0F; + for (int i = 0; i < 4; i++) { + if (intersectingDirections & (1 << i)) { + map_remove_intersecting_walls(x, y, baseZ, clearanceZ, i); + } } } }