src/town_cmd.cpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
--- a/src/town_cmd.cpp	Wed Jun 13 12:05:56 2007 +0000
+++ b/src/town_cmd.cpp	Tue Jun 19 07:21:01 2007 +0000
@@ -474,10 +474,10 @@
 	/* not used */
 }
 
-static int32 ClearTile_Town(TileIndex tile, byte flags)
+static CommandCost ClearTile_Town(TileIndex tile, byte flags)
 {
 	int rating;
-	int32 cost;
+	CommandCost cost;
 	Town *t;
 	HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
 
@@ -704,7 +704,7 @@
 			uint32 r = Random();
 
 			if (CHANCE16I(1, 8, r) && !_generating_world) {
-				int32 res;
+				CommandCost res;
 
 				if (CHANCE16I(1, 16, r)) {
 					res = DoCommand(tile, slope, 0, DC_EXEC | DC_AUTO | DC_NO_WATER,
@@ -726,7 +726,7 @@
 
 static bool TerraformTownTile(TileIndex tile, int edges, int dir)
 {
-	int32 r;
+	CommandCost r;
 
 	TILE_ASSERT(tile);
 
@@ -1059,7 +1059,7 @@
 
 		default:
 build_road_and_exit:
-			if (!CmdFailed(DoCommand(tile, rcmd, t1->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD))) {
+			if (CmdSucceeded(DoCommand(tile, rcmd, t1->index, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD))) {
 				_grow_town_result = -1;
 			}
 			return;
@@ -1092,7 +1092,7 @@
 		do {
 			byte bridge_type = RandomRange(MAX_BRIDGES - 1);
 			if (CheckBridge_Stuff(bridge_type, bridge_len)) {
-				if (!CmdFailed(DoCommand(tile, tmptile, bridge_type | ((0x80 | ROADTYPES_ROAD) << 8), DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
+				if (CmdSucceeded(DoCommand(tile, tmptile, bridge_type | ((0x80 | ROADTYPES_ROAD) << 8), DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
 					_grow_town_result = -1;
 
 				/* obviously, if building any bridge would fail, there is no need to try other bridge-types */
@@ -1231,7 +1231,7 @@
 	for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
 		/* Only work with plain land that not already has a house */
 		if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) {
-			if (!CmdFailed(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
+			if (CmdSucceeded(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
 				DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
 				_current_player = old_player;
 				return true;
@@ -1476,7 +1476,7 @@
  * @param p1 size of the town (0 = small, 1 = medium, 2 = large)
  * @param p2 size mode (@see TownSizeMode)
  */
-int32 CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	Town *t;
 	uint32 townnameparts;
@@ -1600,7 +1600,7 @@
 	if (b)
 		return false;
 
-	return !CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
+	return CmdSucceeded(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR));
 }
 
 
@@ -1665,7 +1665,7 @@
 		for (i = 0; i < HOUSE_MAX; i++) {
 			hs = GetHouseSpecs(i);
 			if ((~hs->building_availability & bitmask) == 0 && hs->enabled) {
-				if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) {
+				if (_loaded_newgrf_features.has_newhouses) {
 					probability_max += hs->probability;
 					cumulative_probs[num] = probability_max;
 				}
@@ -1674,7 +1674,7 @@
 		}
 
 		for (;;) {
-			if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) {
+			if (_loaded_newgrf_features.has_newhouses) {
 				uint r = RandomRange(probability_max);
 				for (i = 0; i < num; i++) if (cumulative_probs[i] >= r) break;
 
@@ -1685,7 +1685,7 @@
 
 			hs = GetHouseSpecs(house);
 
-			if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) {
+			if (_loaded_newgrf_features.has_newhouses) {
 				if (hs->override != 0) hs = GetHouseSpecs(hs->override);
 
 				if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue;
@@ -1767,7 +1767,7 @@
 
 static bool BuildTownHouse(Town *t, TileIndex tile)
 {
-	int32 r;
+	CommandCost r;
 
 	if (IsSteepSlope(GetTileSlope(tile, NULL))) return false;
 	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
@@ -1843,7 +1843,7 @@
  * @param p1 town ID to rename
  * @param p2 unused
  */
-int32 CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdRenameTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
 	StringID str;
 	Town *t;
@@ -1929,7 +1929,7 @@
 static bool DoBuildStatueOfCompany(TileIndex tile, TownID town_id)
 {
 	PlayerID old;
-	int32 r;
+	CommandCost r;
 
 	if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return false;
 
@@ -2047,9 +2047,9 @@
  * @param p1 town to do the action at
  * @param p2 action to perform, @see _town_action_proc for the list of available actions
  */
-int32 CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
+CommandCost CmdDoTownAction(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 {
-	int32 cost;
+	CommandCost cost;
 	Town *t;
 
 	if (!IsValidTownID(p1) || p2 > lengthof(_town_action_proc)) return CMD_ERROR;