From aba4ad86f8fe03895d83c48536d9848726644293 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Thu, 16 Sep 2004 01:00:40 +0200 Subject: [PATCH] rnd-20040916-1-src --- src/conftime.h | 2 +- src/editor.c | 116 +++++++++++++++++++++++++----------------- src/files.c | 12 ++++- src/files.h | 6 +++ src/game.c | 3 +- src/game_em/convert.c | 24 ++++----- src/main.h | 2 + src/screens.c | 49 +++++++++++++++++- 8 files changed, 149 insertions(+), 65 deletions(-) diff --git a/src/conftime.h b/src/conftime.h index 20e261cf..284c7e8a 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-08-23 01:40]" +#define COMPILE_DATE_STRING "[2004-09-16 00:59]" diff --git a/src/editor.c b/src/editor.c index 5856c35a..aa07d4b8 100644 --- a/src/editor.c +++ b/src/editor.c @@ -428,31 +428,32 @@ #define GADGET_ID_SELECTBOX_FIRST (GADGET_ID_TEXT_AREA_FIRST + 1) #define GADGET_ID_TIME_OR_STEPS (GADGET_ID_SELECTBOX_FIRST + 0) -#define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 1) -#define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 2) -#define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 3) -#define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 4) -#define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 5) -#define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 6) -#define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 7) -#define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 8) -#define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 9) -#define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 10) -#define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 11) -#define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 12) -#define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 13) -#define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 14) -#define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 15) -#define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 16) -#define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 17) -#define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 18) -#define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 19) -#define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 20) -#define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 21) -#define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 22) +#define GADGET_ID_GAME_ENGINE_TYPE (GADGET_ID_SELECTBOX_FIRST + 1) +#define GADGET_ID_CUSTOM_WALK_TO_ACTION (GADGET_ID_SELECTBOX_FIRST + 2) +#define GADGET_ID_CUSTOM_EXPLOSION_TYPE (GADGET_ID_SELECTBOX_FIRST + 3) +#define GADGET_ID_CUSTOM_DEADLINESS (GADGET_ID_SELECTBOX_FIRST + 4) +#define GADGET_ID_CUSTOM_MOVE_PATTERN (GADGET_ID_SELECTBOX_FIRST + 5) +#define GADGET_ID_CUSTOM_MOVE_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 6) +#define GADGET_ID_CUSTOM_MOVE_STEPSIZE (GADGET_ID_SELECTBOX_FIRST + 7) +#define GADGET_ID_CUSTOM_MOVE_LEAVE_TYPE (GADGET_ID_SELECTBOX_FIRST + 8) +#define GADGET_ID_CUSTOM_SMASH_TARGETS (GADGET_ID_SELECTBOX_FIRST + 9) +#define GADGET_ID_CUSTOM_SLIPPERY_TYPE (GADGET_ID_SELECTBOX_FIRST + 10) +#define GADGET_ID_CUSTOM_ACCESS_TYPE (GADGET_ID_SELECTBOX_FIRST + 11) +#define GADGET_ID_CUSTOM_ACCESS_LAYER (GADGET_ID_SELECTBOX_FIRST + 12) +#define GADGET_ID_CUSTOM_ACCESS_PROTECTED (GADGET_ID_SELECTBOX_FIRST + 13) +#define GADGET_ID_CUSTOM_ACCESS_DIRECTION (GADGET_ID_SELECTBOX_FIRST + 14) +#define GADGET_ID_CHANGE_TIME_UNITS (GADGET_ID_SELECTBOX_FIRST + 15) +#define GADGET_ID_CHANGE_DIRECT_ACTION (GADGET_ID_SELECTBOX_FIRST + 16) +#define GADGET_ID_CHANGE_OTHER_ACTION (GADGET_ID_SELECTBOX_FIRST + 17) +#define GADGET_ID_CHANGE_SIDE (GADGET_ID_SELECTBOX_FIRST + 18) +#define GADGET_ID_CHANGE_PLAYER (GADGET_ID_SELECTBOX_FIRST + 19) +#define GADGET_ID_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 20) +#define GADGET_ID_CHANGE_REPLACE_WHEN (GADGET_ID_SELECTBOX_FIRST + 21) +#define GADGET_ID_SELECT_CHANGE_PAGE (GADGET_ID_SELECTBOX_FIRST + 22) +#define GADGET_ID_GROUP_CHOICE_MODE (GADGET_ID_SELECTBOX_FIRST + 23) /* textbutton identifiers */ -#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 23) +#define GADGET_ID_TEXTBUTTON_FIRST (GADGET_ID_SELECTBOX_FIRST + 24) #define GADGET_ID_PROPERTIES_INFO (GADGET_ID_TEXTBUTTON_FIRST + 0) #define GADGET_ID_PROPERTIES_CONFIG (GADGET_ID_TEXTBUTTON_FIRST + 1) @@ -628,33 +629,34 @@ /* values for selectbox gadgets */ #define ED_SELECTBOX_ID_TIME_OR_STEPS 0 -#define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 1 -#define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 2 -#define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 3 -#define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 4 -#define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 5 -#define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 6 -#define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 7 -#define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 8 -#define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 9 -#define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 10 -#define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 11 -#define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 12 -#define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 13 -#define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 14 -#define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 15 -#define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 16 -#define ED_SELECTBOX_ID_CHANGE_SIDE 17 -#define ED_SELECTBOX_ID_CHANGE_PLAYER 18 -#define ED_SELECTBOX_ID_CHANGE_PAGE 19 -#define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 20 -#define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 21 -#define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 22 - -#define ED_NUM_SELECTBOX 23 +#define ED_SELECTBOX_ID_GAME_ENGINE_TYPE 1 +#define ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE 2 +#define ED_SELECTBOX_ID_CUSTOM_ACCESS_LAYER 3 +#define ED_SELECTBOX_ID_CUSTOM_ACCESS_PROTECTED 4 +#define ED_SELECTBOX_ID_CUSTOM_ACCESS_DIRECTION 5 +#define ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION 6 +#define ED_SELECTBOX_ID_CUSTOM_MOVE_PATTERN 7 +#define ED_SELECTBOX_ID_CUSTOM_MOVE_DIRECTION 8 +#define ED_SELECTBOX_ID_CUSTOM_MOVE_STEPSIZE 9 +#define ED_SELECTBOX_ID_CUSTOM_MOVE_LEAVE_TYPE 10 +#define ED_SELECTBOX_ID_CUSTOM_SMASH_TARGETS 11 +#define ED_SELECTBOX_ID_CUSTOM_SLIPPERY_TYPE 12 +#define ED_SELECTBOX_ID_CUSTOM_DEADLINESS 13 +#define ED_SELECTBOX_ID_CUSTOM_EXPLOSION_TYPE 14 +#define ED_SELECTBOX_ID_CHANGE_TIME_UNITS 15 +#define ED_SELECTBOX_ID_CHANGE_DIRECT_ACTION 16 +#define ED_SELECTBOX_ID_CHANGE_OTHER_ACTION 17 +#define ED_SELECTBOX_ID_CHANGE_SIDE 18 +#define ED_SELECTBOX_ID_CHANGE_PLAYER 19 +#define ED_SELECTBOX_ID_CHANGE_PAGE 20 +#define ED_SELECTBOX_ID_CHANGE_REPLACE_WHEN 21 +#define ED_SELECTBOX_ID_SELECT_CHANGE_PAGE 22 +#define ED_SELECTBOX_ID_GROUP_CHOICE_MODE 23 + +#define ED_NUM_SELECTBOX 24 #define ED_SELECTBOX_ID_LEVEL_FIRST ED_SELECTBOX_ID_TIME_OR_STEPS -#define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_TIME_OR_STEPS +#define ED_SELECTBOX_ID_LEVEL_LAST ED_SELECTBOX_ID_GAME_ENGINE_TYPE #define ED_SELECTBOX_ID_CUSTOM1_FIRST ED_SELECTBOX_ID_CUSTOM_ACCESS_TYPE #define ED_SELECTBOX_ID_CUSTOM1_LAST ED_SELECTBOX_ID_CUSTOM_WALK_TO_ACTION @@ -1174,6 +1176,14 @@ static struct ValueTextInfo options_time_or_steps[] = { -1, NULL } }; +static struct ValueTextInfo options_game_engine_type[] = +{ + { GAME_ENGINE_TYPE_RND, "RND" }, + { GAME_ENGINE_TYPE_EM, "EM" }, + + { -1, NULL } +}; + static struct ValueTextInfo options_access_type[] = { { EP_WALKABLE, "walkable" }, @@ -1504,6 +1514,14 @@ static struct &level.use_step_counter, NULL, "(0 => no limit)", "time or step limit" }, + { + ED_SETTINGS_XPOS(0), ED_COUNTER_YPOS(6) + 8, + GADGET_ID_GAME_ENGINE_TYPE, GADGET_ID_NONE, + -1, + options_game_engine_type, + &level.game_engine_type, + "game engine:", NULL, "game engine" + }, /* ---------- element settings: configure 1 (custom elements) ----------- */ @@ -2041,6 +2059,8 @@ static struct ED_SETTINGS_XPOS(0), ED_SETTINGS_YPOS(1), GADGET_ID_CUSTOM_USE_GRAPHIC, GADGET_ID_NONE, &custom_element.use_gfx_element, + + /* !!! add separate "use existing element sound" !!! */ #if 0 NULL, "use graphic/sound of element:", "use existing graphic and sound" #else diff --git a/src/files.c b/src/files.c index 0fd7a18a..8d684ff0 100644 --- a/src/files.c +++ b/src/files.c @@ -29,7 +29,7 @@ #define CHUNK_SIZE_NONE -1 /* do not write chunk size */ #define FILE_VERS_CHUNK_SIZE 8 /* size of file version chunk */ #define LEVEL_HEADER_SIZE 80 /* size of level file header */ -#define LEVEL_HEADER_UNUSED 1 /* unused level header bytes */ +#define LEVEL_HEADER_UNUSED 0 /* unused level header bytes */ #define LEVEL_CHUNK_CNT2_SIZE 160 /* size of level CNT2 chunk */ #define LEVEL_CHUNK_CNT2_UNUSED 11 /* unused CNT2 chunk bytes */ #define LEVEL_CHUNK_CNT3_HEADER 16 /* size of level CNT3 header */ @@ -114,6 +114,8 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) int i, j, x, y; + level->game_engine_type = GAME_ENGINE_TYPE_RND; + level->file_version = FILE_VERSION_ACTUAL; level->game_version = GAME_VERSION_ACTUAL; @@ -712,6 +714,8 @@ static int LoadLevel_HEAD(FILE *file, int chunk_size, struct LevelInfo *level) level->can_pass_to_walkable = (getFile8Bit(file) == 1 ? TRUE : FALSE); level->grow_into_diggable = (getFile8Bit(file) == 1 ? TRUE : FALSE); + level->game_engine_type = getFile8Bit(file); + ReadUnusedBytesFromFile(file, LEVEL_HEADER_UNUSED); return chunk_size; @@ -2118,6 +2122,7 @@ void LoadLevelFromFileInfo(struct LevelInfo *level, case LEVEL_FILE_TYPE_EM: LoadLevelFromFileInfo_EM(level, level_file_info); + level->game_engine_type = GAME_ENGINE_TYPE_EM; break; case LEVEL_FILE_TYPE_SP: @@ -2128,6 +2133,9 @@ void LoadLevelFromFileInfo(struct LevelInfo *level, LoadLevelFromFileInfo_RND(level, level_file_info); break; } + + if (level->game_engine_type == GAME_ENGINE_TYPE_UNKNOWN) + level->game_engine_type = GAME_ENGINE_TYPE_RND; } void LoadLevelFromFilename(struct LevelInfo *level, char *filename) @@ -2618,6 +2626,8 @@ static void SaveLevel_HEAD(FILE *file, struct LevelInfo *level) putFile8Bit(file, (level->can_pass_to_walkable ? 1 : 0)); putFile8Bit(file, (level->grow_into_diggable ? 1 : 0)); + putFile8Bit(file, level->game_engine_type); + WriteUnusedBytesToFile(file, LEVEL_HEADER_UNUSED); } diff --git a/src/files.h b/src/files.h index 0918ac91..f0a04345 100644 --- a/src/files.h +++ b/src/files.h @@ -29,6 +29,12 @@ #define NUM_LEVEL_FILE_TYPES 8 +#define GAME_ENGINE_TYPE_UNKNOWN LEVEL_FILE_TYPE_UNKNOWN +#define GAME_ENGINE_TYPE_RND LEVEL_FILE_TYPE_RND +#define GAME_ENGINE_TYPE_EM LEVEL_FILE_TYPE_EM + +#define NUM_ENGINE_TYPES 3 + #define LEVEL_PACKED_START 100 #define PACKED_LEVELS(x) (LEVEL_PACKED_START + x) diff --git a/src/game.c b/src/game.c index 7d0c60eb..423f64d5 100644 --- a/src/game.c +++ b/src/game.c @@ -2061,7 +2061,7 @@ void InitGame() CloseDoor(DOOR_CLOSE_1); /* !!! FIX THIS (START) !!! */ - if (level.file_info.type == LEVEL_FILE_TYPE_EM) + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) { if (em_main_init_game(level_nr, level.file_info.filename) != 0) { @@ -8595,6 +8595,7 @@ void GameActions() recorded_player_action = (tape.playing ? TapePlayAction() : NULL); #if 1 + /* !!! CHECK THIS (tape.pausing is always FALSE here!) !!! */ if (recorded_player_action == NULL && tape.pausing) return; #endif diff --git a/src/game_em/convert.c b/src/game_em/convert.c index 50da08f0..8fd194a9 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -4,8 +4,8 @@ * fixes illegal tiles, acid, wheel, limits times, cleans flags. * * these tables weed out bad tiles for older caves (eg. wheel on -> wheel off) - * and clean up v6 caves (acid, number limits) which should(!) be inconsequential, - * but no doubt it will break some caves. + * and clean up v6 caves (acid, number limits) which should(!) be + * inconsequential, but no doubt it will break some caves. */ #include "tile.h" @@ -162,13 +162,13 @@ int clean_emerald(unsigned char *src, unsigned long *length) v4: v5: - /* id */ + /* id */ src[2106] = 255; src[2107] = 54; src[2108] = 48; src[2109] = 48; - /* time */ + /* time */ i = src[2094] * 10; src[2110] = i >> 8; src[2111] = i; @@ -190,7 +190,7 @@ int clean_emerald(unsigned char *src, unsigned long *length) if (src[i] == 40) src[i] = 147; - /* fix acid */ + /* fix acid */ for (i = 64; i < 2048; i++) if (src[i] == 63) src[i - 64] = 101; @@ -200,10 +200,10 @@ int clean_emerald(unsigned char *src, unsigned long *length) if (src[i] == 63) src[i - 3] = 101; + /* fix acid in eater 2 */ for (i = 2060; i < 2066; i++) if (src[i] == 63) src[i - 3] = 101; - /* fix acid in eater 2 */ /* fix acid in eater 3 */ for (i = 2069; i < 2075; i++) @@ -246,28 +246,28 @@ int clean_emerald(unsigned char *src, unsigned long *length) src[2098] &= 7; src[src[2098] << 8 | src[2099]] = 128; - /* ameuba speed */ + /* ameuba speed */ if ((src[2100] << 8 | src[2101]) > 9999) { src[2100] = 39; src[2101] = 15; } - /* time wonderwall */ + /* time wonderwall */ if ((src[2102] << 8 | src[2103]) > 9999) { src[2102] = 39; src[2103] = 15; } - /* time */ + /* time */ if ((src[2110] << 8 | src[2111]) > 9999) { src[2110] = 39; src[2111] = 15; } - /* wind direction */ + /* wind direction */ i = src[2149]; i &= 15; i &= -i; @@ -280,7 +280,7 @@ int clean_emerald(unsigned char *src, unsigned long *length) src[2155] = 15; } - /* time magnify */ + /* time magnify */ if ((src[2156] << 8 | src[2157]) > 9999) { src[2156] = 39; @@ -693,7 +693,7 @@ void convert_emerald(unsigned char *src) for (temp = 1; temp < 2047; temp++) { - switch(src[temp]) + switch (src[temp]) { case 0x24: /* wonderwall */ lev.wonderwall_state = 1; diff --git a/src/main.h b/src/main.h index 6a37af86..739e75f1 100644 --- a/src/main.h +++ b/src/main.h @@ -1478,6 +1478,8 @@ struct LevelInfo { struct LevelFileInfo file_info; + int game_engine_type; + int file_version; /* file format version the level is stored with */ int game_version; /* game release version the level was created with */ diff --git a/src/screens.c b/src/screens.c index 425c35e8..1ba452fb 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2945,19 +2945,64 @@ void HandleGameActions() return; /* !!! FIX THIS (START) !!! */ - if (level.file_info.type == LEVEL_FILE_TYPE_EM) + if (level.game_engine_type == GAME_ENGINE_TYPE_EM) { + byte *recorded_player_action; byte summarized_player_action = 0; + byte tape_action[MAX_PLAYERS]; int i; + if (tape.pausing) + return; + + recorded_player_action = (tape.playing ? TapePlayAction() : NULL); + for (i = 0; i < MAX_PLAYERS; i++) + { summarized_player_action |= stored_player[i].action; - if (em_main_handle_game(summarized_player_action) != 0) + if (!network_playing) + stored_player[i].effective_action = stored_player[i].action; + } + + if (!options.network && !setup.team_mode) + local_player->effective_action = summarized_player_action; + + if (recorded_player_action != NULL) + for (i = 0; i < MAX_PLAYERS; i++) + stored_player[i].effective_action = recorded_player_action[i]; + + for (i = 0; i < MAX_PLAYERS; i++) + { + tape_action[i] = stored_player[i].effective_action; + + /* !!! (this does not happen in the EM engine) !!! */ + if (tape.recording && tape_action[i] && !tape.player_participates[i]) + tape.player_participates[i] = TRUE; /* player just appeared from CE */ + } + + /* only save actions from input devices, but not programmed actions */ + if (tape.recording) + TapeRecordAction(tape_action); + + if (em_main_handle_game(local_player->effective_action) != 0) { game_status = GAME_MODE_MAIN; DrawMainMenu(); } + + if (TimeFrames >= FRAMES_PER_SECOND) + { + TimeFrames = 0; + TapeTime++; + + if (tape.recording || tape.playing) + DrawVideoDisplay(VIDEO_STATE_TIME_ON, TapeTime); + } + + TimeFrames++; + + BackToFront(); } else { -- 2.34.1