2007-11-25 19:42:40 +00:00
|
|
|
/* copyright (c) 2007 magnus auvinen, see licence.txt for more info */
|
2007-08-22 07:52:33 +00:00
|
|
|
#ifndef ENGINE_SNAPSHOT_H
|
|
|
|
#define ENGINE_SNAPSHOT_H
|
2007-05-22 15:03:32 +00:00
|
|
|
|
2007-12-15 10:24:49 +00:00
|
|
|
#include "e_system.h"
|
2007-08-22 18:40:31 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
/* SNAPSHOT */
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2007-10-06 17:01:06 +00:00
|
|
|
MAX_SNAPSHOT_SIZE=64*1024
|
2007-08-22 07:52:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int type_and_id;
|
|
|
|
} SNAPSHOT_ITEM;
|
|
|
|
|
|
|
|
typedef struct
|
2007-05-22 15:03:32 +00:00
|
|
|
{
|
2007-07-13 13:40:04 +00:00
|
|
|
int data_size;
|
2007-05-22 15:03:32 +00:00
|
|
|
int num_items;
|
2007-08-22 07:52:33 +00:00
|
|
|
} SNAPSHOT;
|
|
|
|
|
|
|
|
int *snapitem_data(SNAPSHOT_ITEM *item);
|
|
|
|
int snapitem_type(SNAPSHOT_ITEM *item);
|
|
|
|
int snapitem_id(SNAPSHOT_ITEM *item);
|
|
|
|
int snapitem_key(SNAPSHOT_ITEM *item);
|
|
|
|
|
|
|
|
int *snapshot_offsets(SNAPSHOT *snap);
|
|
|
|
char *snapshot_datastart(SNAPSHOT *snap);
|
|
|
|
|
|
|
|
SNAPSHOT_ITEM *snapshot_get_item(SNAPSHOT *snap, int index);
|
|
|
|
int snapshot_get_item_datasize(SNAPSHOT *snap, int index);
|
|
|
|
int snapshot_get_item_index(SNAPSHOT *snap, int key);
|
|
|
|
|
|
|
|
void *snapshot_empty_delta();
|
|
|
|
int snapshot_crc(SNAPSHOT *snap);
|
|
|
|
void snapshot_debug_dump(SNAPSHOT *snap);
|
|
|
|
int snapshot_create_delta(SNAPSHOT *from, SNAPSHOT *to, void *data);
|
|
|
|
int snapshot_unpack_delta(SNAPSHOT *from, SNAPSHOT *to, void *data, int data_size);
|
|
|
|
|
|
|
|
/* SNAPSTORAGE */
|
|
|
|
|
|
|
|
typedef struct SNAPSTORAGE_HOLDER_t
|
|
|
|
{
|
|
|
|
struct SNAPSTORAGE_HOLDER_t *prev;
|
|
|
|
struct SNAPSTORAGE_HOLDER_t *next;
|
2007-07-13 13:40:04 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
int64 tagtime;
|
|
|
|
int tick;
|
2007-07-13 13:40:04 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
int snap_size;
|
|
|
|
SNAPSHOT *snap;
|
|
|
|
} SNAPSTORAGE_HOLDER;
|
|
|
|
|
|
|
|
typedef struct SNAPSTORAGE_t
|
|
|
|
{
|
|
|
|
SNAPSTORAGE_HOLDER *first;
|
|
|
|
SNAPSTORAGE_HOLDER *last;
|
|
|
|
} SNAPSTORAGE;
|
|
|
|
|
|
|
|
void snapstorage_init(SNAPSTORAGE *ss);
|
|
|
|
void snapstorage_purge_all(SNAPSTORAGE *ss);
|
|
|
|
void snapstorage_purge_until(SNAPSTORAGE *ss, int tick);
|
|
|
|
void snapstorage_add(SNAPSTORAGE *ss, int tick, int64 tagtime, int data_size, void *data);
|
|
|
|
int snapstorage_get(SNAPSTORAGE *ss, int tick, int64 *tagtime, SNAPSHOT **data);
|
|
|
|
|
|
|
|
/* SNAPBUILD */
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2008-02-02 12:38:36 +00:00
|
|
|
SNAPBUILD_MAX_ITEMS = 1024*2
|
2007-05-22 15:03:32 +00:00
|
|
|
};
|
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
typedef struct SNAPBUILD
|
|
|
|
{
|
|
|
|
char data[MAX_SNAPSHOT_SIZE];
|
|
|
|
int data_size;
|
|
|
|
|
|
|
|
int offsets[SNAPBUILD_MAX_ITEMS];
|
|
|
|
int num_items;
|
|
|
|
} SNAPBUILD;
|
|
|
|
|
|
|
|
void snapbuild_init(SNAPBUILD *sb);
|
|
|
|
SNAPSHOT_ITEM *snapbuild_get_item(SNAPBUILD *sb, int index);
|
|
|
|
int *snapbuild_get_item_data(SNAPBUILD *sb, int key);
|
|
|
|
int snapbuild_finish(SNAPBUILD *sb, void *snapdata);
|
|
|
|
void *snapbuild_new_item(SNAPBUILD *sb, int type, int id, int size);
|
2007-07-13 13:40:04 +00:00
|
|
|
|
2007-08-22 07:52:33 +00:00
|
|
|
#endif /* ENGINE_SNAPSHOT_H */
|