Loading

Revision differences

Old revision #pz1htdturNew revision #ptftckcwn
1https://imgur.com/wQuDOi5  1struct { 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};
2  7  
3static bool GrowingOnWateredTile(TileIndex tile)  8static bool GrowingOnWateredTile(TileIndex tile)  
4{  9{  
5    TrackBits water_track = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));  5    Slope slope = GetTileSlope(tile);
6    if (water_track != TRACK_BIT_NONE) {  6    if (IsSlopeWithOneCornerRaised(slope)) {
7        if (water_track == TRACK_BIT_UPPER || water_track == TRACK_BIT_LOWER || water_track == TRACK_BIT_LEFT || water_track == TRACK_BIT_RIGHT) {  7        Corner corner = GetHighestSlopeCorner(slope);
8            if (water_track == TRACK_BIT_UPPER) {    
9                TileIndex opposite_tile = TileAddWrap(tile, -1, -1);    
10                TrackBits opposite_track = TRACK_BIT_LOWER;    
11  13  
12                TileIndex next_tile_1 = TileAddWrap(tile, -1, 0);  12        TileIndex opposite_tile = tile + table[corner].opposite_tile;
13                TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NW;  13        TrackBits opposite_track = table[corner].opposite_track;
14  16  
15                TileIndex next_tile_2 = TileAddWrap(tile, 0, -1);  15        TileIndex next_tile_1 = tile + table[corner].next_tile_1;
16                TrackBits next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NE;  16        TrackBits next_track_1 = table[corner].next_track_1;
17            } else if (water_track == TRACK_BIT_LOWER) {    
18                TileIndex opposite_tile = TileAddWrap(tile, 1, 1);    
19                TrackBits opposite_track = TRACK_BIT_UPPER;    
20  19  
21                TileIndex next_tile_1 = TileAddWrap(tile, 1, 0);  21        TileIndex next_tile_2 = tile + table[corner].next_tile_2;
22                TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_LOWER : TRACK_BIT_3WAY_SE;  22        TrackBits next_track_2 = table[corner].next_track_2;
23  22  
24                TileIndex next_tile_2 = TileAddWrap(tile, 0, 1);  24        if (IsValidTile(next_tile_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_1 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_1, TRANSPORT_WATER, 0));
26            } else if (water_track == TRACK_BIT_LEFT) {  26        }
27                TileIndex opposite_tile = TileAddWrap(tile, 1, -1);  27        if (IsValidTile(next_tile_2)) {
28                TrackBits opposite_track = TRACK_BIT_RIGHT;  28            next_track_2 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_2, TRANSPORT_WATER, 0));
29  29        }
30                TileIndex next_tile_1 = TileAddWrap(tile, 0, -1);  30        if (next_track_1 != TRACK_BIT_NONE && next_track_2 != TRACK_BIT_NONE) {
31                TrackBits next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_LEFT : TRACK_BIT_3WAY_SW;  31            if (IsValidTile(opposite_tile)) {
32  32                opposite_track &= TrackStatusToTrackBits(GetTileTrackStatus(opposite_track, TRANSPORT_WATER, 0));
33                TileIndex 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;    
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            }  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) {  
45            return false;  57            return false;  
46        }  58        }  
  59        /* Should never reach here */  
47        return false;  60        return false;  
48    }  61    }  
49    return false;  62    return false;