diff -u beasts-orig/beast.c beasts/beast.c --- beasts-orig/beast.c Mon Jul 27 22:36:59 1998 +++ beasts/beast.c Tue Mar 7 20:58:54 2000 @@ -16,7 +16,7 @@ int lastmoved; } Beastie; -static Beastie *beast; +static Beastie *beast = NULL; static int totalbeasts; static int livebeasts; @@ -38,6 +38,7 @@ /************** Out with the beasties! ********************/ + totalbeasts=0; for(species=0; species < BEASTIETYPES; species++) totalbeasts+=numbeasties[species]; @@ -60,10 +61,14 @@ beastPtr->phobic=0; } - place_thing(beast_index, - fieldPtr, - &beastPtr->x, - &beastPtr->y); + if (!place_thing(beast_index, + fieldPtr, + &beastPtr->x, + &beastPtr->y)) + { + livebeasts--; + beastPtr->species=DEAD; + } beastPtr++; beast_index++; @@ -80,7 +85,7 @@ livebeasts--; if(livebeasts==0) - endlevel("All beasts dead."); + endlevel(NEXTLEVEL, "All beasts dead."); /* score++; */ } @@ -112,6 +117,12 @@ { signal(SIGALRM, beastie_call); } + +void +stop_timer() +{ + signal(SIGALRM, SIG_IGN); +} /*********** Beastie Behaviour ****************/ void @@ -162,7 +173,7 @@ endpos=bpos + field->x * dy + dx; flub=field->map[endpos]; if (flub==HERO) { - endlevel("Hero is beastie snack."); + endlevel(GAMEOVER, "Hero is beastie snack."); } if (beast[bnum].phobic > int_rand(50,120)) { @@ -340,7 +351,7 @@ case HOLE: break; case HERO: - endlevel("Hero blown to pieces."); + endlevel(GAMEOVER, "Hero blown to pieces."); default: ConsoleDrawIcon(xx,yy,EMPTY); field->map[yoff+xx]=EMPTY; diff -u beasts-orig/beast.h beasts/beast.h --- beasts-orig/beast.h Mon Jul 27 01:35:25 1998 +++ beasts/beast.h Tue Mar 7 20:58:54 2000 @@ -20,3 +20,5 @@ void init_timer(long usecs); void start_timer(); +void stop_timer(); + diff -u beasts-orig/beasts.h beasts/beasts.h --- beasts-orig/beasts.h Mon Jul 27 22:07:47 1998 +++ beasts/beasts.h Tue Mar 7 20:58:54 2000 @@ -33,9 +33,17 @@ DOWN_RIGHT } Direction; +typedef enum { + LOOP = 0, + NEXTLEVEL, + GAMEOVER +} LoopValue; + typedef void (*DrawIconFunc) (int x, int y, Grounds thing); /* in main.c */ +void endlevel(LoopValue NewStatus, char *msg); + gboolean place_thing(Grounds thing, Field *fieldPtr, int *thing_x, @@ -48,9 +56,9 @@ int dir_to_step(Direction thatway, int rowspan); -Hero *GlobalHeroPtr; -Field *GlobalFieldPtr; -gboolean StopLoop; +extern Hero *GlobalHeroPtr; +extern Field *GlobalFieldPtr; +extern LoopValue StopLoop; #define float_rand() ((float)rand()/(float)RAND_MAX) #define int_rand(N,X) ((int)(((double)rand()/(double)RAND_MAX)*((X)-(N)+1)+(N))) diff -u beasts-orig/console.c beasts/console.c --- beasts-orig/console.c Mon Jul 27 22:10:28 1998 +++ beasts/console.c Tue Mar 7 21:01:50 2000 @@ -69,7 +69,7 @@ moveman(DOWN_RIGHT, field, hero); break; case 'q': - return; + endlevel(GAMEOVER, "Player quit"); break; default: break; @@ -141,3 +141,4 @@ *x=(COLS-2)/2; *y=LINES-4; } + diff -u beasts-orig/main.c beasts/main.c --- beasts-orig/main.c Mon Jul 27 22:38:20 1998 +++ beasts/main.c Tue Mar 7 20:58:54 2000 @@ -26,6 +26,11 @@ /* extern DrawIconFunc ConsoleDrawIcon; */ +/***** Globals ******/ +Hero *GlobalHeroPtr; +Field *GlobalFieldPtr; +LoopValue StopLoop; + /***** Defines ********/ static DrawIconFunc (*draw_icon); @@ -65,7 +70,7 @@ init_timer(1000000/6); /* Establish all the callbacks. */ - + do { level++; init_grounds(&field, @@ -77,15 +82,17 @@ /* Wait for a key or something, and...*/ /* Action! */ - StopLoop=FALSE; + StopLoop=LOOP; start_timer(); ConsoleLoop(&field, &hero); + stop_timer(); /* Hopefully everything is event based and we sleep for a while. */ /* Something caused the level to end. Who won? */ + } while (StopLoop != GAMEOVER); ConsoleQuit(); @@ -93,9 +100,9 @@ } void -endlevel(char *msg) +endlevel(LoopValue NewStatus, char *msg) { - StopLoop=TRUE; + StopLoop=NewStatus; } static void @@ -137,6 +144,8 @@ field[yoff+xx] = WALL; else if (randfooy; yy++) { yoff=yy*field->x; for(xx=0; xx < field->x; xx++) { - if(field->map[yoff+xx] != EMPTY) { + /*if(field->map[yoff+xx] != EMPTY) {*/ /* (*draw_icon)(xx,yy,field->map[yoff+xx]); */ ConsoleDrawIcon(xx,yy,field->map[yoff+xx]); - } /* endif not empty */ + /*}*/ /* endif not empty */ } /* next xx */ } /* next yy */ (*field_refresh)();