ObjectNumber MainObjectArrayPtr::MainObjectArray::FindAvailableObject() { ArrayIndex Block; ArrayIndex Element; ObjectNumber Result = NoObject; Block = m_CurrentLowestFreeObject / MainObjectEntriesPerBlock; Element = m_CurrentLowestFreeObject % MainObjectEntriesPerBlock; for (; Block < m_MainObjectBlockCount; Block ++) { for (; Element < MainObjectEntriesPerBlock; Element ++) { if (m_BlockPtr[Block]->Get(Element) == NoObject) { Result = (ObjectNumber) (Block * MainObjectEntriesPerBlock + Element); break; } } if (Result != NoObject) break; } m_CurrentLowestFreeObject = Result; return Result; }