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:
parent
650239ad74
commit
a5f75468c7
|
@ -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
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)assorted.c 8.2 (Berkeley) 4/28/95";
|
||||
#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 /* 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 "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);
|
||||
static void strike (struct ship *, struct ship *);
|
||||
static void strike (struct ship *, struct ship *);
|
||||
|
||||
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 Ghit = 0, Hhit = 0, Rhit = 0, Chit = 0;
|
||||
|
|
|
@ -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
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)dr_1.c 8.1 (Berkeley) 5/31/93";
|
||||
#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 /* not lint */
|
||||
|
||||
|
@ -196,8 +196,8 @@ fightitout(struct ship *from, struct ship *to, int key)
|
|||
}
|
||||
if (fromstrength >= strengthto * 3 || count == 4) {
|
||||
unboard(to, from, 0);
|
||||
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
|
||||
subtract(to, totalto, crewto, tocap, pcto);
|
||||
subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
|
||||
subtract(to, tocap, totalto, crewto, pcto);
|
||||
makemsg(from, "boarders from %s repelled", to->shipname);
|
||||
sprintf(message, "killed in melee: %d. %s: %d",
|
||||
totalto, from->shipname, totalfrom);
|
||||
|
@ -206,8 +206,8 @@ fightitout(struct ship *from, struct ship *to, int key)
|
|||
return 1;
|
||||
} else if (strengthto >= fromstrength * 3) {
|
||||
unboard(from, to, 0);
|
||||
subtract(from, totalfrom, crewfrom, fromcap, pcfrom);
|
||||
subtract(to, totalto, crewto, tocap, pcto);
|
||||
subtract(from, fromcap, totalfrom, crewfrom, pcfrom);
|
||||
subtract(to, tocap, totalto, crewto, pcto);
|
||||
if (key) {
|
||||
if (fromcap != from)
|
||||
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);
|
||||
mento = crewto[0] ? crewto[0] : crewto[1];
|
||||
if (mento) {
|
||||
subtract(to, mento, crewto, tocap, pcto);
|
||||
subtract(from, - mento, crewfrom, to, 0);
|
||||
subtract(to, tocap, mento, crewto, pcto);
|
||||
subtract(from, to, - mento, crewfrom, 0);
|
||||
}
|
||||
sprintf(message, "captured by the %s!", to->shipname);
|
||||
Writestr(W_SIGNAL, from, message);
|
||||
|
@ -400,7 +400,7 @@ compcombat(void)
|
|||
if (hit >= 0) {
|
||||
if (load != L_GRAPE)
|
||||
hit = hit > 10 ? 10 : hit;
|
||||
table(shootat, load, hit, closest, sp, dieroll());
|
||||
table(sp, closest, shootat, load, hit, dieroll());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)dr_2.c 8.1 (Berkeley) 5/31/93";
|
||||
#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 /* not lint */
|
||||
|
||||
|
@ -55,9 +55,9 @@ void checkup(void);
|
|||
void prizecheck(void);
|
||||
static int str_end(const char *);
|
||||
void closeon(struct ship *, struct ship *, char *, int, int, int);
|
||||
static int score(char *, struct ship *, struct ship *, int);
|
||||
static void move_ship(const char *, struct ship *, unsigned char *, short *, short *, char *);
|
||||
static void try(char *, char *, int, int, int, int, int, struct ship *, struct ship *, int *, int);
|
||||
static int score(struct ship *, struct ship *, char *, int);
|
||||
static void move_ship(struct ship *, const char *, unsigned char *, short *, short *, char *);
|
||||
static void try(struct ship *, struct ship *, char *, char *, int, int, int, int, int, int *, int);
|
||||
static void rmend(char *);
|
||||
|
||||
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!");
|
||||
foreachship(sq) {
|
||||
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
|
||||
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';
|
||||
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
|
||||
score(char *movement, struct ship *ship, struct ship *to, int onlytemp)
|
||||
score(struct ship *ship, struct ship *to, char *movement, int onlytemp)
|
||||
{
|
||||
char drift;
|
||||
int row, col, dir, total, ran;
|
||||
|
@ -175,7 +175,7 @@ score(char *movement, struct ship *ship, struct ship *to, int onlytemp)
|
|||
row = fp->row;
|
||||
col = fp->col;
|
||||
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)
|
||||
strcpy(movement, "d");
|
||||
|
||||
|
@ -195,7 +195,7 @@ score(char *movement, struct ship *ship, struct ship *to, int onlytemp)
|
|||
}
|
||||
|
||||
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;
|
||||
char moved = 0;
|
||||
|
@ -235,7 +235,7 @@ move_ship(const char *p, struct ship *ship, unsigned char *dir, short *row, shor
|
|||
}
|
||||
|
||||
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;
|
||||
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++) {
|
||||
sprintf(st, "%d", n);
|
||||
strcat(temp, st);
|
||||
new = score(temp, f, t, rakeme);
|
||||
new = score(f, t, temp, rakeme);
|
||||
if (new > *high && (!rakeme || rakeyou)) {
|
||||
*high = new;
|
||||
strcpy(command, temp);
|
||||
}
|
||||
try(command, temp, ma-n, ta, af, vma-n,
|
||||
dir, f, t, high, rakeme);
|
||||
try(f, t, command, temp, ma-n, ta, af, vma-n,
|
||||
dir, high, rakeme);
|
||||
rmend(temp);
|
||||
}
|
||||
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)) {
|
||||
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)))) {
|
||||
*high = new;
|
||||
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);
|
||||
}
|
||||
if ((ma > 0 && ta > 0 && (n = str_end(temp)) != 'l' && n != 'r') || !strlen(temp)){
|
||||
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)))){
|
||||
*high = new;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)dr_3.c 8.1 (Berkeley) 5/31/93";
|
||||
#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 /* not lint */
|
||||
|
||||
|
@ -51,7 +51,7 @@ void moveall(void);
|
|||
static int stillmoving(int);
|
||||
static int is_isolated(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);
|
||||
int is_toughmelee(struct ship *, struct ship *, int, int);
|
||||
void reload(void);
|
||||
|
@ -124,7 +124,7 @@ moveall(void)
|
|||
if (!sp->file->movebuf[k])
|
||||
sp->file->movebuf[k+1] = '\0';
|
||||
else if (sp->file->dir)
|
||||
step(sp->file->movebuf[k], sp, &moved[n]);
|
||||
step(sp, sp->file->movebuf[k], &moved[n]);
|
||||
n++;
|
||||
}
|
||||
/*
|
||||
|
@ -233,7 +233,7 @@ push(struct ship *from, struct ship *to)
|
|||
}
|
||||
|
||||
static void
|
||||
step(int com, struct ship *sp, char *moved)
|
||||
step(struct ship *sp, int com, char *moved)
|
||||
{
|
||||
int dist;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -38,18 +38,18 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)dr_5.c 8.2 (Berkeley) 4/28/95";
|
||||
#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 /* not lint */
|
||||
|
||||
#include <sys/types.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);
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -293,7 +293,7 @@ extern int people;
|
|||
extern int hasdriver;
|
||||
|
||||
/* 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);
|
||||
|
||||
/* dr_1.c */
|
||||
|
@ -321,7 +321,7 @@ void ungrap (struct ship *, struct ship *);
|
|||
void grap (struct ship *, struct ship *);
|
||||
|
||||
/* 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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)pl_3.c 8.1 (Berkeley) 5/31/93";
|
||||
#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 /* not lint */
|
||||
|
||||
|
@ -203,7 +203,7 @@ acceptcombat(void)
|
|||
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("\t%d HULL, %d GUNS, %d CREW, %d RIGGING",
|
||||
|
|
|
@ -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
|
||||
|
@ -38,7 +38,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)pl_5.c 8.1 (Berkeley) 5/31/93";
|
||||
#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 /* 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 acceptboard(void);
|
||||
static void parties(int *, struct ship *, int, int);
|
||||
static void parties(struct ship *, int *, int, int);
|
||||
|
||||
void
|
||||
acceptmove(void)
|
||||
|
@ -194,16 +194,16 @@ acceptboard(void)
|
|||
if (meleeing(ms, sp) && crew[2]) {
|
||||
c = sgetch("How many more to board the $$? ",
|
||||
sp, 1);
|
||||
parties(crew, sp, 0, c);
|
||||
parties(sp, crew, 0, c);
|
||||
} else if ((fouled2(ms, sp) || grappled2(ms, sp)) && crew[2]) {
|
||||
c = sgetch("Crew sections to board the $$ (3 max) ?", sp, 1);
|
||||
parties(crew, sp, 0, c);
|
||||
parties(sp, crew, 0, c);
|
||||
}
|
||||
}
|
||||
if (crew[2]) {
|
||||
c = sgetch("How many sections to repel boarders? ",
|
||||
(struct ship *)0, 1);
|
||||
parties(crew, ms, 1, c);
|
||||
parties(ms, crew, 1, c);
|
||||
}
|
||||
blockalarm();
|
||||
draw_slot();
|
||||
|
@ -211,7 +211,7 @@ acceptboard(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;
|
||||
struct BP *ptr;
|
||||
|
|
Loading…
Reference in New Issue