I believe the PackEntityIntoChunk function has a bug in it.
The code that creates the first Block in a chunk will also be called if there is no room left. And at that point, the new Block should chain the old Block on the list. But this is not done.
| Chunk->FirstBlock = World->FirstFreeBlock;
World->FirstFreeBlock = Chunk->FirstBlock->Next;
ClearWorldEntityBlock(Chunk->FirstBlock);
|
This overwrites Chunk->FirstBlock without remembering it.
I think it should become
| world_entity_block *OldFirstBlock = Chunk->FirstBlock;
Chunk->FirstBlock = World->FirstFreeBlock;
World->FirstFreeBlock = Chunk->FirstBlock->Next;
ClearWorldEntityBlock(Chunk->FirstBlock);
Chunk->FirstBlock->Next = OldFirstBlock;
|
Or something like that.
Hope this will prevent any future problems
Regards,
Mox