1 /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2 /* If you are missing that file, acquire a complete release at teeworlds.com. */
3 #ifndef ENGINE_SHARED_SNAPSHOT_H
4 #define ENGINE_SHARED_SNAPSHOT_H
6 #include <base/system.h>
15 int *Data() { return (int *)(this+1); }
16 int Type() { return m_TypeAndID
>>16; }
17 int ID() { return m_TypeAndID
&0xffff; }
18 int Key() { return m_TypeAndID
; }
24 friend class CSnapshotBuilder
;
28 int *Offsets() const { return (int *)(this+1); }
29 char *DataStart() const { return (char*)(Offsets()+m_NumItems
); }
37 void Clear() { m_DataSize
= 0; m_NumItems
= 0; }
38 int NumItems() const { return m_NumItems
; }
39 CSnapshotItem
*GetItem(int Index
);
40 int GetItemSize(int Index
);
41 int GetItemIndex(int Key
);
56 int m_NumDeletedItems
;
58 int m_NumTempItems
; // needed?
63 // TODO: strange arbitrary number
64 short m_aItemSizes
[64];
65 int m_aSnapshotDataRate
[0xffff];
66 int m_aSnapshotDataUpdates
[0xffff];
67 int m_SnapshotCurrent
;
70 void UndiffItem(int *pPast
, int *pDiff
, int *pOut
, int Size
);
74 int GetDataRate(int Index
) { return m_aSnapshotDataRate
[Index
]; }
75 int GetDataUpdates(int Index
) { return m_aSnapshotDataUpdates
[Index
]; }
76 void SetStaticsize(int ItemType
, int Size
);
78 int CreateDelta(class CSnapshot
*pFrom
, class CSnapshot
*pTo
, void *pData
);
79 int UnpackDelta(class CSnapshot
*pFrom
, class CSnapshot
*pTo
, void *pData
, int DataSize
);
85 class CSnapshotStorage
99 CSnapshot
*m_pAltSnap
;
108 void PurgeUntil(int Tick
);
109 void Add(int Tick
, int64 Tagtime
, int DataSize
, void *pData
, int CreateAlt
);
110 int Get(int Tick
, int64
*Tagtime
, CSnapshot
**pData
, CSnapshot
**ppAltData
);
113 class CSnapshotBuilder
120 char m_aData
[CSnapshot::MAX_SIZE
];
123 int m_aOffsets
[MAX_ITEMS
];
129 void *NewItem(int Type
, int ID
, int Size
);
131 CSnapshotItem
*GetItem(int Index
);
132 int *GetItemData(int Key
);
134 int Finish(void *Snapdata
);
138 #endif // ENGINE_SNAPSHOT_H