X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsnapshot.c;h=cd83dc5be1636470983d559a334dad309e96b2f9;hb=343ecd1bed93fa862903ff981ede342825f14401;hp=1059eb954fc858616754b7f4722467fafd644400;hpb=17c77433b0e3b4c985fc4171ab240c1acb3a928a;p=rocksndiamonds.git diff --git a/src/libgame/snapshot.c b/src/libgame/snapshot.c index 1059eb95..cd83dc5b 100644 --- a/src/libgame/snapshot.c +++ b/src/libgame/snapshot.c @@ -4,7 +4,7 @@ // (c) 1995-2014 by Artsoft Entertainment // Holger Schemel // info@artsoft.org -// http://www.artsoft.org/ +// https://www.artsoft.org/ // ---------------------------------------------------------------------------- // snapshot.c // ============================================================================ @@ -16,12 +16,6 @@ #define DEBUG_SNAPSHOTS 0 #endif -#if DEBUG_SNAPSHOTS -#define MAX_SNAPSHOT_BYTES (50 * 1024 * 1024) -#else -#define MAX_SNAPSHOT_BYTES (500 * 1024 * 1024) -#endif - static ListNode *snapshot_single = NULL; static ListNode *snapshot_list = NULL; static ListNode *snapshot_current = NULL; @@ -94,7 +88,7 @@ static void FreeSnapshot(void *snapshot_buffers_ptr) FreeSnapshotBuffers(snapshot_buffers_ptr); } -void FreeSnapshotSingle() +void FreeSnapshotSingle(void) { FreeSnapshotBuffers(snapshot_single); @@ -106,8 +100,8 @@ static void FreeSnapshotList_UpToNode(ListNode *node) while (snapshot_list != node) { #if DEBUG_SNAPSHOTS - printf("::: FreeSnapshotList_*() [%s, %d, %d]\n", - snapshot_list->key, num_snapshot_buffers, num_snapshot_bytes); + Debug("snapshot:FreeSnapshotList_UpToNode", "[%s, %d, %d]", + snapshot_list->key, num_snapshot_buffers, num_snapshot_bytes); #endif deleteNodeFromList(&snapshot_list, snapshot_list->key, FreeSnapshot); @@ -117,10 +111,10 @@ static void FreeSnapshotList_UpToNode(ListNode *node) } } -void FreeSnapshotList() +void FreeSnapshotList(void) { #if DEBUG_SNAPSHOTS - printf("::: FreeSnapshotList()\n"); + Debug("snapshot:FreeSnapshotList", ""); #endif FreeSnapshotList_UpToNode(NULL); @@ -133,11 +127,10 @@ void FreeSnapshotList() snapshot_current = NULL; } -void ReduceSnapshotList() +static void ReduceSnapshotList(void) { #if DEBUG_SNAPSHOTS - printf("::: (Reducing number of snapshots from %d ", - num_snapshots); + int num_snapshots_last = num_snapshots; #endif // maximum number of snapshots exceeded -- thin out list of snapshots @@ -164,13 +157,16 @@ void ReduceSnapshotList() } #if DEBUG_SNAPSHOTS - printf("to %d.)\n", num_snapshots); + Debug("snapshot:ReduceSnapshotList", + "(Reducing number of snapshots from %d to %d.)", + num_snapshots_last, num_snapshots); #if 0 node = snapshot_list; while (node) { - printf("::: key: %s\n", node->key); + Debug("snapshot:ReduceSnapshotList", "key: %s", node->key); + node = node->next; } #endif @@ -191,9 +187,10 @@ void SaveSnapshotToList(ListNode *snapshot_buffers) FreeSnapshotList_UpToNode(snapshot_current); #if DEBUG_SNAPSHOTS - printf("::: SaveSnapshotToList() [%d] [%d snapshots, %d buffers, %d bytes]\n", - next_snapshot_key, num_snapshots, - num_snapshot_buffers, num_snapshot_bytes); + Debug("snapshot:SaveSnapshotToList", + "[%d] [%d snapshots, %d buffers, %d bytes]", + next_snapshot_key, num_snapshots, + num_snapshot_buffers, num_snapshot_bytes); #endif addNodeToList(&snapshot_list, i_to_a(next_snapshot_key), @@ -204,11 +201,11 @@ void SaveSnapshotToList(ListNode *snapshot_buffers) num_snapshots++; next_snapshot_key++; - if (num_snapshot_bytes > MAX_SNAPSHOT_BYTES) + if (num_snapshot_bytes > setup.engine_snapshot_memory) ReduceSnapshotList(); } -boolean LoadSnapshotSingle() +boolean LoadSnapshotSingle(void) { if (snapshot_single) { @@ -230,7 +227,7 @@ boolean LoadSnapshotFromList_Older(int steps) LoadSnapshotBuffers(snapshot_current->content); #if DEBUG_SNAPSHOTS - printf("::: LoadSnapshotFromList_Older() [%s]\n", snapshot_current->key); + Debug("snapshot:LoadSnapshotFromList_Older", "[%s]", snapshot_current->key); #endif return TRUE; @@ -249,7 +246,7 @@ boolean LoadSnapshotFromList_Newer(int steps) LoadSnapshotBuffers(snapshot_current->content); #if DEBUG_SNAPSHOTS - printf("::: LoadSnapshotFromList_Newer() [%s]\n", snapshot_current->key); + Debug("snapshot:LoadSnapshotFromList_Newer", "[%s]", snapshot_current->key); #endif return TRUE; @@ -258,7 +255,7 @@ boolean LoadSnapshotFromList_Newer(int steps) return FALSE; } -boolean CheckSnapshotList() +boolean CheckSnapshotList(void) { return (snapshot_list ? TRUE : FALSE); }