From: Holger Schemel Date: Mon, 9 Apr 2007 00:42:39 +0000 (+0200) Subject: rnd-20070409-1-src X-Git-Tag: 3.2.4^2~37 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=121088f197f0a6eb62f0642d3524726f5fccbba7;p=rocksndiamonds.git rnd-20070409-1-src * fixed displaying of game panel values for Emerald Mine game engine * fixed displaying end-of-level time and score values on new game panel --- diff --git a/ChangeLog b/ChangeLog index 89903c15..b5f7dc49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2007-04-08 * added support for accessing native Diamond Caves II level packages + * fixed displaying of game panel values for Emerald Mine game engine + * fixed displaying end-of-level time and score values on new game panel 2007-04-07 * added game panel control to display arbitrary elements on game panel diff --git a/src/conftime.h b/src/conftime.h index 90fd11bb..4099a36a 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2007-04-08 17:08" +#define COMPILE_DATE_STRING "2007-04-09 02:39" diff --git a/src/files.c b/src/files.c index aa9cdb4c..01548e64 100644 --- a/src/files.c +++ b/src/files.c @@ -1694,7 +1694,8 @@ static int getFileTypeFromBasename(char *basename) return LEVEL_FILE_TYPE_SP; /* check for typical filename of a Diamond Caves II level package file */ - if (strEqualSuffix(basename, ".dc2")) + if (strEqualSuffix(basename, ".dc") || + strEqualSuffix(basename, ".dc2")) return LEVEL_FILE_TYPE_DC; /* ---------- try to determine file type from filesize ---------- */ @@ -5758,12 +5759,10 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level, return; } + // fseek(file, 0x0000, SEEK_SET); + if (level_file_info->packed) { - int position_first_level = 0x00fa; - int extra_bytes = 4; - int skip_bytes; - /* read "magic bytes" from start of file */ fgets(magic_bytes, num_magic_bytes + 1, file); @@ -5772,38 +5771,56 @@ static void LoadLevelFromFileInfo_DC(struct LevelInfo *level, { level->no_valid_file = TRUE; - Error(ERR_WARN, "unknown level file '%s' -- using empty level", filename); + Error(ERR_WARN, "unknown DC level file '%s' -- using empty level", + filename); return; } - /* advance file stream to first level inside the level package */ - skip_bytes = position_first_level - num_magic_bytes - extra_bytes; + if (strEqualPrefix(magic_bytes, "DC2Win95") || + strEqualPrefix(magic_bytes, "DC2Win98")) + { + int position_first_level = 0x00fa; + int extra_bytes = 4; + int skip_bytes; - /* each block of level data is followed by block of non-level data */ - num_levels_to_skip *= 2; + /* advance file stream to first level inside the level package */ + skip_bytes = position_first_level - num_magic_bytes - extra_bytes; - /* at least skip header bytes, therefore use ">= 0" instead of "> 0" */ - while (num_levels_to_skip >= 0) - { - /* advance file stream to next level inside the level package */ - if (fseek(file, skip_bytes, SEEK_CUR) != 0) + /* each block of level data is followed by block of non-level data */ + num_levels_to_skip *= 2; + + /* at least skip header bytes, therefore use ">= 0" instead of "> 0" */ + while (num_levels_to_skip >= 0) { - level->no_valid_file = TRUE; + /* advance file stream to next level inside the level package */ + if (fseek(file, skip_bytes, SEEK_CUR) != 0) + { + level->no_valid_file = TRUE; - Error(ERR_WARN, "cannot fseek in file '%s' -- using empty level", - filename); + Error(ERR_WARN, "cannot fseek in file '%s' -- using empty level", + filename); - return; - } + return; + } - /* skip apparently unused extra bytes following each level */ - ReadUnusedBytesFromFile(file, extra_bytes); + /* skip apparently unused extra bytes following each level */ + ReadUnusedBytesFromFile(file, extra_bytes); - /* read size of next level in level package */ - skip_bytes = getFile32BitLE(file); + /* read size of next level in level package */ + skip_bytes = getFile32BitLE(file); - num_levels_to_skip--; + num_levels_to_skip--; + } + } + else + { + level->no_valid_file = TRUE; + + Error(ERR_WARN, "unknown DC2 level file '%s' -- using empty level", + filename); + + return; } } diff --git a/src/game.c b/src/game.c index 3f6ec77b..d24c62f6 100644 --- a/src/game.c +++ b/src/game.c @@ -2013,16 +2013,27 @@ void InitGameControlValues() void UpdateGameControlValues() { int i, k; - int time = (level.time == 0 ? TimePlayed : TimeLeft); - int score = (local_player->LevelSolved ? local_player->score_final : + int time = (local_player->LevelSolved ? + local_player->LevelSolved_CountingTime : + level.game_engine_type == GAME_ENGINE_TYPE_EM ? + level.native_em_level->lev->time : + 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 : local_player->score); - int exit_closed = (local_player->gems_still_needed > 0 || + int gems = (level.game_engine_type == GAME_ENGINE_TYPE_EM ? + level.native_em_level->lev->required : + local_player->gems_still_needed); + int exit_closed = (level.game_engine_type == GAME_ENGINE_TYPE_EM ? + level.native_em_level->lev->required > 0 : + local_player->gems_still_needed > 0 || local_player->sokobanfields_still_needed > 0 || local_player->lights_still_needed > 0); game_panel_controls[GAME_PANEL_LEVEL_NUMBER].value = level_nr; - game_panel_controls[GAME_PANEL_GEMS].value = - local_player->gems_still_needed; + game_panel_controls[GAME_PANEL_GEMS].value = gems; game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value = 0; for (i = 0; i < MAX_NUM_KEYS; i++) @@ -2035,12 +2046,24 @@ void UpdateGameControlValues() for (i = 0; i < MAX_PLAYERS; i++) { for (k = 0; k < MAX_NUM_KEYS; k++) - if (stored_player[i].key[k]) + { + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + { + if (level.native_em_level->ply[i]->keys & (1 << k)) + game_panel_controls[GAME_PANEL_KEY_1 + k].value = + get_key_element_from_nr(k); + } + else if (stored_player[i].key[k]) game_panel_controls[GAME_PANEL_KEY_1 + k].value = get_key_element_from_nr(k); + } - 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[i]->dynamite; + else + game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += + stored_player[i].inventory_size; if (stored_player[i].num_white_keys > 0) game_panel_controls[GAME_PANEL_KEY_WHITE].value = @@ -2055,12 +2078,24 @@ void UpdateGameControlValues() int player_nr = game.centered_player_nr; for (k = 0; k < MAX_NUM_KEYS; k++) - if (stored_player[player_nr].key[k]) + { + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) + { + if (level.native_em_level->ply[player_nr]->keys & (1 << k)) + game_panel_controls[GAME_PANEL_KEY_1 + k].value = + get_key_element_from_nr(k); + } + else if (stored_player[player_nr].key[k]) game_panel_controls[GAME_PANEL_KEY_1 + k].value = get_key_element_from_nr(k); + } - game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += - stored_player[player_nr].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 + game_panel_controls[GAME_PANEL_INVENTORY_COUNT].value += + stored_player[player_nr].inventory_size; if (stored_player[player_nr].num_white_keys > 0) game_panel_controls[GAME_PANEL_KEY_WHITE].value = EL_DC_KEY_WHITE; @@ -3526,6 +3561,8 @@ void InitGame() player->LevelSolved_PanelOff = FALSE; player->LevelSolved_SaveTape = FALSE; player->LevelSolved_SaveScore = FALSE; + player->LevelSolved_CountingTime = 0; + player->LevelSolved_CountingScore = 0; } network_player_action_received = FALSE; @@ -4281,6 +4318,9 @@ 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_CountingScore = player->score_final; } void GameWon() @@ -4336,6 +4376,9 @@ void GameWon() score = score_final; #if 1 + local_player->LevelSolved_CountingTime = time; + local_player->LevelSolved_CountingScore = score; + game_panel_controls[GAME_PANEL_TIME].value = time; game_panel_controls[GAME_PANEL_SCORE].value = score; @@ -4418,6 +4461,9 @@ void GameWon() score += time_count_steps * level.score[SC_TIME_BONUS]; #if 1 + local_player->LevelSolved_CountingTime = time; + local_player->LevelSolved_CountingScore = score; + game_panel_controls[GAME_PANEL_TIME].value = time; game_panel_controls[GAME_PANEL_SCORE].value = score; diff --git a/src/game.h b/src/game.h index ac2496e1..5b2b46a9 100644 --- a/src/game.h +++ b/src/game.h @@ -214,6 +214,8 @@ struct PlayerInfo boolean LevelSolved_PanelOff; boolean LevelSolved_SaveTape; boolean LevelSolved_SaveScore; + int LevelSolved_CountingTime; + int LevelSolved_CountingScore; int last_move_dir;