Loading

https://imgur.com/wQuDOi5

  1. struct { TileIndexDiff opposite_tile, next_tile_1, next_tile_2; TrackBits opposite_track, next_track_1, next_track_2; } table[] = {
  2.     { TileDiffXY(-1,  1), TileDiffXY( 0,  1), TileDiffXY(-1,  0), TRACK_BIT_LEFT,  _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_NE, _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_SE },
  3.     { TileDiffXY(-1, -1), TileDiffXY(-1,  0), TileDiffXY( 0, -1), TRACK_BIT_LOWER, _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NW, _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NE },
  4.     { TileDiffXY( 1, -1), TileDiffXY( 0, -1), TileDiffXY( 1,  0), TRACK_BIT_RIGHT, _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LEFT  : TRACK_BIT_3WAY_SW, _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LEFT  : TRACK_BIT_3WAY_NW },
  5.     { TileDiffXY( 1,  1), TileDiffXY( 1,  0), TileDiffXY( 0,  1), TRACK_BIT_UPPER, _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SE, _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SW },
  6. };
  7.  
  8. static bool GrowingOnWateredTile(TileIndex tile)
  9. {
  10.     Slope slope = GetTileSlope(tile);
  11.     if (IsSlopeWithOneCornerRaised(slope)) {
  12.         Corner corner = GetHighestSlopeCorner(slope);
  13.  
  14.         TileIndex opposite_tile = tile + table[corner].opposite_tile;
  15.         TrackBits opposite_track = table[corner].opposite_track;
  16.  
  17.         TileIndex next_tile_1 = tile + table[corner].next_tile_1;
  18.         TrackBits next_track_1 = table[corner].next_track_1;
  19.  
  20.         TileIndex next_tile_2 = tile + table[corner].next_tile_2;
  21.         TrackBits next_track_2 = table[corner].next_track_2;
  22.  
  23.         if (IsValidTile(next_tile_1)) {
  24.             next_track_1 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_1, TRANSPORT_WATER, 0));
  25.         }
  26.         if (IsValidTile(next_tile_2)) {
  27.             next_track_2 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_2, TRANSPORT_WATER, 0));
  28.         }
  29.         if (next_track_1 != TRACK_BIT_NONE && next_track_2 != TRACK_BIT_NONE) {
  30.             if (IsValidTile(opposite_tile)) {
  31.                 opposite_track &= TrackStatusToTrackBits(GetTileTrackStatus(opposite_track, TRANSPORT_WATER, 0));
  32.             }
  33.         }
  34.         if (next_track_1 != TRACK_BIT_NONE) {
  35.             if (next_track_2 == TRACK_BIT_NONE) {
  36.                 return false;
  37.             } else {
  38.                 if (opposite_track == TRACK_BIT_NONE) {
  39.                     return true;
  40.                 } else {
  41.                     return false;
  42.                 }
  43.             }
  44.         }
  45.         if (next_track_2 != TRACK_BIT_NONE) {
  46.             if (next_track_1 == TRACK_BIT_NONE) {
  47.                 return false;
  48.             } else {
  49.                 if (opposite_track == TRACK_BIT_NONE) {
  50.                     return true;
  51.                 } else {
  52.                     return false;
  53.                 }
  54.             }
  55.         }
  56.         if (next_track_1 == TRACK_BIT_NONE && next_track_2 == TRACK_BIT_NONE) {
  57.             return false;
  58.         }
  59.         /* Should never reach here */
  60.         return false;
  61.     }
  62.     return false;
  63. }

Version history

Revision # Author Created at
pomxkfugj Anonymous 07 Jan 2019, 15:51:58 UTC Diff
puyn9xqgw Anonymous 07 Jan 2019, 15:46:13 UTC Diff
po0nm4jjw Anonymous 07 Jan 2019, 15:45:11 UTC Diff
pz1htdtur Anonymous 07 Jan 2019, 01:46:47 UTC Diff

Comments