EL_DRACHE,
EL_SONDE,
- EL_LEERRAUM,
- EL_LEERRAUM,
- EL_LEERRAUM,
+ EL_MAUER_X,
+ EL_MAUER_Y,
+ EL_MAUER_XY,
EL_CHAR_A + ('S' - 'A'),
EL_CHAR_A + ('O' - 'A'),
{
if ((event->window == window) &&
(event->data.l[0] == XInternAtom(display, "WM_DELETE_WINDOW", FALSE)))
- CloseAll();
+ game_status = EXITGAME;
}
void HandleButton(int mx, int my, int button)
BOOL CreateNewScoreFile()
{
int i,j,k;
- char filename[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
char empty_alias[MAX_NAMELEN];
FILE *file;
BOOL CreateNewNamesFile(int mode)
{
- char filename[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
FILE *file;
if (mode==PLAYER_LEVEL)
BOOL LoadLevelInfo()
{
int i;
- char filename[MAX_FILENAME];
- char cookie[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
+ char cookie[MAX_FILENAME_LEN];
FILE *file;
sprintf(filename,"%s/%s",level_directory,LEVDIR_FILENAME);
void LoadLevel(int level_nr)
{
int i,x,y;
- char filename[MAX_FILENAME];
- char cookie[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
+ char cookie[MAX_FILENAME_LEN];
FILE *file;
sprintf(filename,"%s/%s/%d",
level_directory,leveldir[leveldir_nr].filename,level_nr);
if (!(file = fopen(filename,"r")))
- {
-/*
- Error(ERR_RETURN, "cannot load level '%s'", filename);
-*/
- }
+ Error(ERR_RETURN, "cannot load level '%s' - creating new level", filename);
else
{
fgets(cookie,LEVEL_COOKIE_LEN,file);
void LoadLevelTape(int level_nr)
{
int i;
- char filename[MAX_FILENAME];
- char cookie[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
+ char cookie[MAX_FILENAME_LEN];
FILE *file;
BOOL levelrec_10 = FALSE;
void LoadScore(int level_nr)
{
int i,j;
- char filename[MAX_FILENAME];
- char cookie[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
+ char cookie[MAX_FILENAME_LEN];
FILE *file;
sprintf(filename,"%s/%s/%s",
void LoadPlayerInfo(int mode)
{
int i;
- char filename[MAX_FILENAME];
- char cookie[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
+ char cookie[MAX_FILENAME_LEN];
FILE *file;
char *login_name = GetLoginName();
struct PlayerInfo default_player, new_player;
void SaveLevel(int level_nr)
{
int i,x,y;
- char filename[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
FILE *file;
sprintf(filename,"%s/%s/%d",
void SaveLevelTape(int level_nr)
{
int i;
- char filename[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
FILE *file;
BOOL new_tape = TRUE;
void SaveScore(int level_nr)
{
int i,j;
- char filename[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
FILE *file;
sprintf(filename,"%s/%s/%s",
void SavePlayerInfo(int mode)
{
int i;
- char filename[MAX_FILENAME];
- char cookie[MAX_FILENAME];
+ char filename[MAX_FILENAME_LEN];
+ char cookie[MAX_FILENAME_LEN];
FILE *file;
struct PlayerInfo default_player;
int version_10_file = FALSE;
phase = 2-MovDelay[x][y]/delay;
if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x),SCREENY(y)))
DrawGraphic(SCREENX(x),SCREENY(y),
- (Store[x][y]==MV_LEFT ? GFX_MAUER_L1 : GFX_MAUER_R1)+phase);
+ (MovDir[x][y] == MV_LEFT ? GFX_MAUER_LEFT :
+ MovDir[x][y] == MV_RIGHT ? GFX_MAUER_RIGHT :
+ MovDir[x][y] == MV_UP ? GFX_MAUER_UP :
+ GFX_MAUER_DOWN ) + phase);
if (!MovDelay[x][y])
{
- if (Store[x][y]==MV_LEFT)
+ if (MovDir[x][y] == MV_LEFT)
{
if (IN_LEV_FIELD(x-1,y) && IS_MAUER(Feld[x-1][y]))
DrawLevelField(x-1,y);
}
- else
+ else if (MovDir[x][y] == MV_RIGHT)
{
if (IN_LEV_FIELD(x+1,y) && IS_MAUER(Feld[x+1][y]))
DrawLevelField(x+1,y);
}
+ else if (MovDir[x][y] == MV_UP)
+ {
+ if (IN_LEV_FIELD(x,y-1) && IS_MAUER(Feld[x][y-1]))
+ DrawLevelField(x,y-1);
+ }
+ else
+ {
+ if (IN_LEV_FIELD(x,y+1) && IS_MAUER(Feld[x][y+1]))
+ DrawLevelField(x,y+1);
+ }
- Feld[x][y] = EL_MAUER_LEBT;
+ Feld[x][y] = Store[x][y];
Store[x][y] = 0;
+ MovDir[x][y] = MV_NO_MOVING;
DrawLevelField(x,y);
}
}
void MauerAbleger(int ax, int ay)
{
+ int element = Feld[ax][ay];
+ BOOL oben_frei = FALSE, unten_frei = FALSE;
BOOL links_frei = FALSE, rechts_frei = FALSE;
+ BOOL oben_massiv = FALSE, unten_massiv = FALSE;
BOOL links_massiv = FALSE, rechts_massiv = FALSE;
if (!MovDelay[ax][ay]) /* neue Mauer / noch nicht gewartet */
return;
}
+ if (IN_LEV_FIELD(ax,ay-1) && IS_FREE(ax,ay-1))
+ oben_frei = TRUE;
+ if (IN_LEV_FIELD(ax,ay+1) && IS_FREE(ax,ay+1))
+ unten_frei = TRUE;
if (IN_LEV_FIELD(ax-1,ay) && IS_FREE(ax-1,ay))
links_frei = TRUE;
if (IN_LEV_FIELD(ax+1,ay) && IS_FREE(ax+1,ay))
rechts_frei = TRUE;
- if (links_frei)
+ if (element == EL_MAUER_Y || element == EL_MAUER_XY)
{
- Feld[ax-1][ay] = EL_MAUERND;
- Store[ax-1][ay] = MV_LEFT;
- if (IN_SCR_FIELD(SCREENX(ax-1),SCREENY(ay)))
- DrawGraphic(SCREENX(ax-1),SCREENY(ay),GFX_MAUER_L1);
+ if (oben_frei)
+ {
+ Feld[ax][ay-1] = EL_MAUERND;
+ Store[ax][ay-1] = element;
+ MovDir[ax][ay-1] = MV_UP;
+ if (IN_SCR_FIELD(SCREENX(ax),SCREENY(ay-1)))
+ DrawGraphic(SCREENX(ax),SCREENY(ay-1),GFX_MAUER_UP);
+ }
+ if (unten_frei)
+ {
+ Feld[ax][ay+1] = EL_MAUERND;
+ Store[ax][ay+1] = element;
+ MovDir[ax][ay+1] = MV_DOWN;
+ if (IN_SCR_FIELD(SCREENX(ax),SCREENY(ay+1)))
+ DrawGraphic(SCREENX(ax),SCREENY(ay+1),GFX_MAUER_DOWN);
+ }
}
- if (rechts_frei)
+
+ if (element == EL_MAUER_X || element == EL_MAUER_XY ||
+ element == EL_MAUER_LEBT)
{
- Feld[ax+1][ay] = EL_MAUERND;
- Store[ax+1][ay] = MV_RIGHT;
- if (IN_SCR_FIELD(SCREENX(ax+1),SCREENY(ay)))
- DrawGraphic(SCREENX(ax+1),SCREENY(ay),GFX_MAUER_R1);
+ if (links_frei)
+ {
+ Feld[ax-1][ay] = EL_MAUERND;
+ Store[ax-1][ay] = element;
+ MovDir[ax-1][ay] = MV_LEFT;
+ if (IN_SCR_FIELD(SCREENX(ax-1),SCREENY(ay)))
+ DrawGraphic(SCREENX(ax-1),SCREENY(ay),GFX_MAUER_LEFT);
+ }
+ if (rechts_frei)
+ {
+ Feld[ax+1][ay] = EL_MAUERND;
+ Store[ax+1][ay] = element;
+ MovDir[ax+1][ay] = MV_RIGHT;
+ if (IN_SCR_FIELD(SCREENX(ax+1),SCREENY(ay)))
+ DrawGraphic(SCREENX(ax+1),SCREENY(ay),GFX_MAUER_RIGHT);
+ }
}
- if (links_frei || rechts_frei)
+ if (element == EL_MAUER_LEBT && (links_frei || rechts_frei))
DrawLevelField(ax,ay);
+ if (!IN_LEV_FIELD(ax,ay-1) || IS_MAUER(Feld[ax][ay-1]))
+ oben_massiv = TRUE;
+ if (!IN_LEV_FIELD(ax,ay+1) || IS_MAUER(Feld[ax][ay+1]))
+ unten_massiv = TRUE;
if (!IN_LEV_FIELD(ax-1,ay) || IS_MAUER(Feld[ax-1][ay]))
links_massiv = TRUE;
if (!IN_LEV_FIELD(ax+1,ay) || IS_MAUER(Feld[ax+1][ay]))
rechts_massiv = TRUE;
- if (links_massiv && rechts_massiv)
+ if (((oben_massiv && unten_massiv) ||
+ element == EL_MAUER_X || element == EL_MAUER_LEBT) &&
+ ((links_massiv && rechts_massiv) ||
+ element == EL_MAUER_Y))
Feld[ax][ay] = EL_MAUERWERK;
}
AusgangstuerBlinken(x,y);
else if (element==EL_MAUERND)
MauerWaechst(x,y);
- else if (element==EL_MAUER_LEBT)
+ else if (element==EL_MAUER_LEBT ||
+ element==EL_MAUER_X ||
+ element==EL_MAUER_Y ||
+ element==EL_MAUER_XY)
MauerAbleger(x,y);
else if (element==EL_BURNING)
CheckForDragon(x,y);
InitJoystick();
InitRND(NEW_RANDOMIZE);
- signal(SIGINT, CloseAll);
- signal(SIGTERM, CloseAll);
+ signal(SIGINT, CloseAllAndExit);
+ signal(SIGTERM, CloseAllAndExit);
InitDisplay();
InitWindow(argc, argv);
local_player = &stored_player[0];
if (!LoadLevelInfo()) /* global level info */
- CloseAll();
+ Error(ERR_EXIT, NULL);
LoadPlayerInfo(PLAYER_SETUP); /* global setup info */
LoadPlayerInfo(PLAYER_LEVEL); /* level specific info */
{ GFX_GEBLUBBER, 4 },
{ GFX_DYNAMIT, 7 },
{ GFX_DYNABOMB, 4 },
+ { GFX_EXPLOSION, 8 },
{ GFX_SOKOBAN_OBJEKT, 1 },
{ GFX_FUNKELN_BLAU, 3 },
{ GFX_FUNKELN_WEISS, 3 },
switch(xpm_err)
{
case XpmOpenFailed:
- fprintf(stderr,"Cannot open Xpm file '%s' !\n",filename);
- CloseAll();
- exit(-1);
+ Error(ERR_EXIT, "cannot open XPM file '%s'", filename);
case XpmFileInvalid:
- fprintf(stderr,"Invalid Xpm file '%s'!\n",filename);
- CloseAll();
- exit(-1);
+ Error(ERR_EXIT, "invalid XPM file '%s'", filename);
case XpmNoMemory:
- fprintf(stderr,"Not enough memory for Xpm file '%s'!\n",filename);
- CloseAll();
- exit(1);
+ Error(ERR_EXIT, "not enough memory for XPM file '%s'", filename);
case XpmColorFailed:
- fprintf(stderr,"Can't get colors for Xpm file '%s'!\n",filename);
- CloseAll();
- exit(-1);
+ Error(ERR_EXIT, "cannot get colors for XPM file '%s'", filename);
default:
break;
}
case GIF_Success:
break;
case GIF_OpenFailed:
- fprintf(stderr,"Cannot open GIF file '%s' !\n",filename);
- CloseAll();
- exit(-1);
+ Error(ERR_EXIT, "cannot open GIF file '%s'", filename);
case GIF_ReadFailed:
- fprintf(stderr,"Cannot read GIF file '%s' !\n",filename);
- CloseAll();
- exit(-1);
+ Error(ERR_EXIT, "cannot read GIF file '%s'", filename);
case GIF_FileInvalid:
- fprintf(stderr,"Invalid GIF file '%s'!\n",filename);
- CloseAll();
- exit(-1);
+ Error(ERR_EXIT, "invalid GIF file '%s'", filename);
case GIF_NoMemory:
- fprintf(stderr,"Not enough memory for GIF file '%s'!\n",filename);
- CloseAll();
- exit(1);
+ Error(ERR_EXIT, "not enough memory for GIF file '%s'", filename);
case GIF_ColorFailed:
- fprintf(stderr,"Can't get colors for GIF file '%s'!\n",filename);
- CloseAll();
- exit(-1);
+ Error(ERR_EXIT, "cannot get colors for GIF file '%s'", filename);
default:
break;
}
case BitmapSuccess:
break;
case BitmapOpenFailed:
- fprintf(stderr,"Bitmap file open failed on '%s' !\n",filename);
- CloseAll();
- exit(-1);
- break;
+ Error(ERR_EXIT, "cannot open XBM file '%s'", filename);
case BitmapFileInvalid:
- fprintf(stderr,"Bitmap file invalid: '%s' !\n",filename);
- CloseAll();
- exit(-1);
- break;
+ Error(ERR_EXIT, "invalid XBM file '%s'", filename);
case BitmapNoMemory:
- fprintf(stderr,"No memory for file '%s' !\n",filename);
- CloseAll();
- exit(-1);
+ Error(ERR_EXIT, "not enough memory for XBM file '%s'", filename);
break;
default:
break;
EL_BETON,
EL_MAUERWERK,
EL_MAUER_LEBT,
+ EL_MAUER_X,
+ EL_MAUER_Y,
+ EL_MAUER_XY,
EL_FELSBODEN,
EL_AUSGANG_ZU,
EL_AUSGANG_ACT,
EL_MAUERWERK,
EL_FELSBODEN,
EL_MAUER_LEBT,
+ EL_MAUER_X,
+ EL_MAUER_Y,
+ EL_MAUER_XY,
EL_MAUERND
};
static int ep_mauer_num = sizeof(ep_mauer)/sizeof(int);
Elementeigenschaften[i] |= (EP_BIT_CHAR | EP_BIT_INACTIVE);
}
-void CloseAll()
+void CloseAllAndExit(int exit_value)
{
int i;
XCloseDisplay(display);
}
- exit(0);
+ exit(exit_value);
}
#include "main.h"
void OpenAll(int, char **);
-void CloseAll();
+void CloseAllAndExit(int);
void InitJoystick(void);
#endif
#include "joystick.h"
#include "misc.h"
-/*
-#include "tools.h"
-#include "game.h"
-#include "events.h"
-#include "sound.h"
-#include "misc.h"
-#include "buttons.h"
-#include <math.h>
-*/
-
void CheckJoystickData()
{
int i;
char *level_directory = LEVEL_PATH;
int width, height;
+char *program_name = NULL;
char *display_name = NULL;
char *server_host = NULL;
int server_port = 0;
};
int num_bg_loops = sizeof(background_loop)/sizeof(int);
-char *program_name;
-
-#define MAX_OPTION_LEN 1024
-
-static void fatal_option()
-{
- fprintf(stderr,"Try '%s --help' for more information.\n",
- program_name);
- exit(1);
-}
-
-static void fatal_unrecognized_option(char *option)
-{
- fprintf(stderr,"%s: unrecognized option '%s'\n",
- program_name, option);
- fatal_option();
-}
-
-static void fatal_option_requires_argument(char *option)
-{
- fprintf(stderr,"%s: option '%s' requires an argument\n",
- program_name, option);
- fatal_option();
-}
-
-static void fatal_invalid_option_argument(char *option)
-{
- fprintf(stderr,"%s: option '%s' has invalid argument\n",
- program_name, option);
- fatal_option();
-}
-
-static void fatal_too_many_arguments()
-{
- fprintf(stderr,"%s: too many arguments\n",
- program_name);
- fatal_option();
-}
-
-extern void fatal(char *);
-
int main(int argc, char *argv[])
{
- char **options_left = &argv[1];
-
program_name = (strrchr(argv[0],'/') ? strrchr(argv[0],'/') + 1 : argv[0]);
- while (*options_left)
- {
- char option_str[MAX_OPTION_LEN];
- char *option = options_left[0];
- char *next_option = options_left[1];
- char *option_arg = NULL;
- int option_len = strlen(option);
-
- strcpy(option_str, option); /* copy argument into buffer */
- option = option_str;
-
- if (strcmp(option, "--") == 0) /* stop scanning arguments */
- break;
-
- if (option_len >= MAX_OPTION_LEN)
- fatal_unrecognized_option(option);
-
- if (strncmp(option, "--", 2) == 0) /* treat '--' like '-' */
- option++;
-
- option_arg = strchr(option, '=');
- if (option_arg == NULL) /* no '=' in option */
- option_arg = next_option;
- else
- {
- *option_arg++ = '\0'; /* cut argument from option */
- if (*option_arg == '\0') /* no argument after '=' */
- fatal_invalid_option_argument(option);
- }
-
- option_len = strlen(option);
-
- if (strcmp(option, "-") == 0)
- fatal_unrecognized_option(option);
- else if (strncmp(option, "-help", option_len) == 0)
- {
- printf("Usage: %s [options] [server.name [port]]\n"
- "Options:\n"
- " -d, --display machine:0 X server display\n"
- " -l, --levels directory alternative level directory\n"
- " -v, --verbose verbose mode\n",
- program_name);
- exit(0);
- }
- else if (strncmp(option, "-display", option_len) == 0)
- {
- if (option_arg == NULL)
- fatal_option_requires_argument(option_str);
-
- display_name = option_arg;
- if (option_arg == next_option)
- options_left++;
-
- printf("--display == '%s'\n", display_name);
- }
- else if (strncmp(option, "-levels", option_len) == 0)
- {
- if (option_arg == NULL)
- fatal_option_requires_argument(option_str);
-
- level_directory = option_arg;
- if (option_arg == next_option)
- options_left++;
-
- printf("--levels == '%s'\n", level_directory);
- }
- else if (strncmp(option, "-verbose", option_len) == 0)
- {
- printf("--verbose\n");
-
- verbose = TRUE;
- }
- else if (*option == '-')
- fatal_unrecognized_option(option_str);
- else if (server_host == NULL)
- {
- server_host = *options_left;
-
- printf("server.name == '%s'\n", server_host);
- }
- else if (server_port == 0)
- {
- server_port = atoi(*options_left);
- if (server_port < 1024)
- fatal("Bad port number");
-
- printf("port == %d\n", server_port);
- }
- else
- fatal_too_many_arguments();
-
- options_left++;
- }
-
- /*
- printf("All went fine -- exiting\n");
- exit(0);
- */
-
- /*
- if (argc>1)
- level_directory = argv[1];
- */
-
-
- /*
- if (argc > 1)
- server_host = argv[1];
-
- if (argc > 2)
- server_port = atoi(argv[2]);
- */
-
-
#ifdef MSDOS
_fmode = O_BINARY;
#endif
+ GetOptions(argv);
OpenAll(argc,argv);
EventLoop();
- CloseAll();
-
- exit(0);
+ CloseAllAndExit(0);
+ exit(0); /* to keep compilers happy */
}
#define MAX_LEVDIR_ENTRIES 15
#define MAX_SCORE_ENTRIES 15
-#define MAX_FILENAME 256
+#define MAX_OPTION_LEN 256
+#define MAX_FILENAME_LEN 256
#define MAX_NUM_AMOEBA 100
#define MAX_ELEMENTS 512
extern char *level_directory;
extern int width, height;
+extern char *program_name;
extern char *display_name;
extern char *server_host;
extern int server_port;
extern int background_loop[];
extern int num_bg_loops;
-extern char *program_name;
-
/* often used screen positions */
#define SX 8
#define EL_CHAR_COPY (EL_CHAR_ASCII0+94)
#define EL_CHAR_END (EL_CHAR_START+79)
-#define EL_UNUSED_200 200
+#define EL_MAUER_X 200
+#define EL_MAUER_Y 201
+#define EL_MAUER_XY 202
+
+#define EL_UNUSED_200 203
/* ... */
#define EL_UNUSED_255 255
#define GFX_MAULWURF 145
#define GFX_SCHWEIN 146
#define GFX_DRACHE 147
+#define GFX_MAUER_XY 148
+#define GFX_MAUER_X 149
+#define GFX_MAUER_Y 150
#define GFX_EDELSTEIN_ROT 152
#define GFX_EDELSTEIN_LILA 154
#define GFX_DYNABOMB_XL 156
#define GFX_SONDE 159
/* Zeile 10 (160) */
#define GFX_EDELSTEIN_BD 163
-#define GFX_MAUER_R1 165
+#define GFX_MAUER_RIGHT 165
+#define GFX_MAUER_R1 GFX_MAUER_RIGHT
#define GFX_MAUER_R 167
-#define GFX_MAUER_L1 168
+#define GFX_MAUER_LEFT 168
+#define GFX_MAUER_L1 GFX_MAUER_LEFT
#define GFX_MAUER_L 170
#define GFX_MAUER_LEBT 171
#define GFX_SIEB2_LEER 172
#define GFX_SPIELER4_RIGHT (GFX_START_ROCKSHEROES +10*HEROES_PER_LINE + 4)
#define GFX_SPIELER4_PUSH_RIGHT (GFX_START_ROCKSHEROES +11*HEROES_PER_LINE + 0)
#define GFX_SPIELER4_PUSH_LEFT (GFX_START_ROCKSHEROES +11*HEROES_PER_LINE + 4)
+#define GFX_MAUER_DOWN (GFX_START_ROCKSHEROES +12*HEROES_PER_LINE + 0)
+#define GFX_MAUER_UP (GFX_START_ROCKSHEROES +12*HEROES_PER_LINE + 3)
+
#define GFX_SONDE_START (GFX_START_ROCKSHEROES + 9*HEROES_PER_LINE + 8)
#define GFX_SCHWEIN_DOWN (GFX_START_ROCKSHEROES + 0*HEROES_PER_LINE + 8)
#define GFX_SCHWEIN_UP (GFX_START_ROCKSHEROES + 0*HEROES_PER_LINE +12)
}
}
-void Error(BOOL fatal_error, char *format_str, ...)
+void GetOptions(char *argv[])
{
- FILE *output_stream = stderr;
- va_list ap;
- char *format_ptr;
- char *s_value;
- int i_value;
- double d_value;
+ char **options_left = &argv[1];
- va_start(ap, format_str); /* ap points to first unnamed argument */
+ while (*options_left)
+ {
+ char option_str[MAX_OPTION_LEN];
+ char *option = options_left[0];
+ char *next_option = options_left[1];
+ char *option_arg = NULL;
+ int option_len = strlen(option);
- fprintf(output_stream, "%s: ", program_name);
+ strcpy(option_str, option); /* copy argument into buffer */
+ option = option_str;
- for(format_ptr=format_str; *format_ptr; format_ptr++)
- {
- if (*format_ptr != '%')
+ if (strcmp(option, "--") == 0) /* stop scanning arguments */
+ break;
+
+ if (option_len >= MAX_OPTION_LEN)
+ Error(ERR_EXITHELP, "unrecognized option '%s'", option);
+
+ if (strncmp(option, "--", 2) == 0) /* treat '--' like '-' */
+ option++;
+
+ option_arg = strchr(option, '=');
+ if (option_arg == NULL) /* no '=' in option */
+ option_arg = next_option;
+ else
+ {
+ *option_arg++ = '\0'; /* cut argument from option */
+ if (*option_arg == '\0') /* no argument after '=' */
+ Error(ERR_EXITHELP, "option '%s' has invalid argument", option_str);
+ }
+
+ option_len = strlen(option);
+
+ if (strcmp(option, "-") == 0)
+ Error(ERR_EXITHELP, "unrecognized option '%s'", option);
+ else if (strncmp(option, "-help", option_len) == 0)
+ {
+ printf("Usage: %s [options] [server.name [port]]\n"
+ "Options:\n"
+ " -d, --display machine:0 X server display\n"
+ " -l, --levels directory alternative level directory\n"
+ " -v, --verbose verbose mode\n",
+ program_name);
+ exit(0);
+ }
+ else if (strncmp(option, "-display", option_len) == 0)
+ {
+ if (option_arg == NULL)
+ Error(ERR_EXITHELP, "option '%s' requires an argument", option_str);
+
+ display_name = option_arg;
+ if (option_arg == next_option)
+ options_left++;
+
+ printf("--display == '%s'\n", display_name);
+ }
+ else if (strncmp(option, "-levels", option_len) == 0)
+ {
+ if (option_arg == NULL)
+ Error(ERR_EXITHELP, "option '%s' requires an argument", option_str);
+
+ level_directory = option_arg;
+ if (option_arg == next_option)
+ options_left++;
+
+ printf("--levels == '%s'\n", level_directory);
+ }
+ else if (strncmp(option, "-verbose", option_len) == 0)
{
- fprintf(output_stream, "%c", *format_ptr);
- continue;
+ printf("--verbose\n");
+
+ verbose = TRUE;
}
+ else if (*option == '-')
+ Error(ERR_EXITHELP, "unrecognized option '%s'", option_str);
+ else if (server_host == NULL)
+ {
+ server_host = *options_left;
- switch(*++format_ptr)
+ printf("server.name == '%s'\n", server_host);
+ }
+ else if (server_port == 0)
{
- case 'd':
- i_value = va_arg(ap, int);
- fprintf(output_stream, "%d", i_value);
- break;
-
- case 'f':
- d_value = va_arg(ap, double);
- fprintf(output_stream, "%f", d_value);
- break;
-
- case 's':
- s_value = va_arg(ap, char *);
- fprintf(output_stream, "%s", s_value);
- break;
-
- default:
- fprintf(stderr, "\nfatal(): invalid format string: %s\n", format_str);
- exit(-1);
+ server_port = atoi(*options_left);
+ if (server_port < 1024)
+ Error(ERR_EXITHELP, "bad port number '%d'", server_port);
+
+ printf("port == %d\n", server_port);
}
+ else
+ Error(ERR_EXITHELP, "too many arguments");
+
+ options_left++;
}
+}
- va_end(ap);
+void Error(int mode, char *format_str, ...)
+{
+ FILE *output_stream = stderr;
+
+ if (format_str)
+ {
+ va_list ap;
+ char *format_ptr;
+ char *s_value;
+ int i_value;
+ double d_value;
+
+ fprintf(output_stream, "%s: ", program_name);
- fprintf(output_stream, "\n");
+ va_start(ap, format_str); /* ap points to first unnamed argument */
+
+ for(format_ptr=format_str; *format_ptr; format_ptr++)
+ {
+ if (*format_ptr != '%')
+ {
+ fprintf(output_stream, "%c", *format_ptr);
+ continue;
+ }
+
+ switch(*++format_ptr)
+ {
+ case 'd':
+ i_value = va_arg(ap, int);
+ fprintf(output_stream, "%d", i_value);
+ break;
+
+ case 'f':
+ d_value = va_arg(ap, double);
+ fprintf(output_stream, "%f", d_value);
+ break;
+
+ case 's':
+ s_value = va_arg(ap, char *);
+ fprintf(output_stream, "%s", s_value);
+ break;
+
+ default:
+ fprintf(stderr, "\nError(): invalid format string: %s\n",format_str);
+ CloseAllAndExit(10);
+ }
+ }
+
+ va_end(ap);
+
+ fprintf(output_stream, "\n");
+ }
+
+ if (mode == ERR_EXITHELP)
+ fprintf(output_stream, "%s: Try option '--help' for more information.\n",
+ program_name);
- if (fatal_error)
+ if (mode == ERR_EXIT || mode == ERR_EXITHELP)
{
fprintf(output_stream, "%s: aborting\n", program_name);
- CloseAll();
- exit(1);
+ CloseAllAndExit(1);
}
}
#define ERR_RETURN 0
#define ERR_EXIT 1
+#define ERR_EXITHELP 2
void InitCounter(void);
unsigned long Counter(void);
unsigned int InitRND(long);
char *GetLoginName(void);
void MarkTileDirty(int, int);
-void Error(BOOL, char *, ...);
+void GetOptions(char **);
+void Error(int, char *, ...);
#endif
if (Store[last_jx][last_jy])
{
DrawLevelElement(last_jx,last_jy, Store[last_jx][last_jy]);
- DrawLevelElementThruMask(last_jx,last_jy, Feld[last_jx][last_jy]);
+ DrawLevelFieldThruMask(last_jx,last_jy);
}
else if (Feld[last_jx][last_jy] == EL_DYNAMIT)
DrawDynamite(last_jx,last_jy);
DrawGraphicThruMask(sx,sy, graphic + phase);
}
+ if ((last_jx != jx || last_jy != jy) && Feld[last_jx][last_jy]==EL_EXPLODING)
+ {
+ int phase = Frame[last_jx][last_jy];
+ int delay = 2;
+
+ if (phase > 2)
+ DrawGraphicThruMask(SCREENX(last_jx),SCREENY(last_jy),
+ GFX_EXPLOSION + ((phase-1)/delay-1));
+ }
+
if (direct_draw_on)
{
int dest_x = SX + SCREENX(MIN(jx,last_jx))*TILEX;
DrawLevelElementExt(x,y, 0,0, element, NO_CUTTING, USE_MASKING);
}
+void DrawLevelFieldThruMask(int x, int y)
+{
+ DrawLevelElementExt(x,y, 0,0, Feld[x][y], NO_CUTTING, USE_MASKING);
+}
+
void ErdreichAnbroeckeln(int x, int y)
{
int i, width, height, cx,cy;
Store[ux][uy]==EL_AMOEBE_NASS)
cut_mode = CUT_ABOVE;
else if (Store[ux][uy]==EL_MORAST_VOLL ||
-
-#if 0
- Store[ux][uy]==EL_SALZSAEURE ||
-#endif
-
- Store[ux][uy]==EL_SIEB_VOLL ||
- Store[ux][uy]==EL_SIEB2_VOLL)
+ Store[ux][uy]==EL_SIEB_VOLL ||
+ Store[ux][uy]==EL_SIEB2_VOLL)
cut_mode = CUT_BELOW;
if (cut_mode==CUT_ABOVE)
else
DrawScreenElementShifted(x,y, 0,MovPos[ux][uy], element, cut_mode);
-#if 1
if (Store[ux][uy] == EL_SALZSAEURE)
DrawLevelElementThruMask(ux,uy+1, EL_SALZSAEURE);
-#endif
-
}
else if (IS_BLOCKED(ux,uy))
{
case EL_ZEIT_VOLL: return(GFX_ZEIT_VOLL);
case EL_ZEIT_LEER: return(GFX_ZEIT_LEER);
case EL_MAUER_LEBT: return(GFX_MAUER_LEBT);
+ case EL_MAUER_X: return(GFX_MAUER_X);
+ case EL_MAUER_Y: return(GFX_MAUER_Y);
+ case EL_MAUER_XY: return(GFX_MAUER_XY);
case EL_EDELSTEIN_BD: return(GFX_EDELSTEIN_BD);
case EL_EDELSTEIN_GELB: return(GFX_EDELSTEIN_GELB);
case EL_EDELSTEIN_ROT: return(GFX_EDELSTEIN_ROT);
void DrawLevelElementShifted(int, int, int, int, int, int);
void DrawScreenElementThruMask(int, int, int);
void DrawLevelElementThruMask(int, int, int);
+void DrawLevelFieldThruMask(int, int);
void ErdreichAnbroeckeln(int, int);
void DrawScreenElement(int, int, int);
void DrawLevelElement(int, int, int);