Fix crash in commit() when all components were removed from entity
Fix crash from issue #2 and add unittest case for it. Also implements general "empty" entity support
This commit is contained in:
parent
beb1837c43
commit
8ac9fa5dbd
3 changed files with 185 additions and 42 deletions
29
tests/bugs.d
29
tests/bugs.d
|
|
@ -142,5 +142,34 @@ unittest
|
|||
gEntityManager.update();
|
||||
gEntityManager.end();
|
||||
|
||||
gEntityManager.destroy();
|
||||
}
|
||||
|
||||
@("2-empty-entity-crash")
|
||||
unittest
|
||||
{
|
||||
|
||||
gEntityManager.initialize(0);
|
||||
|
||||
gEntityManager.beginRegister();
|
||||
|
||||
gEntityManager.registerComponent!CInt;
|
||||
gEntityManager.registerComponent!CFloat;
|
||||
|
||||
gEntityManager.endRegister();
|
||||
|
||||
|
||||
EntityTemplate* tmpl = gEntityManager.allocateTemplate([becsID!CInt, becsID!CFloat].staticArray);
|
||||
scope(exit) gEntityManager.freeTemplate(tmpl);
|
||||
|
||||
EntityID id = gEntityManager.addEntity(tmpl).id;
|
||||
// EntityID id2 = gEntityManager.addEntity().id;
|
||||
|
||||
gEntityManager.commit();
|
||||
|
||||
gEntityManager.removeComponents(id, [becsID!CInt, becsID!CFloat].staticArray);
|
||||
|
||||
gEntityManager.commit();
|
||||
|
||||
gEntityManager.destroy();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue