-/* $NetBSD: extern.h,v 1.15 2000/11/30 21:50:58 jwise Exp $ */
+/* $NetBSD: extern.h,v 1.34 2009/03/15 03:33:56 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* @(#)externs.h 8.1 (Berkeley) 5/31/93
*/
-#include <stdio.h>
-#include <signal.h>
-#include <string.h>
-#include <ctype.h>
-#include <setjmp.h>
#include <sys/types.h>
+#include <stdbool.h>
+
#include "machdep.h"
/* program mode */
extern int mode;
-extern jmp_buf restart;
#define MODE_PLAYER 1
#define MODE_DRIVER 2
#define MODE_LOGGER 3
/* command line flags */
-extern char debug; /* -D */
-extern char randomize; /* -x, give first available ship */
-extern char longfmt; /* -l, print score in long format */
-extern char nobells; /* -b, don't ring bell before Signal */
+extern int randomize; /* -x, give first available ship */
+extern int longfmt; /* -l, print score in long format */
+extern int nobells; /* -b, don't ring bell before Signal */
/* other initial modes */
extern gid_t gid;
extern gid_t egid;
-#define die() ((rand() >> 3) % 6 + 1)
+#define dieroll() ((random()) % 6 + 1)
#define sqr(a) ((a) * (a))
-#define abs(a) ((a) > 0 ? (a) : -(a))
#define min(a,b) ((a) < (b) ? (a) : (b))
#define grappled(a) ((a)->file->ngrap)
#define fouled2(a, b) ((a)->file->foul[(b)->file->index].sn_count)
#define snagged2(a, b) (grappled2(a, b) + fouled2(a, b))
-#define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 ? grappled2(a, b) : 0)
-#define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 ? fouled2(a, b) : 0)
+#define Xgrappled2(a, b) ((a)->file->grap[(b)->file->index].sn_turn < turn-1 \
+ ? grappled2(a, b) : 0)
+#define Xfouled2(a, b) ((a)->file->foul[(b)->file->index].sn_turn < turn-1 \
+ ? fouled2(a, b) : 0)
#define Xsnagged2(a, b) (Xgrappled2(a, b) + Xfouled2(a, b))
#define cleangrapple(a, b, c) Cleansnag(a, b, c, 1)
#define cleanfoul(a, b, c) Cleansnag(a, b, c, 2)
#define cleansnag(a, b, c) Cleansnag(a, b, c, 3)
-#define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured?10:0))
+#define sterncolour(sp) ((sp)->file->stern+'0'-((sp)->file->captured ? 10 : 0))
#define sternrow(sp) ((sp)->file->row + dr[(sp)->file->dir])
#define sterncol(sp) ((sp)->file->col + dc[(sp)->file->dir])
#define HULL 0
#define RIGGING 1
-#define W_CAPTAIN 1
-#define W_CAPTURED 2
-#define W_CLASS 3
-#define W_CREW 4
-#define W_DBP 5
-#define W_DRIFT 6
-#define W_EXPLODE 7
-#define W_FILE 8
-#define W_FOUL 9
-#define W_GUNL 10
-#define W_GUNR 11
-#define W_HULL 12
-#define W_MOVE 13
-#define W_OBP 14
-#define W_PCREW 15
-#define W_UNFOUL 16
-#define W_POINTS 17
-#define W_QUAL 18
-#define W_UNGRAP 19
-#define W_RIGG 20
-#define W_COL 21
-#define W_DIR 22
-#define W_ROW 23
-#define W_SIGNAL 24
-#define W_SINK 25
-#define W_STRUCK 26
-#define W_TA 27
-#define W_ALIVE 28
-#define W_TURN 29
-#define W_WIND 30
-#define W_FS 31
-#define W_GRAP 32
-#define W_RIG1 33
-#define W_RIG2 34
-#define W_RIG3 35
-#define W_RIG4 36
-#define W_BEGIN 37
-#define W_END 38
-#define W_DDEAD 39
-
#define NLOG 10
struct logs {
char l_name[20];
};
struct BP {
- short turnsent;
struct ship *toship;
+ short turnsent;
short mensent;
};
extern int game;
extern int alive;
extern int people;
-extern char hasdriver;
+extern int hasdriver;
/* assorted.c */
-void table (int, int, int, struct ship *, struct ship *, int);
-void Cleansnag (struct ship *, struct ship *, int, int);
+void table(struct ship *, struct ship *, int, int, int, int);
+void Cleansnag(struct ship *, struct ship *, int, int);
/* dr_1.c */
-void unfoul (void);
-void boardcomp (void);
-int fightitout (struct ship *, struct ship *, int);
-void resolve (void);
-void compcombat (void);
-int next (void);
+void unfoul(void);
+void boardcomp(void);
+void resolve(void);
+void compcombat(void);
+int next(void);
/* dr_2.c */
-void thinkofgrapples (void);
-void checkup (void);
-void prizecheck (void);
-int str_end (const char *);
-void closeon (struct ship *, struct ship *, char[], int, int, int);
-int score (char[], struct ship *, struct ship *, int);
-void move_ship (const char *, struct ship *, unsigned char *, short *, short *, char *);
-void try (char[], char [], int, int, int, int, int, struct ship *,
- struct ship *, int *, int);
-void rmend (char *);
+void thinkofgrapples(void);
+void checkup(void);
+void prizecheck(void);
+void closeon(struct ship *, struct ship *, char *, size_t, int, int, bool);
/* dr_3.c */
-void moveall (void);
-int stillmoving (int);
-int is_isolated (struct ship *);
-int push (struct ship *, struct ship *);
-void step (int, struct ship *, char *);
-void sendbp (struct ship *, struct ship *, int, int);
-int is_toughmelee (struct ship *, struct ship *, int, int);
-void reload (void);
-void checksails (void);
+void moveall(void);
+void sendbp(struct ship *, struct ship *, int, int);
+int is_toughmelee(struct ship *, struct ship *, int, int);
+void reload(void);
+void checksails(void);
/* dr_4.c */
-void ungrap (struct ship *, struct ship *);
-void grap (struct ship *, struct ship *);
+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);
-int mensent (struct ship *, struct ship *, int[3], struct ship **, int *,
- int);
+void subtract(struct ship *, struct ship *, int, int [3], int);
+int mensent(struct ship *, struct ship *, int[3], struct ship **, int *, int);
/* dr_main.c */
-int dr_main (void);
+int dr_main(void);
/* game.c */
-int maxturns (struct ship *, char *);
-int maxmove (struct ship *, int, int);
+int maxturns(struct ship *, bool *);
+int maxmove(struct ship *, int, int);
/* lo_main.c */
-int lo_main (void);
+int lo_main(void);
/* misc.c */
-int range (struct ship *, struct ship *);
-struct ship *closestenemy (struct ship *, int, int);
-int angle (int, int);
-int gunsbear (struct ship *, struct ship *);
-int portside (struct ship *, struct ship *, int);
-int colours (struct ship *);
-void logger (struct ship *);
+int range(struct ship *, struct ship *);
+struct ship *closestenemy(struct ship *, int, int);
+int gunsbear(struct ship *, struct ship *);
+int portside(struct ship *, struct ship *, int);
+int colours(struct ship *);
+void logger(struct ship *);
/* parties.c */
-int meleeing (struct ship *, struct ship *);
-int boarding (struct ship *, int);
-void unboard (struct ship *, struct ship *, int);
+int meleeing(struct ship *, struct ship *);
+int boarding(struct ship *, int);
+void unboard(struct ship *, struct ship *, int);
/* pl_1.c */
-void leave (int) __attribute__((__noreturn__));
-void choke (int) __attribute__((__noreturn__));
-void child (int);
+void leave(int) __attribute__((__noreturn__));
+void choke(int) __attribute__((__noreturn__));
+void child(int);
/* pl_2.c */
-void play (void) __attribute__((__noreturn__));
+void newturn(int);
+void play(void) __attribute__((__noreturn__));
/* pl_3.c */
-void acceptcombat (void);
-void grapungrap (void);
-void unfoulplayer (void);
+void acceptcombat(void);
+void grapungrap(void);
+void unfoulplayer(void);
/* pl_4.c */
-void changesail (void);
-void acceptsignal (void);
-void lookout (void);
-const char *saywhat (struct ship *, int);
-void eyeball (struct ship *);
+void changesail(void);
+void acceptsignal(void);
+void lookout(void);
+const char *saywhat(struct ship *, int);
+void eyeball(struct ship *);
/* pl_5.c */
-void acceptmove (void);
-void acceptboard (void);
-void parties (int[3], struct ship *, int, int);
+void acceptmove(void);
+void acceptboard(void);
/* pl_6.c */
-void repair (void);
-int turned (void);
-void loadplayer (void);
+void repair(void);
+void loadplayer(void);
/* pl_7.c */
-void initscreen (void);
-void cleanupscreen (void);
-void newturn (int);
-void Signal (const char *, struct ship *, ...)
+void initscreen(void);
+void cleanupscreen(void);
+void Signal(const char *, struct ship *, ...)
__attribute__((__format__(__printf__,1,3)));
-void Msg (const char *, ...)
+void Msg(const char *, ...)
__attribute__((__format__(__printf__,1,2)));
-void Scroll (void);
-void prompt (const char *, struct ship *);
-void endprompt (int);
-int sgetch (const char *, struct ship *, int);
-void sgetstr (const char *, char *, int);
-void draw_screen (void);
-void draw_view (void);
-void draw_turn (void);
-void draw_stat (void);
-void draw_slot (void);
-void draw_board (void);
-void centerview (void);
-void upview (void);
-void downview (void);
-void leftview (void);
-void rightview (void);
-void adjustview (void);
+void prompt(const char *, struct ship *);
+int sgetch(const char *, struct ship *, int);
+void sgetstr(const char *, char *, int);
+void centerview(void);
+void upview(void);
+void downview(void);
+void leftview(void);
+void rightview(void);
/* pl_main.c */
-int pl_main (void);
-void initialize (void);
+int pl_main(void);
/* sync.c */
-void fmtship (char *, size_t, const char *, struct ship *);
-void makesignal (struct ship *, const char *, struct ship *, ...)
+void fmtship(char *, size_t, const char *, struct ship *);
+void makesignal(struct ship *, const char *, struct ship *, ...)
__attribute__((__format__(__printf__,2,4)));
-void makemsg (struct ship *, const char *, ...)
+void makemsg(struct ship *, const char *, ...)
__attribute__((__format__(__printf__,2,3)));
-int sync_exists (int);
-int sync_open (void);
-void sync_close (int);
-void Write (int, struct ship *, long, long, long, long);
-void Writestr (int, struct ship *, const char *);
-int Sync (void);
-int sync_update (int, struct ship *, const char *, long, long, long, long);
+int sync_exists(int);
+int sync_open(void);
+void sync_close(int);
+int Sync(void);
+
+void send_captain(struct ship *ship, const char *astr);
+void send_captured(struct ship *ship, long a);
+void send_class(struct ship *ship, long a);
+void send_crew(struct ship *ship, long a, long b, long c);
+void send_dbp(struct ship *ship, long a, long b, long c, long d);
+void send_drift(struct ship *ship, long a);
+void send_explode(struct ship *ship, long a);
+void send_foul(struct ship *ship, long a);
+void send_gunl(struct ship *ship, long a, long b);
+void send_gunr(struct ship *ship, long a, long b);
+void send_hull(struct ship *ship, long a);
+void send_move(struct ship *ship, const char *astr);
+void send_obp(struct ship *ship, long a, long b, long c, long d);
+void send_pcrew(struct ship *ship, long a);
+void send_unfoul(struct ship *ship, long a, long b);
+void send_points(struct ship *ship, long a);
+void send_qual(struct ship *ship, long a);
+void send_ungrap(struct ship *ship, long a, long b);
+void send_rigg(struct ship *ship, long a, long b, long c, long d);
+void send_col(struct ship *ship, long a);
+void send_dir(struct ship *ship, long a);
+void send_row(struct ship *ship, long a);
+void send_signal(struct ship *ship, const char *astr);
+void send_sink(struct ship *ship, long a);
+void send_struck(struct ship *ship, long a);
+void send_ta(struct ship *ship, long a);
+void send_alive(void);
+void send_turn(long a);
+void send_wind(long a, long b);
+void send_fs(struct ship *ship, long a);
+void send_grap(struct ship *ship, long a);
+void send_rig1(struct ship *ship, long a);
+void send_rig2(struct ship *ship, long a);
+void send_rig3(struct ship *ship, long a);
+void send_rig4(struct ship *ship, long a);
+void send_begin(struct ship *ship);
+void send_end(struct ship *ship);
+void send_ddead(void);