* fixed an overflow in the tunnel update code. * fragbomb is now 'f', not 'd'. * added a missing call to init_bonus().tags/v0.99.beta14
| @@ -13,18 +13,26 @@ AM_CONFIG_HEADER(config.h) | |||
| AM_PROG_CC_C_O | |||
| AC_PROG_CPP | |||
| AC_ARG_ENABLE(slang, | |||
| [ --enable-slang slang graphics support (default enabled)]) | |||
| AC_ARG_ENABLE(ncurses, | |||
| [ --enable-ncurses ncurses interface support (default is slang)]) | |||
| [ --enable-ncurses ncurses graphics support (default disabled)]) | |||
| if test "${enable_ncurses}" = "yes" | |||
| then | |||
| AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers])) | |||
| AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library])) | |||
| else | |||
| AC_CHECK_HEADER(slang.h,:,AC_MSG_ERROR([cannot find slang headers])) | |||
| AC_CHECK_LIB(slang,SLkp_init,:,AC_MSG_ERROR([cannot find slang library])) | |||
| if test "${enable_slang}" != "no" | |||
| then | |||
| AC_CHECK_HEADER(slang.h,:,AC_MSG_ERROR([cannot find slang headers])) | |||
| AC_CHECK_LIB(slang,SLkp_init,:,AC_MSG_ERROR([cannot find slang library])) | |||
| else | |||
| : | |||
| fi | |||
| fi | |||
| AM_CONDITIONAL(USE_SLANG, test "${enable_slang}" != "no") | |||
| AM_CONDITIONAL(USE_NCURSES, test "${enable_ncurses}" = "yes") | |||
| AC_OUTPUT([ | |||
| @@ -7,12 +7,13 @@ AM_CFLAGS = -g -O2 -fno-strength-reduce -fomit-frame-pointer | |||
| # Code qui fait des warnings == code de porc == deux baffes dans ta gueule | |||
| AM_CFLAGS += -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs | |||
| if USE_SLANG | |||
| CPPFLAGS_slang = -DUSE_SLANG | |||
| LDFLAGS_slang = -lslang | |||
| endif | |||
| if USE_NCURSES | |||
| CPPFLAGS_gfx = -DUSE_NCURSES | |||
| LDFLAGS_gfx = -lncurses | |||
| else | |||
| CPPFLAGS_gfx = -DUSE_SLANG | |||
| LDFLAGS_gfx = -lslang | |||
| CPPFLAGS_ncurses = -DUSE_NCURSES | |||
| LDFLAGS_ncurses = -lncurses | |||
| endif | |||
| bin_PROGRAMS = ttyvaders | |||
| @@ -33,6 +34,6 @@ ttyvaders_SOURCES = \ | |||
| tunnel.c \ | |||
| $(NULL) | |||
| ttyvaders_CPPFLAGS = $(CPPFLAGS_gfx) | |||
| ttyvaders_LDADD = $(LDFLAGS_gfx) | |||
| ttyvaders_CPPFLAGS = $(CPPFLAGS_slang) $(CPPFLAGS_ncurses) | |||
| ttyvaders_LDADD = $(LDFLAGS_slang) $(LDFLAGS_ncurses) | |||
| @@ -3,7 +3,7 @@ | |||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | |||
| * All Rights Reserved | |||
| * | |||
| * $Id: ceo.c,v 1.4 2002/12/22 22:17:41 sam Exp $ | |||
| * $Id: ceo.c,v 1.5 2002/12/23 10:06:27 sam Exp $ | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU General Public License as published by | |||
| @@ -22,6 +22,7 @@ | |||
| #include "config.h" | |||
| #include <stdio.h> | |||
| #include <unistd.h> | |||
| #include "common.h" | |||
| @@ -3,7 +3,7 @@ | |||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | |||
| * All Rights Reserved | |||
| * | |||
| * $Id: common.h,v 1.10 2002/12/23 09:28:37 sam Exp $ | |||
| * $Id: common.h,v 1.11 2002/12/23 10:06:27 sam Exp $ | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU General Public License as published by | |||
| @@ -32,12 +32,17 @@ | |||
| # define gfx_goto(x,y) SLsmg_gotorc(y,x) | |||
| # define gfx_putchar(x) SLsmg_write_char(x) | |||
| # define gfx_putstr(x) SLsmg_write_string(x) | |||
| #else | |||
| #elif USE_NCURSES | |||
| # include <curses.h> | |||
| # define gfx_color(x) attrset(COLOR_PAIR(x)) | |||
| # define gfx_goto(x,y) move(y,x) | |||
| # define gfx_putchar(x) addch(x) | |||
| # define gfx_putstr(x) addstr(x) | |||
| #else | |||
| # define gfx_color(x) do{}while(0) | |||
| # define gfx_goto(x,y) do{}while(0) | |||
| # define gfx_putchar(x) do{}while(0) | |||
| # define gfx_putstr(x) do{}while(0) | |||
| #endif | |||
| #define gfx_putcharTO(x,y,c) do{ gfx_goto(x,y); gfx_putchar(c); }while(0) | |||
| @@ -3,7 +3,7 @@ | |||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | |||
| * All Rights Reserved | |||
| * | |||
| * $Id: graphics.c,v 1.4 2002/12/22 18:44:12 sam Exp $ | |||
| * $Id: graphics.c,v 1.5 2002/12/23 10:06:27 sam Exp $ | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU General Public License as published by | |||
| @@ -49,7 +49,7 @@ int init_graphics( void ) | |||
| SLsmg_cls(); | |||
| SLsmg_refresh(); | |||
| #else | |||
| #elif USE_NCURSES | |||
| /* Initialize ncurses library */ | |||
| initscr(); | |||
| keypad(stdscr, TRUE); | |||
| @@ -57,6 +57,8 @@ int init_graphics( void ) | |||
| cbreak(); | |||
| noecho(); | |||
| nodelay(stdscr, TRUE); | |||
| #else | |||
| /* Dummy driver */ | |||
| #endif | |||
| return 0; | |||
| @@ -80,7 +82,7 @@ void init_game( game *g ) | |||
| g->w = SLtt_Screen_Cols; | |||
| g->h = SLtt_Screen_Rows; | |||
| #else | |||
| #elif USE_NCURSES | |||
| start_color(); | |||
| init_pair( BLACK, COLOR_BLACK, COLOR_BLACK ); | |||
| @@ -96,6 +98,10 @@ void init_game( game *g ) | |||
| g->w = COLS; | |||
| g->h = LINES; | |||
| #else | |||
| /* Use dummy driver */ | |||
| g->w = 80; | |||
| g->h = 25; | |||
| #endif | |||
| } | |||
| @@ -106,13 +112,15 @@ char get_key( void ) | |||
| { | |||
| return SLang_getkey(); | |||
| } | |||
| #else | |||
| #elif USE_NCURSES | |||
| char key; | |||
| if( ( key = getch() ) != ERR ) | |||
| { | |||
| return key; | |||
| } | |||
| #else | |||
| /* Use dummy driver */ | |||
| #endif | |||
| return 0; | |||
| @@ -122,8 +130,10 @@ void clear_graphics( void ) | |||
| { | |||
| #ifdef USE_SLANG | |||
| SLsmg_cls(); | |||
| #else | |||
| #elif USE_NCURSES | |||
| clear(); | |||
| #else | |||
| /* Use dummy driver */ | |||
| #endif | |||
| } | |||
| @@ -132,8 +142,10 @@ void refresh_graphics( void ) | |||
| gfx_goto( 0, 0 ); | |||
| #ifdef USE_SLANG | |||
| SLsmg_refresh(); | |||
| #else | |||
| #elif USE_NCURSES | |||
| refresh(); | |||
| #else | |||
| /* Use dummy driver */ | |||
| #endif | |||
| } | |||
| @@ -142,9 +154,10 @@ void end_graphics( void ) | |||
| #ifdef USE_SLANG | |||
| SLang_reset_tty(); | |||
| SLsmg_reset_smg(); | |||
| #else | |||
| #elif USE_NCURSES | |||
| endwin(); | |||
| #else | |||
| /* Use dummy driver */ | |||
| #endif | |||
| } | |||
| @@ -3,7 +3,7 @@ | |||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | |||
| * All Rights Reserved | |||
| * | |||
| * $Id: main.c,v 1.9 2002/12/23 09:28:37 sam Exp $ | |||
| * $Id: main.c,v 1.10 2002/12/23 10:06:27 sam Exp $ | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU General Public License as published by | |||
| @@ -69,6 +69,7 @@ static void start_game (game *g) | |||
| g->p = create_player( g ); | |||
| g->al = malloc(sizeof(aliens)); | |||
| init_bonus( g, g->bo ); | |||
| init_weapons( g, g->wp ); | |||
| init_explosions( g, g->ex ); | |||
| init_aliens( g, g->al ); | |||
| @@ -128,7 +129,7 @@ static void start_game (game *g) | |||
| add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_BEAM ); | |||
| } | |||
| break; | |||
| case 'd': | |||
| case 'f': | |||
| if( g->p->nuke == 0 ) | |||
| { | |||
| g->p->nuke = 40; | |||
| @@ -222,10 +223,7 @@ static void start_game (game *g) | |||
| } | |||
| free_starfield( g, g->sf ); | |||
| #if 0 | |||
| free_player( p ); | |||
| free_tunnel( g->t ); | |||
| #endif | |||
| // free_player( g->p ); | |||
| } | |||
| @@ -3,7 +3,7 @@ | |||
| * Copyright (c) 2002 Sam Hocevar <sam@zoy.org> | |||
| * All Rights Reserved | |||
| * | |||
| * $Id: tunnel.c,v 1.5 2002/12/23 09:28:37 sam Exp $ | |||
| * $Id: tunnel.c,v 1.6 2002/12/23 10:06:27 sam Exp $ | |||
| * | |||
| * This program is free software; you can redistribute it and/or modify | |||
| * it under the terms of the GNU General Public License as published by | |||
| @@ -39,8 +39,6 @@ tunnel * create_tunnel( game *g, int w, int h ) | |||
| if( t->w >= g->w ) | |||
| { | |||
| t->left[0] = -10; | |||
| t->right[0] = g->w + 10; | |||
| for( i = 0; i < g->h; i++ ) | |||
| { | |||
| t->left[i] = -10; | |||
| @@ -81,7 +79,7 @@ void update_tunnel( game *g, tunnel *t ) | |||
| int i,j,k; | |||
| /* Slide tunnel one block vertically */ | |||
| for( i = t->h; i--; ) | |||
| for( i = t->h - 1; i--; ) | |||
| { | |||
| t->left[i+1] = t->left[i]; | |||
| t->right[i+1] = t->right[i]; | |||