projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge Stas's patch #3.
[super-star-trek.git]
/
sst.c
diff --git
a/sst.c
b/sst.c
index b31200ecece75d2d857a83983d970aa208a57a35..eb7c8f6cb4303edc7ab08b4b85bbf35c12332adf 100644
(file)
--- a/
sst.c
+++ b/
sst.c
@@
-1,6
+1,11
@@
#define INCLUDED // Define externs here
#include <ctype.h>
#include <getopt.h>
#define INCLUDED // Define externs here
#include <ctype.h>
#include <getopt.h>
+#ifdef SERGEEV
+#include <conio.h>
+#include <time.h>
+#include "sstlinux.h"
+#endif /* SERGEEV */
#include "sst.h"
#ifndef SSTDOC
#include "sst.h"
#ifndef SSTDOC
@@
-84,10
+89,19
@@
SERGEEV, not yet completely merged):
*/
static char *commands[] = {
*/
static char *commands[] = {
+#ifdef SERGEEV
+ "--",
+ "---",
+#else
"srscan",
"lrscan",
"srscan",
"lrscan",
+#endif /* SERGEEV */
"phasers",
"phasers",
+#ifdef SERGEEV
+ "torpedo",
+#else
"photons",
"photons",
+#endif /* SERGEEV */
"move",
"shields",
"dock",
"move",
"shields",
"dock",
@@
-96,40
+110,63
@@
static char *commands[] = {
"impulse",
"rest",
"warp",
"impulse",
"rest",
"warp",
+#ifdef SERGEEV
+ "score",
+ "----",
+#else
"status",
"sensors",
"status",
"sensors",
+#endif /* SERGEEV */
"orbit",
"transport",
"mine",
"crystals",
"shuttle",
"planets",
"orbit",
"transport",
"mine",
"crystals",
"shuttle",
"planets",
+#ifdef SERGEEV
+ "-----",
+#else
"request",
"request",
+#endif /* SERGEEV */
"report",
"computer",
"commands",
"report",
"computer",
"commands",
- "emexit",
- "probe",
+
"emexit",
+
"probe",
"abandon",
"destruct",
"abandon",
"destruct",
+#ifdef SERGEEV
+ "save",
+#else
"freeze",
"freeze",
+#endif /* SERGEEV */
"deathray",
"debug",
"deathray",
"debug",
+#ifdef SERGEEV
+ "sos",
+#else
"call",
"call",
+#endif /* SERGEEV */
"quit",
"help"
};
"quit",
"help"
};
+
+#ifdef SERGEEV
+wnd wnds[6]={{1,1,80,25},{1,1,25,12},{26,2,80,12},{65,1,80,10},{1,13,80,23},{1,24,80,25}};
+short curwnd;
+#endif /* SERGEEV */
+
#define NUMCOMMANDS sizeof(commands)/sizeof(commands[0])
static void listCommands(int x) {
#define NUMCOMMANDS sizeof(commands)/sizeof(commands[0])
static void listCommands(int x) {
-
prout(" SRSCAN MOVE PHASERS CALL\n
"
-
" STATUS IMPULSE PHOTONS ABANDON\n
"
-
" LRSCAN WARP SHIELDS DESTRUCT\n
"
-
" CHART REST DOCK QUIT\n
"
-
" DAMAGES REPORT SENSORS ORBIT\n
"
-
" TRANSPORT MINE CRYSTALS SHUTTLE\n
"
-
" PLANETS REQUEST DEATHRAY FREEZE\n
"
-
" COMPUTER EMEXIT PROBE COMMANDS
");
+
proutn ("LEGAL COMMANDS ARE:\n\r
"
+
" MOVE PHASERS SOS PROBE\n\r
"
+
" COMPUTER IMPULSE TORPEDO ABANDON\n\r
"
+
" EMEXIT WARP SHIELDS DESTRUCT\n\r
"
+
" CHART REST DOCK QUIT\n\r
"
+
" DAMAGES REPORT SCORE ORBIT\n\r
"
+
" TRANSPORT MINE CRYSTALS SHUTTLE\n\r
"
+
" PLANETS DEATHRAY SAVE COMMANDS\n\r
");
if (x) prout(" HELP");
}
if (x) prout(" HELP");
}
@@
-244,16
+281,41
@@
void drawmaps(short l){
static void makemoves(void) {
int i, hitme;
static void makemoves(void) {
int i, hitme;
+#ifdef SERGEEV
+ clrscr();
+ setwnd(4);
+#endif /* SERGEEV */
while (TRUE) { /* command loop */
while (TRUE) { /* command loop */
- hitme = FALSE;
- justin = 0;
- Time = 0.0;
- i = -1;
- while (TRUE) { /* get a command */
+#ifdef SERGEEV
+ drawmaps(1);
+#endif /* SERGEEV */
+ while (TRUE) { /* get a command */
+ hitme = FALSE;
+ justin = 0;
+ Time = 0.0;
+ i = -1;
chew();
chew();
- skip(1);
+#ifdef SERGEEV
+ setwnd(5);
+ clrscr();
+#endif /* SERGEEV */
proutn("COMMAND> ");
proutn("COMMAND> ");
- if (scan() == IHEOL) continue;
+ if (scan() == IHEOL) {
+#ifdef SERGEEV
+ _setcursortype(_NOCURSOR);
+ setwnd(4);
+ clrscr();
+ chart(0);
+ _setcursortype(_NORMALCURSOR);
+#endif /* SERGEEV */
+ continue;
+ }
+#ifdef SERGEEV
+ ididit=0;
+ clrscr();
+ setwnd(4);
+ clrscr();
+#endif /* SERGEEV */
for (i=0; i < 26; i++)
if (isit(commands[i]))
break;
for (i=0; i < 26; i++)
if (isit(commands[i]))
break;
@@
-262,20
+324,18
@@
static void makemoves(void) {
if (strcmp(commands[i], citem) == 0) break;
if (i < NUMCOMMANDS) break;
if (strcmp(commands[i], citem) == 0) break;
if (i < NUMCOMMANDS) break;
- if (skill <= 2) {
- prout("UNRECOGNIZED COMMAND. LEGAL COMMANDS ARE:");
- listCommands(TRUE);
- }
- else prout("UNRECOGNIZED COMMAND.");
+ listCommands(TRUE);
}
commandhook(commands[i], TRUE);
switch (i) { /* command switch */
}
commandhook(commands[i], TRUE);
switch (i) { /* command switch */
- case 0: // srscan
- srscan(1);
- break;
- case 1: // lrscan
- lrscan();
- break;
+#ifndef SERGEEV
+ case 0: // srscan
+ srscan(1);
+ break;
+ case 1: // lrscan
+ lrscan();
+ break;
+#endif /* SERGEEV */
case 2: // phasers
phasers();
if (ididit) hitme = TRUE;
case 2: // phasers
phasers();
if (ididit) hitme = TRUE;
@@
-290,12
+350,12
@@
static void makemoves(void) {
case 5: // shields
doshield(1);
if (ididit) {
case 5: // shields
doshield(1);
if (ididit) {
-
attack(2)
;
+
hitme=TRUE
;
shldchg = 0;
}
break;
case 6: // dock
shldchg = 0;
}
break;
case 6: // dock
- dock(1);
+
dock(1);
if (ididit) attack(0);
break;
case 7: // damages
if (ididit) attack(0);
break;
case 7: // damages
@@
-314,12
+374,14
@@
static void makemoves(void) {
case 11: // warp
setwrp();
break;
case 11: // warp
setwrp();
break;
- case 12: // status
-
srscan(3
);
+ case 12: // score
+
score(
);
break;
break;
+#ifndef SERGEEV
case 13: // sensors
sensor();
break;
case 13: // sensors
sensor();
break;
+#endif /* SERGEEV */
case 14: // orbit
orbit();
if (ididit) hitme = TRUE;
case 14: // orbit
orbit();
if (ididit) hitme = TRUE;
@@
-333,6
+395,7
@@
static void makemoves(void) {
break;
case 17: // crystals
usecrystals();
break;
case 17: // crystals
usecrystals();
+ if (ididit) hitme = TRUE;
break;
case 18: // shuttle
shuttle();
break;
case 18: // shuttle
shuttle();
@@
-345,7
+408,7
@@
static void makemoves(void) {
srscan(2);
break;
case 21: // Game Report
srscan(2);
break;
case 21: // Game Report
- report(
0
);
+ report();
break;
case 22: // use COMPUTER!
eta();
break;
case 22: // use COMPUTER!
eta();
@@
-354,12
+417,15
@@
static void makemoves(void) {
listCommands(TRUE);
break;
case 24: // Emergency exit
listCommands(TRUE);
break;
case 24: // Emergency exit
- clearscreen(); // Hide screen
+#ifdef SERGEEV
+ clrscr(); // Hide screen
+#endif /* SERGEEV */
freeze(TRUE); // forced save
exit(1); // And quick exit
break;
case 25:
probe(); // Launch probe
freeze(TRUE); // forced save
exit(1); // And quick exit
break;
case 25:
probe(); // Launch probe
+ if (ididit) hitme = TRUE;
break;
case 26: // Abandon Ship
abandn();
break;
case 26: // Abandon Ship
abandn();
@@
-369,8
+435,11
@@
static void makemoves(void) {
break;
case 28: // Save Game
freeze(FALSE);
break;
case 28: // Save Game
freeze(FALSE);
+#ifdef SERGEEV
+ clrscr();
+#endif /* SERGEEV */
if (skill > 3)
if (skill > 3)
-
prout("WARNING--Frozen
games produce no plaques!");
+
prout("WARNING--Saved
games produce no plaques!");
break;
case 29: // Try a desparation measure
deathray();
break;
case 29: // Try a desparation measure
deathray();
@@
-383,6
+452,7
@@
static void makemoves(void) {
break;
case 31: // Call for help
help();
break;
case 31: // Call for help
help();
+ if (ididit) hitme = TRUE;
break;
case 32:
alldone = 1; // quit the game
break;
case 32:
alldone = 1; // quit the game
@@
-408,7
+478,6
@@
static void makemoves(void) {
atover(0);
continue;
}
atover(0);
continue;
}
- if (nenhere == 0) movetho();
if (hitme && justin==0) {
attack(2);
if (alldone) break;
if (hitme && justin==0) {
attack(2);
if (alldone) break;
@@
-426,7
+495,8
@@
static void makemoves(void) {
int main(int argc, char **argv) {
int main(int argc, char **argv) {
- int i, option, usecurses = TRUE;
+ int i, option, usecurses = TRUE;
+
while ((option = getopt(argc, argv, "t")) != -1) {
switch (option) {
case 't':
while ((option = getopt(argc, argv, "t")) != -1) {
switch (option) {
case 't':
@@
-438,21
+508,28
@@
int main(int argc, char **argv) {
}
}
}
}
+#ifndef SERGEEV
iostart(usecurses);
iostart(usecurses);
- prelim();
+#else
+ randomize();
+ textattr(7);
+ clrscr();
+ setwnd(0);
+#endif /* SERGEEV */
line[0] = '\0';
for (i = optind; i < argc; i++) {
strcat(line, argv[i]);
strcat(line, " ");
}
while (TRUE) { /* Play a game */
line[0] = '\0';
for (i = optind; i < argc; i++) {
strcat(line, argv[i]);
strcat(line, " ");
}
while (TRUE) { /* Play a game */
+ prelim();
setup(line[0] == '\0');
if (alldone) {
score();
alldone = 0;
}
else makemoves();
setup(line[0] == '\0');
if (alldone) {
score();
alldone = 0;
}
else makemoves();
- skip(
2
);
+ skip(
1
);
stars();
skip(1);
stars();
skip(1);
@@
-474,8
+551,8
@@
int main(int argc, char **argv) {
#ifndef SERGEEV
ioend();
#endif /* SERGEEV */
#ifndef SERGEEV
ioend();
#endif /* SERGEEV */
- p
uts
("May the Great Bird of the Galaxy roost upon your home planet.");
-
exit(0)
;
+ p
rout
("May the Great Bird of the Galaxy roost upon your home planet.");
+
return 0
;
}
}
@@
-505,7
+582,7
@@
char *cramlc(enum loctype key, int x, int y) {
buf[0] = '\0';
if (key == quadrant) strcpy(buf, "Quadrant ");
else if (key == sector) strcpy(buf, "Sector ");
buf[0] = '\0';
if (key == quadrant) strcpy(buf, "Quadrant ");
else if (key == sector) strcpy(buf, "Sector ");
- sprintf(buf+strlen(buf), "%d
-
%d", x, y);
+ sprintf(buf+strlen(buf), "%d
-
%d", x, y);
return buf;
}
return buf;
}
@@
-575,6
+652,14
@@
int scan(void) {
return IHEOL;
}
getline(line, sizeof(line));
return IHEOL;
}
getline(line, sizeof(line));
+#ifdef SERGEEV
+ fflush(stdin);
+ if (curwnd==5){
+ clrscr();
+ setwnd(4);
+ clrscr();
+ }
+#endif /* SERGEEV */
linep = line;
}
// Skip leading white space
linep = line;
}
// Skip leading white space