-#define COMPILE_DATE_STRING "[2002-12-23 00:34]"
+#define COMPILE_DATE_STRING "[2002-12-27 15:33]"
return chunk_size;
}
-void LoadTape(int level_nr)
+void LoadTapeFromFilename(char *filename)
{
- char *filename = getTapeFilename(level_nr);
char cookie[MAX_LINE_LEN];
char chunk_name[CHUNK_ID_LEN + 1];
FILE *file;
tape.length_seconds = GetTapeLength();
}
+void LoadTape(int level_nr)
+{
+ char *filename = getTapeFilename(level_nr);
+
+ LoadTapeFromFilename(filename);
+}
+
static void SaveTape_VERS(FILE *file, struct TapeInfo *tape)
{
putFileVersion(file, tape->file_version);
return;
}
- printf("\n");
- printf("-------------------------------------------------------------------------------\n");
+ printf_line('-', 79);
printf("Tape of Level %d (file version %06d, game version %06d)\n",
tape->level_nr, tape->file_version, tape->game_version);
- printf("-------------------------------------------------------------------------------\n");
+ printf_line('-', 79);
for(i=0; i<tape->length; i++)
{
if (i >= MAX_TAPELEN)
break;
+ printf("%03d: ", i);
+
for(j=0; j<MAX_PLAYERS; j++)
{
if (tape->player_participates[j])
printf("(%03d)\n", tape->pos[i].delay);
}
- printf("-------------------------------------------------------------------------------\n");
+ printf_line('-', 79);
}
void LoadLevel(int);
void SaveLevel(int);
+void LoadTapeFromFilename(char *);
void LoadTape(int);
void SaveTape(int);
void DumpTape(struct TapeInfo *);
void StartMoving(int x, int y)
{
+ static boolean use_spring_bug = TRUE;
+ boolean started_moving = FALSE; /* some elements can fall _and_ move */
int element = Feld[x][y];
if (Stop[x][y])
GfxAction[x][y] = GFX_ACTION_DEFAULT;
- if (CAN_FALL(element) && y<lev_fieldy-1)
+ if (CAN_FALL(element) && y < lev_fieldy - 1)
{
if ((x>0 && IS_PLAYER(x-1, y)) || (x<lev_fieldx-1 && IS_PLAYER(x+1, y)))
if (JustBeingPushed(x, y))
if (IS_FREE(x, y+1))
{
InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
Feld[x][y] = EL_QUICKSAND_EMPTYING;
Store[x][y] = EL_ROCK;
PlaySoundLevel(x, y, SND_QUICKSAND_EMPTYING);
Feld[x][y+1] == EL_QUICKSAND_EMPTY)
{
InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
Feld[x][y] = EL_QUICKSAND_FILLING;
Store[x][y] = element;
PlaySoundLevel(x, y, SND_QUICKSAND_FILLING);
if (IS_FREE(x, y+1))
{
InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
Feld[x][y] = EL_MAGIC_WALL_EMPTYING;
Store[x][y] = EL_CHANGED(Store[x][y]);
}
if (IS_FREE(x, y+1))
{
InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
Feld[x][y] = EL_BD_MAGIC_WALL_EMPTYING;
Store[x][y] = EL_CHANGED2(Store[x][y]);
}
Feld[x][y+1] == EL_BD_MAGIC_WALL_ACTIVE))
{
InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
Feld[x][y] =
(Feld[x][y+1] == EL_MAGIC_WALL_ACTIVE ? EL_MAGIC_WALL_FILLING :
EL_BD_MAGIC_WALL_FILLING);
else if (CAN_SMASH(element) && Feld[x][y+1] == EL_ACID)
{
Blurb(x, y);
+
InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+
Store[x][y] = EL_ACID;
}
else if (CAN_SMASH(element) && Feld[x][y+1] == EL_BLOCKED &&
{
Impact(x, y);
}
+ else if (IS_FREE(x, y+1) && element == EL_SPRING && use_spring_bug)
+ {
+ if (MovDir[x][y] == MV_NO_MOVING)
+ {
+ InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
+ }
+ }
else if (IS_FREE(x, y+1))
{
InitMovingField(x, y, MV_DOWN);
+ started_moving = TRUE;
}
else if (element == EL_AMOEBA_DROP)
{
left = !(right = RND(2));
InitMovingField(x, y, left ? MV_LEFT : MV_RIGHT);
+ started_moving = TRUE;
}
}
else if (IS_BELT_ACTIVE(Feld[x][y+1]))
(belt_dir == MV_RIGHT && right_is_free))
{
InitMovingField(x, y, belt_dir);
+ started_moving = TRUE;
+
GfxAction[x][y] = GFX_ACTION_DEFAULT;
}
}
}
- if (CAN_MOVE(element)) /* not "else if" because of EL_SPRING */
+ /* not "else if" because of EL_SPRING */
+ if (CAN_MOVE(element) && !started_moving)
{
int newx, newy;
&& JustBeingPushed(x, y))
return;
+#if 0
+#if 0
if (element == EL_SPRING && MovDir[x][y] == MV_DOWN)
Feld[x][y + 1] = EL_EMPTY; /* was set to EL_BLOCKED above */
+#else
+ if (element == EL_SPRING && MovDir[x][y] != MV_NO_MOVING)
+ {
+ Moving2Blocked(x, y, &newx, &newy);
+ if (Feld[newx][newy] == EL_BLOCKED)
+ Feld[newx][newy] = EL_EMPTY; /* was set to EL_BLOCKED above */
+ }
+#endif
+#endif
if (!MovDelay[x][y]) /* start new movement phase */
{
#endif
#endif
-
-
FrameCounter++;
TimeFrames++;
int original_move_delay_value = player->move_delay_value;
#if DEBUG
- printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES.\n");
+ printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES. [%ld]\n",
+ tape.counter);
#endif
/* scroll remaining steps with finest movement resolution */
static Bitmap *bitmap_font_initial = NULL;
+static void InitGlobal(void);
static void InitSetup(void);
static void InitPlayerInfo(void);
static void InitLevelInfo(void);
static void InitElementInfo(void);
static void InitGraphicInfo(void);
static void InitSoundInfo();
-static void Execute_Debug_Command(char *);
+static void Execute_Command(char *);
void OpenAll(void)
{
- if (options.debug_command)
- {
- Execute_Debug_Command(options.debug_command);
+ InitGlobal(); /* initialize some global variables */
- exit(0);
- }
+ if (options.execute_command)
+ Execute_Command(options.execute_command);
if (options.serveronly)
{
InitGfxBackground();
InitToons();
+ if (global.autoplay_leveldir)
+ {
+ AutoPlayTape();
+ return;
+ }
+
DrawMainMenu();
InitNetworkServer();
}
+void InitGlobal()
+{
+ global.autoplay_leveldir = NULL;
+
+ global.frames_per_second = 0;
+ global.fps_slowdown = FALSE;
+ global.fps_slowdown_factor = 1;
+}
+
void InitSetup()
{
LoadSetup(); /* global setup info */
int i;
#endif
- /* initialize some global variables */
- global.frames_per_second = 0;
- global.fps_slowdown = FALSE;
- global.fps_slowdown_factor = 1;
-
/* initialize screen properties */
InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
Elementeigenschaften1[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
}
-void Execute_Debug_Command(char *command)
+void Execute_Command(char *command)
{
- if (strcmp(command, "create graphicsinfo.conf") == 0)
+ if (strcmp(command, "print graphicsinfo.conf") == 0)
{
int i;
printf("# %s\n",
getFormattedSetupEntry(image_config[i].token,
image_config[i].value));
+
+ exit(0);
}
- else if (strcmp(command, "create soundsinfo.conf") == 0)
+ else if (strcmp(command, "print soundsinfo.conf") == 0)
{
int i;
printf("# %s\n",
getFormattedSetupEntry(sound_config[i].token,
sound_config[i].value));
+
+ exit(0);
}
- else if (strcmp(command, "create musicinfo.conf") == 0)
+ else if (strcmp(command, "print musicinfo.conf") == 0)
{
printf("# (Currently only \"name\" and \"sort_priority\" recognized.)\n");
printf("\n");
printf("%s\n", getFormattedSetupEntry("name", "Classic Music"));
printf("\n");
printf("%s\n", getFormattedSetupEntry("sort_priority", "100"));
+
+ exit(0);
+ }
+ else if (strncmp(command, "dump tape ", 10) == 0)
+ {
+ char *filename = &command[10];
+
+ if (access(filename, F_OK) != 0)
+ Error(ERR_EXIT, "cannot open file '%s'", filename);
+
+ LoadTapeFromFilename(filename);
+ DumpTape(&tape);
+
+ exit(0);
+ }
+ else if (strncmp(command, "autoplay ", 9) == 0)
+ {
+ char *str_copy = getStringCopy(&command[9]);
+ char *str_ptr = strchr(str_copy, ' ');
+
+ global.autoplay_leveldir = str_copy;
+ global.autoplay_level_nr = -1;
+
+ if (str_ptr != NULL)
+ {
+ *str_ptr++ = '\0'; /* terminate leveldir string */
+ global.autoplay_level_nr = atoi(str_ptr); /* get level_nr value */
+ }
}
- else if (strcmp(command, "help") == 0)
+ else
{
- printf("The following commands are recognized:\n");
- printf(" \"create graphicsinfo.conf\"\n");
- printf(" \"create soundsinfo.conf\"\n");
- printf(" \"create musicinfo.conf\"\n");
+ Error(ERR_EXIT_HELP, "unrecognized command '%s'", command);
}
}
return s_copy;
}
+static void printUsage()
+{
+ printf("\n"
+ "Usage: %s [OPTION]... [HOSTNAME [PORT]]\n"
+ "\n"
+ "Options:\n"
+ " -d, --display HOSTNAME[:SCREEN] specify X server display\n"
+ " -b, --basepath DIRECTORY alternative base DIRECTORY\n"
+ " -l, --level DIRECTORY alternative level DIRECTORY\n"
+ " -g, --graphics DIRECTORY alternative graphics DIRECTORY\n"
+ " -s, --sounds DIRECTORY alternative sounds DIRECTORY\n"
+ " -m, --music DIRECTORY alternative music DIRECTORY\n"
+ " -n, --network network multiplayer game\n"
+ " --serveronly only start network server\n"
+ " -v, --verbose verbose mode\n"
+ " --debug display debugging information\n"
+ " -e, --execute COMMAND execute batch COMMAND:\n"
+ "\n"
+ "Valid commands for '--execute' option:\n"
+ " \"print graphicsinfo.conf\" print default graphics config\n"
+ " \"print soundsinfo.conf\" print default sounds config\n"
+ " \"print musicinfo.conf\" print default music config\n"
+ " \"dump tape FILE\" dump tape data from FILE\n"
+ " \"autoplay LEVELDIR\" play level tapes for LEVELDIR\n"
+ "\n",
+ program.command_basename);
+}
+
void GetOptions(char *argv[])
{
char **options_left = &argv[1];
options.graphics_directory = RO_BASE_PATH "/" GRAPHICS_DIRECTORY;
options.sounds_directory = RO_BASE_PATH "/" SOUNDS_DIRECTORY;
options.music_directory = RO_BASE_PATH "/" MUSIC_DIRECTORY;
- options.autoplay_leveldir = NULL;
+ options.execute_command = NULL;
options.serveronly = FALSE;
options.network = FALSE;
options.verbose = FALSE;
options.debug = FALSE;
- options.debug_command = NULL;
while (*options_left)
{
Error(ERR_EXIT_HELP, "unrecognized option '%s'", option);
else if (strncmp(option, "-help", option_len) == 0)
{
- printf("Usage: %s [options] [<server host> [<server port>]]\n"
- "Options:\n"
- " -d, --display <host>[:<scr>] X server display\n"
- " -b, --basepath <directory> alternative base directory\n"
- " -l, --level <directory> alternative level directory\n"
- " -g, --graphics <directory> alternative graphics directory\n"
- " -s, --sounds <directory> alternative sounds directory\n"
- " -m, --music <directory> alternative music directory\n"
- " -a, --autoplay <level series> automatically play level tapes\n"
- " -n, --network network multiplayer game\n"
- " --serveronly only start network server\n"
- " -v, --verbose verbose mode\n"
- " --debug display debugging information\n",
- program.command_basename);
-
- if (options.debug)
- printf(" --debug-command <command> execute special command\n");
+ printUsage();
exit(0);
}
if (option_arg == next_option)
options_left++;
}
- else if (strncmp(option, "-autoplay", option_len) == 0)
- {
- if (option_arg == NULL)
- Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
-
- options.autoplay_leveldir = option_arg;
- if (option_arg == next_option)
- options_left++;
- }
else if (strncmp(option, "-network", option_len) == 0)
{
options.network = TRUE;
{
options.debug = TRUE;
}
- else if (strncmp(option, "-debug-command", option_len) == 0)
+ else if (strncmp(option, "-execute", option_len) == 0)
{
if (option_arg == NULL)
Error(ERR_EXIT_HELP, "option '%s' requires an argument", option_str);
- options.debug_command = option_arg;
+ options.execute_command = option_arg;
if (option_arg == next_option)
options_left++;
}
#endif
+/* ========================================================================= */
+/* some generic helper functions */
+/* ========================================================================= */
+
+void printf_line(char line_char, int line_length)
+{
+ int i;
+
+ for (i=0; i<line_length; i++)
+ printf("%c", line_char);
+
+ printf("\n");
+}
+
+
/* ========================================================================= */
/* the following is only for debugging purpose and normally not used */
/* ========================================================================= */
void dumpErrorFile();
#endif
+void printf_line(char, int);
+
void debug_print_timestamp(int, char *);
#endif /* MISC_H */
{
if (gfx.draw_deactivation_mask != REDRAW_NONE)
{
- if ((gfx.draw_deactivation_mask & REDRAW_FIELD) &&
- x < gfx.sx + gfx.sxsize)
+ if (gfx.draw_deactivation_mask & REDRAW_ALL)
+ return TRUE;
+ else if ((gfx.draw_deactivation_mask & REDRAW_FIELD) &&
+ x < gfx.sx + gfx.sxsize)
return TRUE;
else if ((gfx.draw_deactivation_mask & REDRAW_DOORS) &&
x > gfx.dx)
char *graphics_directory;
char *sounds_directory;
char *music_directory;
- char *autoplay_leveldir;
+ char *execute_command;
boolean serveronly;
boolean network;
boolean verbose;
boolean debug;
-
- char *debug_command;
};
struct VideoSystemInfo
struct GlobalInfo
{
+ char *autoplay_leveldir;
+ int autoplay_level_nr;
+
float frames_per_second;
boolean fps_slowdown;
int fps_slowdown_factor;
OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
- if (options.autoplay_leveldir)
- AutoPlayTape();
-
#if 0
ClearEventQueue();
#endif
tape.playing = FALSE;
tape.fast_forward = FALSE;
tape.index_search = FALSE;
- tape.auto_play = (options.autoplay_leveldir != NULL);
+ tape.auto_play = (global.autoplay_leveldir != NULL);
tape.auto_play_level_solved = FALSE;
tape.quick_resume = FALSE;
tape.single_step = FALSE;
{
tape.pausing = FALSE;
- SetDrawDeactivationMask(REDRAW_FIELD | REDRAW_DOOR_1);
+ SetDrawDeactivationMask(REDRAW_FIELD);
audio.sound_deactivated = TRUE;
}
}
static LevelDirTree *autoplay_leveldir = NULL;
static boolean autoplay_initialized = FALSE;
static int autoplay_level_nr = -1;
+ static int levels_played = 0;
+ static int levels_solved = 0;
if (autoplay_initialized)
{
/* just finished auto-playing tape */
printf("%s.\n", tape.auto_play_level_solved ? "solved" : "NOT SOLVED");
+
+ levels_played++;
+ if (tape.auto_play_level_solved)
+ levels_solved++;
}
else
{
+ DrawCompleteVideoDisplay();
+ audio.sound_enabled = FALSE;
+
autoplay_leveldir = getTreeInfoFromIdentifier(leveldir_first,
- options.autoplay_leveldir);
+ global.autoplay_leveldir);
if (autoplay_leveldir == NULL)
Error(ERR_EXIT, "no such level identifier: '%s'",
- options.autoplay_leveldir);
+ global.autoplay_leveldir);
leveldir_current = autoplay_leveldir;
+ if (global.autoplay_level_nr != -1)
+ {
+ autoplay_leveldir->first_level = global.autoplay_level_nr;
+ autoplay_leveldir->last_level = global.autoplay_level_nr;
+ }
+
autoplay_level_nr = autoplay_leveldir->first_level;
- printf("Playing tapes of level series '%s'.\n", options.autoplay_leveldir);
+ printf_line('=', 79);
+ printf("Automatically playing level tapes\n");
+ printf_line('-', 79);
+ printf("Level series identifier: '%s'\n", autoplay_leveldir->identifier);
+ printf("Level series name: '%s'\n", autoplay_leveldir->name);
+ printf("Level series author: '%s'\n", autoplay_leveldir->author);
+ printf("Number of levels: %d\n", autoplay_leveldir->levels);
+ printf_line('=', 79);
+ printf("\n");
autoplay_initialized = TRUE;
}
LoadLevel(level_nr);
if (level.no_level_file)
{
- printf("(no level file)\n");
+ printf("(no level)\n");
continue;
}
LoadTape(level_nr);
if (TAPE_IS_EMPTY(tape))
{
- printf("(no tape file)\n");
+ printf("(no tape)\n");
continue;
}
- break;
- }
+ printf("playing tape ... ");
+
+ TapeStartGamePlaying();
+ TapeStartIndexSearch();
- if (autoplay_level_nr >= autoplay_leveldir->last_level)
- CloseAllAndExit(0);
+ return;
+ }
- printf("playing tape ... ");
+ printf("\n");
+ printf_line('=', 79);
+ printf("Summary\n");
+ printf_line('-', 79);
+ printf("Number of levels played: %d\n", levels_played);
+ printf("Number of levels solved: %d (%d%%)\n", levels_solved,
+ levels_solved * 100 / levels_played);
+ printf_line('=', 79);
- TapeStartGamePlaying();
- TapeStartIndexSearch();
+ CloseAllAndExit(0);
}
{
stepsize = 20;
door_delay_value = 0;
+
StopSound(SND_MENU_DOOR_OPENING);
StopSound(SND_MENU_DOOR_CLOSING);
}
+ if (global.autoplay_leveldir)
+ {
+ door_state |= DOOR_NO_DELAY;
+ door_state &= ~DOOR_CLOSE_ALL;
+ }
+
if (door_state & DOOR_ACTION)
{
if (!(door_state & DOOR_NO_DELAY))
Bitmap *bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
GC gc = bitmap->stored_clip_gc;
- WaitUntilDelayReached(&door_delay, door_delay_value);
+ if (!(door_state & DOOR_NO_DELAY))
+ WaitUntilDelayReached(&door_delay, door_delay_value);
if (door_state & DOOR_ACTION_1)
{