Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Object {
- Object* NextObject; // Pointer to first item in our same container (tiles are Map Containers). Can be NULL.
- Object* Container; // Cannot be NULL, except if we are a Map Container object.
- Object* Content; // Pointer to our content, if we have, otherwise NULL.
- ObjectType* Type; // A C array holds all the object types, this points to ours
- int32_t InstanceAttributes[20]; // Can be plain integers or some sort of reference to other object (i.e the Dynamic String Table).
- bool State;
- };
- Object::Object() {
- State = 0;
- ObjectTableFree.push_front();
- }
- #define TABLESIZE 64
- #define CHUNKSIZE 32768
- ObjectChunk* ObjectTable;
- std::forward_list<Object *> ObjectTableFree(TABLESIZE * CHUNKSIZE);
- struct ObjectChunk {
- Object Obj[CHUNKSIZE];
- };
- void InitMap() {
- ObjectTable = new ObjectChunk[TABLESIZE];
- // Here we also read the map from the hard disk, and
- }
- Object* CreateObject() {
- if (ObjectTableFree.empty())
- ResizeObjectTable();
- Object* obj = ObjectTableFree.front();
- assert(obj);
- ObjectTableFree.pop_front();
- return obj;
- }
- Object* AppendObject(Object* Con, ObjectType* Type, bool AsContent) {
- assert(Con);
- Object* obj = CreateObject();
- obj->Container = Con;
- Object->setType(Type);
- if (AsContent) {
- if (Con->Content)
- obj->NextObject = Con->Content;
- Con->NextObject = obj;
- return obj;
- if (Con->NextObject)
- obj->NextObject = Con->NextObject;
- Con->NextObject = obj;
- return obj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement