|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 5228 (0x146c)
Types: TextFile
Names: »plot.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Vtrek/plot.c«
/* plot.c -- plot routines for visual star trek */
#include "vtrek.h"
#ifdef BSD
#include <strings.h>
#else
#include <string.h>
#endif
/* replot screen */
replot()
{
clear ();
plt_stat(ALL, 0);
plt_srs(ALL, 0, 0);
plt_dam(ALL, 0);
plt_gal(ALL, 0, 0);
mvaddstr (11, 17, "READOUT");
mvaddstr (12, 17, "-------");
plt_num(ALL);
}
/* plot status (upper left) */
plt_stat(op, item)
int op, item;
{
static char *text[9] = {
" Status", " ------", "Stardate :",
"Condition :", "Quadrant :", "Sector :",
"Energy :", "Photon torps :", "Shields :"
};
static char *ctext[4] = {
"Green", "Yellow", "Red", "Docked"
};
int i, high, low;
if (op & TEXT)
for (i = 0; i < 9; i++)
mvaddstr (i + 1, 0, text[i]);
if (op & (INFO | ELEMENT)) {
if (op & INFO) {
low = STARDATE;
high = SHIELDS;
}
else {
low = item;
high = item;
}
for (i = low; i <= high; i++) {
switch (i) {
case STARDATE :
(void) mvprintw (3, 15, "%-.1f", stardate);
break;
case CONDITION :
(void) mvprintw (4, 15, "%-6s", ctext[condition]);
break;
case QUADRANT :
(void) mvprintw (5, 15, "[%d,%d]", xquad + 1, yquad + 1);
break;
case SECTOR :
(void) mvprintw (6, 15, "[%d,%d]", xsect + 1, ysect + 1);
break;
case ENERGY :
(void) mvprintw (7, 15, "%-4d", energy);
break;
case TORPS :
(void) mvprintw (8, 15, "%-2d", torps);
break;
case SHIELDS :
(void) mvprintw (9, 15, "%-4d", shields);
break;
}
}
}
}
/* plot short range scan */
plt_srs(op, xs, ys)
int op, xs, ys;
{
static char *htext = "-1--2--3--4--5--6--7--8-";
static char *stext[6] = {
" ", "<K>", "<S>", " * ", "???", " + "
};
int i, j;
if (op & TEXT) {
mvaddstr (0, 27, htext);
for (i = 1; i < 9; i++) {
(void) mvprintw (i, 26, "%d", i);
(void) mvprintw (i, 51, "%d", i);
}
mvaddstr (9, 27, htext);
}
(void) strcpy(stext[PLAYER], playership);
if (op & INFO) {
for (i = 0; i < 8; i++) {
move (i + 1, 27);
for (j = 0; j < 8; j++)
(void) printw ("%s", stext[(damage[SRS] <= 0) ? EMPTY : quadrant[j][i]]);
}
}
else if (op & ELEMENT) {
(void) mvprintw (ys + 1, 27 + 3 * xs, "%s", stext[(damage[SRS] <= 0) ? EMPTY : quadrant[xs][ys]]);
}
}
/* plot damage info */
plt_dam(op, item)
int op, item;
{
static char *text[10] = {
" Damage Report", " -------------",
"Warp engines :", "S.R. sensors :", "L.R. sensors :",
"Phaser control :", "Damage control :", "Defense control :",
"Computer :", "Photon tubes :"
};
int i;
if (op & TEXT)
for (i = 0; i < 10; i++)
mvaddstr (i, 55, text[i]);
if (op & INFO)
for (i = 0; i < 8; i++) {
move (i + 2, 73);
if (damage[DAMAGE] <= 0)
(void) printw (" ");
else
(void) printw ("%4d", damage[i]);
}
else if (op & ELEMENT) {
move (item + 2, 73);
if (damage[DAMAGE] <= 0)
(void) printw (" ");
else
(void) printw ("%4d", damage[item]);
}
}
/* plot galaxy map */
plt_gal(op, xq, yq)
int op, xq, yq;
{
static char *htext = "-1- -2- -3- -4- -5- -6- -7- -8-";
int i, j, fedquad;
if (op & TEXT) {
mvaddstr (12, 46, htext);
for (i = 1; i < 9; i++) {
(void) mvprintw (i + 12, 44, "%d:", i);
for (j = 0; j < 7; j++)
mvaddch (i + 12, 49 + (j << 2), ':');
(void) mvprintw (i + 12, 77, ":%d", i);
}
mvaddstr (21, 46, htext);
}
if (op & INFO) {
for (i = 0; i < 8; i++)
for (j = 0; j < 8; j++) {
move (i + 13, 46 + (j << 2));
if (damage[COMPUTER] <= 0 || !galaxy[j][i].known)
(void) printw (" ");
else
(void) printw ("%01d%01d%01d", galaxy[j][i].nkling, galaxy[j][i].nbase,
galaxy[j][i].nstar);
}
mvaddch (yquad + 13, 45 + (xquad << 2), '[');
mvaddch (yquad + 13, 49 + (xquad << 2), ']');
}
else if (op & ELEMENT) {
move (yq + 13, 45 + (xq << 2));
fedquad = (xq == xquad && yq == yquad);
addch (fedquad ? '[' : ':');
if (damage[COMPUTER] <= 0)
(void) printw (" ");
else
(void) printw ("%01d%01d%01d", galaxy[xq][yq].nkling, galaxy[xq][yq].nbase, galaxy[xq][yq].nstar);
addch (fedquad ? ']' : ':');
}
}
/* plot number of star bases & klingons */
plt_num(op)
int op;
{
float kf;
if (op & TEXT) {
mvaddstr (22, 46, "Base stars = ");
mvaddstr (22, 62, "Klingons = ");
mvaddstr (23, 53, "Kill Factor = ");
}
if (op & INFO) {
(void) mvprintw (22, 58, " %d", numbases);
(void) mvprintw (22, 72, " %d/%d ", numkling, begkling);
move (23, 67);
if (begdate != stardate)
kf = (begkling - numkling) / (stardate - begdate);
else
kf = 0.0;
(void) printw ("%5.3f ", kf);
}
}
/* change readout */
readout(op, str)
int op;
char *str;
{
int i, j;
switch (op) {
case CLEAR : /* clear readout */
for (i = 14; i <= 13 + rolines; i++) {
move (i-1, 0);
for (j = 0; j < 44; j++)
addch (' ');
}
rolines = 0;
break;
case ADDLINE : /* add line to readout */
if (rolines >= 10)
readout(CLEAR, (char *) 0);
(void) mvprintw (13 + rolines, 0, "%-.44s", str);
rolines++;
break;
}
}