689 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
691 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) { |
690 if (!CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE)) return CMD_ERROR; |
692 if (!CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE)) return CMD_ERROR; |
691 } |
693 } |
692 |
694 |
693 if (flags & DC_EXEC) { |
695 if (flags & DC_EXEC) { |
694 byte m5; |
696 TileIndex c = tile; |
695 uint c = tile; |
|
696 uint16 new_data; |
|
697 |
697 |
698 //checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until |
698 //checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until |
699 // you have a "Poor" (0) town rating |
699 // you have a "Poor" (0) town rating |
700 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) |
700 if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) |
701 ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); |
701 ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM); |
702 |
702 |
703 do { |
703 do { |
704 m5 = _m[c].m5; |
704 if (!(_m[c].m5 & 0x40)) { |
705 |
705 // bridge ramp |
706 if (m5 & 0x40) { |
706 DoClearSquare(c); |
707 if (m5 & 0x20) { |
|
708 static const uint16 _new_data_table[] = {0x1002, 0x1001, 0x2005, 0x200A, 0, 0, 0, 0}; |
|
709 new_data = _new_data_table[((m5 & 0x18) >> 2) | (m5 & 1)]; |
|
710 } else { |
|
711 if (GB(m5, 3, 2) == 0) goto clear_it; |
|
712 new_data = (GetTileSlope(c, NULL) == 0) ? 0x6000 : 0x6001; |
|
713 } |
|
714 |
|
715 SetTileType(c, new_data >> 12); |
|
716 _m[c].m5 = (byte)new_data; |
|
717 _m[c].m2 = 0; |
|
718 _m[c].m4 &= 0x0F; |
|
719 |
|
720 MarkTileDirtyByTile(c); |
|
721 |
|
722 } else { |
707 } else { |
723 clear_it:; |
708 // bridge middle part |
724 DoClearSquare(c); |
709 if (_m[c].m5 & 0x20) { |
|
710 // transport under bridge |
|
711 if (GB(_m[c].m5, 3, 2) == TRANSPORT_RAIL) { |
|
712 MakeRailNormal(c, GetTileOwner(c), _m[c].m5 & 1 ? TRACK_BIT_X : TRACK_BIT_Y, GB(_m[c].m3, 0, 3)); |
|
713 } else { |
|
714 MakeRoadNormal(c, GetTileOwner(c), _m[c].m5 & 1 ? ROAD_X : ROAD_Y, 0); // XXX Determine town, missing till now |
|
715 } |
|
716 MarkTileDirtyByTile(c); |
|
717 } else { |
|
718 // clear under bridge |
|
719 if (GB(_m[c].m5, 3, 2) == 0) { |
|
720 // grass under bridge |
|
721 DoClearSquare(c); |
|
722 } else { |
|
723 // water under bridge |
|
724 if (GetTileSlope(c, NULL) == 0) { |
|
725 MakeWater(c); |
|
726 } else { |
|
727 MakeShore(c); |
|
728 } |
|
729 MarkTileDirtyByTile(c); |
|
730 } |
|
731 } |
725 } |
732 } |
726 c += (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
733 c += (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
727 } while (c <= endtile); |
734 } while (c <= endtile); |
728 |
735 |
729 SetSignalsOnBothDir(tile, direction == AXIS_X ? TRACK_X : TRACK_Y); |
736 SetSignalsOnBothDir(tile, direction == AXIS_X ? TRACK_X : TRACK_Y); |