#if USE_DELAYED_GFX_REDRAW
#define TEST_DrawLevelField(x, y) \
GfxRedraw[x][y] |= GFX_REDRAW_TILE
-#define TEST_DrawLevelFieldCrumbledSand(x, y) \
+#define TEST_DrawLevelFieldCrumbled(x, y) \
GfxRedraw[x][y] |= GFX_REDRAW_TILE_CRUMBLED
-#define TEST_DrawLevelFieldCrumbledSandNeighbours(x, y) \
+#define TEST_DrawLevelFieldCrumbledNeighbours(x, y) \
GfxRedraw[x][y] |= GFX_REDRAW_TILE_CRUMBLED_NEIGHBOURS
#define TEST_DrawTwinkleOnField(x, y) \
GfxRedraw[x][y] |= GFX_REDRAW_TILE_TWINKLED
#else
#define TEST_DrawLevelField(x, y) \
DrawLevelField(x, y)
-#define TEST_DrawLevelFieldCrumbledSand(x, y) \
- DrawLevelFieldCrumbledSand(x, y)
-#define TEST_DrawLevelFieldCrumbledSandNeighbours(x, y) \
- DrawLevelFieldCrumbledSandNeighbours(x, y)
+#define TEST_DrawLevelFieldCrumbled(x, y) \
+ DrawLevelFieldCrumbled(x, y)
+#define TEST_DrawLevelFieldCrumbledNeighbours(x, y) \
+ DrawLevelFieldCrumbledNeighbours(x, y)
#define TEST_DrawTwinkleOnField(x, y) \
DrawTwinkleOnField(x, y)
#endif
static boolean recursion_loop_detected;
static boolean recursion_loop_element;
+static int map_player_action[MAX_PLAYERS];
+
/* ------------------------------------------------------------------------- */
/* definition of elements that automatically change to other elements after */
local_player->LevelSolved_CountingTime :
level.game_engine_type == GAME_ENGINE_TYPE_EM ?
level.native_em_level->lev->time :
+ level.game_engine_type == GAME_ENGINE_TYPE_SP ?
+ level.native_sp_level->game_sp->time_played :
level.time == 0 ? TimePlayed : TimeLeft);
int score = (local_player->LevelSolved ?
local_player->LevelSolved_CountingScore :
level.game_engine_type == GAME_ENGINE_TYPE_EM ?
level.native_em_level->lev->score :
+ level.game_engine_type == GAME_ENGINE_TYPE_SP ?
+ level.native_sp_level->game_sp->score :
local_player->score);
int gems = (level.game_engine_type == GAME_ENGINE_TYPE_EM ?
level.native_em_level->lev->required :
+ level.game_engine_type == GAME_ENGINE_TYPE_SP ?
+ level.native_sp_level->game_sp->infotrons_still_needed :
local_player->gems_still_needed);
int exit_closed = (level.game_engine_type == GAME_ENGINE_TYPE_EM ?
level.native_em_level->lev->required > 0 :
+ level.game_engine_type == GAME_ENGINE_TYPE_SP ?
+ level.native_sp_level->game_sp->infotrons_still_needed > 0 :
local_player->gems_still_needed > 0 ||
local_player->sokobanfields_still_needed > 0 ||
local_player->lights_still_needed > 0);
{
for (i = 0; i < MAX_PLAYERS; i++)
{
+ /* only one player in Supaplex game engine */
+ if (level.game_engine_type == GAME_ENGINE_TYPE_SP && i > 0)
+ break;
+
for (k = 0; k < MAX_NUM_KEYS; k++)
{
if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value +=
level.native_em_level->ply[i]->dynamite;
+ else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+ game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value +=
+ level.native_sp_level->game_sp->red_disk_count;
else
game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value +=
stored_player[i].inventory_size;
if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value +=
level.native_em_level->ply[player_nr]->dynamite;
+ else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+ game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value +=
+ level.native_sp_level->game_sp->red_disk_count;
else
game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value +=
stored_player[player_nr].inventory_size;
player->present = FALSE;
player->active = FALSE;
+ player->mapped = FALSE;
+
player->killed = FALSE;
player->reanimated = FALSE;
player->LevelSolved_SaveScore = FALSE;
player->LevelSolved_CountingTime = 0;
player->LevelSolved_CountingScore = 0;
+
+ map_player_action[i] = i;
}
network_player_action_received = FALSE;
game.belt_dir_nr[i] = 3; /* not moving, next moving left */
#if USE_NEW_PLAYER_ASSIGNMENTS
+ /* !!! SAME AS init.c:InitPlayerInfo() -- FIX THIS !!! */
+ /* choose default local player */
+ local_player = &stored_player[0];
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ stored_player[i].connected = FALSE;
+
+ local_player->connected = TRUE;
+ /* !!! SAME AS init.c:InitPlayerInfo() -- FIX THIS !!! */
+
+ if (tape.playing)
+ {
+ /* try to guess locally connected team mode players (needed for correct
+ assignment of player figures from level to locally playing players) */
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (tape.player_participates[i])
+ stored_player[i].connected = TRUE;
+ }
+ else if (setup.team_mode && !options.network)
+ {
+ /* try to guess locally connected team mode players (needed for correct
+ assignment of player figures from level to locally playing players) */
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (setup.input[i].use_joystick ||
+ setup.input[i].key.left != KSYM_UNDEFINED)
+ stored_player[i].connected = TRUE;
+ }
+
+#if 0
+ for (i = 0; i < MAX_PLAYERS; i++)
+ printf("::: player %d: %s\n", i,
+ (stored_player[i].connected ? "connected" : "not connected"));
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ printf("::: player %d: %s\n", i,
+ (stored_player[i].present ? "present" : "not present"));
+#endif
+
/* check if any connected player was not found in playfield */
for (i = 0; i < MAX_PLAYERS; i++)
{
if (player->connected && !player->present)
{
- for (j = 0; j < MAX_PLAYERS; j++)
+ struct PlayerInfo *field_player = NULL;
+
+#if 0
+ printf("::: looking for field player for player %d ...\n", i);
+#endif
+
+ /* assign first free player found that is present in the playfield */
+
+ /* first try: look for unmapped playfield player that is not connected */
+ if (field_player == NULL)
+ for (j = 0; j < MAX_PLAYERS; j++)
+ if (stored_player[j].present &&
+ !stored_player[j].mapped &&
+ !stored_player[j].connected)
+ field_player = &stored_player[j];
+
+ /* second try: look for *any* unmapped playfield player */
+ if (field_player == NULL)
+ for (j = 0; j < MAX_PLAYERS; j++)
+ if (stored_player[j].present &&
+ !stored_player[j].mapped)
+ field_player = &stored_player[j];
+
+ if (field_player != NULL)
{
- struct PlayerInfo *some_player = &stored_player[j];
- int jx = some_player->jx, jy = some_player->jy;
+ int jx = field_player->jx, jy = field_player->jy;
- /* assign first free player found that is present in the playfield */
- if (some_player->present && !some_player->connected)
- {
- player->present = FALSE;
- player->active = FALSE;
+#if 0
+ printf("::: found player figure %d\n", field_player->index_nr);
+#endif
- some_player->present = TRUE;
- some_player->active = TRUE;
+ player->present = FALSE;
+ player->active = FALSE;
- /*
- player->initial_element = some_player->initial_element;
- player->artwork_element = some_player->artwork_element;
+ field_player->present = TRUE;
+ field_player->active = TRUE;
- player->block_last_field = some_player->block_last_field;
- player->block_delay_adjustment = some_player->block_delay_adjustment;
- */
+ /*
+ player->initial_element = field_player->initial_element;
+ player->artwork_element = field_player->artwork_element;
- StorePlayer[jx][jy] = some_player->element_nr;
+ player->block_last_field = field_player->block_last_field;
+ player->block_delay_adjustment = field_player->block_delay_adjustment;
+ */
- some_player->jx = some_player->last_jx = jx;
- some_player->jy = some_player->last_jy = jy;
+ StorePlayer[jx][jy] = field_player->element_nr;
- if (local_player == player)
- local_player = some_player;
+ field_player->jx = field_player->last_jx = jx;
+ field_player->jy = field_player->last_jy = jy;
- break;
- }
+ if (local_player == player)
+ local_player = field_player;
+
+ map_player_action[field_player->index_nr] = i;
+
+ field_player->mapped = TRUE;
+
+#if 0
+ printf("::: map_player_action[%d] == %d\n",
+ field_player->index_nr, i);
+#endif
}
}
+
+ if (player->connected && player->present)
+ player->mapped = TRUE;
}
#else
{
for (j = 0; j < MAX_PLAYERS; j++)
{
- struct PlayerInfo *some_player = &stored_player[j];
- int jx = some_player->jx, jy = some_player->jy;
+ struct PlayerInfo *field_player = &stored_player[j];
+ int jx = field_player->jx, jy = field_player->jy;
/* assign first free player found that is present in the playfield */
- if (some_player->present && !some_player->connected)
+ if (field_player->present && !field_player->connected)
{
player->present = TRUE;
player->active = TRUE;
- some_player->present = FALSE;
- some_player->active = FALSE;
+ field_player->present = FALSE;
+ field_player->active = FALSE;
- player->initial_element = some_player->initial_element;
- player->artwork_element = some_player->artwork_element;
+ player->initial_element = field_player->initial_element;
+ player->artwork_element = field_player->artwork_element;
- player->block_last_field = some_player->block_last_field;
- player->block_delay_adjustment = some_player->block_delay_adjustment;
+ player->block_last_field = field_player->block_last_field;
+ player->block_delay_adjustment = field_player->block_delay_adjustment;
StorePlayer[jx][jy] = player->element_nr;
}
#endif
+#if 0
+ printf("::: local_player->present == %d\n", local_player->present);
+#endif
+
if (tape.playing)
{
/* when playing a tape, eliminate all players who do not participate */
+#if USE_NEW_PLAYER_ASSIGNMENTS
for (i = 0; i < MAX_PLAYERS; i++)
{
- if (stored_player[i].active && !tape.player_participates[i])
+ if (stored_player[i].active &&
+ !tape.player_participates[map_player_action[i]])
{
struct PlayerInfo *player = &stored_player[i];
int jx = player->jx, jy = player->jy;
Feld[jx][jy] = EL_EMPTY;
}
}
+#else
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ if (stored_player[i].active &&
+ !tape.player_participates[i])
+ {
+ struct PlayerInfo *player = &stored_player[i];
+ int jx = player->jx, jy = player->jy;
+
+ player->active = FALSE;
+ StorePlayer[jx][jy] = 0;
+ Feld[jx][jy] = EL_EMPTY;
+ }
+ }
+#endif
}
else if (!options.network && !setup.team_mode) /* && !tape.playing */
{
/* when recording the game, store which players take part in the game */
if (tape.recording)
{
+#if USE_NEW_PLAYER_ASSIGNMENTS
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (stored_player[i].connected)
+ tape.player_participates[i] = TRUE;
+#else
for (i = 0; i < MAX_PLAYERS; i++)
if (stored_player[i].active)
tape.player_participates[i] = TRUE;
+#endif
}
if (options.debug)
/* blit playfield from scroll buffer to normal back buffer for fading in */
BlitScreenToBitmap_EM(backbuffer);
}
+ else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+ {
+ InitGameEngine_SP();
+
+ /* blit playfield from scroll buffer to normal back buffer for fading in */
+ BlitScreenToBitmap_SP(backbuffer);
+ }
else
{
DrawLevel();
if (quick_relocation)
{
- int offset = game.scroll_delay_value;
-
if (!IN_VIS_FIELD(SCREENX(x), SCREENY(y)) || center_screen)
{
if (!level.shifted_relocation || center_screen)
}
else
{
+#if 1
+ if (!level.shifted_relocation || center_screen)
+ {
+ /* quick relocation (without scrolling), with centering of screen */
+
+ scroll_x = (x < SBX_Left + MIDPOSX ? SBX_Left :
+ x > SBX_Right + MIDPOSX ? SBX_Right :
+ x - MIDPOSX);
+
+ scroll_y = (y < SBY_Upper + MIDPOSY ? SBY_Upper :
+ y > SBY_Lower + MIDPOSY ? SBY_Lower :
+ y - MIDPOSY);
+ }
+ else
+ {
+ /* quick relocation (without scrolling), but do not center screen */
+
+ int center_scroll_x = (old_x < SBX_Left + MIDPOSX ? SBX_Left :
+ old_x > SBX_Right + MIDPOSX ? SBX_Right :
+ old_x - MIDPOSX);
+
+ int center_scroll_y = (old_y < SBY_Upper + MIDPOSY ? SBY_Upper :
+ old_y > SBY_Lower + MIDPOSY ? SBY_Lower :
+ old_y - MIDPOSY);
+
+ int offset_x = x + (scroll_x - center_scroll_x);
+ int offset_y = y + (scroll_y - center_scroll_y);
+
+ scroll_x = (offset_x < SBX_Left + MIDPOSX ? SBX_Left :
+ offset_x > SBX_Right + MIDPOSX ? SBX_Right :
+ offset_x - MIDPOSX);
+
+ scroll_y = (offset_y < SBY_Upper + MIDPOSY ? SBY_Upper :
+ offset_y > SBY_Lower + MIDPOSY ? SBY_Lower :
+ offset_y - MIDPOSY);
+ }
+#else
/* quick relocation (without scrolling), inside visible screen area */
+ int offset = game.scroll_delay_value;
+
if ((move_dir == MV_LEFT && scroll_x > x - MIDPOSX + offset) ||
(move_dir == MV_RIGHT && scroll_x < x - MIDPOSX - offset))
scroll_x = x - MIDPOSX + (scroll_x < x - MIDPOSX ? -offset : +offset);
/* don't scroll over playfield boundaries */
if (scroll_y < SBY_Upper || scroll_y > SBY_Lower)
scroll_y = (scroll_y < SBY_Upper ? SBY_Upper : SBY_Lower);
+#endif
}
RedrawPlayfield(TRUE, 0,0,0,0);
Feld[jx][jy] = el_player;
InitPlayerField(jx, jy, el_player, TRUE);
+ /* "InitPlayerField()" above sets Feld[jx][jy] to EL_EMPTY, but it may be
+ possible that the relocation target field did not contain a player element,
+ but a walkable element, to which the new player was relocated -- in this
+ case, restore that (already initialized!) element on the player field */
if (!ELEM_IS_PLAYER(element)) /* player may be set on walkable element */
{
- Feld[jx][jy] = element;
+ Feld[jx][jy] = element; /* restore previously existing element */
+#if 0
+ /* !!! do not initialize already initialized element a second time !!! */
+ /* (this causes at least problems with "element creation" CE trigger for
+ already existing elements, and existing Sokoban fields counted twice) */
InitField(jx, jy, FALSE);
+#endif
}
/* only visually relocate centered player */
CheckTriggeredElementChangeByPlayer(jx, jy, element, CE_PLAYER_ENTERS_X,
player->index_bit, enter_side);
+
+#if 1
+ if (player->is_switching)
+ {
+ /* ensure that relocation while still switching an element does not cause
+ a new element to be treated as also switched directly after relocation
+ (this is important for teleporter switches that teleport the player to
+ a place where another teleporter switch is in the same direction, which
+ would then incorrectly be treated as immediately switched before the
+ direction key that caused the switch was released) */
+
+ player->switch_x += jx - old_jx;
+ player->switch_y += jy - old_jy;
+ }
+#endif
}
void Explode(int ex, int ey, int phase, int mode)
TestIfElementTouchesCustomElement(x, y);
if (GFX_CRUMBLED(element))
- TEST_DrawLevelFieldCrumbledSandNeighbours(x, y);
+ TEST_DrawLevelFieldCrumbledNeighbours(x, y);
if (IS_PLAYER(x, y) && !PLAYERINFO(x, y)->present)
StorePlayer[x][y] = 0;
int frame = getGraphicAnimationFrame(graphic, GfxFrame[x][y]);
if (phase == delay)
- TEST_DrawLevelFieldCrumbledSand(x, y);
+ TEST_DrawLevelFieldCrumbled(x, y);
if (IS_WALKABLE_OVER(Back[x][y]) && Back[x][y] != EL_EMPTY)
{
/* uncrumble neighbour fields, if needed */
if (element == EL_INVISIBLE_SAND)
- TEST_DrawLevelFieldCrumbledSandNeighbours(x, y);
+ TEST_DrawLevelFieldCrumbledNeighbours(x, y);
}
else if (element == EL_INVISIBLE_STEELWALL_ACTIVE ||
element == EL_INVISIBLE_WALL_ACTIVE ||
/* re-crumble neighbour fields, if needed */
if (element == EL_INVISIBLE_SAND)
- TEST_DrawLevelFieldCrumbledSandNeighbours(x, y);
+ TEST_DrawLevelFieldCrumbledNeighbours(x, y);
}
}
}
/* uncrumble neighbour fields, if needed */
if (element == EL_INVISIBLE_SAND)
- TEST_DrawLevelFieldCrumbledSandNeighbours(x, y);
+ TEST_DrawLevelFieldCrumbledNeighbours(x, y);
}
else if (element == EL_INVISIBLE_STEELWALL_ACTIVE ||
element == EL_INVISIBLE_WALL_ACTIVE ||
/* re-crumble neighbour fields, if needed */
if (element == EL_INVISIBLE_SAND)
- TEST_DrawLevelFieldCrumbledSandNeighbours(x, y);
+ TEST_DrawLevelFieldCrumbledNeighbours(x, y);
}
}
}
if (IN_SCR_FIELD(sx, sy))
{
- TEST_DrawLevelFieldCrumbledSand(xx, yy);
+ TEST_DrawLevelFieldCrumbled(xx, yy);
DrawGraphic(sx, sy, flame_graphic, frame);
}
}
{
Feld[x][y] = EL_SAND;
- TEST_DrawLevelFieldCrumbledSandNeighbours(x, y);
+ TEST_DrawLevelFieldCrumbledNeighbours(x, y);
}
else if (element == EL_QUICKSAND_FILLING)
{
InitField(x, y, FALSE);
if (GFX_CRUMBLED(Feld[x][y]))
- TEST_DrawLevelFieldCrumbledSandNeighbours(x, y);
+ TEST_DrawLevelFieldCrumbledNeighbours(x, y);
if (ELEM_IS_PLAYER(move_leave_element))
RelocatePlayer(x, y, move_leave_element);
/* if new animation frame was drawn, correct crumbled sand border */
if (IS_NEW_FRAME(GfxFrame[x][y], graphic))
- TEST_DrawLevelFieldCrumbledSand(x, y);
+ TEST_DrawLevelFieldCrumbled(x, y);
}
static int getSpecialActionElement(int element, int number, int base_element)
TEST_DrawLevelField(x, y);
if (GFX_CRUMBLED(new_element))
- TEST_DrawLevelFieldCrumbledSandNeighbours(x, y);
+ TEST_DrawLevelFieldCrumbledNeighbours(x, y);
}
#if 1
if (tape.single_step && tape.recording && !tape.pausing)
{
+#if 1
+ /* as it is called "single step mode", just return to pause mode when the
+ player stopped moving after one tile (or never starts moving at all) */
+ if (!player->is_moving)
+#else
+ /* this is buggy: there are quite some cases where the single step mode
+ does not return to pause mode (like pushing things that don't move
+ or simply by trying to run against a wall) */
if (button1 || (dropped && !moved))
+#endif
{
TapeTogglePause(TAPE_TOGGLE_AUTOMATIC);
SnapField(player, 0, 0); /* stop snapping */
{
int i;
+ /* !!! SAME CODE AS IN "GameActions()" -- FIX THIS !!! */
if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
{
if (level.native_em_level->lev->home == 0) /* all players at home */
level.native_em_level->ply[3]->alive == 0) /* all dead */
AllPlayersGone = TRUE;
}
+ else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+ {
+ if (game_sp.LevelSolved &&
+ !game_sp.GameOver) /* game won */
+ {
+ PlayerWins(local_player);
+
+ game_sp.GameOver = TRUE;
+
+ AllPlayersGone = TRUE;
+ }
+
+ if (game_sp.GameOver) /* game lost */
+ AllPlayersGone = TRUE;
+ }
if (TimeFrames >= FRAMES_PER_SECOND)
{
if (game.restart_level)
StartGameActions(options.network, setup.autorecord, level.random_seed);
+ /* !!! SAME CODE AS IN "CheckLevelTime()" -- FIX THIS !!! */
if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
{
if (level.native_em_level->lev->home == 0) /* all players at home */
level.native_em_level->ply[3]->alive == 0) /* all dead */
AllPlayersGone = TRUE;
}
+ else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+ {
+ if (game_sp.LevelSolved &&
+ !game_sp.GameOver) /* game won */
+ {
+ PlayerWins(local_player);
+
+ game_sp.GameOver = TRUE;
+
+ AllPlayersGone = TRUE;
+ }
+
+ if (game_sp.GameOver) /* game lost */
+ AllPlayersGone = TRUE;
+ }
if (local_player->LevelSolved && !local_player->LevelSolved_GameEnd)
GameWon();
if (tape.recording)
TapeRecordAction(tape_action);
+#if USE_NEW_PLAYER_ASSIGNMENTS
+ {
+ byte mapped_action[MAX_PLAYERS];
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ mapped_action[i] = stored_player[map_player_action[i]].effective_action;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ stored_player[i].effective_action = mapped_action[i];
+ }
+#endif
+
if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
{
GameActions_EM_Main();
}
+ else if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+ {
+ GameActions_SP_Main();
+ }
else
{
GameActions_RND();
AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */
}
+void GameActions_SP_Main()
+{
+ byte effective_action[MAX_PLAYERS];
+ boolean warp_mode = (tape.playing && tape.warp_forward && !tape.pausing);
+ int i;
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ effective_action[i] = stored_player[i].effective_action;
+
+ GameActions_SP(effective_action, warp_mode);
+
+ CheckLevelTime();
+
+ AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */
+}
+
void GameActions_RND()
{
int magic_wall_x = 0, magic_wall_y = 0;
DrawLevelField(x, y);
if (GfxRedraw[x][y] & GFX_REDRAW_TILE_CRUMBLED)
- DrawLevelFieldCrumbledSand(x, y);
+ DrawLevelFieldCrumbled(x, y);
if (GfxRedraw[x][y] & GFX_REDRAW_TILE_CRUMBLED_NEIGHBOURS)
- DrawLevelFieldCrumbledSandNeighbours(x, y);
+ DrawLevelFieldCrumbledNeighbours(x, y);
if (GfxRedraw[x][y] & GFX_REDRAW_TILE_TWINKLED)
DrawTwinkleOnField(x, y);
if (Feld[jx][jy] == EL_EXIT_OPEN ||
Feld[jx][jy] == EL_EM_EXIT_OPEN ||
+#if 1
+ Feld[jx][jy] == EL_EM_EXIT_OPENING ||
+#endif
Feld[jx][jy] == EL_STEEL_EXIT_OPEN ||
Feld[jx][jy] == EL_EM_STEEL_EXIT_OPEN ||
+#if 1
+ Feld[jx][jy] == EL_EM_STEEL_EXIT_OPENING ||
+#endif
Feld[jx][jy] == EL_SP_EXIT_OPEN ||
Feld[jx][jy] == EL_SP_EXIT_OPENING) /* <-- special case */
{
}
else if (element == EL_EXIT_OPEN ||
element == EL_EM_EXIT_OPEN ||
+#if 1
+ element == EL_EM_EXIT_OPENING ||
+#endif
element == EL_STEEL_EXIT_OPEN ||
element == EL_EM_STEEL_EXIT_OPEN ||
+#if 1
+ element == EL_EM_STEEL_EXIT_OPENING ||
+#endif
element == EL_SP_EXIT_OPEN ||
element == EL_SP_EXIT_OPENING)
{
PlayLevelSoundElementAction(nextx, nexty, EL_SOKOBAN_FIELD_EMPTY,
ACTION_FILLING);
+#if 1
+ if (local_player->sokobanfields_still_needed == 0 &&
+ (game.emulation == EMU_SOKOBAN || level.auto_exit_sokoban))
+#else
if (local_player->sokobanfields_still_needed == 0 &&
game.emulation == EMU_SOKOBAN)
+#endif
{
PlayerWins(player);
}
}
+void PlayLevelSound_SP(int xx, int yy, int element_sp, int action_sp)
+{
+ int element = map_element_SP_to_RND(element_sp);
+ int action = map_action_SP_to_RND(action_sp);
+ int offset = (setup.sp_show_border_elements ? 0 : 1);
+ int x = xx - offset;
+ int y = yy - offset;
+
+#if 0
+ printf("::: %d -> %d\n", element_sp, action_sp);
+#endif
+
+ PlayLevelSoundElementAction(x, y, element, action);
+}
+
#if 0
void ChangeTime(int value)
{
/* game engine snapshot handling functions */
/* ------------------------------------------------------------------------- */
-#define ARGS_ADDRESS_AND_SIZEOF(x) (&(x)), (sizeof(x))
-
struct EngineSnapshotInfo
{
/* runtime values for custom element collect score */
int choice_pos[NUM_GROUP_ELEMENTS];
/* runtime values for belt position animations */
- int belt_graphic[4 * NUM_BELT_PARTS];
- int belt_anim_mode[4 * NUM_BELT_PARTS];
-};
-
-struct EngineSnapshotNodeInfo
-{
- void *buffer_orig;
- void *buffer_copy;
- int size;
+ int belt_graphic[4][NUM_BELT_PARTS];
+ int belt_anim_mode[4][NUM_BELT_PARTS];
};
static struct EngineSnapshotInfo engine_snapshot_rnd;
-static ListNode *engine_snapshot_list = NULL;
static char *snapshot_level_identifier = NULL;
static int snapshot_level_nr = -1;
-void FreeEngineSnapshot()
-{
- while (engine_snapshot_list != NULL)
- deleteNodeFromList(&engine_snapshot_list, engine_snapshot_list->key,
- checked_free);
-
- setString(&snapshot_level_identifier, NULL);
- snapshot_level_nr = -1;
-}
-
static void SaveEngineSnapshotValues_RND()
{
static int belt_base_active_element[4] =
int graphic = el2img(element);
int anim_mode = graphic_info[graphic].anim_mode;
- engine_snapshot_rnd.belt_graphic[i * 4 + j] = graphic;
- engine_snapshot_rnd.belt_anim_mode[i * 4 + j] = anim_mode;
+ engine_snapshot_rnd.belt_graphic[i][j] = graphic;
+ engine_snapshot_rnd.belt_anim_mode[i][j] = anim_mode;
}
}
}
{
for (j = 0; j < NUM_BELT_PARTS; j++)
{
- int graphic = engine_snapshot_rnd.belt_graphic[i * 4 + j];
- int anim_mode = engine_snapshot_rnd.belt_anim_mode[i * 4 + j];
+ int graphic = engine_snapshot_rnd.belt_graphic[i][j];
+ int anim_mode = engine_snapshot_rnd.belt_anim_mode[i][j];
graphic_info[graphic].anim_mode = anim_mode;
}
}
}
-static 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);
-}
-
void SaveEngineSnapshot()
{
- FreeEngineSnapshot(); /* free previous snapshot, if needed */
-
- if (level_editor_test_game) /* do not save snapshots from editor */
+ /* do not save snapshots from editor */
+ if (level_editor_test_game)
return;
+ /* free previous snapshot buffers, if needed */
+ FreeEngineSnapshotBuffers();
+
/* copy some special values to a structure better suited for the snapshot */
SaveEngineSnapshotValues_RND();
SaveEngineSnapshotValues_EM();
+ SaveEngineSnapshotValues_SP();
/* save values stored in special snapshot structure */
SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_rnd));
SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_em));
+ SaveEngineSnapshotBuffer(ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_sp));
/* save further RND engine values */
snapshot_level_nr = level_nr;
#if 0
- ListNode *node = engine_snapshot_list;
+ ListNode *node = engine_snapshot_list_rnd;
int num_bytes = 0;
while (node != NULL)
#endif
}
-static void LoadEngineSnapshotBuffer(struct EngineSnapshotNodeInfo *bi)
-{
- memcpy(bi->buffer_orig, bi->buffer_copy, bi->size);
-}
-
void LoadEngineSnapshot()
{
- ListNode *node = engine_snapshot_list;
+ /* restore generically stored snapshot buffers */
- if (engine_snapshot_list == NULL)
- return;
-
- while (node != NULL)
- {
- LoadEngineSnapshotBuffer((struct EngineSnapshotNodeInfo *)node->content);
-
- node = node->next;
- }
+ LoadEngineSnapshotBuffers();
/* restore special values from snapshot structure */
LoadEngineSnapshotValues_RND();
LoadEngineSnapshotValues_EM();
+ LoadEngineSnapshotValues_SP();
}
boolean CheckEngineSnapshot()
RedrawGadget(game_gadget[i]);
}
-static void HandleGameButtons(struct GadgetInfo *gi)
+static void HandleGameButtonsExt(int id)
{
- int id = gi->custom_id;
-
if (game_status != GAME_MODE_PLAYING)
return;
if (setup.sound_music)
{
setup.sound_music = FALSE;
+
FadeMusic();
}
else if (audio.music_available)
else if (audio.loops_available)
{
setup.sound = setup.sound_loops = TRUE;
+
SetAudioMode(setup.sound);
}
break;
else if (audio.sound_available)
{
setup.sound = setup.sound_simple = TRUE;
+
SetAudioMode(setup.sound);
}
break;
break;
}
}
+
+static void HandleGameButtons(struct GadgetInfo *gi)
+{
+ HandleGameButtonsExt(gi->custom_id);
+}
+
+void HandleSoundButtonKeys(Key key)
+{
+#if 1
+ if (key == setup.shortcut.sound_simple)
+ ClickOnGadget(game_gadget[SOUND_CTRL_ID_SIMPLE], MB_LEFTBUTTON);
+ else if (key == setup.shortcut.sound_loops)
+ ClickOnGadget(game_gadget[SOUND_CTRL_ID_LOOPS], MB_LEFTBUTTON);
+ else if (key == setup.shortcut.sound_music)
+ ClickOnGadget(game_gadget[SOUND_CTRL_ID_MUSIC], MB_LEFTBUTTON);
+#else
+ if (key == setup.shortcut.sound_simple)
+ HandleGameButtonsExt(SOUND_CTRL_ID_SIMPLE);
+ else if (key == setup.shortcut.sound_loops)
+ HandleGameButtonsExt(SOUND_CTRL_ID_LOOPS);
+ else if (key == setup.shortcut.sound_music)
+ HandleGameButtonsExt(SOUND_CTRL_ID_MUSIC);
+#endif
+}