mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r9893) -Fix (r9892): various small bugs that only act up when using something different than plain roads.
This commit is contained in:
parent
d86b5e5e93
commit
07535d857b
|
@ -147,17 +147,18 @@ int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
/* limit the bits to delete to the existing bits. */
|
/* limit the bits to delete to the existing bits. */
|
||||||
c &= present;
|
c &= present;
|
||||||
if (c == 0) return CMD_ERROR;
|
if (c == ROAD_NONE) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
|
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
|
||||||
|
|
||||||
present ^= c;
|
present ^= c;
|
||||||
if (present == 0) {
|
if (present == ROAD_NONE) {
|
||||||
RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
|
RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
|
||||||
if (rts == ROADTYPES_NONE) {
|
if (rts == ROADTYPES_NONE) {
|
||||||
DoClearSquare(tile);
|
DoClearSquare(tile);
|
||||||
} else {
|
} else {
|
||||||
|
SetRoadBits(tile, ROAD_NONE, rt);
|
||||||
SetRoadTypes(tile, rts);
|
SetRoadTypes(tile, rts);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -299,6 +300,7 @@ int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
switch (GetRoadTileType(tile)) {
|
switch (GetRoadTileType(tile)) {
|
||||||
case ROAD_TILE_NORMAL:
|
case ROAD_TILE_NORMAL:
|
||||||
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
|
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
|
||||||
|
if (!HASBIT(GetRoadTypes(tile), rt)) break;
|
||||||
|
|
||||||
existing = GetRoadBits(tile, rt);
|
existing = GetRoadBits(tile, rt);
|
||||||
if ((existing & pieces) == pieces) {
|
if ((existing & pieces) == pieces) {
|
||||||
|
@ -381,7 +383,7 @@ do_clear:;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
if (IsTileType(tile, MP_STREET)) {
|
if (IsTileType(tile, MP_STREET)) {
|
||||||
if (existing == 0) {
|
if (existing == ROAD_NONE) {
|
||||||
SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
|
SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
|
||||||
SetRoadOwner(tile, rt, _current_player);
|
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 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 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 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)
|
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;
|
if (p1 >= MapSize()) return CMD_ERROR;
|
||||||
|
|
||||||
start_tile = p1;
|
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 */
|
/* 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
|
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 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 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 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)
|
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;
|
if (p1 >= MapSize()) return CMD_ERROR;
|
||||||
|
|
||||||
start_tile = p1;
|
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 */
|
/* 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
|
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 tile tile where to build the depot
|
||||||
* @param flags operation to perform
|
* @param flags operation to perform
|
||||||
* @param p1 bit 0..1 entrance direction (DiagDirection)
|
* @param p1 bit 0..1 entrance direction (DiagDirection)
|
||||||
* bit 2 road type
|
* bit 2..3 road type
|
||||||
* @param p2 unused
|
* @param p2 unused
|
||||||
*
|
*
|
||||||
* @todo When checking for the tile slope,
|
* @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);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
DiagDirection dir = Extract<DiagDirection, 0>(p1);
|
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);
|
tileh = GetTileSlope(tile, NULL);
|
||||||
if (tileh != SLOPE_FLAT && (
|
if (tileh != SLOPE_FLAT && (
|
||||||
|
|
|
@ -84,11 +84,12 @@ static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
|
||||||
void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (success) {
|
if (success) {
|
||||||
|
DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
|
||||||
SndPlayTileFx(SND_1F_SPLAT, tile);
|
SndPlayTileFx(SND_1F_SPLAT, tile);
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
BuildRoadOutsideStation(tile, (DiagDirection)p1);
|
BuildRoadOutsideStation(tile, dir);
|
||||||
/* For a drive-through road stop build connecting road for other entrance */
|
/* 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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_TRAM: SB( _m[t].m5, 0, 5, o); break;
|
||||||
case ROADTYPE_HWAY: SB(_me[t].m7, 0, 5, o); break;
|
case ROADTYPE_HWAY: SB(_me[t].m7, 0, 5, o); break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case ROAD_TILE_CROSSING:
|
case ROAD_TILE_CROSSING:
|
||||||
switch (rt) {
|
switch (rt) {
|
||||||
default: NOT_REACHED();
|
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_TRAM: SB( _m[t].m5, 0, 5, o); break;
|
||||||
case ROADTYPE_HWAY: SB(_me[t].m7, 0, 5, o); break;
|
case ROADTYPE_HWAY: SB(_me[t].m7, 0, 5, o); break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case ROAD_TILE_DEPOT: return SetTileOwner(t, o);
|
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);
|
SetTileOwner(t, road);
|
||||||
_m[t].m2 = town;
|
_m[t].m2 = town;
|
||||||
_m[t].m3 = 0;
|
_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;
|
_m[t].m5 = ROAD_TILE_NORMAL << 6 | tram;
|
||||||
SB(_m[t].m6, 2, 4, HASBIT(rot, ROADTYPE_HWAY) ? bits : 0);
|
SB(_m[t].m6, 2, 4, HASBIT(rot, ROADTYPE_HWAY) ? bits : 0);
|
||||||
_me[t].m7 = rot << 5 | hway;
|
_me[t].m7 = rot << 5 | hway;
|
||||||
|
|
|
@ -1397,7 +1397,7 @@ int32 CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
/* Save the stop info before it is removed */
|
/* Save the stop info before it is removed */
|
||||||
bool is_drive_through = IsDriveThroughStopTile(tile);
|
bool is_drive_through = IsDriveThroughStopTile(tile);
|
||||||
RoadTypes rts = GetRoadTypes(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);
|
bool is_towns_road = is_drive_through && GetStopBuiltOnTownRoad(tile);
|
||||||
|
|
||||||
int32 ret = RemoveRoadStop(st, flags, tile);
|
int32 ret = RemoveRoadStop(st, flags, tile);
|
||||||
|
|
Loading…
Reference in New Issue