From c6a6731be54b549f4859e71475e78ffac8a1557e Mon Sep 17 00:00:00 2001 From: jan6 Date: Tue, 11 Feb 2020 16:18:17 +0000 Subject: [PATCH] 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" --- LICENSE | 1 + Makefile | 14 ++++++---- README | 27 ++++++++++++++---- changelog | 17 ++++++++++++ common.h | 17 ++++-------- starlanes.c | 80 ++++++++++++++++++++++++++++++----------------------- 6 files changed, 100 insertions(+), 56 deletions(-) create mode 120000 LICENSE diff --git a/LICENSE b/LICENSE new file mode 120000 index 0000000..d24842f --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +COPYING \ No newline at end of file diff --git a/Makefile b/Makefile index d68866c..e3b8f84 100644 --- a/Makefile +++ b/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 diff --git a/README b/README index bb56aa8..77ba493 100644 --- a/README +++ b/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 diff --git a/changelog b/changelog index 75bcf08..ab73810 100644 --- a/changelog +++ b/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 diff --git a/common.h b/common.h index e7b4ff9..69b653f 100644 --- a/common.h +++ b/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; - - - - diff --git a/starlanes.c b/starlanes.c index f8d51f3..9cc873c 100644 --- a/starlanes.c +++ b/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 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;plnmr0){ +/* 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"); }