Loading

https://imgur.com/wQuDOi5

  1. static bool GrowingOnWateredTile(TileIndex tile)
  2. {
  3.     TrackBits water_track = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));
  4.     if (water_track != TRACK_BIT_NONE) {
  5.         if (water_track == TRACK_BIT_UPPER || water_track == TRACK_BIT_LOWER || water_track == TRACK_BIT_LEFT || water_track == TRACK_BIT_RIGHT) {
  6.             TileIndex opposite_tile = INVALID_TILE;
  7.             TrackBits opposite_track = TRACK_BIT_NONE;
  8.  
  9.             TileIndex next_tile_1 = INVALID_TILE;
  10.             TrackBits next_track_1 = TRACK_BIT_NONE;
  11.  
  12.             TileIndex next_tile_2 = INVALID_TILE;
  13.             TrackBits next_track_2 = TRACK_BIT_NONE;
  14.             if (water_track == TRACK_BIT_UPPER) {
  15.                 opposite_tile = TileAddWrap(tile, -1, -1);
  16.                 opposite_track = TRACK_BIT_LOWER;
  17.  
  18.                 next_tile_1 = TileAddWrap(tile, -1, 0);
  19.                 next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NW;
  20.  
  21.                 next_tile_2 = TileAddWrap(tile, 0, -1);
  22.                 next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NE;
  23.             } else if (water_track == TRACK_BIT_RIGHT) {
  24.                 opposite_tile = TileAddWrap(tile, -1, 1);
  25.                 opposite_track = TRACK_BIT_LEFT;
  26.  
  27.                 next_tile_1 = TileAddWrap(tile, 0, 1);
  28.                 next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_NE;
  29.  
  30.                 next_tile_2 = TileAddWrap(tile, -1, 0);
  31.                 next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_SE;
  32.             } else if (water_track == TRACK_BIT_LOWER) {
  33.                 opposite_tile = TileAddWrap(tile, 1, 1);
  34.                 opposite_track = TRACK_BIT_UPPER;
  35.  
  36.                 next_tile_1 = TileAddWrap(tile, 1, 0);
  37.                 next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SE;
  38.  
  39.                 next_tile_2 = TileAddWrap(tile, 0, 1);
  40.                 next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SW;
  41.             } else if (water_track == TRACK_BIT_LEFT) {
  42.                 opposite_tile = TileAddWrap(tile, 1, -1);
  43.                 opposite_track = TRACK_BIT_RIGHT;
  44.  
  45.                 next_tile_1 = TileAddWrap(tile, 0, -1);
  46.                 next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LEFT : TRACK_BIT_3WAY_SW;
  47.  
  48.                 next_tile_2 = TileAddWrap(tile, 1, 0);
  49.                 next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LEFT : TRACK_BIT_3WAY_NW;
  50.             }
  51.             if (IsValidTile(next_tile_1)) {
  52.                 next_track_1 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_1, TRANSPORT_WATER, 0));
  53.             }
  54.             if (IsValidTile(next_tile_2)) {
  55.                 next_track_2 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_2, TRANSPORT_WATER, 0));
  56.             }
  57.             if (next_track_1 != TRACK_BIT_NONE && next_track_2 != TRACK_BIT_NONE) {
  58.                 if (IsValidTile(opposite_tile)) {
  59.                     opposite_track &= TrackStatusToTrackBits(GetTileTrackStatus(opposite_track, TRANSPORT_WATER, 0));
  60.                 }
  61.             }
  62.             if (next_track_1 != TRACK_BIT_NONE) {
  63.                 if (next_track_2 == TRACK_BIT_NONE) {
  64.                     return false;
  65.                 } else {
  66.                     if (opposite_track == TRACK_BIT_NONE) {
  67.                         return true;
  68.                     } else {
  69.                         return false;
  70.                     }
  71.                 }
  72.             }
  73.             if (next_track_2 != TRACK_BIT_NONE) {
  74.                 if (next_track_1 == TRACK_BIT_NONE) {
  75.                     return false;
  76.                 } else {
  77.                     if (opposite_track == TRACK_BIT_NONE) {
  78.                         return true;
  79.                     } else {
  80.                         return false;
  81.                     }
  82.                 }
  83.             }
  84.             /* Should never reach here */
  85.             return false;
  86.         }
  87.         return false;
  88.     }
  89.     return false;
  90. }

Version history

Revision # Author Created at
pz1htdtur Anonymous 07 Jan 2019, 01:46:47 UTC Diff

Comments