MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / ValidateRoomPathPoint

Function ValidateRoomPathPoint

Descent3/BOA.cpp:1328–1369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1326#define MAX_SUBDIVISIONS 12 // Actually 19 (we don't do extremities)
1327
1328void ValidateRoomPathPoint(int room, char *message, int len) {
1329 vector pos;
1330 int i, j, k;
1331
1332 pos = Rooms[room].path_pnt;
1333
1334 if (IsPathPointValid(room, &pos))
1335 return;
1336
1337 bool f_found = false;
1338 // vector best_pnt;
1339 // float best_distance;
1340
1341 vector diff = (Rooms[room].max_xyz - Rooms[room].min_xyz) / MAX_SUBDIVISIONS;
1342
1343 for (i = 1; i < MAX_SUBDIVISIONS - 1; i++) {
1344 for (j = 1; j < MAX_SUBDIVISIONS - 1; j++) {
1345 for (k = 1; k < MAX_SUBDIVISIONS - 1; k++) {
1346 vector t_pnt = Rooms[room].min_xyz;
1347 t_pnt.x += diff.x * i;
1348 t_pnt.y += diff.y * j;
1349 t_pnt.z += diff.z * k;
1350
1351 if (IsPathPointValid(room, &t_pnt)) {
1352 Rooms[room].path_pnt = t_pnt;
1353 return;
1354 }
1355 }
1356 }
1357 }
1358
1359 if (!message)
1360 mprintf(0, "Room %d has a bad center point\n", room);
1361 else {
1362 char new_message[300];
1363 snprintf(new_message, sizeof(new_message), "Room %d has a bad center point\n", room);
1364
1365 if (strlen(message) + strlen(new_message) < (uint32_t)len) {
1366 strcat(message, new_message);
1367 }
1368 }
1369}
1370
1371void BOA_ComputePathPoints(char *message, int len) {
1372 int i;

Callers 1

BOA_ComputePathPointsFunction · 0.85

Calls 1

IsPathPointValidFunction · 0.85

Tested by

no test coverage detected