2001-01-04 06:51:23 +03:00
|
|
|
/* $NetBSD: pl_7.c,v 1.19 2001/01/04 03:51:24 jwise Exp $ */
|
1995-04-22 14:36:43 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-04-22 14:36:43 +04:00
|
|
|
* Copyright (c) 1983, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 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
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef lint
|
1995-04-22 14:36:43 +04:00
|
|
|
#if 0
|
|
|
|
static char sccsid[] = "@(#)pl_7.c 8.1 (Berkeley) 5/31/93";
|
|
|
|
#else
|
2001-01-04 06:51:23 +03:00
|
|
|
__RCSID("$NetBSD: pl_7.c,v 1.19 2001/01/04 03:51:24 jwise Exp $");
|
1995-04-22 14:36:43 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
2001-01-04 06:51:23 +03:00
|
|
|
#include <signal.h>
|
1997-10-13 23:42:53 +04:00
|
|
|
#include <stdarg.h>
|
2001-01-04 06:21:16 +03:00
|
|
|
#include <stdio.h>
|
1997-10-13 23:42:53 +04:00
|
|
|
#include <unistd.h>
|
2001-01-04 06:21:16 +03:00
|
|
|
#include "player.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2001-01-04 05:43:32 +03:00
|
|
|
void initscreen(void);
|
|
|
|
void cleanupscreen(void);
|
|
|
|
void newturn(int);
|
|
|
|
void Signal(const char *, struct ship *, ...);
|
|
|
|
void Msg(const char *, ...);
|
|
|
|
static void Scroll(void);
|
|
|
|
void prompt(const char *, struct ship *);
|
|
|
|
static 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);
|
|
|
|
static void adjustview(void);
|
1995-04-22 14:36:43 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Display interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
static char sc_hasprompt;
|
Add use of `const' where appropriate to the games.
This merges in all such remaining changes from the Linux port of the
NetBSD games, except in hunt (where substantial changes from OpenBSD
need to be looked at).
Some such changes were previously covered in PRs bin/6041, bin/6146,
bin/6148, bin/6150, bin/6151, bin/6580, bin/6660, bin/7993, bin/7994,
bin/8039, bin/8057 and bin/8093.
1999-09-09 01:17:44 +04:00
|
|
|
static const char *sc_prompt;
|
|
|
|
static const char *sc_buf;
|
1993-03-21 12:45:37 +03:00
|
|
|
static int sc_line;
|
|
|
|
|
1999-12-28 21:05:24 +03:00
|
|
|
WINDOW *view_w;
|
|
|
|
WINDOW *slot_w;
|
|
|
|
WINDOW *scroll_w;
|
|
|
|
WINDOW *stat_w;
|
|
|
|
WINDOW *turn_w;
|
|
|
|
|
|
|
|
char done_curses;
|
|
|
|
char loaded, fired, changed, repaired;
|
|
|
|
char dont_adjust;
|
|
|
|
int viewrow, viewcol;
|
|
|
|
char movebuf[sizeof SHIP(0)->file->movebuf];
|
|
|
|
int player;
|
|
|
|
struct ship *ms; /* memorial structure, &cc->ship[player] */
|
|
|
|
struct File *mf; /* ms->file */
|
|
|
|
struct shipspecs *mc; /* ms->specs */
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
initscreen(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-01-31 14:08:53 +03:00
|
|
|
if (!SCREENTEST()) {
|
|
|
|
printf("Can't sail on this terminal.\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
/* initscr() already done in SCREENTEST() */
|
|
|
|
view_w = newwin(VIEW_Y, VIEW_X, VIEW_T, VIEW_L);
|
|
|
|
slot_w = newwin(SLOT_Y, SLOT_X, SLOT_T, SLOT_L);
|
|
|
|
scroll_w = newwin(SCROLL_Y, SCROLL_X, SCROLL_T, SCROLL_L);
|
|
|
|
stat_w = newwin(STAT_Y, STAT_X, STAT_T, STAT_L);
|
|
|
|
turn_w = newwin(TURN_Y, TURN_X, TURN_T, TURN_L);
|
|
|
|
done_curses++;
|
2001-01-02 00:57:37 +03:00
|
|
|
leaveok(view_w, 1);
|
|
|
|
leaveok(slot_w, 1);
|
|
|
|
leaveok(stat_w, 1);
|
|
|
|
leaveok(turn_w, 1);
|
1993-03-21 12:45:37 +03:00
|
|
|
noecho();
|
|
|
|
crmode();
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
cleanupscreen(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
/* alarm already turned off */
|
|
|
|
if (done_curses) {
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(scroll_w, SCROLL_Y - 1, 0);
|
|
|
|
wclrtoeol(scroll_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
draw_screen();
|
|
|
|
endwin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
/*ARGSUSED*/
|
1993-03-21 12:45:37 +03:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
newturn(int n __attribute__((__unused__)))
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
repaired = loaded = fired = changed = 0;
|
|
|
|
movebuf[0] = '\0';
|
|
|
|
|
2001-01-02 00:57:37 +03:00
|
|
|
alarm(0);
|
1998-08-30 13:19:36 +04:00
|
|
|
if (mf->readyL & R_LOADING) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mf->readyL & R_DOUBLE)
|
|
|
|
mf->readyL = R_LOADING;
|
|
|
|
else
|
|
|
|
mf->readyL = R_LOADED;
|
1998-08-30 13:19:36 +04:00
|
|
|
}
|
|
|
|
if (mf->readyR & R_LOADING) {
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mf->readyR & R_DOUBLE)
|
|
|
|
mf->readyR = R_LOADING;
|
|
|
|
else
|
|
|
|
mf->readyR = R_LOADED;
|
1998-08-30 13:19:36 +04:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!hasdriver)
|
1999-02-10 03:45:45 +03:00
|
|
|
Write(W_DDEAD, SHIP(0), 0, 0, 0, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (sc_hasprompt) {
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(scroll_w, sc_line, 0);
|
|
|
|
wclrtoeol(scroll_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
if (Sync() < 0)
|
|
|
|
leave(LEAVE_SYNC);
|
|
|
|
if (!hasdriver)
|
|
|
|
leave(LEAVE_DRIVER);
|
|
|
|
if (sc_hasprompt)
|
2001-01-02 00:57:37 +03:00
|
|
|
wprintw(scroll_w, "%s%s", sc_prompt, sc_buf);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (turn % 50 == 0)
|
1999-02-10 03:45:45 +03:00
|
|
|
Write(W_ALIVE, SHIP(0), 0, 0, 0, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mf->FS && (!mc->rig1 || windspeed == 6))
|
1999-02-10 03:45:45 +03:00
|
|
|
Write(W_FS, ms, 0, 0, 0, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mf->FS == 1)
|
1999-02-10 03:45:45 +03:00
|
|
|
Write(W_FS, ms, 2, 0, 0, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
if (mf->struck)
|
|
|
|
leave(LEAVE_QUIT);
|
|
|
|
if (mf->captured != 0)
|
|
|
|
leave(LEAVE_CAPTURED);
|
|
|
|
if (windspeed == 7)
|
|
|
|
leave(LEAVE_HURRICAN);
|
|
|
|
|
|
|
|
adjustview();
|
|
|
|
draw_screen();
|
|
|
|
|
2001-01-02 00:57:37 +03:00
|
|
|
signal(SIGALRM, newturn);
|
|
|
|
alarm(7);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*VARARGS2*/
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
|
|
|
Signal(const char *fmt, struct ship *ship, ...)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-13 23:42:53 +04:00
|
|
|
va_list ap;
|
|
|
|
char format[BUFSIZ];
|
|
|
|
|
|
|
|
va_start(ap, ship);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!done_curses)
|
|
|
|
return;
|
|
|
|
if (*fmt == '\7')
|
|
|
|
putchar(*fmt++);
|
1997-10-13 23:42:53 +04:00
|
|
|
fmtship(format, sizeof(format), fmt, ship);
|
2001-01-02 00:57:37 +03:00
|
|
|
vwprintw(scroll_w, format, ap);
|
1997-10-13 23:42:53 +04:00
|
|
|
va_end(ap);
|
1993-03-21 12:45:37 +03:00
|
|
|
Scroll();
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
/*VARARGS2*/
|
|
|
|
void
|
|
|
|
Msg(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
if (!done_curses)
|
|
|
|
return;
|
|
|
|
if (*fmt == '\7')
|
|
|
|
putchar(*fmt++);
|
2001-01-02 00:57:37 +03:00
|
|
|
vwprintw(scroll_w, fmt, ap);
|
1997-10-13 23:42:53 +04:00
|
|
|
va_end(ap);
|
|
|
|
Scroll();
|
|
|
|
}
|
|
|
|
|
2001-01-04 05:43:32 +03:00
|
|
|
static void
|
2001-01-02 00:57:37 +03:00
|
|
|
Scroll(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
if (++sc_line >= SCROLL_Y)
|
|
|
|
sc_line = 0;
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(scroll_w, sc_line, 0);
|
|
|
|
wclrtoeol(scroll_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-04 05:43:32 +03:00
|
|
|
prompt(const char *p, struct ship *ship)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-14 01:02:57 +04:00
|
|
|
static char buf[BUFSIZ];
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-14 01:02:57 +04:00
|
|
|
fmtship(buf, sizeof(buf), p, ship);
|
|
|
|
sc_prompt = buf;
|
1993-03-21 12:45:37 +03:00
|
|
|
sc_buf = "";
|
|
|
|
sc_hasprompt = 1;
|
2001-01-02 00:57:37 +03:00
|
|
|
waddstr(scroll_w, buf);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2001-01-04 05:43:32 +03:00
|
|
|
static void
|
2001-01-02 00:57:37 +03:00
|
|
|
endprompt(int flag)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
sc_hasprompt = 0;
|
|
|
|
if (flag)
|
|
|
|
Scroll();
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
int
|
2001-01-02 00:57:37 +03:00
|
|
|
sgetch(const char *p, struct ship *ship, int flag)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-13 23:42:53 +04:00
|
|
|
int c;
|
1993-03-21 12:45:37 +03:00
|
|
|
prompt(p, ship);
|
|
|
|
blockalarm();
|
2001-01-02 00:57:37 +03:00
|
|
|
wrefresh(scroll_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
unblockalarm();
|
|
|
|
while ((c = wgetch(scroll_w)) == EOF)
|
|
|
|
;
|
|
|
|
if (flag && c >= ' ' && c < 0x7f)
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(scroll_w, c);
|
1993-03-21 12:45:37 +03:00
|
|
|
endprompt(flag);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
sgetstr(const char *pr, char *buf, int n)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-13 23:42:53 +04:00
|
|
|
int c;
|
|
|
|
char *p = buf;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
prompt(pr, (struct ship *)0);
|
|
|
|
sc_buf = buf;
|
|
|
|
for (;;) {
|
|
|
|
*p = 0;
|
|
|
|
blockalarm();
|
2001-01-02 00:57:37 +03:00
|
|
|
wrefresh(scroll_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
unblockalarm();
|
|
|
|
while ((c = wgetch(scroll_w)) == EOF)
|
|
|
|
;
|
|
|
|
switch (c) {
|
|
|
|
case '\n':
|
|
|
|
case '\r':
|
|
|
|
endprompt(1);
|
|
|
|
return;
|
|
|
|
case '\b':
|
|
|
|
if (p > buf) {
|
2001-01-02 00:57:37 +03:00
|
|
|
waddstr(scroll_w, "\b \b");
|
1993-03-21 12:45:37 +03:00
|
|
|
p--;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (c >= ' ' && c < 0x7f && p < buf + n - 1) {
|
|
|
|
*p++ = c;
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(scroll_w, c);
|
1993-03-21 12:45:37 +03:00
|
|
|
} else
|
2001-01-02 00:57:37 +03:00
|
|
|
putchar('\a');
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
draw_screen(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
draw_view();
|
|
|
|
draw_turn();
|
|
|
|
draw_stat();
|
|
|
|
draw_slot();
|
2001-01-02 00:57:37 +03:00
|
|
|
wrefresh(scroll_w); /* move the cursor */
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
draw_view(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-13 23:42:53 +04:00
|
|
|
struct ship *sp;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2001-01-02 00:57:37 +03:00
|
|
|
werase(view_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
foreachship(sp) {
|
|
|
|
if (sp->file->dir
|
|
|
|
&& sp->file->row > viewrow
|
|
|
|
&& sp->file->row < viewrow + VIEW_Y
|
|
|
|
&& sp->file->col > viewcol
|
|
|
|
&& sp->file->col < viewcol + VIEW_X) {
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(view_w, sp->file->row - viewrow,
|
1993-03-21 12:45:37 +03:00
|
|
|
sp->file->col - viewcol);
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(view_w, colours(sp));
|
|
|
|
wmove(view_w,
|
1993-03-21 12:45:37 +03:00
|
|
|
sternrow(sp) - viewrow,
|
|
|
|
sterncol(sp) - viewcol);
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(view_w, sterncolour(sp));
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
2001-01-02 00:57:37 +03:00
|
|
|
wrefresh(view_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
draw_turn(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(turn_w, 0, 0);
|
|
|
|
wprintw(turn_w, "%cTurn %d", dont_adjust?'*':'-', turn);
|
|
|
|
wrefresh(turn_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
draw_stat(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(stat_w, STAT_1, 0);
|
|
|
|
wprintw(stat_w, "Points %3d\n", mf->points);
|
|
|
|
wprintw(stat_w, "Fouls %2d\n", fouled(ms));
|
|
|
|
wprintw(stat_w, "Grapples %2d\n", grappled(ms));
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(stat_w, STAT_2, 0);
|
|
|
|
wprintw(stat_w, " 0 %c(%c)\n",
|
1993-03-21 12:45:37 +03:00
|
|
|
maxmove(ms, winddir + 3, -1) + '0',
|
|
|
|
maxmove(ms, winddir + 3, 1) + '0');
|
2001-01-02 00:57:37 +03:00
|
|
|
waddstr(stat_w, " \\|/\n");
|
|
|
|
wprintw(stat_w, " -^-%c(%c)\n",
|
1993-03-21 12:45:37 +03:00
|
|
|
maxmove(ms, winddir + 2, -1) + '0',
|
|
|
|
maxmove(ms, winddir + 2, 1) + '0');
|
2001-01-02 00:57:37 +03:00
|
|
|
waddstr(stat_w, " /|\\\n");
|
|
|
|
wprintw(stat_w, " | %c(%c)\n",
|
1993-03-21 12:45:37 +03:00
|
|
|
maxmove(ms, winddir + 1, -1) + '0',
|
|
|
|
maxmove(ms, winddir + 1, 1) + '0');
|
2001-01-02 00:57:37 +03:00
|
|
|
wprintw(stat_w, " %c(%c)\n",
|
1993-03-21 12:45:37 +03:00
|
|
|
maxmove(ms, winddir, -1) + '0',
|
|
|
|
maxmove(ms, winddir, 1) + '0');
|
|
|
|
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(stat_w, STAT_3, 0);
|
|
|
|
wprintw(stat_w, "Load %c%c %c%c\n",
|
1993-03-21 12:45:37 +03:00
|
|
|
loadname[mf->loadL], readyname(mf->readyL),
|
|
|
|
loadname[mf->loadR], readyname(mf->readyR));
|
2001-01-02 00:57:37 +03:00
|
|
|
wprintw(stat_w, "Hull %2d\n", mc->hull);
|
|
|
|
wprintw(stat_w, "Crew %2d %2d %2d\n",
|
1993-03-21 12:45:37 +03:00
|
|
|
mc->crew1, mc->crew2, mc->crew3);
|
2001-01-02 00:57:37 +03:00
|
|
|
wprintw(stat_w, "Guns %2d %2d\n", mc->gunL, mc->gunR);
|
|
|
|
wprintw(stat_w, "Carr %2d %2d\n", mc->carL, mc->carR);
|
|
|
|
wprintw(stat_w, "Rigg %d %d %d ", mc->rig1, mc->rig2, mc->rig3);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mc->rig4 < 0)
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(stat_w, '-');
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
2001-01-02 00:57:37 +03:00
|
|
|
wprintw(stat_w, "%d", mc->rig4);
|
|
|
|
wrefresh(stat_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
draw_slot(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
if (!boarding(ms, 0)) {
|
2001-01-02 00:57:37 +03:00
|
|
|
mvwaddstr(slot_w, 0, 0, " ");
|
|
|
|
mvwaddstr(slot_w, 1, 0, " ");
|
1993-03-21 12:45:37 +03:00
|
|
|
} else
|
2001-01-02 00:57:37 +03:00
|
|
|
mvwaddstr(slot_w, 1, 0, "OBP");
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!boarding(ms, 1)) {
|
2001-01-02 00:57:37 +03:00
|
|
|
mvwaddstr(slot_w, 2, 0, " ");
|
|
|
|
mvwaddstr(slot_w, 3, 0, " ");
|
1993-03-21 12:45:37 +03:00
|
|
|
} else
|
2001-01-02 00:57:37 +03:00
|
|
|
mvwaddstr(slot_w, 3, 0, "DBP");
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(slot_w, SLOT_Y-4, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mf->RH)
|
2001-01-02 00:57:37 +03:00
|
|
|
wprintw(slot_w, "%dRH", mf->RH);
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
2001-01-02 00:57:37 +03:00
|
|
|
waddstr(slot_w, " ");
|
|
|
|
wmove(slot_w, SLOT_Y-3, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mf->RG)
|
2001-01-02 00:57:37 +03:00
|
|
|
wprintw(slot_w, "%dRG", mf->RG);
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
2001-01-02 00:57:37 +03:00
|
|
|
waddstr(slot_w, " ");
|
|
|
|
wmove(slot_w, SLOT_Y-2, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
if (mf->RR)
|
2001-01-02 00:57:37 +03:00
|
|
|
wprintw(slot_w, "%dRR", mf->RR);
|
1993-03-21 12:45:37 +03:00
|
|
|
else
|
2001-01-02 00:57:37 +03:00
|
|
|
waddstr(slot_w, " ");
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define Y (SLOT_Y/2)
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(slot_w, 7, 1);
|
|
|
|
wprintw(slot_w,"%d", windspeed);
|
|
|
|
mvwaddch(slot_w, Y, 0, ' ');
|
|
|
|
mvwaddch(slot_w, Y, 2, ' ');
|
|
|
|
mvwaddch(slot_w, Y-1, 0, ' ');
|
|
|
|
mvwaddch(slot_w, Y-1, 1, ' ');
|
|
|
|
mvwaddch(slot_w, Y-1, 2, ' ');
|
|
|
|
mvwaddch(slot_w, Y+1, 0, ' ');
|
|
|
|
mvwaddch(slot_w, Y+1, 1, ' ');
|
|
|
|
mvwaddch(slot_w, Y+1, 2, ' ');
|
|
|
|
wmove(slot_w, Y - dr[winddir], 1 - dc[winddir]);
|
1993-03-21 12:45:37 +03:00
|
|
|
switch (winddir) {
|
|
|
|
case 1:
|
|
|
|
case 5:
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(slot_w, '|');
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
case 6:
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(slot_w, '/');
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
case 7:
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(slot_w, '-');
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
case 8:
|
2001-01-02 00:57:37 +03:00
|
|
|
waddch(slot_w, '\\');
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
|
|
|
}
|
2001-01-02 00:57:37 +03:00
|
|
|
mvwaddch(slot_w, Y + dr[winddir], 1 + dc[winddir], '+');
|
|
|
|
wrefresh(slot_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
draw_board(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-13 23:42:53 +04:00
|
|
|
int n;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2001-01-02 00:57:37 +03:00
|
|
|
clear();
|
|
|
|
werase(view_w);
|
|
|
|
werase(slot_w);
|
|
|
|
werase(scroll_w);
|
|
|
|
werase(stat_w);
|
|
|
|
werase(turn_w);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
sc_line = 0;
|
|
|
|
|
2001-01-02 00:57:37 +03:00
|
|
|
move(BOX_T, BOX_L);
|
1993-03-21 12:45:37 +03:00
|
|
|
for (n = 0; n < BOX_X; n++)
|
2001-01-02 00:57:37 +03:00
|
|
|
addch('-');
|
|
|
|
move(BOX_B, BOX_L);
|
1993-03-21 12:45:37 +03:00
|
|
|
for (n = 0; n < BOX_X; n++)
|
2001-01-02 00:57:37 +03:00
|
|
|
addch('-');
|
1993-03-21 12:45:37 +03:00
|
|
|
for (n = BOX_T+1; n < BOX_B; n++) {
|
2001-01-02 00:57:37 +03:00
|
|
|
mvaddch(n, BOX_L, '|');
|
|
|
|
mvaddch(n, BOX_R, '|');
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2001-01-02 00:57:37 +03:00
|
|
|
mvaddch(BOX_T, BOX_L, '+');
|
|
|
|
mvaddch(BOX_T, BOX_R, '+');
|
|
|
|
mvaddch(BOX_B, BOX_L, '+');
|
|
|
|
mvaddch(BOX_B, BOX_R, '+');
|
|
|
|
refresh();
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define WSaIM "Wooden Ships & Iron Men"
|
2001-01-02 00:57:37 +03:00
|
|
|
wmove(view_w, 2, (VIEW_X - sizeof WSaIM - 1) / 2);
|
|
|
|
waddstr(view_w, WSaIM);
|
|
|
|
wmove(view_w, 4, (VIEW_X - strlen(cc->name)) / 2);
|
|
|
|
waddstr(view_w, cc->name);
|
|
|
|
wrefresh(view_w);
|
|
|
|
|
|
|
|
move(LINE_T, LINE_L);
|
|
|
|
printw("Class %d %s (%d guns) '%s' (%c%c)",
|
1993-03-21 12:45:37 +03:00
|
|
|
mc->class,
|
|
|
|
classname[mc->class],
|
|
|
|
mc->guns,
|
|
|
|
ms->shipname,
|
|
|
|
colours(ms),
|
|
|
|
sterncolour(ms));
|
2001-01-02 00:57:37 +03:00
|
|
|
refresh();
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
centerview(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
viewrow = mf->row - VIEW_Y / 2;
|
|
|
|
viewcol = mf->col - VIEW_X / 2;
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
upview(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
viewrow -= VIEW_Y / 3;
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
downview(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
viewrow += VIEW_Y / 3;
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
leftview(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
viewcol -= VIEW_X / 5;
|
|
|
|
}
|
|
|
|
|
1997-10-13 23:42:53 +04:00
|
|
|
void
|
2001-01-02 00:57:37 +03:00
|
|
|
rightview(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
viewcol += VIEW_X / 5;
|
|
|
|
}
|
|
|
|
|
2001-01-04 05:43:32 +03:00
|
|
|
static void
|
2001-01-02 00:57:37 +03:00
|
|
|
adjustview(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
if (dont_adjust)
|
|
|
|
return;
|
|
|
|
if (mf->row < viewrow + VIEW_Y/4)
|
|
|
|
viewrow = mf->row - (VIEW_Y - VIEW_Y/4);
|
|
|
|
else if (mf->row > viewrow + (VIEW_Y - VIEW_Y/4))
|
|
|
|
viewrow = mf->row - VIEW_Y/4;
|
|
|
|
if (mf->col < viewcol + VIEW_X/8)
|
|
|
|
viewcol = mf->col - (VIEW_X - VIEW_X/8);
|
|
|
|
else if (mf->col > viewcol + (VIEW_X - VIEW_X/8))
|
|
|
|
viewcol = mf->col - VIEW_X/8;
|
|
|
|
}
|