Sdk/World: Fix destruction retrieval while world clear
This commit is contained in:
parent
19724f1e66
commit
b83a9b60e7
|
|
@ -34,6 +34,7 @@ Nazara Development Kit:
|
|||
- TextAreaWidget will now show a cursor as long as it has focus
|
||||
- Fix BaseWidget linking error on Linux
|
||||
- ⚠️ Rewrite StateMachine to fix instantaneous state changing (state change is no longer effective until the next update call)
|
||||
- Fix entities destruction when coming from World::Clear() (also called by destructor), which invalidated world entities handles before destroying entities (preventing destruction callback to get valid entities handles from world)
|
||||
|
||||
# 0.4:
|
||||
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ namespace Ndk
|
|||
*
|
||||
* \param id Identifier of the entity
|
||||
*
|
||||
* \remark Handle referenced by this function can move in memory when updating the world, do not keep a reference to a handle from a world update to another
|
||||
* \remark Handle referenced by this function can move in memory when updating the world, do not keep a handle reference from a world update to another
|
||||
* \remark If an invalid identifier is provided, an error got triggered and an invalid handle is returned
|
||||
*/
|
||||
inline const EntityHandle& World::GetEntity(EntityId id)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace Ndk
|
|||
|
||||
Entity::~Entity()
|
||||
{
|
||||
if (m_world)
|
||||
if (m_world && m_valid)
|
||||
Destroy();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,10 +115,15 @@ namespace Ndk
|
|||
|
||||
void World::Clear() noexcept
|
||||
{
|
||||
// First, destruction of entities, then handles
|
||||
// This is made to avoid that handle warn uselessly entities before their destruction
|
||||
m_entities.clear();
|
||||
// Destroy every valid entity first, to ensure entities are still accessible by ID while being destroyed
|
||||
for (EntityBlock* entBlock : m_entityBlocks)
|
||||
{
|
||||
if (entBlock->entity.IsValid())
|
||||
entBlock->entity.Destroy();
|
||||
}
|
||||
m_entityBlocks.clear();
|
||||
|
||||
m_entities.clear();
|
||||
m_freeIdList.clear();
|
||||
m_waitingEntities.clear();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue