From d42e0a36609c7990f8b9f6fcd80f37f65bcf5149 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 3 Mar 2004 18:11:24 +0100 Subject: [PATCH] rnd-20040303-B-src --- Makefile | 4 ++-- src/Makefile | 3 ++- src/conftime.h | 2 +- src/files.c | 47 +++++++++++++++++++++++++++++++++++++++++----- src/game.c | 29 +++++++++++++++++++++++----- src/libgame/misc.c | 5 +++++ src/main.h | 8 +++++--- src/tape.c | 6 +++++- 8 files changed, 86 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 481244f7..1ea92b07 100644 --- a/Makefile +++ b/Makefile @@ -50,8 +50,8 @@ CROSS_PATH_WIN32=/usr/local/cross-tools/i386-mingw32msvc SRC_DIR = src MAKE_CMD = $(MAKE) -C $(SRC_DIR) -# DEFAULT_TARGET = x11 -DEFAULT_TARGET = sdl +DEFAULT_TARGET = x11 +# DEFAULT_TARGET = sdl # ----------------------------------------------------------------------------- diff --git a/src/Makefile b/src/Makefile index f065f0b9..ef1f52af 100644 --- a/src/Makefile +++ b/src/Makefile @@ -85,7 +85,8 @@ endif ifeq ($(TARGET),x11) SYS_CFLAGS = -DTARGET_X11 $(X11_INCL) -SYS_LDFLAGS = $(X11_LIBS) -lX11 +# SYS_LDFLAGS = $(X11_LIBS) -lX11 +SYS_LDFLAGS = $(XLIB_PATH)/libX11.a endif ifeq ($(TARGET),sdl) diff --git a/src/conftime.h b/src/conftime.h index 33ec8ea7..c6f7f77c 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-03-03 01:34]" +#define COMPILE_DATE_STRING "[2004-03-03 18:10]" diff --git a/src/files.c b/src/files.c index a6b41e1b..bf3b77e7 100644 --- a/src/files.c +++ b/src/files.c @@ -289,7 +289,7 @@ static void setLevelInfoToDefaults(struct LevelInfo *level) BorderElement = EL_STEELWALL; - level->no_level_file = FALSE; + level->no_valid_file = FALSE; if (leveldir_current == NULL) /* only when dumping level */ return; @@ -1182,7 +1182,7 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, if (!(file = fopen(filename, MODE_READ))) { - level->no_level_file = TRUE; + level->no_valid_file = TRUE; if (level != &level_template) Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); @@ -1198,6 +1198,8 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, getFileChunkBE(file, chunk_name, NULL); if (strcmp(chunk_name, "CAVE") != 0) { + level->no_valid_file = TRUE; + Error(ERR_WARN, "unknown format of level file '%s'", filename); fclose(file); return; @@ -1212,6 +1214,8 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, if (!checkCookieString(cookie, LEVEL_COOKIE_TMPL)) { + level->no_valid_file = TRUE; + Error(ERR_WARN, "unknown format of level file '%s'", filename); fclose(file); return; @@ -1219,6 +1223,8 @@ static void LoadLevelFromFileInfo_RND(struct LevelInfo *level, if ((level->file_version = getFileVersionFromCookieString(cookie)) == -1) { + level->no_valid_file = TRUE; + Error(ERR_WARN, "unsupported version of level file '%s'", filename); fclose(file); return; @@ -1632,7 +1638,7 @@ static void LoadLevelFromFileInfo_EM(struct LevelInfo *level, if (!(file = fopen(filename, MODE_READ))) { - level->no_level_file = TRUE; + level->no_valid_file = TRUE; Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); @@ -1824,7 +1830,7 @@ static void LoadLevelFromFileInfo_SP(struct LevelInfo *level, if (!(file = fopen(filename, MODE_READ))) { - level->no_level_file = TRUE; + level->no_valid_file = TRUE; Error(ERR_WARN, "cannot read level '%s' -- using empty level", filename); @@ -1834,7 +1840,7 @@ static void LoadLevelFromFileInfo_SP(struct LevelInfo *level, /* position file stream to the requested level inside the level package */ if (fseek(file, nr * SP_LEVEL_SIZE, SEEK_SET) != 0) { - level->no_level_file = TRUE; + level->no_valid_file = TRUE; Error(ERR_WARN, "cannot fseek level '%s' -- using empty level", filename); @@ -2928,6 +2934,13 @@ void SaveLevelTemplate() void DumpLevel(struct LevelInfo *level) { + if (level->no_valid_file) + { + Error(ERR_WARN, "cannot dump -- no valid level file found"); + + return; + } + printf_line("-", 79); printf("Level xxx (file version %08d, game version %08d)\n", level->file_version, level->game_version); @@ -2986,6 +2999,8 @@ static void setTapeInfoToDefaults() tape.recording = FALSE; tape.playing = FALSE; tape.pausing = FALSE; + + tape.no_valid_file = FALSE; } static int LoadTape_VERS(FILE *file, int chunk_size, struct TapeInfo *tape) @@ -3150,7 +3165,13 @@ void LoadTapeFromFilename(char *filename) setTapeInfoToDefaults(); if (!(file = fopen(filename, MODE_READ))) + { + tape.no_valid_file = TRUE; + + Error(ERR_WARN, "cannot read tape '%s' -- using empty tape", filename); + return; + } getFileChunkBE(file, chunk_name, NULL); if (strcmp(chunk_name, "RND1") == 0) @@ -3160,6 +3181,8 @@ void LoadTapeFromFilename(char *filename) getFileChunkBE(file, chunk_name, NULL); if (strcmp(chunk_name, "TAPE") != 0) { + tape.no_valid_file = TRUE; + Error(ERR_WARN, "unknown format of tape file '%s'", filename); fclose(file); return; @@ -3174,6 +3197,8 @@ void LoadTapeFromFilename(char *filename) if (!checkCookieString(cookie, TAPE_COOKIE_TMPL)) { + tape.no_valid_file = TRUE; + Error(ERR_WARN, "unknown format of tape file '%s'", filename); fclose(file); return; @@ -3181,6 +3206,8 @@ void LoadTapeFromFilename(char *filename) if ((tape.file_version = getFileVersionFromCookieString(cookie)) == -1) { + tape.no_valid_file = TRUE; + Error(ERR_WARN, "unsupported version of tape file '%s'", filename); fclose(file); return; @@ -3397,11 +3424,21 @@ void DumpTape(struct TapeInfo *tape) { int i, j; +#if 1 + if (tape->no_valid_file) + { + Error(ERR_WARN, "cannot dump -- no valid tape file found"); + + return; + } +#else if (TAPE_IS_EMPTY(*tape)) { Error(ERR_WARN, "no tape available for level %d", tape->level_nr); + return; } +#endif printf_line("-", 79); printf("Tape of Level %03d (file version %08d, game version %08d)\n", diff --git a/src/game.c b/src/game.c index 560a0272..d3ac2307 100644 --- a/src/game.c +++ b/src/game.c @@ -8073,20 +8073,25 @@ static void CheckGravityMovement(struct PlayerInfo *player) { if (game.gravity && !player->programmed_action) { - int move_dir_vertical = player->action & (MV_UP | MV_DOWN); - int move_dir_horizontal = player->action & (MV_LEFT | MV_RIGHT); + int move_dir_horizontal = player->action & MV_HORIZONTAL; + int move_dir_vertical = player->action & MV_VERTICAL; int move_dir = - (player->last_move_dir & (MV_LEFT | MV_RIGHT) ? + (player->last_move_dir & MV_HORIZONTAL ? (move_dir_vertical ? move_dir_vertical : move_dir_horizontal) : (move_dir_horizontal ? move_dir_horizontal : move_dir_vertical)); int jx = player->jx, jy = player->jy; int dx = (move_dir & MV_LEFT ? -1 : move_dir & MV_RIGHT ? +1 : 0); int dy = (move_dir & MV_UP ? -1 : move_dir & MV_DOWN ? +1 : 0); int new_jx = jx + dx, new_jy = jy + dy; + boolean player_is_snapping = player->action & JOY_BUTTON_1; boolean field_under_player_is_free = (IN_LEV_FIELD(jx, jy + 1) && IS_FREE(jx, jy + 1)); boolean player_is_moving_to_valid_field = - (IN_LEV_FIELD(new_jx, new_jy) && + ( +#if 1 + !player_is_snapping && +#endif + IN_LEV_FIELD(new_jx, new_jy) && (Feld[new_jx][new_jy] == EL_SP_BASE || Feld[new_jx][new_jy] == EL_SAND || (IS_SP_PORT(Feld[new_jx][new_jy]) && @@ -8098,10 +8103,24 @@ static void CheckGravityMovement(struct PlayerInfo *player) (IS_WALKABLE(Feld[jx][jy]) && !(element_info[Feld[jx][jy]].access_direction & MV_DOWN))); +#if 0 + printf("::: checking gravity NOW [%d, %d, %d] [%d] ...\n", + field_under_player_is_free, + player_is_standing_on_valid_field, + player_is_moving_to_valid_field, + (player_is_moving_to_valid_field ? Feld[new_jx][new_jy] : -1)); +#endif + if (field_under_player_is_free && !player_is_standing_on_valid_field && !player_is_moving_to_valid_field) + { +#if 0 + printf("::: setting programmed_action to MV_DOWN ...\n"); +#endif + player->programmed_action = MV_DOWN; + } } } @@ -8315,7 +8334,7 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) player->move_delay_value = original_move_delay_value; } - if (player->last_move_dir & (MV_LEFT | MV_RIGHT)) + if (player->last_move_dir & MV_HORIZONTAL) { if (!(moved |= MovePlayerOneStep(player, 0, dy, dx, dy))) moved |= MovePlayerOneStep(player, dx, 0, dx, dy); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 3b447821..cb0f6525 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -679,6 +679,11 @@ void GetOptions(char *argv[], void (*print_usage_function)(void)) options.execute_command = option_arg; if (option_arg == next_option) options_left++; + +#if 1 + /* when doing batch processing, always enable verbose mode (warnings) */ + options.verbose = TRUE; +#endif } else if (*option == '-') { diff --git a/src/main.h b/src/main.h index e40f4d88..b483378e 100644 --- a/src/main.h +++ b/src/main.h @@ -256,8 +256,8 @@ /* values for custom move patterns */ #define MV_HORIZONTAL (MV_LEFT | MV_RIGHT) -#define MV_VERTICAL (MV_UP | MV_DOWN) -#define MV_ALL_DIRECTIONS (MV_HORIZONTAL | MV_VERTICAL) +#define MV_VERTICAL (MV_UP | MV_DOWN) +#define MV_ALL_DIRECTIONS (MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN) #define MV_ANY_DIRECTION (MV_ALL_DIRECTIONS) #define MV_TOWARDS_PLAYER (1 << MV_BIT_TOWARDS_PLAYER) #define MV_AWAY_FROM_PLAYER (1 << MV_BIT_AWAY_FROM_PLAYER) @@ -1438,7 +1438,7 @@ struct LevelInfo boolean use_custom_template; /* use custom properties from template file */ - boolean no_level_file; /* set for currently undefined levels */ + boolean no_valid_file; /* set when level file missing or invalid */ }; struct TapeInfo @@ -1472,6 +1472,8 @@ struct TapeInfo byte action[MAX_PLAYERS]; byte delay; } pos[MAX_TAPELEN]; + + boolean no_valid_file; /* set when tape file missing or invalid */ }; struct GameInfo diff --git a/src/tape.c b/src/tape.c index 51dcd8a2..f05a3b45 100644 --- a/src/tape.c +++ b/src/tape.c @@ -775,14 +775,18 @@ void AutoPlayTape() printf("Level %03d: ", level_nr); LoadLevel(level_nr); - if (level.no_level_file) + if (level.no_valid_file) { printf("(no level)\n"); continue; } LoadSolutionTape(level_nr); +#if 1 + if (tape.no_valid_file) +#else if (TAPE_IS_EMPTY(tape)) +#endif { printf("(no tape)\n"); continue; -- 2.34.1