Tags: patch
thanks

Hi,

This patch make netmaze run for my on amd64 -- I just swapped all the
longs for ints.  Behavior between i386 and amd64 looks the same to me
now.

-Kees

-- 
Kees Cook                                            @outflux.net
diff -u netmaze-0.81+jpg0.82/allmove.c netmaze-0.81+jpg0.82/allmove.c
--- netmaze-0.81+jpg0.82/allmove.c
+++ netmaze-0.81+jpg0.82/allmove.c
@@ -12,24 +12,24 @@
 extern void play_sound(int);
 extern int random_maze(MAZE*,int,int);
 
-extern long trigtab[];
+extern int trigtab[];
 extern struct shared_struct *sm;
 
-static void enemy_colision(long,long,PLAYER*,PLAYER*);
+static void enemy_colision(int,int,PLAYER*,PLAYER*);
 static int  enemy_touch(PLAYER *player,PLAYER *players);
-static void wall_pcoll(long,long,PLAYER*);
+static void wall_pcoll(int,int,PLAYER*);
 static int  wall_scoll(PLAYER*,int nr);
-static int  player_hit(int,long,long,PLAYER *players);
+static int  player_hit(int,int,int,PLAYER *players);
 static void set_player_pos(PLAYER*,int,MAZE *mazeadd);
 static int  add_shot(PLAYER*);
 static void remove_shot(PLAYER*,int);
-static int  ball_bounce(PLAYER *p,int i,int xc,int yc,long x,long y);
+static int  ball_bounce(PLAYER *p,int i,int xc,int yc,int x,int y);
 static void convert_trigtabs(int divider);
-void myrandominit(long s);
+void myrandominit(int s);
 static int myrandom(void);
 static void reset_player(PLAYER *players,int i);
 
-long walktab[320],shoottab[320];
+int walktab[320],shoottab[320];
 
 /*
  in diesem Programmteil sollten moeglichst keine
@@ -56,7 +56,7 @@
 {
   int i,joy,wink,plynum,j,next;
   PLAYER *player;
-  long plx,ply;
+  int plx,ply;
   int count;
 
   count = 1<<sm->config.divider;
@@ -407,9 +407,9 @@
 /* Player <-> Wall Collision  */
 /******************************/
 
-static void wall_pcoll(long xold,long yold,PLAYER *player)
+static void wall_pcoll(int xold,int yold,PLAYER *player)
 {
-  long x,y;
+  int x,y;
   int  xc,yc;
   int  xflag=-1;
   int  yflag=-1;
@@ -547,9 +547,9 @@
 
 static int wall_scoll(PLAYER *p,int i)
 {
-  long x,y;
+  int x,y;
   int  xc,yc,flag=0;
-  long sx,sy;
+  int sx,sy;
 
   sx = p->shots[i].sx;
   sy = p->shots[i].sy;
@@ -655,7 +655,7 @@
  * wall_scoll-helper (not complete yet)
  */
 
-static int ball_bounce(PLAYER *p,int i,int xc,int yc,long x,long y)
+static int ball_bounce(PLAYER *p,int i,int xc,int yc,int x,int y)
 {
   int f = 0,w = 0;
 
@@ -744,7 +744,7 @@
 /* Player <-> Player Collision  */
 /********************************/
 
-static void enemy_colision(long xold,long yold,PLAYER *player,PLAYER *players)
+static void enemy_colision(int xold,int yold,PLAYER *player,PLAYER *players)
 {
   if(enemy_touch(player,players))
   {
@@ -756,7 +756,7 @@
 static int enemy_touch(PLAYER *player,PLAYER *players)
 {
   int i;
-  long xd,yd;
+  int xd,yd;
 
   for(i=0;i<sm->anzplayers;i++,players++)
   {
@@ -785,10 +785,10 @@
 /* -1: no hit / >= 0: playernr. */
 /********************************/
 
-static int player_hit(int plnr,long sx,long sy,PLAYER *plys)
+static int player_hit(int plnr,int sx,int sy,PLAYER *plys)
 {
   int i;
-  long xd,yd;
+  int xd,yd;
 
   for(i=0;i<sm->anzplayers;i++,plys++)
   {
@@ -977,7 +977,7 @@
  * "Random" from: r.sedgewick/algorithms
  */
 
-void myrandominit(long s)
+void myrandominit(int s)
 {
   int j;
   sm->rndshiftpos = 10;
@@ -1006,9 +1006,9 @@
 
 static void convert_trigtabs(int divider)
 {
-  long *tab1 = trigtab,*tab2 = walktab,*tab3 = shoottab;
+  int *tab1 = trigtab,*tab2 = walktab,*tab3 = shoottab;
   int i;
-  long s;
+  int s;
   static int t = -1;
 
   if(divider == t) return;
diff -u netmaze-0.81+jpg0.82/netmaze.h netmaze-0.81+jpg0.82/netmaze.h
--- netmaze-0.81+jpg0.82/netmaze.h
+++ netmaze-0.81+jpg0.82/netmaze.h
@@ -98,7 +98,7 @@
 
 struct fd_mask
 {
-  u_long fds_bits[NOFILE/32+1];
+  u_int fds_bits[NOFILE/32+1];
 };
 
 /* Structur auf MAZE. Here is all important maze-stuff */
@@ -114,18 +114,18 @@
   int xdim;
   int ydim;
   char *setlist;
-  long *bitlist;
+  int *bitlist;
 } MAZE;
 
 /* PLAYER-Struct */
 
 typedef struct {
-  long sx;
-  long sy;
-  long sxd;
-  long syd;
+  int sx;
+  int sy;
+  int sxd;
+  int syd;
   int  salive;
-  long power;
+  int power;
   int  next; /* next shot in chain */
   int  last; /* last shot in chain */
 } SHOT;
@@ -163,8 +163,8 @@
   char name[MAXNAME+1];
   char comment[MAXCOMMENT+1];
   int team;
-  long x;
-  long y;
+  int x;
+  int y;
   int winkel;
   int fitness;
   int follow;
@@ -200,8 +200,8 @@
   int x2,h2;
   int ident;
   int rclip,lclip;
-  long xd,yd;
-  long rmax,rmin;
+  int xd,yd;
+  int rmax,rmin;
   int  clipped; /* need for texture */
 } WALL;
 
@@ -290,8 +290,8 @@
   int marks;                       /* # markers */
   mapmark markers[32];             /* Map markers */
   int rndshiftpos;                 /* Random */
-  long rndshifttab[55];            /* more random-stuff */
-  volatile unsigned long drawwait; /* delay Draw .. */
+  int rndshifttab[55];            /* more random-stuff */
+  volatile unsigned int drawwait; /* delay Draw .. */
 
   /* flags */
   volatile int gameflag:1;             /* Game-is-running-flag */
diff -u netmaze-0.81+jpg0.82/x11gfx.c netmaze-0.81+jpg0.82/x11gfx.c
--- netmaze-0.81+jpg0.82/x11gfx.c
+++ netmaze-0.81+jpg0.82/x11gfx.c
@@ -47,7 +47,7 @@
 static GC mkunilogo(void);
 static GC mkcolormap(char *name,XColor*);
 static GC mkdithermap(char *bitmap,char *fg,char *bg);
-unsigned long get_best_color(XColor *col);
+unsigned int get_best_color(XColor *col);
 static int calc_pos(int num,int len);
 static int calc_fitlen(int fit,int height);
 /*
@@ -59,19 +59,19 @@
 
 /* extern: texture.c */
 extern void image_bg(int ctop,int cbottom);
-extern void image_circle(long x1,long y1,long h1,long h2,int col);
-extern void image_sym_vline(long x1,long h1,int col,int);
+extern void image_circle(int x1,int y1,int h1,int h2,int col);
+extern void image_sym_vline(int x1,int h1,int col,int);
 extern void image_hline(int x1,int y1,int x2,int val);
-extern void image_face(long x,long  r,int win,int col);
+extern void image_face(int x,int  r,int win,int col);
 extern void image_floor(int x,int y,int angle,struct texture *tx);
 extern void image_top(int ctop);
 
 extern struct texture *load_texture(char *);
 extern void make_tabs(void);
-extern void texture_wall(long x1,long h1,long x2,long h2,struct texture *tex,long,long,int,int,int);
+extern void texture_wall(int x1,int h1,int x2,int h2,struct texture *tex,int,int,int,int,int);
 
 static struct texture *textures[16];
-extern long texturemem;
+extern int texturemem;
 
 static int XErrorNewHandler(Display*,XErrorEvent*);
 static int XErrorFlag=0;
@@ -582,7 +582,7 @@
     int mx,my;
     int tx,ty;
     int dx,dy;
-    static long count=0;
+    static int count=0;
     int angle, diff;
 
     if (me && them)
@@ -631,9 +631,9 @@
   int id,i,r,r2,s;
   unsigned int width,height,x1;
   int x,y;
-  unsigned long pixel;
+  unsigned int pixel;
 #ifdef PERFORMANCE_TEST
-  long a;
+  int a;
 #endif
 
 /*
@@ -869,7 +869,7 @@
 static int calc_fitlen(int fit,int height)
 {
   int i;
-  i = (int) (( (long) fit * (long) height) / 2000) ;
+  i = (int) (( (int) fit * (int) height) / 2000) ;
   return (i<0)?0:i;
 }
 
@@ -1150,17 +1150,17 @@
  * find a good color: slow and ugly but works ... 
  */
 
-unsigned long get_best_color(XColor *col)
+unsigned int get_best_color(XColor *col)
 {
 #define MAX_COLORS 1024
 #define SHFT 12
   static unsigned char cfield[MAX_COLORS][4];
-  static unsigned long pfield[MAX_COLORS];
+  static unsigned int pfield[MAX_COLORS];
   static int outofcol=0;
   static int num=0;
   int i,best=0;
   unsigned char r,g,b;
-  long d,diff=0x7fffffff;
+  int d,diff=0x7fffffff;
 
   r=(col->red>>SHFT)&0xff; g=(col->green>>SHFT)&0xff; b=(col->blue>>SHFT)&0xff;
   
diff -u netmaze-0.81+jpg0.82/better.c netmaze-0.81+jpg0.82/better.c
--- netmaze-0.81+jpg0.82/better.c
+++ netmaze-0.81+jpg0.82/better.c
@@ -17,7 +17,7 @@
 #include "netmaze.h"
 #include "better.h"
 
-#define BIGGEST			/* groesster long-wert */
+#define BIGGEST			/* groesster int-wert */
 #define NERVOUS 50000000 	/* ab hier sucht BB sein Opfer */
 #define TODESRADIUS1 7000000
 #define TODESRADIUS 15000000   
@@ -28,7 +28,7 @@
 
 
 static int enemy_touch(PLAYER *player,PLAYER *opfer){
-  long xd,yd;
+  int xd,yd;
 
       xd = (player->x - opfer->x);
       yd = (player->y - opfer->y);
@@ -74,18 +74,18 @@
 
 
 
-/* umwandlung von quadranten nach longs und umgekehrt */
+/* umwandlung von quadranten nach ints und umgekehrt */
 
-int ltoq(long eingabe)
+int ltoq(int eingabe)
 {
 	return (int) ( (eingabe & 0xff000000) >> 24);
 }
 
-long qtol(int eingabe)
+int qtol(int eingabe)
 {
-	long ausgabe;
+	int ausgabe;
 
-	ausgabe = (long) eingabe;
+	ausgabe = (int) eingabe;
 	return (eingabe << 24);
 }
 
@@ -100,11 +100,11 @@
 sicher nicht besonders schoen, effizient oder gar korrekt ;-) aber es
 geht so einigermassen... */
 
-int k_sichtbar(long x1,long y1,long  x2,long y2)
+int k_sichtbar(int x1,int y1,int  x2,int y2)
 {
 	int x1q,y1q,x2q,y2q,xqdiff,yqdiff;
 	int x_count,y_count,vstep,hstep,hstep1,vstep1;
-	long xdiff,ydiff,xl_count,yl_count,xl_step,yl_step;
+	int xdiff,ydiff,xl_count,yl_count,xl_step,yl_step;
 	float xy,yx;
 
 	
@@ -130,7 +130,7 @@
 	{
 		x_count=x1q;
 		xl_count=x1;
-		xl_step= (hstep) * (long) (xy * 0x01000000);
+		xl_step= (hstep) * (int) (xy * 0x01000000);
 
 		for(y_count=y1q+((hstep==-1)?1:0);
 		    (hstep==-1)?(y_count<=y2q):(y_count>y2q);
@@ -152,7 +152,7 @@
 		y_count=y1q;
 		yl_count=y1;
 		
-		yl_step=-(vstep)*(long) (yx * 0x01000000);
+		yl_step=-(vstep)*(int) (yx * 0x01000000);
 
 		for(x_count=x1q+((vstep==-1)?1:0);
 		    (vstep==-1)?(x_count<=x2q):(x_count>x2q);
@@ -215,8 +215,8 @@
 
 /* gibt die koordinate des abstandes zum opfer zurueck, die groesser ist */
 
-long OpferDistanz(int opfer){
-	long	x_dist, y_dist;
+int OpferDistanz(int opfer){
+	int	x_dist, y_dist;
 	if (opfer ==  -1) return BIGGEST;
 	x_dist=labs((sm->playfeld[ownnumber].x)-(sm->playfeld[opfer].x));
 	y_dist=labs((sm->playfeld[ownnumber].y)-(sm->playfeld[opfer].y));
@@ -230,8 +230,8 @@
 /* ermittelt das naechste opfer mit hilfe von OpferDistanz() */
 
 int Opfer(){
-	long BestOpfer=-1;
-	long WeissesindenAugen=NERVOUS;
+	int BestOpfer=-1;
+	int WeissesindenAugen=NERVOUS;
 	int i;
 	if (robodat.freund == -1 ) return robodat.exfreund;
 	/* schleife ueber alle spieler */
@@ -279,10 +279,10 @@
 }
 
 
-static long deg(double x,double y){
-  long winkel;
+static int deg(double x,double y){
+  int winkel;
   if (x){ /* muss Berechnet Werden */
-    winkel =  (long)(atan(y/x)/(2.0*M_PI) * 265 );
+    winkel =  (int)(atan(y/x)/(2.0*M_PI) * 265 );
     if (winkel > 0 ){
       if (y > 0){
       }else{
@@ -305,7 +305,7 @@
   return (winkel + 128) % 256  ;
 }
 
-static long target_angle(PLAYER* them){
+static int target_angle(PLAYER* them){
     int mx,my;
     int tx,ty;
     int dx,dy;
@@ -334,9 +334,9 @@
 
 /* testen, was besser ist, rechts oder links fahren */
 void angl(int opfer){
-	long ownwinkel=sm->playfeld[ownnumber].winkel;
-	long angle = target_angle(&(sm->playfeld[opfer]));
-	long wonkel;
+	int ownwinkel=sm->playfeld[ownnumber].winkel;
+	int angle = target_angle(&(sm->playfeld[opfer]));
+	int wonkel;
 	wonkel=angle - ownwinkel;
 /*	fprintf (stderr,"\neigenwinkel %li winkel zu anderem  %li diff %li ",ownwinkel,angle,wonkel);
 */	if ((wonkel)>0){
@@ -359,8 +359,8 @@
 int own_action(void){
   static touchie=0;
   int opfer, winkel, owinkel, hwinkel, lwinkel, alt_opfer;
-  long x_dist,y_dist,nx_dist,ny_dist,lx_dist,ly_dist,hx_dist,hy_dist;
-  long i;
+  int x_dist,y_dist,nx_dist,ny_dist,lx_dist,ly_dist,hx_dist,hy_dist;
+  int i;
 
   if (!(sm->playfeld[ownnumber].alive)){ /* I'm dead , wooouueeehhhh */
     touchie=0;
@@ -409,7 +409,7 @@
 	      fprintf(stderr,"%s : the pig flees! (no touch)\n",sm->ownname);
 	    }else{
 	      /* I seem to be blocked by a wall, but see the victim ->evade a short time*/
-	      i = (long)(drand48() * 2);
+	      i = (int)(drand48() * 2);
 	      switch (i) {
 	      case 0 :
 		robodat.ret = JOY_RIGHT;
@@ -423,8 +423,8 @@
 	    };
 	  };
 	}else{
-	  /* I seem to be blocked by a wall ->evade a long time */
-	  i = (long)(drand48() * 2);
+	  /* I seem to be blocked by a wall ->evade a int time */
+	  i = (int)(drand48() * 2);
 	  switch (i) {
 	  case 0 :
 	    robodat.ret = JOY_RIGHT;
@@ -441,7 +441,7 @@
       }else
 	robodat.ausweichen--; /* count down evading */
     }else if (!robodat.jagd){ /* no victim , no evade */
-      i = (long)(drand48() * 40);
+      i = (int)(drand48() * 40);
       touchie=0;
       robodat.counter++;
       switch(i){
diff -u netmaze-0.81+jpg0.82/draw_3d.c netmaze-0.81+jpg0.82/draw_3d.c
--- netmaze-0.81+jpg0.82/draw_3d.c
+++ netmaze-0.81+jpg0.82/draw_3d.c
@@ -15,7 +15,7 @@
 
 extern struct shared_struct *sm;
 
-static int  wall_3d(long,long,long,long,int,WALL*);
+static int  wall_3d(int,int,int,int,int,WALL*);
 static void sort_walls(WALL*,int);
 static int  comp(WALL*,WALL*);
 static int  clip_walls(WALL*,int);
@@ -76,7 +76,7 @@
     if(sm->mapdraw)
       draw_rmap(sm->playfeld1,sm->maplines,sm->anzlines);
 #ifdef ALL_PERFORMANCE_TEST
-    { long a=clock();
+    { int a=clock();
 #endif
     if(!sm->texturemode)
       draw_maze(wallbuff,sm->playfeld1,anz,sm->shownumber); /* <-does XSync()*/
@@ -254,15 +254,15 @@
 
 static int calc_walls(PLAYER *players,WALL *walls,MAZE *maze,int anzahl)
 {
-  long xpos,ypos;
+  int xpos,ypos;
   int xloop,yloop,xfield,yfield,tnr;
   int xdim,ydim,xdist,ydist,istart,jstart,iend,jend;
   int winkel;
-  long xrot,yrot,x1rot,y1rot,tsin,tcos;
+  int xrot,yrot,x1rot,y1rot,tsin,tcos;
   double xdrot,ydrot,dsin,dcos /* xd1rot,yd1rot */ ;
   int i,j,p;
   int (*hwalls)[MAZEDIMENSION],(*vwalls)[MAZEDIMENSION];
-  long xd,yd,xd1;
+  int xd,yd,xd1;
   PLAYER *player;
 
   player = players+sm->shownumber;
@@ -311,14 +311,14 @@
   iend = yloop+istart;
   jend = xloop+jstart;
 
-  xdrot = (double) (xd1 = ((long)(-xdist)<<24) - (xpos & 0x00ffffff));
-  ydrot = (double) (yd  = ((long)(-ydist)<<24) - (ypos & 0x00ffffff));
+  xdrot = (double) (xd1 = ((int)(-xdist)<<24) - (xpos & 0x00ffffff));
+  ydrot = (double) (yd  = ((int)(-ydist)<<24) - (ypos & 0x00ffffff));
 /*
   xd1rot = xdrot*dcos - ydrot*dsin;
   yd1rot = ydrot*dcos + xdrot*dsin;
 */
-  x1rot = xrot = (long) ( (xdrot*dcos - ydrot*dsin) / 0x1000000 );
-  y1rot = yrot = (long) ( (ydrot*dcos + xdrot*dsin) / 0x1000000 );
+  x1rot = xrot = (int) ( (xdrot*dcos - ydrot*dsin) / 0x1000000 );
+  y1rot = yrot = (int) ( (ydrot*dcos + xdrot*dsin) / 0x1000000 );
 
   sm->marks=0;
 
@@ -410,7 +410,7 @@
 static int calc_players(int number,WALL *walls,PLAYER *players,int anz)
 {
   int i,wink;
-  long x,y,xd,yd,rmax,rmin,hor1,h1;
+  int x,y,xd,yd,rmax,rmin,hor1,h1;
   double xdrot,ydrot,dsin,dcos;
 
   x = players[number].x;
@@ -430,9 +430,9 @@
       walls[anz].xd = ((xd>0) ? xd : -xd);
       walls[anz].yd = ((yd>0) ? yd : -yd);
 
-      if( (yd = (long) ((ydrot*dcos + xdrot*dsin) / 0x1000000) >>16) > 0)
+      if( (yd = (int) ((ydrot*dcos + xdrot*dsin) / 0x1000000) >>16) > 0)
       {
-        xd = (long) ((xdrot*dcos - ydrot*dsin) / 0x1000000) >>16;
+        xd = (int) ((xdrot*dcos - ydrot*dsin) / 0x1000000) >>16;
 
         if(xd > 0)
         {
@@ -470,7 +470,7 @@
 static int calc_shoots(int number,WALL *walls,PLAYER *players,int anz)
 {
   int i,j,wink;
-  long x,y,xd,yd,rmax,rmin,h1;
+  int x,y,xd,yd,rmax,rmin,h1;
   double xdrot,ydrot,dsin,dcos;
 
   x = players[number].x;
@@ -489,9 +489,9 @@
       walls[anz].xd = ((xd>0) ? xd : -xd);
       walls[anz].yd = ((yd>0) ? yd : -yd);
 
-      if( (yd = (long) ((ydrot*dcos + xdrot*dsin) / 0x1000000) >>16) > 0)
+      if( (yd = (int) ((ydrot*dcos + xdrot*dsin) / 0x1000000) >>16) > 0)
       {
-        if( (xd = (long) ((xdrot*dcos - ydrot*dsin) / 0x1000000) >> 16) > 0)
+        if( (xd = (int) ((xdrot*dcos - ydrot*dsin) / 0x1000000) >> 16) > 0)
         {
           rmax = ((xd+PRADIUS)*(xd+PRADIUS) + (yd+PRADIUS)*(yd+PRADIUS))<<2;
           rmin = ((xd-PRADIUS)*(xd-PRADIUS) + (yd-PRADIUS)*(yd-PRADIUS))<<2;
@@ -521,9 +521,9 @@
   return anz;
 }
 
-static int wall_3d(long x1,long y1,long x2,long y2,int ident,WALL *wall)
+static int wall_3d(int x1,int y1,int x2,int y2,int ident,WALL *wall)
 {
-  long rmax,rmin,x,r,h1,h2;
+  int rmax,rmin,x,r,h1,h2;
 
   x1 >>= 16; x2 >>= 16; y1 >>= 16; y2 >>= 16;
 
@@ -635,7 +635,7 @@
 
 static int stest(WALL *w1,WALL *w2)
 {
-  long d;
+  int d;
   int xr1,xl1,xr2,xl2;
 
   if(w1->ident < 0x100)
diff -u netmaze-0.81+jpg0.82/robot.c netmaze-0.81+jpg0.82/robot.c
--- netmaze-0.81+jpg0.82/robot.c
+++ netmaze-0.81+jpg0.82/robot.c
@@ -36,7 +36,7 @@
 /* extern: allmove.c */
 extern void move_all(PLAYER*,int*);
 extern void run_game(MAZE*,PLAYER*);
-extern void myrandominit(long);
+extern void myrandominit(int);
 
 /* extern: user-defined-functions */
 extern int own_action(void);
diff -u netmaze-0.81+jpg0.82/netserv.c netmaze-0.81+jpg0.82/netserv.c
--- netmaze-0.81+jpg0.82/netserv.c
+++ netmaze-0.81+jpg0.82/netserv.c
@@ -47,8 +47,8 @@
 struct cqueue *cfirst;
 struct gqueue *gfirst;
 
-volatile unsigned long timerticks=0;
-unsigned long lasttick=0,starttick=0;
+volatile unsigned int timerticks=0;
+unsigned int lasttick=0,starttick=0;
 
 int acc_socket;
 int menu_in=0,menu_out=1,use_exmenu=FALSE;
@@ -79,7 +79,7 @@
 
 void usage(void);
 void print_menu(void);
-void print_timerinfo(unsigned long);
+void print_timerinfo(unsigned int);
 void list_connections(void);
 
 void handle_input(void);
@@ -830,8 +830,8 @@
 {
   struct gqueue *g;
   struct pqueue *p;
-  unsigned long t;
-  static unsigned long lasttick;
+  unsigned int t;
+  static unsigned int lasttick;
   int d;
 
   t = timerticks;
@@ -1138,7 +1138,7 @@
 
 void work_input(unsigned char *buf,int len,struct cqueue *q)
 {
-  unsigned long lval;
+  unsigned int lval;
   struct pqueue *pl;
   int cn;
 
@@ -1222,10 +1222,10 @@
         if(!(q->mode & (SINGLEPLAYER)) )
         {
           lval = 0;
-          lval |= ((unsigned long) buf[1]) << 24;
-          lval |= ((unsigned long) buf[2]) << 16;
-          lval |= ((unsigned long) buf[3]) << 8;
-          lval |= ((unsigned long) buf[4]);
+          lval |= ((unsigned int) buf[1]) << 24;
+          lval |= ((unsigned int) buf[2]) << 16;
+          lval |= ((unsigned int) buf[3]) << 8;
+          lval |= ((unsigned int) buf[4]);
 
           switch(lval)
           {
@@ -1960,7 +1960,7 @@
   exit(0);
 }
 
-void print_timerinfo(unsigned long t)
+void print_timerinfo(unsigned int t)
 {
   switch(t & 0x3f)
   {
diff -u netmaze-0.81+jpg0.82/audio.c netmaze-0.81+jpg0.82/audio.c
--- netmaze-0.81+jpg0.82/audio.c
+++ netmaze-0.81+jpg0.82/audio.c
@@ -55,8 +55,8 @@
 
 struct sample 
 {
-  long start;
-  long len;
+  int start;
+  int len;
   char name[20];
 };
 
@@ -184,7 +184,7 @@
   FILE *fd;
   unsigned char junk[8];
   int  i,j,a,delay;
-  long blen,pos;
+  int blen,pos;
   unsigned char c;
 
   delay = play_delay;
@@ -210,10 +210,10 @@
   for(i=0;i<len;i++)
   {
     fread(junk,1,8,fd);
-    sinfo[i].start = ((long)junk[0]<<24)+((long)junk[1]<<16)
-                     +((long)junk[2]<<8)+((long)junk[3]);
-    sinfo[i].len = ((long)junk[4]<<24)+((long)junk[5]<<16)
-                     +((long)junk[6]<<8)+((long)junk[7]);
+    sinfo[i].start = ((int)junk[0]<<24)+((int)junk[1]<<16)
+                     +((int)junk[2]<<8)+((int)junk[3]);
+    sinfo[i].len = ((int)junk[4]<<24)+((int)junk[5]<<16)
+                     +((int)junk[6]<<8)+((int)junk[7]);
     fread(sinfo[i].name,1,16,fd);
   }
 
diff -u netmaze-0.81+jpg0.82/debian/changelog netmaze-0.81+jpg0.82/debian/changelog
--- netmaze-0.81+jpg0.82/debian/changelog
+++ netmaze-0.81+jpg0.82/debian/changelog
@@ -1,3 +1,10 @@
+netmaze (0.81+jpg0.82-12.1) unstable; urgency=low
+
+  * Non-maintainer upload.
+  * Change long to int to handle 64bit compiles (Closes: #502657).
+
+ -- Kees Cook <[EMAIL PROTECTED]>  Sun, 26 Oct 2008 09:33:01 -0700
+
 netmaze (0.81+jpg0.82-12) unstable; urgency=low
 
   * Ack NMU.  Closes: #346967.
only in patch2:
unchanged:
--- netmaze-0.81+jpg0.82.orig/trigtab.h
+++ netmaze-0.81+jpg0.82/trigtab.h
@@ -2,7 +2,7 @@
  * sin/cos tab (DON'T CHANGE!!)
  */
 
-long trigtab[] = {
+int trigtab[] = {
 0x00000000,0x00064855,0x000c8fb2,0x0012d520,
 0x001917a6,0x001f564e,0x00259020,0x002bc428,
 0x0031f170,0x00381704,0x003e33f2,0x00444749,
only in patch2:
unchanged:
--- netmaze-0.81+jpg0.82.orig/netmaze.c
+++ netmaze-0.81+jpg0.82/netmaze.c
@@ -113,7 +113,7 @@
         sm->sologame = FALSE;
         if(strlen(argv[i]) > 255)
         {
-          fprintf(stderr,"Hostname too long!!\n");
+          fprintf(stderr,"Hostname too int!!\n");
           exit(1);
         }
         strcpy(sm->hostname,argv[i]);
@@ -128,7 +128,7 @@
         i++;
         if(strlen(argv[i]) >= MAXNAME)
         {
-          fprintf(stderr,"Name too long. Maximum is %d character.\n",MAXNAME-1);
+          fprintf(stderr,"Name too int. Maximum is %d character.\n",MAXNAME-1);
           exit(1);
         }
         strcpy(sm->ownname,argv[i]);
@@ -169,7 +169,7 @@
         i++;
         if(strlen(argv[i]) >= MAXCOMMENT)
         {
-          fprintf(stderr,"Comment too long. Maximum is %d character.\n",MAXCOMMENT-1);
+          fprintf(stderr,"Comment too int. Maximum is %d character.\n",MAXCOMMENT-1);
           exit(1);
         }
         strcpy(sm->owncomment,argv[i]);
@@ -507,7 +507,7 @@
   if((s=getenv("NETMAZE_NAME"))!=NULL)
   {
     if(strlen(s) > 15)
-      fprintf(stderr,"NETMAZE_NAME too long!\n");
+      fprintf(stderr,"NETMAZE_NAME too int!\n");
     else
       strcpy(sm->ownname,s);
   }
@@ -516,7 +516,7 @@
   if((s=getenv("NETMAZE_COMMENT"))!=NULL)
   {
     if(strlen(s) > 31)
-      fprintf(stderr,"NETMAZE_COMMENT too long!\n");
+      fprintf(stderr,"NETMAZE_COMMENT too int!\n");
     else
       strcpy(sm->owncomment,s);
   }
only in patch2:
unchanged:
--- netmaze-0.81+jpg0.82.orig/network.c
+++ netmaze-0.81+jpg0.82/network.c
@@ -29,7 +29,7 @@
 
 extern void move_all(PLAYER*,int*);
 extern void run_game(MAZE*,PLAYER*);
-extern void myrandominit(long);
+extern void myrandominit(int);
 extern void inactivate_player(int);
 extern void activate_player(int);
 
@@ -60,7 +60,7 @@
   static int frag=0,fraglen;
 
       if(frag > 0)
-      { /* we allow exact 1 fragmentation (our messages aren't long) */
+      { /* we allow exact 1 fragmentation (our messages aren't int) */
         if((count = recv(own_socket,buf+fraglen,frag,0)) != frag)
 	{
 	  fprintf(stderr,"Major protocoll-error: %d!!\n",buf[0]);
@@ -131,7 +131,7 @@
   char data[1];
   int (*hfeld)[MAZEDIMENSION],(*vfeld)[MAZEDIMENSION];
   int i,j;
-  long randbase;
+  int randbase;
 
   switch(*buf)
   {
@@ -143,8 +143,8 @@
         {
           sm->playfeld[i].team = buf[16+i];
         }
-        randbase = (long) (unsigned char) buf[5];
-        randbase += ((long) (unsigned char) buf[4]) << 8;
+        randbase = (int) (unsigned char) buf[5];
+        randbase += ((int) (unsigned char) buf[4]) << 8;
         myrandominit(randbase);
         sm->gamemode = (unsigned char) buf[7];
         sm->gamemode += ((int)(unsigned char)buf[8])<<8;
only in patch2:
unchanged:
--- netmaze-0.81+jpg0.82.orig/network.h
+++ netmaze-0.81+jpg0.82/network.h
@@ -15,19 +15,19 @@
 #define PLAYERMAGIC 0x77554712L
 
 /*
-void pushlong(char *s,long w)
+void pushint(char *s,int w)
 {
-  s[0] = ((unsigned long) w)>>24;
-  s[1] = ((unsigned long) w)>>16;
-  s[2] = ((unsigned long) w)>>8;
-  s[3] = ((unsigned long) w);
+  s[0] = ((unsigned int) w)>>24;
+  s[1] = ((unsigned int) w)>>16;
+  s[2] = ((unsigned int) w)>>8;
+  s[3] = ((unsigned int) w);
 }
 
-long poplong(char *s)
+int popint(char *s)
 {
-  w = ((unsigend long) s[0]<<24) + ((unsigend long) s[1]<<16) +
-      ((unsigend long) s[2]<<8) + ((unsigend long) s[3])
-  return((long) w);
+  w = ((unsigend int) s[0]<<24) + ((unsigend int) s[1]<<16) +
+      ((unsigend int) s[2]<<8) + ((unsigend int) s[3])
+  return((int) w);
 
 }
 */
only in patch2:
unchanged:
--- netmaze-0.81+jpg0.82.orig/x11smiley.c
+++ netmaze-0.81+jpg0.82/x11smiley.c
@@ -140,7 +140,7 @@
 
 }
 
-void image_face(long x,long r,int win,int col)
+void image_face(int x,int r,int win,int col)
 {
   int j,k,k1,y;
   double scale,scale1,jmp=0.5;
only in patch2:
unchanged:
--- netmaze-0.81+jpg0.82.orig/netserv.h
+++ netmaze-0.81+jpg0.82/netserv.h
@@ -47,7 +47,7 @@
   int plnum; /* number of players from this connection */
   int mode; /* flags */
   int socket;
-  unsigned long lasttick;
+  unsigned int lasttick;
   struct sockaddr remoteaddr;  /* remote socket address */
   char hostname[256];
   int response;
only in patch2:
unchanged:
--- netmaze-0.81+jpg0.82.orig/better.h
+++ netmaze-0.81+jpg0.82/better.h
@@ -4,8 +4,8 @@
 typedef struct { int ret;
                 richtung zustand;
                 int counter;
-                long oldx;
-                long oldy;
+                int oldx;
+                int oldy;
                 int ausweichen;
                 int jagd;
                 int freund;
only in patch2:
unchanged:
--- netmaze-0.81+jpg0.82.orig/texture.c
+++ netmaze-0.81+jpg0.82/texture.c
@@ -13,19 +13,19 @@
 static char *make_jump_tab(int h);
 struct texture *load_texture(char *name);
 void image_hline(int x1,int y1,int x2,int val);
-void image_circle(long x1,long y1,long h1,long h2,int);
+void image_circle(int x1,int y1,int h1,int h2,int);
 
-extern unsigned long get_best_color(XColor *col);
+extern unsigned int get_best_color(XColor *col);
 
 extern struct shared_struct *sm;
 /*
 static unsigned char *sqrttab;
 */
 static double *circletab;
-static long *floortab;
-long texturemem;
+static int *floortab;
+int texturemem;
 extern struct texture *vtex;
-extern long trigtab[];
+extern int trigtab[];
 
 /*
  * Draw a texture-wall.. really not fast
@@ -35,11 +35,11 @@
  * type: 0=full, !0=mirrored
  */
 
-void texture_wall(long x1,long hn1,long x2,long hn2,struct texture *tex,long lclip,long rclip,int size,int clipped,int type)
+void texture_wall(int x1,int hn1,int x2,int hn2,struct texture *tex,int lclip,int rclip,int size,int clipped,int type)
 {
   int j,xp,hi,k,ln,d,i1,istep;
   char *jmpt,*imgbuf,*t1,*t2;
-  long h,xn1,yn1;
+  int h,xn1,yn1;
   char *ia1,*ia2,pixval1,pixval2;
   int shift=size-4,offset=0;
 
@@ -181,8 +181,8 @@
 
 static char *make_jump_tab(int h)
 {
-  long d;
-  long d1;
+  int d;
+  int d1;
   int i,j,h1,shft;
   char *t1,*t;
   static char *jmptabsave[32] = { NULL, };
@@ -225,7 +225,7 @@
 static char *make_div_tab(int h)
 {
   int i,h1,shft;
-  long h2;
+  int h2;
   char *t;
   static char *divtabsave[32] = { NULL, };
   short (*t1)[2];
@@ -255,11 +255,11 @@
   h2=WYHALF*h;
   for(i=WYHALF;i<4096;i++)
   {
-    long w;
+    int w;
     w = h2 / i;
     t1[i][0] = w;
-    w = ((long)i<<16) / h;
-    w *= (long) t1[i][0];
+    w = ((int)i<<16) / h;
+    w *= (int) t1[i][0];
     w += 0x7fff;
     t1[i][1] = WYHALF - (w>>16);
   }
@@ -270,7 +270,7 @@
 void make_tabs(void)
 {
   int i,j;
-  long *fltab;
+  int *fltab;
   double m[] = { 0,0,0,0,0,0,0,0,0,0,0, 0.5 , 1.0 , 2.0 , 4.0 , 8.0 };
 
 /*
@@ -290,7 +290,7 @@
     circletab[i] = sqrt(1 - ((double) i)*((double) i)/(512*512));
   }
 
-  fltab = floortab = (long *) malloc(sizeof(long)*4*(WYSIZE>>1)*128);
+  fltab = floortab = (int *) malloc(sizeof(int)*4*(WYSIZE>>1)*128);
   if(floortab == NULL)
   {
     fprintf(stderr,"No memory for floortab.\n");
@@ -323,10 +323,10 @@
       xo = d1cos*(XMIN) - ydrot*dsin;
       yo = ydrot*dcos + d1sin*(XMIN);
 
-      *fltab++ = (long) (xo*0x10);
-      *fltab++ = (long) (yo*0x10);
-      *fltab++ = (long) (d1sin*0x10000*m[sm->outputsize]);
-      *fltab++ = (long) (d1cos*0x10000*m[sm->outputsize]);
+      *fltab++ = (int) (xo*0x10);
+      *fltab++ = (int) (yo*0x10);
+      *fltab++ = (int) (d1sin*0x10000*m[sm->outputsize]);
+      *fltab++ = (int) (d1cos*0x10000*m[sm->outputsize]);
     }
   }
 }
@@ -337,7 +337,7 @@
   int i,j,k,precalc=0,h,w;
   FILE *f;
   char *b,*t,*t1;
-  long d,d1;
+  int d,d1;
   unsigned char buf[32];
   int map[256];
   char fn[1024];
@@ -394,11 +394,11 @@
   {
     tex->datatab = malloc( sizeof(char *) * (h+1) );
     texturemem += (h>>1)*w*h+((w*h)>>1)+4;
-    tex->data = (char *) (((long) malloc((h>>1)*w*h+((w*h)>>1)+4) + 3) & 0xfffffffc);
+    tex->data = (char *) (((int) malloc((h>>1)*w*h+((w*h)>>1)+4) + 3) & 0xfffffffc);
   }
   else
   {
-    tex->data = (char *) (((long) malloc(w*h+4) + 3) & 0xfffffffc);
+    tex->data = (char *) (((int) malloc(w*h+4) + 3) & 0xfffffffc);
     texturemem += w*h+4;
   }
   if( (tex->data == NULL) || (precalc && (tex->datatab == NULL)) )
@@ -485,11 +485,11 @@
   return tex;
 }
 
-void image_circle(long x1,long y1,long h1,long h2,int col)
+void image_circle(int x1,int y1,int h1,int h2,int col)
 {
   int i,j,k,xi1,xi2;
-  long d;
-  long d1=0x7fff;
+  int d;
+  int d1=0x7fff;
   int r;
   int lclip,rclip,xmid;
 
@@ -535,9 +535,9 @@
 {
   char *image = sm->grafix.imagebuf + (IMAGEHEIGHT>>1)*IMAGEWIDTH + ((IMAGEWIDTH-WXSIZE)>>1);
   char *t = tx->data;
-  long *fltab;
+  int *fltab;
   int i,j;
-  long mask = 0x00ff0000;
+  int mask = 0x00ff0000;
   int step=IMAGEWIDTH-WXSIZE;
 
   switch(angle & 0x80)
@@ -547,7 +547,7 @@
 
       for(j=(WYSIZE>>1);j;j--,image+=step)
       {
-        long xo,yo,tsin,tcos;
+        int xo,yo,tsin,tcos;
         xo   = x + *fltab++;
         yo   = y + *fltab++;
         tsin = *fltab++;
@@ -568,7 +568,7 @@
 
       for(j=(WYSIZE>>1);j;j--,image+=step)
       {
-        long xo,yo,tsin,tcos;
+        int xo,yo,tsin,tcos;
         xo   = x - *fltab++;
         yo   = y - *fltab++;
         tsin = - *fltab++;
@@ -587,10 +587,10 @@
 {
   int i,j,k;
 
-  unsigned long *ia1;
-  unsigned long val1=c1 +((long) c1<<8) +((long) c1<<16) +((long) c1<<24);
+  unsigned int *ia1;
+  unsigned int val1=c1 +((int) c1<<8) +((int) c1<<16) +((int) c1<<24);
 
-  ia1 = (unsigned long *) (sm->grafix.imagebuf + 
+  ia1 = (unsigned int *) (sm->grafix.imagebuf + 
                        ((IMAGEWIDTH-WXSIZE)>>1) + (IMAGEHEIGHT>>1)*IMAGEWIDTH);
   k = WXSIZE>>2;
 
@@ -606,11 +606,11 @@
 {
   int i,j,k;
 
-  unsigned long *ia1,*ia2;
-  unsigned long val1=c1 +((long) c1<<8) +((long) c1<<16) +((long) c1<<24);
-  unsigned long val2=c2 +((long) c2<<8) +((long) c2<<16) +((long) c2<<24);
+  unsigned int *ia1,*ia2;
+  unsigned int val1=c1 +((int) c1<<8) +((int) c1<<16) +((int) c1<<24);
+  unsigned int val2=c2 +((int) c2<<8) +((int) c2<<16) +((int) c2<<24);
 
-  ia1 = ia2 = (unsigned long *) (sm->grafix.imagebuf + 
+  ia1 = ia2 = (unsigned int *) (sm->grafix.imagebuf + 
                        ((IMAGEWIDTH-WXSIZE)>>1) + (IMAGEHEIGHT>>1)*IMAGEWIDTH);
   k = WXSIZE>>2;
 
@@ -630,7 +630,7 @@
 {
   char *img = sm->grafix.imagebuf + y1*IMAGEWIDTH + x1;
   int d1,d2,d3;
-  unsigned long val1;
+  unsigned int val1;
 
   if(x2 < x1)
   {
@@ -646,7 +646,7 @@
   }
   else
   {
-    val1=val +((long) val<<8) +((long) val<<16) +((long) val<<24);
+    val1=val +((int) val<<8) +((int) val<<16) +((int) val<<24);
     d1=4-(x1 & 0x3);
     d2=x2 & 0x3;
     d3=(x2-d2-x1-d1)>>2;
@@ -659,8 +659,8 @@
       *img++ = val;
     for(;d3;d3--)
     { 
-         /* *(((unsigned long*)img)++) = val1; */
-      *(((unsigned long*)img)) = val1;
+         /* *(((unsigned int*)img)++) = val1; */
+      *(((unsigned int*)img)) = val1;
       img+=4;
     }
     for(;d2;d2--)
@@ -668,7 +668,7 @@
   }
 }
 
-void image_sym_vline(long x1,long h1,int col,int size)
+void image_sym_vline(int x1,int h1,int col,int size)
 {
   char *ia1,*ia2;
 

Reply via email to