X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=457748b31795dafb1581152110a543693975450a;hb=20414a1c99e248151e43daf6ef5433e943afddd6;hp=50ffaf1662b441fa85bc712a0b9be8239e35326e;hpb=dfe534c10c9825cafd54961c60fc81a56691dc55;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 50ffaf16..457748b3 100644 --- a/src/game.c +++ b/src/game.c @@ -19,12 +19,14 @@ #include "init.h" #include "files.h" #include "tape.h" -#include "joystick.h" #include "network.h" /* this switch controls how rocks move horizontally */ #define OLD_GAME_BEHAVIOUR FALSE +/* EXPERIMENTAL STUFF */ +#define USE_NEW_AMOEBA_CODE FALSE + /* for DigField() */ #define DF_NO_PUSH 0 #define DF_DIG 1 @@ -171,10 +173,10 @@ void GetPlayerConfig() setup.sound = FALSE; if (!audio.loops_available) - { setup.sound_loops = FALSE; + + if (!audio.music_available) setup.sound_music = FALSE; - } if (!video.fullscreen_available) setup.fullscreen = FALSE; @@ -268,7 +270,7 @@ static void InitField(int x, int y, boolean init_game) StorePlayer[x][y] = Feld[x][y]; - if (options.verbose) + if (options.debug) { printf("Player %d activated.\n", player->element_nr); printf("[Local player is %d and currently %s.]\n", @@ -430,6 +432,18 @@ static void InitField(int x, int y, boolean init_game) } } +void DrawGameDoorValues() +{ + DrawText(DX + XX_EMERALDS, DY + YY_EMERALDS, + int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); + DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE, + int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); + DrawText(DX + XX_SCORE, DY + YY_SCORE, + int2str(local_player->score, 5), FS_SMALL, FC_YELLOW); + DrawText(DX + XX_TIME, DY + YY_TIME, + int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); +} + void InitGame() { int i, j, x, y; @@ -437,6 +451,14 @@ void InitGame() boolean emulate_sb = TRUE; /* unless non-SOKOBAN elements found */ boolean emulate_sp = TRUE; /* unless non-SUPAPLEX elements found */ +#if DEBUG +#if USE_NEW_AMOEBA_CODE + printf("Using new amoeba code.\n"); +#else + printf("Using old amoeba code.\n"); +#endif +#endif + /* don't play tapes over network */ network_playing = (options.network && !tape.playing); @@ -480,16 +502,16 @@ void InitGame() player->frame_reset_delay = 0; - player->push_delay = 0; - player->push_delay_value = 5; - - player->move_delay = 0; player->last_move_dir = MV_NO_MOVING; player->is_moving = FALSE; + player->move_delay = -1; /* no initial move delay */ player->move_delay_value = (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED); + player->push_delay = 0; + player->push_delay_value = 5; + player->snapped = FALSE; player->last_jx = player->last_jy = 0; @@ -659,7 +681,7 @@ void InitGame() tape.player_participates[i] = TRUE; } - if (options.verbose) + if (options.debug) { for (i=0; i= GAME_VERSION_2_0) - Elementeigenschaften2[ep_slippery[i]] |= EP_BIT_SLIPPERY_GEMS; +#endif + Elementeigenschaften2[ep_em_slippery_wall[i]] |= + EP_BIT_EM_SLIPPERY_WALL; else - Elementeigenschaften2[ep_slippery[i]] &= ~EP_BIT_SLIPPERY_GEMS; + Elementeigenschaften2[ep_em_slippery_wall[i]] &= + ~EP_BIT_EM_SLIPPERY_WALL; } } @@ -766,6 +804,9 @@ void InitGame() DX + XX_LEVEL - 1, DY + YY_LEVEL + 1); } +#if 1 + DrawGameDoorValues(); +#else DrawText(DX + XX_EMERALDS, DY + YY_EMERALDS, int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE, @@ -774,8 +815,10 @@ void InitGame() int2str(local_player->score, 5), FS_SMALL, FC_YELLOW); DrawText(DX + XX_TIME, DY + YY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); +#endif UnmapGameButtons(); + UnmapTapeButtons(); game_gadget[SOUND_CTRL_ID_MUSIC]->checked = setup.sound_music; game_gadget[SOUND_CTRL_ID_LOOPS]->checked = setup.sound_loops; game_gadget[SOUND_CTRL_ID_SIMPLE]->checked = setup.sound_simple; @@ -788,12 +831,12 @@ void InitGame() OpenDoor(DOOR_OPEN_ALL); - if (setup.sound_music && num_bg_loops) - PlayMusic(level_nr % num_bg_loops); + if (setup.sound_music) + PlayMusic(level_nr); KeyboardAutoRepeatOff(); - if (options.verbose) + if (options.debug) { for (i=0; i<4; i++) printf("Player %d %sactive.\n", @@ -942,12 +985,12 @@ void GameWon() if (TimeLeft) { - if (setup.sound_loops) + if (!tape.playing && setup.sound_loops) PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP); while(TimeLeft > 0) { - if (!setup.sound_loops) + if (!tape.playing && !setup.sound_loops) PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); if (TimeLeft > 0 && !(TimeLeft % 10)) RaiseScore(level.score[SC_ZEITBONUS]); @@ -957,20 +1000,22 @@ void GameWon() TimeLeft--; DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); BackToFront(); - Delay(10); + + if (!tape.playing) + Delay(10); } - if (setup.sound_loops) + if (!tape.playing && setup.sound_loops) StopSound(SND_SIRR); } else if (level.time == 0) /* level without time limit */ { - if (setup.sound_loops) + if (!tape.playing && setup.sound_loops) PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP); while(TimePlayed < 999) { - if (!setup.sound_loops) + if (!tape.playing && !setup.sound_loops) PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); if (TimePlayed < 999 && !(TimePlayed % 10)) RaiseScore(level.score[SC_ZEITBONUS]); @@ -980,10 +1025,12 @@ void GameWon() TimePlayed++; DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FS_SMALL, FC_YELLOW); BackToFront(); - Delay(10); + + if (!tape.playing) + Delay(10); } - if (setup.sound_loops) + if (!tape.playing && setup.sound_loops) StopSound(SND_SIRR); } @@ -2003,17 +2050,6 @@ void Impact(int x, int y) case EL_SP_ZONK: sound = SND_SP_ZONKDOWN; break; - case EL_SCHLUESSEL: - case EL_SCHLUESSEL1: - case EL_SCHLUESSEL2: - case EL_SCHLUESSEL3: - case EL_SCHLUESSEL4: - case EL_EM_KEY_1: - case EL_EM_KEY_2: - case EL_EM_KEY_3: - case EL_EM_KEY_4: - sound = SND_KINK; - break; case EL_ZEIT_VOLL: case EL_ZEIT_LEER: sound = SND_DENG; @@ -2611,7 +2647,7 @@ void StartMoving(int x, int y) #endif #else else if ((IS_SLIPPERY(Feld[x][y+1]) || - (IS_SLIPPERY_GEMS(Feld[x][y+1]) && IS_GEM(element))) && + (IS_EM_SLIPPERY_WALL(Feld[x][y+1]) && IS_GEM(element))) && !IS_FALLING(x, y+1) && !JustStopped[x][y+1] && element != EL_DX_SUPABOMB && element != EL_SP_DISK_ORANGE) #endif @@ -4207,7 +4243,9 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) { static byte stored_player_action[MAX_PLAYERS]; static int num_stored_actions = 0; +#if 0 static boolean save_tape_entry = FALSE; +#endif boolean moved = FALSE, snapped = FALSE, bombed = FALSE; int left = player_action & JOY_LEFT; int right = player_action & JOY_RIGHT; @@ -4240,6 +4278,15 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) moved = MoveFigure(player, dx, dy); } + if (tape.single_step && tape.recording && !tape.pausing) + { + if (button1 || (bombed && !moved)) + { + TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); + SnapField(player, 0, 0); /* stop snapping */ + } + } + #if 0 if (tape.recording && (moved || snapped || bombed)) { @@ -4247,9 +4294,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) player_action &= JOY_BUTTON; stored_player_action[player->index_nr] = player_action; -#if 1 save_tape_entry = TRUE; -#endif } else if (tape.playing && snapped) SnapField(player, 0, 0); /* stop snapping */ @@ -4349,6 +4394,9 @@ void GameActions() action_delay_value = (tape.playing && tape.fast_forward ? FfwdFrameDelay : GameFrameDelay); + if (tape.playing && tape.index_search && !tape.pausing) + action_delay_value = 0; + /* ---------- main game synchronization point ---------- */ WaitUntilDelayReached(&action_delay, action_delay_value); @@ -4383,11 +4431,6 @@ void GameActions() if (tape.pausing) return; - if (tape.playing) - TapePlayDelay(); - else if (tape.recording) - TapeRecordDelay(); - recorded_player_action = (tape.playing ? TapePlayAction() : NULL); for (i=0; imove_delay, player->move_delay_value) && - !(tape.playing && tape.file_version < FILE_VERSION_2_0)) + !(tape.playing && tape.game_version < GAME_VERSION_2_0)) return FALSE; #endif @@ -5147,6 +5192,10 @@ void ScrollFigure(struct PlayerInfo *player, int mode) if (!local_player->friends_still_needed) player->LevelSolved = player->GameOver = TRUE; } + + if (tape.single_step && tape.recording && !tape.pausing && + !player->programmed_action) + TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); } } @@ -5798,7 +5847,7 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; #else if (!FrameReached(&player->push_delay, player->push_delay_value) && - !(tape.playing && tape.file_version < FILE_VERSION_2_0) && + !(tape.playing && tape.game_version < GAME_VERSION_2_0) && element != EL_SPRING) return MF_NO_ACTION; #endif @@ -6040,7 +6089,7 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; #else if (!FrameReached(&player->push_delay, player->push_delay_value) && - !(tape.playing && tape.file_version < FILE_VERSION_2_0) && + !(tape.playing && tape.game_version < GAME_VERSION_2_0) && element != EL_BALLOON) return MF_NO_ACTION; #endif @@ -6274,6 +6323,31 @@ void RaiseScoreElement(int element) } } +void RequestQuitGame(boolean ask_if_really_quit) +{ + if (AllPlayersGone || + !ask_if_really_quit || + level_editor_test_game || + Request("Do you really want to quit the game ?", + REQ_ASK | REQ_STAY_CLOSED)) + { +#if defined(PLATFORM_UNIX) + if (options.network) + SendToServer_StopPlaying(); + else +#endif + { + game_status = MAINMENU; + DrawMainMenu(); + } + } + else + { + OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); + } +} + + /* ---------- new game button stuff ---------------------------------------- */ /* graphic position values for game buttons */ @@ -6422,30 +6496,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) switch (id) { case GAME_CTRL_ID_STOP: - if (AllPlayersGone) - { - CloseDoor(DOOR_CLOSE_1); - game_status = MAINMENU; - DrawMainMenu(); - break; - } - - if (level_editor_test_game || - Request("Do you really want to quit the game ?", - REQ_ASK | REQ_STAY_CLOSED)) - { -#if defined(PLATFORM_UNIX) - if (options.network) - SendToServer_StopPlaying(); - else -#endif - { - game_status = MAINMENU; - DrawMainMenu(); - } - } - else - OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); + RequestQuitGame(TRUE); break; case GAME_CTRL_ID_PAUSE: @@ -6459,7 +6510,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) #endif } else - TapeTogglePause(); + TapeTogglePause(TAPE_TOGGLE_MANUAL); break; case GAME_CTRL_ID_PLAY: @@ -6483,11 +6534,10 @@ static void HandleGameButtons(struct GadgetInfo *gi) setup.sound_music = FALSE; FadeMusic(); } - else if (audio.loops_available) + else if (audio.music_available) { setup.sound = setup.sound_music = TRUE; - if (num_bg_loops) - PlayMusic(level_nr % num_bg_loops); + PlayMusic(level_nr); } break;