unmovable_cmd.c
changeset 1035 812f837ee03f
parent 926 a6d140a6a4de
child 1059 fe97d81a1b4f
equal deleted inserted replaced
1034:e761d474e204 1035:812f837ee03f
   238 
   238 
   239 	tile_s = TILE_XY(TileX(tile) - 4, TileY(tile) - 4);
   239 	tile_s = TILE_XY(TileX(tile) - 4, TileY(tile) - 4);
   240 
   240 
   241 	BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
   241 	BEGIN_TILE_LOOP(tile, 9, 9, tile_s)
   242 		// already a radio tower here?
   242 		// already a radio tower here?
   243 		if (IS_TILETYPE(tile, MP_UNMOVABLE) && _map5[tile] == 0)
   243 		if (IsTileType(tile, MP_UNMOVABLE) && _map5[tile] == 0)
   244 			return false;
   244 			return false;
   245 	END_TILE_LOOP(tile, 9, 9, tile_s)
   245 	END_TILE_LOOP(tile, 9, 9, tile_s)
   246 	return true;
   246 	return true;
   247 }
   247 }
   248 
   248 
   263 	do {
   263 	do {
   264 		r = Random();
   264 		r = Random();
   265 		tile = r % MapSize();
   265 		tile = r % MapSize();
   266 //		TILE_MASK seems to be not working correctly. Radio masts accumulate in one area.
   266 //		TILE_MASK seems to be not working correctly. Radio masts accumulate in one area.
   267 //		tile = TILE_MASK(r);
   267 //		tile = TILE_MASK(r);
   268 		if (IS_TILETYPE(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) {
   268 		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) {
   269 			if(!checkRadioTowerNearby(tile))
   269 			if(!checkRadioTowerNearby(tile))
   270 				continue;
   270 				continue;
   271 			_map_type_and_height[tile] |= MP_UNMOVABLE << 4;
   271 			_map_type_and_height[tile] |= MP_UNMOVABLE << 4;
   272 			_map5[tile] = 0;
   272 			_map5[tile] = 0;
   273 			_map_owner[tile] = OWNER_NONE;
   273 			_map_owner[tile] = OWNER_NONE;
   294 		j = 20;
   294 		j = 20;
   295 		do {
   295 		do {
   296 			if (--j == 0)
   296 			if (--j == 0)
   297 				goto restart;
   297 				goto restart;
   298 			tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
   298 			tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
   299 		} while (!(IS_TILETYPE(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
   299 		} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
   300 
   300 
   301 		assert(tile == TILE_MASK(tile));
   301 		assert(tile == TILE_MASK(tile));
   302 
   302 
   303 		_map_type_and_height[tile] |= MP_UNMOVABLE << 4;
   303 		_map_type_and_height[tile] |= MP_UNMOVABLE << 4;
   304 		_map5[tile] = 1;
   304 		_map5[tile] = 1;