I am glad to get such a turnout on responses. I am not sure if I should overload the standard new operator as I am already getting pretty good speed. I may want to make a test branch.
With my architecture, I have a system similar to this ...
Game Object
Children: Tile and DynamicE
Tile Children: WoodenDoor, Grass, ect...
DynamicE Children: Zombie, Monster, ect...
This is just an example layout but gives you the idea.
Game object has the following virtual functions
1 2
|
virtual void Update(unsigned int T)=0;
virtual bool RunEvent(Event& E)=0;
|
All of type Tile are stored into a Map object containing Chunk objects. DynamicE is stored in a separate unordered map of Id's.
Tile only adds a
1 2 3 4 5 6
|
virtual bool SaveToFile(std::ofstream*);
virtual bool ReadFromFile(std::ifstream*);
private:
unsigned int Id;
unsigned int AssignedImage;
|
All of my current children of Tile are ROUGHLY the same size, with a few containing a Boolean value to define toggle states or similar.
If they are all roughly the same size I can create a maximum size requirement and have each one use prealocated memory allocated in a block equal to the bytes taken up by (MaximumSize * ChunkSizeX * ChunkSizeY * ChunkSizeZ) and clean up the memory afterwords, however I am not necessarily sure how I would implement this.