game.scroll_delay_value =
MIN(MAX(MIN_SCROLL_DELAY, game.scroll_delay_value), MAX_SCROLL_DELAY);
+ /* ---------- initialize game engine snapshots ---------------------------- */
+ for (i = 0; i < MAX_PLAYERS; i++)
+ game.snapshot.last_action[i] = 0;
+ game.snapshot.changed_action = FALSE;
+ game.snapshot.mode = SNAPSHOT_MODE_MOVE;
+
FreeEngineSnapshotList();
}
(player->is_snapping && !player_was_snapping) ||
(player->is_dropping && !player_was_dropping))
{
- SaveEngineSnapshotToList();
+ if (!SaveEngineSnapshotToList())
+ return;
player_was_moving = FALSE;
player_was_snapping = TRUE;
byte tape_action[MAX_PLAYERS];
int i;
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+
+ // allow engine snapshot if movement attempt was stopped
+ if ((game.snapshot.last_action[i] & KEY_MOTION) != 0 &&
+ (player->action & KEY_MOTION) == 0)
+ game.snapshot.changed_action = TRUE;
+
+ // allow engine snapshot in case of snapping/dropping attempt
+ if ((game.snapshot.last_action[i] & KEY_BUTTON) == 0 &&
+ (player->action & KEY_BUTTON) != 0)
+ game.snapshot.changed_action = TRUE;
+
+ game.snapshot.last_action[i] = player->action;
+ }
+
/* detect endless loops, caused by custom element programming */
if (recursion_loop_detected && recursion_loop_depth == 0)
{
SaveSnapshotSingle(buffers);
}
-void SaveEngineSnapshotToList()
+boolean SaveEngineSnapshotToList()
{
+ boolean save_snapshot =
+ (FrameCounter == 0 ||
+ (game.snapshot.mode == SNAPSHOT_MODE_STEP) ||
+ (game.snapshot.mode == SNAPSHOT_MODE_MOVE &&
+ game.snapshot.changed_action));
+
+ game.snapshot.changed_action = FALSE;
+
+ if (!save_snapshot)
+ return FALSE;
+
ListNode *buffers = SaveEngineSnapshotBuffers();
/* finally save all snapshot buffers to snapshot list */
SaveSnapshotToList(buffers);
+
+ return TRUE;
}
void LoadEngineSnapshotValues()
#define NUM_PANEL_ELEMENTS 8
#define NUM_PANEL_CE_SCORE 8
+#define SNAPSHOT_MODE_STEP 0
+#define SNAPSHOT_MODE_MOVE 1
+
+
struct GamePanelInfo
{
struct TextPosInfo level_number;
struct XY sound_simple;
};
+struct GameSnapshotInfo
+{
+ int mode;
+
+ byte last_action[MAX_PLAYERS];
+ boolean changed_action;
+};
+
struct GameInfo
{
/* values for control panel */
/* values for random number generator initialization after snapshot */
unsigned int num_random_calls;
+
+ /* values for game engine snapshot control */
+ struct GameSnapshotInfo snapshot;
};
struct PlayerInfo
void FreeEngineSnapshotList();
void LoadEngineSnapshotSingle();
void SaveEngineSnapshotSingle();
-void SaveEngineSnapshotToList();
+boolean SaveEngineSnapshotToList();
boolean CheckEngineSnapshot();
void CreateGameButtons();
{
if (!player_was_waiting)
{
- SaveEngineSnapshotToList();
+ if (!SaveEngineSnapshotToList())
+ return;
player_was_waiting = TRUE;
}
void CheckSaveEngineSnapshot_SP(boolean murphy_is_waiting,
boolean murphy_is_dropping)
{
- static boolean player_was_waiting = FALSE;
+ static boolean player_was_waiting = TRUE;
if (murphy_is_waiting)
{
if (!player_was_waiting)
{
- SaveEngineSnapshotToList();
+ if (!SaveEngineSnapshotToList())
+ return;
player_was_waiting = TRUE;
}