Skip to content

Commit a5f7546

Browse files
jwisejwise
jwise
authored and
jwise
committed
Normalize signature of ship handling functions -- struct ship * from and
struct ship * to are now always the first two args.
1 parent 650239a commit a5f7546

File tree

8 files changed

+54
-54
lines changed

8 files changed

+54
-54
lines changed

games/sail/assorted.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: assorted.c,v 1.12 2001/01/04 03:21:16 jwise Exp $ */
1+
/* $NetBSD: assorted.c,v 1.13 2001/01/04 06:16:51 jwise Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,20 +38,20 @@
3838
#if 0
3939
static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95";
4040
#else
41-
__RCSID("$NetBSD: assorted.c,v 1.12 2001/01/04 03:21:16 jwise Exp $");
41+
__RCSID("$NetBSD: assorted.c,v 1.13 2001/01/04 06:16:51 jwise Exp $");
4242
#endif
4343
#endif /* not lint */
4444

4545
#include <stdlib.h>
4646
#include <err.h>
4747
#include "extern.h"
4848

49-
void table(int, int, int, struct ship *, struct ship *, int);
49+
void table(struct ship *, struct ship *, int, int, int, int);
5050
void Cleansnag(struct ship *, struct ship *, int, int);
51-
static void strike (struct ship *, struct ship *);
51+
static void strike (struct ship *, struct ship *);
5252

5353
void
54-
table(int rig, int shot, int hittable, struct ship *on, struct ship *from, int roll)
54+
table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int roll)
5555
{
5656
int hhits = 0, chits = 0, ghits = 0, rhits = 0;
5757
int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0;

games/sail/dr_1.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_1.c,v 1.16 2001/01/04 05:34:56 jwise Exp $ */
1+
/* $NetBSD: dr_1.c,v 1.17 2001/01/04 06:16:51 jwise Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: dr_1.c,v 1.16 2001/01/04 05:34:56 jwise Exp $");
41+
__RCSID("$NetBSD: dr_1.c,v 1.17 2001/01/04 06:16:51 jwise Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -196,8 +196,8 @@ fightitout(struct ship *from, struct ship *to, int key)
196196
}
197197
if (fromstrength >= strengthto * 3 || count == 4) {
198198
unboard(to, from, 0);
199-
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
200-
subtract(to, totalto, crewto, tocap, pcto);
199+
subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
200+
subtract(to, tocap, totalto, crewto, pcto);
201201
makemsg(from, "boarders from %s repelled", to->shipname);
202202
sprintf(message, "killed in melee: %d. %s: %d",
203203
totalto, from->shipname, totalfrom);
@@ -206,8 +206,8 @@ fightitout(struct ship *from, struct ship *to, int key)
206206
return 1;
207207
} else if (strengthto >= fromstrength * 3) {
208208
unboard(from, to, 0);
209-
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
210-
subtract(to, totalto, crewto, tocap, pcto);
209+
subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
210+
subtract(to, tocap, totalto, crewto, pcto);
211211
if (key) {
212212
if (fromcap != from)
213213
Write(W_POINTS, fromcap,
@@ -228,8 +228,8 @@ fightitout(struct ship *from, struct ship *to, int key)
228228
Write(W_POINTS, to, topoints, 0, 0, 0);
229229
mento = crewto[0] ? crewto[0] : crewto[1];
230230
if (mento) {
231-
subtract(to, mento, crewto, tocap, pcto);
232-
subtract(from, - mento, crewfrom, to, 0);
231+
subtract(to, tocap, mento, crewto, pcto);
232+
subtract(from, to, - mento, crewfrom, 0);
233233
}
234234
sprintf(message, "captured by the %s!", to->shipname);
235235
Writestr(W_SIGNAL, from, message);
@@ -400,7 +400,7 @@ compcombat(void)
400400
if (hit >= 0) {
401401
if (load != L_GRAPE)
402402
hit = hit > 10 ? 10 : hit;
403-
table(shootat, load, hit, closest, sp, dieroll());
403+
table(sp, closest, shootat, load, hit, dieroll());
404404
}
405405
}
406406
}

games/sail/dr_2.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_2.c,v 1.16 2001/01/04 03:51:23 jwise Exp $ */
1+
/* $NetBSD: dr_2.c,v 1.17 2001/01/04 06:16:51 jwise Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: dr_2.c,v 1.16 2001/01/04 03:51:23 jwise Exp $");
41+
__RCSID("$NetBSD: dr_2.c,v 1.17 2001/01/04 06:16:51 jwise Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -55,9 +55,9 @@ void checkup(void);
5555
void prizecheck(void);
5656
static int str_end(const char *);
5757
void closeon(struct ship *, struct ship *, char *, int, int, int);
58-
static int score(char *, struct ship *, struct ship *, int);
59-
static void move_ship(const char *, struct ship *, unsigned char *, short *, short *, char *);
60-
static void try(char *, char *, int, int, int, int, int, struct ship *, struct ship *, int *, int);
58+
static int score(struct ship *, struct ship *, char *, int);
59+
static void move_ship(struct ship *, const char *, unsigned char *, short *, short *, char *);
60+
static void try(struct ship *, struct ship *, char *, char *, int, int, int, int, int, int *, int);
6161
static void rmend(char *);
6262

6363
const int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */
@@ -117,7 +117,7 @@ checkup(void)
117117
makemsg(sp, "exploding!");
118118
foreachship(sq) {
119119
if (sp != sq && sq->file->dir && range(sp, sq) < 4)
120-
table(RIGGING, L_EXPLODE, sp->specs->guns/13, sq, sp, 6);
120+
table(sp, sq, RIGGING, L_EXPLODE, sp->specs->guns/13, 6);
121121
}
122122
} else
123123
makemsg(sp, "sinking!");
@@ -160,11 +160,11 @@ closeon(struct ship *from, struct ship *to, char *command, int ta, int ma, int a
160160

161161
temp[0] = command[0] = '\0';
162162
high = -30000;
163-
try(command, temp, ma, ta, af, ma, from->file->dir, from, to, &high, 0);
163+
try(from, to, command, temp, ma, ta, af, ma, from->file->dir, &high, 0);
164164
}
165165

166166
static int
167-
score(char *movement, struct ship *ship, struct ship *to, int onlytemp)
167+
score(struct ship *ship, struct ship *to, char *movement, int onlytemp)
168168
{
169169
char drift;
170170
int row, col, dir, total, ran;
@@ -175,7 +175,7 @@ score(char *movement, struct ship *ship, struct ship *to, int onlytemp)
175175
row = fp->row;
176176
col = fp->col;
177177
drift = fp->drift;
178-
move_ship(movement, ship, &fp->dir, &fp->row, &fp->col, &drift);
178+
move_ship(ship, movement, &fp->dir, &fp->row, &fp->col, &drift);
179179
if (!*movement)
180180
strcpy(movement, "d");
181181

@@ -195,7 +195,7 @@ score(char *movement, struct ship *ship, struct ship *to, int onlytemp)
195195
}
196196

197197
static void
198-
move_ship(const char *p, struct ship *ship, unsigned char *dir, short *row, short *col, char *drift)
198+
move_ship(struct ship *ship, const char *p, unsigned char *dir, short *row, short *col, char *drift)
199199
{
200200
int dist;
201201
char moved = 0;
@@ -235,7 +235,7 @@ move_ship(const char *p, struct ship *ship, unsigned char *dir, short *row, shor
235235
}
236236

237237
static void
238-
try(char *command, char *temp, int ma, int ta, int af, int vma, int dir, struct ship *f, struct ship *t, int *high, int rakeme)
238+
try(struct ship *f, struct ship *t, char *command, char *temp, int ma, int ta, int af, int vma, int dir, int *high, int rakeme)
239239
{
240240
int new, n;
241241
char st[4];
@@ -245,33 +245,33 @@ try(char *command, char *temp, int ma, int ta, int af, int vma, int dir, struct
245245
for (n = 1; vma - n >= 0; n++) {
246246
sprintf(st, "%d", n);
247247
strcat(temp, st);
248-
new = score(temp, f, t, rakeme);
248+
new = score(f, t, temp, rakeme);
249249
if (new > *high && (!rakeme || rakeyou)) {
250250
*high = new;
251251
strcpy(command, temp);
252252
}
253-
try(command, temp, ma-n, ta, af, vma-n,
254-
dir, f, t, high, rakeme);
253+
try(f, t, command, temp, ma-n, ta, af, vma-n,
254+
dir, high, rakeme);
255255
rmend(temp);
256256
}
257257
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) {
258258
strcat(temp, "r");
259-
new = score(temp, f, t, rakeme);
259+
new = score(f, t, temp, rakeme);
260260
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) {
261261
*high = new;
262262
strcpy(command, temp);
263263
}
264-
try(command, temp, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1),f,t,high,rakeme);
264+
try(f, t, command, temp, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1), high, rakeme);
265265
rmend(temp);
266266
}
267267
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){
268268
strcat(temp, "l");
269-
new = score(temp, f, t, rakeme);
269+
new = score(f, t, temp, rakeme);
270270
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))){
271271
*high = new;
272272
strcpy(command, temp);
273273
}
274-
try(command, temp, ma-1, ta-1, af, (min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))), (dir-1 ? dir -1 : 8), f, t, high, rakeme);
274+
try(f, t, command, temp, ma-1, ta-1, af, (min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))), (dir-1 ? dir -1 : 8), high, rakeme);
275275
rmend(temp);
276276
}
277277
}

games/sail/dr_3.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_3.c,v 1.12 2001/01/04 03:51:23 jwise Exp $ */
1+
/* $NetBSD: dr_3.c,v 1.13 2001/01/04 06:16:51 jwise Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: dr_3.c,v 1.12 2001/01/04 03:51:23 jwise Exp $");
41+
__RCSID("$NetBSD: dr_3.c,v 1.13 2001/01/04 06:16:51 jwise Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -51,7 +51,7 @@ void moveall(void);
5151
static int stillmoving(int);
5252
static int is_isolated(struct ship *);
5353
static int push(struct ship *, struct ship *);
54-
static void step(int, struct ship *, char *);
54+
static void step(struct ship *, int, char *);
5555
void sendbp(struct ship *, struct ship *, int, int);
5656
int is_toughmelee(struct ship *, struct ship *, int, int);
5757
void reload(void);
@@ -124,7 +124,7 @@ moveall(void)
124124
if (!sp->file->movebuf[k])
125125
sp->file->movebuf[k+1] = '\0';
126126
else if (sp->file->dir)
127-
step(sp->file->movebuf[k], sp, &moved[n]);
127+
step(sp, sp->file->movebuf[k], &moved[n]);
128128
n++;
129129
}
130130
/*
@@ -233,7 +233,7 @@ push(struct ship *from, struct ship *to)
233233
}
234234

235235
static void
236-
step(int com, struct ship *sp, char *moved)
236+
step(struct ship *sp, int com, char *moved)
237237
{
238238
int dist;
239239

games/sail/dr_5.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_5.c,v 1.9 2001/01/04 03:51:23 jwise Exp $ */
1+
/* $NetBSD: dr_5.c,v 1.10 2001/01/04 06:16:51 jwise Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,18 +38,18 @@
3838
#if 0
3939
static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95";
4040
#else
41-
__RCSID("$NetBSD: dr_5.c,v 1.9 2001/01/04 03:51:23 jwise Exp $");
41+
__RCSID("$NetBSD: dr_5.c,v 1.10 2001/01/04 06:16:51 jwise Exp $");
4242
#endif
4343
#endif /* not lint */
4444

4545
#include <sys/types.h>
4646
#include "extern.h"
4747

48-
void subtract(struct ship *, int, int *, struct ship *, int);
48+
void subtract(struct ship *, struct ship *, int, int *, int);
4949
int mensent(struct ship *, struct ship *, int *, struct ship **, int *, int);
5050

5151
void
52-
subtract(struct ship *from, int totalfrom, int *crewfrom, struct ship *fromcap, int pcfrom)
52+
subtract(struct ship *from, struct ship *fromcap, int totalfrom, int *crewfrom, int pcfrom)
5353
{
5454
int n;
5555

games/sail/extern.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: extern.h,v 1.23 2001/01/04 05:34:56 jwise Exp $ */
1+
/* $NetBSD: extern.h,v 1.24 2001/01/04 06:16:51 jwise Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -293,7 +293,7 @@ extern int people;
293293
extern int hasdriver;
294294

295295
/* assorted.c */
296-
void table (int, int, int, struct ship *, struct ship *, int);
296+
void table (struct ship *, struct ship *, int, int, int, int);
297297
void Cleansnag (struct ship *, struct ship *, int, int);
298298

299299
/* dr_1.c */
@@ -321,7 +321,7 @@ void ungrap (struct ship *, struct ship *);
321321
void grap (struct ship *, struct ship *);
322322

323323
/* dr_5.c */
324-
void subtract (struct ship *, int, int [3], struct ship *, int);
324+
void subtract (struct ship *, struct ship *, int, int [3], int);
325325
int mensent (struct ship *, struct ship *, int[3], struct ship **, int *,
326326
int);
327327

games/sail/pl_3.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: pl_3.c,v 1.14 2001/01/04 04:41:41 jwise Exp $ */
1+
/* $NetBSD: pl_3.c,v 1.15 2001/01/04 06:16:51 jwise Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: pl_3.c,v 1.14 2001/01/04 04:41:41 jwise Exp $");
41+
__RCSID("$NetBSD: pl_3.c,v 1.15 2001/01/04 06:16:51 jwise Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -203,7 +203,7 @@ acceptcombat(void)
203203
hhits = 0;
204204
}
205205
}
206-
table(shootat, load, hit, closest, ms, roll);
206+
table(ms, closest, shootat, load, hit, roll);
207207
}
208208
Msg("Damage inflicted on the %s:", closest->shipname);
209209
Msg("\t%d HULL, %d GUNS, %d CREW, %d RIGGING",

games/sail/pl_5.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: pl_5.c,v 1.12 2001/01/04 04:41:42 jwise Exp $ */
1+
/* $NetBSD: pl_5.c,v 1.13 2001/01/04 06:16:51 jwise Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
3838
#if 0
3939
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
4040
#else
41-
__RCSID("$NetBSD: pl_5.c,v 1.12 2001/01/04 04:41:42 jwise Exp $");
41+
__RCSID("$NetBSD: pl_5.c,v 1.13 2001/01/04 06:16:51 jwise Exp $");
4242
#endif
4343
#endif /* not lint */
4444

@@ -54,7 +54,7 @@ __RCSID("$NetBSD: pl_5.c,v 1.12 2001/01/04 04:41:42 jwise Exp $");
5454

5555
void acceptmove(void);
5656
void acceptboard(void);
57-
static void parties(int *, struct ship *, int, int);
57+
static void parties(struct ship *, int *, int, int);
5858

5959
void
6060
acceptmove(void)
@@ -194,24 +194,24 @@ acceptboard(void)
194194
if (meleeing(ms, sp) && crew[2]) {
195195
c = sgetch("How many more to board the $$? ",
196196
sp, 1);
197-
parties(crew, sp, 0, c);
197+
parties(sp, crew, 0, c);
198198
} else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) {
199199
c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1);
200-
parties(crew, sp, 0, c);
200+
parties(sp, crew, 0, c);
201201
}
202202
}
203203
if (crew[2]) {
204204
c = sgetch("How many sections to repel boarders? ",
205205
(struct ship *)0, 1);
206-
parties(crew, ms, 1, c);
206+
parties(ms, crew, 1, c);
207207
}
208208
blockalarm();
209209
draw_slot();
210210
unblockalarm();
211211
}
212212

213213
static void
214-
parties(int *crew, struct ship *to, int isdefense, int buf)
214+
parties(struct ship *to, int *crew, int isdefense, int buf)
215215
{
216216
int k, j, men;
217217
struct BP *ptr;

0 commit comments

Comments
 (0)