MCPcopy Create free account
hub / github.com/NetHack/NetHack / fill_point

Function fill_point

src/vision.c:1050–1128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1048}
1049
1050staticfn void
1051fill_point(int row, int col)
1052{
1053 int i;
1054
1055 if (!viz_clear[row][col])
1056 return;
1057
1058 viz_clear[row][col] = 0;
1059
1060 if (col == 0) {
1061 if (viz_clear[row][1]) { /* adjacent is clear */
1062 right_ptrs[row][0] = 0;
1063 } else {
1064 right_ptrs[row][0] = right_ptrs[row][1];
1065 for (i = 1; i <= right_ptrs[row][1]; i++)
1066 left_ptrs[row][i] = 0;
1067 }
1068 } else if (col == COLNO - 1) {
1069 if (viz_clear[row][COLNO - 2]) { /* adjacent is clear */
1070 left_ptrs[row][COLNO - 1] = COLNO - 1;
1071 } else {
1072 left_ptrs[row][COLNO - 1] = left_ptrs[row][COLNO - 2];
1073 for (i = left_ptrs[row][COLNO - 2]; i < COLNO - 1; i++)
1074 right_ptrs[row][i] = COLNO - 1;
1075 }
1076
1077 /*
1078 * Else we know that we are not on an edge.
1079 */
1080 } else if (viz_clear[row][col - 1] && viz_clear[row][col + 1]) {
1081 /* Both sides clear */
1082 for (i = left_ptrs[row][col - 1] + 1; i <= col; i++)
1083 right_ptrs[row][i] = col;
1084
1085 if (!left_ptrs[row][col - 1]) /* catch the end case */
1086 right_ptrs[row][0] = col;
1087
1088 for (i = col; i < right_ptrs[row][col + 1]; i++)
1089 left_ptrs[row][i] = col;
1090
1091 if (right_ptrs[row][col + 1] == COLNO - 1) /* catch the end case */
1092 left_ptrs[row][COLNO - 1] = col;
1093
1094 } else if (viz_clear[row][col - 1]) {
1095 /* Left side clear, right side blocked. */
1096 for (i = col; i <= right_ptrs[row][col + 1]; i++)
1097 left_ptrs[row][i] = col;
1098
1099 for (i = left_ptrs[row][col - 1] + 1; i < col; i++)
1100 right_ptrs[row][i] = col;
1101
1102 if (!left_ptrs[row][col - 1]) /* catch the end case */
1103 right_ptrs[row][i] = col;
1104
1105 right_ptrs[row][col] = right_ptrs[row][col + 1];
1106
1107 } else if (viz_clear[row][col + 1]) {

Callers 1

block_pointFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected