From 0918c3eb2f6219a8cc72aa85bd9c4889788dd474 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 4 Dec 1998 01:21:21 +0100 Subject: [PATCH] rnd-19981204-1 --- Makefile | 12 +++------ src/Makefile | 25 +++++++++++++++---- src/buttons.c | 2 +- src/cartoons.c | 8 +++--- src/editor.c | 2 +- src/events.c | 2 +- src/files.c | 6 ++--- src/game.c | 68 ++++---------------------------------------------- src/image.c | 4 +-- src/init.c | 26 ++++++++----------- src/main.h | 10 ++++---- src/misc.c | 24 ++++-------------- src/netserv.c | 7 +++--- src/network.c | 8 +++--- src/screens.c | 13 +++++----- src/sound.c | 27 ++++++++++---------- src/sound.h | 8 +++--- src/tools.c | 10 +++++--- 18 files changed, 101 insertions(+), 161 deletions(-) diff --git a/Makefile b/Makefile index 8d50bfea..4616aecb 100644 --- a/Makefile +++ b/Makefile @@ -11,14 +11,10 @@ # 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: @@ -30,13 +26,13 @@ clean: 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 diff --git a/src/Makefile b/src/Makefile index 26739fb7..3019442b 100644 --- a/src/Makefile +++ b/src/Makefile @@ -44,9 +44,22 @@ SCORE_ENTRIES = MANY_PER_NAME # 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)\"" @@ -55,9 +68,10 @@ CONFIG_SCORE_ENTRIES = -D$(SCORE_ENTRIES) 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 @@ -72,7 +86,8 @@ DEBUG = -DDEBUG -g -Wall # 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) diff --git a/src/buttons.c b/src/buttons.c index d9c2c47f..62c5a1c1 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -632,7 +632,7 @@ void DrawPlayerButton(unsigned long state, int mode) { 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; diff --git a/src/cartoons.c b/src/cartoons.c index 96ad9793..834996b7 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -107,8 +107,8 @@ void DoAnimation() 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; @@ -195,8 +195,8 @@ boolean AnimateToon(int toon_nr, boolean restart) 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; diff --git a/src/editor.c b/src/editor.c index 8ea4472c..2955faec 100644 --- a/src/editor.c +++ b/src/editor.c @@ -694,7 +694,7 @@ void LevelEd(int mx, int my, int button) } 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; diff --git a/src/events.c b/src/events.c index 7f71d4b7..2d8eca3e 100644 --- a/src/events.c +++ b/src/events.c @@ -662,7 +662,7 @@ void HandleJoystick() 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; diff --git a/src/files.c b/src/files.c index be7bd1a1..211a38d1 100644 --- a/src/files.c +++ b/src/files.c @@ -155,7 +155,7 @@ static char *getScoreDir(char *level_subdir) 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); @@ -173,7 +173,7 @@ static char *getLevelFilename(int nr) 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); @@ -187,7 +187,7 @@ static char *getTapeFilename(int nr) 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); diff --git a/src/game.c b/src/game.c index 8b5d2a79..26cc84cc 100644 --- a/src/game.c +++ b/src/game.c @@ -99,60 +99,6 @@ /* 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; ywidth, image->height); free(mask_data); @@ -375,7 +375,7 @@ XImageInfo *Image_to_Pixmap(Display *display, int screen, Visual *visual, ximage->byte_order = MSBFirst; src_ptr = image->data; - dst_ptr = ximage->data; + dst_ptr = (byte *)ximage->data; switch (visual->class) { diff --git a/src/init.c b/src/init.c index 4ff449d9..321875dc 100644 --- a/src/init.c +++ b/src/init.c @@ -160,14 +160,14 @@ void InitSound() */ #endif -#else +#else /* MSDOS */ sound_loops_allowed = TRUE; /* setup.sound_loops_on = TRUE; */ -#endif +#endif /* MSDOS */ for(i=0; i= 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++; @@ -384,8 +384,6 @@ void GetOptions(char *argv[]) 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) { @@ -396,8 +394,6 @@ void GetOptions(char *argv[]) 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); @@ -410,42 +406,32 @@ void GetOptions(char *argv[]) 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"); diff --git a/src/netserv.c b/src/netserv.c index 178e89e3..a9ffa6a7 100644 --- a/src/netserv.c +++ b/src/netserv.c @@ -34,7 +34,7 @@ static int onceonly = 0; struct NetworkServerPlayerInfo { int fd; - unsigned char player_name[16]; + char player_name[16]; unsigned char number; struct NetworkServerPlayerInfo *next; char active; @@ -283,7 +283,8 @@ static void Handle_OP_PLAYER_NAME(struct NetworkServerPlayerInfo *player, for (i=0; iplayer_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; @@ -348,7 +349,7 @@ static void Handle_OP_START_PLAYING(struct NetworkServerPlayerInfo *player) 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) diff --git a/src/network.c b/src/network.c index bd408a1e..5d137f05 100644 --- a/src/network.c +++ b/src/network.c @@ -236,7 +236,7 @@ void SendToServer_StartPlaying() 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); } @@ -364,7 +364,7 @@ static void Handle_OP_PLAYER_NAME(unsigned int len) 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() @@ -413,13 +413,13 @@ static void Handle_OP_START_PLAYING() { 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, diff --git a/src/screens.c b/src/screens.c index f2076dce..adbda0da 100644 --- a/src/screens.c +++ b/src/screens.c @@ -158,7 +158,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) (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); @@ -656,7 +656,7 @@ void DrawHelpScreen() 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; @@ -710,7 +710,6 @@ void HandleHelpScreen(int button) void HandleTypeName(int newxpos, KeySym key) { static int xpos = 0, ypos = 2; - unsigned char ascii; if (newxpos) { @@ -723,9 +722,11 @@ void HandleTypeName(int newxpos, KeySym key) 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; @@ -800,7 +801,7 @@ void HandleChooseLevel(int mx, int my, int dx, int dy, int button) { 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; @@ -1388,7 +1389,7 @@ void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button) 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; diff --git a/src/sound.c b/src/sound.c index 3f150101..2518499b 100644 --- a/src/sound.c +++ b/src/sound.c @@ -118,8 +118,9 @@ void SoundServer() 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; @@ -251,12 +252,12 @@ void SoundServer() } } -#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 */ @@ -272,9 +273,9 @@ void SoundServer() 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 */ @@ -305,7 +306,7 @@ void SoundServer() } } -#endif /* von '#ifdef VOXWARE' */ +#endif /* !VOXWARE */ } #endif @@ -707,7 +708,7 @@ boolean LoadSound_8SVX(struct SoundInfo *snd_info) char filename[256]; #ifndef MSDOS struct SoundHeader_8SVX *sound_header; - unsigned char *ptr; + char *ptr; char *sound_ext = "8svx"; #else char *sound_ext = "wav"; @@ -760,9 +761,9 @@ boolean LoadSound_8SVX(struct SoundInfo *snd_info) 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)) { @@ -781,7 +782,7 @@ boolean LoadSound_8SVX(struct SoundInfo *snd_info) } 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); } @@ -794,7 +795,7 @@ boolean LoadSound_8SVX(struct SoundInfo *snd_info) } return(FALSE); -#else +#else /* MSDOS */ snd_info->sample_ptr = load_sample(filename); if(!snd_info->sample_ptr) { @@ -803,7 +804,7 @@ boolean LoadSound_8SVX(struct SoundInfo *snd_info) return(FALSE); } return(TRUE); -#endif // von #ifndef MSDOS +#endif /* MSDOS */ } void PlaySound(int nr) diff --git a/src/sound.h b/src/sound.h index 47807dde..2c747bd8 100644 --- a/src/sound.h +++ b/src/sound.h @@ -131,9 +131,9 @@ struct SoundHeader_WAV 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; @@ -153,7 +153,7 @@ struct SoundControl int playingtime; long playingpos; long data_len; - char *data_ptr; + byte *data_ptr; #ifdef MSDOS int voice; #endif diff --git a/src/tools.c b/src/tools.c index b8026898..d2645960 100644 --- a/src/tools.c +++ b/src/tools.c @@ -831,6 +831,8 @@ void DrawGraphicShifted(int x,int y, int dx,int dy, int graphic, 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; @@ -1599,11 +1601,11 @@ unsigned int GetDoorState() 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); -- 2.34.1