* LEFT and RIGHT pointer rules * * * **NOTE** The rules changed on 4/4/90. This comment reflects the * new rules. The change was so that the stone-wall optimization * would work. * * OK, now the tough stuff. We must maintain our left and right * row pointers. The rules are as follows: * * Left Pointers: * ______________ * * + If you are a clear spot, your left will p
| 964 | * spot on its right) will point to itself. |
| 965 | */ |
| 966 | staticfn void |
| 967 | dig_point(int row, int col) |
| 968 | { |
| 969 | int i; |
| 970 | |
| 971 | if (viz_clear[row][col]) |
| 972 | return; /* already done */ |
| 973 | |
| 974 | viz_clear[row][col] = 1; |
| 975 | |
| 976 | /* |
| 977 | * Boundary cases first. |
| 978 | */ |
| 979 | if (col == 0) { /* left edge */ |
| 980 | if (viz_clear[row][1]) { |
| 981 | right_ptrs[row][0] = right_ptrs[row][1]; |
| 982 | } else { |
| 983 | right_ptrs[row][0] = 1; |
| 984 | for (i = 1; i <= right_ptrs[row][1]; i++) |
| 985 | left_ptrs[row][i] = 1; |
| 986 | } |
| 987 | } else if (col == (COLNO - 1)) { /* right edge */ |
| 988 | |
| 989 | if (viz_clear[row][COLNO - 2]) { |
| 990 | left_ptrs[row][COLNO - 1] = left_ptrs[row][COLNO - 2]; |
| 991 | } else { |
| 992 | left_ptrs[row][COLNO - 1] = COLNO - 2; |
| 993 | for (i = left_ptrs[row][COLNO - 2]; i < COLNO - 1; i++) |
| 994 | right_ptrs[row][i] = COLNO - 2; |
| 995 | } |
| 996 | |
| 997 | /* |
| 998 | * At this point, we know we aren't on the boundaries. |
| 999 | */ |
| 1000 | } else if (viz_clear[row][col - 1] && viz_clear[row][col + 1]) { |
| 1001 | /* Both sides clear */ |
| 1002 | for (i = left_ptrs[row][col - 1]; i <= col; i++) { |
| 1003 | if (!viz_clear[row][i]) |
| 1004 | continue; /* catch non-end case */ |
| 1005 | right_ptrs[row][i] = right_ptrs[row][col + 1]; |
| 1006 | } |
| 1007 | for (i = col; i <= right_ptrs[row][col + 1]; i++) { |
| 1008 | if (!viz_clear[row][i]) |
| 1009 | continue; /* catch non-end case */ |
| 1010 | left_ptrs[row][i] = left_ptrs[row][col - 1]; |
| 1011 | } |
| 1012 | |
| 1013 | } else if (viz_clear[row][col - 1]) { |
| 1014 | /* Left side clear, right side blocked. */ |
| 1015 | for (i = col + 1; i <= right_ptrs[row][col + 1]; i++) |
| 1016 | left_ptrs[row][i] = col + 1; |
| 1017 | |
| 1018 | for (i = left_ptrs[row][col - 1]; i <= col; i++) { |
| 1019 | if (!viz_clear[row][i]) |
| 1020 | continue; /* catch non-end case */ |
| 1021 | right_ptrs[row][i] = col + 1; |
| 1022 | } |
| 1023 | left_ptrs[row][col] = left_ptrs[row][col - 1]; |