summaryrefslogtreecommitdiff
path: root/games/xworm/patches/patch-ab
blob: 4aca8c66c6d132ca896604decde538a206afeb20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
$NetBSD: patch-ab,v 1.2 2005/12/29 20:27:14 joerg Exp $

--- xworm.c.orig	1997-05-07 16:25:57.000000000 +0000
+++ xworm.c
@@ -3,13 +3,20 @@
  
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
+#include <sys/time.h>
+#endif
 #include <time.h>
 #include <string.h>
 #include <stdio.h>
 
-#define gridfile "xworm.grid"
-#define fontfile "xworm.font"
-#define logofile "xworm.raw"
+#ifndef PREFIX
+#define PREFIX "."
+#endif
+
+#define gridfile PREFIX "/xworm.grid"
+#define fontfile PREFIX "/xworm.font"
+#define logofile PREFIX "/xworm.raw"
 
 #define maxQ 5000    /* max queue */
 #define NCOLORS 15   /* number of colours */
@@ -551,16 +558,24 @@ void AllocColours(void){
  colormap = DefaultColormap(display, screen);
   if (!XAllocColorCells(display, colormap, True, NULL, 0, pixels, npixels)) {
     fprintf(stderr, "failed to allocate all %d colours\n", NCOLORS);
-    exit(1);
-  }
-  for (i = 0; i < NCOLORS; i++) { /* Initialize RGB values ... */
-    color_tab[i].pixel = pixels[i];
-    color_tab[i].red   = rgb_tab[i].r;
-    color_tab[i].green = rgb_tab[i].g;
-    color_tab[i].blue  = rgb_tab[i].b;
-    color_tab[i].flags = DoRed | DoGreen | DoBlue;
+    for (i = 0; i < NCOLORS; i++) { /* Initialize RGB values ... */
+      color_tab[i].pixel = pixels[i];
+      color_tab[i].red   = rgb_tab[i].r;
+      color_tab[i].green = rgb_tab[i].g;
+      color_tab[i].blue  = rgb_tab[i].b;
+      color_tab[i].flags = DoRed | DoGreen | DoBlue;
+      XAllocColor(display, colormap, &color_tab[i]);
+    }
+  } else {
+    for (i = 0; i < NCOLORS; i++) { /* Initialize RGB values ... */
+      color_tab[i].pixel = pixels[i];
+      color_tab[i].red   = rgb_tab[i].r;
+      color_tab[i].green = rgb_tab[i].g;
+      color_tab[i].blue  = rgb_tab[i].b;
+      color_tab[i].flags = DoRed | DoGreen | DoBlue;
+    }
+    XStoreColors(display, colormap, color_tab, npixels);
   }
-  XStoreColors(display, colormap, color_tab, npixels);
 }
 
 Bool predproc (display,event,arg)
@@ -773,7 +788,7 @@ float rnd(int x) { /* This routine retur
 void rgrid(void){
  FILE *fpg;
  if ((fpg=fopen(gridfile,"rb")) == NULL) {
-  printf("Error opening file /users/paalde/bin/xworm.grid. unrecoverable \n");
+  printf("Error opening file %s/xworm.grid. unrecoverable \n", PREFIX);
   exit (0);
  }
  for (i=1;i<maxGrid;i++) {