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

Function ObjUnlink

Descent3/object.cpp:1480–1523  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1478}
1479
1480void ObjUnlink(int objnum) {
1481 object *obj = &Objects[objnum];
1482
1483 ASSERT(objnum != -1);
1484
1485 // If object is already unlinked, do nothing
1486 if (obj->roomnum == -1) {
1487 return;
1488 }
1489
1490 if (obj->flags & OF_BIG_OBJECT) {
1491 BigObjRemove(objnum);
1492 }
1493
1494 if (OBJECT_OUTSIDE(obj)) {
1495 int cellnum = CELLNUM(obj->roomnum);
1496
1497 terrain_segment *seg = &Terrain_seg[cellnum];
1498
1499 if (obj->prev == -1)
1500 seg->objects = obj->next;
1501 else
1502 Objects[obj->prev].next = obj->next;
1503
1504 if (obj->next != -1)
1505 Objects[obj->next].prev = obj->prev;
1506 } else {
1507 room *rp = &Rooms[obj->roomnum];
1508
1509 if (obj->prev == -1)
1510 rp->objects = obj->next;
1511 else
1512 Objects[obj->prev].next = obj->next;
1513
1514 if (obj->next != -1)
1515 Objects[obj->next].prev = obj->prev;
1516 }
1517
1518 // Mark as not linked
1519 obj->roomnum = -1;
1520
1521 ASSERT(Objects[0].next != 0);
1522 ASSERT(Objects[0].prev != 0);
1523}
1524
1525//-----------------------------------------------------------------------------
1526// Scan the object list, freeing down to num_used objects

Callers 3

LGSObjectsFunction · 0.85
ObjDeleteFunction · 0.85
ObjRelinkFunction · 0.85

Calls 1

BigObjRemoveFunction · 0.85

Tested by

no test coverage detected