tunnelbridge_cmd.c
changeset 3493 4d5830846ec2
parent 3491 4c8427796c64
child 3517 76814013e912
equal deleted inserted replaced
3492:5670ff6c83e9 3493:4d5830846ec2
   214 		if (!ValParamRailtype(GB(p2, 8, 8))) return CMD_ERROR;
   214 		if (!ValParamRailtype(GB(p2, 8, 8))) return CMD_ERROR;
   215 		railtype = GB(p2, 8, 8);
   215 		railtype = GB(p2, 8, 8);
   216 		transport = TRANSPORT_RAIL;
   216 		transport = TRANSPORT_RAIL;
   217 	}
   217 	}
   218 
   218 
   219 	x = TileX(end_tile) * TILE_SIZE;
   219 	x = TileX(end_tile);
   220 	y = TileY(end_tile) * TILE_SIZE;
   220 	y = TileY(end_tile);
   221 	sx = TileX(p1) * TILE_SIZE;
   221 	sx = TileX(p1);
   222 	sy = TileY(p1) * TILE_SIZE;
   222 	sy = TileY(p1);
   223 
   223 
   224 	/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */
   224 	/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */
   225 	if (x == sx) {
   225 	if (x == sx) {
   226 		if (y == sy) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON);
   226 		if (y == sy) return_cmd_error(STR_5008_CANNOT_START_AND_END_ON);
   227 		direction = AXIS_Y;
   227 		direction = AXIS_Y;
   238 	} else {
   238 	} else {
   239 		return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN);
   239 		return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN);
   240 	}
   240 	}
   241 
   241 
   242 	/* set and test bridge length, availability */
   242 	/* set and test bridge length, availability */
   243 	bridge_len = ((sx + sy - x - y) / TILE_SIZE) - 1;
   243 	bridge_len = (sx + sy - x - y) - 1;
   244 	if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
   244 	if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
   245 
   245 
   246 	/* retrieve landscape height and ensure it's on land */
   246 	/* retrieve landscape height and ensure it's on land */
   247 	tile_start = TileVirtXY(x, y);
   247 	tile_start = TileXY(x, y);
   248 	tile_end = TileVirtXY(sx, sy);
   248 	tile_end = TileXY(sx, sy);
   249 	if ((IsTileType(tile_start, MP_WATER) && _m[tile_start].m5 == 0) ||
   249 	if ((IsTileType(tile_start, MP_WATER) && _m[tile_start].m5 == 0) ||
   250 			(IsTileType(tile_end, MP_WATER) && _m[tile_end].m5 == 0)) {
   250 			(IsTileType(tile_end, MP_WATER) && _m[tile_end].m5 == 0)) {
   251 		return_cmd_error(STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH);
   251 		return_cmd_error(STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH);
   252 	}
   252 	}
   253 
   253