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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
--- Makefile.orig 2003-01-01 23:36:19.000000000 -0500
+++ Makefile 2003-01-01 23:39:32.000000000 -0500
@@ -1,8 +1,9 @@
CFLAGS=-g
+LDFLAGS=
PROGRAMS=combat
ROBOTS=cylon tracker target
-CC=g++ -g
+CC=g++
all: $(PROGRAMS) $(ROBOTS)
@@ -10,29 +11,29 @@
rm -f $(PROGRAMS) $(ROBOTS) *.o core
combat: combat.o
- $(CC) $(CFLAGS) -o $@ combat.o -lm
+ $(CC) -o $@ $(LDFLAGS) combat.o -lm
combat.o: combat.c
$(CC) $(CFLAGS) -c combat.c
robots.o: robots.C robots.h
- g++ -c robots.C
+ $(CC) $(CFLAGS) -c robots.C
cylon: cylon.o robots.o
- g++ -static -o $@ cylon.o robots.o
+ $(CC) -o $@ $(LDFLAGS) cylon.o robots.o
cylon.o: cylon.c robots.h
- g++ -c cylon.c
+ $(CC) $(CFLAGS) -c cylon.c
tracker: tracker.o robots.o
- g++ -static -o $@ tracker.o robots.o
+ $(CC) -o $@ $(LDFLAGS) tracker.o robots.o
tracker.o: tracker.c robots.h
- g++ -c tracker.c
+ $(CC) $(CFLAGS) -c tracker.c
target: target.o robots.o
- g++ -static -o $@ target.o robots.o
+ $(CC) -o $@ $(LDFLAGS) target.o robots.o
target.o: target.c robots.h
- g++ -c target.c
+ $(CC) $(CFLAGS) -c target.c
--- combat.c.orig 2003-01-01 23:32:55.000000000 -0500
+++ combat.c 2003-01-01 23:34:06.000000000 -0500
@@ -29,6 +29,7 @@
#include <signal.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
@@ -96,7 +97,7 @@
Robot *robots=NULL;
int nrobots=0;
-plot(int x, int y, char c)
+void plot(int x, int y, char c)
{
int h = int(x)*79/10000;
int v = 34-int(y)*(31-nrobots)/10000;
@@ -472,7 +473,7 @@
}
-Between(double x1, double y1, double x2, double y2, double x0, double y0)
+int Between(double x1, double y1, double x2, double y2, double x0, double y0)
{
double tx,ty;
/* is (x0,y0) between (x1,y1) - (x2,y2)? */
--- cylon.c.orig 2003-01-01 23:32:49.000000000 -0500
+++ cylon.c 2003-01-01 23:40:13.000000000 -0500
@@ -1,6 +1,6 @@
#include "robots.h"
-Distance(int x1, int y1, int x2, int y2)
+int Distance(int x1, int y1, int x2, int y2)
{
int dx = x1-x2;
int dy = y1-y2;
@@ -8,7 +8,7 @@
return sqrt(dx*dx + dy*dy);
}
-Goto(int x, int y)
+void Goto(int x, int y)
{
int dir = atan2(y-loc_y(),x-loc_x());
int dist = Distance(x,y,loc_x(),loc_y());
@@ -37,8 +37,9 @@
drive(dir,0);
}
-main()
+int main()
{
while (1)
Goto(rand(9000)+500,rand(9000)+500);
+ return 0;
}
--- robots.C.orig 2003-01-01 23:34:39.000000000 -0500
+++ robots.C 2003-01-01 23:35:18.000000000 -0500
@@ -6,6 +6,7 @@
#include <time.h>
#include <sys/types.h>
#include <unistd.h>
+#include <string.h>
#include "robots.h"
--- tracker.c.orig 2003-01-01 23:35:27.000000000 -0500
+++ tracker.c 2003-01-01 23:35:46.000000000 -0500
@@ -18,7 +18,7 @@
// Shoot at a target if its in range (<= 7000 units) *and* its far
// enough away that we will only be slightly damaged (>200 units) by the
// resulting explosion.
-inline shoot(int dir,int range)
+void inline shoot(int dir,int range)
{
if (range <= 7000 && range > 200) {
printlog("cannon(%d,%d)",dir,range);
@@ -26,7 +26,7 @@
}
}
-main()
+int main()
{
int sdir=0; /* current scan direction */
int dir=0; /* current movement direction */
@@ -74,4 +74,6 @@
else
sdir -= 20; /* increment the scan */
}
+
+ return 0;
}
|