X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=1c493508a290286f096830ed58ae3de7ec219057;hb=4c4a7be95adb3df36b3e4cb0ac365097243ac66b;hp=8ac2616131b19c07bf66ea9e47abaec49a95bb8a;hpb=1e23125074b86c5eb1254037a81a3e9062152b7f;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 8ac26161..1c493508 100644 --- a/src/game.c +++ b/src/game.c @@ -2032,6 +2032,9 @@ static void InitField(int x, int y, boolean init_game) { GfxElementEmpty[x][y] = element; Tile[x][y] = EL_EMPTY; + + if (element_info[element].use_gfx_element) + game.use_masked_elements = TRUE; } break; @@ -2678,15 +2681,25 @@ static void DisplayGameControlValues(void) if (type == TYPE_INTEGER) { if (nr == GAME_PANEL_LEVEL_NUMBER || + nr == GAME_PANEL_INVENTORY_COUNT || + nr == GAME_PANEL_SCORE || + nr == GAME_PANEL_HIGHSCORE || nr == GAME_PANEL_TIME) { boolean use_dynamic_size = (size == -1 ? TRUE : FALSE); if (use_dynamic_size) // use dynamic number of digits { - int value_change = (nr == GAME_PANEL_LEVEL_NUMBER ? 100 : 1000); - int size1 = (nr == GAME_PANEL_LEVEL_NUMBER ? 2 : 3); - int size2 = size1 + 1; + int value_change = (nr == GAME_PANEL_LEVEL_NUMBER ? 100 : + nr == GAME_PANEL_INVENTORY_COUNT || + nr == GAME_PANEL_TIME ? 1000 : 100000); + int size_add = (nr == GAME_PANEL_LEVEL_NUMBER || + nr == GAME_PANEL_INVENTORY_COUNT || + nr == GAME_PANEL_TIME ? 1 : 2); + int size1 = (nr == GAME_PANEL_LEVEL_NUMBER ? 2 : + nr == GAME_PANEL_INVENTORY_COUNT || + nr == GAME_PANEL_TIME ? 3 : 5); + int size2 = size1 + size_add; int font1 = pos->font; int font2 = pos->font_alt; @@ -3842,6 +3855,9 @@ void InitGame(void) game.envelope_active = FALSE; + // special case: set custom artwork setting to initial value + game.use_masked_elements = game.use_masked_elements_initial; + for (i = 0; i < NUM_BELTS; i++) { game.belt_dir[i] = MV_NONE; @@ -5088,7 +5104,14 @@ static int addScoreEntry(struct ScoreInfo *list, struct ScoreEntry *new_entry, // (special case: historic score entries have an empty tape basename entry) if (strEqual(new_entry->tape_basename, entry->tape_basename) && !strEqual(new_entry->tape_basename, UNDEFINED_FILENAME)) + { + // special case: use server score instead of local score value if higher + // (historic scores might have been truncated to 16-bit values locally) + if (score_is_better) + entry->score = new_entry->score; + return -1; + } if (is_better || entry_is_empty) { @@ -5987,6 +6010,10 @@ static void Explode(int ex, int ey, int phase, int mode) return; } + // this can happen if the player was just killed by an explosion + if (GfxElement[x][y] == EL_UNDEFINED) + GfxElement[x][y] = EL_EMPTY; + if (phase == last_phase) { int element; @@ -8417,6 +8444,9 @@ static void StartMoving(int x, int y) GfxDir[x][y] = diagonal_move_dir; ChangeDelay[x][y] = change_delay; + if (Store[x][y] == EL_EMPTY) + Store[x][y] = GfxElementEmpty[x][y]; + graphic = el_act_dir2img(GfxElement[x][y], GfxAction[x][y], GfxDir[x][y]); @@ -11590,6 +11620,35 @@ static void CheckLevelSolved(void) } } +static void CheckLevelTime_StepCounter(void) +{ + int i; + + TimePlayed++; + + if (TimeLeft > 0) + { + TimeLeft--; + + if (TimeLeft <= 10 && setup.time_limit && !game.LevelSolved) + PlaySound(SND_GAME_RUNNING_OUT_OF_TIME); + + game_panel_controls[GAME_PANEL_TIME].value = TimeLeft; + + DisplayGameControlValues(); + + if (!TimeLeft && setup.time_limit && !game.LevelSolved) + for (i = 0; i < MAX_PLAYERS; i++) + KillPlayer(&stored_player[i]); + } + else if (game.no_time_limit && !game.all_players_gone) + { + game_panel_controls[GAME_PANEL_TIME].value = TimePlayed; + + DisplayGameControlValues(); + } +} + static void CheckLevelTime(void) { int i; @@ -11712,6 +11771,9 @@ void StartGameActions(boolean init_network_game, boolean record_tape, if (record_tape) TapeStartRecording(new_random_seed); + if (setup.auto_pause_on_start && !tape.pausing) + TapeTogglePause(TAPE_TOGGLE_MANUAL); + if (init_network_game) { SendToServer_LevelFile(); @@ -12288,6 +12350,25 @@ void GameActions_RND(void) CheckElementChangeByMouse(x, y, element, CE_PRESSED_BY_MOUSE, ch_button); CheckTriggeredElementChangeByMouse(x, y, element, CE_MOUSE_PRESSED_ON_X, ch_button); + + if (level.use_step_counter) + { + boolean counted_click = FALSE; + + // element clicked that can change when clicked/pressed + if (CAN_CHANGE_OR_HAS_ACTION(element) && + (HAS_ANY_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) || + HAS_ANY_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE))) + counted_click = TRUE; + + // element clicked that can trigger change when clicked/pressed + if (trigger_events[element][CE_MOUSE_CLICKED_ON_X] || + trigger_events[element][CE_MOUSE_PRESSED_ON_X]) + counted_click = TRUE; + + if (new_button && counted_click) + CheckLevelTime_StepCounter(); + } } SCAN_PLAYFIELD(x, y) @@ -12296,6 +12377,9 @@ void GameActions_RND(void) graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]); last_gfx_frame = GfxFrame[x][y]; + if (element == EL_EMPTY) + graphic = el2img(GfxElementEmpty[x][y]); + ResetGfxFrame(x, y); if (GfxFrame[x][y] != last_gfx_frame && !Stop[x][y]) @@ -13243,33 +13327,7 @@ void ScrollPlayer(struct PlayerInfo *player, int mode) } if (level.use_step_counter) - { - int i; - - TimePlayed++; - - if (TimeLeft > 0) - { - TimeLeft--; - - if (TimeLeft <= 10 && setup.time_limit && !game.LevelSolved) - PlaySound(SND_GAME_RUNNING_OUT_OF_TIME); - - game_panel_controls[GAME_PANEL_TIME].value = TimeLeft; - - DisplayGameControlValues(); - - if (!TimeLeft && setup.time_limit && !game.LevelSolved) - for (i = 0; i < MAX_PLAYERS; i++) - KillPlayer(&stored_player[i]); - } - else if (game.no_time_limit && !game.all_players_gone) - { - game_panel_controls[GAME_PANEL_TIME].value = TimePlayed; - - DisplayGameControlValues(); - } - } + CheckLevelTime_StepCounter(); if (tape.single_step && tape.recording && !tape.pausing && !player->programmed_action)