projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
printfs have been banished. All outputnow goes through prout/proutn/prouts.
[super-star-trek.git]
/
sst.c
diff --git
a/sst.c
b/sst.c
index 2c888443c27eeaf4c6b943d71442fee786e68ecb..af932a0dbcb000c7e1e3ba7f260ece91f3cda2bc 100644
(file)
--- a/
sst.c
+++ b/
sst.c
@@
-1,6
+1,7
@@
#define INCLUDED // Define externs here
\r
#include "sst.h"
\r
#include <ctype.h>
\r
#define INCLUDED // Define externs here
\r
#include "sst.h"
\r
#include <ctype.h>
\r
+#include <stdarg.h>
\r
#ifdef MSDOS
\r
#include <dos.h>
\r
#endif
\r
#ifdef MSDOS
\r
#include <dos.h>
\r
#endif
\r
@@
-13,8
+14,6
@@
static int linecount; /* for paging */
\r
static void clearscreen(void);
\r
\r
\r
static void clearscreen(void);
\r
\r
-#define NUMCOMMANDS 34
\r
-
\r
/* Compared to original version, I've changed the "help" command to
\r
"call" and the "terminate" command to "quit" to better match
\r
user expectations. The DECUS version apparently made those changes
\r
/* Compared to original version, I've changed the "help" command to
\r
"call" and the "terminate" command to "quit" to better match
\r
user expectations. The DECUS version apparently made those changes
\r
@@
-52,7
+51,7
@@
static void clearscreen(void);
*/
\r
\r
\r
*/
\r
\r
\r
-static char *commands[
NUMCOMMANDS
] = {
\r
+static char *commands[] = {
\r
"srscan",
\r
"lrscan",
\r
"phasers",
\r
"srscan",
\r
"lrscan",
\r
"phasers",
\r
@@
-88,6
+87,7
@@
static char *commands[NUMCOMMANDS] = {
"quit",
\r
"help"
\r
};
\r
"quit",
\r
"help"
\r
};
\r
+#define NUMCOMMANDS sizeof(commands)/sizeof(commands[0])
\r
\r
static void listCommands(int x) {
\r
prout(" SRSCAN MOVE PHASERS CALL\n"
\r
\r
static void listCommands(int x) {
\r
prout(" SRSCAN MOVE PHASERS CALL\n"
\r
@@
-210,7
+210,7
@@
static void makemoves(void) {
warp(1);
\r
break;
\r
case 5: // shields
\r
warp(1);
\r
break;
\r
case 5: // shields
\r
-
shei
ld(1);
\r
+
doshie
ld(1);
\r
if (ididit) {
\r
attack(2);
\r
shldchg = 0;
\r
if (ididit) {
\r
attack(2);
\r
shldchg = 0;
\r
@@
-324,7
+324,7
@@
static void makemoves(void) {
events();
\r
if (alldone) break; // Events did us in
\r
}
\r
events();
\r
if (alldone) break; // Events did us in
\r
}
\r
- if (
d
.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!
\r
+ if (
game.state
.galaxy[quadx][quady] == 1000) { // Galaxy went Nova!
\r
atover(0);
\r
continue;
\r
}
\r
atover(0);
\r
continue;
\r
}
\r
@@
-332,7
+332,7
@@
static void makemoves(void) {
if (hitme && justin==0) {
\r
attack(2);
\r
if (alldone) break;
\r
if (hitme && justin==0) {
\r
attack(2);
\r
if (alldone) break;
\r
- if (
d.galaxy[quadx][quady] == 1000) {
// went NOVA!
\r
+ if (
game.state.galaxy[quadx][quady] == 1000) {
// went NOVA!
\r
atover(0);
\r
hitme = TRUE;
\r
continue;
\r
atover(0);
\r
hitme = TRUE;
\r
continue;
\r
@@
-345,7
+345,7
@@
static void makemoves(void) {
}
\r
\r
\r
}
\r
\r
\r
-
void
main(int argc, char **argv) {
\r
+
int
main(int argc, char **argv) {
\r
int i;
\r
int hitme;
\r
char ch;
\r
int i;
\r
int hitme;
\r
char ch;
\r
@@
-374,13
+374,13
@@
void main(int argc, char **argv) {
skip(1);
\r
\r
if (tourn && alldone) {
\r
skip(1);
\r
\r
if (tourn && alldone) {
\r
- pr
intf
("Do you want your score recorded?");
\r
+ pr
outn
("Do you want your score recorded?");
\r
if (ja()) {
\r
chew2();
\r
freeze(FALSE);
\r
}
\r
}
\r
if (ja()) {
\r
chew2();
\r
freeze(FALSE);
\r
}
\r
}
\r
- pr
intf
("Do you want to play again?");
\r
+ pr
outn
("Do you want to play again?");
\r
if (!ja()) break;
\r
}
\r
skip(1);
\r
if (!ja()) break;
\r
}
\r
skip(1);
\r
@@
-401,8
+401,8
@@
void cramen(int i) {
case IHP: s = "Planet"; break;
\r
case IHB: s = "Starbase"; break;
\r
case IHBLANK: s = "Black hole"; break;
\r
case IHP: s = "Planet"; break;
\r
case IHB: s = "Starbase"; break;
\r
case IHBLANK: s = "Black hole"; break;
\r
- case IHT: s = "Thol
e
an"; break;
\r
- case IHWEB: s = "Thol
e
an web"; break;
\r
+ case IHT: s = "Thol
i
an"; break;
\r
+ case IHWEB: s = "Thol
i
an web"; break;
\r
default: s = "Unknown??"; break;
\r
}
\r
proutn(s);
\r
default: s = "Unknown??"; break;
\r
}
\r
proutn(s);
\r
@@
-411,10
+411,7
@@
void cramen(int i) {
void cramlc(int key, int x, int y) {
\r
if (key == 1) proutn(" Quadrant");
\r
else if (key == 2) proutn(" Sector");
\r
void cramlc(int key, int x, int y) {
\r
if (key == 1) proutn(" Quadrant");
\r
else if (key == 2) proutn(" Sector");
\r
- proutn(" ");
\r
- crami(x, 1);
\r
- proutn(" - ");
\r
- crami(y, 1);
\r
+ proutn(" %d - %d", x, y);
\r
}
\r
\r
void crmena(int i, int enemy, int key, int x, int y) {
\r
}
\r
\r
void crmena(int i, int enemy, int key, int x, int y) {
\r
@@
-486,7
+483,8
@@
int scan(void) {
chew();
\r
return IHEOL;
\r
}
\r
chew();
\r
return IHEOL;
\r
}
\r
- gets(line);
\r
+ fgets(line, sizeof(line), stdin);
\r
+ line[strlen(line)-1] = '\0';
\r
linep = line;
\r
}
\r
// Skip leading white space
\r
linep = line;
\r
}
\r
// Skip leading white space
\r
@@
-536,12
+534,6
@@
void cramf(double x, int w, int d) {
proutn(buf);
\r
}
\r
\r
proutn(buf);
\r
}
\r
\r
-void crami(int i, int w) {
\r
- char buf[16];
\r
- sprintf(buf, "%*d", w, i);
\r
- proutn(buf);
\r
-}
\r
-
\r
double square(double i) { return i*i; }
\r
\r
static void clearscreen(void) {
\r
double square(double i) { return i*i; }
\r
\r
static void clearscreen(void) {
\r
@@
-591,22
+583,34
@@
void skip(int i) {
}
\r
\r
\r
}
\r
\r
\r
-void proutn(char *s) {
\r
- fputs(s, stdout);
\r
+void proutn(char *fmt, ...) {
\r
+ va_list ap;
\r
+ va_start(ap, fmt);
\r
+ vprintf(fmt, ap);
\r
+ va_end(ap);
\r
}
\r
\r
}
\r
\r
-void prout(char *s) {
\r
- proutn(s);
\r
- skip(1);
\r
+void prout(char *fmt, ...) {
\r
+ va_list ap;
\r
+ va_start(ap, fmt);
\r
+ vprintf(fmt, ap);
\r
+ va_end(ap);
\r
+ skip(1);
\r
}
\r
\r
}
\r
\r
-void prouts(char *
s
) {
\r
+void prouts(char *
fmt, ...
) {
\r
clock_t endTime;
\r
clock_t endTime;
\r
+ char *s, buf[BUFSIZ];
\r
/* print slowly! */
\r
/* print slowly! */
\r
- while (*s) {
\r
+ va_list ap;
\r
+ va_start(ap, fmt);
\r
+ vsprintf(buf, fmt, ap);
\r
+ va_end(ap);
\r
+ skip(1);
\r
+ for (s = buf; *s; s++) {
\r
endTime = clock() + CLOCKS_PER_SEC*0.05;
\r
while (clock() < endTime) ;
\r
endTime = clock() + CLOCKS_PER_SEC*0.05;
\r
while (clock() < endTime) ;
\r
- putchar(*s
++
);
\r
+ putchar(*s);
\r
fflush(stdout);
\r
}
\r
}
\r
fflush(stdout);
\r
}
\r
}
\r
@@
-637,7
+641,7
@@
void debugme(void) {
proutn("Reset damage? ");
\r
if (ja() != 0) {
\r
int i;
\r
proutn("Reset damage? ");
\r
if (ja() != 0) {
\r
int i;
\r
- for (i=0; i <=
ndevice
; i++) if (damage[i] > 0.0) damage[i] = 0.0;
\r
+ for (i=0; i <=
NDEVICES
; i++) if (damage[i] > 0.0) damage[i] = 0.0;
\r
stdamtim = 1e30;
\r
}
\r
proutn("Toggle idebug? ");
\r
stdamtim = 1e30;
\r
}
\r
proutn("Toggle idebug? ");
\r
@@
-649,7
+653,7
@@
void debugme(void) {
proutn("Cause selective damage? ");
\r
if (ja() != 0) {
\r
int i, key;
\r
proutn("Cause selective damage? ");
\r
if (ja() != 0) {
\r
int i, key;
\r
- for (i=1; i <=
ndevice
; i++) {
\r
+ for (i=1; i <=
NDEVICES
; i++) {
\r
proutn("Kill ");
\r
proutn(device[i]);
\r
proutn("? ");
\r
proutn("Kill ");
\r
proutn(device[i]);
\r
proutn("? ");
\r
@@
-657,7
+661,7
@@
void debugme(void) {
key = scan();
\r
if (key == IHALPHA && isit("y")) {
\r
damage[i] = 10.0;
\r
key = scan();
\r
if (key == IHALPHA && isit("y")) {
\r
damage[i] = 10.0;
\r
- if (i == DRADIO) stdamtim =
d
.date;
\r
+ if (i == DRADIO) stdamtim =
game.state
.date;
\r
}
\r
}
\r
}
\r
}
\r
}
\r
}
\r
@@
-676,12
+680,12
@@
void debugme(void) {
case FSCMOVE: proutn("SC Move "); break;
\r
case FSCDBAS: proutn("SC Base Destroy "); break;
\r
}
\r
case FSCMOVE: proutn("SC Move "); break;
\r
case FSCDBAS: proutn("SC Base Destroy "); break;
\r
}
\r
- cramf(future[i]-
d
.date, 8, 2);
\r
+ cramf(future[i]-
game.state
.date, 8, 2);
\r
chew();
\r
proutn(" ?");
\r
key = scan();
\r
if (key == IHREAL) {
\r
chew();
\r
proutn(" ?");
\r
key = scan();
\r
if (key == IHREAL) {
\r
- future[i] =
d
.date + aaitem;
\r
+ future[i] =
game.state
.date + aaitem;
\r
}
\r
}
\r
chew();
\r
}
\r
}
\r
chew();
\r