X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Flibgame%2Fsnapshot.c;fp=src%2Flibgame%2Fsnapshot.c;h=d28ae349e585acb88d8a4c1daa617f0d465d19ab;hp=0000000000000000000000000000000000000000;hb=f926e522aef77158e0011ae5ad2cf8805509d6d1;hpb=4f9e14eb7715eb000d6a750f9734b8dcc521923f diff --git a/src/libgame/snapshot.c b/src/libgame/snapshot.c new file mode 100644 index 00000000..d28ae349 --- /dev/null +++ b/src/libgame/snapshot.c @@ -0,0 +1,55 @@ +/*********************************************************** +* Artsoft Retro-Game Library * +*----------------------------------------------------------* +* (c) 1995-2006 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * +*----------------------------------------------------------* +* snapshot.c * +***********************************************************/ + +#include "snapshot.h" + + +static ListNode *engine_snapshot_list = NULL; + +void SaveEngineSnapshotBuffer(void *buffer, int size) +{ + struct EngineSnapshotNodeInfo *bi = + checked_calloc(sizeof(struct EngineSnapshotNodeInfo)); + + bi->buffer_orig = buffer; + bi->buffer_copy = checked_malloc(size); + bi->size = size; + + memcpy(bi->buffer_copy, buffer, size); + + addNodeToList(&engine_snapshot_list, NULL, bi); +} + +static void LoadEngineSnapshotBuffer(struct EngineSnapshotNodeInfo *bi) +{ + memcpy(bi->buffer_orig, bi->buffer_copy, bi->size); +} + +void LoadEngineSnapshotBuffers() +{ + ListNode *node = engine_snapshot_list; + + while (node != NULL) + { + LoadEngineSnapshotBuffer((struct EngineSnapshotNodeInfo *)node->content); + + node = node->next; + } +} + +void FreeEngineSnapshotBuffers() +{ + while (engine_snapshot_list != NULL) + deleteNodeFromList(&engine_snapshot_list, engine_snapshot_list->key, + checked_free); +}