bool room_is_private( ROOM_INDEX_DATA *pRoomIndex )
{
CHAR_DATA *rch;
int count;
if (pRoomIndex->owner != NULL && pRoomIndex->owner[0] != '\0')
return TRUE;
count = 0;
for ( rch = pRoomIndex->people; rch != NULL; rch = rch->next_in_room )
count++;
if ( IS_SET(pRoomIndex->room_flags, ROOM_PRIVATE) && count >= 2 )
return TRUE;
if ( IS_SET(pRoomIndex->room_flags, ROOM_SOLITARY) && count >= 1 )
return TRUE;
if ( IS_SET(pRoomIndex->room_flags, ROOM_IMP_ONLY) )
return TRUE;
return FALSE;
}
bool room_can_be_private( ROOM_INDEX_DATA *pRoomIndex )
{
if (pRoomIndex->owner != NULL && pRoomIndex->owner[0] != '\0')
return TRUE;
if ( IS_SET(pRoomIndex->room_flags, ROOM_PRIVATE))
return TRUE;
if ( IS_SET(pRoomIndex->room_flags, ROOM_SOLITARY))
return TRUE;
if ( IS_SET(pRoomIndex->room_flags, ROOM_IMP_ONLY) )
return TRUE;
return FALSE;
}
The iterator is also reusable anywhere that you would want to traverse all of the rooms for whatever reason efficiently.
The room checks are still in place but the ch specific checks should be done after the call, and recall it if the check didn't flesh out.
This is because you might want to grab a random room for some purpose other than sending a character to it.