| 540 | } |
| 541 | |
| 542 | HCollection NewCollection(const char* name, dmResource::HFactory factory, HRegister regist, uint32_t max_instances, HCollectionDesc collection_desc) |
| 543 | { |
| 544 | if (max_instances >= INVALID_INSTANCE_INDEX) |
| 545 | { |
| 546 | dmLogError("max_instances must be less or equal to %d", INVALID_INSTANCE_INDEX - 1); |
| 547 | return 0; |
| 548 | } |
| 549 | |
| 550 | Collection* collection = AllocCollection(name, regist, max_instances, (dmGameObjectDDF::CollectionDesc*)collection_desc); |
| 551 | if (!collection) |
| 552 | { |
| 553 | return 0; |
| 554 | } |
| 555 | |
| 556 | collection->m_NameHash = dmHashString64(name); // Same as the socket name |
| 557 | |
| 558 | HCollection hcollection = (HCollection)new CollectionHandle; |
| 559 | Result result = AttachCollection(collection, name, factory, regist, hcollection); |
| 560 | if (result != RESULT_OK) |
| 561 | { |
| 562 | DeallocCollection(collection); |
| 563 | delete hcollection; |
| 564 | return 0; |
| 565 | } |
| 566 | return hcollection; |
| 567 | } |
| 568 | |
| 569 | static void DoDeleteAll(Collection* collection) |
| 570 | { |