diff --git a/games/xrobots/Makefile b/games/xrobots/Makefile index 13a08fcbdfac..c7719cd34cd9 100644 --- a/games/xrobots/Makefile +++ b/games/xrobots/Makefile @@ -1,22 +1,22 @@ PORTNAME= xrobots PORTVERSION= 1.0 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= games MASTER_SITES= http://www.mavetju.org/download/adopted/ DISTNAME= ${PORTNAME}-${PORTVERSION}-ss-10.20 MAINTAINER= ports@FreeBSD.org COMMENT= Fight off villainous robots (X version) USES= imake xorg USE_XORG= x11 xaw xext xmu xt sm ice WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION} post-install: ${CP} ${FILESDIR}/xrobotscores ${STAGEDIR}${PREFIX}/lib/X11 pre-build: ${REINPLACE_CMD} -e 's|__PREFIX__|${PREFIX}|g' \ ${WRKSRC}/xrobots.man ${WRKSRC}/Imakefile .include diff --git a/games/xrobots/files/patch-score.c b/games/xrobots/files/patch-score.c index 549ee2d1f197..fbe0e5eb4cf5 100644 --- a/games/xrobots/files/patch-score.c +++ b/games/xrobots/files/patch-score.c @@ -1,73 +1,92 @@ --- score.c.orig 1998-01-22 14:58:52 UTC +++ score.c @@ -56,6 +56,7 @@ #include /* brings in */ #include +#include #include "xrobots.h" /*----------------------------------------------------------------------*/ -@@ -67,14 +68,13 @@ typedef struct { +@@ -67,14 +68,13 @@ static SCORE scores[MAXSCORES]; static SCORE scores[MAXSCORES]; -void show_scores(), +static void show_scores(), write_out_scores(); static void new_high_score(), load_scores(); static FILE *scorefile = 0; -char *score_filename; /*----------------------------------------------------------------------*/ +@@ -91,7 +91,7 @@ check_score(current_score) + } + if(scorefile) { + #ifndef SYSV +- flock(scorefile->_file, LOCK_UN); ++ flock(fileno(scorefile), LOCK_UN); + #endif + fclose(scorefile); + show_scores(); @@ -103,19 +103,20 @@ static void load_scores() { int i = 0; - if( !(scorefile = fopen(score_filename,"r+")) ) { - scorefile = fopen(score_filename, "w"); + if( !(scorefile = fopen(app_data.score_filename,"r+")) ) { + scorefile = fopen(app_data.score_filename, "w"); return; } #ifndef SYSV - flock(scorefile->_file, LOCK_EX); +- flock(scorefile->_file, LOCK_EX); ++ flock(fileno(scorefile), LOCK_EX); #endif - while( fgets(scores[i].score,6,scorefile) /* get score */ - && fgets(scores[i].name,26,scorefile) /* get name */ - && fgetc(scorefile)) /* and newline */ - { - i++; - if( i > MAXSCORES ) break; + for(i = 0; i < MAXSCORES; i++) { + if(!fgets(scores[i].score, 6, scorefile)) /* get score */ + break; + if(!fgets(scores[i].name, 26, scorefile)) /* get name */ + break; + if(!fgetc(scorefile)) /* and newline */ + break; } } @@ -194,7 +195,7 @@ static Arg arglist_popdown[] = { /*ARGSUSED*/ -static XtCallbackProc +static void popdown_callback(w, closure, call_data) Widget w; caddr_t closure; -@@ -253,7 +254,7 @@ void +@@ -253,7 +254,7 @@ show_scores() show_scores() { int i; - char tmp_str[31]; + char tmp_str[64]; Arg tmp_arg; for(i = 0;i_file, LOCK_UN); ++ flock(fileno(scorefile), LOCK_UN); + #endif + fclose(scorefile); + show_scores();