Loading

Paste #pqo1srqxj

  1. static TreeType GetRandomTreeType(TileIndex tile, uint seed)
  2. {
  3.     uint8 th = TileHeight(tile);
  4.     uint limited_seed = seed / 16;
  5.     uint8 no_trees_height = _settings_game.game_creation.no_trees_height - limited_seed;
  6.     uint8 evergreen_min_height = _settings_game.game_creation.evergreen_min_height - limited_seed;
  7.  
  8.     switch (_settings_game.game_creation.landscape) {
  9.         case LT_ARCTIC:
  10.             /* In arctic clamp the heights to snow line */
  11.             no_trees_height = max(GetSnowLine(), no_trees_height);
  12.             evergreen_min_height = min(GetSnowLine(), evergreen_min_height);
  13.  
  14.             /* Fall through */
  15.  
  16.         case LT_TEMPERATE:
  17.             if (th > no_trees_height) {
  18.                 return TREE_INVALID;
  19.             }
  20.  
  21.             if (th < evergreen_min_height) {
  22.                 return (TreeType)(seed * TREE_COUNT_TEMPERATE / 256 + TREE_TEMPERATE);
  23.             }
  24.  
  25.             return (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC);
  26.  
  27.         case LT_TROPIC:
  28.             switch (GetTropicZone(tile)) {
  29.                 case TROPICZONE_NORMAL:  return (TreeType)(seed * TREE_COUNT_SUB_TROPICAL / 256 + TREE_SUB_TROPICAL);
  30.                 case TROPICZONE_DESERT:  return (TreeType)((seed > 12) ? TREE_INVALID : TREE_CACTUS);
  31.                 default:                 return (TreeType)(seed * TREE_COUNT_RAINFOREST / 256 + TREE_RAINFOREST);
  32.             }
  33.  
  34.         default:
  35.             return (TreeType)(seed * TREE_COUNT_TOYLAND / 256 + TREE_TOYLAND);
  36.     }
  37. }

Comments