+static void ReduceSnapshotList(void)
+{
+#if DEBUG_SNAPSHOTS
+ int num_snapshots_last = num_snapshots;
+#endif
+
+ // maximum number of snapshots exceeded -- thin out list of snapshots
+ ListNode *node = snapshot_list;
+ int num_snapshots_to_skip = num_snapshots / 10;
+
+ // do not remove the newest snapshots from the list
+ while (node && num_snapshots_to_skip--)
+ node = node->next;
+
+ // remove every second snapshot from the remaining list
+ while (node)
+ {
+ // never delete the first list node (snapshot at game start)
+ if (node->next == NULL)
+ break;
+
+ // in alternation, delete one node from the list ...
+ deleteNodeFromList(&node, node->key, FreeSnapshot);
+ num_snapshots--;
+
+ // ... and keep one node (which always exists here)
+ node = node->next;
+ }
+
+#if DEBUG_SNAPSHOTS
+ Debug("snapshot:ReduceSnapshotList",
+ "(Reducing number of snapshots from %d to %d.)",
+ num_snapshots_last, num_snapshots);
+
+#if 0
+ node = snapshot_list;
+ while (node)
+ {
+ Debug("snapshot:ReduceSnapshotList", "key: %s", node->key);
+
+ node = node->next;
+ }
+#endif
+#endif
+}
+