Loading

Revision differences

Old revision #pz1htdturNew revision #pomxkfugj
1https://imgur.com/wQuDOi5    
2    
3static bool GrowingOnWateredTile(TileIndex tile)  1static bool GrowingOnWateredTile(TileIndex tile)  
4{  2{  
5    TrackBits water_track = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));  3    TrackBits water_track = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));  
6    if (water_track != TRACK_BIT_NONE) {  4    if (water_track != TRACK_BIT_NONE) {  
7        if (water_track == TRACK_BIT_UPPER || water_track == TRACK_BIT_LOWER || water_track == TRACK_BIT_LEFT || water_track == TRACK_BIT_RIGHT) {  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;  
8            if (water_track == TRACK_BIT_UPPER) {  14            if (water_track == TRACK_BIT_UPPER) {  
9                TileIndex opposite_tile = TileAddWrap(tile, -1, -1);  9                opposite_tile = TileAddWrap(tile, -1, -1);
10                TrackBits opposite_track = TRACK_BIT_LOWER;  10                opposite_track = TRACK_BIT_LOWER;
11  17  
12                TileIndex next_tile_1 = TileAddWrap(tile, -1, 0);  12                next_tile_1 = TileAddWrap(tile, -1, 0);
13                TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NW;  13                next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NW;
14  20  
15                TileIndex next_tile_2 = TileAddWrap(tile, 0, -1);  21                next_tile_2 = TileAddWrap(tile, 0, -1);
16                TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NE;  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;
17            } else if (water_track == TRACK_BIT_LOWER) {  32            } else if (water_track == TRACK_BIT_LOWER) {  
18                TileIndex opposite_tile = TileAddWrap(tile, 1, 1);  18                opposite_tile = TileAddWrap(tile, 1, 1);
19                TrackBits opposite_track = TRACK_BIT_UPPER;  19                opposite_track = TRACK_BIT_UPPER;
20  35  
21                TileIndex next_tile_1 = TileAddWrap(tile, 1, 0);  21                next_tile_1 = TileAddWrap(tile, 1, 0);
22                TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SE;  22                next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SE;
23  38  
24                TileIndex next_tile_2 = TileAddWrap(tile, 0, 1);  24                next_tile_2 = TileAddWrap(tile, 0, 1);
25                TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SW;  25                next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SW;
26            } else if (water_track == TRACK_BIT_LEFT) {  41            } else if (water_track == TRACK_BIT_LEFT) {  
27                TileIndex opposite_tile = TileAddWrap(tile, 1, -1);  27                opposite_tile = TileAddWrap(tile, 1, -1);
28                TrackBits opposite_track = TRACK_BIT_RIGHT;  28                opposite_track = TRACK_BIT_RIGHT;
29  44  
30                TileIndex next_tile_1 = TileAddWrap(tile, 0, -1);  30                next_tile_1 = TileAddWrap(tile, 0, -1);
31                TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LEFT : TRACK_BIT_3WAY_SW;  31                next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LEFT : TRACK_BIT_3WAY_SW;
32  47  
33                TileIndex next_tile_2 = TileAddWrap(tile, 1, 0);  33                next_tile_2 = TileAddWrap(tile, 1, 0);
34                TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LEFT : TRACK_BIT_3WAY_NW;  34                next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LEFT : TRACK_BIT_3WAY_NW;
35            } else if (water_track == TRACK_BIT_RIGHT) {    
36                TileIndex opposite_tile = TileAddWrap(tile, -1, 1);    
37                TrackBits opposite_track = TRACK_BIT_LEFT;    
38    
39                TileIndex next_tile_1 = TileAddWrap(tile, 0, 1);    
40                TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_NE;    
41    
42                TileIndex next_tile_2 = TileAddWrap(tile, -1, 0);    
43                TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_SE;    
44            }  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            if (next_track_1 == TRACK_BIT_NONE && next_track_2 == TRACK_BIT_NONE) {  
  85                return false;  
  86            }  
  87            /* Should never reach here */  
45            return false;  88            return false;  
46        }  89        }  
  90        /* Should never reach here either */  
47        return false;  91        return false;  
48    }  92    }  
49    return false;  93    return false;