src/station_cmd.cpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
--- a/src/station_cmd.cpp	Wed Jun 13 12:05:56 2007 +0000
+++ b/src/station_cmd.cpp	Tue Jun 19 07:21:01 2007 +0000
@@ -612,13 +612,13 @@
 	UpdateStationSignCoord(st);
 }
 
-static int32 ClearTile_Station(TileIndex tile, byte flags);
+static CommandCost ClearTile_Station(TileIndex tile, byte flags);
 
 // Tries to clear the given area. Returns the cost in case of success.
 // Or an error code if it failed.
-int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true)
+CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true)
 {
-	int32 cost = 0;
+	CommandCost cost = 0;
 	int allowed_z = -1;
 
 	BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
@@ -626,7 +626,7 @@
 			return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
 		}
 
-		if (!EnsureNoVehicle(tile_cur)) return CMD_ERROR;
+		if (!EnsureNoVehicleOnGround(tile_cur)) return CMD_ERROR;
 
 		uint z;
 		Slope tileh = GetTileSlope(tile_cur, &z);
@@ -680,7 +680,7 @@
 				}
 			}
 		} else if (check_clear) {
-			int32 ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+			CommandCost ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 			if (CmdFailed(ret)) return ret;
 			cost += ret;
 		}
@@ -801,10 +801,10 @@
  * - p2 = (bit  8-15) - custom station class
  * - p2 = (bit 16-23) - custom station id
  */
-int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2)
 {
 	int w_org, h_org;
-	int32 ret;
+	CommandCost ret;
 
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
@@ -838,7 +838,7 @@
 	//  for detail info, see: https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365
 	ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
 	if (CmdFailed(ret)) return ret;
-	int32 cost = ret + (numtracks * _eco->GetPrice(CEconomy::TRAIN_STATION_TRACK) + _eco->GetPrice(CEconomy::TRAIN_STATION_LENGTH)) * plat_len;
+	CommandCost cost = ret + (numtracks * _eco->GetPrice(CEconomy::TRAIN_STATION_TRACK) + _eco->GetPrice(CEconomy::TRAIN_STATION_LENGTH)) * plat_len;
 
 	Station *st = NULL;
 	bool check_surrounding = true;
@@ -1054,7 +1054,7 @@
  * @param p1 start_tile
  * @param p2 unused
  */
-int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	TileIndex start = p1 == 0 ? tile : p1;
 
@@ -1125,7 +1125,7 @@
 }
 
 
-static int32 RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
+static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
 {
 	/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
 	if (_current_player == OWNER_WATER && _patches.nonuniform_stations)
@@ -1142,7 +1142,7 @@
 
 	assert(w != 0 && h != 0);
 
-	int32 cost = 0;
+	CommandCost cost = 0;
 	/* clear all areas of the station */
 	do {
 		int w_bak = w;
@@ -1191,7 +1191,7 @@
  * @return            The cost and state of the operation
  * @retval CMD_ERROR  An error occured during the operation.
  */
-int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
+CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
 {
 	const Station* st = GetStationByTile(tile);
 
@@ -1243,7 +1243,7 @@
  *           bit 2..4: the roadtypes
  *           bit 5: allow stations directly adjacent to other stations.
  */
-int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	bool type = HASBIT(p2, 0);
 	bool is_drive_through = HASBIT(p2, 1);
@@ -1267,7 +1267,7 @@
 
 	if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
 
-	int32 cost = 0;
+	CommandCost cost = 0;
 
 	/* Not allowed to build over this road */
 	if (build_over_road) {
@@ -1371,7 +1371,7 @@
 }
 
 // Remove a bus station
-static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
+static CommandCost RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
 {
 	if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) {
 		return CMD_ERROR;
@@ -1425,7 +1425,7 @@
  * @param p1 not used
  * @param p2 bit 0: 0 for Bus stops, 1 for truck stops
  */
-int32 CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	/* Make sure the specified tile is a road stop of the correct type */
 	if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile) || (uint32)GetRoadStopType(tile) != p2) return CMD_ERROR;
@@ -1438,10 +1438,10 @@
 			DiagDirToRoadBits(GetRoadStopDir(tile));
 	bool is_towns_road = is_drive_through && GetStopBuiltOnTownRoad(tile);
 
-	int32 ret = RemoveRoadStop(st, flags, tile);
+	CommandCost ret = RemoveRoadStop(st, flags, tile);
 
 	/* If the stop was a drive-through stop replace the road */
-	if ((flags & DC_EXEC) && !CmdFailed(ret) && is_drive_through) {
+	if ((flags & DC_EXEC) && CmdSucceeded(ret) && is_drive_through) {
 		/* Rebuild the drive throuhg road stop. As a road stop can only be
 		 * removed by the owner of the roadstop, _current_player is the
 		 * owner of the road stop. */
@@ -1550,7 +1550,7 @@
  * @param p1 airport type, @see airport.h
  * @param p2 (bit 0) - allow airports directly adjacent to other airports.
  */
-int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	bool airport_upgrade = true;
 
@@ -1582,9 +1582,9 @@
 	int w = afc->size_x;
 	int h = afc->size_y;
 
-	int32 ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
+	CommandCost ret = CheckFlatLandBelow(tile, w, h, flags, 0, NULL);
 	if (CmdFailed(ret)) return ret;
-	int32 cost = ret;
+	CommandCost cost = ret;
 
 	Station *st = NULL;
 
@@ -1676,7 +1676,7 @@
 	return cost;
 }
 
-static int32 RemoveAirport(Station *st, uint32 flags)
+static CommandCost RemoveAirport(Station *st, uint32 flags)
 {
 	if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
 		return CMD_ERROR;
@@ -1687,7 +1687,7 @@
 	int w = afc->size_x;
 	int h = afc->size_y;
 
-	int32 cost = w * h * _eco->GetPrice(CEconomy::REMOVE_AIRPORT);
+	CommandCost cost = w * h * _eco->GetPrice(CEconomy::REMOVE_AIRPORT);
 
 	Vehicle *v;
 	FOR_ALL_VEHICLES(v) {
@@ -1730,7 +1730,7 @@
  * @param p1 unused
  * @param p2 unused
  */
-int32 CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
@@ -1789,7 +1789,7 @@
 	return false;
 }
 
-static int32 RemoveBuoy(Station *st, uint32 flags)
+static CommandCost RemoveBuoy(Station *st, uint32 flags)
 {
 	/* XXX: strange stuff */
 	if (!IsValidPlayer(_current_player))  return_cmd_error(INVALID_STRING_ID);
@@ -1839,9 +1839,9 @@
  * @param p1 (bit 0) - allow docks directly adjacent to other docks.
  * @param p2 unused
  */
-int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	int32 cost;
+	CommandCost cost;
 
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 
@@ -1938,7 +1938,7 @@
 	return _eco->GetPrice(CEconomy::BUILD_DOCK);
 }
 
-static int32 RemoveDock(Station *st, uint32 flags)
+static CommandCost RemoveDock(Station *st, uint32 flags)
 {
 	if (!CheckOwnership(st->owner)) return CMD_ERROR;
 
@@ -2494,7 +2494,7 @@
  * @param p1 station ID that is to be renamed
  * @param p2 unused
  */
-int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	if (!IsValidStationID(p1) || _cmd_text[0] == '\0') return CMD_ERROR;
 	Station *st = GetStation(p1);
@@ -2748,7 +2748,7 @@
 				CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_TRAM), OWNER_TOWN, &edge_road, ROADTYPE_TRAM);
 }
 
-static int32 ClearTile_Station(TileIndex tile, byte flags)
+static CommandCost ClearTile_Station(TileIndex tile, byte flags)
 {
 	if (flags & DC_AUTO) {
 		switch (GetStationType(tile)) {