printf("Player %d %sactive.\n",
i + 1, (stored_player[i].active ? "" : "not "));
}
+
+#if 0
+ printf("::: starting game [%d]\n", FrameCounter);
+#endif
}
void InitMovDir(int x, int y)
int rnd_value = 24;
int rnd = RND(rnd_value);
+#if 0
+ if (FrameCounter < 1 && x == 0 && y == 29)
+ printf(":2: %d/%d: %d [%d]\n", x, y, MovDir[x][y], FrameCounter);
+#endif
+
if (can_move_on && rnd > rnd_value / 8)
MovDir[x][y] = old_move_dir;
else if (can_turn_left && can_turn_right)
xx = x + move_xy[MovDir[x][y]].x;
yy = y + move_xy[MovDir[x][y]].y;
+#if 0
+ if (FrameCounter < 1 && x == 0 && y == 29)
+ printf(":3: %d/%d: %d (%d/%d: %d) [%d]\n", x, y, MovDir[x][y],
+ xx, yy, Feld[xx][yy],
+ FrameCounter);
+#endif
+
+#if 1
+ if (!IN_LEV_FIELD_AND_IS_FREE(xx, yy))
+ MovDir[x][y] = old_move_dir;
+#else
if (!IS_FREE(xx, yy))
MovDir[x][y] = old_move_dir;
+#endif
+
+#if 0
+ if (FrameCounter < 1 && x == 0 && y == 29)
+ printf(":4: %d/%d: %d [%d]\n", x, y, MovDir[x][y], FrameCounter);
+#endif
MovDelay[x][y] = 0;
}
{
int direction = MovDir[x][y];
-#if 1
+#if 0
GfxDir[x][y] = MovDir[x][y];
#endif
TurnRoundExt(x, y);
-#if 0
+#if 1
GfxDir[x][y] = MovDir[x][y];
#endif
if (direction != MovDir[x][y])
GfxFrame[x][y] = 0;
-#if 0
+#if 1
if (MovDelay[x][y])
- GfxAction[x][y] = ACTION_XXX_LEFT + MV_DIR_BIT(direction);
+ GfxAction[x][y] = ACTION_TURNING_FROM_LEFT + MV_DIR_BIT(direction);
#else
if (MovDelay[x][y])
GfxAction[x][y] = ACTION_WAITING;
return;
#if 1
- /* !!! this should be handled more generic (not only for mole) !!! */
if (MovDelay[x][y] == 0)
GfxAction[x][y] = ACTION_DEFAULT;
#else
#endif
#endif
+#if 0
+ if (FrameCounter < 1 && x == 0 && y == 29)
+ printf(":1: %d/%d: %d [%d]\n", x, y, MovDir[x][y], FrameCounter);
+#endif
+
if (!MovDelay[x][y]) /* start new movement phase */
{
/* all objects that can change their move direction after each step
{
TurnRound(x, y);
+#if 0
+ if (FrameCounter < 1 && x == 0 && y == 29)
+ printf(":9: %d: %d [%d]\n", y, MovDir[x][y], FrameCounter);
+#endif
+
if (MovDelay[x][y] && (element == EL_BUG ||
element == EL_SPACESHIP ||
element == EL_SP_SNIKSNAK ||
{
TestIfBadThingTouchesHero(newx, newy);
TestIfBadThingTouchesFriend(newx, newy);
- TestIfBadThingTouchesOtherBadThing(newx, newy);
+
+ if (!IS_CUSTOM_ELEMENT(element))
+ TestIfBadThingTouchesOtherBadThing(newx, newy);
}
else if (element == EL_PENGUIN)
TestIfFriendTouchesBadThing(newx, newy);
return CheckElementSideChange(x, y, element, CH_SIDE_ANY, trigger_event, -1);
}
+#if 1
+static byte PlayerActions(struct PlayerInfo *player, byte player_action)
+{
+#if 0
+ static byte stored_player_action[MAX_PLAYERS];
+ static int num_stored_actions = 0;
+#endif
+ boolean moved = FALSE, snapped = FALSE, dropped = FALSE;
+ int left = player_action & JOY_LEFT;
+ int right = player_action & JOY_RIGHT;
+ int up = player_action & JOY_UP;
+ int down = player_action & JOY_DOWN;
+ int button1 = player_action & JOY_BUTTON_1;
+ int button2 = player_action & JOY_BUTTON_2;
+ int dx = (left ? -1 : right ? 1 : 0);
+ int dy = (up ? -1 : down ? 1 : 0);
+
+#if 0
+ stored_player_action[player->index_nr] = 0;
+ num_stored_actions++;
+#endif
+
+#if 0
+ printf("::: player %d [%d]\n", player->index_nr, FrameCounter);
+#endif
+
+ if (!player->active || tape.pausing)
+ return 0;
+
+ if (player_action)
+ {
+#if 0
+ printf("::: player %d acts [%d]\n", player->index_nr, FrameCounter);
+#endif
+
+ if (button1)
+ snapped = SnapField(player, dx, dy);
+ else
+ {
+ if (button2)
+ dropped = DropElement(player);
+
+ moved = MovePlayer(player, dx, dy);
+ }
+
+ if (tape.single_step && tape.recording && !tape.pausing)
+ {
+ if (button1 || (dropped && !moved))
+ {
+ TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
+ SnapField(player, 0, 0); /* stop snapping */
+ }
+ }
+
+#if 1
+ return player_action;
+#else
+ stored_player_action[player->index_nr] = player_action;
+#endif
+ }
+ else
+ {
+#if 0
+ printf("::: player %d waits [%d]\n", player->index_nr, FrameCounter);
+#endif
+
+ /* no actions for this player (no input at player's configured device) */
+
+ DigField(player, 0, 0, 0, 0, DF_NO_PUSH);
+ SnapField(player, 0, 0);
+ CheckGravityMovement(player);
+
+ if (player->MovPos == 0)
+ InitPlayerGfxAnimation(player, ACTION_DEFAULT, player->MovDir);
+
+ if (player->MovPos == 0) /* needed for tape.playing */
+ player->is_moving = FALSE;
+
+ return 0;
+ }
+
+#if 0
+ if (tape.recording && num_stored_actions >= MAX_PLAYERS)
+ {
+ printf("::: player %d recorded [%d]\n", player->index_nr, FrameCounter);
+
+ TapeRecordAction(stored_player_action);
+ num_stored_actions = 0;
+ }
+#endif
+}
+
+#else
+
static void PlayerActions(struct PlayerInfo *player, byte player_action)
{
static byte stored_player_action[MAX_PLAYERS];
stored_player_action[player->index_nr] = 0;
num_stored_actions++;
+ printf("::: player %d [%d]\n", player->index_nr, FrameCounter);
+
if (!player->active || tape.pausing)
return;
if (player_action)
{
+ printf("::: player %d acts [%d]\n", player->index_nr, FrameCounter);
+
if (button1)
snapped = SnapField(player, dx, dy);
else
}
else
{
+ printf("::: player %d waits [%d]\n", player->index_nr, FrameCounter);
+
/* no actions for this player (no input at player's configured device) */
DigField(player, 0, 0, 0, 0, DF_NO_PUSH);
if (tape.recording && num_stored_actions >= MAX_PLAYERS)
{
+ printf("::: player %d recorded [%d]\n", player->index_nr, FrameCounter);
+
TapeRecordAction(stored_player_action);
num_stored_actions = 0;
}
}
+#endif
void GameActions()
{
int i, x, y, element, graphic;
byte *recorded_player_action;
byte summarized_player_action = 0;
+#if 1
+ byte tape_action[MAX_PLAYERS];
+#endif
if (game_status != GAME_MODE_PLAYING)
return;
if (tape.pausing)
return;
+#if 0
+ printf("::: getting new tape action [%d]\n", FrameCounter);
+#endif
+
recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
for (i=0; i<MAX_PLAYERS; i++)
if (!options.network && !setup.team_mode)
local_player->effective_action = summarized_player_action;
- for (i=0; i<MAX_PLAYERS; i++)
+ for (i=0; i < MAX_PLAYERS; i++)
{
int actual_player_action = stored_player[i].effective_action;
if (recorded_player_action)
actual_player_action = recorded_player_action[i];
- PlayerActions(&stored_player[i], actual_player_action);
+ tape_action[i] = PlayerActions(&stored_player[i], actual_player_action);
+
ScrollPlayer(&stored_player[i], SCROLL_GO_ON);
}
+#if 1
+ if (tape.recording)
+ TapeRecordAction(tape_action);
+#endif
+
network_player_action_received = FALSE;
ScrollScreen(NULL, SCROLL_GO_ON);
{
DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
+#if 0
+ if (element == EL_BUG)
+ printf("::: %d, %d\n", graphic, GfxFrame[x][y]);
+#endif
+
#if 0
if (element == EL_MOLE)
printf("::: %d, %d\n", graphic, GfxFrame[x][y]);