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

Function GetFreeRoom

editor/Erooms.cpp:578–608  ·  view source on GitHub ↗

Returns a free room number, & marks it no longer free. Returns -1 if none free. If palette_room is true, allocate out of the part of the array for the room palette

Source from the content-addressed store, hash-verified

576// Returns a free room number, & marks it no longer free. Returns -1 if none free.
577// If palette_room is true, allocate out of the part of the array for the room palette
578int GetFreeRoom(bool palette_room) {
579 int roomnum;
580 int start, end;
581
582 int old_hri = Highest_room_index;
583
584 if (palette_room) {
585 start = FIRST_PALETTE_ROOM;
586 end = start + MAX_PALETTE_ROOMS;
587 } else {
588 start = 0;
589 end = MAX_ROOMS;
590 }
591
592 for (roomnum = start; roomnum < end; roomnum++)
593 if (!Rooms[roomnum].used)
594 break;
595
596 if (roomnum == end) // couldn't find a free room
597 return -1;
598
599 if (!palette_room) {
600 if (roomnum > Highest_room_index)
601 Highest_room_index = roomnum;
602 } else
603 Current_faces[roomnum - FIRST_PALETTE_ROOM] = 0;
604
605 BNode_RemapTerrainRooms(old_hri, Highest_room_index);
606
607 return roomnum;
608}
609
610// Allocates a room & initializes it.
611// Memory is allocated for faces & verts arrays, but the elements are *not* initialized

Callers 3

CreateNewRoomFunction · 0.85
AttachGroupFunction · 0.85
DropRoomFunction · 0.85

Calls 1

BNode_RemapTerrainRoomsFunction · 0.85

Tested by

no test coverage detected