| 817 | } |
| 818 | |
| 819 | HInstance NewInstance(Collection* collection, Prototype* proto, const char* prototype_name) { |
| 820 | if (collection->m_InstanceIndices.Remaining() == 0) |
| 821 | { |
| 822 | dmLogError("The game object instance could not be created since the buffer is full (%d). Increase the capacity with collection.max_instances", collection->m_InstanceIndices.Capacity()); |
| 823 | return 0; |
| 824 | } |
| 825 | HInstance instance = AllocInstance(proto, prototype_name); |
| 826 | instance->m_Collection = collection; |
| 827 | uint16_t instance_index = collection->m_InstanceIndices.Pop(); |
| 828 | instance->m_Index = instance_index; |
| 829 | dmMutex::Lock(collection->m_Mutex); |
| 830 | instance->m_Generation = dmMath::Max(1U, collection->m_GenInstanceCounter++); |
| 831 | dmMutex::Unlock(collection->m_Mutex); |
| 832 | assert(collection->m_Instances[instance_index] == 0); |
| 833 | collection->m_Instances[instance_index] = instance; |
| 834 | |
| 835 | InsertInstanceInLevelIndex(collection, instance); |
| 836 | |
| 837 | return instance; |
| 838 | } |
| 839 | |
| 840 | HInstance NewInstance(HCollection hcollection, Prototype* proto, const char* prototype_name){ |
| 841 | return NewInstance(hcollection->m_Collection, proto, prototype_name); |
no test coverage detected