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

Function BOA_ComputeMinDist

Descent3/BOA.cpp:381–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381bool BOA_ComputeMinDist(int start_room, int end_room, float max_check_dist, float *dist, int *num_blockages) {
382 *dist = 0.0f;
383
384 start_room = BOA_INDEX(start_room);
385 end_room = BOA_INDEX(end_room);
386
387 if (start_room == end_room) {
388 return true;
389 }
390
391 if (start_room == Highest_room_index + 1 && end_room > Highest_room_index) {
392 return true;
393 }
394
395 if (end_room == Highest_room_index + 1 && start_room > Highest_room_index) {
396 return true;
397 }
398
399 int cur_room = end_room;
400 int last_room;
401
402 if (start_room < 0 || end_room < 0) {
403 return false;
404 }
405
406 if (start_room > Highest_room_index + BOA_num_terrain_regions ||
407 end_room > Highest_room_index + BOA_num_terrain_regions) {
408 return false;
409 }
410
411 if (start_room <= Highest_room_index && !Rooms[start_room].used)
412 return false;
413
414 if (end_room <= Highest_room_index && !Rooms[end_room].used)
415 return false;
416
417 do {
418 last_room = cur_room;
419
420 if (cur_room <= Highest_room_index && num_blockages && (Rooms[cur_room].flags & RF_DOOR) &&
421 (cur_room != end_room)) {
422 float door_position = DoorwayGetPosition(&Rooms[cur_room]);
423
424 *num_blockages += 1.0f - door_position;
425 }
426
427 cur_room = BOA_NEXT_ROOM(cur_room, start_room);
428 int last_portal;
429
430 if (last_room == cur_room || cur_room == BOA_NO_PATH)
431 return false;
432
433 if (BOA_INDEX(last_room) != BOA_INDEX(cur_room)) {
434 last_portal = BOA_DetermineStartRoomPortal(last_room, NULL, cur_room, NULL);
435 }
436
437 if (last_room == end_room) {
438 int this_portal = BOA_DetermineStartRoomPortal(cur_room, NULL, last_room, NULL);

Callers 4

osipf_AIGetDistToObjFunction · 0.85
compute_sound_dist_infoFunction · 0.85
AIFindRoomWithFlagFunction · 0.85
AIFindObjOfTypeFunction · 0.85

Calls 1

Tested by

no test coverage detected