From: Holger Schemel Date: Fri, 16 Dec 2016 15:13:15 +0000 (+0100) Subject: fixed code to compile with current gcc and 64-bit systems X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=c27d6982a3c8e3ce85d4c974af6465f5cf1855b0;p=rocksndiamonds.git fixed code to compile with current gcc and 64-bit systems --- diff --git a/src/editor.c b/src/editor.c index ee7fe4e5..8aa1971f 100644 --- a/src/editor.c +++ b/src/editor.c @@ -727,7 +727,7 @@ void LevelEd(int mx, int my, int button) } else /********** KONTROLL-FENSTER **********/ { - static long choice_delay = 0; + static int choice_delay = 0; int choice = CheckCountButtons(mx,my,button); int step = (button==1 ? 1 : button==2 ? 5 : button==3 ? 10 : 0); @@ -1085,7 +1085,7 @@ void LevelNameTyping(KeySym key) } } -void DrawEditButton(unsigned long state) +void DrawEditButton(unsigned int state) { int i; int xpos = 0, ypos = 1, xsize = 2, ysize = 3; @@ -1129,7 +1129,7 @@ void DrawEditButton(unsigned long state) redraw_mask |= REDRAW_DOOR_2; } -void DrawCtrlButton(unsigned long state) +void DrawCtrlButton(unsigned int state) { int i; int xpos = 0, ypos = 1, xsize = 2, ysize = 3; diff --git a/src/editor.h b/src/editor.h index d01f8136..b929fbd9 100644 --- a/src/editor.h +++ b/src/editor.h @@ -300,8 +300,8 @@ void DrawLevelEd(void); void ScrollMiniLevel(int, int, int); void LevelEd(int, int, int); void LevelNameTyping(KeySym); -void DrawEditButton(unsigned long state); -void DrawCtrlButton(unsigned long state); +void DrawEditButton(unsigned int state); +void DrawCtrlButton(unsigned int state); void DrawElemButton(int, int); void DrawCountButton(int, int); int CheckEditButtons(int, int, int); diff --git a/src/events.c b/src/events.c index 1e8fcd1c..788cca84 100644 --- a/src/events.c +++ b/src/events.c @@ -604,7 +604,7 @@ void HandleJoystick() case SETUP: { int dx = 0, dy = 0; - static long joystickmove_delay = 0; + static int joystickmove_delay = 0; if (DelayReached(&joystickmove_delay,15) || button) { diff --git a/src/game.c b/src/game.c index 6d5ca5bc..9af32646 100644 --- a/src/game.c +++ b/src/game.c @@ -82,6 +82,7 @@ void LoadLevelInfo() char filename[MAX_FILENAME]; char cookie[MAX_FILENAME]; FILE *file; + int ignored; sprintf(filename,"%s/%s",LEVEL_PATH,LEVDIR_FILENAME); @@ -91,7 +92,7 @@ void LoadLevelInfo() CloseAll(); } - fscanf(file,"%s\n",cookie); + ignored = fscanf(file,"%s\n",cookie); if (strcmp(cookie,LEVELDIR_COOKIE)) /* ungültiges Format? */ { fprintf(stderr,"%s: wrong format of level info file!\n",progname); @@ -103,10 +104,10 @@ void LoadLevelInfo() leveldir_nr = 0; for(i=0;i0 && DelayReached(&time_delay,100) && !tape.pausing) @@ -2343,7 +2349,7 @@ BOOL MoveFigureOneStep(int dx, int dy) BOOL MoveFigure(int dx, int dy) { - static long move_delay = 0; + static int move_delay = 0; int moved = MF_NO_ACTION; if (GameOver || (!dx && !dy)) @@ -2490,7 +2496,7 @@ int DigField(int x, int y, int mode) { int dx=x-JX, dy=y-JY; int element; - static long push_delay = 0; + static int push_delay = 0; static int push_delay_value = 20; if (mode==DF_NO_PUSH) @@ -2898,7 +2904,7 @@ void TapeErase() tape.length = 0; } -void DrawVideoDisplay(unsigned long state, unsigned long value) +void DrawVideoDisplay(unsigned int state, unsigned int value) { int i; int part1 = 0, part2 = 1; @@ -3024,7 +3030,7 @@ void DrawVideoDisplay(unsigned long state, unsigned long value) redraw_mask |= REDRAW_VIDEO_3; } -void DrawSoundDisplay(unsigned long state) +void DrawSoundDisplay(unsigned int state) { int pos, cx = DOOR_GFX_PAGEX4, cy = 0; @@ -3046,7 +3052,7 @@ void DrawSoundDisplay(unsigned long state) redraw_mask |= REDRAW_DOOR_1; } -void DrawGameButton(unsigned long state) +void DrawGameButton(unsigned int state) { int pos, cx = DOOR_GFX_PAGEX4, cy = -GAME_BUTTON_YSIZE; @@ -3065,7 +3071,7 @@ void DrawGameButton(unsigned long state) redraw_mask |= REDRAW_DOOR_1; } -void DrawChooseButton(unsigned long state) +void DrawChooseButton(unsigned int state) { int pos, cx = DOOR_GFX_PAGEX4, cy = 0; @@ -3082,7 +3088,7 @@ void DrawChooseButton(unsigned long state) redraw_mask |= REDRAW_DOOR_1; } -void DrawConfirmButton(unsigned long state) +void DrawConfirmButton(unsigned int state) { int cx = DOOR_GFX_PAGEX4, cy = 0; diff --git a/src/game.h b/src/game.h index 422343d8..a4ca2e85 100644 --- a/src/game.h +++ b/src/game.h @@ -94,10 +94,10 @@ int TapePlayAction(void); BOOL TapePlayDelay(void); void TapeStop(void); void TapeErase(void); -void DrawVideoDisplay(unsigned long, unsigned long); -void DrawSoundDisplay(unsigned long); -void DrawGameButton(unsigned long); -void DrawChooseButton(unsigned long); -void DrawConfirmButton(unsigned long); +void DrawVideoDisplay(unsigned int, unsigned int); +void DrawSoundDisplay(unsigned int); +void DrawGameButton(unsigned int); +void DrawChooseButton(unsigned int); +void DrawConfirmButton(unsigned int); #endif diff --git a/src/init.c b/src/init.c index ec0a1c74..ca182972 100644 --- a/src/init.c +++ b/src/init.c @@ -187,10 +187,10 @@ void InitWindow(int argc, char *argv[]) XClassHint class_hints; XTextProperty windowName, iconName; XGCValues gc_values; - unsigned long gc_valuemask; + unsigned int gc_valuemask; char *window_name = "Rocks'n'Diamonds"; char *icon_name = "Rocks'n'Diamonds"; - long window_event_mask; + int window_event_mask; width = WIN_XSIZE; height = WIN_YSIZE; @@ -276,9 +276,9 @@ void InitGfx() unsigned int width,height; int hot_x,hot_y; XGCValues gc_values; - unsigned long gc_valuemask; + unsigned int gc_valuemask; XGCValues clip_gc_values; - unsigned long clip_gc_valuemask; + unsigned int clip_gc_valuemask; char filename[256]; Pixmap shapemask; diff --git a/src/main.c b/src/main.c index 2c237ce3..b15d193a 100644 --- a/src/main.c +++ b/src/main.c @@ -36,7 +36,7 @@ char *sound_device_name = SOUND_DEVICE; int joystick_device = 0; char *joystick_device_name[2] = { DEV_JOYSTICK_0, DEV_JOYSTICK_1 }; int width, height; -unsigned long pen_fg, pen_bg; +unsigned int pen_fg, pen_bg; int game_status = MAINMENU; int button_status = MB_NOT_PRESSED, motion_status = FALSE; diff --git a/src/main.h b/src/main.h index 761bc9f5..07509387 100644 --- a/src/main.h +++ b/src/main.h @@ -187,9 +187,9 @@ struct RecordingInfo { int level_nr; unsigned int random_seed; - unsigned long date; - unsigned long counter; - unsigned long length; + unsigned int date; + unsigned int counter; + unsigned int length; BOOL recording, playing, pausing; struct { @@ -204,6 +204,46 @@ struct JoystickInfo int yupper, ylower, ymiddle; }; +struct SoundHeader_SUN +{ + unsigned int magic; + unsigned int hdr_size; + unsigned int data_size; + unsigned int encoding; + unsigned int sample_rate; + unsigned int channels; +}; + +struct SoundHeader_8SVX +{ + char magic_FORM[4]; + unsigned int chunk_size; + char magic_8SVX[4]; +}; + +struct SoundInfo +{ + char *name; + char *file_ptr, *data_ptr; + int file_len, data_len; +}; + +struct SoundControl +{ + int nr; + int volume; + int stereo; + BOOL active; + BOOL loop; + BOOL fade_sound; + BOOL stop_sound; + BOOL stop_all_sounds; + int playingtime; + int playingpos; + int data_len; + char *data_ptr; +}; + extern Display *display; extern int screen; extern Window window; @@ -222,7 +262,7 @@ extern char *sound_device_name; extern int joystick_device; extern char *joystick_device_name[2]; extern int width, height; -extern unsigned long pen_fg, pen_bg; +extern unsigned int pen_fg, pen_bg; extern int game_status; extern int button_status, motion_status; diff --git a/src/misc.c b/src/misc.c index a066cff5..23fc73a1 100644 --- a/src/misc.c +++ b/src/misc.c @@ -24,7 +24,7 @@ #include #include -void microsleep(unsigned long usec) +void microsleep(unsigned int usec) { struct timeval delay; @@ -36,7 +36,7 @@ void microsleep(unsigned long usec) progname); } -unsigned long be2long(unsigned long *be) /* big-endian -> longword */ +unsigned int be2int(unsigned int *be) /* big-endian -> longword */ { unsigned char *ptr = (unsigned char *)be; @@ -56,7 +56,7 @@ unsigned int RND(unsigned int max) return(rand() % max); } -unsigned int InitRND(long seed) +unsigned int InitRND(int seed) { struct timeval current_time; @@ -157,8 +157,8 @@ void DoAnimation() void HandleAnimation(int mode) { - static long animstart_delay = -1; - static long animstart_delay_value = 0; + static int animstart_delay = -1; + static int animstart_delay_value = 0; static BOOL anim_restart = TRUE; static BOOL reset_delay = TRUE; static int toon_nr = 0; @@ -208,7 +208,7 @@ BOOL AnimateToon(int toon_nr, BOOL restart) static delta_x = 0, delta_y = 0; static int frame = 0, frame_step = 1; static BOOL horiz_move, vert_move; - static long anim_delay = 0; + static int anim_delay = 0; static int anim_delay_value = 0; struct AnimInfo *anim = &toon[toon_nr]; static int width,height; diff --git a/src/misc.h b/src/misc.h index c4cba8de..f0eac7f1 100644 --- a/src/misc.h +++ b/src/misc.h @@ -84,11 +84,11 @@ struct AnimInfo #define NEW_RANDOMIZE -1 -void microsleep(unsigned long); -unsigned long be2long(unsigned long *); +void microsleep(unsigned int); +unsigned int be2int(unsigned int *); char *int2str(int, int); unsigned int RND(unsigned int); -unsigned int InitRND(long); +unsigned int InitRND(int); char *GetLoginName(void); void InitAnimation(void); diff --git a/src/screens.c b/src/screens.c index 2d5d17c1..a519c1f8 100644 --- a/src/screens.c +++ b/src/screens.c @@ -116,7 +116,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) (x==15 && level_nr=0) { @@ -231,7 +232,7 @@ void SoundServer() } /* finally play the sound fragment */ - write(sound_device,playing_buffer,fragment_size); + ignored = write(sound_device,playing_buffer,fragment_size); } /* if no sounds playing, free device for other sound programs */ @@ -246,8 +247,8 @@ void SoundServer() { struct timeval delay = { 0, 0 }; char *sample_ptr; - long sample_size, max_sample_size = SND_BLOCKSIZE; - long sample_rate = 8000; /* standard "/dev/audio" sampling rate */ + int sample_size, max_sample_size = SND_BLOCKSIZE; + int sample_rate = 8000; /* standard "/dev/audio" sampling rate */ int wait_percent = 90; /* wait 90% of the real playing time */ int i; @@ -614,7 +615,7 @@ BOOL LoadSound(struct SoundInfo *snd_info) snd_hdr = (struct SoundHeader_8SVX *)snd_info->file_ptr; if (strncmp(snd_hdr->magic_FORM,"FORM",4) || - snd_info->file_len!=be2long(&snd_hdr->chunk_size)+8 || + snd_info->file_len!=be2int(&snd_hdr->chunk_size)+8 || strncmp(snd_hdr->magic_8SVX,"8SVX",4)) { fprintf(stderr,"%s: '%s' is not an IFF/8SVX file or broken- no sounds\n", @@ -628,20 +629,20 @@ BOOL LoadSound(struct SoundInfo *snd_info) { if (!strncmp(ptr,"VHDR",4)) { - ptr+=be2long((unsigned long *)(ptr+4)); + ptr+=be2int((unsigned int *)(ptr+4)); } if (!strncmp(ptr,"ANNO",4)) { - ptr+=be2long((unsigned long *)(ptr+4)); + ptr+=be2int((unsigned int *)(ptr+4)); } if (!strncmp(ptr,"CHAN",4)) { - ptr+=be2long((unsigned long *)(ptr+4)); + ptr+=be2int((unsigned int *)(ptr+4)); } if (!strncmp(ptr,"BODY",4)) { snd_info->data_ptr = ptr+8; - snd_info->data_len = be2long((unsigned long *)(ptr+4)); + snd_info->data_len = be2int((unsigned int *)(ptr+4)); return(TRUE); } ptr++; diff --git a/src/sound.h b/src/sound.h index be853f8c..bc6b883e 100644 --- a/src/sound.h +++ b/src/sound.h @@ -26,7 +26,7 @@ #define VOXWARE #endif /* where is the right declaration for 'ioctl'? */ -extern void ioctl(long, long, void *); +extern void ioctl(int, int, void *); #endif #define SND_BLOCKSIZE 4096 @@ -89,48 +89,8 @@ extern void ioctl(long, long, void *); #define SOUND_STATUS SOUND_AVAILABLE #endif -struct SoundHeader_SUN -{ - unsigned long magic; - unsigned long hdr_size; - unsigned long data_size; - unsigned long encoding; - unsigned long sample_rate; - unsigned long channels; -}; - -struct SoundHeader_8SVX -{ - char magic_FORM[4]; - unsigned long chunk_size; - char magic_8SVX[4]; -}; - -struct SoundInfo -{ - char *name; - char *file_ptr, *data_ptr; - long file_len, data_len; -}; - -struct SoundControl -{ - int nr; - int volume; - int stereo; - BOOL active; - BOOL loop; - BOOL fade_sound; - BOOL stop_sound; - BOOL stop_all_sounds; - int playingtime; - long playingpos; - long data_len; - char *data_ptr; -}; - /* function from "misc.c" */ -unsigned long be2long(unsigned long *); +unsigned int be2int(unsigned int *); /* sound server functions */ void SoundServer(void); diff --git a/src/tools.c b/src/tools.c index f1d2e259..32e63091 100644 --- a/src/tools.c +++ b/src/tools.c @@ -112,7 +112,7 @@ void BackToFront() void FadeToFront() { - long fading_delay = 300000; + int fading_delay = 300000; if (fading_on && (redraw_mask & REDRAW_FIELD)) { @@ -901,7 +901,7 @@ BOOL AreYouSure(char *text, unsigned int ays_state) ty--; continue; } - sprintf(txt,text); + sprintf(txt,"%s",text); txt[tl]=0; DrawTextExt(pix[PIX_DB_DOOR],gc, DOOR_GFX_PAGEX1+51-(tl*14)/2,SY+ty*16,txt,FS_SMALL,FC_YELLOW); @@ -1185,11 +1185,11 @@ void MoveDoor(unsigned int door_state) door2 = door_state & DOOR_ACTION_2; } -long mainCounter(int mode) +int mainCounter(int mode) { static struct timeval base_time = { 0, 0 }; struct timeval current_time; - long counter_ms; + int counter_ms; gettimeofday(¤t_time,NULL); if (mode==0 || current_time.tv_sec0) microsleep(wait*10000); } -void WaitCounter2(long value) /* wait for counter to reach value */ +void WaitCounter2(int value) /* wait for counter to reach value */ { - long wait; + int wait; while((wait=value-Counter2())>0) microsleep(wait*1000); } -void Delay(long value) +void Delay(int value) { microsleep(value); } -BOOL DelayReached(long *counter_var, int delay) +BOOL DelayReached(int *counter_var, int delay) { - long actual_counter = Counter(); + int actual_counter = Counter(); if (actual_counter>*counter_var+delay || actual_counter<*counter_var) { @@ -1275,6 +1275,7 @@ void LoadJoystickData() int i; char cookie[256]; FILE *file; + int ignored; if (joystick_status==JOYSTICK_OFF) return; @@ -1282,7 +1283,7 @@ void LoadJoystickData() if (!(file=fopen(JOYDAT_FILE,"r"))) return; - fscanf(file,"%s",cookie); + ignored = fscanf(file,"%s",cookie); if (strcmp(cookie,JOYSTICK_COOKIE)) /* ungültiges Format? */ { fprintf(stderr,"%s: wrong format of joystick file!\n",progname); @@ -1292,11 +1293,13 @@ void LoadJoystickData() for(i=0;i<2;i++) { - fscanf(file,"%s",cookie); - fscanf(file, "%d %d %d \n", - &joystick[i].xleft, &joystick[i].xmiddle, &joystick[i].xright); - fscanf(file, "%d %d %d \n", - &joystick[i].yupper, &joystick[i].ymiddle, &joystick[i].ylower); + ignored = fscanf(file,"%s",cookie); + ignored = + fscanf(file, "%d %d %d \n", + &joystick[i].xleft, &joystick[i].xmiddle, &joystick[i].xright); + ignored = + fscanf(file, "%d %d %d \n", + &joystick[i].yupper, &joystick[i].ymiddle, &joystick[i].ylower); } fclose(file); @@ -1359,7 +1362,7 @@ void CheckJoystickData() int JoystickPosition(int middle, int margin, int actual) { - long range, pos; + int range, pos; int percentage; if (marginmiddle) diff --git a/src/tools.h b/src/tools.h index b3fa84e4..9bb11c58 100644 --- a/src/tools.h +++ b/src/tools.h @@ -80,14 +80,14 @@ BOOL AreYouSure(char *, unsigned int); void OpenDoor(unsigned int); void CloseDoor(unsigned int); void MoveDoor(unsigned int); -long mainCounter(int); +int mainCounter(int); void InitCounter(void); -long Counter(void); -long Counter2(void); -void WaitCounter(long); -void WaitCounter2(long); -void Delay(long); -BOOL DelayReached(long *, int); +int Counter(void); +int Counter2(void); +void WaitCounter(int); +void WaitCounter2(int); +void Delay(int); +BOOL DelayReached(int *, int); int ReadPixel(Drawable, int, int); int el2gfx(int); void LoadJoystickData(void);