Guest User

Untitled

a guest
Jan 18th, 2021
64
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <queue>
  2. static void CreateDesertOrRainForest()
  3. {
  4.     TileIndex update_freq = MapSize() / 8;
  5.     uint max_desert_height = CeilDiv(_settings_game.construction.max_heightlevel, 4);
  6.     std::queue<std::pair<TileIndex, TileIndex>> queue;
  7.  
  8.     for (TileIndex tile = 0; tile != MapSize(); ++tile) {
  9.         if ((tile % update_freq) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
  10.  
  11.         if (!IsValidTile(tile)) continue;
  12.  
  13.         if ((TileHeight(tile) >= max_desert_height || IsTileType(tile, MP_WATER))) {
  14.             SetTropicZone(tile, TROPICZONE_RAINFOREST);
  15.             queue.push(std::make_pair(tile, tile));
  16.         } else {
  17.             SetTropicZone(tile, TROPICZONE_DESERT);
  18.         }
  19.     }
  20.  
  21.     static const TileIndexDiffC NEIGHBORS[] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
  22.     while (!queue.empty()) {
  23.         auto p = queue.front();
  24.         queue.pop();
  25.         for (auto &d : NEIGHBORS) {
  26.             auto t = AddTileIndexDiffCWrap(p.second, d);
  27.             if (t == INVALID_TILE) continue;
  28.             if (GetTropicZone(t) != TROPICZONE_DESERT) continue;
  29.  
  30.             auto dist = DistanceSquare(t, p.first);
  31.             if (dist < 49) {
  32.                 queue.push(std::make_pair(p.first, t));
  33.                 SetTropicZone(t, dist < 4 ? TROPICZONE_RAINFOREST : TROPICZONE_NORMAL);
  34.             }
  35.         }
  36.     }
  37.  
  38.     for (uint i = 0; i != 256; i++) {
  39.         if ((i % 64) == 0) IncreaseGeneratingWorldProgress(GWP_LANDSCAPE);
  40.  
  41.         RunTileLoop();
  42.     }
  43. }
  44.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×