X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=9445ac72f25dfdf0b64ea366c57981b436e0b4d4;hb=c3218c06da4da799c906a5adaacd625583f65616;hp=7c70ae071aead691d63232a5006a07089ca0e0ac;hpb=205e33df255a817dc1032696f065256a08aa61fa;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 7c70ae07..9445ac72 100644 --- a/src/game.c +++ b/src/game.c @@ -2223,6 +2223,15 @@ void UpdatePlayfieldElementCount() void UpdateGameControlValues() { int i, k; +#if 1 + int time = (local_player->LevelSolved ? + 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 : + game.no_time_limit ? TimePlayed : TimeLeft); +#else int time = (local_player->LevelSolved ? local_player->LevelSolved_CountingTime : level.game_engine_type == GAME_ENGINE_TYPE_EM ? @@ -2230,6 +2239,7 @@ void UpdateGameControlValues() level.game_engine_type == GAME_ENGINE_TYPE_SP ? level.native_sp_level->game_sp->time_played : level.time == 0 ? TimePlayed : TimeLeft); +#endif int score = (local_player->LevelSolved ? local_player->LevelSolved_CountingScore : level.game_engine_type == GAME_ENGINE_TYPE_EM ? @@ -3180,7 +3190,7 @@ void DrawGameDoorValues() void DrawGameDoorValues_OLD() { - int time_value = (level.time == 0 ? TimePlayed : TimeLeft); + int time_value = (game.no_time_limit ? TimePlayed : TimeLeft); int dynamite_value = 0; int score_value = (local_player->LevelSolved ? local_player->score_final : local_player->score); @@ -3923,6 +3933,8 @@ void InitGame() AllPlayersGone = FALSE; + game.no_time_limit = (level.time == 0); + game.yamyam_content_nr = 0; game.robot_wheel_active = FALSE; game.magic_wall_active = FALSE; @@ -4485,7 +4497,9 @@ void InitGame() local_player->jy - MIDPOSY); } +#if 0 printf("::: %d, %d (initial)\n", scroll_x, scroll_y); +#endif #if 0 /* do not use PLAYING mask for fading out from main screen */ @@ -4636,6 +4650,17 @@ void InitGame() MapTapeButtons(); #endif + if (!game.restart_level && !tape.playing) + { + LevelStats_incPlayed(level_nr); + + SaveLevelSetup_SeriesInfo(); + +#if 0 + printf("::: PLAYING LEVEL (%d)\n", LevelStats_getPlayed(level_nr)); +#endif + } + game.restart_level = FALSE; } @@ -4854,7 +4879,8 @@ static void PlayerWins(struct PlayerInfo *player) player->score_final = (level.game_engine_type == GAME_ENGINE_TYPE_EM ? level.native_em_level->lev->score : player->score); - player->LevelSolved_CountingTime = (level.time == 0 ? TimePlayed : TimeLeft); + player->LevelSolved_CountingTime = (game.no_time_limit ? TimePlayed : + TimeLeft); player->LevelSolved_CountingScore = player->score_final; } @@ -4879,6 +4905,17 @@ void GameWon() local_player->LevelSolved_SaveTape = tape.recording; local_player->LevelSolved_SaveScore = !tape.playing; + if (!tape.playing) + { + LevelStats_incSolved(level_nr); + + SaveLevelSetup_SeriesInfo(); + +#if 0 + printf("::: LEVEL SOLVED (%d)\n", LevelStats_getSolved(level_nr)); +#endif + } + if (tape.auto_play) /* tape might already be stopped here */ tape.auto_play_level_solved = TRUE; @@ -4889,7 +4926,7 @@ void GameWon() game_over_delay_1 = game_over_delay_value_1; game_over_delay_2 = game_over_delay_value_2; - time = time_final = (level.time == 0 ? TimePlayed : TimeLeft); + time = time_final = (game.no_time_limit ? TimePlayed : TimeLeft); score = score_final = local_player->score_final; if (TimeLeft > 0) @@ -4897,7 +4934,7 @@ void GameWon() time_final = 0; score_final += TimeLeft * level.score[SC_TIME_BONUS]; } - else if (level.time == 0 && TimePlayed < 999) + else if (game.no_time_limit && TimePlayed < 999) { time_final = 999; score_final += (999 - TimePlayed) * level.score[SC_TIME_BONUS]; @@ -5083,6 +5120,7 @@ void GameEnd() if (level_nr == leveldir_current->handicap_level) { leveldir_current->handicap_level++; + SaveLevelSetup_SeriesInfo(); } @@ -9530,8 +9568,8 @@ void AmoebeUmwandelnBD(int ax, int ay, int new_element) void AmoebeWaechst(int x, int y) { - static unsigned long sound_delay = 0; - static unsigned long sound_delay_value = 0; + static unsigned int sound_delay = 0; + static unsigned int sound_delay_value = 0; if (!MovDelay[x][y]) /* start new growing cycle */ { @@ -9566,8 +9604,8 @@ void AmoebeWaechst(int x, int y) void AmoebaDisappearing(int x, int y) { - static unsigned long sound_delay = 0; - static unsigned long sound_delay_value = 0; + static unsigned int sound_delay = 0; + static unsigned int sound_delay_value = 0; if (!MovDelay[x][y]) /* start new shrinking cycle */ { @@ -12182,6 +12220,9 @@ static void CheckLevelTime() PlaySound(SND_GAME_RUNNING_OUT_OF_TIME); #if 1 + /* this does not make sense: game_panel_controls[GAME_PANEL_TIME].value + is reset from other values in UpdateGameDoorValues() -- FIX THIS */ + game_panel_controls[GAME_PANEL_TIME].value = TimeLeft; DisplayGameControlValues(); @@ -12199,19 +12240,19 @@ static void CheckLevelTime() } } #if 1 - else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */ + else if (game.no_time_limit && !AllPlayersGone) /* level w/o time limit */ { game_panel_controls[GAME_PANEL_TIME].value = TimePlayed; DisplayGameControlValues(); } #else - else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */ + else if (game.no_time_limit && !AllPlayersGone) /* level w/o time limit */ DrawGameValue_Time(TimePlayed); #endif level.native_em_level->lev->time = - (level.time == 0 ? TimePlayed : TimeLeft); + (game.no_time_limit ? TimePlayed : TimeLeft); } if (tape.recording || tape.playing) @@ -12278,9 +12319,9 @@ void AdvanceFrameAndPlayerCounters(int player_nr) } void StartGameActions(boolean init_network_game, boolean record_tape, - long random_seed) + int random_seed) { - unsigned long new_random_seed = InitRND(random_seed); + unsigned int new_random_seed = InitRND(random_seed); if (record_tape) TapeStartRecording(new_random_seed); @@ -12299,8 +12340,8 @@ void StartGameActions(boolean init_network_game, boolean record_tape, void GameActions() { - static unsigned long game_frame_delay = 0; - unsigned long game_frame_delay_value; + static unsigned int game_frame_delay = 0; + unsigned int game_frame_delay_value; byte *recorded_player_action; byte summarized_player_action = 0; byte tape_action[MAX_PLAYERS]; @@ -13068,7 +13109,7 @@ void GameActions_RND() /* new experimental amoeba growth stuff */ if (!(FrameCounter % 8)) { - static unsigned long random = 1684108901; + static unsigned int random = 1684108901; for (i = 0; i < level.amoeba_speed * 28 / 8; i++) { @@ -13252,9 +13293,9 @@ void GameActions_RND() if (options.debug) /* calculate frames per second */ { - static unsigned long fps_counter = 0; + static unsigned int fps_counter = 0; static int fps_frames = 0; - unsigned long fps_delay_ms = Counter() - fps_counter; + unsigned int fps_delay_ms = Counter() - fps_counter; fps_frames++; @@ -13685,7 +13726,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) int original_move_delay_value = player->move_delay_value; #if DEBUG - printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES. [%ld]\n", + printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES. [%d]\n", tape.counter); #endif @@ -14067,14 +14108,14 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) KillPlayer(&stored_player[i]); } #if 1 - else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */ + else if (game.no_time_limit && !AllPlayersGone) /* level w/o time limit */ { game_panel_controls[GAME_PANEL_TIME].value = TimePlayed; DisplayGameControlValues(); } #else - else if (level.time == 0 && !AllPlayersGone) /* level w/o time limit */ + else if (game.no_time_limit && !AllPlayersGone) /* level w/o time limit */ DrawGameValue_Time(TimePlayed); #endif } @@ -14087,7 +14128,7 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) void ScrollScreen(struct PlayerInfo *player, int mode) { - static unsigned long screen_frame_counter = 0; + static unsigned int screen_frame_counter = 0; if (mode == SCROLL_INIT) { @@ -15630,6 +15671,7 @@ static int DigField(struct PlayerInfo *player, if (level.time > 0 || level.use_time_orb_bug) { TimeLeft += level.time_orb_time; + game.no_time_limit = FALSE; #if 1 game_panel_controls[GAME_PANEL_TIME].value = TimeLeft; @@ -16311,7 +16353,7 @@ void PlayLevelSound_SP(int xx, int yy, int element_sp, int action_sp) #if 0 void ChangeTime(int value) { - int *time = (level.time == 0 ? &TimePlayed : &TimeLeft); + int *time = (game.no_time_limit ? &TimePlayed : &TimeLeft); *time += value; @@ -16496,7 +16538,7 @@ void RequestQuitGame(boolean ask_if_really_quit) /* random generator functions */ /* ------------------------------------------------------------------------- */ -unsigned int InitEngineRandom_RND(long seed) +unsigned int InitEngineRandom_RND(int seed) { game.num_random_calls = 0; @@ -16589,7 +16631,7 @@ static void SaveEngineSnapshotValues_RND() static void LoadEngineSnapshotValues_RND() { - unsigned long num_random_calls = game.num_random_calls; + unsigned int num_random_calls = game.num_random_calls; int i, j; for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++) @@ -16807,7 +16849,7 @@ void CreateGameButtons() struct GadgetInfo *gi; int button_type; boolean checked; - unsigned long event_mask; + unsigned int event_mask; int gd_x = gfx->src_x; int gd_y = gfx->src_y; int gd_xp = gfx->src_x + gfx->pressed_xoffset;