diff options
author | rubidium <rubidium@openttd.org> | 2007-05-20 22:04:24 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-05-20 22:04:24 +0000 |
commit | fe420111e858bf37d9837cef8f33d9b530689dcb (patch) | |
tree | ac57754a35ba01ad4ff91419f6ce4e25bad6e86c | |
parent | 51109475a2e90499e19c1c7d1bff03393bdcaf4f (diff) | |
download | openttd-fe420111e858bf37d9837cef8f33d9b530689dcb.tar.xz |
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
-rw-r--r-- | src/road_cmd.cpp | 24 | ||||
-rw-r--r-- | src/road_gui.cpp | 5 | ||||
-rw-r--r-- | src/road_map.h | 4 | ||||
-rw-r--r-- | src/station_cmd.cpp | 2 |
4 files changed, 22 insertions, 13 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 636fed9a7..71a21db7d 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -147,17 +147,18 @@ int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) /* limit the bits to delete to the existing bits. */ c &= present; - if (c == 0) return CMD_ERROR; + if (c == ROAD_NONE) return CMD_ERROR; if (flags & DC_EXEC) { ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM); present ^= c; - if (present == 0) { + if (present == ROAD_NONE) { RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt)); if (rts == ROADTYPES_NONE) { DoClearSquare(tile); } else { + SetRoadBits(tile, ROAD_NONE, rt); SetRoadTypes(tile, rts); } } else { @@ -299,6 +300,7 @@ int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) switch (GetRoadTileType(tile)) { case ROAD_TILE_NORMAL: if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS); + if (!HASBIT(GetRoadTypes(tile), rt)) break; existing = GetRoadBits(tile, rt); if ((existing & pieces) == pieces) { @@ -381,7 +383,7 @@ do_clear:; if (flags & DC_EXEC) { if (IsTileType(tile, MP_STREET)) { - if (existing == 0) { + if (existing == ROAD_NONE) { SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt)); SetRoadOwner(tile, rt, _current_player); } @@ -434,7 +436,7 @@ int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec) * - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1) * - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2) * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) - * - p2 = (bit 3) - road type + * - p2 = (bit 3 + 4) - road type */ int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) { @@ -446,7 +448,8 @@ int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) if (p1 >= MapSize()) return CMD_ERROR; start_tile = p1; - RoadType rt = (RoadType)HASBIT(p2, 3); + RoadType rt = (RoadType)GB(p2, 3, 2); + if (!IsValidRoadType(rt)) return CMD_ERROR; /* Only drag in X or Y direction dictated by the direction variable */ if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis @@ -493,7 +496,7 @@ int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) * - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1) * - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2) * - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4) - * - p2 = (bit 3) - road type + * - p2 = (bit 3 + 4) - road type */ int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) { @@ -505,7 +508,8 @@ int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) if (p1 >= MapSize()) return CMD_ERROR; start_tile = p1; - RoadType rt = (RoadType)HASBIT(p2, 3); + RoadType rt = (RoadType)GB(p2, 3, 2); + if (!IsValidRoadType(rt)) return CMD_ERROR; /* Only drag in X or Y direction dictated by the direction variable */ if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis @@ -546,7 +550,7 @@ int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2) * @param tile tile where to build the depot * @param flags operation to perform * @param p1 bit 0..1 entrance direction (DiagDirection) - * bit 2 road type + * bit 2..3 road type * @param p2 unused * * @todo When checking for the tile slope, @@ -561,7 +565,9 @@ int32 CmdBuildRoadDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); DiagDirection dir = Extract<DiagDirection, 0>(p1); - RoadType rt = (RoadType)HASBIT(p1, 2); + RoadType rt = (RoadType)GB(p1, 2, 2); + + if (!IsValidRoadType(rt)) return CMD_ERROR; tileh = GetTileSlope(tile, NULL); if (tileh != SLOPE_FLAT && ( diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 3b21fef41..2ae045de9 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -84,11 +84,12 @@ static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction) void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { + DiagDirection dir = (DiagDirection)GB(p1, 0, 2); SndPlayTileFx(SND_1F_SPLAT, tile); ResetObjectToPlace(); - BuildRoadOutsideStation(tile, (DiagDirection)p1); + BuildRoadOutsideStation(tile, dir); /* For a drive-through road stop build connecting road for other entrance */ - if (HASBIT(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir((DiagDirection)p1)); + if (HASBIT(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir)); } } diff --git a/src/road_map.h b/src/road_map.h index 15edb8e43..4887e76d3 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -116,6 +116,7 @@ static inline void SetRoadOwner(TileIndex t, RoadType rt, Owner o) case ROADTYPE_TRAM: SB( _m[t].m5, 0, 5, o); break; case ROADTYPE_HWAY: SB(_me[t].m7, 0, 5, o); break; } + break; case ROAD_TILE_CROSSING: switch (rt) { default: NOT_REACHED(); @@ -123,6 +124,7 @@ static inline void SetRoadOwner(TileIndex t, RoadType rt, Owner o) case ROADTYPE_TRAM: SB( _m[t].m5, 0, 5, o); break; case ROADTYPE_HWAY: SB(_me[t].m7, 0, 5, o); break; } + break; case ROAD_TILE_DEPOT: return SetTileOwner(t, o); } } @@ -264,7 +266,7 @@ static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, Tow SetTileOwner(t, road); _m[t].m2 = town; _m[t].m3 = 0; - _m[t].m4 = (HASBIT(rot, ROADTYPE_ROAD) ? bits : 0) << 4 | HASBIT(rot, ROADTYPE_TRAM) ? bits : 0; + _m[t].m4 = (HASBIT(rot, ROADTYPE_TRAM) ? bits : 0) << 4 | (HASBIT(rot, ROADTYPE_ROAD) ? bits : 0); _m[t].m5 = ROAD_TILE_NORMAL << 6 | tram; SB(_m[t].m6, 2, 4, HASBIT(rot, ROADTYPE_HWAY) ? bits : 0); _me[t].m7 = rot << 5 | hway; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index d331dd870..313bd05b5 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -1397,7 +1397,7 @@ int32 CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) /* Save the stop info before it is removed */ bool is_drive_through = IsDriveThroughStopTile(tile); RoadTypes rts = GetRoadTypes(tile); - RoadBits road_bits = GetAnyRoadBits(tile, HASBIT(rts, ROADTYPE_ROAD) ? ROADTYPE_ROAD : ROADTYPE_TRAM); + RoadBits road_bits = GetAllRoadBits(tile); bool is_towns_road = is_drive_through && GetStopBuiltOnTownRoad(tile); int32 ret = RemoveRoadStop(st, flags, tile); |