unmovable_cmd.c
changeset 2951 2de6d3a59743
parent 2893 8861b61a7d2b
child 3017 a75caf4efa2d
equal deleted inserted replaced
2950:30eee9c93028 2951:2de6d3a59743
   334 	TileIndex tile;
   334 	TileIndex tile;
   335 	uint32 r;
   335 	uint32 r;
   336 	int dir;
   336 	int dir;
   337 	uint h;
   337 	uint h;
   338 
   338 
   339 	if (_opt.landscape == LT_CANDY)
   339 	if (_opt.landscape == LT_CANDY) return;
   340 		return;
       
   341 
   340 
   342 	/* add radio tower */
   341 	/* add radio tower */
   343 	i = ScaleByMapSize(1000);
   342 	i = ScaleByMapSize(1000);
   344 	j = ScaleByMapSize(40); // maximum number of radio towers on the map
   343 	j = ScaleByMapSize(40); // maximum number of radio towers on the map
   345 	do {
   344 	do {
   346 		tile = RandomTile();
   345 		tile = RandomTile();
   347 		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) {
   346 		if (IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h >= 32) {
   348 			if(!checkRadioTowerNearby(tile))
   347 			if (!checkRadioTowerNearby(tile)) continue;
   349 				continue;
       
   350 			SetTileType(tile, MP_UNMOVABLE);
   348 			SetTileType(tile, MP_UNMOVABLE);
   351 			_m[tile].m5 = 0;
   349 			_m[tile].m5 = 0;
   352 			SetTileOwner(tile, OWNER_NONE);
   350 			SetTileOwner(tile, OWNER_NONE);
   353 			if (--j == 0)
   351 			if (--j == 0) break;
   354 				break;
       
   355 		}
   352 		}
   356 	} while (--i);
   353 	} while (--i);
   357 
   354 
   358 	if (_opt.landscape == LT_DESERT)
   355 	if (_opt.landscape == LT_DESERT) return;
   359 		return;
       
   360 
   356 
   361 	/* add lighthouses */
   357 	/* add lighthouses */
   362 	i = ScaleByMapSize1D((Random() & 3) + 7);
   358 	i = ScaleByMapSize1D((Random() & 3) + 7);
   363 	do {
   359 	do {
   364 restart:
   360 restart:
   370 			(dir == 1) ? TileXY(r, 0)         : 0 + // top
   366 			(dir == 1) ? TileXY(r, 0)         : 0 + // top
   371 			(dir == 2) ? TileXY(MapMaxX(), r) : 0 + // right
   367 			(dir == 2) ? TileXY(MapMaxX(), r) : 0 + // right
   372 			(dir == 3) ? TileXY(r, MapMaxY()) : 0;  // bottom
   368 			(dir == 3) ? TileXY(r, MapMaxY()) : 0;  // bottom
   373 		j = 20;
   369 		j = 20;
   374 		do {
   370 		do {
   375 			if (--j == 0)
   371 			if (--j == 0) goto restart;
   376 				goto restart;
       
   377 			tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
   372 			tile = TILE_MASK(tile + ToTileIndexDiff(_tile_add[dir]));
   378 		} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
   373 		} while (!(IsTileType(tile, MP_CLEAR) && GetTileSlope(tile, &h) == 0 && h <= 16));
   379 
   374 
   380 		assert(tile == TILE_MASK(tile));
   375 		assert(tile == TILE_MASK(tile));
   381 
   376