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 ---------- */
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);
{
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;
}
}
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++)
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 =
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;
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;
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()
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;
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;