| 1128 | } |
| 1129 | |
| 1130 | static S32 GetBoulderForGenerating(xBoulderGenerator* bg) |
| 1131 | { |
| 1132 | S32 numList; |
| 1133 | S32 j; |
| 1134 | S32 i; |
| 1135 | S32 oldestCulled = -1; |
| 1136 | S32 minAge = bg->numBoulders >> 1; |
| 1137 | |
| 1138 | for (i = 0, numList = bg->numBoulders; i < numList; i++) |
| 1139 | { |
| 1140 | j = i + bg->nextBoulder; |
| 1141 | |
| 1142 | if (j >= numList) |
| 1143 | { |
| 1144 | j -= numList; |
| 1145 | } |
| 1146 | |
| 1147 | if (!xEntIsVisible(bg->boulderList[j])) |
| 1148 | { |
| 1149 | break; |
| 1150 | } |
| 1151 | |
| 1152 | if (bg->boulderAges[j] < minAge) |
| 1153 | { |
| 1154 | // :^) |
| 1155 | } |
| 1156 | else if (oldestCulled < 0) |
| 1157 | { |
| 1158 | oldestCulled = j; |
| 1159 | } |
| 1160 | else if (bg->boulderList[oldestCulled]->isCulled) |
| 1161 | { |
| 1162 | if (bg->boulderList[j]->isCulled && |
| 1163 | (bg->boulderAges[oldestCulled] < bg->boulderAges[j])) |
| 1164 | { |
| 1165 | oldestCulled = j; |
| 1166 | } |
| 1167 | } |
| 1168 | else if (bg->boulderList[j]->isCulled || |
| 1169 | (bg->boulderAges[oldestCulled] < bg->boulderAges[j])) |
| 1170 | { |
| 1171 | oldestCulled = j; |
| 1172 | } |
| 1173 | } |
| 1174 | |
| 1175 | if (i == numList) |
| 1176 | { |
| 1177 | if (oldestCulled < 0) |
| 1178 | { |
| 1179 | j = (numList - 1) * xurand(); |
| 1180 | if (j >= numList) |
| 1181 | { |
| 1182 | j = numList - 1; |
| 1183 | } |
| 1184 | } |
| 1185 | else |
| 1186 | { |
| 1187 | j = oldestCulled; |
no test coverage detected