From e1f28eea29e0d92fd30f53ec2c081876b8611a1e Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 17 May 2020 21:35:49 +0000 Subject: Tidied up function defs and prototypes. Removed warnings. --- dash.c | 491 +++++++++++++++++++++++++++-------------------------------------- 1 file changed, 207 insertions(+), 284 deletions(-) diff --git a/dash.c b/dash.c index 0c124ce..5b639c4 100644 --- a/dash.c +++ b/dash.c @@ -30,6 +30,10 @@ #include +#include +#include +#include + #include "Xbit.h" #define WINX 100 @@ -47,17 +51,17 @@ # define USLEEP(x) usleep(x) #endif -XSizeHints size_hints; -ulong black,white; -Display *disp; -Window window; -Colormap cm; -XFontStruct *font; +static XSizeHints size_hints; +static ulong black,white; +static Display *disp; +static Window window; +static Colormap cm; +static XFontStruct *font; -char *GetPath(), - *GetFXPath(), - *GetLevelPath(), - *GetLibPath(); +static char *GetPath(void), + *GetFXPath(const char *s), + *GetLevelPath(const char *s), + *GetLibPath(const char *s); #define SPACESPRNAME "space" #define EARTHSPRNAME "earth" @@ -132,7 +136,7 @@ typedef struct Pixmap p; } sprite; -sprite spr[NOSPR]= +static sprite spr[NOSPR]= { {SPACESPRNAME,0}, {EARTHSPRNAME,0}, @@ -155,7 +159,7 @@ sprite spr[NOSPR]= {CHSRGENSPRNAME,0} }; -char glyph_map[NOSPR]= +static char glyph_map[NOSPR]= { /* SPACESPR */ ' ', /* EARTHSPR */ '.', @@ -197,10 +201,10 @@ typedef struct int x,y; } Generator; -Enemy enemy[MAX_ENEMY]; -Generator generator[MAX_GENERATOR]; -int no_enemy; -int no_generator; +static Enemy enemy[MAX_ENEMY]; +static Generator generator[MAX_GENERATOR]; +static int no_enemy; +static int no_generator; #define AMOEBA_COUNT 5 @@ -213,9 +217,9 @@ typedef struct int could_move; } Amoeba; -Amoeba amoeba; -int max_amoeba_size; -int amoeba_move_chance; +static Amoeba amoeba; +static int max_amoeba_size; +static int amoeba_move_chance; #define WELLDONELEV -1 @@ -245,7 +249,7 @@ typedef struct #define ROT_LEFT(d) ((((d)-1)max_bounds.width)>>1),y,s,c); } -CursesCentre(s,y,c) -char *s; -int y,c; - +static void CursesCentre(const char *s, int y, ulong c) { - /* mvaddstr(y,SCRX/2-strlen(s)/2,s); */ mvaddstr(y,COLS/2-strlen(s)/2,s); } -DoTillPress(f,s,qf) -int (*f)(); -int s,qf; - +static void DoTillPress(void (*f)(void),int s,int qf) { XEvent e; @@ -1177,8 +1164,7 @@ static struct }; -int XTitle() - +static void XTitle(void) { static int fr=True; static int bln=0; @@ -1253,8 +1239,6 @@ int XTitle() } (*Update)(); - - return(XFUNCCONT); } /* --------------------------------------------------------------------- */ @@ -1266,8 +1250,7 @@ struct int x,y; } ispr[INTROSPR]; -XIntroLevel() - +static void XIntroLevel(void) { static int fr=True; char s[100]; @@ -1306,14 +1289,11 @@ XIntroLevel() (*Centre)("Press Space to continue",Y(SCRY-2),white); (*Update)(); - - return(XFUNCCONT); } /* --------------------------------------------------------------------- */ -int LevelOk() - +static void LevelOk(void) { static int ix=1; int x,y; @@ -1352,8 +1332,7 @@ int LevelOk() } -int LevelNotOk() - +static void LevelNotOk(void) { static int ix=1; int x,y; @@ -1392,9 +1371,7 @@ int LevelNotOk() /* --------------------------------------------------------------------- */ -DrawMess(s) -char *s; - +static void DrawMess(const char *s) { if (!cursesmode) XFillBox(0,0,X(SCRX),Y(1)-1,black); @@ -1403,8 +1380,7 @@ char *s; } -DrawScore() - +static void DrawScore(void) { if (!cursesmode) { @@ -1425,15 +1401,13 @@ DrawScore() } -XUpdate() - +static void XUpdate(void) { Redraw(0,0); } -XRepaint(full) - +static void XRepaint(int full) { static char scr[SCRX][SCRY]; static int lx,ly; @@ -1527,8 +1501,7 @@ XRepaint(full) /* --------------------------------------------------------------------- */ #define MOVE_AMOEBA(x,y) ((AT(x,y)==SPACESPR)||(AT(x,y)==EARTHSPR)) -CheckAmoebaMove(x,y) - +static int CheckAmoebaMove(int x, int y) { int r=False; @@ -1575,8 +1548,7 @@ CheckAmoebaMove(x,y) return(r); } -HandleAmoeba() - +static void HandleAmoeba(void) { int f,x,y,d; @@ -1613,9 +1585,7 @@ HandleAmoeba() /* --------------------------------------------------------------------- */ -GenerateMonsters(x,y,t) -int x,y,t; - +static void GenerateMonsters(int x, int y, int t) { if ((AT(x-1,y)==SPACESPR)&&(no_enemyx+move_tbl[(d)].x,(e)->y+move_tbl[(d)].y)) { @@ -1733,32 +1699,7 @@ int d; (c==BUTTSPR)|| \ (c==CHSRSPR)) -HandleEnemies() - -{ - int f; - - for(f=0;fx,e->y)) { @@ -2022,9 +1957,31 @@ Enemy *e; } +static void HandleEnemies(void) +{ + int f; + + for(f=0;f