diff options
author | Christian Weisgerber <naddy@FreeBSD.org> | 2015-09-21 20:36:55 +0800 |
---|---|---|
committer | Christian Weisgerber <naddy@FreeBSD.org> | 2015-09-21 20:36:55 +0800 |
commit | 7537f9bef042a7e9f34f21a5b1ada7278513d37a (patch) | |
tree | e1c61f9540d534926550cefb52e1a45875a76347 /games/xrobots | |
parent | e31df43b34a01b163f59ac4aeeb606183259a203 (diff) | |
download | freebsd-ports-gnome-7537f9bef042a7e9f34f21a5b1ada7278513d37a.tar.gz freebsd-ports-gnome-7537f9bef042a7e9f34f21a5b1ada7278513d37a.tar.zst freebsd-ports-gnome-7537f9bef042a7e9f34f21a5b1ada7278513d37a.zip |
Properly fix the LP64 issue in the application resource handling rather
than praying that globals end up in the lower 32-bit address space.
Add a number of missing includes, etc.
Approved by: edwin
Diffstat (limited to 'games/xrobots')
-rw-r--r-- | games/xrobots/Makefile | 4 | ||||
-rw-r--r-- | games/xrobots/files/patch-actions.c | 61 | ||||
-rw-r--r-- | games/xrobots/files/patch-game.c | 40 | ||||
-rw-r--r-- | games/xrobots/files/patch-graphics.c | 69 | ||||
-rw-r--r-- | games/xrobots/files/patch-main.c | 109 | ||||
-rw-r--r-- | games/xrobots/files/patch-score.c | 164 | ||||
-rw-r--r-- | games/xrobots/files/patch-xrobots.h | 70 | ||||
-rw-r--r-- | games/xrobots/files/patch-xrobots.man | 8 |
8 files changed, 376 insertions, 149 deletions
diff --git a/games/xrobots/Makefile b/games/xrobots/Makefile index 33c15ce7889b..f16e3c73b826 100644 --- a/games/xrobots/Makefile +++ b/games/xrobots/Makefile @@ -3,7 +3,7 @@ PORTNAME= xrobots PORTVERSION= 1.0 -PORTREVISION= 4 +PORTREVISION= 5 CATEGORIES= games MASTER_SITES= http://www.mavetju.org/download/adopted/ DISTNAME= ${PORTNAME}-${PORTVERSION}-ss-10.20 @@ -18,7 +18,7 @@ WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION} post-install: ${CP} ${FILESDIR}/xrobotscores ${STAGEDIR}${PREFIX}/lib/X11 -post-patch: +pre-build: ${REINPLACE_CMD} -e 's|__PREFIX__|${PREFIX}|g' \ ${WRKSRC}/xrobots.man ${WRKSRC}/Imakefile diff --git a/games/xrobots/files/patch-actions.c b/games/xrobots/files/patch-actions.c index 0b9bf78e407d..1661b49ff49c 100644 --- a/games/xrobots/files/patch-actions.c +++ b/games/xrobots/files/patch-actions.c @@ -1,6 +1,14 @@ ---- actions.c.orig 2013-10-13 01:20:18.000000000 +1100 -+++ actions.c 2013-10-13 01:26:21.000000000 +1100 -@@ -66,6 +66,7 @@ +--- actions.c.orig 1989-11-17 22:37:37 UTC ++++ actions.c +@@ -37,6 +37,7 @@ + #include <X11/Intrinsic.h> + #include <X11/StringDefs.h> + #include <math.h> ++#include <stdlib.h> + #include "xrobots.h" + + extern Widget sonic_command; +@@ -66,6 +67,7 @@ do_nothing_action(w,event,params,num_par Cardinal *num_params; { /* do nothing */ @@ -8,7 +16,7 @@ } -@@ -169,11 +170,11 @@ +@@ -169,11 +171,11 @@ move_action(w,event,params,num_params) int diff_x, diff_y; int num_wasted; @@ -22,7 +30,7 @@ last_human_x = human_x; last_human_y = human_y; -@@ -210,14 +211,14 @@ +@@ -210,14 +212,14 @@ jump_action(w,event,params,num_params) int diff_x, diff_y; int num_wasted; @@ -40,7 +48,25 @@ while( can_go(human_x+diff_x,human_y+diff_y) ) { last_human_x = human_x; -@@ -261,7 +262,7 @@ +@@ -225,7 +227,7 @@ jump_action(w,event,params,num_params) + human_x += diff_x; + human_y += diff_y; + num_wasted = chase(0); +- if(showjumps) ++ if(app_data.showjumps) + show_movement(); + add_score(num_wasted); + if(!num_robots) +@@ -235,7 +237,7 @@ jump_action(w,event,params,num_params) + if(!num_robots) + new_level(); + else +- if(!showjumps) ++ if(!app_data.showjumps) + display_level(); + display_possible_moves(); + auto_teleport(); +@@ -261,7 +263,7 @@ go_here_action(w,event,params,num_params int tmp_human_x, tmp_human_y; int num_wasted; @@ -49,3 +75,26 @@ while(direction = determine_direction(event->x,event->y)) { if(direction == STILL) break; +@@ -280,19 +282,19 @@ go_here_action(w,event,params,num_params + human_x = tmp_human_x; + human_y = tmp_human_y; + num_wasted = chase(0); +- if(showjumps) ++ if(app_data.showjumps) + show_movement(); + add_score(num_wasted); + if(!num_robots) + break; +- if(spiffy) ++ if(app_data.spiffy) + pointer_moved((Widget)0,(caddr_t)0,event); + XFlush(display); + } + if(!num_robots) + new_level(); + else +- if(!showjumps) ++ if(!app_data.showjumps) + display_level(); + display_possible_moves(); + auto_teleport(); diff --git a/games/xrobots/files/patch-game.c b/games/xrobots/files/patch-game.c new file mode 100644 index 000000000000..566074c6b52a --- /dev/null +++ b/games/xrobots/files/patch-game.c @@ -0,0 +1,40 @@ +--- game.c.orig 1995-03-27 12:14:34 UTC ++++ game.c +@@ -34,10 +34,8 @@ + * HP-UX :- following two defines + */ + +-#define srandom srand +-#define random rand +- + #include <X11/Intrinsic.h> ++#include <stdlib.h> + #include "xrobots.h" + + /* some of these are global */ +@@ -281,7 +279,7 @@ wait_for_em() + /* backout of latest chase() and break loop */ + undo_chase(); + +- if(diewaiting) { /* for those risk takers out there */ ++ if(app_data.diewaiting) { /* for those risk takers out there */ + display_level(); + do_death(); + check_score(score); +@@ -294,14 +292,14 @@ wait_for_em() + add_score(num_wasted); + if(!num_robots) + break; +- if(showjumps) ++ if(app_data.showjumps) + show_movement(); + XFlush(display); + } + if(!num_robots) + new_level(); + else +- if(!showjumps) ++ if(!app_data.showjumps) + display_level(); + display_possible_moves(); + auto_teleport(); diff --git a/games/xrobots/files/patch-graphics.c b/games/xrobots/files/patch-graphics.c new file mode 100644 index 000000000000..bebd78e2d1d1 --- /dev/null +++ b/games/xrobots/files/patch-graphics.c @@ -0,0 +1,69 @@ +--- graphics.c.orig 1989-11-17 22:37:38 UTC ++++ graphics.c +@@ -79,8 +79,8 @@ init_pixmaps(top_shell) + + /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ + +- fgcolor.pixel = fg; +- bgcolor.pixel = bg; ++ fgcolor.pixel = app_data.fg; ++ bgcolor.pixel = app_data.bg; + fgcolor.flags = DoRed | DoGreen | DoBlue; + bgcolor.flags = DoRed | DoGreen | DoBlue; + XQueryColor(display,DefaultColormapOfScreen(XtScreen(playfield_widget)), &fgcolor); +@@ -156,11 +156,11 @@ auto_teleport() + { + if(!cant_move) + return; +- if(autoteleport && sonic_used) { ++ if(app_data.autoteleport && sonic_used) { + teleport(); + return; + } +- if(autoteleportalways) ++ if(app_data.autoteleportalways) + teleport(); + } + +@@ -171,12 +171,12 @@ display_ok_move(x,y) + + if(can_go(x,y)) { + cant_move = 0; +- if(!spiffy) return; ++ if(!app_data.spiffy) return; + /* show the icon for a good move */ + XDrawPoint(display, playfield, gc, + pos_to_coord(x)+CELLSIZE/2,pos_to_coord(y)+CELLSIZE/2); + } else { +- if(!spiffy) return; ++ if(!app_data.spiffy) return; + /* or erase any previous dross */ + if( INXRANGE(x) && INYRANGE(y) && (robot_array[x][y] == EMPTY)) + XClearArea(display, playfield, +@@ -370,7 +370,7 @@ void free_pixmaps() + XFreeCursor(display,stayC); + XFreeCursor(display,thumbsC); + XFreeCursor(display,cant_goC); +- for(i=0;i++;i<NUM_TMP_CURSOR_PIXMAPS) ++ for(i=0;i<NUM_TMP_CURSOR_PIXMAPS;i++) + XFreePixmap(display,tmp_pixmap[i]); + + XFreePixmap(display,playerP); +@@ -405,7 +405,7 @@ show_teleport() + */ + unsigned int i; + +- if(!spiffy) return; ++ if(!app_data.spiffy) return; + + for(i=100;i>0;i-=10) { + XDrawArc(display,playfield,gc, +@@ -430,7 +430,7 @@ int center_x = pos_to_coord(human_x)+(CE + center_y = pos_to_coord(human_y)+(CELLSIZE/2)-2; + int i; + +- if(!spiffy) return; ++ if(!app_data.spiffy) return; + + for(i=pos_to_coord(human_x-1);i<pos_to_coord(human_x+2);i+=SPACING) { + XDrawLine(display,playfield,agc,center_x,center_y,i,pos_to_coord(human_y-1)); diff --git a/games/xrobots/files/patch-main.c b/games/xrobots/files/patch-main.c index 9a49ee5710b5..fc32162b3cbc 100644 --- a/games/xrobots/files/patch-main.c +++ b/games/xrobots/files/patch-main.c @@ -1,62 +1,107 @@ ---- main.c.orig 1998-01-23 01:34:05.000000000 +1100 -+++ main.c 2013-10-13 01:30:59.000000000 +1100 -@@ -170,31 +170,31 @@ - {"-scorefile","scorefile",XrmoptionSepArg, NULL }, +--- main.c.orig 1998-01-22 14:34:05 UTC ++++ main.c +@@ -55,11 +55,11 @@ + #endif + + ++#include <stdio.h> ++#include <stdlib.h> ++#include <unistd.h> + #include "xrobots.h" + +-#define srandom srand +-#define random rand +- + /*----------------------------------------------------------------------*/ + + Widget top_shell, top_widget, playfield_widget, score_command, sonic_command; +@@ -153,13 +153,7 @@ static XtActionsRec actions[] = { + {"do_nothing",(XtActionProc)do_nothing_action}, }; --static XtResource application_resources[] = { -+XtResource application_resources[] = { +-Pixel fg, bg; +-Boolean spiffy, /* limited graphics */ +- autoteleport, /* teleport when sonic used, and no moves */ +- autoteleportalways, /* teleport when no available moves */ +- showjumps, /* show no intermediate moves */ +- diewaiting; /* die if you use wait unsafely */ +-XtTranslations translations; ++AppData app_data; + + static XrmOptionDescRec options[] = { + {"-spiffy", "spiffy", XrmoptionSepArg, NULL }, +@@ -172,29 +166,30 @@ static XrmOptionDescRec options[] = { + + static XtResource application_resources[] = { {"foreground", "Foreground", XtRPixel, sizeof(Pixel), - (Cardinal)&fg, XtRString, (caddr_t) "Black"}, -+ NULL, XtRString, (caddr_t) "Black"}, ++ XtOffsetOf(AppData, fg), XtRString, (caddr_t) "Black"}, {"background", "Background", XtRPixel, sizeof(Pixel), - (Cardinal)&bg, XtRString, (caddr_t) "White"}, -+ NULL, XtRString, (caddr_t) "White"}, ++ XtOffsetOf(AppData, bg), XtRString, (caddr_t) "White"}, {"spiffy", "Spiffy", XtRBoolean, sizeof(Boolean), - (Cardinal)&spiffy, XtRString, (caddr_t) "True"}, -+ NULL, XtRString, (caddr_t) "True"}, ++ XtOffsetOf(AppData, spiffy), XtRString, (caddr_t) "True"}, {"autoteleport", "Autoteleport", XtRBoolean, sizeof(Boolean), - (Cardinal)&autoteleport, XtRString, (caddr_t) "False"}, -+ NULL, XtRString, (caddr_t) "False"}, ++ XtOffsetOf(AppData, autoteleport), XtRString, (caddr_t) "False"}, {"autoteleportalways", "Autoteleportalways", XtRBoolean, sizeof(Boolean), - (Cardinal)&autoteleportalways, XtRString, (caddr_t) "False"}, -+ NULL, XtRString, (caddr_t) "False"}, ++ XtOffsetOf(AppData, autoteleportalways), XtRString, (caddr_t) "False"}, {"showmovement", "Showmovement", XtRBoolean, sizeof(Boolean), - (Cardinal)&showjumps, XtRString, (caddr_t) "True"}, -+ NULL, XtRString, (caddr_t) "True"}, ++ XtOffsetOf(AppData, showjumps), XtRString, (caddr_t) "True"}, {"diewaiting", "Diewaiting", XtRBoolean, sizeof(Boolean), - (Cardinal)&diewaiting, XtRString, (caddr_t) "False"}, -+ NULL, XtRString, (caddr_t) "False"}, ++ XtOffsetOf(AppData, diewaiting), XtRString, (caddr_t) "False"}, {"translations","Translations", XtRTranslationTable, sizeof(XtTranslations), - (Cardinal)&translations, XtRString, (caddr_t)translations_str}, -+ NULL, XtRString, (caddr_t)translations_str}, ++ XtOffsetOf(AppData, translations), XtRString, (caddr_t)translations_str}, {"scorefile","Scorefile", XtRString, sizeof(String), - (Cardinal)&score_filename, XtRString, (caddr_t)SCORE_FILE}, -+ NULL, XtRString, (caddr_t)SCORE_FILE}, ++ XtOffsetOf(AppData, score_filename), XtRString, (caddr_t)SCORE_FILE}, }; /*----------------------------------------------------------------------*/ ++int main(argc, argv) - unsigned int argc; + int argc; char **argv; { Arg args[1]; -@@ -206,6 +206,16 @@ - - srandom(getpid()); - -+ application_resources[0].resource_offset=(Cardinal)&fg; -+ application_resources[1].resource_offset=(Cardinal)&bg; -+ application_resources[2].resource_offset=(Cardinal)&spiffy; -+ application_resources[3].resource_offset=(Cardinal)&autoteleport; -+ application_resources[4].resource_offset=(Cardinal)&autoteleportalways; -+ application_resources[5].resource_offset=(Cardinal)&showjumps; -+ application_resources[6].resource_offset=(Cardinal)&diewaiting; -+ application_resources[7].resource_offset=(Cardinal)&translations; -+ application_resources[8].resource_offset=(Cardinal)&score_filename; -+ - top_shell = XtInitialize(argv[0], "xrobots", options, XtNumber(options), - (int *)&argc, argv); - XtSetValues(top_shell, arglisttop_shell, XtNumber(arglisttop_shell)); +@@ -212,7 +207,7 @@ main(argc, argv) + + XtAddActions(actions,XtNumber(actions)); + +- XtGetApplicationResources(top_shell, 0, application_resources, ++ XtGetApplicationResources(top_shell, &app_data, application_resources, + XtNumber(application_resources), NULL, 0 ); + + top_widget = XtCreateManagedWidget( +@@ -228,7 +223,7 @@ main(argc, argv) + arglistplayfield, + XtNumber(arglistplayfield)); + +- XtAugmentTranslations(playfield_widget,translations); ++ XtAugmentTranslations(playfield_widget,app_data.translations); + + teleport_command = XtCreateManagedWidget( + "teleport_button", +@@ -292,12 +287,12 @@ main(argc, argv) + + display = XtDisplay(playfield_widget); + playfield = XtWindow(playfield_widget); +- gcv.foreground = fg; +- gcv.background = bg; ++ gcv.foreground = app_data.fg; ++ gcv.background = app_data.bg; + gcv.function = GXcopy; + gc = XCreateGC(display, playfield, + GCForeground | GCBackground | GCFunction, &gcv); +- gcv.foreground = bg; ++ gcv.foreground = app_data.bg; + cleargc = XCreateGC(display, playfield, + GCForeground | GCBackground | GCFunction, &gcv); + diff --git a/games/xrobots/files/patch-score.c b/games/xrobots/files/patch-score.c index 87414fe10e96..549ee2d1f197 100644 --- a/games/xrobots/files/patch-score.c +++ b/games/xrobots/files/patch-score.c @@ -1,91 +1,73 @@ -*** score.c.orig Thu Jan 22 09:58:52 1998 ---- score.c Sun Apr 12 14:00:32 1998 -*************** -*** 56,61 **** ---- 56,62 ---- - - #include <X11/Xos.h> /* brings in <sys/file.h> */ - #include <stdio.h> -+ #include <stdlib.h> - #include "xrobots.h" - - /*----------------------------------------------------------------------*/ -*************** -*** 67,73 **** - - static SCORE scores[MAXSCORES]; - -! void show_scores(), - write_out_scores(); - - static void new_high_score(), ---- 68,74 ---- - - static SCORE scores[MAXSCORES]; - -! static void show_scores(), - write_out_scores(); - - static void new_high_score(), -*************** -*** 110,121 **** - #ifndef SYSV - flock(scorefile->_file, 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; - } - } - ---- 111,123 ---- - #ifndef SYSV - flock(scorefile->_file, LOCK_EX); - #endif -! 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,200 **** - - - /*ARGSUSED*/ -! static XtCallbackProc - popdown_callback(w, closure, call_data) - Widget w; - caddr_t closure; ---- 196,202 ---- - - - /*ARGSUSED*/ -! static void - popdown_callback(w, closure, call_data) - Widget w; - caddr_t closure; -*************** -*** 253,259 **** - show_scores() - { - int i; -! char tmp_str[31]; - Arg tmp_arg; - - for(i = 0;i<MAXSCORES;i++) { ---- 255,261 ---- - show_scores() - { - int i; -! char tmp_str[64]; - Arg tmp_arg; - - for(i = 0;i<MAXSCORES;i++) { +--- score.c.orig 1998-01-22 14:58:52 UTC ++++ score.c +@@ -56,6 +56,7 @@ + + #include <X11/Xos.h> /* brings in <sys/file.h> */ + #include <stdio.h> ++#include <stdlib.h> + #include "xrobots.h" + + /*----------------------------------------------------------------------*/ +@@ -67,14 +68,13 @@ typedef struct { + + 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; + + /*----------------------------------------------------------------------*/ + +@@ -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); + #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 + show_scores() + { + int i; +- char tmp_str[31]; ++ char tmp_str[64]; + Arg tmp_arg; + + for(i = 0;i<MAXSCORES;i++) { diff --git a/games/xrobots/files/patch-xrobots.h b/games/xrobots/files/patch-xrobots.h index 7061fa8835c2..c070e442fa37 100644 --- a/games/xrobots/files/patch-xrobots.h +++ b/games/xrobots/files/patch-xrobots.h @@ -1,14 +1,56 @@ -*** xrobots.h.orig Fri Nov 17 14:37:40 1989 ---- xrobots.h Mon Jan 2 22:47:56 1995 -*************** -*** 146,154 **** - game_active, - sonic_used; - -- #define MIN(a,b) ((a<b)?a:b) -- #define MAX(a,b) ((a>b)?a:b) -- - #define INXRANGE( _x_ ) (((_x_) >=0) && ((_x_)<MAXX)) - #define INYRANGE( _y_ ) (((_y_) >=0) && ((_y_)<MAXY)) - ---- 146,151 ---- +--- xrobots.h.orig 1989-11-17 22:37:40 UTC ++++ xrobots.h +@@ -33,21 +33,27 @@ + * + */ + ++typedef struct { ++ Pixel fg, ++ bg; ++ Boolean spiffy, /* limited graphics */ ++ autoteleport, /* teleport when sonic used, and no moves */ ++ autoteleportalways, /* teleport when no available moves */ ++ showjumps, /* show no intermediate moves */ ++ diewaiting; /* die if you use wait unsafely */ ++ XtTranslations translations; ++ char *score_filename; ++} AppData; ++ + /* + * from main.c + */ ++extern AppData app_data; + extern Display *display; + extern Window playfield; + extern Widget playfield_widget; + extern GC gc, + cleargc; +-extern Pixel fg, +- bg; +-extern Boolean spiffy, +- autoteleport, +- autoteleportalways, +- showjumps, +- diewaiting; + extern unsigned int + chasetime; + +@@ -106,8 +112,6 @@ extern void check_score(), + + extern void show_scores_callback(); + +-extern char *score_filename; +- + /* + * from game.c + */ +@@ -146,9 +150,6 @@ extern int score, + game_active, + sonic_used; + +-#define MIN(a,b) ((a<b)?a:b) +-#define MAX(a,b) ((a>b)?a:b) +- + #define INXRANGE( _x_ ) (((_x_) >=0) && ((_x_)<MAXX)) + #define INYRANGE( _y_ ) (((_y_) >=0) && ((_y_)<MAXY)) + diff --git a/games/xrobots/files/patch-xrobots.man b/games/xrobots/files/patch-xrobots.man index a51f9f2f62e5..4e4362ed8b44 100644 --- a/games/xrobots/files/patch-xrobots.man +++ b/games/xrobots/files/patch-xrobots.man @@ -1,5 +1,5 @@ ---- xrobots.man.orig Sat Nov 18 09:37:40 1989 -+++ xrobots.man Sat Dec 8 22:47:26 2001 +--- xrobots.man.orig 1989-11-17 22:37:40 UTC ++++ xrobots.man @@ -3,7 +3,7 @@ .SH NAME xrobots \- fight off villainous robots (X Windows) @@ -9,7 +9,7 @@ .SH DESCRIPTION .LP As in robots(6), xrobots puts you into a world of evil robots (but in -@@ -110,7 +110,7 @@ +@@ -110,7 +110,7 @@ game play a little more like BSD robots. xrobots.scorefile .RS Set this to the path of your personal score file. The file will be @@ -18,7 +18,7 @@ .RE .LP xrobots.showmovement -@@ -214,7 +214,7 @@ +@@ -214,7 +214,7 @@ the USER environment variable. .LP .SH FILES .LP |