Changeset - r10128:f4940f705b87
[Not reviewed]
master
0 1 0
smatz - 16 years ago 2008-09-13 17:06:44
smatz@openttd.org
(svn r14314) -Fix: pay for two road bits when adding/removing roadtype at drive through road stop/level crossing
1 file changed with 6 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/road_cmd.cpp
Show inline comments
 
@@ -252,13 +252,14 @@ static CommandCost RemoveRoad(TileIndex 
 
					TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
 

	
 
					for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
 
				}
 
			}
 
		} else {
 
			cost.AddCost(_price.remove_road);
 
			assert(IsDriveThroughStopTile(tile));
 
			cost.AddCost(_price.remove_road * 2);
 
			if (flags & DC_EXEC) {
 
				SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
 
				MarkTileDirtyByTile(tile);
 
			}
 
		}
 
		return cost;
 
@@ -522,12 +523,13 @@ CommandCost CmdBuildRoad(TileIndex tile,
 
				} break;
 

	
 
				case ROAD_TILE_CROSSING:
 
					if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
 
					other_bits = GetCrossingRoadBits(tile);
 
					if (pieces & ComplementRoadBits(other_bits)) goto do_clear;
 
					pieces = other_bits; // we need to pay for both roadbits
 
					break;
 

	
 
				default:
 
				case ROAD_TILE_DEPOT:
 
					goto do_clear;
 
			}
 
@@ -574,13 +576,15 @@ CommandCost CmdBuildRoad(TileIndex tile,
 
			return CommandCost(EXPENSES_CONSTRUCTION, _price.build_road * (rt == ROADTYPE_ROAD ? 2 : 4));
 
		}
 

	
 
		case MP_STATION:
 
			if (!IsRoadStop(tile)) goto do_clear;
 
			if (IsDriveThroughStopTile(tile)) {
 
				if (pieces & ~AxisToRoadBits(DiagDirToAxis(GetRoadStopDir(tile)))) goto do_clear;
 
				RoadBits curbits = AxisToRoadBits(DiagDirToAxis(GetRoadStopDir(tile)));
 
				if (pieces & ~curbits) goto do_clear;
 
				pieces = curbits; // we need to pay for both roadbits
 
			} else {
 
				if (pieces & ~DiagDirToRoadBits(GetRoadStopDir(tile))) goto do_clear;
 
			}
 
			if (HasTileRoadType(tile, rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
 
			break;
 

	
0 comments (0 inline, 0 general)