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

Function ObjLink

Descent3/object.cpp:1436–1478  ·  view source on GitHub ↗

link the object into the list for its room

Source from the content-addressed store, hash-verified

1434
1435// link the object into the list for its room
1436void ObjLink(int objnum, int roomnum) {
1437 object *obj = &Objects[objnum];
1438
1439 ASSERT(objnum != -1);
1440
1441 ASSERT(obj->roomnum == -1);
1442 ASSERT(!(obj->flags & OF_BIG_OBJECT));
1443
1444 if ((obj->size >= MIN_BIG_OBJ_RAD) && (!ROOMNUM_OUTSIDE(roomnum))) {
1445 BigObjAdd(objnum);
1446 }
1447
1448 obj->roomnum = roomnum;
1449
1450 if (ROOMNUM_OUTSIDE(roomnum)) {
1451 int cellnum = CELLNUM(roomnum);
1452
1453 obj->next = Terrain_seg[cellnum].objects;
1454 Terrain_seg[cellnum].objects = objnum;
1455
1456 ASSERT(obj->next != objnum);
1457 } else {
1458 ASSERT(roomnum >= 0 && roomnum <= Highest_room_index);
1459 ASSERT(!(Rooms[roomnum].flags & RF_EXTERNAL));
1460
1461 obj->next = Rooms[roomnum].objects;
1462 Rooms[roomnum].objects = objnum;
1463 ASSERT(obj->next != objnum);
1464 }
1465
1466 obj->prev = -1;
1467
1468 if (obj->next != -1)
1469 Objects[obj->next].prev = objnum;
1470
1471 ASSERT(Objects[0].next != 0);
1472 if (Objects[0].next == 0)
1473 Objects[0].next = -1;
1474
1475 ASSERT(Objects[0].prev != 0);
1476 if (Objects[0].prev == 0)
1477 Objects[0].prev = -1;
1478}
1479
1480void ObjUnlink(int objnum) {
1481 object *obj = &Objects[objnum];

Callers 4

LGSObjectsFunction · 0.85
LoadLevelFunction · 0.85
ObjCreateFunction · 0.85
ObjRelinkFunction · 0.85

Calls 1

BigObjAddFunction · 0.85

Tested by

no test coverage detected