Fix games/golddig in the face of picky compilers

C (and linkers) has changed a little since 2001, so patch up the
places where "extern" is needed, add <string.h> and missing
cases in switch() to silence warnings. golddig runs nearly as
well as on my Apple //c (see games/kgoldrunner for a newer take
on the same concept, though)

Not taking maintainership, I just spotted this among the recent
fallout-cleanup and thought "I can do that while I wait for the
potatoes to boil."
This commit is contained in:
Adriaan de Groot 2021-02-18 16:37:39 +00:00
parent 27b00582ca
commit c0aeda4368
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=565951
7 changed files with 172 additions and 4 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= golddig
PORTVERSION= 3.1
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= games
MASTER_SITES= http://www.NetBSD.org/~chuck/gz/
DISTNAME= ${PORTNAME}C${PORTVERSION}
@ -11,9 +11,6 @@ DISTNAME= ${PORTNAME}C${PORTVERSION}
MAINTAINER= ports@FreeBSD.org
COMMENT= Getting the Gold and Avoiding Death
BROKEN_FreeBSD_13= ld: error: duplicate symbol: background
BROKEN_FreeBSD_14= ld: error: duplicate symbol: background
USES= xorg
USE_XORG= x11
MAKE_ENV= X11BASE="${LOCALBASE}" \

View file

@ -0,0 +1,19 @@
--- badguy.c.orig 2001-03-16 00:44:30 UTC
+++ badguy.c
@@ -20,7 +20,7 @@ int badscore; /* Score given during current
/* killing bad guys */
/* Graphics cursors for drawing the possible states of the badguys */
-GC badguy1gc,badguy2gc,badguy3gc;
+extern GC badguy1gc,badguy2gc,badguy3gc;
/* Initialize data structure for bad guys from level data */
void start_badguy()
@@ -421,6 +421,7 @@ void move_badguys()
case RIGHT: dir = LEFT; break;
case UP: dir = DOWN; break;
case DOWN: dir = UP; break;
+ case UNMOVE: case STAND: case DIGLEFT: case DIGRIGHT: case PUTDOWN: break;
}
/* Execute computed movement. */

View file

@ -0,0 +1,10 @@
--- golddig.c.orig 2021-02-18 16:25:22 UTC
+++ golddig.c
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>

View file

@ -0,0 +1,91 @@
--- golddig.h.orig 2001-03-19 19:26:10 UTC
+++ golddig.h
@@ -11,43 +11,47 @@
#ifdef VMS
#define LIB "GOLDDIG$:" /* Default path name */
#endif
-
-int xsize,ysize; /* Current level width and height */
-int levelstart; /* Level that player started at */
-int levelnum; /* Current level number */
-int score; /* Total score */
-int speed; /* Speed of game. 1 is slowest, 5 is default */
+
+#ifndef GOLDDIG_EXTERN
+#define GOLDDIG_EXTERN extern
+#endif
+
+GOLDDIG_EXTERN int xsize,ysize; /* Current level width and height */
+GOLDDIG_EXTERN int levelstart; /* Level that player started at */
+GOLDDIG_EXTERN int levelnum; /* Current level number */
+GOLDDIG_EXTERN int score; /* Total score */
+GOLDDIG_EXTERN int speed; /* Speed of game. 1 is slowest, 5 is default */
extern int lives; /* How many player lives left */
extern int angelleft; /* How many movement on angelhood are left */
-int goldleft; /* Total number of treasure blocks left */
-char *worldname; /* Name of world (set of levels) */
-int curtick; /* Current clock tick number */
+GOLDDIG_EXTERN int goldleft; /* Total number of treasure blocks left */
+GOLDDIG_EXTERN char *worldname; /* Name of world (set of levels) */
+GOLDDIG_EXTERN int curtick; /* Current clock tick number */
extern int newlevel; /* Non-zero if a new level was just drawn */
-extern int savehighscore; /* only save highscores if only default levels */
+GOLDDIG_EXTERN int savehighscore; /* only save highscores if only default levels */
/* were used */
/* Variables from controlling input and output scripts */
-FILE *inscr,*outscr; /* Incoming and outgoing script file */
-int incount,outcount; /* Current script input and */
+GOLDDIG_EXTERN FILE *inscr,*outscr; /* Incoming and outgoing script file */
+GOLDDIG_EXTERN int incount,outcount; /* Current script input and */
/* output order count */
-Display *disp; /* X11 display of client */
-Window wind; /* X11 window where game is displayed */
-int scrn; /* Which screen is in use */
-unsigned long background; /* background color (color displays) */
-char *geom; /* Display geometry description string */
+GOLDDIG_EXTERN Display *disp; /* X11 display of client */
+GOLDDIG_EXTERN Window wind; /* X11 window where game is displayed */
+GOLDDIG_EXTERN int scrn; /* Which screen is in use */
+GOLDDIG_EXTERN unsigned long background; /* background color (color displays) */
+GOLDDIG_EXTERN char *geom; /* Display geometry description string */
/* Enumerated type to described direction or activity */
enum directs {
UNMOVE = 0,STAND = 1,UP = 2,DOWN = 3,LEFT = 4,RIGHT = 5,
DIGLEFT = 6,DIGRIGHT = 7,PUTDOWN = 8
};
-enum directs curorder; /* Current order which player has */
+GOLDDIG_EXTERN enum directs curorder; /* Current order which player has */
/* typed at the keyboard. */
-enum directs inorder,outorder; /* Current script input and */
+GOLDDIG_EXTERN enum directs inorder,outorder; /* Current script input and */
/* output order */
/* Structure describing all stats of thing */
-struct thing_s {
+GOLDDIG_EXTERN struct thing_s {
int xstart,ystart; /* Starting position of thing. For both */
/* this pair and (xpos,ypos), the value is */
/* actually 2 times the expected value. */
@@ -111,9 +115,9 @@ struct thing_s {
#define BADGUY 'b'
#define MAXLEVEL 5000 /* Maximum size of a level */
-unsigned char level[MAXLEVEL]; /* Array describing level using */
+GOLDDIG_EXTERN unsigned char level[MAXLEVEL]; /* Array describing level using */
/* characters from above */
-unsigned char moveallow[MAXLEVEL]; /* Array describing which directions can */
+GOLDDIG_EXTERN unsigned char moveallow[MAXLEVEL]; /* Array describing which directions can */
/* be moved out of any position in level */
/* Bit patterns for moveallow array */
#define MOVEUP 0x1 /* Upward movement is allowed */
@@ -146,7 +150,7 @@ struct symbs_s {
/* Array for fast lookup of block types. This array is index by the */
/* actual block character. */
-struct fast_s {
+GOLDDIG_EXTERN struct fast_s {
GC gc; /* Graphics cursor used for drawing block */
long code; /* Code describing block properties */
} fast_lookup[256];

View file

@ -0,0 +1,13 @@
--- moveall.c.orig 2021-02-18 16:19:37 UTC
+++ moveall.c
@@ -9,8 +9,8 @@ extern int numbadguy;
/* These are the graphics cursors used for drawing the player at */
/* various times. */
-GC standgc,angelgc,angelugc,angellgc,flygc,hang1gc,hang2gc,up1gc,up2gc;
-GC left1gc,left2gc,right1gc,right2gc;
+extern GC standgc,angelgc,angelugc,angellgc,flygc,hang1gc,hang2gc,up1gc,up2gc;
+extern GC left1gc,left2gc,right1gc,right2gc;
/* Redraw the player. The graphics cursors all use the GXor function */
/* so they will not erase what is underneath. */

View file

@ -0,0 +1,26 @@
--- movement.c.orig 1991-04-02 06:46:54 UTC
+++ movement.c
@@ -426,6 +426,7 @@ int num; /* Number of bad g
newdir = thing->dir;
}
break;
+ case STAND: case DIGLEFT: case DIGRIGHT: case UNMOVE: case PUTDOWN: break;
}
/* By default, the thing is standing in place */
@@ -498,6 +499,7 @@ int num; /* Number of bad g
thing->dir = RIGHT;
}
break;
+ case STAND: case UNMOVE: break;
}
return(0);
}
@@ -602,6 +604,7 @@ int num; /* Number of bad g
thing->dir = RIGHT;
}
break;
+ case STAND: case DIGLEFT: case DIGRIGHT: case UNMOVE: case PUTDOWN: break;
}
return(0);
}

View file

@ -0,0 +1,12 @@
--- shared.c.orig 2021-02-18 15:46:01 UTC
+++ shared.c
@@ -14,6 +14,9 @@
#include <X11/Xutil.h>
#include <errno.h>
#include <string.h>
+
+#define GOLDDIG_EXTERN
+
#include <golddig.h>
/* Include all the bitmaps for the terrain blocks */
#include <bitmaps.h>