Skip to content

Commit b8c43a1

Browse files
committed
Lines <= 80 chars, remove trailing whitespace, other formatting adjustments.
No functional change.
1 parent 7ce7d47 commit b8c43a1

18 files changed

+253
-192
lines changed

games/sail/assorted.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: assorted.c,v 1.15 2003/08/07 09:37:41 agc Exp $ */
1+
/* $NetBSD: assorted.c,v 1.16 2009/03/14 19:35:13 dholland Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -34,18 +34,19 @@
3434
#if 0
3535
static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95";
3636
#else
37-
__RCSID("$NetBSD: assorted.c,v 1.15 2003/08/07 09:37:41 agc Exp $");
37+
__RCSID("$NetBSD: assorted.c,v 1.16 2009/03/14 19:35:13 dholland Exp $");
3838
#endif
3939
#endif /* not lint */
4040

4141
#include <stdlib.h>
4242
#include <err.h>
4343
#include "extern.h"
4444

45-
static void strike (struct ship *, struct ship *);
45+
static void strike(struct ship *, struct ship *);
4646

4747
void
48-
table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int roll)
48+
table(struct ship *from, struct ship *on,
49+
int rig, int shot, int hittable, int roll)
4950
{
5051
int hhits = 0, chits = 0, ghits = 0, rhits = 0;
5152
int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0;
@@ -65,9 +66,9 @@ table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int r
6566
rigg[1] = on->specs->rig2;
6667
rigg[2] = on->specs->rig3;
6768
rigg[3] = on->specs->rig4;
68-
if (shot == L_GRAPE)
69+
if (shot == L_GRAPE) {
6970
Chit = chits = hittable;
70-
else {
71+
} else {
7172
tp = &(rig ? RigTable : HullTable)[hittable][roll-1];
7273
Chit = chits = tp->C;
7374
Rhit = rhits = tp->R;
@@ -84,22 +85,24 @@ table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int r
8485
pc -= (chits + 1) / 2;
8586
chits /= 2;
8687
}
87-
for (n = 0; n < 3; n++)
88+
for (n = 0; n < 3; n++) {
8889
if (chits > crew[n]) {
8990
chits -= crew[n];
9091
crew[n] = 0;
9192
} else {
9293
crew[n] -= chits;
9394
chits = 0;
9495
}
95-
for (n = 0; n < 3; n++)
96-
if (rhits > rigg[n]){
96+
}
97+
for (n = 0; n < 3; n++) {
98+
if (rhits > rigg[n]) {
9799
rhits -= rigg[n];
98100
rigg[n] = 0;
99101
} else {
100102
rigg[n] -= rhits;
101103
rhits = 0;
102104
}
105+
}
103106
if (rigg[3] != -1 && rhits > rigg[3]) {
104107
rhits -= rigg[3];
105108
rigg[3] = 0;
@@ -122,7 +125,7 @@ table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int r
122125
car -= ghits;
123126
ghits = 0;
124127
}
125-
if (ghits > guns){
128+
if (ghits > guns) {
126129
ghits -= guns;
127130
guns = 0;
128131
} else {
@@ -221,14 +224,16 @@ table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int r
221224
makemsg(on, message);
222225
}
223226
/*
224-
if (Chit > 1 && on->file->readyL&R_INITIAL && on->file->readyR&R_INITIAL) {
227+
if (Chit > 1 && on->file->readyL & R_INITIAL &&
228+
on->file->readyR & R_INITIAL) {
225229
on->specs->qual--;
226230
if (on->specs->qual <= 0) {
227231
makemsg(on, "crew mutinying!");
228232
on->specs->qual = 5;
229233
Write(W_CAPTURED, on, on->file->index, 0, 0, 0);
230-
} else
234+
} else {
231235
makemsg(on, "crew demoralized");
236+
}
232237
Write(W_QUAL, on, on->specs->qual, 0, 0, 0);
233238
}
234239
*/

games/sail/display.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/* $NetBSD: display.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */
1+
/* $NetBSD: display.h,v 1.4 2009/03/14 19:35:13 dholland Exp $ */
22

33
/*-
44
* Copyright (c) 2001 The NetBSD Foundation, Inc.
55
* All rights reserved.
66
*
77
* This code is derived from software contributed to The NetBSD Foundation
8-
* by
8+
* by
99
*
1010
* Redistribution and use in source and binary forms, with or without
1111
* modification, are permitted provided that the following conditions
@@ -30,7 +30,9 @@
3030
*/
3131

3232
#ifdef SIGTSTP
33-
#define SCREENTEST() (initscr() != NULL && signal(SIGTSTP, SIG_DFL) != SIG_ERR && STAT_R < COLS && SCROLL_Y > 0)
33+
#define SCREENTEST() (initscr() != NULL && \
34+
signal(SIGTSTP, SIG_DFL) != SIG_ERR && \
35+
STAT_R < COLS && SCROLL_Y > 0)
3436
#else
3537
#define SCREENTEST() (initscr() != NULL && STAT_R < COLS && SCROLL_Y > 0)
3638
#endif

games/sail/dr_1.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_1.c,v 1.24 2009/03/09 04:38:39 dholland Exp $ */
1+
/* $NetBSD: dr_1.c,v 1.25 2009/03/14 19:35:13 dholland Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
3434
#if 0
3535
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
3636
#else
37-
__RCSID("$NetBSD: dr_1.c,v 1.24 2009/03/09 04:38:39 dholland Exp $");
37+
__RCSID("$NetBSD: dr_1.c,v 1.25 2009/03/14 19:35:13 dholland Exp $");
3838
#endif
3939
#endif /* not lint */
4040

@@ -45,7 +45,7 @@ __RCSID("$NetBSD: dr_1.c,v 1.24 2009/03/09 04:38:39 dholland Exp $");
4545
#include "extern.h"
4646
#include "driver.h"
4747

48-
static int fightitout(struct ship *, struct ship *, int);
48+
static int fightitout(struct ship *, struct ship *, int);
4949

5050
void
5151
unfoul(void)
@@ -102,7 +102,7 @@ boardcomp(void)
102102
/* OBP */
103103
sendbp(sp, sq, crew[0]*100, 0);
104104
crew[0] = 0;
105-
} else if (crew[1]){
105+
} else if (crew[1]) {
106106
/* OBP */
107107
sendbp(sp, sq, crew[1]*10, 0);
108108
crew[1] = 0;
@@ -247,7 +247,8 @@ resolve(void)
247247
if (sp->file->dir == 0)
248248
continue;
249249
for (sq = sp + 1; sq < ls; sq++)
250-
if (sq->file->dir && meleeing(sp, sq) && meleeing(sq, sp))
250+
if (sq->file->dir && meleeing(sp, sq) &&
251+
meleeing(sq, sp))
251252
fightitout(sp, sq, 0);
252253
thwart = 2;
253254
foreachship(sq) {
@@ -293,7 +294,7 @@ compcombat(void)
293294
if (sp->file->DBP[n].turnsent)
294295
men += sp->file->DBP[n].mensent;
295296
}
296-
if (men){
297+
if (men) {
297298
crew[0] = men/100 ? 0 : crew[0] != 0;
298299
crew[1] = (men%100)/10 ? 0 : crew[1] != 0;
299300
crew[2] = men%10 ? 0 : crew[2] != 0;
@@ -319,7 +320,8 @@ compcombat(void)
319320
closest = closestenemy(sp, r ? 'r' : 'l', 0);
320321
if (closest == 0)
321322
continue;
322-
if (range(closest, sp) > range(sp, closestenemy(sp, r ? 'r' : 'l', 1)))
323+
if (range(closest, sp) >
324+
range(sp, closestenemy(sp, r ? 'r' : 'l', 1)))
323325
continue;
324326
if (closest->file->struck)
325327
continue;
@@ -360,13 +362,14 @@ compcombat(void)
360362
if (rakehim && sternrake)
361363
hit++;
362364
hit += QUAL[indx][capship(sp)->specs->qual - 1];
363-
for (n = 0; n < 3 && sp->file->captured == 0; n++)
365+
for (n = 0; n < 3 && sp->file->captured == 0; n++) {
364366
if (!crew[n]) {
365367
if (indx <= 5)
366368
hit--;
367369
else
368370
hit -= 2;
369371
}
372+
}
370373
if (ready & R_INITIAL) {
371374
if (!r)
372375
sp->file->readyL &= ~R_INITIAL;
@@ -394,7 +397,8 @@ compcombat(void)
394397
if (hit >= 0) {
395398
if (load != L_GRAPE)
396399
hit = hit > 10 ? 10 : hit;
397-
table(sp, closest, shootat, load, hit, dieroll());
400+
table(sp, closest, shootat, load, hit,
401+
dieroll());
398402
}
399403
}
400404
}

games/sail/dr_2.c

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: dr_2.c,v 1.22 2009/03/14 18:32:47 dholland Exp $ */
1+
/* $NetBSD: dr_2.c,v 1.23 2009/03/14 19:35:13 dholland Exp $ */
22

33
/*
44
* Copyright (c) 1983, 1993
@@ -34,7 +34,7 @@
3434
#if 0
3535
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
3636
#else
37-
__RCSID("$NetBSD: dr_2.c,v 1.22 2009/03/14 18:32:47 dholland Exp $");
37+
__RCSID("$NetBSD: dr_2.c,v 1.23 2009/03/14 19:35:13 dholland Exp $");
3838
#endif
3939
#endif /* not lint */
4040

@@ -47,11 +47,15 @@ __RCSID("$NetBSD: dr_2.c,v 1.22 2009/03/14 18:32:47 dholland Exp $");
4747

4848
#define couldwin(f,t) (f->specs->crew2 > t->specs->crew2 * 1.5)
4949

50-
static int str_end(const char *);
51-
static int score(struct ship *, struct ship *, char *, size_t, int);
52-
static void move_ship(struct ship *, const char *, unsigned char *, short *, short *, int *);
53-
static void try(struct ship *f, struct ship *t, char *command, size_t commandmax, char *temp, size_t tempmax, int ma, int ta, int af, int vma, int dir, int *high, int rakeme);
54-
static void rmend(char *);
50+
static int str_end(const char *);
51+
static int score(struct ship *, struct ship *, char *, size_t, int);
52+
static void move_ship(struct ship *, const char *, unsigned char *,
53+
short *, short *, int *);
54+
static void try(struct ship *f, struct ship *t,
55+
char *command, size_t commandmax, char *temp, size_t tempmax,
56+
int ma, int ta, int af, int vma, int dir, int *high,
57+
int rakeme);
58+
static void rmend(char *);
5559

5660
const int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */
5761

@@ -109,11 +113,14 @@ checkup(void)
109113
if (sink != 1) {
110114
makemsg(sp, "exploding!");
111115
foreachship(sq) {
112-
if (sp != sq && sq->file->dir && range(sp, sq) < 4)
113-
table(sp, sq, RIGGING, L_EXPLODE, sp->specs->guns/13, 6);
116+
if (sp != sq && sq->file->dir &&
117+
range(sp, sq) < 4)
118+
table(sp, sq, RIGGING, L_EXPLODE,
119+
sp->specs->guns/13, 6);
114120
}
115-
} else
121+
} else {
116122
makemsg(sp, "sinking!");
123+
}
117124
}
118125
}
119126

@@ -127,9 +134,13 @@ prizecheck(void)
127134
continue;
128135
if (sp->file->struck || sp->file->dir == 0)
129136
continue;
130-
if (sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3 > sp->file->pcrew * 6) {
137+
if (sp->specs->crew1 + sp->specs->crew2 + sp->specs->crew3 >
138+
sp->file->pcrew * 6) {
131139
Writestr(W_SIGNAL, sp, "prize crew overthrown");
132-
Write(W_POINTS, sp->file->captured, sp->file->captured->file->points - 2 * sp->specs->pts, 0, 0, 0);
140+
Write(W_POINTS, sp->file->captured,
141+
sp->file->captured->file->points
142+
- 2 * sp->specs->pts,
143+
0, 0, 0);
133144
Write(W_CAPTURED, sp, -1, 0, 0, 0);
134145
}
135146
}
@@ -146,18 +157,21 @@ str_end(const char *str)
146157
}
147158

148159
void
149-
closeon(struct ship *from, struct ship *to, char *command, size_t commandmax, int ta, int ma, int af)
160+
closeon(struct ship *from, struct ship *to, char *command, size_t commandmax,
161+
int ta, int ma, int af)
150162
{
151163
int high;
152164
char temp[10];
153165

154166
temp[0] = command[0] = '\0';
155167
high = -30000;
156-
try(from, to, command, commandmax, temp, sizeof(temp), ma, ta, af, ma, from->file->dir, &high, 0);
168+
try(from, to, command, commandmax, temp, sizeof(temp),
169+
ma, ta, af, ma, from->file->dir, &high, 0);
157170
}
158171

159172
static int
160-
score(struct ship *ship, struct ship *to, char *movement, size_t movementmax, int onlytemp)
173+
score(struct ship *ship, struct ship *to, char *movement, size_t movementmax,
174+
int onlytemp)
161175
{
162176
int drift;
163177
int row, col, dir, total, ran;
@@ -188,7 +202,8 @@ score(struct ship *ship, struct ship *to, char *movement, size_t movementmax, in
188202
}
189203

190204
static void
191-
move_ship(struct ship *ship, const char *p, unsigned char *dir, short *row, short *col, int *drift)
205+
move_ship(struct ship *ship, const char *p, unsigned char *dir,
206+
short *row, short *col, int *drift)
192207
{
193208
int dist;
194209
char moved = 0;
@@ -228,7 +243,10 @@ move_ship(struct ship *ship, const char *p, unsigned char *dir, short *row, shor
228243
}
229244

230245
static void
231-
try(struct ship *f, struct ship *t, char *command, size_t commandmax, char *temp, size_t tempmax, int ma, int ta, int af, int vma, int dir, int *high, int rakeme)
246+
try(struct ship *f, struct ship *t,
247+
char *command, size_t commandmax,
248+
char *temp, size_t tempmax,
249+
int ma, int ta, int af, int vma, int dir, int *high, int rakeme)
232250
{
233251
int new, n;
234252
char st[4];
@@ -243,28 +261,39 @@ try(struct ship *f, struct ship *t, char *command, size_t commandmax, char *temp
243261
*high = new;
244262
strlcpy(command, temp, commandmax);
245263
}
246-
try(f, t, command, commandmax, temp, tempmax, ma-n, ta, af, vma-n,
247-
dir, high, rakeme);
264+
try(f, t, command, commandmax, temp, tempmax,
265+
ma-n, ta, af, vma-n,
266+
dir, high, rakeme);
248267
rmend(temp);
249268
}
250-
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) {
269+
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') ||
270+
!strlen(temp)) {
251271
strlcat(temp, "r", tempmax);
252272
new = score(f, t, temp, tempmax, rakeme);
253-
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) {
273+
if (new > *high && (!rakeme ||
274+
(gunsbear(f, t) && !gunsbear(t, f)))) {
254275
*high = new;
255276
strlcpy(command, temp, commandmax);
256277
}
257-
try(f, t, command, commandmax, temp, tempmax, ma-1, ta-1, af, min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)), (dir == 8 ? 1 : dir+1), high, rakeme);
278+
try(f, t, command, commandmax, temp, tempmax,
279+
ma-1, ta-1, af,
280+
min(ma-1, maxmove(f, (dir == 8 ? 1 : dir+1), 0)),
281+
(dir == 8 ? 1 : dir+1), high, rakeme);
258282
rmend(temp);
259283
}
260-
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){
284+
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') ||
285+
!strlen(temp)) {
261286
strlcat(temp, "l", sizeof(temp));
262287
new = score(f, t, temp, tempmax, rakeme);
263-
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))){
288+
if (new > *high && (!rakeme ||
289+
(gunsbear(f, t) && !gunsbear(t, f)))) {
264290
*high = new;
265291
strlcpy(command, temp, commandmax);
266292
}
267-
try(f, t, command, commandmax, temp, tempmax, ma-1, ta-1, af, (min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))), (dir-1 ? dir -1 : 8), high, rakeme);
293+
try(f, t, command, commandmax, temp, tempmax,
294+
ma-1, ta-1, af,
295+
(min(ma-1,maxmove(f, (dir-1 ? dir-1 : 8), 0))),
296+
(dir-1 ? dir -1 : 8), high, rakeme);
268297
rmend(temp);
269298
}
270299
}

0 commit comments

Comments
 (0)