tron@2186: /* $Id$ */ tron@2186: belugas@6889: /** @file road_cmd.cpp */ belugas@6889: truelight@0: #include "stdafx.h" Darkvater@1891: #include "openttd.h" tron@3189: #include "bridge_map.h" rubidium@6486: #include "bridge.h" tron@6460: #include "cmd_helper.h" tron@3101: #include "rail_map.h" tron@3144: #include "road_map.h" tron@4232: #include "sprite.h" hackykid@2008: #include "table/sprites.h" tron@507: #include "table/strings.h" tron@2163: #include "functions.h" tron@679: #include "map.h" maedhros@6669: #include "landscape.h" tron@1209: #include "tile.h" tron@3319: #include "town_map.h" truelight@0: #include "vehicle.h" truelight@0: #include "viewport.h" truelight@0: #include "command.h" truelight@0: #include "player.h" truelight@0: #include "town.h" truelight@0: #include "gfx.h" tron@337: #include "sound.h" KUDr@3900: #include "yapf/yapf.h" truelight@1313: #include "depot.h" maedhros@7037: #include "newgrf.h" rubidium@7175: #include "station_map.h" rubidium@7175: #include "tunnel_map.h" truelight@0: truelight@0: tron@3381: static uint CountRoadBits(RoadBits r) tron@3381: { tron@3381: uint count = 0; tron@3381: tron@3381: if (r & ROAD_NW) ++count; tron@3381: if (r & ROAD_SW) ++count; tron@3381: if (r & ROAD_SE) ++count; tron@3381: if (r & ROAD_NE) ++count; tron@3381: return count; tron@3381: } tron@3381: tron@3381: rubidium@7157: bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt) truelight@0: { tron@3149: RoadBits present; tron@3149: RoadBits n; truelight@0: *edge_road = true; truelight@0: rubidium@7157: if (_game_mode == GM_EDITOR || remove == ROAD_NONE) return true; truelight@0: rubidium@7247: /* Water can always flood and towns can always remove "normal" road pieces. rubidium@7247: * Towns are not be allowed to remove non "normal" road pieces, like tram rubidium@7247: * tracks as that would result in trams that cannot turn. */ rubidium@7247: if (_current_player == OWNER_WATER || rubidium@7247: (rt == ROADTYPE_ROAD && !IsValidPlayer(_current_player))) return true; truelight@0: belugas@6889: /* Only do the special processing if the road is owned belugas@6889: * by a town */ Darkvater@4849: if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner); truelight@0: tron@3017: if (_cheats.magic_bulldozer.value) return true; truelight@0: belugas@6889: /* Get a bitmask of which neighbouring roads has a tile */ rubidium@5838: n = ROAD_NONE; rubidium@7157: present = GetAnyRoadBits(tile, rt); rubidium@7157: if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile, -1, 0), rt) & ROAD_SW) n |= ROAD_NE; rubidium@7157: if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile, 0, 1), rt) & ROAD_NW) n |= ROAD_SE; rubidium@7157: if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0), rt) & ROAD_NE) n |= ROAD_SW; rubidium@7157: if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0, -1), rt) & ROAD_SE) n |= ROAD_NW; truelight@201: belugas@6889: /* If 0 or 1 bits are set in n, or if no bits that match the bits to remove, belugas@6889: * then allow it */ tron@3149: if ((n & (n - 1)) != 0 && (n & remove) != 0) { truelight@0: Town *t; truelight@0: *edge_road = false; belugas@6889: /* you can remove all kind of roads with extra dynamite */ tron@3017: if (_patches.extra_dynamite) return true; truelight@0: rubidium@6582: t = ClosestTownFromTile(tile, (uint)-1); Darkvater@1638: tron@534: SetDParam(0, t->index); truelight@0: _error_message = STR_2009_LOCAL_AUTHORITY_REFUSES; truelight@0: return false; truelight@0: } truelight@0: truelight@0: return true; truelight@0: } truelight@0: rubidium@7157: static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool *edge_road, RoadType rt) rubidium@6442: { rubidium@7157: return CheckAllowRemoveRoad(tile, remove, GetRoadOwner(tile, rt), edge_road, rt); rubidium@6442: } truelight@0: Darkvater@1784: /** Delete a piece of road. tron@3491: * @param tile tile where to remove road from belugas@6979: * @param flags operation to perform tron@6460: * @param p1 bit 0..3 road pieces to remove (RoadBits) rubidium@7157: * bit 4..5 road type Darkvater@1784: * @param p2 unused truelight@0: */ tron@3491: int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) truelight@0: { belugas@6889: /* cost for removing inner/edge -roads */ Darkvater@1638: static const uint16 road_remove_cost[2] = {50, 18}; Darkvater@1638: truelight@0: Town *t; Darkvater@1784: /* true if the roadpiece was always removeable, Darkvater@1784: * false if it was a center piece. Affects town ratings drop */ truelight@0: bool edge_road; truelight@201: truelight@0: SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); truelight@0: rubidium@7157: RoadType rt = (RoadType)GB(p1, 4, 2); rubidium@7175: if (!IsValidRoadType(rt)) return CMD_ERROR; Darkvater@2074: rubidium@7175: Owner owner; rubidium@7175: switch (GetTileType(tile)) { rubidium@7175: case MP_STREET: rubidium@7175: owner = GetRoadOwner(tile, rt); rubidium@7175: break; rubidium@7175: rubidium@7175: case MP_STATION: rubidium@7175: if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; rubidium@7175: owner = GetTileOwner(tile); rubidium@7175: break; rubidium@7175: rubidium@7175: case MP_TUNNELBRIDGE: rubidium@7175: if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) || rubidium@7175: (IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR; rubidium@7175: owner = GetTileOwner(tile); rubidium@7175: break; rubidium@7175: rubidium@7175: default: rubidium@7175: return CMD_ERROR; rubidium@7175: } Darkvater@1638: Darkvater@1638: if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) { celestar@5573: t = GetTownByTile(tile); tron@3017: } else { truelight@1280: t = NULL; tron@3017: } truelight@201: tron@6460: RoadBits pieces = Extract(p1); rubidium@7157: RoadTypes rts = GetRoadTypes(tile); rubidium@7157: /* The tile doesn't have the given road type */ rubidium@7157: if (!HASBIT(rts, rt)) return CMD_ERROR; tron@6460: rubidium@7157: if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) return CMD_ERROR; truelight@0: belugas@6902: if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; celestar@3933: belugas@6889: /* check if you're allowed to remove the street owned by a town belugas@6889: * removal allowance depends on difficulty setting */ celestar@5573: if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR; celestar@5573: rubidium@7175: if (!IsTileType(tile, MP_STREET)) { rubidium@7175: /* If it's the last roadtype, just clear the whole tile */ rubidium@7175: if (rts == RoadTypeToRoadTypes(rt)) return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); rubidium@7175: rubidium@7175: int32 cost; rubidium@7175: if (IsTileType(tile, MP_TUNNELBRIDGE)) { rubidium@7175: TileIndex other_end = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile); rubidium@7175: /* Pay for *every* tile of the bridge or tunnel */ rubidium@7175: cost = (DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile) + 1) * _price.remove_road; rubidium@7175: if (flags & DC_EXEC) { rubidium@7175: SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt)); rubidium@7175: SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt)); rubidium@7175: rubidium@7175: /* Mark tiles diry that have been repaved */ rubidium@7210: MarkTileDirtyByTile(tile); rubidium@7175: MarkTileDirtyByTile(other_end); rubidium@7175: if (IsBridge(tile)) { rubidium@7175: TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile)); rubidium@7175: rubidium@7209: for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t); rubidium@7175: } rubidium@7175: } rubidium@7175: } else { rubidium@7175: cost = _price.remove_road; rubidium@7175: if (flags & DC_EXEC) { rubidium@7175: SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt)); rubidium@7175: MarkTileDirtyByTile(tile); rubidium@7175: } rubidium@7175: } rubidium@7175: return cost; rubidium@7175: } rubidium@7175: celestar@5573: switch (GetRoadTileType(tile)) { celestar@5573: case ROAD_TILE_NORMAL: { rubidium@7157: RoadBits present = GetRoadBits(tile, rt); celestar@5573: RoadBits c = pieces; celestar@5573: celestar@5573: if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); celestar@5573: celestar@5573: if (GetTileSlope(tile, NULL) != SLOPE_FLAT && celestar@5573: (present == ROAD_Y || present == ROAD_X)) { rubidium@5838: c |= (RoadBits)((c & 0xC) >> 2); rubidium@5838: c |= (RoadBits)((c & 0x3) << 2); celestar@5573: } celestar@5573: belugas@6889: /* limit the bits to delete to the existing bits. */ celestar@5573: c &= present; rubidium@7158: if (c == ROAD_NONE) return CMD_ERROR; celestar@5573: celestar@5573: if (flags & DC_EXEC) { celestar@5573: ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); celestar@5573: celestar@5573: present ^= c; rubidium@7158: if (present == ROAD_NONE) { rubidium@7157: RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt)); rubidium@7157: if (rts == ROADTYPES_NONE) { rubidium@7157: DoClearSquare(tile); rubidium@7157: } else { rubidium@7158: SetRoadBits(tile, ROAD_NONE, rt); rubidium@7157: SetRoadTypes(tile, rts); rubidium@7157: } celestar@5573: } else { rubidium@7260: /* When bits are removed, you *always* end up with something that rubidium@7260: * is not a complete straight road tile. However, trams do not have rubidium@7260: * onewayness, so they cannot remove it either. */ rubidium@7260: if (rt != ROADTYPE_TRAM) SetDisallowedRoadDirections(tile, DRD_NONE); rubidium@7157: SetRoadBits(tile, present, rt); celestar@5573: MarkTileDirtyByTile(tile); celestar@5573: } celestar@5573: } celestar@5573: return CountRoadBits(c) * _price.remove_road; celestar@5573: } celestar@5573: celestar@5573: case ROAD_TILE_CROSSING: { celestar@5573: if (pieces & ComplementRoadBits(GetCrossingRoadBits(tile))) { tron@3176: return CMD_ERROR; truelight@0: } truelight@0: rubidium@7193: /* Don't allow road to be removed from the crossing when there is tram; rubidium@7193: * we can't draw the crossing without trambits ;) */ rubidium@7193: if (rt == ROADTYPE_ROAD && HASBIT(GetRoadTypes(tile), ROADTYPE_TRAM)) return CMD_ERROR; rubidium@7193: truelight@0: if (flags & DC_EXEC) { rubidium@7157: if (rt == ROADTYPE_ROAD) { rubidium@7157: ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); rubidium@7157: } celestar@5573: rubidium@7157: RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt)); rubidium@7157: if (rts == ROADTYPES_NONE) { rubidium@7157: MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile)); rubidium@7157: } else { rubidium@7157: SetRoadTypes(tile, rts); rubidium@7157: } tron@3060: MarkTileDirtyByTile(tile); rubidium@5838: YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile))); truelight@0: } tron@3381: return _price.remove_road * 2; celestar@5573: } tron@3977: celestar@5573: default: celestar@5573: case ROAD_TILE_DEPOT: celestar@5573: return CMD_ERROR; truelight@0: } truelight@0: } truelight@0: truelight@0: tron@3104: static const RoadBits _valid_tileh_slopes_road[][15] = { belugas@6889: /* set of normal ones */ truelight@0: { rubidium@5838: ROAD_ALL, ROAD_NONE, ROAD_NONE, rubidium@5838: ROAD_X, ROAD_NONE, ROAD_NONE, // 3, 4, 5 rubidium@5838: ROAD_Y, ROAD_NONE, ROAD_NONE, rubidium@5838: ROAD_Y, ROAD_NONE, ROAD_NONE, // 9, 10, 11 rubidium@5838: ROAD_X, ROAD_NONE, ROAD_NONE truelight@201: }, belugas@6889: /* allowed road for an evenly raised platform */ truelight@201: { rubidium@5838: ROAD_NONE, truelight@0: ROAD_SW | ROAD_NW, truelight@0: ROAD_SW | ROAD_SE, tron@3098: ROAD_Y | ROAD_SW, truelight@0: truelight@0: ROAD_SE | ROAD_NE, // 4 truelight@0: ROAD_ALL, tron@3098: ROAD_X | ROAD_SE, truelight@0: ROAD_ALL, truelight@0: truelight@0: ROAD_NW | ROAD_NE, // 8 tron@3098: ROAD_X | ROAD_NW, truelight@0: ROAD_ALL, truelight@0: ROAD_ALL, truelight@0: tron@3098: ROAD_Y | ROAD_NE, // 12 truelight@0: ROAD_ALL, truelight@0: ROAD_ALL dominik@13: }, truelight@0: }; truelight@0: truelight@0: tron@3636: static uint32 CheckRoadSlope(Slope tileh, RoadBits* pieces, RoadBits existing) truelight@0: { tron@3381: RoadBits road_bits; truelight@201: tron@4246: if (IsSteepSlope(tileh)) { tron@4246: if (existing == 0) { belugas@6889: /* force full pieces. */ rubidium@5838: *pieces |= (RoadBits)((*pieces & 0xC) >> 2); rubidium@5838: *pieces |= (RoadBits)((*pieces & 0x3) << 2); tron@4246: if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform; tron@4246: } tron@4246: return CMD_ERROR; tron@4246: } tron@3381: road_bits = *pieces | existing; truelight@0: belugas@6889: /* no special foundation */ tron@3381: if ((~_valid_tileh_slopes_road[0][tileh] & road_bits) == 0) { belugas@6889: /* force that all bits are set when we have slopes */ tron@3636: if (tileh != SLOPE_FLAT) *pieces |= _valid_tileh_slopes_road[0][tileh]; tron@3381: return 0; // no extra cost tron@3381: } tron@3381: belugas@6889: /* foundation is used. Whole tile is leveled up */ tron@3381: if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) { tron@4077: return existing != 0 ? 0 : _price.terraform; tron@3381: } tron@3381: belugas@6889: /* partly leveled up tile, only if there's no road on that tile */ tron@3636: if (existing == 0 && (tileh == SLOPE_W || tileh == SLOPE_S || tileh == SLOPE_E || tileh == SLOPE_N)) { belugas@6889: /* force full pieces. */ rubidium@5838: *pieces |= (RoadBits)((*pieces & 0xC) >> 2); rubidium@5838: *pieces |= (RoadBits)((*pieces & 0x3) << 2); tron@3381: if (*pieces == ROAD_X || *pieces == ROAD_Y) return _price.terraform; truelight@0: } truelight@0: return CMD_ERROR; truelight@0: } truelight@0: Darkvater@1784: /** Build a piece of road. tron@3491: * @param tile tile where to build road belugas@6979: * @param flags operation to perform tron@6460: * @param p1 bit 0..3 road pieces to build (RoadBits) rubidium@7157: * bit 4..5 road type rubidium@7260: * bit 6..7 disallowed directions to toggle Darkvater@1784: * @param p2 the town that is building the road (0 if not applicable) truelight@0: */ tron@3491: int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) truelight@0: { tron@3381: int32 cost = 0; tron@3381: int32 ret; rubidium@5838: RoadBits existing = ROAD_NONE; rubidium@7211: RoadBits all_bits = ROAD_NONE; tron@3636: Slope tileh; truelight@201: truelight@0: SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); truelight@0: Darkvater@1784: /* Road pieces are max 4 bitset values (NE, NW, SE, SW) and town can only be non-zero Darkvater@1784: * if a non-player is building the road */ tron@6460: if ((IsValidPlayer(_current_player) && p2 != 0) || (_current_player == OWNER_TOWN && !IsValidTownID(p2))) return CMD_ERROR; tron@6460: tron@6460: RoadBits pieces = Extract(p1); Darkvater@1784: rubidium@7157: RoadType rt = (RoadType)GB(p1, 4, 2); rubidium@7157: if (!IsValidRoadType(rt)) return CMD_ERROR; rubidium@7157: rubidium@7260: DisallowedRoadDirections toggle_drd = (DisallowedRoadDirections)GB(p1, 6, 2); rubidium@7260: celestar@3434: tileh = GetTileSlope(tile, NULL); truelight@0: celestar@3434: switch (GetTileType(tile)) { tron@3060: case MP_STREET: rubidium@3793: switch (GetRoadTileType(tile)) { rubidium@7260: case ROAD_TILE_NORMAL: { tron@4046: if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); rubidium@7252: if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; rubidium@7252: glx@7215: all_bits = GetAllRoadBits(tile); rubidium@7158: if (!HASBIT(GetRoadTypes(tile), rt)) break; tron@4046: rubidium@7157: existing = GetRoadBits(tile, rt); rubidium@7260: RoadBits merged = existing | pieces; rubidium@7264: bool crossing = (merged != ROAD_X && merged != ROAD_Y); rubidium@7264: if (rt != ROADTYPE_TRAM && (GetDisallowedRoadDirections(tile) != DRD_NONE || toggle_drd != DRD_NONE) && crossing) { rubidium@7260: /* Junctions cannot be one-way */ rubidium@7260: return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION); rubidium@7260: } tron@3150: if ((existing & pieces) == pieces) { rubidium@7260: /* We only want to set the (dis)allowed road directions */ rubidium@7260: if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && GetRoadOwner(tile, ROADTYPE_ROAD) == _current_player) { rubidium@7260: if (crossing) return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION); rubidium@7260: rubidium@7260: /* Ignore half built tiles */ rubidium@7260: if (flags & DC_EXEC && rt != ROADTYPE_TRAM && (existing == ROAD_X || existing == ROAD_Y)) { rubidium@7260: SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd); rubidium@7260: MarkTileDirtyByTile(tile); rubidium@7260: } rubidium@7260: return 0; rubidium@7260: } tron@3066: return_cmd_error(STR_1007_ALREADY_BUILT); tron@3066: } rubidium@7260: } break; tron@3066: rubidium@3793: case ROAD_TILE_CROSSING: rubidium@7157: if (HASBIT(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); rubidium@7211: all_bits = GetCrossingRoadBits(tile); rubidium@7211: if (pieces & ComplementRoadBits(all_bits)) goto do_clear; rubidium@7157: break; tron@3066: tron@3069: default: rubidium@3793: case ROAD_TILE_DEPOT: tron@3066: goto do_clear; tron@3060: } tron@3060: break; truelight@0: tron@3060: case MP_RAILWAY: { tron@3099: Axis roaddir; dominik@13: tron@3636: if (IsSteepSlope(tileh)) { tron@3060: return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); tron@3060: } tron@3060: tron@3104: #define M(x) (1 << (x)) tron@3104: /* Level crossings may only be built on these slopes */ tron@3636: if (!HASBIT(M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT), tileh)) { tron@3060: return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); tron@3060: } tron@3104: #undef M tron@3060: rubidium@3792: if (GetRailTileType(tile) != RAIL_TILE_NORMAL) goto do_clear; tron@3269: switch (GetTrackBits(tile)) { tron@3269: case TRACK_BIT_X: tron@3269: if (pieces & ROAD_X) goto do_clear; tron@3269: roaddir = AXIS_Y; tron@3269: break; tron@3269: tron@3269: case TRACK_BIT_Y: tron@3269: if (pieces & ROAD_Y) goto do_clear; tron@3269: roaddir = AXIS_X; tron@3269: break; tron@3269: tron@3269: default: goto do_clear; tron@3060: } tron@3060: belugas@6902: if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; tron@3381: tron@3060: if (flags & DC_EXEC) { rubidium@5838: YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile))); rubidium@7193: /* Always add road to the roadtypes (can't draw without it) */ rubidium@7193: MakeRoadCrossing(tile, _current_player, _current_player, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2); tron@3100: MarkTileDirtyByTile(tile); tron@3060: } rubidium@7193: return _price.build_road * (rt == ROADTYPE_ROAD ? 2 : 4); tron@3017: } truelight@0: rubidium@7175: case MP_STATION: rubidium@7175: if (!IsDriveThroughStopTile(tile)) return CMD_ERROR; rubidium@7175: if (HASBIT(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); rubidium@7257: /* Don't allow "upgrading" the roadstop when vehicles are already driving on it */ rubidium@7257: if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; rubidium@7175: break; rubidium@7175: rubidium@7175: case MP_TUNNELBRIDGE: rubidium@7175: if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) || rubidium@7175: (IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR; rubidium@7175: if (HASBIT(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT); rubidium@7257: /* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */ rubidium@7257: if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; rubidium@7175: break; rubidium@7175: tron@3060: default: truelight@0: do_clear:; tron@3491: ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); tron@3381: if (CmdFailed(ret)) return ret; tron@3381: cost += ret; truelight@0: } truelight@0: rubidium@7212: if (all_bits != pieces) { rubidium@7211: /* Check the foundation/slopes when adding road/tram bits */ rubidium@7211: ret = CheckRoadSlope(tileh, &pieces, all_bits | existing); rubidium@7211: /* Return an error if we need to build a foundation (ret != 0) but the rubidium@7211: * current patch-setting is turned off (or stupid AI@work) */ rubidium@7211: if (CmdFailed(ret) || (ret != 0 && (!_patches.build_on_slopes || _is_old_ai_player))) { rubidium@7211: return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); rubidium@7211: } rubidium@7211: cost += ret; rubidium@7211: } truelight@0: celestar@3434: if (IsTileType(tile, MP_STREET)) { belugas@6889: /* Don't put the pieces that already exist */ tron@3150: pieces &= ComplementRoadBits(existing); truelight@0: } truelight@0: tron@3381: cost += CountRoadBits(pieces) * _price.build_road; rubidium@7175: if (IsTileType(tile, MP_TUNNELBRIDGE)) { rubidium@7175: /* Pay for *every* tile of the bridge or tunnel */ rubidium@7175: cost *= DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile); rubidium@7175: } truelight@0: truelight@0: if (flags & DC_EXEC) { rubidium@7175: switch (GetTileType(tile)) { rubidium@7175: case MP_STREET: { rubidium@7175: RoadTileType rtt = GetRoadTileType(tile); rubidium@7175: if (existing == ROAD_NONE || rtt == ROAD_TILE_CROSSING) { rubidium@7175: SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); rubidium@7175: SetRoadOwner(tile, rt, _current_player); rubidium@7175: } rubidium@7175: if (rtt != ROAD_TILE_CROSSING) SetRoadBits(tile, existing | pieces, rt); rubidium@7175: } break; rubidium@7175: rubidium@7175: case MP_TUNNELBRIDGE: { rubidium@7175: TileIndex other_end = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile); rubidium@7175: rubidium@7175: SetRoadTypes(other_end, GetRoadTypes(other_end) | RoadTypeToRoadTypes(rt)); rubidium@7157: SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); rubidium@7175: rubidium@7175: /* Mark tiles diry that have been repaved */ rubidium@7175: MarkTileDirtyByTile(other_end); rubidium@7210: MarkTileDirtyByTile(tile); rubidium@7175: if (IsBridge(tile)) { rubidium@7175: TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile)); rubidium@7175: rubidium@7209: for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t); rubidium@7175: } rubidium@7175: } break; rubidium@7175: rubidium@7175: case MP_STATION: rubidium@7175: SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); rubidium@7175: break; rubidium@7175: rubidium@7175: default: rubidium@7175: MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, _current_player, _current_player, _current_player); rubidium@7175: break; truelight@0: } truelight@0: rubidium@7260: if (rt != ROADTYPE_TRAM && IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) { rubidium@7260: existing |= pieces; rubidium@7260: SetDisallowedRoadDirections(tile, (existing == ROAD_X || existing == ROAD_Y) ? rubidium@7260: GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE); rubidium@7260: } rubidium@7260: truelight@0: MarkTileDirtyByTile(tile); truelight@0: } truelight@0: return cost; truelight@0: } truelight@0: celestar@6694: /** celestar@6694: * Switches the rail type on a level crossing. celestar@6694: * @param tile The tile on which the railtype is to be convert. celestar@6694: * @param totype The railtype we want to convert to celestar@6694: * @param exec Switches between test and execute mode celestar@6694: * @return The cost and state of the operation celestar@6694: * @retval CMD_ERROR An error occured during the operation. celestar@6694: */ Darkvater@3435: int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec) truelight@0: { belugas@6889: /* not a railroad crossing? */ Darkvater@1927: if (!IsLevelCrossing(tile)) return CMD_ERROR; truelight@0: belugas@6889: /* not owned by me? */ belugas@6902: if (!CheckTileOwnership(tile) || !EnsureNoVehicleOnGround(tile)) return CMD_ERROR; truelight@0: rubidium@6498: if (GetRailType(tile) == totype) return CMD_ERROR; truelight@0: belugas@6889: /* 'hidden' elrails can't be downgraded to normal rail when elrails are disabled */ rubidium@6498: if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR; KUDr@5116: truelight@0: if (exec) { rubidium@6498: SetRailType(tile, totype); truelight@0: MarkTileDirtyByTile(tile); rubidium@5838: YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile))); truelight@0: } truelight@0: celestar@6694: return _price.build_rail / 2; truelight@0: } truelight@0: truelight@0: Darkvater@1784: /** Build a long piece of road. tron@3491: * @param end_tile end tile of drag belugas@6979: * @param flags operation to perform Darkvater@1784: * @param p1 start tile of drag Darkvater@1784: * @param p2 various bitstuffed elements Darkvater@1784: * - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1) Darkvater@1784: * - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2) Darkvater@1784: * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) rubidium@7158: * - p2 = (bit 3 + 4) - road type rubidium@7260: * - p2 = (bit 5) - set road direction Darkvater@1784: */ tron@3491: int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) truelight@0: { tron@3491: TileIndex start_tile, tile; Darkvater@1784: int32 cost, ret; rubidium@7206: bool had_bridge = false; rubidium@7260: bool had_success = false; rubidium@7260: DisallowedRoadDirections drd = DRD_NORTHBOUND; truelight@0: darkvater@889: SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); darkvater@889: tron@2934: if (p1 >= MapSize()) return CMD_ERROR; Darkvater@1784: truelight@0: start_tile = p1; rubidium@7158: RoadType rt = (RoadType)GB(p2, 3, 2); rubidium@7158: if (!IsValidRoadType(rt)) return CMD_ERROR; truelight@0: Darkvater@1784: /* Only drag in X or Y direction dictated by the direction variable */ Darkvater@1784: if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis Darkvater@1784: if (HASBIT(p2, 2) && TileX(start_tile) != TileX(end_tile)) return CMD_ERROR; // y-axis Darkvater@1784: Darkvater@1784: /* Swap start and ending tile, also the half-tile drag var (bit 0 and 1) */ Darkvater@1784: if (start_tile > end_tile || (start_tile == end_tile && HASBIT(p2, 0))) { Darkvater@1784: TileIndex t = start_tile; Darkvater@1784: start_tile = end_tile; Darkvater@1784: end_tile = t; rubidium@6987: p2 ^= IS_INT_INSIDE(p2 & 3, 1, 3) ? 3 : 0; rubidium@7260: drd = DRD_SOUTHBOUND; truelight@0: } truelight@0: rubidium@7260: /* On the X-axis, we have to swap the initial bits, so they rubidium@7260: * will be interpreted correctly in the GTTS. Futhermore rubidium@7260: * when you just 'click' on one tile to build them. */ rubidium@7260: if (HASBIT(p2, 2) == (start_tile == end_tile)) drd ^= DRD_BOTH; rubidium@7260: /* No disallowed direction bits have to be toggled */ rubidium@7260: if (!HASBIT(p2, 5)) drd = DRD_NONE; rubidium@7260: truelight@0: cost = 0; truelight@0: tile = start_tile; belugas@6889: /* Start tile is the small number. */ Darkvater@1784: for (;;) { tron@3098: RoadBits bits = HASBIT(p2, 2) ? ROAD_Y : ROAD_X; tron@3098: Darkvater@1784: if (tile == end_tile && !HASBIT(p2, 1)) bits &= ROAD_NW | ROAD_NE; Darkvater@1784: if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW; truelight@0: rubidium@7260: ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD); Darkvater@1784: if (CmdFailed(ret)) { Darkvater@1784: if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR; Darkvater@3671: _error_message = INVALID_STRING_ID; tron@2549: } else { rubidium@7260: had_success = true; rubidium@7206: /* Only pay for the upgrade on one side of the bridge */ rubidium@7206: if (IsBridgeTile(tile)) { rubidium@7206: if ((!had_bridge || GetBridgeRampDirection(tile) == DIAGDIR_SE || GetBridgeRampDirection(tile) == DIAGDIR_SW)) { rubidium@7206: cost += ret; rubidium@7206: } rubidium@7206: had_bridge = true; rubidium@7206: } else { rubidium@7206: cost += ret; rubidium@7206: } tron@2549: } truelight@0: Darkvater@1784: if (tile == end_tile) break; truelight@0: tron@1981: tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); truelight@0: } truelight@0: rubidium@7260: return !had_success ? CMD_ERROR : cost; truelight@0: } truelight@0: Darkvater@1784: /** Remove a long piece of road. tron@3491: * @param end_tile end tile of drag belugas@6979: * @param flags operation to perform Darkvater@1784: * @param p1 start tile of drag Darkvater@1784: * @param p2 various bitstuffed elements Darkvater@1784: * - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1) Darkvater@1784: * - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2) Darkvater@1784: * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) rubidium@7158: * - p2 = (bit 3 + 4) - road type Darkvater@1784: */ tron@3491: int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) truelight@0: { tron@3491: TileIndex start_tile, tile; Darkvater@1784: int32 cost, ret; truelight@0: darkvater@889: SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); darkvater@889: tron@2934: if (p1 >= MapSize()) return CMD_ERROR; Darkvater@1784: truelight@0: start_tile = p1; rubidium@7158: RoadType rt = (RoadType)GB(p2, 3, 2); rubidium@7158: if (!IsValidRoadType(rt)) return CMD_ERROR; truelight@0: Darkvater@1784: /* Only drag in X or Y direction dictated by the direction variable */ Darkvater@1784: if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis Darkvater@1784: if (HASBIT(p2, 2) && TileX(start_tile) != TileX(end_tile)) return CMD_ERROR; // y-axis Darkvater@1784: Darkvater@1784: /* Swap start and ending tile, also the half-tile drag var (bit 0 and 1) */ Darkvater@1784: if (start_tile > end_tile || (start_tile == end_tile && HASBIT(p2, 0))) { Darkvater@1784: TileIndex t = start_tile; Darkvater@1784: start_tile = end_tile; Darkvater@1784: end_tile = t; tron@3017: p2 ^= IS_INT_INSIDE(p2 & 3, 1, 3) ? 3 : 0; truelight@0: } truelight@0: truelight@0: cost = 0; truelight@0: tile = start_tile; belugas@6889: /* Start tile is the small number. */ Darkvater@1784: for (;;) { tron@3098: RoadBits bits = HASBIT(p2, 2) ? ROAD_Y : ROAD_X; tron@3098: Darkvater@1784: if (tile == end_tile && !HASBIT(p2, 1)) bits &= ROAD_NW | ROAD_NE; Darkvater@1784: if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW; truelight@201: belugas@6889: /* try to remove the halves. */ tron@3098: if (bits != 0) { rubidium@7157: ret = DoCommand(tile, rt << 4 | bits, 0, flags, CMD_REMOVE_ROAD); Darkvater@1784: if (!CmdFailed(ret)) cost += ret; truelight@0: } truelight@0: Darkvater@1784: if (tile == end_tile) break; truelight@0: tron@1981: tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0); truelight@0: } truelight@0: Darkvater@1784: return (cost == 0) ? CMD_ERROR : cost; truelight@0: } truelight@0: Darkvater@1784: /** Build a road depot. tron@3491: * @param tile tile where to build the depot belugas@6979: * @param flags operation to perform tron@6460: * @param p1 bit 0..1 entrance direction (DiagDirection) rubidium@7158: * bit 2..3 road type Darkvater@1784: * @param p2 unused celestar@2085: * celestar@2085: * @todo When checking for the tile slope, celestar@2085: * distingush between "Flat land required" and "land sloped in wrong direction" truelight@0: */ tron@3491: int32 CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) truelight@0: { truelight@0: int32 cost; truelight@0: Depot *dep; tron@3636: Slope tileh; truelight@0: truelight@0: SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); truelight@0: tron@6460: DiagDirection dir = Extract(p1); rubidium@7158: RoadType rt = (RoadType)GB(p1, 2, 2); rubidium@7158: rubidium@7158: if (!IsValidRoadType(rt)) return CMD_ERROR; Darkvater@1784: tron@3055: tileh = GetTileSlope(tile, NULL); tron@3636: if (tileh != SLOPE_FLAT && ( tron@2549: !_patches.build_on_slopes || tron@3636: IsSteepSlope(tileh) || tron@6460: !CanBuildDepotByTileh(dir, tileh) tron@2549: )) { tron@2549: return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); truelight@0: } truelight@0: tron@3491: cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); Darkvater@1784: if (CmdFailed(cost)) return CMD_ERROR; truelight@0: celestar@5573: if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); celestar@5573: truelight@0: dep = AllocateDepot(); tron@2549: if (dep == NULL) return CMD_ERROR; truelight@0: truelight@201: if (flags & DC_EXEC) { truelight@0: dep->xy = tile; truelight@0: dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; truelight@0: rubidium@7157: MakeRoadDepot(tile, _current_player, dir, rt); tron@3100: MarkTileDirtyByTile(tile); truelight@0: } truelight@0: return cost + _price.build_road_depot; truelight@0: } truelight@0: tron@1979: static int32 RemoveRoadDepot(TileIndex tile, uint32 flags) truelight@0: { darkvater@149: if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) truelight@0: return CMD_ERROR; truelight@0: tron@2639: if (!EnsureNoVehicle(tile)) return CMD_ERROR; truelight@0: truelight@4388: if (flags & DC_EXEC) DeleteDepot(GetDepotByTile(tile)); truelight@0: truelight@0: return _price.remove_road_depot; truelight@0: } truelight@0: tron@1977: static int32 ClearTile_Road(TileIndex tile, byte flags) tron@1977: { rubidium@3793: switch (GetRoadTileType(tile)) { rubidium@3793: case ROAD_TILE_NORMAL: { rubidium@7157: RoadBits b = GetAllRoadBits(tile); truelight@0: Darkvater@5888: #define M(x) (1 << (x)) Darkvater@5888: /* Clear the road if only one piece is on the tile OR the AI tries Darkvater@5888: * to clear town road OR we are not using the DC_AUTO flag */ Darkvater@5888: if ((M(b) & (M(ROAD_NW) | M(ROAD_SW) | M(ROAD_SE) | M(ROAD_NE))) || Darkvater@5888: ((flags & DC_AI_BUILDING) && IsTileOwner(tile, OWNER_TOWN)) || Darkvater@5888: !(flags & DC_AUTO) Darkvater@5888: ) { rubidium@7175: RoadTypes rts = GetRoadTypes(tile); rubidium@7175: int32 ret = 0; rubidium@7175: for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) { rubidium@7175: if (HASBIT(rts, rt)) { rubidium@7175: int32 tmp_ret = DoCommand(tile, rt << 4 | GetRoadBits(tile, rt), 0, flags, CMD_REMOVE_ROAD); rubidium@7175: if (CmdFailed(tmp_ret)) return tmp_ret; rubidium@7228: ret += tmp_ret; rubidium@7175: } rubidium@7175: } rubidium@7175: return ret; tron@3060: } Darkvater@5888: return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); Darkvater@5894: } Darkvater@5888: #undef M truelight@0: rubidium@3793: case ROAD_TILE_CROSSING: { tron@3060: int32 ret; tron@3060: tron@3069: if (flags & DC_AUTO) return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); tron@3060: tron@3491: ret = DoCommand(tile, GetCrossingRoadBits(tile), 0, flags, CMD_REMOVE_ROAD); tron@3060: if (CmdFailed(ret)) return CMD_ERROR; tron@3060: tron@3060: if (flags & DC_EXEC) { tron@3491: DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); tron@3060: } tron@3060: return ret; tron@3060: } tron@3060: tron@3069: default: rubidium@3793: case ROAD_TILE_DEPOT: tron@3060: if (flags & DC_AUTO) { tron@3060: return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); tron@3060: } tron@3060: return RemoveRoadDepot(tile, flags); truelight@0: } truelight@0: } truelight@0: truelight@0: rubidium@6574: struct DrawRoadTileStruct { truelight@0: uint16 image; truelight@0: byte subcoord_x; truelight@0: byte subcoord_y; rubidium@6574: }; truelight@0: truelight@0: #include "table/road_land.h" truelight@0: truelight@0: tron@3636: uint GetRoadFoundation(Slope tileh, RoadBits bits) tron@2548: { tron@3878: uint i; tron@3878: belugas@6889: /* normal level sloped building */ tron@4246: if (!IsSteepSlope(tileh) && tron@4246: (~_valid_tileh_slopes_road[1][tileh] & bits) == 0) { tron@4246: return tileh; tron@4246: } truelight@0: belugas@6889: /* inclined sloped building */ tron@3878: switch (bits) { tron@3878: case ROAD_X: i = 0; break; tron@3878: case ROAD_Y: i = 1; break; tron@3878: default: return 0; tron@3017: } tron@3878: switch (tileh) { tron@4246: case SLOPE_W: tron@4246: case SLOPE_STEEP_W: i += 0; break; tron@4246: case SLOPE_S: tron@4246: case SLOPE_STEEP_S: i += 2; break; tron@4246: case SLOPE_E: tron@4246: case SLOPE_STEEP_E: i += 4; break; tron@4246: case SLOPE_N: tron@4246: case SLOPE_STEEP_N: i += 6; break; tron@4246: default: return 0; tron@3878: } tron@3878: return i + 15; truelight@0: } truelight@0: truelight@0: const byte _road_sloped_sprites[14] = { truelight@0: 0, 0, 2, 0, truelight@0: 0, 1, 0, 0, truelight@0: 3, 0, 0, 0, truelight@0: 0, 0 truelight@0: }; truelight@0: peter1138@2471: /** maedhros@7037: * Whether to draw unpaved roads regardless of the town zone. maedhros@7037: * By default, OpenTTD always draws roads as unpaved if they are on a desert maedhros@7037: * tile or above the snowline. Newgrf files, however, can set a bit that allows maedhros@7037: * paved roads to be built on desert tiles as they would be on grassy tiles. maedhros@7037: * maedhros@7037: * @param tile The tile the road is on maedhros@7037: * @param roadside What sort of road this is maedhros@7037: * @return True if the road should be drawn unpaved regardless of the roadside. maedhros@7037: */ maedhros@7037: static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside) maedhros@7037: { maedhros@7037: return (IsOnSnow(tile) && maedhros@7037: !(_opt.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) && maedhros@7037: roadside != ROADSIDE_BARREN && roadside != ROADSIDE_GRASS && roadside != ROADSIDE_GRASS_ROAD_WORKS)); maedhros@7037: } maedhros@7037: maedhros@7037: /** rubidium@7187: * Draws the catenary for the given tile rubidium@7187: * @param ti information about the tile (slopes, height etc) rubidium@7187: * @param tram the roadbits for the tram rubidium@7187: */ rubidium@7187: void DrawTramCatenary(TileInfo *ti, RoadBits tram) rubidium@7187: { rubidium@7187: /* Don't draw the catenary under a low bridge */ rubidium@7187: if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !HASBIT(_transparent_opt, TO_BUILDINGS)) { rubidium@7187: uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile)); rubidium@7187: rubidium@7195: if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return; rubidium@7187: } rubidium@7187: rubidium@7187: SpriteID front; rubidium@7187: SpriteID back; rubidium@7187: rubidium@7187: if (ti->tileh != SLOPE_FLAT) { rubidium@7187: back = SPR_TRAMWAY_BACK_WIRES_SLOPED + _road_sloped_sprites[ti->tileh - 1]; rubidium@7187: front = SPR_TRAMWAY_FRONT_WIRES_SLOPED + _road_sloped_sprites[ti->tileh - 1]; rubidium@7187: } else { rubidium@7187: back = SPR_TRAMWAY_BASE + _road_backpole_sprites_1[tram]; rubidium@7187: front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram]; rubidium@7187: } rubidium@7187: rubidium@7187: SpriteID pal = PAL_NONE; rubidium@7187: if (HASBIT(_transparent_opt, TO_BUILDINGS)) { rubidium@7187: SETBIT(front, PALETTE_MODIFIER_TRANSPARENT); rubidium@7187: SETBIT(back, PALETTE_MODIFIER_TRANSPARENT); rubidium@7187: pal = PALETTE_TO_TRANSPARENT; rubidium@7187: } rubidium@7187: rubidium@7195: AddSortableSpriteToDraw(back, pal, ti->x, ti->y, 16, 16, 0x1F, ti->z); rubidium@7195: AddSortableSpriteToDraw(front, pal, ti->x, ti->y, 16, 16, 0x1F, ti->z); rubidium@7187: } rubidium@7187: rubidium@7187: /** rubidium@7260: * Draws details on/around the road rubidium@7260: * @param img the sprite to draw rubidium@7260: * @param ti the tile to draw on rubidium@7260: * @param dx the offset from the top of the BB of the tile rubidium@7260: * @param dy the offset from the top of the BB of the tile rubidium@7260: * @param h the height of the sprite to draw rubidium@7260: */ rubidium@7260: static void DrawRoadDetail(SpriteID img, TileInfo *ti, int dx, int dy, int h) rubidium@7260: { rubidium@7260: int x = ti->x | dx; rubidium@7260: int y = ti->y | dy; rubidium@7260: byte z = ti->z; rubidium@7260: if (ti->tileh != SLOPE_FLAT) z = GetSlopeZ(x, y); rubidium@7260: AddSortableSpriteToDraw(img, PAL_NONE, x, y, 2, 2, h, z); rubidium@7260: } rubidium@7260: rubidium@7260: /** peter1138@2471: * Draw ground sprite and road pieces peter1138@2471: * @param ti TileInfo peter1138@2471: */ tron@4081: static void DrawRoadBits(TileInfo* ti) peter1138@2471: { rubidium@7157: RoadBits road = GetRoadBits(ti->tile, ROADTYPE_ROAD); rubidium@7187: RoadBits tram = GetRoadBits(ti->tile, ROADTYPE_TRAM); rubidium@7187: peter1138@2471: const DrawRoadTileStruct *drts; peter1138@5919: SpriteID image = 0; peter1138@5919: SpriteID pal = PAL_NONE; tron@4048: Roadside roadside; peter1138@2471: tron@3636: if (ti->tileh != SLOPE_FLAT) { rubidium@7187: int foundation = GetRoadFoundation(ti->tileh, road | tram); peter1138@2471: tron@2639: if (foundation != 0) DrawFoundation(ti, foundation); peter1138@2471: belugas@6889: /* DrawFoundation() modifies ti. belugas@6889: * Default sloped sprites.. */ tron@3636: if (ti->tileh != SLOPE_FLAT) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F; peter1138@2471: } peter1138@2471: rubidium@7187: if (image == 0) image = _road_tile_sprites_1[road != ROAD_NONE ? road : tram]; peter1138@2471: tron@4048: roadside = GetRoadside(ti->tile); peter1138@2471: maedhros@7037: if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) { peter1138@2471: image += 19; tron@4048: } else { tron@4048: switch (roadside) { peter1138@5919: case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break; tron@4048: case ROADSIDE_GRASS: break; tron@4048: case ROADSIDE_GRASS_ROAD_WORKS: break; tron@4048: default: image -= 19; break; // Paved tron@4048: } peter1138@2471: } peter1138@2471: peter1138@5919: DrawGroundSprite(image, pal); peter1138@2471: rubidium@7260: if (road != ROAD_NONE) { rubidium@7260: DisallowedRoadDirections drd = GetDisallowedRoadDirections(ti->tile); rubidium@7260: if (drd != DRD_NONE) { rubidium@7260: DrawRoadDetail(SPR_ONEWAY_BASE + drd - 1 + ((road == ROAD_X) ? 0 : 3), ti, 8, 8, 0); rubidium@7260: } rubidium@7260: } rubidium@7260: rubidium@7187: /* For tram we overlay the road graphics with either tram tracks only rubidium@7187: * (when there is actual road beneath the trams) or with tram tracks rubidium@7187: * and some dirts which hides the road graphics */ rubidium@7187: if (tram != ROAD_NONE) { rubidium@7187: if (ti->tileh != SLOPE_FLAT) { rubidium@7187: image = _road_sloped_sprites[ti->tileh - 1] + SPR_TRAMWAY_SLOPED_OFFSET; rubidium@7187: } else { rubidium@7187: image = _road_tile_sprites_1[tram] - SPR_ROAD_Y; rubidium@7187: } rubidium@7187: image += (road == ROAD_NONE) ? SPR_TRAMWAY_TRAM : SPR_TRAMWAY_OVERLAY; rubidium@7187: DrawGroundSprite(image, pal); rubidium@7187: } rubidium@7187: celestar@3430: if (HasRoadWorks(ti->tile)) { belugas@6889: /* Road works */ rubidium@7187: DrawGroundSprite((road | tram) & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE); peter1138@2471: return; peter1138@2471: } peter1138@2471: rubidium@7187: if (tram != ROAD_NONE) DrawTramCatenary(ti, tram); rubidium@7187: belugas@6889: /* Return if full detail is disabled, or we are zoomed fully out. */ truelight@7122: if (!HASBIT(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZOOM_LVL_DETAIL) return; tron@5148: belugas@6889: /* Draw extra details. */ tron@4048: for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) { rubidium@7260: DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10); peter1138@2471: } peter1138@2471: } peter1138@2471: truelight@0: static void DrawTile_Road(TileInfo *ti) truelight@0: { rubidium@3793: switch (GetRoadTileType(ti->tile)) { rubidium@3793: case ROAD_TILE_NORMAL: tron@4081: DrawRoadBits(ti); tron@3060: break; truelight@0: rubidium@3793: case ROAD_TILE_CROSSING: { peter1138@5919: SpriteID image; peter1138@5919: SpriteID pal = PAL_NONE; maedhros@7037: Roadside roadside = GetRoadside(ti->tile); tron@4000: tron@3636: if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); truelight@0: rubidium@6498: image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.crossing; tron@3060: tron@3272: if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++; celestar@3322: if (IsCrossingBarred(ti->tile)) image += 2; tron@3060: maedhros@7037: if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) { tron@3060: image += 8; tron@3060: } else { maedhros@7037: switch (roadside) { peter1138@5919: case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break; tron@4048: case ROADSIDE_GRASS: break; tron@4048: default: image += 4; break; // Paved tron@4048: } tron@3060: } tron@3060: peter1138@5919: DrawGroundSprite(image, pal); rubidium@7193: if (HASBIT(GetRoadTypes(ti->tile), ROADTYPE_TRAM)) { rubidium@7193: DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal); rubidium@7193: DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile)); rubidium@7193: } rubidium@6498: if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti); tron@3060: break; truelight@0: } truelight@0: tron@3098: default: rubidium@3793: case ROAD_TILE_DEPOT: { tron@4232: const DrawTileSprites* dts; tron@4232: const DrawTileSeqStruct* dtss; peter1138@5919: SpriteID palette; truelight@0: tron@3636: if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh); tron@1398: tron@4226: palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile)); truelight@0: rubidium@7187: if (HASBIT(GetRoadTypes(ti->tile), ROADTYPE_TRAM)) { rubidium@7187: dts = &_tram_depot[GetRoadDepotDirection(ti->tile)]; rubidium@7187: } else { rubidium@7187: dts = &_road_depot[GetRoadDepotDirection(ti->tile)]; rubidium@7187: } rubidium@7187: peter1138@5919: DrawGroundSprite(dts->ground_sprite, PAL_NONE); tron@3060: tron@4232: for (dtss = dts->seq; dtss->image != 0; dtss++) { peter1138@5919: SpriteID image = dtss->image; peter1138@5919: SpriteID pal; tron@3060: peter1138@6923: if (HASBIT(_transparent_opt, TO_BUILDINGS)) { peter1138@5919: SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); peter1138@5919: pal = PALETTE_TO_TRANSPARENT; peter1138@5919: } else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) { peter1138@5919: pal = palette; peter1138@5919: } else { peter1138@5919: pal = PAL_NONE; tron@4226: } tron@3060: tron@4077: AddSortableSpriteToDraw( peter1138@5919: image, pal, tron@4232: ti->x + dtss->delta_x, ti->y + dtss->delta_y, tron@4232: dtss->size_x, dtss->size_y, tron@4232: dtss->size_z, ti->z tron@3060: ); tron@3060: } tron@3060: break; truelight@0: } truelight@0: } celestar@5573: DrawBridgeMiddle(ti); truelight@0: } truelight@0: rubidium@7162: void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt) truelight@0: { peter1138@5919: SpriteID palette = PLAYER_SPRITE_COLOR(_local_player); rubidium@7187: const DrawTileSprites* dts = (rt == ROADTYPE_TRAM) ? &_tram_depot[dir] : &_road_depot[dir]; tron@4232: const DrawTileSeqStruct* dtss; truelight@0: tron@2639: x += 33; tron@2639: y += 17; truelight@0: peter1138@5919: DrawSprite(dts->ground_sprite, PAL_NONE, x, y); truelight@0: tron@4232: for (dtss = dts->seq; dtss->image != 0; dtss++) { tron@4232: Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z); peter1138@5919: SpriteID image = dtss->image; truelight@201: peter1138@5919: DrawSprite(image, HASBIT(image, PALETTE_MODIFIER_COLOR) ? palette : PAL_NONE, x + pt.x, y + pt.y); truelight@0: } truelight@0: } truelight@0: tron@4231: static uint GetSlopeZ_Road(TileIndex tile, uint x, uint y) truelight@0: { tron@4231: uint z; tron@4231: Slope tileh = GetTileSlope(tile, &z); tron@3098: tron@3636: if (tileh == SLOPE_FLAT) return z; tron@4231: if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { rubidium@7157: uint f = GetRoadFoundation(tileh, GetAllRoadBits(tile)); tron@3060: tron@3286: if (f != 0) { tron@4246: if (IsSteepSlope(tileh)) { tron@4246: z += TILE_HEIGHT; tron@4246: } else if (f < 15) { tron@4246: return z + TILE_HEIGHT; // leveled foundation tron@4246: } tron@3286: tileh = _inclined_tileh[f - 15]; // inclined foundation truelight@0: } tron@4231: return z + GetPartialZ(x & 0xF, y & 0xF, tileh); tron@3286: } else { tron@3645: return z + TILE_HEIGHT; truelight@0: } dominik@39: } dominik@39: tron@3636: static Slope GetSlopeTileh_Road(TileIndex tile, Slope tileh) dominik@39: { tron@3636: if (tileh == SLOPE_FLAT) return SLOPE_FLAT; rubidium@3793: if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) { rubidium@7157: uint f = GetRoadFoundation(tileh, GetAllRoadBits(tile)); tron@3098: tron@3418: if (f == 0) return tileh; tron@3636: if (f < 15) return SLOPE_FLAT; // leveled foundation tron@3286: return _inclined_tileh[f - 15]; // inclined foundation tron@3286: } else { tron@3636: return SLOPE_FLAT; dominik@39: } truelight@0: } truelight@0: tron@1977: static void GetAcceptedCargo_Road(TileIndex tile, AcceptedCargo ac) truelight@0: { truelight@0: /* not used */ truelight@0: } truelight@0: tron@1977: static void AnimateTile_Road(TileIndex tile) truelight@0: { tron@2639: if (IsLevelCrossing(tile)) MarkTileDirtyByTile(tile); truelight@0: } truelight@0: tron@4048: tron@4048: static const Roadside _town_road_types[][2] = { tron@4048: { ROADSIDE_GRASS, ROADSIDE_GRASS }, tron@4048: { ROADSIDE_PAVED, ROADSIDE_PAVED }, tron@4048: { ROADSIDE_PAVED, ROADSIDE_PAVED }, tron@4048: { ROADSIDE_TREES, ROADSIDE_TREES }, tron@4048: { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED } truelight@0: }; truelight@0: tron@4048: static const Roadside _town_road_types_2[][2] = { tron@4048: { ROADSIDE_GRASS, ROADSIDE_GRASS }, tron@4048: { ROADSIDE_PAVED, ROADSIDE_PAVED }, tron@4048: { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }, tron@4048: { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED }, tron@4048: { ROADSIDE_STREET_LIGHTS, ROADSIDE_PAVED } truelight@0: }; truelight@0: truelight@0: tron@1977: static void TileLoop_Road(TileIndex tile) truelight@0: { tron@3017: switch (_opt.landscape) { belugas@6683: case LT_ARCTIC: maedhros@6669: if (IsOnSnow(tile) != (GetTileZ(tile) > GetSnowLine())) { celestar@3430: ToggleSnow(tile); tron@3017: MarkTileDirtyByTile(tile); tron@3017: } tron@3017: break; tron@3017: belugas@6683: case LT_TROPIC: celestar@3430: if (GetTropicZone(tile) == TROPICZONE_DESERT && !IsOnDesert(tile)) { celestar@3430: ToggleDesert(tile); tron@3017: MarkTileDirtyByTile(tile); tron@3017: } tron@3017: break; truelight@0: } truelight@0: rubidium@3793: if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) return; truelight@0: celestar@3430: if (!HasRoadWorks(tile)) { tron@4077: const Town* t = ClosestTownFromTile(tile, (uint)-1); tron@4077: int grp = 0; truelight@1280: truelight@0: if (t != NULL) { truelight@0: grp = GetTownRadiusGroup(t, tile); truelight@201: belugas@6889: /* Show an animation to indicate road work */ truelight@201: if (t->road_build_months != 0 && tron@4077: (DistanceManhattan(t->xy, tile) < 8 || grp != 0) && rubidium@7157: GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetAllRoadBits(tile) == ROAD_X || GetAllRoadBits(tile) == ROAD_Y)) { belugas@6902: if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && CHANCE16(1, 20)) { celestar@3430: StartRoadWorks(tile); truelight@201: tron@541: SndPlayTileFx(SND_21_JACKHAMMER, tile); truelight@0: CreateEffectVehicleAbove( celestar@3421: TileX(tile) * TILE_SIZE + 7, celestar@3421: TileY(tile) * TILE_SIZE + 7, truelight@0: 0, tron@1359: EV_BULLDOZER); truelight@0: MarkTileDirtyByTile(tile); truelight@0: return; truelight@0: } truelight@0: } truelight@0: } truelight@0: truelight@0: { celestar@3430: /* Adjust road ground type depending on 'grp' (grp is the distance to the center) */ belugas@6683: const Roadside* new_rs = (_opt.landscape == LT_TOYLAND) ? _town_road_types_2[grp] : _town_road_types[grp]; tron@4048: Roadside cur_rs = GetRoadside(tile); truelight@201: celestar@3430: /* We have our desired type, do nothing */ tron@4048: if (cur_rs == new_rs[0]) return; celestar@3430: celestar@3430: /* We have the pre-type of the desired type, switch to the desired type */ tron@4048: if (cur_rs == new_rs[1]) { tron@4048: cur_rs = new_rs[0]; celestar@3430: /* We have barren land, install the pre-type */ tron@4048: } else if (cur_rs == ROADSIDE_BARREN) { tron@4048: cur_rs = new_rs[1]; celestar@3430: /* We're totally off limits, remove any installation and make barren land */ truelight@0: } else { tron@4048: cur_rs = ROADSIDE_BARREN; truelight@0: } tron@4048: SetRoadside(tile, cur_rs); truelight@0: MarkTileDirtyByTile(tile); truelight@0: } celestar@3430: } else if (IncreaseRoadWorksCounter(tile)) { celestar@3430: TerminateRoadWorks(tile); truelight@0: MarkTileDirtyByTile(tile); truelight@0: } truelight@0: } truelight@0: tron@1977: static void ClickTile_Road(TileIndex tile) truelight@0: { rubidium@6585: if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) ShowDepotWindow(tile, VEH_ROAD); truelight@0: } truelight@0: truelight@0: static const byte _road_trackbits[16] = { truelight@0: 0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, truelight@0: }; truelight@0: rubidium@7179: static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint sub_mode) tron@1977: { rubidium@7157: tron@3066: switch (mode) { tron@3066: case TRANSPORT_RAIL: tron@3066: if (!IsLevelCrossing(tile)) return 0; tron@3267: return GetCrossingRailBits(tile) * 0x101; truelight@201: tron@3066: case TRANSPORT_ROAD: rubidium@7179: if ((GetRoadTypes(tile) & sub_mode) == 0) return 0; rubidium@3793: switch (GetRoadTileType(tile)) { rubidium@7179: case ROAD_TILE_NORMAL: { rubidium@7179: RoadType rt = (RoadType)FindFirstBit(sub_mode); rubidium@7260: const uint drd_to_multiplier[DRD_END] = { 0x101, 0x100, 0x1, 0x0 }; rubidium@7260: uint multiplier = drd_to_multiplier[rt == ROADTYPE_TRAM ? DRD_NONE : GetDisallowedRoadDirections(tile)]; rubidium@7260: return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile, rt)] * multiplier; rubidium@7179: } tron@3066: rubidium@3793: case ROAD_TILE_CROSSING: { tron@4158: uint32 r = AxisToTrackBits(GetCrossingRoadAxis(tile)) * 0x101; tron@3272: tron@3367: if (IsCrossingBarred(tile)) r *= 0x10001; tron@3066: return r; tron@3066: } tron@3066: tron@3069: default: rubidium@3793: case ROAD_TILE_DEPOT: tron@4158: return AxisToTrackBits(DiagDirToAxis(GetRoadDepotDirection(tile))) * 0x101; truelight@201: } tron@3066: break; tron@3066: tron@3066: default: break; truelight@0: } truelight@0: return 0; truelight@0: } truelight@0: truelight@0: static const StringID _road_tile_strings[] = { truelight@0: STR_1814_ROAD, truelight@0: STR_1814_ROAD, truelight@0: STR_1814_ROAD, truelight@0: STR_1815_ROAD_WITH_STREETLIGHTS, truelight@0: STR_1814_ROAD, truelight@0: STR_1816_TREE_LINED_ROAD, truelight@0: STR_1814_ROAD, truelight@0: STR_1814_ROAD, truelight@0: }; truelight@0: tron@1977: static void GetTileDesc_Road(TileIndex tile, TileDesc *td) truelight@0: { tron@1901: td->owner = GetTileOwner(tile); rubidium@3793: switch (GetRoadTileType(tile)) { rubidium@3793: case ROAD_TILE_CROSSING: td->str = STR_1818_ROAD_RAIL_LEVEL_CROSSING; break; rubidium@3793: case ROAD_TILE_DEPOT: td->str = STR_1817_ROAD_VEHICLE_DEPOT; break; tron@4048: default: td->str = _road_tile_strings[GetRoadside(tile)]; break; tron@3069: } truelight@0: } truelight@0: maedhros@7219: /** maedhros@7219: * Given the direction the road depot is pointing, this is the direction the maedhros@7219: * vehicle should be travelling in in order to enter the depot. maedhros@7219: */ maedhros@7219: static const byte _roadveh_enter_depot_dir[4] = { maedhros@7219: TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE truelight@0: }; truelight@0: tron@1977: static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y) truelight@0: { rubidium@3793: switch (GetRoadTileType(tile)) { rubidium@3793: case ROAD_TILE_CROSSING: rubidium@6585: if (v->type == VEH_TRAIN && !IsCrossingBarred(tile)) { tron@3060: /* train crossing a road */ tron@3060: SndPlayVehicleFx(SND_0E_LEVEL_CROSSING, v); celestar@3322: BarCrossing(tile); tron@3060: MarkTileDirtyByTile(tile); truelight@0: } tron@3060: break; tron@3060: rubidium@3793: case ROAD_TILE_DEPOT: rubidium@6585: if (v->type == VEH_ROAD && tron@4077: v->u.road.frame == 11 && maedhros@7219: _roadveh_enter_depot_dir[GetRoadDepotDirection(tile)] == v->u.road.state) { bjarni@4725: VehicleEnterDepot(v); rubidium@6317: return VETSB_ENTERED_WORMHOLE; tron@3060: } tron@3060: break; tron@3060: tron@3060: default: break; truelight@0: } rubidium@6317: return VETSB_CONTINUE; truelight@0: } truelight@0: truelight@0: Darkvater@2436: static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player) truelight@0: { rubidium@7157: if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) { rubidium@7213: if (GetTileOwner(tile) == old_player) { rubidium@7213: if (new_player == PLAYER_SPECTATOR) { rubidium@7213: DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); rubidium@7213: } else { rubidium@7213: SetTileOwner(tile, new_player); rubidium@7213: } rubidium@7185: } rubidium@7157: return; truelight@0: } truelight@0: rubidium@7157: for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) { rubidium@7157: if (!HASBIT(GetRoadTypes(tile), rt)) continue; truelight@0: rubidium@7157: if (GetRoadOwner(tile, rt) == old_player) { rubidium@7157: SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player); rubidium@7157: } rubidium@7157: } tron@3060: rubidium@7157: if (IsLevelCrossing(tile)) { rubidium@7185: if (GetTileOwner(tile) == old_player) { rubidium@7185: if (new_player == PLAYER_SPECTATOR) { rubidium@7185: MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY)); rubidium@7185: } else { rubidium@7185: SetTileOwner(tile, new_player); rubidium@7185: } rubidium@7185: } truelight@0: } truelight@0: } truelight@0: truelight@0: rubidium@5838: extern const TileTypeProcs _tile_type_road_procs = { rubidium@4344: DrawTile_Road, /* draw_tile_proc */ rubidium@4344: GetSlopeZ_Road, /* get_slope_z_proc */ rubidium@4344: ClearTile_Road, /* clear_tile_proc */ rubidium@4344: GetAcceptedCargo_Road, /* get_accepted_cargo_proc */ rubidium@4344: GetTileDesc_Road, /* get_tile_desc_proc */ rubidium@4344: GetTileTrackStatus_Road, /* get_tile_track_status_proc */ rubidium@4344: ClickTile_Road, /* click_tile_proc */ rubidium@4344: AnimateTile_Road, /* animate_tile_proc */ rubidium@4344: TileLoop_Road, /* tile_loop_clear */ rubidium@4344: ChangeTileOwner_Road, /* change_tile_owner_clear */ rubidium@4344: NULL, /* get_produced_cargo_proc */ rubidium@4344: VehicleEnter_Road, /* vehicle_enter_tile_proc */ rubidium@4344: GetSlopeTileh_Road, /* get_slope_tileh_proc */ truelight@0: };