Loading

Revision differences

Old revision #puyn9xqgwNew revision #ptftckcwn
  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};  
  7  
1static bool GrowingOnWateredTile(TileIndex tile)  8static bool GrowingOnWateredTile(TileIndex tile)  
2{  9{  
3    TrackBits water_track = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_WATER, 0));  3    Slope slope = GetTileSlope(tile);
4    if (water_track != TRACK_BIT_NONE) {  4    if (IsSlopeWithOneCornerRaised(slope)) {
5        if (water_track == TRACK_BIT_UPPER || water_track == TRACK_BIT_LOWER || water_track == TRACK_BIT_LEFT || water_track == TRACK_BIT_RIGHT) {  5        Corner corner = GetHighestSlopeCorner(slope);
6            TileIndex opposite_tile = INVALID_TILE;    
7            TrackBits opposite_track = TRACK_BIT_NONE;    
8  13  
9            TileIndex next_tile_1 = INVALID_TILE;  9        TileIndex opposite_tile = tile + table[corner].opposite_tile;
10            TrackBits next_track_1 = TRACK_BIT_NONE;  10        TrackBits opposite_track = table[corner].opposite_track;
11  16  
12            TileIndex next_tile_2 = INVALID_TILE;  12        TileIndex next_tile_1 = tile + table[corner].next_tile_1;
13            TrackBits next_track_2 = TRACK_BIT_NONE;  13        TrackBits next_track_1 = table[corner].next_track_1;
14            if (water_track == TRACK_BIT_UPPER) {    
15                opposite_tile = TileAddWrap(tile, -1, -1);    
16                opposite_track = TRACK_BIT_LOWER;    
17  19  
18                next_tile_1 = TileAddWrap(tile, -1, 0);  18        TileIndex next_tile_2 = tile + table[corner].next_tile_2;
19                next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_Y | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NW;  19        TrackBits next_track_2 = table[corner].next_track_2;
20  22  
21                next_tile_2 = TileAddWrap(tile, 0, -1);  21        if (IsValidTile(next_tile_1)) {
22                next_track_2 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_UPPER : TRACK_BIT_3WAY_NE;  22            next_track_1 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_1, TRANSPORT_WATER, 0));
23            } else if (water_track == TRACK_BIT_RIGHT) {  23        }
24                opposite_tile = TileAddWrap(tile, -1, 1);  24        if (IsValidTile(next_tile_2)) {
25                opposite_track = TRACK_BIT_LEFT;  25            next_track_2 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_2, TRANSPORT_WATER, 0));
26  26        }
27                next_tile_1 = TileAddWrap(tile, 0, 1);  27        if (next_track_1 != TRACK_BIT_NONE && next_track_2 != TRACK_BIT_NONE) {
28                next_track_1 = _settings_game.pf.forbid_90_deg ? TRACK_BIT_X | TRACK_BIT_RIGHT : TRACK_BIT_3WAY_NE;  28            if (IsValidTile(opposite_tile)) {
29  29                opposite_track &= TrackStatusToTrackBits(GetTileTrackStatus(opposite_track, TRANSPORT_WATER, 0));
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            }  32            }  
51            if (IsValidTile(next_tile_1)) {  51        }
52                next_track_1 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_1, TRANSPORT_WATER, 0));  52        if (next_track_1 != TRACK_BIT_NONE) {
53            }  53            if (next_track_2 == TRACK_BIT_NONE) {
54            if (IsValidTile(next_tile_2)) {  54                return false;
55                next_track_2 &= TrackStatusToTrackBits(GetTileTrackStatus(next_tile_2, TRANSPORT_WATER, 0));  55            } else {
56            }  56                if (opposite_track == TRACK_BIT_NONE) {
57            if (next_track_1 != TRACK_BIT_NONE && next_track_2 != TRACK_BIT_NONE) {  57                    return true;
58                if (IsValidTile(opposite_tile)) {  58                } else {
59                    opposite_track &= TrackStatusToTrackBits(GetTileTrackStatus(opposite_track, TRANSPORT_WATER, 0));  59                    return false;
60                }  42                }  
61            }  43            }  
62            if (next_track_1 != TRACK_BIT_NONE) {  44        }
63                if (next_track_2 == TRACK_BIT_NONE) {  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 {
64                    return false;  52                    return false;  
65                } else {    
66                    if (opposite_track == TRACK_BIT_NONE) {    
67                        return true;    
68                    } else {    
69                        return false;    
70                    }    
71                }  53                }  
72            }  54            }  
73            if (next_track_2 != TRACK_BIT_NONE) {  73        }
74                if (next_track_1 == TRACK_BIT_NONE) {  74        if (next_track_1 == TRACK_BIT_NONE && next_track_2 == 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;  57            return false;  
86        }  58        }  
87        /* Should never reach here either */  87        /* Should never reach here */
88        return false;  60        return false;  
89    }  61    }  
90    return false;  62    return false;