forked from envs/starlanes
1.4.0 by jan6
edited stats and company names, copyright, changelog, edited final stats to not exit unless Y is pressed, removed buggy AI, added "make clean"
This commit is contained in:
parent
ba30e92f1b
commit
c6a6731be5
14
Makefile
14
Makefile
|
@ -3,7 +3,7 @@
|
|||
#
|
||||
CC=/usr/bin/gcc
|
||||
#CCOPTS=-Wall
|
||||
CCOPTS=-O2
|
||||
CCOPTS=-static -O2
|
||||
CURSESLIB=ncurses
|
||||
INSTALLDIR=/usr/local
|
||||
|
||||
|
@ -12,14 +12,16 @@ all: starlanes
|
|||
clean: *.o starlanes
|
||||
rm -f *.o starlanes
|
||||
|
||||
ai.o: ai.c common.h
|
||||
$(CC) -g $(CCOPTS) -c ai.c
|
||||
#ai.o: ai.c common.h
|
||||
# $(CC) -g $(CCOPTS) -c ai.c
|
||||
|
||||
starlanes.o: starlanes.c ai.c common.h
|
||||
starlanes.o: starlanes.c common.h #ai.c
|
||||
$(CC) -g $(CCOPTS) -c starlanes.c
|
||||
|
||||
starlanes: starlanes.o ai.o
|
||||
$(CC) -g starlanes.o ai.o -o starlanes -l$(CURSESLIB)
|
||||
starlanes: starlanes.o #ai.o
|
||||
# $(CC) -g starlanes.o ai.o -o starlanes -l$(CURSESLIB)
|
||||
$(CC) -g -O2 starlanes.o -o starlanes -l$(CURSESLIB)
|
||||
strip --strip-unneeded --strip-debug --merge-notes starlanes
|
||||
|
||||
install:
|
||||
cp starlanes $(INSTALLDIR)/bin
|
||||
|
|
27
README
27
README
|
@ -1,8 +1,23 @@
|
|||
Type "make" to build the starlanes binaries, then sign on as root
|
||||
an type "make fakeinstall"
|
||||
which will, uh, pretend to install everything. If all the commands that
|
||||
it's going to execute look correct, go ahead and type "make install" (as
|
||||
root) to install the goods.
|
||||
Type "make" to build the starlanes binaries, then type "make fakeinstall"
|
||||
which will, pretend to install everything. If all the commands and paths that
|
||||
it's going to use look correct, then go ahead and type "make install" (as
|
||||
root) to install the goods system-wide
|
||||
or run it directly from the directory with ./starlanes
|
||||
|
||||
I removed the AI, at least for now
|
||||
(feel free to add it back if you figure out how to properly fix it)
|
||||
I also changed the company names slightly, and adjusted the stats for no reason
|
||||
most importantly, after experiencing troubles where someone accidentally closed
|
||||
the final stats screen, I modified it to only close when pressing Y (doesn't matter if lower or uppercase)
|
||||
|
||||
there are still plenty of warnings left to fix,
|
||||
but they don't affect the gameplay
|
||||
|
||||
~jan6
|
||||
jan6@tilde.ninja and jan6@envs.net
|
||||
--------
|
||||
rest of the readme is written by other people
|
||||
--------
|
||||
|
||||
I would like to claim that the reason there is no
|
||||
configure file is because for a small program
|
||||
|
@ -25,6 +40,8 @@ you installed starlanes and type "./starlanes"
|
|||
David
|
||||
"dejvid@zamir.net" and "dejvid@barnsdle.demon.co.uk"
|
||||
|
||||
---
|
||||
|
||||
This is a port to C from a version of Starlanes for the Osborne 1. The
|
||||
original source is from a First Osborne Group (FOG) disk that I probably
|
||||
picked up in 1982. The author isn't identified. Based on comments in
|
||||
|
|
17
changelog
17
changelog
|
@ -1,3 +1,20 @@
|
|||
Version 1.4.0 released 2020 by ~jan6
|
||||
jan6@tilde.ninja and jan6@envs.net
|
||||
|
||||
Removed AI (crashes when trying to use it)
|
||||
|
||||
Changed some stats and company names slightly
|
||||
|
||||
Modified final stats screen to not exit unless player presses "Y"
|
||||
|
||||
Fixed a couple critical errors preventing compilation
|
||||
|
||||
Added "make clean"
|
||||
|
||||
Stripped the binary (about halving final size)
|
||||
|
||||
|
||||
|
||||
Version 1.3.0 released 2004 by David Barnsdale
|
||||
dejvid@barnsdle.demon.co.uk and dejvid@zamir.net
|
||||
|
||||
|
|
17
common.h
17
common.h
|
@ -7,11 +7,10 @@
|
|||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
** GNU General Public License v2 for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
** along with this program;
|
||||
*/
|
||||
|
||||
#define OFFMAP '-' /* space character */
|
||||
|
@ -22,12 +21,12 @@
|
|||
|
||||
#define NUMCO 5 /* number of companies (don't change) */
|
||||
#define INIT_CO_COST 100 /* initial company start cost */
|
||||
#define FOUNDER_BONUS 5 /* founder gets this much stock */
|
||||
#define NUMMOVES 5 /* number of moves options a player gets */
|
||||
#define FOUNDER_BONUS 10 /* founder gets this much stock */
|
||||
#define NUMMOVES 6 /* number of moves options a player gets */
|
||||
#define MAXPLAYERS 4 /* total number of players a game can have */
|
||||
#define STARCOST 500 /* company's price increase near star */
|
||||
#define STARCOST 555 /* company's price increase near star */
|
||||
#define BLACKHOLECOST -500 /* price increase near black hole */
|
||||
#define NEWCOCOST 100 /* company's price increase near new co */
|
||||
#define NEWCOCOST 111 /* company's price increase near new co */
|
||||
|
||||
|
||||
#define Mx 12 /* x dimension of map */
|
||||
|
@ -63,7 +62,3 @@ typedef struct {
|
|||
int risk; /* value related to chance of being swallowed by Black Hole */
|
||||
int netpot; /* potential - risk */
|
||||
} COMPANY;
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
80
starlanes.c
80
starlanes.c
|
@ -2,7 +2,7 @@
|
|||
** starlanes v1.3.0 (29-Mar-1997) -- a space-age stock trading game
|
||||
**
|
||||
** Copyright (C) 1997 Brian "Beej" Hall
|
||||
** with modifications by David Barnsdale 2004
|
||||
** with modifications by David Barnsdale 2004 and by ~jan6 2020
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or
|
||||
** modify it under the terms of the GNU General Public License
|
||||
|
@ -101,7 +101,8 @@
|
|||
|
||||
/* #define NUMMOVES 5 number of different moves a player gets */
|
||||
|
||||
#define END_PERCENT 54 /* end when this much of the map is full */
|
||||
//#define END_PERCENT 55 /* end when this much of the map is full */
|
||||
#define END_PERCENT 1 /* end when this much of the map is full */
|
||||
#define DEF_LINES 25 /* default number of lines on screen */
|
||||
#define DEF_COLUMNS 80 /* default number of columns on screen */
|
||||
|
||||
|
@ -120,9 +121,9 @@
|
|||
|
||||
/* function prototypes: */
|
||||
|
||||
extern void generate_nme(char *nme);
|
||||
extern char placemove( PLAYER *pla,int *move, COMPANY *co, int turn,char *map, int Difficulty);
|
||||
extern void ai_buy_sell(PLAYER *pla, COMPANY *com, int turn,char *map, int Difficulty);
|
||||
//extern void generate_nme(char *nme);
|
||||
//extern char placemove( PLAYER *pla,int *move, COMPANY *co, int turn,char *map, int Difficulty);
|
||||
//extern void ai_buy_sell(PLAYER *pla, COMPANY *com, int turn,char *map, int Difficulty);
|
||||
|
||||
void initialize(void);
|
||||
void color_setup(void);
|
||||
|
@ -153,7 +154,7 @@ void redraw(void);
|
|||
void show_standings(char *title);
|
||||
void show_company_holdings(char *title);
|
||||
int order_compare(const void *v1, const void *v2);
|
||||
void quit_yn(void);
|
||||
int quit_yn(void);
|
||||
void shutdown(void);
|
||||
void usage(void);
|
||||
/* ai functions
|
||||
|
@ -176,13 +177,13 @@ int MAPY = My; /* y dimension of map */
|
|||
int LINES; /* lines in screen */
|
||||
int COLUMNS; /* columns in screen */
|
||||
char *map; /* pointer to the map data */
|
||||
char *mapc; /* copy of map for ai */
|
||||
//char *mapc; /* copy of map for ai */
|
||||
PLAYER *pl; /* pointer to array of players */
|
||||
COMPANY *co; /* pointer to array of companies */
|
||||
int numplayers,turn; /* number of players, whose turn it is */
|
||||
WINDOW *mapwin,*general,*coinfo; /* pointers to the windows */
|
||||
int color; /* true if we want color */
|
||||
int sologame; /* set to true if nmr of playes is 0*/
|
||||
int sologame=0; /* set to true if nmr of playes is 0*/
|
||||
int Difficulty;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -247,10 +248,10 @@ int main(int argc, char *argv[])
|
|||
holding_bonus();
|
||||
if ((done = check_endgame()) != 1) {
|
||||
if (pl[turn].ishuman==1) buy_sell();
|
||||
else {
|
||||
*mapc=*map ;
|
||||
ai_buy_sell(pl,co,turn,map,Difficulty);
|
||||
}
|
||||
//else {
|
||||
//mapc=*map ;
|
||||
//ai_buy_sell(pl,co,turn,map,Difficulty);
|
||||
//}
|
||||
turn = (++turn)%numplayers;
|
||||
}
|
||||
} while (!done);
|
||||
|
@ -285,11 +286,11 @@ void initialize(void)
|
|||
fprintf(stderr,"starlanes: error mallocing space for map\n");
|
||||
exit(1);
|
||||
}
|
||||
if ((mapc=malloc(MAPX*MAPY)) == NULL) {
|
||||
/* if ((mapc=malloc(MAPX*MAPY)) == NULL) {
|
||||
fprintf(stderr,"starlanes: error mallocing space for copy of map\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
*/
|
||||
if ((co=calloc(1,NUMCO * sizeof(COMPANY))) == NULL) {
|
||||
fprintf(stderr,"starlanes: error mallocing space for companies\n");
|
||||
exit(1);
|
||||
|
@ -315,11 +316,11 @@ void initialize(void)
|
|||
|
||||
for(i=0;i<NUMCO;i++) {
|
||||
switch(i) {
|
||||
case 0: strcpy(co[i].name, "Altair Starways");break;
|
||||
case 1: strcpy(co[i].name, "Beetlejuice, Ltd.");break;
|
||||
case 2: strcpy(co[i].name, "Capella Freight Co.");break;
|
||||
case 3: strcpy(co[i].name, "Denebola Shippers");break;
|
||||
case 4: strcpy(co[i].name, "Eridani Expediters");break;
|
||||
case 0: strcpy(co[i].name, "Altar & Stairway, Ltd.");break;
|
||||
case 1: strcpy(co[i].name, "Beatles & Juice Co.");break;
|
||||
case 2: strcpy(co[i].name, "Capella Fright, Ltd.");break;
|
||||
case 3: strcpy(co[i].name, "Denebola Dice Shippers");break;
|
||||
case 4: strcpy(co[i].name, "Eridani Expert Export");break;
|
||||
}
|
||||
co[i].size = co[i].price = 0;
|
||||
}
|
||||
|
@ -402,9 +403,9 @@ void get_num_players(void)
|
|||
attron(color?YELLOW_ON_BLUE|A_BOLD:A_REVERSE);
|
||||
center(stdscr,COLUMNS,6,"* S * T * A * R ** L * A * N * E * S *");
|
||||
attroff(color?YELLOW_ON_BLUE|A_BOLD:A_REVERSE);
|
||||
sprintf(s,"Please enter the number of players [1-%d] ",MAXPLAYERS);
|
||||
sprintf(s,"Please enter the number of players [1-%d] ",MAXPLAYERS);
|
||||
center(stdscr,COLUMNS,9,s);
|
||||
center(stdscr,COLUMNS,10,"or enter 0 for solo play against the ai: ");
|
||||
// center(stdscr,COLUMNS,10,"or enter 0 for solo play against the ai: ");
|
||||
refresh();
|
||||
noecho();raw();
|
||||
do {
|
||||
|
@ -413,7 +414,8 @@ void get_num_players(void)
|
|||
addch(c+'0');
|
||||
|
||||
numplayers = (int)c;
|
||||
if (numplayers == 0){
|
||||
if (numplayers == 0) numplayers=1;
|
||||
/* if (numplayers == 0){
|
||||
numplayers=4;
|
||||
sologame=1;
|
||||
sprintf(s,"Please enter level (1 easiest,3 hardest)");
|
||||
|
@ -425,25 +427,25 @@ void get_num_players(void)
|
|||
} while (Difficulty < 1 || Difficulty > 3);
|
||||
addch(Difficulty+'0');
|
||||
}
|
||||
else sologame =0;
|
||||
else */ sologame=0;
|
||||
|
||||
srand(getpid()); /* reseed the dumb random number generator */
|
||||
turn = rand()%numplayers;
|
||||
|
||||
nl();
|
||||
for(plnmr=0;plnmr<numplayers;plnmr++){
|
||||
if (sologame==1 && plnmr>0){
|
||||
/* if (sologame==1 && plnmr>0){
|
||||
pl[plnmr].ishuman=0 /* here computer will generate a name */;
|
||||
generate_nme(pl[plnmr].name);
|
||||
/* generate_nme(pl[plnmr].name);
|
||||
}
|
||||
else {
|
||||
else { */
|
||||
sprintf(s,"Player %d, enter your name: ",plnmr+1);
|
||||
center(stdscr,COLUMNS-8 ,12+sologame+plnmr,s);
|
||||
refresh();
|
||||
my_mvwgetstr(stdscr,plnmr+12+sologame,49,20,0,pl[plnmr].name);
|
||||
/*getstr(pl[plnmr].name);*/
|
||||
if (pl[plnmr].name[0] == '\0') plnmr--;
|
||||
}
|
||||
// }
|
||||
}
|
||||
nonl();
|
||||
}
|
||||
|
@ -536,7 +538,8 @@ void show_coinfo(void)
|
|||
case 4: attrs = CO_E;break;
|
||||
}
|
||||
wattron(coinfo,attrs);
|
||||
wprintw(coinfo," %-19s ",co[i].name);
|
||||
// wprintw(coinfo," %-19s ",co[i].name);
|
||||
wprintw(coinfo," %-22s ",co[i].name);
|
||||
wattroff(coinfo,attrs);
|
||||
wprintw(coinfo,"$%-4d ",co[i].price);
|
||||
/*if (pl[turn].holdings[i] == 0) wattron(coinfo,A_BLINK);*/
|
||||
|
@ -601,7 +604,7 @@ int get_move(void)
|
|||
c = getch();
|
||||
splat =c;
|
||||
}
|
||||
else { c=placemove(pl,move,co,turn,map,Difficulty);} /* ai will choose place */
|
||||
else {1==1;} // c=placemove(pl,move,co,turn,map,Difficulty);} /* ai will choose place */
|
||||
if (c == CTRL_L) {
|
||||
redraw();
|
||||
continue;
|
||||
|
@ -1343,10 +1346,17 @@ void show_standings(char *title)
|
|||
|
||||
sprintf(s,"Available company sectors remaining: %d", togo);
|
||||
center(stand,60,5+numplayers, s);
|
||||
center(stand,60,7+numplayers,"Press any key to continue...");
|
||||
if (check_endgame() == 1){
|
||||
center(stand,60,7+numplayers,"Press \"Y\" key to continue.");
|
||||
} else {
|
||||
center(stand,60,7+numplayers,"Press any key to continue...");
|
||||
};
|
||||
wnoutrefresh(stand);
|
||||
doupdate();
|
||||
getch();
|
||||
if (check_endgame() == 1) {
|
||||
while(1){doupdate();if (toupper(getch()) == 'Y'){break;};}
|
||||
}
|
||||
else {getch();};
|
||||
delwin(stand);
|
||||
touchwin(mapwin);
|
||||
touchwin(general);
|
||||
|
@ -1513,13 +1523,13 @@ void show_company_holdings(char *title)
|
|||
** quit_yn() -- asks the users if they're sure they want to quit
|
||||
*/
|
||||
|
||||
void quit_yn(void)
|
||||
int quit_yn(void)
|
||||
{
|
||||
WINDOW *yn;
|
||||
|
||||
if ((yn = newwin(5,42,5,(COLUMNS-42)/2)) == NULL) {
|
||||
fprintf(stderr,"starlanes: couldn't open window for y/n prompt\n");
|
||||
exit(1);
|
||||
exit(1);return 0;
|
||||
}
|
||||
|
||||
wattron(yn,QUIT_BORDER);
|
||||
|
@ -1536,11 +1546,12 @@ void quit_yn(void)
|
|||
if (toupper(getch()) == 'Y') {
|
||||
delwin(yn);
|
||||
shutdown();
|
||||
exit(2);
|
||||
exit(2);return 0;
|
||||
}
|
||||
delwin(yn);
|
||||
touchwin(mapwin);touchwin(coinfo);
|
||||
wnoutrefresh(mapwin);wnoutrefresh(coinfo);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1555,6 +1566,7 @@ void shutdown(void)
|
|||
endwin();
|
||||
printf("Starlanes for ncurses v%s Copyright by Brian \"Beej\" Hall 1997 \n",VERSION);
|
||||
printf("Update: David Barnsdale 2004\n");
|
||||
printf("Update: jan6 2020\n");
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue