Normalize signature of ship handling functions -- struct ship * from and

struct ship * to are now always the first two args.
This commit is contained in:
jwise 2001-01-04 06:16:51 +00:00
parent 650239ad74
commit a5f75468c7
8 changed files with 54 additions and 54 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: assorted.c,v 1.12 2001/01/04 03:21:16 jwise Exp $ */ /* $NetBSD: assorted.c,v 1.13 2001/01/04 06:16:51 jwise Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95";
#else #else
__RCSID("$NetBSD: assorted.c,v 1.12 2001/01/04 03:21:16 jwise Exp $"); __RCSID("$NetBSD: assorted.c,v 1.13 2001/01/04 06:16:51 jwise Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -46,12 +46,12 @@ __RCSID("$NetBSD: assorted.c,v 1.12 2001/01/04 03:21:16 jwise Exp $");
#include <err.h> #include <err.h>
#include "extern.h" #include "extern.h"
void table(int, int, int, struct ship *, struct ship *, int); void table(struct ship *, struct ship *, int, int, int, int);
void Cleansnag(struct ship *, struct ship *, int, int); void Cleansnag(struct ship *, struct ship *, int, int);
static void strike (struct ship *, struct ship *); static void strike (struct ship *, struct ship *);
void void
table(int rig, int shot, int hittable, struct ship *on, struct ship *from, int roll) table(struct ship *from, struct ship *on, int rig, int shot, int hittable, int roll)
{ {
int hhits = 0, chits = 0, ghits = 0, rhits = 0; int hhits = 0, chits = 0, ghits = 0, rhits = 0;
int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0; int Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dr_1.c,v 1.16 2001/01/04 05:34:56 jwise Exp $ */ /* $NetBSD: dr_1.c,v 1.17 2001/01/04 06:16:51 jwise Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
#else #else
__RCSID("$NetBSD: dr_1.c,v 1.16 2001/01/04 05:34:56 jwise Exp $"); __RCSID("$NetBSD: dr_1.c,v 1.17 2001/01/04 06:16:51 jwise Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -196,8 +196,8 @@ fightitout(struct ship *from, struct ship *to, int key)
} }
if (fromstrength >= strengthto * 3 || count == 4) { if (fromstrength >= strengthto * 3 || count == 4) {
unboard(to, from, 0); unboard(to, from, 0);
subtract(from, totalfrom, crewfrom, fromcap, pcfrom); subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
subtract(to, totalto, crewto, tocap, pcto); subtract(to, tocap, totalto, crewto, pcto);
makemsg(from, "boarders from %s repelled", to->shipname); makemsg(from, "boarders from %s repelled", to->shipname);
sprintf(message, "killed in melee: %d. %s: %d", sprintf(message, "killed in melee: %d. %s: %d",
totalto, from->shipname, totalfrom); totalto, from->shipname, totalfrom);
@ -206,8 +206,8 @@ fightitout(struct ship *from, struct ship *to, int key)
return 1; return 1;
} else if (strengthto >= fromstrength * 3) { } else if (strengthto >= fromstrength * 3) {
unboard(from, to, 0); unboard(from, to, 0);
subtract(from, totalfrom, crewfrom, fromcap, pcfrom); subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
subtract(to, totalto, crewto, tocap, pcto); subtract(to, tocap, totalto, crewto, pcto);
if (key) { if (key) {
if (fromcap != from) if (fromcap != from)
Write(W_POINTS, fromcap, Write(W_POINTS, fromcap,
@ -228,8 +228,8 @@ fightitout(struct ship *from, struct ship *to, int key)
Write(W_POINTS, to, topoints, 0, 0, 0); Write(W_POINTS, to, topoints, 0, 0, 0);
mento = crewto[0] ? crewto[0] : crewto[1]; mento = crewto[0] ? crewto[0] : crewto[1];
if (mento) { if (mento) {
subtract(to, mento, crewto, tocap, pcto); subtract(to, tocap, mento, crewto, pcto);
subtract(from, - mento, crewfrom, to, 0); subtract(from, to, - mento, crewfrom, 0);
} }
sprintf(message, "captured by the %s!", to->shipname); sprintf(message, "captured by the %s!", to->shipname);
Writestr(W_SIGNAL, from, message); Writestr(W_SIGNAL, from, message);
@ -400,7 +400,7 @@ compcombat(void)
if (hit >= 0) { if (hit >= 0) {
if (load != L_GRAPE) if (load != L_GRAPE)
hit = hit > 10 ? 10 : hit; hit = hit > 10 ? 10 : hit;
table(shootat, load, hit, closest, sp, dieroll()); table(sp, closest, shootat, load, hit, dieroll());
} }
} }
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: dr_2.c,v 1.16 2001/01/04 03:51:23 jwise Exp $ */ /* $NetBSD: dr_2.c,v 1.17 2001/01/04 06:16:51 jwise Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
#else #else
__RCSID("$NetBSD: dr_2.c,v 1.16 2001/01/04 03:51:23 jwise Exp $"); __RCSID("$NetBSD: dr_2.c,v 1.17 2001/01/04 06:16:51 jwise Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -55,9 +55,9 @@ void checkup(void);
void prizecheck(void); void prizecheck(void);
static int str_end(const char *); static int str_end(const char *);
void closeon(struct ship *, struct ship *, char *, int, int, int); void closeon(struct ship *, struct ship *, char *, int, int, int);
static int score(char *, struct ship *, struct ship *, int); static int score(struct ship *, struct ship *, char *, int);
static void move_ship(const char *, struct ship *, unsigned char *, short *, short *, char *); static void move_ship(struct ship *, const char *, unsigned char *, short *, short *, char *);
static void try(char *, char *, int, int, int, int, int, struct ship *, struct ship *, int *, int); static void try(struct ship *, struct ship *, char *, char *, int, int, int, int, int, int *, int);
static void rmend(char *); static void rmend(char *);
const int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */ const int dtab[] = {0,1,1,2,3,4,4,5}; /* diagonal distances in x==y */
@ -117,7 +117,7 @@ checkup(void)
makemsg(sp, "exploding!"); makemsg(sp, "exploding!");
foreachship(sq) { foreachship(sq) {
if (sp != sq && sq->file->dir && range(sp, sq) < 4) if (sp != sq && sq->file->dir && range(sp, sq) < 4)
table(RIGGING, L_EXPLODE, sp->specs->guns/13, sq, sp, 6); table(sp, sq, RIGGING, L_EXPLODE, sp->specs->guns/13, 6);
} }
} else } else
makemsg(sp, "sinking!"); makemsg(sp, "sinking!");
@ -160,11 +160,11 @@ closeon(struct ship *from, struct ship *to, char *command, int ta, int ma, int a
temp[0] = command[0] = '\0'; temp[0] = command[0] = '\0';
high = -30000; high = -30000;
try(command, temp, ma, ta, af, ma, from->file->dir, from, to, &high, 0); try(from, to, command, temp, ma, ta, af, ma, from->file->dir, &high, 0);
} }
static int static int
score(char *movement, struct ship *ship, struct ship *to, int onlytemp) score(struct ship *ship, struct ship *to, char *movement, int onlytemp)
{ {
char drift; char drift;
int row, col, dir, total, ran; int row, col, dir, total, ran;
@ -175,7 +175,7 @@ score(char *movement, struct ship *ship, struct ship *to, int onlytemp)
row = fp->row; row = fp->row;
col = fp->col; col = fp->col;
drift = fp->drift; drift = fp->drift;
move_ship(movement, ship, &fp->dir, &fp->row, &fp->col, &drift); move_ship(ship, movement, &fp->dir, &fp->row, &fp->col, &drift);
if (!*movement) if (!*movement)
strcpy(movement, "d"); strcpy(movement, "d");
@ -195,7 +195,7 @@ score(char *movement, struct ship *ship, struct ship *to, int onlytemp)
} }
static void static void
move_ship(const char *p, struct ship *ship, unsigned char *dir, short *row, short *col, char *drift) move_ship(struct ship *ship, const char *p, unsigned char *dir, short *row, short *col, char *drift)
{ {
int dist; int dist;
char moved = 0; char moved = 0;
@ -235,7 +235,7 @@ move_ship(const char *p, struct ship *ship, unsigned char *dir, short *row, shor
} }
static void static void
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) 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)
{ {
int new, n; int new, n;
char st[4]; char st[4];
@ -245,33 +245,33 @@ try(char *command, char *temp, int ma, int ta, int af, int vma, int dir, struct
for (n = 1; vma - n >= 0; n++) { for (n = 1; vma - n >= 0; n++) {
sprintf(st, "%d", n); sprintf(st, "%d", n);
strcat(temp, st); strcat(temp, st);
new = score(temp, f, t, rakeme); new = score(f, t, temp, rakeme);
if (new > *high && (!rakeme || rakeyou)) { if (new > *high && (!rakeme || rakeyou)) {
*high = new; *high = new;
strcpy(command, temp); strcpy(command, temp);
} }
try(command, temp, ma-n, ta, af, vma-n, try(f, t, command, temp, ma-n, ta, af, vma-n,
dir, f, t, high, rakeme); dir, high, rakeme);
rmend(temp); rmend(temp);
} }
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) { if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) {
strcat(temp, "r"); strcat(temp, "r");
new = score(temp, f, t, rakeme); new = score(f, t, temp, rakeme);
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) { if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))) {
*high = new; *high = new;
strcpy(command, temp); strcpy(command, temp);
} }
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); 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);
rmend(temp); rmend(temp);
} }
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){ if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){
strcat(temp, "l"); strcat(temp, "l");
new = score(temp, f, t, rakeme); new = score(f, t, temp, rakeme);
if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))){ if (new > *high && (!rakeme || (gunsbear(f, t) && !gunsbear(t, f)))){
*high = new; *high = new;
strcpy(command, temp); strcpy(command, temp);
} }
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); 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);
rmend(temp); rmend(temp);
} }
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: dr_3.c,v 1.12 2001/01/04 03:51:23 jwise Exp $ */ /* $NetBSD: dr_3.c,v 1.13 2001/01/04 06:16:51 jwise Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93";
#else #else
__RCSID("$NetBSD: dr_3.c,v 1.12 2001/01/04 03:51:23 jwise Exp $"); __RCSID("$NetBSD: dr_3.c,v 1.13 2001/01/04 06:16:51 jwise Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -51,7 +51,7 @@ void moveall(void);
static int stillmoving(int); static int stillmoving(int);
static int is_isolated(struct ship *); static int is_isolated(struct ship *);
static int push(struct ship *, struct ship *); static int push(struct ship *, struct ship *);
static void step(int, struct ship *, char *); static void step(struct ship *, int, char *);
void sendbp(struct ship *, struct ship *, int, int); void sendbp(struct ship *, struct ship *, int, int);
int is_toughmelee(struct ship *, struct ship *, int, int); int is_toughmelee(struct ship *, struct ship *, int, int);
void reload(void); void reload(void);
@ -124,7 +124,7 @@ moveall(void)
if (!sp->file->movebuf[k]) if (!sp->file->movebuf[k])
sp->file->movebuf[k+1] = '\0'; sp->file->movebuf[k+1] = '\0';
else if (sp->file->dir) else if (sp->file->dir)
step(sp->file->movebuf[k], sp, &moved[n]); step(sp, sp->file->movebuf[k], &moved[n]);
n++; n++;
} }
/* /*
@ -233,7 +233,7 @@ push(struct ship *from, struct ship *to)
} }
static void static void
step(int com, struct ship *sp, char *moved) step(struct ship *sp, int com, char *moved)
{ {
int dist; int dist;

View File

@ -1,4 +1,4 @@
/* $NetBSD: dr_5.c,v 1.9 2001/01/04 03:51:23 jwise Exp $ */ /* $NetBSD: dr_5.c,v 1.10 2001/01/04 06:16:51 jwise Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,18 +38,18 @@
#if 0 #if 0
static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95"; static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95";
#else #else
__RCSID("$NetBSD: dr_5.c,v 1.9 2001/01/04 03:51:23 jwise Exp $"); __RCSID("$NetBSD: dr_5.c,v 1.10 2001/01/04 06:16:51 jwise Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
#include "extern.h" #include "extern.h"
void subtract(struct ship *, int, int *, struct ship *, int); void subtract(struct ship *, struct ship *, int, int *, int);
int mensent(struct ship *, struct ship *, int *, struct ship **, int *, int); int mensent(struct ship *, struct ship *, int *, struct ship **, int *, int);
void void
subtract(struct ship *from, int totalfrom, int *crewfrom, struct ship *fromcap, int pcfrom) subtract(struct ship *from, struct ship *fromcap, int totalfrom, int *crewfrom, int pcfrom)
{ {
int n; int n;

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.23 2001/01/04 05:34:56 jwise Exp $ */ /* $NetBSD: extern.h,v 1.24 2001/01/04 06:16:51 jwise Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -293,7 +293,7 @@ extern int people;
extern int hasdriver; extern int hasdriver;
/* assorted.c */ /* assorted.c */
void table (int, int, int, struct ship *, struct ship *, int); void table (struct ship *, struct ship *, int, int, int, int);
void Cleansnag (struct ship *, struct ship *, int, int); void Cleansnag (struct ship *, struct ship *, int, int);
/* dr_1.c */ /* dr_1.c */
@ -321,7 +321,7 @@ void ungrap (struct ship *, struct ship *);
void grap (struct ship *, struct ship *); void grap (struct ship *, struct ship *);
/* dr_5.c */ /* dr_5.c */
void subtract (struct ship *, int, int [3], struct ship *, int); void subtract (struct ship *, struct ship *, int, int [3], int);
int mensent (struct ship *, struct ship *, int[3], struct ship **, int *, int mensent (struct ship *, struct ship *, int[3], struct ship **, int *,
int); int);

View File

@ -1,4 +1,4 @@
/* $NetBSD: pl_3.c,v 1.14 2001/01/04 04:41:41 jwise Exp $ */ /* $NetBSD: pl_3.c,v 1.15 2001/01/04 06:16:51 jwise Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93";
#else #else
__RCSID("$NetBSD: pl_3.c,v 1.14 2001/01/04 04:41:41 jwise Exp $"); __RCSID("$NetBSD: pl_3.c,v 1.15 2001/01/04 06:16:51 jwise Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -203,7 +203,7 @@ acceptcombat(void)
hhits = 0; hhits = 0;
} }
} }
table(shootat, load, hit, closest, ms, roll); table(ms, closest, shootat, load, hit, roll);
} }
Msg("Damage inflicted on the %s:", closest->shipname); Msg("Damage inflicted on the %s:", closest->shipname);
Msg("\t%d HULL, %d GUNS, %d CREW, %d RIGGING", Msg("\t%d HULL, %d GUNS, %d CREW, %d RIGGING",

View File

@ -1,4 +1,4 @@
/* $NetBSD: pl_5.c,v 1.12 2001/01/04 04:41:42 jwise Exp $ */ /* $NetBSD: pl_5.c,v 1.13 2001/01/04 06:16:51 jwise Exp $ */
/* /*
* Copyright (c) 1983, 1993 * Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93"; static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
#else #else
__RCSID("$NetBSD: pl_5.c,v 1.12 2001/01/04 04:41:42 jwise Exp $"); __RCSID("$NetBSD: pl_5.c,v 1.13 2001/01/04 06:16:51 jwise Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -54,7 +54,7 @@ __RCSID("$NetBSD: pl_5.c,v 1.12 2001/01/04 04:41:42 jwise Exp $");
void acceptmove(void); void acceptmove(void);
void acceptboard(void); void acceptboard(void);
static void parties(int *, struct ship *, int, int); static void parties(struct ship *, int *, int, int);
void void
acceptmove(void) acceptmove(void)
@ -194,16 +194,16 @@ acceptboard(void)
if (meleeing(ms, sp) && crew[2]) { if (meleeing(ms, sp) && crew[2]) {
c = sgetch("How many more to board the $$? ", c = sgetch("How many more to board the $$? ",
sp, 1); sp, 1);
parties(crew, sp, 0, c); parties(sp, crew, 0, c);
} else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) { } else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) {
c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1); c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1);
parties(crew, sp, 0, c); parties(sp, crew, 0, c);
} }
} }
if (crew[2]) { if (crew[2]) {
c = sgetch("How many sections to repel boarders? ", c = sgetch("How many sections to repel boarders? ",
(struct ship *)0, 1); (struct ship *)0, 1);
parties(crew, ms, 1, c); parties(ms, crew, 1, c);
} }
blockalarm(); blockalarm();
draw_slot(); draw_slot();
@ -211,7 +211,7 @@ acceptboard(void)
} }
static void static void
parties(int *crew, struct ship *to, int isdefense, int buf) parties(struct ship *to, int *crew, int isdefense, int buf)
{ {
int k, j, men; int k, j, men;
struct BP *ptr; struct BP *ptr;