Mostly bugfix update + empty components support and remove EntityID from Event structure

-empty components now take no memory, so flag components is now far better
-added test for critical bug
-fixed critical bug with adding/removing entities form inside events
-fixed small bug with TestRunner
-improve basic tests
-fixed betterC compilation on DMD
-remove EntityID form Event structure
-added "return" attribute to some functions
-moved some code from Tempalte side to actual implementation
-fixed bug with EntityTemplate copying
-commented out some possibliy unused code
-use code formatter
This commit is contained in:
Mergul 2020-05-27 17:03:44 +02:00
parent 15cd57dbcb
commit 6929f5a748
16 changed files with 988 additions and 544 deletions

View file

@ -35,7 +35,7 @@ struct BlockAllocator
*/
void freeBlock(void* block) nothrow @nogc
{
*cast(void**)block = next_block;
*cast(void**) block = next_block;
next_block = block;
}
@ -44,9 +44,9 @@ struct BlockAllocator
*/
void freeMemory() nothrow @nogc
{
while(pointers)
while (pointers)
{
foreach(i;0..pointers.numberof)
foreach (i; 0 .. pointers.numberof)
{
Mallocator.alignDispose(pointers.blocks[i]);
}
@ -60,12 +60,14 @@ private:
void allocBlock() nothrow @nogc
{
next_block = cast(void*) Mallocator.alignAlloc(
block_size * blocks_in_allocation, block_size);
if(next_block is null)assert(0);
next_block = cast(void*) Mallocator.alignAlloc(block_size * blocks_in_allocation,
block_size);
if (next_block is null)
assert(0);
if(pointers is null)pointers = Mallocator.make!BlockPointers;
if(pointers.numberof >= 32)
if (pointers is null)
pointers = Mallocator.make!BlockPointers;
if (pointers.numberof >= 32)
{
BlockPointers* new_pointers = Mallocator.make!BlockPointers;
new_pointers.next_pointers = pointers;
@ -78,8 +80,7 @@ private:
void** pointer = cast(void**)(next_block + i * block_size);
*pointer = next_block + (i + 1) * block_size;
}
void** pointer = cast(void**)(
next_block + (blocks_in_allocation - 1) * block_size);
void** pointer = cast(void**)(next_block + (blocks_in_allocation - 1) * block_size);
*pointer = null;
}