Bug fixes
-fix: UnittestRunner don't catch RangeError -fix: sometimes onUpdate was called with empty array of entities
This commit is contained in:
parent
d733bb514c
commit
3e7575c4b2
2 changed files with 33 additions and 4 deletions
|
|
@ -1011,7 +1011,8 @@ export struct EntityManager
|
|||
if (entities_count > 0)
|
||||
{
|
||||
assert(entities_count <= block.entities_count
|
||||
&& offset <= block.entities_count);
|
||||
&& offset < block.entities_count);
|
||||
assert(entities_count > offset);
|
||||
|
||||
fillInputData(input_data, info, block, offset, entities_count, system);
|
||||
|
||||
|
|
@ -1489,21 +1490,27 @@ export struct EntityManager
|
|||
if (first_block is null || blocks_count == 0)
|
||||
continue;
|
||||
|
||||
//if this info will fill job
|
||||
if ((blocks_count - 1) * info.max_entities + entities_count
|
||||
+ info.last_block.entities_count - first_elem >= entities_per_job)
|
||||
{
|
||||
int reamaining_entities = (entities_per_job - entities_count - (
|
||||
first_block.entities_count - first_elem));
|
||||
if (reamaining_entities >= 0)
|
||||
|
||||
//if first block don't fill job
|
||||
if (reamaining_entities > 0)
|
||||
{
|
||||
//take as many full blocks as possible
|
||||
int full_blocks_count = reamaining_entities / info.max_entities;
|
||||
EntitiesBlock* block = first_block;
|
||||
foreach (i; 0 .. full_blocks_count + 1)
|
||||
block = block.next_block;
|
||||
|
||||
//if full block + actual contained entities + remaining entities form first block > entities count per job
|
||||
if (full_blocks_count * info.max_entities + entities_count + (
|
||||
first_block.entities_count - first_elem) >= entities_per_job)
|
||||
{
|
||||
assert(entities_per_job == full_blocks_count * info.max_entities + entities_count + (first_block.entities_count - first_elem));
|
||||
CallData data = CallData(caller.system_id, sys,
|
||||
info, sys.m_update_delegate, first_block,
|
||||
cast(ushort)(full_blocks_count + 1),
|
||||
|
|
@ -1518,6 +1525,8 @@ export struct EntityManager
|
|||
entities_count += full_blocks_count * info.max_entities + (
|
||||
first_block.entities_count - first_elem); // - first_elem;
|
||||
uint last_elem = entities_per_job - entities_count; // + first_elem - 1;
|
||||
assert(last_elem > 0);
|
||||
assert(last_elem <= block.entities_count);
|
||||
CallData data = CallData(caller.system_id, sys,
|
||||
info, sys.m_update_delegate, first_block,
|
||||
cast(ushort)(full_blocks_count + 2),
|
||||
|
|
@ -1525,19 +1534,31 @@ export struct EntityManager
|
|||
tmp_datas.add(data);
|
||||
first_elem = last_elem;
|
||||
blocks_count -= full_blocks_count + 1;
|
||||
assert(first_elem <= block.entities_count);
|
||||
first_block = block;
|
||||
if(last_elem == block.entities_count)
|
||||
{
|
||||
assert(block.next_block == null);
|
||||
first_block = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint last_elem = entities_per_job - entities_count;
|
||||
assert(last_elem > 0);
|
||||
CallData data = CallData(caller.system_id, sys,
|
||||
info, sys.m_update_delegate, first_block, 1,
|
||||
cast(ushort) first_elem, cast(ushort)(first_elem + last_elem));
|
||||
tmp_datas.add(data);
|
||||
first_elem += last_elem;
|
||||
assert(first_elem <= first_block.entities_count);
|
||||
//if job takes every entity, take next block
|
||||
if(first_elem == first_block.entities_count)
|
||||
{
|
||||
first_elem = 0;
|
||||
first_block = first_block.next_block;
|
||||
blocks_count--;
|
||||
}
|
||||
}
|
||||
nextJob();
|
||||
entities_count = 0;
|
||||
|
|
@ -1545,6 +1566,7 @@ export struct EntityManager
|
|||
}
|
||||
else
|
||||
{
|
||||
//take whole info blocks
|
||||
CallData data = CallData(caller.system_id, sys, info, sys.m_update_delegate,
|
||||
first_block, cast(ushort) blocks_count, cast(ushort) first_elem);
|
||||
tmp_datas.add(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue