# you shouldn't need to change anything below #
#-----------------------------------------------------------------------------#
-PROGNAME = rocksndiamonds
-SRC_DIR = src
-
MAKE = make
-RM = rm -f
-MV = mv -f
-MAKE_CMD = $(MAKE) -C $(SRC_DIR)
+SRC_DIR = src
+MAKE_CMD = @$(MAKE) -C $(SRC_DIR)
all:
backup:
./Scripts/make_backup.sh
-dist: dist-unix dist-dos
-
dist-unix:
./Scripts/make_dist_unix.sh .
dist-dos:
./Scripts/make_dist_dos.sh .
+dist: dist-unix dist-dos
+
depend:
$(MAKE_CMD) depend
# you shouldn't need to change anything below #
#-----------------------------------------------------------------------------#
-PROGNAME = ../rocksndiamonds
+ifdef COMSPEC
+PLATFORM = dos
+else
+PLATFORM = unix
+endif
+ifeq ($(PLATFORM),unix)
RM = rm -f
+PROGNAME = ../rocksndiamonds
+LIBS = -L$(XLIB_PATH) $(EXTRA_X11_LIBS) -lX11 -lm $(EXTRA_LIBS)
+else
+RM = del
+PROGNAME = ..\rocks.exe
+LIBS = -lm -lalleg
+endif
+
CPP = $(CC) -E
CONFIG_GAME_DIR = -DGAME_DIR="\"$(GAME_DIR)\""
CONFIG = $(CONFIG_GAME_DIR) $(SOUNDS) $(JOYSTICK) \
$(CONFIG_SCORE_ENTRIES) $(XPM_INCLUDE_FILE)
-# DEBUG = -DDEBUG -g -ansi -pedantic -Wall
-DEBUG = -DDEBUG -g -Wall
-# DEBUG = -O6
+# DEBUG = -DDEBUG -g -Wall -ansi -pedantic
+# DEBUG = -DDEBUG -g -Wall
+DEBUG = -O3 -Wall
+# DEBUG = -O3
# SYSTEM = -Aa -D_HPUX_SOURCE -Dhpux # for HP-UX (obsolete)
# SYSTEM = -DSYSV -Ae # for HP-UX
# LIBS = -L/usr/X11R6/lib -lX11 -lm
# LIBS = -L/usr/X11R6/lib $(EXTRA_X11_LIBS) -lX11 -lm $(EXTRA_LIBS)
-LIBS = -L$(XLIB_PATH) $(EXTRA_X11_LIBS) -lX11 -lm $(EXTRA_LIBS)
+
+# LIBS = -L$(XLIB_PATH) $(EXTRA_X11_LIBS) -lX11 -lm $(EXTRA_LIBS)
# CFLAGS = -O2 $(CONFIG) $(SYSTEM)
CFLAGS = $(DEBUG) $(CONFIG) $(SYSTEM) $(INCL)
{
Drawable dest_drawto;
int dest_xoffset, dest_yoffset;
- int graphic;
+ int graphic = GFX_SPIELER1; /* default */
int graphic_offset = (PLAYER_BUTTON_XSIZE - TILEX/2)/2;
int xpos, ypos;
int cx = DOOR_GFX_PAGEX4, cy = 0;
void HandleAnimation(int mode)
{
- static long animstart_delay = -1;
- static long animstart_delay_value = 0;
+ static unsigned long animstart_delay = -1;
+ static unsigned long animstart_delay_value = 0;
static boolean anim_restart = TRUE;
static boolean reset_delay = TRUE;
static int toon_nr = 0;
static int delta_x = 0, delta_y = 0;
static int frame = 0, frame_step = 1;
static boolean horiz_move, vert_move;
- static long anim_delay = 0;
- static int anim_delay_value = 0;
+ static unsigned long anim_delay = 0;
+ static unsigned long anim_delay_value = 0;
static int width,height;
static int pad_x,pad_y;
static int cut_x,cut_y;
}
else /********** EDIT/CTRL-FENSTER **********/
{
- static long choice_delay = 0;
+ static unsigned long choice_delay = 0;
int choice = CheckElemButtons(mx,my,button);
int elem_pos = choice-ED_BUTTON_ELEM;
case SETUP:
case SETUPINPUT:
{
- static long joystickmove_delay = 0;
+ static unsigned long joystickmove_delay = 0;
if (joystick && !button && !DelayReached(&joystickmove_delay, 150))
newbutton = dx = dy = 0;
static char *getLevelFilename(int nr)
{
static char *filename = NULL;
- char basename[20 + strlen(LEVELFILE_EXTENSION)];
+ char basename[MAX_FILENAME_LEN];
if (filename != NULL)
free(filename);
static char *getTapeFilename(int nr)
{
static char *filename = NULL;
- char basename[20 + strlen(LEVELFILE_EXTENSION)];
+ char basename[MAX_FILENAME_LEN];
if (filename != NULL)
free(filename);
static char *getScoreFilename(int nr)
{
static char *filename = NULL;
- char basename[20 + strlen(LEVELFILE_EXTENSION)];
+ char basename[MAX_FILENAME_LEN];
if (filename != NULL)
free(filename);
/* to control special behaviour of certain game elements */
int game_emulation = EMU_NONE;
-
-
-#ifdef DEBUG
-#if 0
-static unsigned int getStateCheckSum(int counter)
-{
- int x, y;
- unsigned int mult = 1;
- unsigned int checksum = 0;
- /*
- static short lastFeld[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
- */
- static boolean first_game = TRUE;
-
- for (y=0; y<lev_fieldy; y++) for(x=0; x<lev_fieldx; x++)
- {
- /*
- if (counter == 3)
- {
- if (first_game)
- lastFeld[x][y] = Feld[x][y];
- else if (lastFeld[x][y] != Feld[x][y])
- printf("DIFF: [%d][%d]: lastFeld == %d != %d == Feld\n",
- x, y, lastFeld[x][y], Feld[x][y]);
- }
- */
-
- checksum += mult++ * Ur[x][y];
- checksum += mult++ * Feld[x][y];
-
- /*
- checksum += mult++ * MovPos[x][y];
- checksum += mult++ * MovDir[x][y];
- checksum += mult++ * MovDelay[x][y];
- checksum += mult++ * Store[x][y];
- checksum += mult++ * Store2[x][y];
- checksum += mult++ * StorePlayer[x][y];
- checksum += mult++ * Frame[x][y];
- checksum += mult++ * AmoebaNr[x][y];
- checksum += mult++ * JustHit[x][y];
- checksum += mult++ * Stop[x][y];
- */
- }
-
- if (counter == 3 && first_game)
- first_game = FALSE;
-
- return checksum;
-}
-#endif
-#endif
-
-
-
void GetPlayerConfig()
{
if (sound_status == SOUND_OFF)
void AmoebeWaechst(int x, int y)
{
- static long sound_delay = 0;
- static int sound_delay_value = 0;
+ static unsigned long sound_delay = 0;
+ static unsigned long sound_delay_value = 0;
if (!MovDelay[x][y]) /* start new growing cycle */
{
void GameActions()
{
- static long action_delay = 0;
- long action_delay_value;
+ static unsigned long action_delay = 0;
+ unsigned long action_delay_value;
int sieb_x = 0, sieb_y = 0;
int i, x, y, element;
byte *recorded_player_action;
#if 1
WaitUntilDelayReached(&action_delay, action_delay_value);
#else
- /*
- while (!DelayReached(&action_delay, action_delay_value));
- */
while (!DelayReached(&action_delay, action_delay_value))
{
}
print_debug("done");
-
#endif
void ScrollScreen(struct PlayerInfo *player, int mode)
{
- static long screen_frame_counter = 0;
+ static unsigned long screen_frame_counter = 0;
if (mode == SCROLL_INIT)
{
dst_ptr += bytes_per_row; /* continue with leftmost byte of next row */
}
- mask_pixmap = XCreateBitmapFromData(display, window, mask_data,
+ mask_pixmap = XCreateBitmapFromData(display, window, (char *)mask_data,
image->width, image->height);
free(mask_data);
ximage->byte_order = MSBFirst;
src_ptr = image->data;
- dst_ptr = ximage->data;
+ dst_ptr = (byte *)ximage->data;
switch (visual->class)
{
*/
#endif
-#else
+#else /* MSDOS */
sound_loops_allowed = TRUE;
/*
setup.sound_loops_on = TRUE;
*/
-#endif
+#endif /* MSDOS */
for(i=0; i<NUM_SOUNDS; i++)
{
if (sound_status == SOUND_OFF)
return;
-#ifndef MSDOS
+#ifdef MSDOS
+ SoundServer();
+ return;
+#endif
+
if (pipe(sound_pipe)<0)
{
Error(ERR_WARN, "cannot create pipe - no sounds");
}
else /* we are parent */
close(sound_pipe[0]); /* no reading from pipe needed */
-#else
- SoundServer();
-#endif
}
void InitJoysticks()
joystick_status = JOYSTICK_AVAILABLE;
}
-#else
+
+#else /* MSDOS */
/* try to access two joysticks; if that fails, try to access just one */
if (install_joystick(JOY_TYPE_2PADS) == 0 ||
#ifdef MSDOS
DrawInitText("MSDOS version done by Guido Schulz",210,FC_BLUE);
rest(200);
-#endif MSDOS
+#endif /* MSDOS */
DrawInitText("Loading graphics:",120,FC_GREEN);
for(i=0; i<NUM_PICTURES; i++)
char *picturemask_ext = "Mask.xbm";
#else
int pcx_err;
-
-#if 1
char *picture_ext = ".pcx";
-#else
- char *picture_ext = ".gif";
-#endif
-
#endif
/* Grafik laden */
#ifdef MSDOS
rest(100);
-#endif MSDOS
+#endif /* MSDOS */
#if DEBUG_TIMING
debug_print_timestamp(1, NULL); /* initialize timestamp function */
boolean gone, LevelSolved, GameOver;
boolean snapped;
- long move_delay;
+ unsigned long move_delay;
int last_move_dir;
- long push_delay;
- int push_delay_value;
+ unsigned long push_delay;
+ unsigned long push_delay_value;
int frame_reset_delay;
- long actual_frame_counter;
+ unsigned long actual_frame_counter;
int score;
int gems_still_needed;
#define TAPES_DIRECTORY "tapes"
#define SCORES_DIRECTORY "scores"
-#define VERSION_STRING "1.2 preview 1"
+#define VERSION_STRING "1.2.0"
#define GAMETITLE_STRING "Rocks'n'Diamonds"
#define WINDOWTITLE_STRING GAMETITLE_STRING " " VERSION_STRING
#define COPYRIGHT_STRING "Copyright ^1995-98 by Holger Schemel"
char *option_arg = NULL;
int option_len = strlen(option);
+ if (option_len >= MAX_OPTION_LEN)
+ Error(ERR_EXIT_HELP, "unrecognized option '%s'", 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)
- Error(ERR_EXIT_HELP, "unrecognized option '%s'", option);
-
if (strncmp(option, "--", 2) == 0) /* treat '--' like '-' */
option++;
options.display_name = option_arg;
if (option_arg == next_option)
options_left++;
-
- printf("--display == '%s'\n", options.display_name);
}
else if (strncmp(option, "-basepath", option_len) == 0)
{
if (option_arg == next_option)
options_left++;
- printf("--basepath == '%s'\n", options.base_directory);
-
/* adjust path for level directory accordingly */
options.level_directory =
getPath2(options.base_directory, LEVELS_DIRECTORY);
options.level_directory = option_arg;
if (option_arg == next_option)
options_left++;
-
- printf("--levels == '%s'\n", options.level_directory);
}
else if (strncmp(option, "-network", option_len) == 0)
{
- printf("--network\n");
-
options.network = TRUE;
}
else if (strncmp(option, "-serveronly", option_len) == 0)
{
- printf("--serveronly\n");
-
options.serveronly = TRUE;
}
else if (strncmp(option, "-verbose", option_len) == 0)
{
- printf("--verbose\n");
-
options.verbose = TRUE;
}
else if (*option == '-')
+ {
Error(ERR_EXIT_HELP, "unrecognized option '%s'", option_str);
+ }
else if (options.server_host == NULL)
{
options.server_host = *options_left;
-
- printf("server.name == '%s'\n", options.server_host);
}
else if (options.server_port == 0)
{
options.server_port = atoi(*options_left);
if (options.server_port < 1024)
Error(ERR_EXIT_HELP, "bad port number '%d'", options.server_port);
-
- printf("port == %d\n", options.server_port);
}
else
Error(ERR_EXIT_HELP, "too many arguments");
struct NetworkServerPlayerInfo
{
int fd;
- unsigned char player_name[16];
+ char player_name[16];
unsigned char number;
struct NetworkServerPlayerInfo *next;
char active;
for (i=0; i<len-2; i++)
{
if (player->player_name[i] < ' ' ||
- (player->player_name[i] > 0x7e && player->player_name[i] <= 0xa0))
+ ((unsigned char)(player->player_name[i]) > 0x7e &&
+ (unsigned char)(player->player_name[i]) <= 0xa0))
{
player->player_name[i] = 0;
break;
v->action_received = FALSE;
}
- broadcast(NULL, 10 + strlen(&buffer[10])+1, 0);
+ broadcast(NULL, 10 + strlen((char *)&buffer[10])+1, 0);
}
static void Handle_OP_PAUSE_PLAYING(struct NetworkServerPlayerInfo *player)
buffer[8] = (unsigned char)((new_random_seed >> 8) & 0xff);
buffer[9] = (unsigned char)((new_random_seed >> 0) & 0xff);
- strcpy(&buffer[10], leveldir[leveldir_nr].name);
+ strcpy((char *)&buffer[10], leveldir[leveldir_nr].name);
SendBufferToServer(10 + strlen(leveldir[leveldir_nr].name)+1);
}
buffer[len] = 0;
Error(ERR_NETWORK_CLIENT, "client %d calls itself \"%s\"",
buffer[0], &buffer[2]);
- strncpy(player->name, &buffer[2], MAX_PLAYER_NAME_LEN);
+ strncpy(player->name, (char *)&buffer[2], MAX_PLAYER_NAME_LEN);
}
static void Handle_OP_PLAYER_CONNECTED()
{
int new_level_nr, new_leveldir_nr;
unsigned long new_random_seed;
- unsigned char *new_leveldir_name;
+ char *new_leveldir_name;
new_level_nr = (buffer[2] << 8) + buffer[3];
new_leveldir_nr = (buffer[4] << 8) + buffer[5];
new_random_seed =
(buffer[6] << 24) | (buffer[7] << 16) | (buffer[8] << 8) | (buffer[9]);
- new_leveldir_name = &buffer[10];
+ new_leveldir_name = (char *)&buffer[10];
printf("OP_START_PLAYING: %d\n", buffer[0]);
Error(ERR_NETWORK_CLIENT,
(x == 15 && level_nr < leveldir[leveldir_nr].levels - 1)) &&
button)
{
- static long level_delay = 0;
+ static unsigned long level_delay = 0;
int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
int new_level_nr, old_level_nr = level_nr;
int font_color = (leveldir[leveldir_nr].readonly ? FC_RED : FC_YELLOW);
void HandleHelpScreen(int button)
{
- static long hs_delay = 0;
+ static unsigned long hs_delay = 0;
int num_helpscreen_els_pages =
(num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
int button_released = !button;
void HandleTypeName(int newxpos, KeySym key)
{
static int xpos = 0, ypos = 2;
- unsigned char ascii;
if (newxpos)
{
if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) &&
xpos < MAX_NAMELEN - 1)
{
+ char ascii;
+
if (key >= XK_A && key <= XK_Z)
ascii = 'A' + (char)(key - XK_A);
- if (key >= XK_a && key <= XK_z)
+ else
ascii = 'a' + (char)(key - XK_a);
setup.player_name[xpos] = ascii;
{
static int choice = 3;
static int first_entry = 0;
- static long choose_delay = 0;
+ static unsigned long choose_delay = 0;
static int redraw = TRUE;
int x = (mx + 32 - SX) / 32, y = (my + 32 - SY) / 32;
int num_page_entries;
if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
{
- static long delay = 0;
+ static unsigned long delay = 0;
if (!DelayReached(&delay, 150))
goto out;
if (playing_sounds || snd_ctrl.active)
{
struct timeval delay = { 0, 0 };
- char *sample_ptr;
- long sample_size, max_sample_size;
+ byte *sample_ptr;
+ long sample_size;
+ long max_sample_size; /* MIGHT BE USED UNINITIALIZED! TO BE FIXED! */
long fragment_size;
boolean stereo;
}
}
-#else /* von '#ifdef VOXWARE' */
+#else /* !VOXWARE */
if (snd_ctrl.active && !snd_ctrl.loop)
{
struct timeval delay = { 0, 0 };
- char *sample_ptr;
+ byte *sample_ptr;
long sample_size, max_sample_size = SND_BLOCKSIZE;
long sample_rate = 8000; /* standard "/dev/audio" sampling rate */
int wait_percent = 90; /* wait 90% of the real playing time */
FD_SET(sound_pipe[0], &sound_fdset);
/* get pointer and size of the actual sound sample */
- sample_ptr = snd_ctrl.data_ptr+snd_ctrl.playingpos;
+ sample_ptr = snd_ctrl.data_ptr + snd_ctrl.playingpos;
sample_size =
- MIN(max_sample_size,snd_ctrl.data_len-snd_ctrl.playingpos);
+ MIN(max_sample_size, snd_ctrl.data_len - snd_ctrl.playingpos);
snd_ctrl.playingpos += sample_size;
/* fill the first mixing buffer with original sample */
}
}
-#endif /* von '#ifdef VOXWARE' */
+#endif /* !VOXWARE */
}
#endif
char filename[256];
#ifndef MSDOS
struct SoundHeader_8SVX *sound_header;
- unsigned char *ptr;
+ char *ptr;
char *sound_ext = "8svx";
#else
char *sound_ext = "wav";
return(FALSE);
}
- ptr = snd_info->file_ptr + 12;
+ ptr = (char *)snd_info->file_ptr + 12;
- while(ptr < (unsigned char *)(snd_info->file_ptr + snd_info->file_len))
+ while(ptr < (char *)(snd_info->file_ptr + snd_info->file_len))
{
if (!strncmp(ptr,"VHDR",4))
{
}
else if (!strncmp(ptr,"BODY",4))
{
- snd_info->data_ptr = ptr + 8;
+ snd_info->data_ptr = (byte *)ptr + 8;
snd_info->data_len = be2long((unsigned long *)(ptr + 4));
return(TRUE);
}
}
return(FALSE);
-#else
+#else /* MSDOS */
snd_info->sample_ptr = load_sample(filename);
if(!snd_info->sample_ptr)
{
return(FALSE);
}
return(TRUE);
-#endif // von #ifndef MSDOS
+#endif /* MSDOS */
}
void PlaySound(int nr)
struct SoundInfo
{
- unsigned char *name;
- unsigned char *file_ptr;
- char *data_ptr;
+ char *name;
+ byte *file_ptr;
+ byte *data_ptr;
long file_len, data_len;
#ifdef MSDOS
SAMPLE *sample_ptr;
int playingtime;
long playingpos;
long data_len;
- char *data_ptr;
+ byte *data_ptr;
#ifdef MSDOS
int voice;
#endif
src_x = (graphic % HEROES_PER_LINE) * TILEX + cx;
src_y = (graphic / HEROES_PER_LINE) * TILEY + cy;
}
+ else /* big font graphics currently not allowed (and not needed) */
+ return;
dest_x = FX + x * TILEX + dx;
dest_y = FY + y * TILEY + dy;
unsigned int MoveDoor(unsigned int door_state)
{
- static unsigned int door1 = DOOR_OPEN_1;
- static unsigned int door2 = DOOR_CLOSE_2;
- static long door_delay = 0;
+ static int door1 = DOOR_OPEN_1;
+ static int door2 = DOOR_CLOSE_2;
+ static unsigned long door_delay = 0;
int x, start, stepsize = 2;
- long door_delay_value = stepsize * 5;
+ unsigned long door_delay_value = stepsize * 5;
if (door_state == DOOR_GET_STATE)
return(door1 | door2);