-
Notifications
You must be signed in to change notification settings - Fork 1
Object IDs
There are two major forms of object ids, which are permanent object ids (size 24 bytes) and object handles, which are only valid as long as the object is resident in memory.
The objects storage space is handled by the master object table, which gives out the handles to identify the location of objects in the table. It also manages an index that maps from permanent object ids to handles.
A permanent object id is in reality a union whose content depends on the type of the id. The union will start with a type value, which is 16-bit. The following types are known to exist:
- NULL (0)
- Proto (1)
- GUID (2)
- Positional (3)
- Handle (0xFFFE)
- Blocked (0xFFFF)
enum ObjectIDType : uint16_t {
OIT_NULL = 0,
OIT_PROTO = 1,
OIT_GUID = 2,
OIT_POSITIONAL = 3,
OIT_HANDLE = 0xFFFE,
OIT_BLOCKED = 0xFFFF
};
#pragma pack(push, 8)
struct ObjectID {
ObjectIDType type;
union {
int protoId;
GUID guid;
struct Positional {
locXY pos; // Position (x,y)
int tempId; // Unknown purpose
int map;
} pos;
} id;
};
#pragma pack(pop)
Object handles are 64-bit values that contain information about the runtime location of an object in memory.
The number is actually a composite:
[idx] << 29 bit
[serial] << 3 bit
+ 2
Where idx is the overall index in the master table of objects, serial is the serial number of insertion (which just counts up for each new object). The serial number could be used to identify when an old handle is used to access a cell that has since been freed and reused for some other object. The serial number used to allocate an object handle is stored inside the cell and would be changed when a new object is put into that cell.
The lower three bit are initialized with "2" when the handle is created. This is checked in some places to verify that it is a valid object handle.