town_cmd.c
changeset 3933 231ae3c419f4
parent 3877 0a298def0202
child 3977 513433ebd092
equal deleted inserted replaced
3932:dfe10fa5ce4f 3933:231ae3c419f4
    24 #include "gui.h"
    24 #include "gui.h"
    25 #include "unmovable_map.h"
    25 #include "unmovable_map.h"
    26 #include "water_map.h"
    26 #include "water_map.h"
    27 #include "variables.h"
    27 #include "variables.h"
    28 #include "bridge.h"
    28 #include "bridge.h"
       
    29 #include "bridge_map.h"
    29 #include "table/town_land.h"
    30 #include "table/town_land.h"
    30 
    31 
    31 enum {
    32 enum {
    32 	/* Max towns: 64000 (8 * 8000) */
    33 	/* Max towns: 64000 (8 * 8000) */
    33 	TOWN_POOL_BLOCK_SIZE_BITS = 3,       /* In bits, so (1 << 3) == 8 */
    34 	TOWN_POOL_BLOCK_SIZE_BITS = 3,       /* In bits, so (1 << 3) == 8 */
  1091 	};
  1092 	};
  1092 
  1093 
  1093 	slope = GetTileSlope(tile, NULL);
  1094 	slope = GetTileSlope(tile, NULL);
  1094 	if (IsSteepSlope(slope)) return false;
  1095 	if (IsSteepSlope(slope)) return false;
  1095 
  1096 
       
  1097 	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
       
  1098 
  1096 	b = 0;
  1099 	b = 0;
  1097 	if ((slope != SLOPE_FLAT && ~slope & _masks[mode])) b = ~b;
  1100 	if ((slope != SLOPE_FLAT && ~slope & _masks[mode])) b = ~b;
  1098 	if ((tileh != SLOPE_FLAT && ~tileh & _masks[mode+4])) b = ~b;
  1101 	if ((tileh != SLOPE_FLAT && ~tileh & _masks[mode+4])) b = ~b;
  1099 	if (b)
  1102 	if (b)
  1100 		return false;
  1103 		return false;
  1133 
  1136 
  1134 	for (i = 0; i != 4; i++) {
  1137 	for (i = 0; i != 4; i++) {
  1135 		tile += ToTileIndexDiff(_tile_add[i]);
  1138 		tile += ToTileIndexDiff(_tile_add[i]);
  1136 
  1139 
  1137 		if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return false;
  1140 		if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return false;
       
  1141 
       
  1142 		if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
  1138 
  1143 
  1139 		if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR)))
  1144 		if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER | DC_FORCETEST, CMD_LANDSCAPE_CLEAR)))
  1140 			return false;
  1145 			return false;
  1141 	}
  1146 	}
  1142 
  1147 
  1268 	int32 r;
  1273 	int32 r;
  1269 
  1274 
  1270 	// make sure it's possible
  1275 	// make sure it's possible
  1271 	if (!EnsureNoVehicle(tile)) return false;
  1276 	if (!EnsureNoVehicle(tile)) return false;
  1272 	if (IsSteepSlope(GetTileSlope(tile, NULL))) return false;
  1277 	if (IsSteepSlope(GetTileSlope(tile, NULL))) return false;
       
  1278 	if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return false;
  1273 
  1279 
  1274 	r = DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR);
  1280 	r = DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR);
  1275 	if (CmdFailed(r)) return false;
  1281 	if (CmdFailed(r)) return false;
  1276 
  1282 
  1277 	DoBuildTownHouse(t, tile);
  1283 	DoBuildTownHouse(t, tile);