From 3e6273504781ffcacc62105c1c2e628a23bc7469 Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 9 Nov 2003 23:34:24 +0000 Subject: [PATCH] * src/*.c: + Added missing #include "config.h". + Fixed a nasty bug in ee_rand() calls. git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/ttyvaders/trunk@110 92316355-f0b4-4df1-b90c-862c8a59935f --- src/aliens.c | 4 +++- src/bonus.c | 2 ++ src/box.c | 2 ++ src/collide.c | 6 ++++-- src/explosions.c | 4 +++- src/main.c | 6 ++++-- src/overlay.c | 2 ++ src/player.c | 2 ++ src/starfield.c | 20 +++++++++++--------- src/tunnel.c | 4 ++-- src/weapons.c | 2 ++ 11 files changed, 37 insertions(+), 17 deletions(-) diff --git a/src/aliens.c b/src/aliens.c index 1a9d896..78abaa8 100644 --- a/src/aliens.c +++ b/src/aliens.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h" @@ -72,7 +74,7 @@ void update_aliens(game *g, aliens *al) { add_explosion(g, g->ex, al->x[i], al->y[i], 0, 0, EXPLOSION_MEDIUM); al->type[i] = ALIEN_NONE; - add_bonus(g, g->bo, al->x[i], al->y[i], ee_rand(0,5) ? BONUS_GREEN : BONUS_LIFE); + add_bonus(g, g->bo, al->x[i], al->y[i], ee_rand(0,4) ? BONUS_GREEN : BONUS_LIFE); } /* Update coordinates */ diff --git a/src/bonus.c b/src/bonus.c index 92035c9..103c94e 100644 --- a/src/bonus.c +++ b/src/bonus.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h" diff --git a/src/box.c b/src/box.c index 041d3d7..5f5d74f 100644 --- a/src/box.c +++ b/src/box.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h" diff --git a/src/collide.c b/src/collide.c index a59b252..9375484 100644 --- a/src/collide.c +++ b/src/collide.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h" @@ -125,12 +127,12 @@ void collide_weapons_tunnel(game *g, weapons *wp, tunnel *t, explosions *ex) if(x - 2 <= t->left[y-j]) { add_explosion(g, ex, GET_MIN(t->left[y-j], x+3), y-j, 0, 1, EXPLOSION_SMALL); - t->left[y-j] -= ee_rand(0,3); + t->left[y-j] -= ee_rand(0,2); } else if(x + 3 >= t->right[y-j]) { add_explosion(g, ex, GET_MAX(t->right[y-j], x-2), y-j, 0, 1, EXPLOSION_SMALL); - t->right[y-j] += ee_rand(0,3); + t->right[y-j] += ee_rand(0,2); } } break; diff --git a/src/explosions.c b/src/explosions.c index 6ca9472..03ea3c5 100644 --- a/src/explosions.c +++ b/src/explosions.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h" @@ -73,7 +75,7 @@ void draw_explosions(game *g, explosions *ex) #if 0 ee_color(GREEN); ee_goto(ex->x[i] + 3, ex->y[i]); - switch(ee_rand(0,3)) + switch(ee_rand(0,2)) { case 0: ee_putchar('p'); diff --git a/src/main.c b/src/main.c index 86ae445..6bd7bb1 100644 --- a/src/main.c +++ b/src/main.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include @@ -182,11 +184,11 @@ static void start_game (game *g) skip = 0; /* XXX: to be removed */ - if(ee_rand(0,10) == 0) + if(ee_rand(0, 9) == 0) { int list[3] = { ALIEN_FOO, ALIEN_BAR, ALIEN_BAZ }; - add_alien(g, g->al, 0, rand() % g->h / 2, list[ee_rand(0,3)]); + add_alien(g, g->al, 0, rand() % g->h / 2, list[ee_rand(0,2)]); } /* Update game rules */ diff --git a/src/overlay.c b/src/overlay.c index 637f1ed..cc0cba2 100644 --- a/src/overlay.c +++ b/src/overlay.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h" diff --git a/src/player.c b/src/player.c index ee57b12..7159ea9 100644 --- a/src/player.c +++ b/src/player.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h" diff --git a/src/starfield.c b/src/starfield.c index 85a3082..6884990 100644 --- a/src/starfield.c +++ b/src/starfield.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h" @@ -33,11 +35,11 @@ starfield * create_starfield(game *g) for(i = 0; i < STARS; i++) { - s[i].x = ee_rand(0, g->w); - s[i].y = ee_rand(0, g->h); - s[i].z = ee_rand(1, 4); - s[i].c = ee_rand(6, 8); - s[i].ch = ee_rand(0, 2) ? '.' : '\''; + s[i].x = ee_rand(0, g->w - 1); + s[i].y = ee_rand(0, g->h - 1); + s[i].z = ee_rand(1, 3); + s[i].c = ee_rand(6, 7); + s[i].ch = ee_rand(0, 1) ? '.' : '\''; } return s; @@ -66,11 +68,11 @@ void update_starfield(game *g, starfield *s) { if(s[i].x < 0) { - s[i].x = ee_rand(0, g->w); + s[i].x = ee_rand(0, g->w - 1); s[i].y = 0; - s[i].z = ee_rand(1, 3); - s[i].c = ee_rand(6, 8); - s[i].ch = ee_rand(0, 2) ? '.' : '\''; + s[i].z = ee_rand(1, 2); + s[i].c = ee_rand(6, 7); + s[i].ch = ee_rand(0, 1) ? '.' : '\''; } else if(s[i].y < g->h-1) { diff --git a/src/tunnel.c b/src/tunnel.c index 955d63d..0adfb79 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -169,8 +169,8 @@ void update_tunnel(game *g, tunnel *t) } /* Generate new values */ - i = delta[ee_rand(0,6)]; - j = delta[ee_rand(0,6)]; + i = delta[ee_rand(0,5)]; + j = delta[ee_rand(0,5)]; /* Check in which direction we need to alter tunnel */ if(t->right[1] - t->left[1] < t->w) diff --git a/src/weapons.c b/src/weapons.c index 84ad161..b861065 100644 --- a/src/weapons.c +++ b/src/weapons.c @@ -20,6 +20,8 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "config.h" + #include #include "common.h"