Skip site navigation (1)Skip section navigation (2)
Date:      20 Nov 2004 15:13:43 -0000
From:      Erik Greenwald <erik@smluc.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        erik@math.smsu.edu
Subject:   ports/74162: [Update]  games/xroads  fix for 5/current
Message-ID:  <20041120151343.753.qmail@phoenix.smluc.org>
Resent-Message-ID: <200411201520.iAKFKDX2098486@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         74162
>Category:       ports
>Synopsis:       [Update]  games/xroads  fix for 5/current
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 20 15:20:12 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Erik Greenwald
>Release:        FreeBSD 4.10-STABLE i386
>Organization:
>Environment:
System: FreeBSD fenris 4.10-STABLE FreeBSD 4.10-STABLE #1: Sat Sep 25 14:06:08 EDT 2004 root@:/usr/src/sys/compile/FENRIS i386


>Description:

games/xroads files on 5.3 and -current due to the addition of 
'round' to math.h conflicting with a function in the game. This
patch changes the name of the games function to "xrround", 
eliminating the conflict. Tested (and amusing) on

FreeBSD fenris 4.10-STABLE FreeBSD 4.10-STABLE #1: Sat Sep 25 14:06:08 EDT 2004     root@:/usr/src/sys/compile/FENRIS  i386
FreeBSD vidar.br0kenland.org 6.0-CURRENT FreeBSD 6.0-CURRENT #0: Thu Nov  4 11:54:46 EST 2004     erik@vidar.br0kenland.org:/usr/home/erik/tmp/fbsd/usr/src/sys/VIDAR  i386

Port revision has not been bumped since this only fixes compile 
breakage (should be no change to pre-5.3 operation)

willing to hold maintainership

>How-To-Repeat:
>Fix:

--- patch-games_xroads begins here ---
Index: games/xroads/Makefile
===================================================================
RCS file: /home/ncvs/ports/games/xroads/Makefile,v
retrieving revision 1.15
diff -u -r1.15 Makefile
--- games/xroads/Makefile	17 Jul 2004 14:21:05 -0000	1.15
+++ games/xroads/Makefile	20 Nov 2004 15:06:17 -0000
@@ -12,7 +12,7 @@
 MASTER_SITES=	http://linux.tucows.com/files/x11/entertain/
 DISTNAME=	${PORTNAME}-v${PORTVERSION}
 
-MAINTAINER=	ports@FreeBSD.org
+MAINTAINER=	erik@smluc.org
 COMMENT=	Commodore 64 "Crossroads"-like video game for X Window System
 
 USE_X_PREFIX=	yes
Index: games/xroads/files/patch-ai.c
===================================================================
RCS file: games/xroads/files/patch-ai.c
diff -N games/xroads/files/patch-ai.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ games/xroads/files/patch-ai.c	20 Nov 2004 15:06:17 -0000
@@ -0,0 +1,116 @@
+--- ai.c.orig	Sat Nov 20 09:50:36 2004
++++ ai.c	Sat Nov 20 09:50:56 2004
+@@ -59,12 +59,12 @@
+    int tries=0;
+ 
+       /* If in a halfstep, finish it */
+-   if(ntrunc(amonst->x)!=round(amonst->x)) switch(amonst->dir) {
++   if(ntrunc(amonst->x)!=xrround(amonst->x)) switch(amonst->dir) {
+       case LEFT: amonst->x-=0.5; return;
+       case RIGHT: amonst->x+=0.5; return;
+       default: amonst->dir = directions[(int)rnd(2) + 2]; break;
+       }
+-   if(ntrunc(amonst->y)!=round(amonst->y)) switch(amonst->dir) {
++   if(ntrunc(amonst->y)!=xrround(amonst->y)) switch(amonst->dir) {
+       case UP: amonst->y-=0.5; return;
+       case DOWN: amonst->y+=0.5; return;
+       default: amonst->dir = directions[(int)rnd(2)]; break;
+@@ -84,9 +84,9 @@
+       /* Find coordinates for new position */
+    switch(dir) {
+       case UP: y-=0.5; eqy=ntrunc(y); eqx=ntrunc(x); break;
+-      case DOWN: y+=0.5; eqy=round(y); eqx=ntrunc(x); break;
++      case DOWN: y+=0.5; eqy=xrround(y); eqx=ntrunc(x); break;
+       case LEFT: x-=0.5; eqy=ntrunc(y); eqx=ntrunc(x); break;
+-      case RIGHT: x+=0.5; eqy=ntrunc(y); eqx=round(x); break;
++      case RIGHT: x+=0.5; eqy=ntrunc(y); eqx=xrround(x); break;
+       default: printf("Error: Not a direction\n"); return;
+       }
+ 
+@@ -95,7 +95,7 @@
+       goto tryagain;
+ 
+       /* Check for double half-step */
+-   if(ntrunc(x)!=round(x) && ntrunc(y)!=round(y)) goto tryagain;
++   if(ntrunc(x)!=xrround(x) && ntrunc(y)!=xrround(y)) goto tryagain;
+ 
+       /* Did we hit a powerup? */
+    if(data[xytotype(eqx, eqy)].etype == POWERUP) {
+@@ -121,12 +121,12 @@
+    float dx, dy, dz;
+ 
+       /* If in a halfstep, finish it */
+-   if(ntrunc(amonst->x)!=round(amonst->x)) switch(amonst->dir) {
++   if(ntrunc(amonst->x)!=xrround(amonst->x)) switch(amonst->dir) {
+       case LEFT: amonst->x-=0.5; return;
+       case RIGHT: amonst->x+=0.5; return;
+       default: amonst->dir = directions[(int)rnd(2) + 2]; break;
+       }
+-   if(ntrunc(amonst->y)!=round(amonst->y)) switch(amonst->dir) {
++   if(ntrunc(amonst->y)!=xrround(amonst->y)) switch(amonst->dir) {
+       case UP: amonst->y-=0.5; return;
+       case DOWN: amonst->y+=0.5; return;
+       default: amonst->dir = directions[(int)rnd(2)]; break;
+@@ -146,8 +146,8 @@
+    tryagain: /* Come back here to try again */
+    tries++;
+    if(tries>100) {
+-      if(ntrunc(amonst->x)==round(amonst->x) &&
+-         ntrunc(amonst->y)==round(amonst->y))
++      if(ntrunc(amonst->x)==xrround(amonst->x) &&
++         ntrunc(amonst->y)==xrround(amonst->y))
+          watchentity(amonst, target);
+       return;
+       }
+@@ -186,7 +186,7 @@
+       goto tryagain;
+ 
+       /* Be careful of half-steps */
+-   if(ntrunc(x)!=round(x) && ntrunc(y)!=round(y)) goto tryagain;
++   if(ntrunc(x)!=xrround(x) && ntrunc(y)!=xrround(y)) goto tryagain;
+ 
+       /* Did we hit a powerup? */
+    if(data[xytotype(eqx, eqy)].etype == POWERUP) {
+@@ -318,7 +318,7 @@
+       printf("I was asked to kill a monster that shouldn't be killed!\n");
+       if(amonst->health <= 0) {
+          if(data[amonst->type].etype != EFFECT) {
+-            maze[round(amonst->y)][round(amonst->x)] = -2; /* Blank */
++            maze[xrround(amonst->y)][xrround(amonst->x)] = -2; /* Blank */
+             maze[ntrunc(amonst->y)][ntrunc(amonst->x)] = -2; /* Blank */
+             }
+          draw_tilex2(mainwindow, data[amonst->type].tile[amonst->frame],
+@@ -332,8 +332,8 @@
+                      bmonst->x*GRIDSIZE, bmonst->y*GRIDSIZE,
+                      bmonst->color, bmonst->dir);
+          }
+-      if(maze[round(amonst->y)][round(amonst->x)]!=-2) {
+-         bmonst=&monst[maze[round(amonst->y)][round(amonst->x)]];
++      if(maze[xrround(amonst->y)][xrround(amonst->x)]!=-2) {
++         bmonst=&monst[maze[xrround(amonst->y)][xrround(amonst->x)]];
+          draw_tilex2(mainwindow, data[bmonst->type].tile[bmonst->frame],
+                      bmonst->x*GRIDSIZE, bmonst->y*GRIDSIZE,
+                      bmonst->color, bmonst->dir);
+@@ -392,9 +392,9 @@
+       amonst->atspeed = data[amonst->type].atspeed;
+       switch(amonst->dir) {
+          case LEFT: fx-=1; x=ntrunc(fx); y=ntrunc(fy); break;
+-         case RIGHT: fx+=1; x=round(fx); y=ntrunc(fy); break;
++         case RIGHT: fx+=1; x=xrround(fx); y=ntrunc(fy); break;
+          case UP: fy-=1; y=ntrunc(fy); x=ntrunc(fx); break;
+-         case DOWN: fy+=1; y=round(fy); x=ntrunc(fx); break;
++         case DOWN: fy+=1; y=xrround(fy); x=ntrunc(fx); break;
+          }
+       icorrectpos(&x, &y);
+       if(!checkdest(x, y)) {
+@@ -460,8 +460,8 @@
+    if(!(amonst->x == target->x || amonst->y == target->y)) return 0;
+ 
+       /* Halfsteps are banned */
+-   if(round(amonst->x) != ntrunc(amonst->x)) return 0;
+-   if(round(amonst->y) != ntrunc(amonst->y)) return 0;
++   if(xrround(amonst->x) != ntrunc(amonst->x)) return 0;
++   if(xrround(amonst->y) != ntrunc(amonst->y)) return 0;
+ 
+       /* Force x1, y1 to be smaller pair */
+    if(x1 > x2) {
Index: games/xroads/files/patch-xroads.c
===================================================================
RCS file: games/xroads/files/patch-xroads.c
diff -N games/xroads/files/patch-xroads.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ games/xroads/files/patch-xroads.c	20 Nov 2004 15:06:17 -0000
@@ -0,0 +1,134 @@
+--- xroads.c.orig	Fri Jul 16 21:37:03 1999
++++ xroads.c	Sat Nov 20 10:01:35 2004
+@@ -318,7 +318,7 @@
+ }
+ 
+ /*************************************************************************************************/
+-int round( float num ) {  /* Round a float to an int */
++int xrround( float num ) {  /* Round a float to an int */
+    return (int)(num+0.5);
+ }
+ 
+@@ -452,8 +452,8 @@
+             }
+ 
+          /* VacAttack */
+-      if(data[amonst->type].attack1==VACCUUM && (round(amonst->x) ==
+-         ntrunc(amonst->x) && round(amonst->y) == ntrunc(amonst->y)) &&
++      if(data[amonst->type].attack1==VACCUUM && (xrround(amonst->x) ==
++         ntrunc(amonst->x) && xrround(amonst->y) == ntrunc(amonst->y)) &&
+          clearshot(amonst, &monst[targ]) && amonst->team!=monst[targ].team
+          && data[monst[targ].type].etype != POWERUP) {
+          watchentity(amonst, &monst[targ]);
+@@ -479,9 +479,9 @@
+       else amonst->frame++;
+ 
+       if(data[amonst->type].etype!=EFFECT) {
+-         maze[round(oldy)][round(oldx)]=-2; /* Blank out old space */
++         maze[xrround(oldy)][xrround(oldx)]=-2; /* Blank out old space */
+          maze[ntrunc(oldy)][ntrunc(oldx)]=-2;
+-         maze[round(amonst->y)][round(amonst->x)]=number;
++         maze[xrround(amonst->y)][xrround(amonst->x)]=number;
+          maze[ntrunc(amonst->y)][ntrunc(amonst->x)]=number;
+          }
+ 
+@@ -491,8 +491,8 @@
+          draw_tilex2(mainwindow, data[bmonst->type].tile[bmonst->frame], (bmonst->x)*GRIDSIZE,
+                      (bmonst->y)*GRIDSIZE, bmonst->color, bmonst->dir);
+          }
+-      if(maze[round(amonst->y)][round(amonst->x)]!=-2) {
+-         bmonst=&monst[maze[round(amonst->y)][round(amonst->x)]];
++      if(maze[xrround(amonst->y)][xrround(amonst->x)]!=-2) {
++         bmonst=&monst[maze[xrround(amonst->y)][xrround(amonst->x)]];
+          draw_tilex2(mainwindow, data[bmonst->type].tile[bmonst->frame], (bmonst->x)*GRIDSIZE,
+                      (bmonst->y)*GRIDSIZE, bmonst->color, bmonst->dir);
+          }
+@@ -615,7 +615,7 @@
+    else if(player->attr & PULL_R) { newx+=1; player->attr &= ~PULL_R; }
+ 
+       /* Only one half-step at a time */
+-   if(round(newx)!=ntrunc(newx) && round(newy)!=ntrunc(newy)) {
++   if(xrround(newx)!=ntrunc(newx) && xrround(newy)!=ntrunc(newy)) {
+ #ifdef DEBUG
+       printf("Damn, in two half-steps at a time...\n");
+ #endif
+@@ -631,17 +631,17 @@
+ 
+       /* If we're in a half-step, eqx and eqy are the space we're moving
+          into */
+-   if(round(newx)!=ntrunc(newx)) {
++   if(xrround(newx)!=ntrunc(newx)) {
+       eqy = ntrunc(newy);
+       if(newx > player->x)
+-         eqx = round(newx);
++         eqx = xrround(newx);
+       else if(newx < player->x)
+          eqx = ntrunc(newx);
+       }
+-   else if(round(newy)!=ntrunc(newy)) {
++   else if(xrround(newy)!=ntrunc(newy)) {
+       eqx = ntrunc(newx);
+       if(newy > player->y)
+-         eqy = round(newy);
++         eqy = xrround(newy);
+       else if(newy < player->y)
+          eqy = ntrunc(newy);
+       }
+@@ -652,9 +652,9 @@
+ /*
+    switch(player->dir) {
+       case LEFT: eqx = ntrunc(newx); break;
+-      case RIGHT: eqx = round(newx); break;
++      case RIGHT: eqx = xrround(newx); break;
+       case UP: eqy = ntrunc(newy); break;
+-      case DOWN: eqy = round(newy); break;
++      case DOWN: eqy = xrround(newy); break;
+       default: break;
+       }
+ */
+@@ -667,8 +667,8 @@
+    printf("Destination (%0.2f, %0.2f)...\n", newx, newy);
+    printf("Equiv (%d, %d)\n", eqx, eqy);
+    printf("@ %d, %d : %d\n", eqx, eqy, maze[eqy][eqx]);
+-   printf("newx: %0.2f: round %d, ntrunc %d\n", newx, round(newx), ntrunc(newx));
+-   printf("newy: %0.2f: round %d, ntrunc %d\n", newy, round(newy), ntrunc(newy));
++   printf("newx: %0.2f: round %d, ntrunc %d\n", newx, xrround(newx), ntrunc(newx));
++   printf("newy: %0.2f: round %d, ntrunc %d\n", newy, xrround(newy), ntrunc(newy));
+    printf("Checkdest: %d\n", checkdest(eqx, eqy));
+    printf("-----\n");
+    }
+@@ -704,7 +704,7 @@
+ #ifdef DEBUG
+       printf("something in the way. (%d or %d)\n",
+              maze[ntrunc(newy)][ntrunc(newx)],
+-             maze[round(newy)][round(newy)]);
++             maze[xrround(newy)][xrround(newy)]);
+ #endif
+       newx=player->x;
+       newy=player->y;
+@@ -715,14 +715,14 @@
+ #endif
+ 
+      /* Destination has been set, now all we have to do is move there */
+-   maze[round(player->y)][round(player->x)]=-2;
++   maze[xrround(player->y)][xrround(player->x)]=-2;
+    maze[ntrunc(player->y)][ntrunc(player->x)]=-2;
+    draw_tilex2(mainwindow, blank, player->x*GRIDSIZE, player->y*GRIDSIZE,
+                BLACK, RIGHT);
+ 
+       /* Draw player */
+    player->x=newx; player->y=newy;
+-   maze[round(player->y)][round(player->x)]=player->ind;
++   maze[xrround(player->y)][xrround(player->x)]=player->ind;
+    maze[ntrunc(player->y)][ntrunc(player->x)]=player->ind;
+    draw_tilex2(mainwindow, data[datapos].tile[player->frame],
+                player->x*GRIDSIZE, player->y*GRIDSIZE,
+@@ -1340,7 +1340,7 @@
+          player[i]->health = 0;
+          if(player[i]->attr & ACTIVE) {
+             player[i]->attr ^= ACTIVE;
+-            maze[round(player[i]->y)][round(player[i]->x)] = -2;
++            maze[xrround(player[i]->y)][xrround(player[i]->x)] = -2;
+             maze[ntrunc(player[i]->y)][ntrunc(player[i]->x)] = -2;  
+             draw_tilex2(mainwindow, blank, player[i]->x*GRIDSIZE,
+                         player[i]->y*GRIDSIZE, BLACK, RIGHT);
Index: games/xroads/files/patch-xroads.h
===================================================================
RCS file: games/xroads/files/patch-xroads.h
diff -N games/xroads/files/patch-xroads.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ games/xroads/files/patch-xroads.h	20 Nov 2004 15:06:17 -0000
@@ -0,0 +1,11 @@
+--- xroads.h.orig	Sat Nov 20 09:50:11 2004
++++ xroads.h	Sat Nov 20 09:49:42 2004
+@@ -33,7 +33,7 @@
+ void killme( char * );
+ void xconnect( int, char *[] );
+ int ntrunc( float );
+-int round( float );
++int xrround( float );
+ #ifdef SIGHANDLE
+ void sigcatch( int );
+ #endif
--- patch-games_xroads ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041120151343.753.qmail>