Advertisement
Guest User

Untitled

a guest
Dec 26th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1.     int max_height = H2I(TGPGetMaxHeight());
  2.  
  3.     /* Transfer height map into OTTD map */
  4.     int h0_tile_count = 0; // count tiles at sea level
  5.     for (int y = 0; y < _height_map.size_y; y++) {
  6.         for (int x = 0; x < _height_map.size_x; x++) {
  7.             int height = Clamp(H2I(_height_map.height(x, y)), 0, max_height);
  8.             if (height == 0) h0_tile_count++;
  9.             TgenSetTileHeight(TileXY(x, y), height);
  10.         }
  11.     }
  12.  
  13.     if (_settings_game.game_creation.landscape == LT_ARCTIC) {
  14.         int land_mass_size = _height_map.size_x * _height_map.size_y - h0_tile_count; // available tiles above sea
  15.         int tile_count = 0, cur_height = 1;
  16.         while (tile_count < land_mass_size * 2 / 3 && cur_height <= max_height) {
  17.             for (int y = 0; y < _height_map.size_y; y++) {
  18.                 for (int x = 0; x < _height_map.size_x; x++) {
  19.                     if (TileHeight(TileXY(x, y)) == cur_height) tile_count++;
  20.                 }
  21.             }
  22.             cur_height++;
  23.         }
  24.  
  25.         _settings_game.game_creation.snow_line_height = Clamp(cur_height, MIN_SNOWLINE_HEIGHT, MAX_SNOWLINE_HEIGHT);
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement