Changed Positions to Float, added that one game_loop can now take longer as 20ms and Animations needs to be put in a other way to so everything will be right in time

origin
stpohle 22 years ago
parent c9493ffc1f
commit b69ff0ae4e

@ -1,4 +1,9 @@
$Id: TODO,v 1.23 2003/08/30 11:45:54 stpohle Exp $ $Id: TODO,v 1.24 2003/11/05 12:15:12 stpohle Exp $
- new menudesign
- multiplayer broadcast in the local network
ip: 10.*.*.* and 192.168.*.*
- more specials (Kicking Bomb) - more specials (Kicking Bomb)

@ -1,4 +1,4 @@
# Anjuta Version 1.0.2 # Anjuta Version 1.1.97
Compatibility Level: 1 Compatibility Level: 1
<PROJECT_DESCRIPTION_START> <PROJECT_DESCRIPTION_START>
@ -39,16 +39,17 @@ echo "T $target H $host B $buid" >cross-target.txt
props.file.type=project props.file.type=project
anjuta.version=1.0.2 anjuta.version=1.1.97
anjuta.compatibility.level=1 anjuta.compatibility.level=1
project.name=bomberclone project.name=bomberclone
project.type=GENERIC project.type=GENERIC
project.target.type=EXECUTABLE project.target.type=EXECUTABLE
project.version=0.9.9 project.version=0.11.0
project.author=steffen project.author=steffen
project.source.target=bomberclone project.source.target=bomberclone
project.has.gettext=0 project.has.gettext=0
project.gui.command=
project.programming.language=C project.programming.language=C
project.excluded.modules=intl project.excluded.modules=intl
@ -65,22 +66,25 @@ project.menu.need.terminal=0
project.configure.options= project.configure.options=
anjuta.program.arguments= anjuta.program.arguments=
preferences.build.option.jobs=0
preferences.build.option.silent=0
preferences.build.option.autosave=0
preferences.anjuta.make.options=-k
preferences.make=make
preferences.build.option.keep.going=0
preferences.build.option.warn.undef=0
preferences.autoformat.custom.style=-br -brs -l100 -lc100 -lp -hnl -bc -nip -nce -ncdw -bli1 -i4 -ts1-bad -bap
preferences.autoformat.style=Custom style
preferences.indent.opening=0
preferences.autoformat.disable=0
preferences.indent.automatic=1 preferences.indent.automatic=1
preferences.use.tabs=1 preferences.use.tabs=1
preferences.indent.opening=0
preferences.indent.closing=0
preferences.tabsize=4
preferences.indent.size=4 preferences.indent.size=4
preferences.autoformat.style=Custom style preferences.tabsize=4
preferences.autoformat.custom.style=-br -brs -l100 -lc100 -lp -hnl -bc -nip -nce -ncdw -bli1 -i4 -ts1-bad -bap preferences.indent.closing=0
preferences.autoformat.disable=0
preferences.debugger.command=gdb
preferences.ui.designer=glade '$(project.name).glade'
preferences.help.browser=devhelp -s '$(current.file.selection)'
module.include.name=include module.include.name=include
module.include.type= module.include.type=
module.include.expanded=1
module.include.files=\ module.include.files=\
basic.h\ basic.h\
bomberclone.h\ bomberclone.h\
@ -97,7 +101,6 @@ module.include.files=\
module.source.name=src module.source.name=src
module.source.type= module.source.type=
module.source.expanded=1
module.source.files=\ module.source.files=\
sysfunc.c\ sysfunc.c\
udp.c\ udp.c\
@ -130,25 +133,20 @@ module.source.files=\
module.pixmap.name=pixmaps module.pixmap.name=pixmaps
module.pixmap.type= module.pixmap.type=
module.pixmap.expanded=0
module.pixmap.files= module.pixmap.files=
module.data.name=data module.data.name=data
module.data.type= module.data.type=
module.data.expanded=0
module.data.files= module.data.files=
module.help.name=help module.help.name=help
module.help.type= module.help.type=
module.help.expanded=0
module.help.files= module.help.files=
module.doc.name=doc module.doc.name=doc
module.doc.type= module.doc.type=
module.doc.expanded=0
module.doc.files= module.doc.files=
module.po.expanded=0
module.po.files= module.po.files=
compiler.options.supports= compiler.options.supports=
@ -157,11 +155,12 @@ compiler.options.library.paths=
compiler.options.libraries= compiler.options.libraries=
compiler.options.libraries.selected= compiler.options.libraries.selected=
compiler.options.defines= compiler.options.defines=
compiler.options.defines.selected=
compiler.options.warning.buttons=0 0 1 1 1 1 1 1 1 1 1 0 1 0 0 1 compiler.options.warning.buttons=0 0 1 1 1 1 1 1 1 1 1 0 1 0 0 1
compiler.options.optimize.buttons=0 1 0 0 compiler.options.optimize.buttons=0 1 0 0
compiler.options.other.buttons=1 0 compiler.options.other.buttons=1 0
compiler.options.other.c.flags= compiler.options.other.c.flags=
compiler.options.other.l.flags= compiler.options.other.l.flags=
compiler.options.other.l.libs= compiler.options.other.l.libs=
project.source.paths=
project.src.paths=

@ -4,7 +4,7 @@ dnl If you don't want it to overwrite it,
dnl Please disable it in the Anjuta project configuration dnl Please disable it in the Anjuta project configuration
AC_INIT(configure.in) AC_INIT(configure.in)
AM_INIT_AUTOMAKE(bomberclone, 0.10.1) AM_INIT_AUTOMAKE(bomberclone, 0.11.0)
AM_CONFIG_HEADER AM_CONFIG_HEADER
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
@ -79,28 +79,28 @@ AC_SUBST(MATHLIB)
dnl Check for OpenGL ***********************+ dnl Check for OpenGL ***********************+
AC_MSG_CHECKING(for OpenGL support) dnl AC_MSG_CHECKING(for OpenGL support)
have_opengl=no dnl have_opengl=no
AC_TRY_COMPILE([ dnl AC_TRY_COMPILE([
#if defined(__APPLE__) && defined(__MACH__) dnl #if defined(__APPLE__) && defined(__MACH__)
#include <OpenGL/gl.h> dnl #include <OpenGL/gl.h>
#include <OpenGL/glu.h> dnl #include <OpenGL/glu.h>
#else dnl #else
#include <GL/gl.h> dnl #include <GL/gl.h>
#include <GL/glu.h> dnl #include <GL/glu.h>
#endif dnl #endif
],[ dnl ],[
],[ dnl ],[
have_opengl=yes dnl have_opengl=yes
]) dnl ])
AC_MSG_RESULT($have_opengl) dnl AC_MSG_RESULT($have_opengl)
if test x$have_opengl = xyes; then dnl if test x$have_opengl = xyes; then
CFLAGS="$CFLAGS" dnl CFLAGS="$CFLAGS"
LIBS="$LIBS $SYS_GL_LIBS" dnl LIBS="$LIBS $SYS_GL_LIBS"
AC_DEFINE(HAVE_OPENGL, [1], [OpenGL Headers found]) dnl AC_DEFINE(HAVE_OPENGL, [1], [OpenGL Headers found])
else dnl else
AC_MSG_WARN(Unable to find OpenGL headers and libraries) dnl AC_MSG_WARN(Unable to find OpenGL headers and libraries)
fi dnl fi

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.4 2003/09/23 20:28:24 stpohle Exp $ */ /* $Id: basic.h,v 1.5 2003/11/05 12:15:25 stpohle Exp $ */
/* basic types which we need everywhere */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -19,7 +19,7 @@
#define GAME_TUNNEL_TO 50 /* wait 5 game cycls before move and show #define GAME_TUNNEL_TO 50 /* wait 5 game cycls before move and show
player again */ player again */
#define EXPLOSION_SAVE_DISTANCE 64 #define EXPLOSION_SAVE_DISTANCE 0.25
#define SPECIAL_TRIGGER_TIMEOUT 15 #define SPECIAL_TRIGGER_TIMEOUT 15
#define SPECIAL_TRIGGER_NUMUSE 5 // 0=unlimited #define SPECIAL_TRIGGER_NUMUSE 5 // 0=unlimited
#define SPECIAL_TRIGGER_TIME 25 #define SPECIAL_TRIGGER_TIME 25
@ -28,7 +28,7 @@
#define START_BOMBS 1 #define START_BOMBS 1
#define START_RANGE 2 #define START_RANGE 2
#define START_SPEED 16 #define START_SPEED 0.05
#define SPEEDMUL 1.2 #define SPEEDMUL 1.2
#define MAX_PLAYERS 8 #define MAX_PLAYERS 8
@ -78,6 +78,9 @@
#define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (bman.players[__result].gfx_nr != __gfx_nr) && (__result >= 0); __result--); #define MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (bman.players[__result].gfx_nr != __gfx_nr) && (__result >= 0); __result--);
#define CUTINT(__x) (__x-floorf(__x)) // cut the integer part off
#define postofield(__x) ((int)(rintf(__x))) // position to int with rounding
#include <SDL.h> #include <SDL.h>
enum _networkflags { enum _networkflags {
@ -242,4 +245,10 @@ struct {
Sint16 y; Sint16 y;
} typedef _point; } typedef _point;
struct {
float x;
float y;
} typedef _pointf;
#endif #endif

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.4 2003/09/23 20:28:24 stpohle Exp $ */ /* $Id: bomberclone.h,v 1.5 2003/11/05 12:15:25 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -12,6 +12,7 @@
#include <time.h> #include <time.h>
#include <ctype.h> #include <ctype.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <math.h>
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include <winsock.h> #include <winsock.h>
@ -54,7 +55,7 @@ struct {
struct { struct {
_point pos; // lower byte = _X Higher Byte = FX _pointf pos; // lower byte = _X Higher Byte = FX
int firer[4]; // range of the fire for the fire for each direction int firer[4]; // range of the fire for the fire for each direction
int firerst[4]; /* just save here where the direction was going to stop (-1) int firerst[4]; /* just save here where the direction was going to stop (-1)
if the exp is still growing */ if the exp is still growing */
@ -66,7 +67,7 @@ struct {
unsigned char mode; // mode of the bomb BM_* unsigned char mode; // mode of the bomb BM_*
int ex_nr; // explosion number int ex_nr; // explosion number
_point dest; // destination to move the bomb to _point dest; // destination to move the bomb to
int speed; // bomb moving speed float speed; // bomb moving speed
} typedef _bomb; } typedef _bomb;
@ -88,11 +89,10 @@ struct {
int illframe; int illframe;
int illframeto; int illframeto;
_point pos; /* position (without the offset) _pointf pos; // position on the field
_x = pos.x & 255; fx = pos.x >> 8; */ _pointf old; // the old position
_point old; // the old position int tunnelto; /* timeout for dont show and move player
int tunnelto; /* timeout for dont show and move player needed on the tunnel effect */
needed on the tunnel effect */
signed char d; // direction signed char d; // direction
signed char m; // player is moving ? signed char m; // player is moving ?
@ -102,8 +102,7 @@ struct {
int bomb_lastex; // number of the bomb which explode the last time int bomb_lastex; // number of the bomb which explode the last time
_bomb bombs[MAX_BOMBS]; // number of bombs who are ticking. _bomb bombs[MAX_BOMBS]; // number of bombs who are ticking.
int range; // range of the bombs int range; // range of the bombs
int speed; // how fast we can go (0 = slow, 1 = normal... 3 = fastest) float speed; // how fast we can go (0 = slow, 1 = normal... 3 = fastest)
int speeddat; // some data i need to do the speed thing
_playerilness ill[PI_max]; // all possible types _playerilness ill[PI_max]; // all possible types
_special special; // special the player has _special special; // special the player has
@ -176,6 +175,7 @@ struct {
extern _bomberclone bman; extern _bomberclone bman;
extern Uint32 timestamp; extern Uint32 timestamp;
extern float timefactor;
extern int debug; extern int debug;
// Game routines.. // Game routines..
@ -206,7 +206,7 @@ extern void restore_players_screen ();
extern void move_player (int pl_nr); extern void move_player (int pl_nr);
extern int stepmove_player (int pl_nr); extern int stepmove_player (int pl_nr);
extern void player_drop_bomb (int pl_nr); extern void player_drop_bomb (int pl_nr);
extern void get_player_on (short int x, short int y, int pl_nr[]); extern void get_player_on (float x, float y, int pl_nr[]);
extern void player_died (_player * player, signed char dead_by); extern void player_died (_player * player, signed char dead_by);
extern void draw_players (); extern void draw_players ();
extern void player_animation (_player * player); extern void player_animation (_player * player);
@ -220,14 +220,14 @@ extern void player_check_powerup (int p_nr);
extern void player_set_gfx (_player *p, signed char gfx_nr); extern void player_set_gfx (_player *p, signed char gfx_nr);
extern int player_findfreebomb (_player *player); extern int player_findfreebomb (_player *player);
extern int player_checkpos (int x, int y); extern int player_checkpos (int x, int y);
extern inline int postofield (int pos); // extern inline int postofield (int pos);
// for the bomb.. // for the bomb..
extern int bomb_loop (); extern int bomb_loop ();
extern void bomb_explode (int p, int b, int net); extern void bomb_explode (int p, int b, int net);
extern inline void bomb_action (_bomb *bomb); extern inline void bomb_action (_bomb *bomb);
extern void bomb_move (_bomb *bomb); extern void bomb_move (_bomb *bomb);
extern void get_bomb_on (short int x, short int y, _point bombs[]); extern void get_bomb_on (float x, float y, _point bombs[]);
extern void draw_fire (int x, int y, int d, int frame); extern void draw_fire (int x, int y, int d, int frame);
extern void do_explosion (int p, int b); extern void do_explosion (int p, int b);
extern void restore_explosion (_bomb * bomb); extern void restore_explosion (_bomb * bomb);

@ -40,6 +40,10 @@ network.h file... for everything what have to do with the network stuff
#define HTON32(__i) (__i) #define HTON32(__i) (__i)
#endif #endif
/* converting of float to int and other direction */
#define FTOI16(__x) ((Sint16)((float)(__x * 256.0f)))
#define I16TOF(__x) (((float)__x) / 256.0f)
#ifdef _WIN32 #ifdef _WIN32
#define _sockaddr sockaddr #define _sockaddr sockaddr
#else #else

@ -1,4 +1,4 @@
/* $Id: bomb.c,v 1.46 2003/09/09 14:12:59 stpohle Exp $ */ /* $Id: bomb.c,v 1.47 2003/11/05 12:15:25 stpohle Exp $ */
/* everything what have to do with the bombs */ /* everything what have to do with the bombs */
#include "bomberclone.h" #include "bomberclone.h"
@ -12,8 +12,8 @@ draw_bomb (_bomb * bomb)
int x = bomb->pos.x, int x = bomb->pos.x,
y = bomb->pos.y; y = bomb->pos.y;
if (x < 0 || y < 0 || x>>8 >= map.size.x || y>>8 >= map.size.y) { if (x < 0 || y < 0 || x >= map.size.x || y >= map.size.y) {
d_printf ("FATAL: Draw Bomb out of range [%d,%d]\n", x, y); d_printf ("FATAL: Draw Bomb out of range [%f,%f]\n", x, y);
return; return;
} }
@ -32,18 +32,18 @@ draw_bomb (_bomb * bomb)
dest.w = src.w = gfx.bomb.image->w; dest.w = src.w = gfx.bomb.image->w;
dest.h = src.h = gfx.block.y; dest.h = src.h = gfx.block.y;
dest.x = gfx.offset.x + (x >> 8) * gfx.block.x + gfx.postab[bomb->pos.x & 0x0FF]; dest.x = gfx.offset.x + x * gfx.block.x;
dest.y = gfx.offset.y + (y >> 8) * gfx.block.y + gfx.postab[bomb->pos.y & 0x0FF]; dest.y = gfx.offset.y + y * gfx.block.y;
src.x = 0; src.x = 0;
src.y = src.h * bomb->frame; src.y = src.h * bomb->frame;
stonelist_add (x>>8, y>>8); stonelist_add (x, y);
if (bomb->mode != BM_normal) { if (bomb->mode != BM_normal) {
stonelist_add ((x>>8)+1, y>>8); stonelist_add (x+1, y);
stonelist_add (x>>8, (y>>8)+1); stonelist_add (x, y+1);
stonelist_add ((x>>8)+1, (y>>8)+1); stonelist_add (x+1, y+1);
} }
gfx_blit (gfx.bomb.image, &src, gfx.screen, &dest, y + 2); gfx_blit (gfx.bomb.image, &src, gfx.screen, &dest, (y*256) + 2);
}; };
@ -53,7 +53,7 @@ bomb_explode (int p, int b, int net)
int d; int d;
_bomb *bomb = &bman.players[p].bombs[b]; _bomb *bomb = &bman.players[p].bombs[b];
d_printf ("Bomb Explode p:%d, b:%d [%d,%d]\n", p, b, bomb->pos.x, bomb->pos.y); d_printf ("Bomb Explode p:%d, b:%d [%f,%f]\n", p, b, bomb->pos.x, bomb->pos.y);
if (bomb->ex_nr == -1) if (bomb->ex_nr == -1)
bomb->ex_nr = bman.last_ex_nr++; // set bomb explosion id bomb->ex_nr = bman.last_ex_nr++; // set bomb explosion id
@ -80,32 +80,34 @@ void
bomb_move (_bomb * bomb) bomb_move (_bomb * bomb)
{ {
int step = 0, dist = 0, keepdir = 0; int step = 0, dist = 0, keepdir = 0;
_point fpos, rpos; _pointf fpos, rpos;
map.bfield[bomb->pos.x>>8][bomb->pos.y>>8] = 0; /* delete bfield */ map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 0; /* delete bfield */
stonelist_add (bomb->pos.x>>8, bomb->pos.y>>8); stonelist_add (bomb->pos.x, bomb->pos.y);
/* do this once, and again if the direction is still ok */ /* do this once, and again if the direction is still ok */
do { do {
/* get the current position of the bomb */ /* get the current position of the bomb */
fpos.x = bomb->pos.x >> 8; fpos.x = rintf (bomb->pos.x);
fpos.y = bomb->pos.y >> 8; fpos.y = rintf (bomb->pos.y);
rpos.x = bomb->pos.x & 0xFF; rpos.x = fpos.x - bomb->pos.x;
rpos.y = bomb->pos.y & 0xFF; rpos.y = fpos.y - bomb->pos.y;
if (rpos.x < 0) rpos.x = -rpos.x; // only positive values
if (rpos.y < 0) rpos.y = -rpos.y; // only positive values
/* calculate the next step speed or next full field.. /* calculate the next step speed or next full field..
depend on what is the smaler one */ depend on what is the smaler one */
if (bomb->dest.x < 0) if (bomb->dest.x < 0)
step = rpos.x; step = rpos.x;
else if (bomb->dest.x > 0) else if (bomb->dest.x > 0)
step = 0x100 - rpos.x; step = 1.0f - rpos.x;
else if (bomb->dest.y < 0) else if (bomb->dest.y < 0)
step = rpos.y; step = rpos.y;
else if (bomb->dest.y > 0) else if (bomb->dest.y > 0)
step = 0x100 - rpos.y; step = 1.0f - rpos.y;
if (step > bomb->speed || step == 0) if (step > (timefactor * bomb->speed) || step == 0)
step = bomb->speed; step = (timefactor * bomb->speed);
/* move the bomb to the new position */ /* move the bomb to the new position */
if (bomb->dest.x < 0) if (bomb->dest.x < 0)
@ -119,15 +121,15 @@ bomb_move (_bomb * bomb)
/* if we are on a complete field, check if we /* if we are on a complete field, check if we
can move to the next one */ can move to the next one */
if (((bomb->pos.x & 0xFF) == 0) && ((bomb->pos.y & 0xFF) == 0)) { if ((CUTINT(bomb->pos.x) == 0.0f) && (CUTINT(bomb->pos.y) == 0.0f)) {
if (bomb->mode == BM_pushed) if (bomb->mode == BM_pushed)
bomb->mode = BM_normal; bomb->mode = BM_normal;
else if (bomb->mode == BM_moving || bomb->mode == BM_liquid) { else if (bomb->mode == BM_moving || bomb->mode == BM_liquid) {
/* it is a moving liquid bomb so check for another field */ /* it is a moving liquid bomb so check for another field */
_point b, d; _point b, d;
b.x = bomb->pos.x >> 8; b.x = bomb->pos.x;
b.y = bomb->pos.y >> 8; b.y = bomb->pos.y;
d.x = b.x + bomb->dest.x; d.x = b.x + bomb->dest.x;
d.y = b.y + bomb->dest.y; d.y = b.y + bomb->dest.y;
@ -163,10 +165,10 @@ bomb_move (_bomb * bomb)
} }
} }
dist += step; dist += step;
} while (dist < bomb->speed && (bomb->mode == BM_liquid || bomb->mode == BM_moving) && keepdir); } while (dist < (timefactor * bomb->speed) && (bomb->mode == BM_liquid || bomb->mode == BM_moving) && keepdir);
map.bfield[bomb->pos.x>>8][bomb->pos.y>>8] = 1; /* set new bfield */ map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 1; /* set new bfield */
stonelist_add (bomb->pos.x>>8, bomb->pos.y>>8); stonelist_add (bomb->pos.x, bomb->pos.y);
} }
@ -234,7 +236,7 @@ bomb_loop ()
/* check if on the givin place is a bomb /* check if on the givin place is a bomb
bombs[].x = player, bombs[].y = bombnumber */ bombs[].x = player, bombs[].y = bombnumber */
void void
get_bomb_on (short int x, short int y, _point bombs[]) get_bomb_on (float x, float y, _point bombs[])
{ {
int p, int p,
b, b,
@ -246,7 +248,7 @@ get_bomb_on (short int x, short int y, _point bombs[])
for (b = 0; b < MAX_BOMBS; b++) { for (b = 0; b < MAX_BOMBS; b++) {
bomb = &bman.players[p].bombs[b]; bomb = &bman.players[p].bombs[b];
if (bomb->state == BS_ticking || bomb->state == BS_trigger) { if (bomb->state == BS_ticking || bomb->state == BS_trigger) {
if (bomb->pos.x-0x100 < x && bomb->pos.x+0x100 > x && bomb->pos.y-0x100 < y && bomb->pos.y+0x100 > y) { if (bomb->pos.x-1.0f < x && bomb->pos.x+1.0f > x && bomb->pos.y-1.0f < y && bomb->pos.y+1.0f > y) {
bombs[i].x = p; bombs[i].x = p;
bombs[i].y = b; bombs[i].y = b;
i++; i++;
@ -257,6 +259,7 @@ get_bomb_on (short int x, short int y, _point bombs[])
bombs[i].x = bombs[i].y = -1; bombs[i].x = bombs[i].y = -1;
}; };
/* if frame == -1 we will draw the framenumber in /* if frame == -1 we will draw the framenumber in
the field.ex data */ the field.ex data */
void void
@ -277,7 +280,7 @@ draw_fire (int x, int y, int d, int frame)
src.y = frame * src.w; src.y = frame * src.w;
src.x = d * src.w; src.x = d * src.w;
gfx_blit (gfx.fire.image, &src, gfx.screen, &dest, (y << 8)); gfx_blit (gfx.fire.image, &src, gfx.screen, &dest, (y * 100));
}; };
@ -288,10 +291,6 @@ restore_explosion (_bomb * bomb)
d, dx = 0, d, dx = 0,
dy = 0, _x, dy = 0, _x,
_y; _y;
_point bpos;
bpos.x = bomb->pos.x >> 8;
bpos.y = bomb->pos.y >> 8;
for (d = 0; d < 4; d++) { for (d = 0; d < 4; d++) {
switch (d) { switch (d) {
@ -313,8 +312,8 @@ restore_explosion (_bomb * bomb)
break; break;
} }
_x = bpos.x; _x = bomb->pos.x;
_y = bpos.y; _y = bomb->pos.y;
for (i = 0; i < bomb->firer[d]; i++) { for (i = 0; i < bomb->firer[d]; i++) {
if (--map.field[_x][_y].ex[d].count == 0) // there was only one explosion so if (--map.field[_x][_y].ex[d].count == 0) // there was only one explosion so
@ -352,14 +351,14 @@ restore_explosion (_bomb * bomb)
net_game_send_field (_x, _y); net_game_send_field (_x, _y);
} }
} }
_x = bpos.x; _x = bomb->pos.x;
_y = bpos.y; _y = bomb->pos.y;
/* delete field from the bfield map */ /* delete field from the bfield map */
if (bomb->mode == BM_moving || bomb->mode == BM_pushed || bomb->mode == BM_liquid) if (bomb->mode == BM_moving || bomb->mode == BM_pushed || bomb->mode == BM_liquid)
map.bfield[bpos.x + bomb->dest.x][bpos.y + bomb->dest.y] = 0; map.bfield[(int)bomb->pos.x + bomb->dest.x][(int)bomb->pos.y + bomb->dest.y] = 0;
map.bfield[bpos.x][bpos.y] = 0; map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 0;
}; };
@ -379,8 +378,8 @@ explosion_check_field (int x, int y, int p, int b)
if (x < 0 || x >= map.size.x || y < 0 || y >= map.size.y) if (x < 0 || x >= map.size.x || y < 0 || y >= map.size.y)
return FT_block; return FT_block;
get_player_on (x << 8, y << 8, pl); get_player_on (x, y, pl);
get_bomb_on (x << 8, y << 8, bo); get_bomb_on (x, y, bo);
// check if any bomb have to explode.. // check if any bomb have to explode..
for (i = 0; bo[i].x != -1; i++) { for (i = 0; bo[i].x != -1; i++) {
@ -422,11 +421,7 @@ draw_explosion (_bomb * bomb)
r, r,
dx, dx,
dy; dy;
_point p, _point p;
bpos;
bpos.x = bomb->pos.x >> 8;
bpos.y = bomb->pos.y >> 8;
bomb->frameto--; bomb->frameto--;
if (bomb->frameto < 0 || bomb->frameto > ANI_FIRETIMEOUT) if (bomb->frameto < 0 || bomb->frameto > ANI_FIRETIMEOUT)
@ -451,8 +446,8 @@ draw_explosion (_bomb * bomb)
dy = 1; dy = 1;
break; break;
} }
p.x = bpos.x; p.x = bomb->pos.x;
p.y = bpos.y; p.y = bomb->pos.y;
for (r = 0; r < bomb->firer[d]; r++) { for (r = 0; r < bomb->firer[d]; r++) {
if (bomb->frameto == 0) { if (bomb->frameto == 0) {
@ -476,10 +471,6 @@ do_explosion (int p, int b)
int dx = 0, int dx = 0,
dy = 0, dy = 0,
d; d;
_point bpos;
bpos.x = bomb->pos.x >> 8;
bpos.y = bomb->pos.y >> 8;
for (d = 0; d < 4; d++) { for (d = 0; d < 4; d++) {
switch (d) { switch (d) {
@ -507,18 +498,18 @@ do_explosion (int p, int b)
dx = bomb->firer[d] * dx; dx = bomb->firer[d] * dx;
dy = bomb->firer[d] * dy; dy = bomb->firer[d] * dy;
checkfield = explosion_check_field (bpos.x + dx, bpos.y + dy, p, b); checkfield = explosion_check_field (bomb->pos.x + dx, bomb->pos.y + dy, p, b);
if ((checkfield == FT_nothing || checkfield == FT_tunnel) if ((checkfield == FT_nothing || checkfield == FT_tunnel)
&& bomb->firerst[d] == -1) { && bomb->firerst[d] == -1) {
bomb->firer[d]++; bomb->firer[d]++;
map.field[bpos.x + dx][bpos.y + dy].ex[d].count++; map.field[(int)bomb->pos.x + dx][(int)bomb->pos.y + dy].ex[d].count++;
map.field[bpos.x + dx][bpos.y + dy].ex[d].frame = bomb->firer[d]; map.field[(int)bomb->pos.x + dx][(int)bomb->pos.y + dy].ex[d].frame = bomb->firer[d];
/* if we have a slow pc we can enable this and disable the drawing animation */ /* if we have a slow pc we can enable this and disable the drawing animation */
// draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d, gfx.fire.frames>>1); // draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d, gfx.fire.frames>>1);
} }
else { else {
bomb->firerst[d] = bomb->firer[d]; bomb->firerst[d] = bomb->firer[d];
stonelist_add (bpos.x + dx, bpos.y + dy); stonelist_add (bomb->pos.x + dx, bomb->pos.y + dy);
} }
} }
} }

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.46 2003/08/29 22:04:19 stpohle Exp $ */ /* $Id: field.c,v 1.47 2003/11/05 12:15:25 stpohle Exp $ */
/* field.c - procedures which are needed to control the field */ /* field.c - procedures which are needed to control the field */
#include "bomberclone.h" #include "bomberclone.h"
@ -154,14 +154,14 @@ draw_stone (int x, int y)
} }
if (srcimg != NULL && stone->type != FT_tunnel) if (srcimg != NULL && stone->type != FT_tunnel)
gfx_blit (srcimg, &src, gfx.screen, &dest, (y << 8) + 1); gfx_blit (srcimg, &src, gfx.screen, &dest, (y*256) + 1);
else if (srcimg != NULL && stone->type == FT_tunnel) else if (srcimg != NULL && stone->type == FT_tunnel)
gfx_blit (srcimg, &src, gfx.screen, &dest, (y << 8) - 1); gfx_blit (srcimg, &src, gfx.screen, &dest, (y*256) - 1);
if (i >= FT_death) { /* draw now the powerup itself */ if (i >= FT_death) { /* draw now the powerup itself */
srcimg = gfx.field[i].image; srcimg = gfx.field[i].image;
src.y = 0; src.y = 0;
gfx_blit (srcimg, &src, gfx.screen, &dest, (y << 8) + 2); gfx_blit (srcimg, &src, gfx.screen, &dest, (y*256) + 2);
} }
/* if the current field is half hidden by the lower /* if the current field is half hidden by the lower
@ -177,7 +177,7 @@ draw_stone (int x, int y)
gfx.offset.y + ((gfx.block.y * (y + 1)) - gfx.offset.y + ((gfx.block.y * (y + 1)) -
(gfx.field[map.field[x][y + 1].type].h - (gfx.field[map.field[x][y + 1].type].h -
gfx.field[map.field[x][y + 1].type].w)); gfx.field[map.field[x][y + 1].type].w));
gfx_blit (gfx.field[map.field[x][y + 1].type].image, &src, gfx.screen, &dest, (y << 8) + 5); gfx_blit (gfx.field[map.field[x][y + 1].type].image, &src, gfx.screen, &dest, (y*256) + 5);
} }
// draw explosions if there is any // draw explosions if there is any
@ -188,7 +188,7 @@ draw_stone (int x, int y)
} }
if (debug) if (debug)
font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, (y << 8) - 6); font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, (y*256) - 6);
return; return;
}; };

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.56 2003/09/16 22:20:03 stpohle Exp $ /* $Id: game.c,v 1.57 2003/11/05 12:15:25 stpohle Exp $
game.c - procedures for the game. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -81,7 +81,7 @@ game_draw_info ()
font_draw (x, 0, text, 0); font_draw (x, 0, text, 0);
sprintf (text, "Range: %2d", bman.players[bman.p_nr].range); sprintf (text, "Range: %2d", bman.players[bman.p_nr].range);
font_draw (x, 16, text, 0); font_draw (x, 16, text, 0);
sprintf (text, "Speed: %2d", bman.players[bman.p_nr].speed); sprintf (text, "Speed: %1.1f", bman.players[bman.p_nr].speed*10);
font_draw (x, 32, text, 0); font_draw (x, 32, text, 0);
if (bman.players[bman.p_nr].special.type != 0) { if (bman.players[bman.p_nr].special.type != 0) {
dest.x = x - 32; dest.x = x - 32;
@ -246,6 +246,8 @@ game_loop ()
timediff1 = timeloop1 - timestamp; timediff1 = timeloop1 - timestamp;
timestamp = timeloop1; timestamp = timeloop1;
timefactor = ((float)timediff1) / 20.0f;
} }
chat_show (-1, -1, -1, -1); chat_show (-1, -1, -1, -1);

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.15 2003/07/08 21:16:04 stpohle Exp $ */ /* $Id: main.c,v 1.16 2003/11/05 12:15:25 stpohle Exp $ */
#include "bomberclone.h" #include "bomberclone.h"
#include "network.h" #include "network.h"
@ -10,6 +10,7 @@
_bomberclone bman; // Holds GameData _bomberclone bman; // Holds GameData
Uint32 timestamp; // timestamp Uint32 timestamp; // timestamp
float timefactor; // factor for the time
int int
main (int argc, char **argv) main (int argc, char **argv)

@ -1,4 +1,4 @@
/* $Id: map.c,v 1.11 2003/08/30 11:45:55 stpohle Exp $ */ /* $Id: map.c,v 1.12 2003/11/05 12:15:25 stpohle Exp $ */
/* map handling, like generate and load maps. */ /* map handling, like generate and load maps. */
#include "bomberclone.h" #include "bomberclone.h"
@ -202,8 +202,8 @@ map_set_playerposition (int usermap)
/* check if there is no block */ /* check if there is no block */
if ((dx > 1 || dy > 1) if ((dx > 1 || dy > 1)
&& ((map.field[PLX][PLY].type != FT_block && maxloop > 100) && ((map.field[(int)PLX][(int)PLY].type != FT_block && maxloop > 100)
|| map.field[PLX][PLY].type == FT_nothing)) { || map.field[(int)PLX][(int)PLY].type == FT_nothing)) {
/* get (up or down) dx and (left or right) dy */ /* get (up or down) dx and (left or right) dy */
dx = s_random (2); dx = s_random (2);
if (dx == 0) if (dx == 0)
@ -213,18 +213,18 @@ map_set_playerposition (int usermap)
dy = -1; dy = -1;
/* first check if there is and free place for us */ /* first check if there is and free place for us */
if (!((map.field[PLX + dx][PLY].type != FT_block && maxloop > 100) || if (!((map.field[(int)PLX + dx][(int)PLY].type != FT_block && maxloop > 100) ||
map.field[PLX + dx][PLY].type == FT_nothing)) map.field[(int)PLX + dx][(int)PLY].type == FT_nothing))
dx = -dx; dx = -dx;
if (!((map.field[PLX + dx][PLY].type != FT_block && maxloop > 100) || if (!((map.field[(int)PLX + dx][(int)PLY].type != FT_block && maxloop > 100) ||
map.field[PLX + dx][PLY].type == FT_nothing)) map.field[(int)PLX + dx][(int)PLY].type == FT_nothing))
PLX = -1; PLX = -1;
if (!((map.field[PLX][PLY + dy].type != FT_block && maxloop > 100) || if (!((map.field[(int)PLX][(int)PLY + dy].type != FT_block && maxloop > 100) ||
map.field[PLX][PLY + dy].type == FT_nothing)) map.field[(int)PLX][(int)PLY + dy].type == FT_nothing))
dy = -dy; dy = -dy;
if (!((map.field[PLX][PLY + dy].type != FT_block && maxloop > 100) || if (!((map.field[(int)PLX][(int)PLY + dy].type != FT_block && maxloop > 100) ||
map.field[PLX][PLY + dy].type == FT_nothing)) map.field[(int)PLX][(int)PLY + dy].type == FT_nothing))
PLY = -1; PLY = -1;
} }
else { else {
@ -233,17 +233,17 @@ map_set_playerposition (int usermap)
} }
/* make some space */ /* make some space */
if (PLX != -1 && PLY != -1) { if (PLX >= 0.0f && PLY >= 0.0f) {
if (map.field[PLX][PLY].type != FT_tunnel) if (map.field[(int)PLX][(int)PLY].type != FT_tunnel)
map.field[PLX][PLY].type = FT_nothing; map.field[(int)PLX][(int)PLY].type = FT_nothing;
if (map.field[PLX + dx][PLY].type != FT_tunnel) if (map.field[(int)PLX + dx][(int)PLY].type != FT_tunnel)
map.field[PLX + dx][PLY].type = FT_nothing; map.field[(int)PLX + dx][(int)PLY].type = FT_nothing;
if (map.field[PLX][PLY + dy].type != FT_tunnel) if (map.field[(int)PLX][(int)PLY + dy].type != FT_tunnel)
map.field[PLX][PLY + dy].type = FT_nothing; map.field[(int)PLX][(int)PLY + dy].type = FT_nothing;
} }
} }
} }
if (PLX == -1 || PLY == -1) { if (PLX < 0 || PLY < 0) {
/* we could not set all fields or we don't run on a usermap */ /* we could not set all fields or we don't run on a usermap */
if (usermap) { if (usermap) {
sprintf (txt, "Not all players could be set (Pl:%d)", i); sprintf (txt, "Not all players could be set (Pl:%d)", i);
@ -254,27 +254,27 @@ map_set_playerposition (int usermap)
PLX = 2 * (s_random ((map.size.x - 1) / 2)) + 1; PLX = 2 * (s_random ((map.size.x - 1) / 2)) + 1;
PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1; PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1;
if (map.field[PLX][PLY].type != FT_tunnel) if (map.field[(int)PLX][(int)PLY].type != FT_tunnel)
map.field[PLX][PLY].type = FT_nothing; map.field[(int)PLX][(int)PLY].type = FT_nothing;
dx = s_random (4); // bit 1 = up/down bit 2 = left/right dx = s_random (4); // bit 1 = up/down bit 2 = left/right
/* up and down */ /* up and down */
if (((dx & 1) == 0 && PLX > 1) || PLX >= map.size.x - 2) { if (((dx & 1) == 0 && PLX > 1.0f) || PLX >= map.size.x - 2) {
if (map.field[PLX - 1][PLY].type != FT_tunnel) if (map.field[(int)PLX - 1][(int)PLY].type != FT_tunnel)
map.field[PLX - 1][PLY].type = FT_nothing; map.field[(int)PLX - 1][(int)PLY].type = FT_nothing;
} }
else { else {
if (map.field[PLX + 1][PLY].type != FT_tunnel) if (map.field[(int)PLX + 1][(int)PLY].type != FT_tunnel)
map.field[PLX + 1][PLY].type = FT_nothing; map.field[(int)PLX + 1][(int)PLY].type = FT_nothing;
} }
/* left and right */ /* left and right */
if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2) { if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2) {
if (map.field[PLX][PLY - 1].type != FT_tunnel) if (map.field[(int)PLX][(int)PLY - 1].type != FT_tunnel)
map.field[PLX][PLY - 1].type = FT_nothing; map.field[(int)PLX][(int)PLY - 1].type = FT_nothing;
} }
else { else {
if (map.field[PLX][PLY + 1].type != FT_tunnel) if (map.field[(int)PLX][(int)PLY + 1].type != FT_tunnel)
map.field[PLX][PLY + 1].type = FT_nothing; map.field[(int)PLX][(int)PLY + 1].type = FT_nothing;
} }
} }
mx = my = 100; mx = my = 100;
@ -298,13 +298,7 @@ map_set_playerposition (int usermap)
p++; p++;
} }
} }
for (i = 0; i < MAX_PLAYERS; i++) {
PLX = PLX << 8;
PLY = PLY << 8;
}
}; };
#undef PLX #undef PLX
#undef PLY #undef PLY

@ -430,8 +430,8 @@ send_playerdata (_net_addr * addr, int p_nr, _player * pl)
else else
p_dat.h.flags = PKGF_ackreq; p_dat.h.flags = PKGF_ackreq;
p_dat.pos.x = HTON16 (pl->pos.x); p_dat.pos.x = HTON16 (FTOI16 (pl->pos.x));
p_dat.pos.y = HTON16 (pl->pos.y); p_dat.pos.y = HTON16 (FTOI16 (pl->pos.y));
p_dat.bombs_n = pl->bombs_n; p_dat.bombs_n = pl->bombs_n;
p_dat.d = pl->d; p_dat.d = pl->d;
p_dat.range = pl->range; p_dat.range = pl->range;
@ -469,8 +469,8 @@ do_playerdata (struct pkg_playerdata *p_dat, _net_addr * addr)
pl->dead_by = NTOH16 (p_dat->dead_by); pl->dead_by = NTOH16 (p_dat->dead_by);
} }
else if (bman.state != GS_running || bman.p_nr != p_dat->p_nr) { else if (bman.state != GS_running || bman.p_nr != p_dat->p_nr) {
pl->pos.x = NTOH16 (p_dat->pos.x); pl->pos.x = I16TOF (NTOH16 (p_dat->pos.x));
pl->pos.y = NTOH16 (p_dat->pos.y); pl->pos.y = I16TOF (NTOH16 (p_dat->pos.y));
pl->dead_by = p_dat->dead_by; pl->dead_by = p_dat->dead_by;
pl->points = NTOH16 (p_dat->points); pl->points = NTOH16 (p_dat->points);
pl->d = p_dat->d; pl->d = p_dat->d;
@ -520,8 +520,8 @@ send_playermove (_net_addr * addr, int p_nr, _player * pl)
p_dat.h.len = HTON16 (sizeof (struct pkg_playermove)); p_dat.h.len = HTON16 (sizeof (struct pkg_playermove));
p_dat.h.flags = 0; p_dat.h.flags = 0;
p_dat.pos.x = HTON16 (pl->pos.x); p_dat.pos.x = HTON16 (FTOI16 (pl->pos.x));
p_dat.pos.y = HTON16 (pl->pos.y); p_dat.pos.y = HTON16 (FTOI16 (pl->pos.y));
p_dat.m = pl->m; p_dat.m = pl->m;
p_dat.d = pl->d; p_dat.d = pl->d;
p_dat.p_nr = p_nr; p_dat.p_nr = p_nr;
@ -587,8 +587,8 @@ do_playermove (struct pkg_playermove *p_dat, _net_addr * addr)
pl->m = p_dat->m; pl->m = p_dat->m;
pl->d = p_dat->d; pl->d = p_dat->d;
pl->speed = p_dat->speed; pl->speed = p_dat->speed;
pl->pos.x = HTON16 (p_dat->pos.x); pl->pos.x = I16TOF (HTON16 (p_dat->pos.x));
pl->pos.y = HTON16 (p_dat->pos.y); pl->pos.y = I16TOF (HTON16 (p_dat->pos.y));
pl->tunnelto = HTON16 (p_dat->tunnelto); pl->tunnelto = HTON16 (p_dat->tunnelto);
} }
@ -610,7 +610,7 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
return; // if there was a bomb let it explose don't delete the bomb return; // if there was a bomb let it explose don't delete the bomb
d_printf ("do_bombdata [%d,%d] Player: %d Bomb: %d, ex_nr:%d\n", d_printf ("do_bombdata [%d,%d] Player: %d Bomb: %d, ex_nr:%d\n",
NTOH16 (b_dat->x) >> 8, NTOH16 (b_dat->y) >> 8, b_dat->p_nr, I16TOF(NTOH16 (b_dat->x)), I16TOF(NTOH16 (b_dat->y)), b_dat->p_nr,
b_dat->b_nr, NTOH32 (b_dat->ex_nr)); b_dat->b_nr, NTOH32 (b_dat->ex_nr));
bomb = &bman.players[b_dat->p_nr].bombs[b_dat->b_nr]; bomb = &bman.players[b_dat->p_nr].bombs[b_dat->b_nr];
@ -624,28 +624,29 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
d_printf ("do_bombdata WARNING : bomb explosion haven't finished\n"); d_printf ("do_bombdata WARNING : bomb explosion haven't finished\n");
if (bomb->state != BS_off) { // handle push & kick special if (bomb->state != BS_off) { // handle push & kick special
map.bfield[(bomb->pos.x >> 8)][(bomb->pos.y >> 8)] = 0; //remove bomb at old location map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 0; //remove bomb at old location
stonelist_add (bomb->pos.x >> 8, bomb->pos.y >> 8); stonelist_add (bomb->pos.x, bomb->pos.y);
} }
if (bomb->state == BS_off && (b_dat->state == BS_ticking || b_dat->state == BS_trigger)) if (bomb->state == BS_off && (b_dat->state == BS_ticking || b_dat->state == BS_trigger))
snd_play (SND_bombdrop); snd_play (SND_bombdrop);
bomb->pos.x = NTOH16 (b_dat->x); /* convert position back to float */
bomb->pos.y = NTOH16 (b_dat->y); bomb->pos.x = I16TOF (NTOH16 (b_dat->x));
bomb->pos.y = I16TOF (NTOH16 (b_dat->y));
if (bomb->state != b_dat->state && bomb->state != BS_ticking) if (bomb->state != b_dat->state && bomb->state != BS_ticking)
bomb->to = NTOH32 (b_dat->to); /* only set if the bomb isn't already ticking bomb->to = NTOH32 (b_dat->to); /* only set if the bomb isn't already ticking
to make sure the timeout won't be resetted to make sure the timeout won't be resetted
by an old network packet */ by an old network packet */
map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1; // keep the bfield up to date map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 1; // keep the bfield up to date
bomb->r = b_dat->r; bomb->r = b_dat->r;
bomb->ex_nr = NTOH32 (b_dat->ex_nr); bomb->ex_nr = NTOH32 (b_dat->ex_nr);
bomb->state = b_dat->state & 0x0F; bomb->state = b_dat->state & 0x0F;
bomb->mode = b_dat->state >> 4; bomb->mode = b_dat->state >> 4;
bomb->speed = NTOH16 (b_dat->speed); bomb->speed = I16TOF (NTOH16 (b_dat->speed));
bomb->dest.x = NTOH16 (b_dat->destx); bomb->dest.x = NTOH16 (b_dat->destx);
bomb->dest.y = NTOH16 (b_dat->desty); bomb->dest.y = NTOH16 (b_dat->desty);
@ -664,8 +665,8 @@ send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb)
b_dat.h.typ = PKG_bombdata; b_dat.h.typ = PKG_bombdata;
b_dat.h.len = HTON16 (sizeof (struct pkg_bombdata)); b_dat.h.len = HTON16 (sizeof (struct pkg_bombdata));
b_dat.x = HTON16 (bomb->pos.x); b_dat.x = HTON16 (FTOI16 (bomb->pos.x));
b_dat.y = HTON16 (bomb->pos.y); b_dat.y = HTON16 (FTOI16 (bomb->pos.y));
b_dat.to = HTON32 (bomb->to); b_dat.to = HTON32 (bomb->to);
b_dat.r = bomb->r; b_dat.r = bomb->r;
b_dat.ex_nr = HTON32 (bomb->ex_nr); b_dat.ex_nr = HTON32 (bomb->ex_nr);
@ -673,7 +674,7 @@ send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb)
b_dat.b_nr = b; b_dat.b_nr = b;
b_dat.p_nr = p; b_dat.p_nr = p;
b_dat.h.flags = PKGF_ackreq; b_dat.h.flags = PKGF_ackreq;
b_dat.speed = HTON16 (bomb->speed); b_dat.speed = HTON16 (FTOI16 (bomb->speed));
b_dat.destx = HTON16 (bomb->dest.x); b_dat.destx = HTON16 (bomb->dest.x);
b_dat.desty = HTON16 (bomb->dest.y); b_dat.desty = HTON16 (bomb->dest.y);
@ -724,6 +725,7 @@ send_tunneldata (_net_addr * addr, int tunnelnr, int x, int y)
} }
}; };
void void
send_quit (_net_addr * addr, char *plhost, char * plport) send_quit (_net_addr * addr, char *plhost, char * plport)
{ {

@ -12,10 +12,10 @@ draw_player (_player * player)
dest; dest;
int i; int i;
if ((player->pos.x >> 8) < 0 || (player->pos.x >> 8) >= map.size.x || if ((int)player->pos.x < 0 || (int)player->pos.x >= map.size.x ||
(player->pos.y >> 8) < 0 || (player->pos.y >> 8) >= map.size.y) { (int)player->pos.y < 0 || (int)player->pos.y >= map.size.y) {
d_printf ("FATAL: Draw Player out of range : [%d,%d]\n", (player->pos.x >> 8), d_printf ("FATAL: Draw Player out of range : [%f,%f]\n", player->pos.x,
(player->pos.y >> 8)); player->pos.y);
return; return;
} }
@ -24,15 +24,13 @@ draw_player (_player * player)
dest.w = src.w = player->gfx->ani.w; dest.w = src.w = player->gfx->ani.w;
dest.h = src.h = player->gfx->ani.h; dest.h = src.h = player->gfx->ani.h;
dest.x = dest.x =
gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x + gfx.offset.x + player->gfx->offset.x + player->pos.x * gfx.block.x;
gfx.postab[player->pos.x & 255];
dest.y = dest.y =
gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y + gfx.offset.y + player->gfx->offset.y + player->pos.y * gfx.block.y;
gfx.postab[player->pos.y & 255];
src.x = player->d * player->gfx->ani.w; src.x = player->d * player->gfx->ani.w;
src.y = player->frame * player->gfx->ani.h; src.y = player->frame * player->gfx->ani.h;
gfx_blit (player->gfx->ani.image, &src, gfx.screen, &dest, player->pos.y + 128); gfx_blit (player->gfx->ani.image, &src, gfx.screen, &dest, (player->pos.y * 256) + 128);
/* if the player is ill, draw this image above him */ /* if the player is ill, draw this image above him */
if (PS_IS_alife (player->state)) { if (PS_IS_alife (player->state)) {
@ -43,12 +41,10 @@ draw_player (_player * player)
src.x = 0; src.x = 0;
src.y = (2 * gfx.block.y) * player->illframe; src.y = (2 * gfx.block.y) * player->illframe;
dest.x = dest.x =
(-(gfx.block.x >> 1)) + gfx.offset.x + (player->pos.x >> 8) * gfx.block.x + gfx.offset.x + ((player->pos.x-0.5f) * gfx.block.x);
gfx.postab[player->pos.x & 255];
dest.y = dest.y =
gfx.offset.y + ((player->pos.y >> 8) - 1) * gfx.block.y + gfx.offset.y + ((player->pos.y - 1.0f) * gfx.block.y);
gfx.postab[player->pos.y & 255]; gfx_blit (gfx.ill.image, &src, gfx.screen, &dest, (player->pos.y*256) + 129);
gfx_blit (gfx.ill.image, &src, gfx.screen, &dest, player->pos.y + 129);
} }
} }
} }
@ -59,11 +55,9 @@ draw_player (_player * player)
dest.h = src.h = player->gfx->ani.h; dest.h = src.h = player->gfx->ani.h;
dest.x = dest.x =
gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x + gfx.offset.x + player->gfx->offset.x + player->pos.x * gfx.block.x;
gfx.postab[player->pos.x & 255];
dest.y = dest.y =
gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y + gfx.offset.y + player->gfx->offset.y + player->pos.y * gfx.block.y;
gfx.postab[player->pos.y & 255];
src.x = 0; src.x = 0;
src.y = (2 * gfx.block.y) * player->frame; src.y = (2 * gfx.block.y) * player->frame;
@ -86,31 +80,34 @@ restore_players_screen ()
ye; ye;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if ((PS_IS_used (bman.players[i].state)) && bman.players[i].old.x != -1) { if ((PS_IS_used (bman.players[i].state)) && bman.players[i].old.x >= 0.0f ) {
if ((bman.players[i].old.x >> 8) < 0 || (bman.players[i].old.x >> 8) >= map.size.x if (bman.players[i].old.x < 0.0f || bman.players[i].old.x >= map.size.x
|| (bman.players[i].old.y >> 8) < 0 || (bman.players[i].old.y >> 8) >= map.size.y) || bman.players[i].old.y < 0.0f || bman.players[i].old.y >= map.size.y)
d_printf ("FATAL: Restore Player out of range : playernr %d [%d,%d]\n", i, d_printf ("FATAL: Restore Player out of range : playernr %d [%f,%f]\n", i,
(bman.players[i].old.x >> 8), (bman.players[i].old.y >> 8)); bman.players[i].old.x, bman.players[i].old.y);
else { else {
if ((bman.players[i].old.x & 0xFF) > 128) { // start and end position for the stones to redraw X Position
x = (bman.players[i].old.x >> 8); if (CUTINT(bman.players[i].old.x) > 0.5f) {
xe = (bman.players[i].old.x >> 8) + 2; x = bman.players[i].old.x;
xe = bman.players[i].old.x + 2;
} }
else { else {
x = (bman.players[i].old.x >> 8) - 1; x = bman.players[i].old.x - 1;
xe = (bman.players[i].old.x >> 8) + 1; xe = bman.players[i].old.x + 1;
} }
if (x < 0) if (x < 0)
x = 0; x = 0;
if (xe >= map.size.x) if (xe >= map.size.x)
xe = map.size.x - 1; xe = map.size.x - 1;
ys = (bman.players[i].old.y >> 8) - 1; // start and end position for the stones to redraw X Position
ye = (bman.players[i].old.y >> 8) + 1; ys = bman.players[i].old.y - 1;
ye = bman.players[i].old.y + 1;
if (ys < 0) if (ys < 0)
ys = 0; ys = 0;
if (ye >= map.size.y) if (ye >= map.size.y)
ye = map.size.y - 1; ye = map.size.y - 1;
// redrawing of the stone
xs = x; xs = x;
for (; x <= xe; x++) for (; x <= xe; x++)
for (y = ys; y <= ye; y++) for (y = ys; y <= ye; y++)
@ -124,10 +121,8 @@ void
player_check_powerup (int p_nr) player_check_powerup (int p_nr)
{ {
_player *p = &bman.players[p_nr]; _player *p = &bman.players[p_nr];
int fx = p->pos.x >> 8; int fx = p->pos.x;
int fy = p->pos.y >> 8; int fy = p->pos.y;
int _x = p->pos.x & 255;
int _y = p->pos.y & 255;
int ft, int ft,
i; i;
@ -135,11 +130,12 @@ player_check_powerup (int p_nr)
return; return;
/* Get the right field position */ /* Get the right field position */
if (_x > 128) if (CUTINT(p->pos.x) > 0.5)
fx = fx + 1; fx = fx + 1;
if (_y > 128) if (CUTINT(p->pos.y) > 0.5)
fy = fy + 1; fy = fy + 1;
ft = map.field[fx][fy].type; ft = map.field[fx][fy].type;
/* we found a mixed powerup */ /* we found a mixed powerup */
if (ft == FT_mixed) { if (ft == FT_mixed) {
i = s_random (6); i = s_random (6);
@ -232,59 +228,55 @@ stepmove_player (int pl_nr)
_point bomb1[MAX_PLAYERS * MAX_BOMBS], _point bomb1[MAX_PLAYERS * MAX_BOMBS],
bomb2[MAX_PLAYERS * MAX_BOMBS]; bomb2[MAX_PLAYERS * MAX_BOMBS];
_player *p = &bman.players[pl_nr]; _player *p = &bman.players[pl_nr];
int speed = 0, int i,
i,
j, j,
f; f;
_point fpos, // field position _pointf _pos, // position inside the field
d; // distance to move
float speed = 0.0f;
_pos, // position inside the field
d;
if (p->m == 1) { if (p->m == 1) {
fpos.x = p->pos.x >> 8; _pos.x = CUTINT(p->pos.x);
fpos.y = p->pos.y >> 8; _pos.y = CUTINT(p->pos.y);
_pos.x = p->pos.x & 255;
_pos.y = p->pos.y & 255;
// do direction correction for going up/down // do direction correction for going up/down
if (_pos.x > 0 && _pos.x <= 128 && (p->d == up || p->d == down)) if (_pos.x > 0.0f && _pos.x <= 0.5f && (p->d == up || p->d == down))
p->d = left; p->d = left;
if (_pos.x > 128 && _pos.x < 256 && (p->d == up || p->d == down)) if (_pos.x > 0.5f && _pos.x < 1.0f && (p->d == up || p->d == down))
p->d = right; p->d = right;
// do direction correction for left/right // do direction correction for left/right
if (_pos.y > 0 && _pos.y <= 128 && (p->d == left || p->d == right)) if (_pos.y > 0.0f && _pos.y <= 0.5f && (p->d == left || p->d == right))
p->d = up; p->d = up;
if (_pos.y > 128 && _pos.y < 256 && (p->d == left || p->d == right)) if (_pos.y > 0.5f && _pos.y < 1.0f && (p->d == left || p->d == right))
p->d = down; p->d = down;
/* get the distance/speed until we reach the next position */ /* get the distance/speed until we reach the next position */
if (p->d == left) if (p->d == left)
speed = _pos.x; speed = _pos.x;
else if (p->d == right) else if (p->d == right)
speed = 256 - _pos.x; speed = 1.0f - _pos.x;
else if (p->d == up) else if (p->d == up)
speed = _pos.y; speed = _pos.y;
else else
speed = 256 - _pos.y; speed = 1.0f - _pos.y;
if (speed > p->speed || speed == 0) if (speed > (p->speed * timefactor) || speed == 0)
speed = p->speed; speed = p->speed * timefactor;
// check the new field position // check the new field position
d.x = d.y = 0; d.x = d.y = 0.0f;
if (p->d == left && _pos.y == 0 if (p->d == left && _pos.y == 0.0f
&& ((_pos.x == 0 && check_field (fpos.x - 1, fpos.y)) || (_pos.x > 0))) && ((_pos.x == 0.0f && check_field (p->pos.x - 1.0f, p->pos.y)) || (_pos.x > 0.0f)))
d.x = -speed; d.x = -speed;
if (p->d == right && _pos.y == 0 if (p->d == right && _pos.y == 0.0f
&& ((_pos.x == 0 && check_field (fpos.x + 1, fpos.y)) || (_pos.x > 0))) && ((_pos.x == 0.0f && check_field (p->pos.x + 1.0f, p->pos.y)) || (_pos.x > 0.0f)))
d.x = speed; d.x = speed;
if (p->d == up && _pos.x == 0 if (p->d == up && _pos.x == 0.0f
&& ((_pos.y == 0 && check_field (fpos.x, fpos.y - 1)) || (_pos.y > 0))) && ((_pos.y == 0.0f && check_field (p->pos.x, p->pos.y - 1.0f)) || (_pos.y > 0.0f)))
d.y = -speed; d.y = -speed;
if (p->d == down && _pos.x == 0 if (p->d == down && _pos.x == 0.0f
&& ((_pos.y == 0 && check_field (fpos.x, fpos.y + 1)) || (_pos.y > 0))) && ((_pos.y == 0.0f && check_field (p->pos.x, p->pos.y + 1.0f)) || (_pos.y > 0.0f)))
d.y = speed; d.y = speed;
// check if we can move and if there is any bomb // check if we can move and if there is any bomb
@ -294,7 +286,7 @@ stepmove_player (int pl_nr)
if (bomb1[0].x == -1 && bomb2[0].x != -1) if (bomb1[0].x == -1 && bomb2[0].x != -1)
/* old pos no bomb, new pos no bomb */ /* old pos no bomb, new pos no bomb */
d.x = d.y = 0; d.x = d.y = 0.0f;
else if (bomb2[0].x != -1) { else if (bomb2[0].x != -1) {
/* new pos bomb, old pos bomb... check if it's the same /* new pos bomb, old pos bomb... check if it's the same
use f to save if we found the bomb or not use f to save if we found the bomb or not
@ -305,7 +297,7 @@ stepmove_player (int pl_nr)
/* identical bomb found ... f = 1 */ /* identical bomb found ... f = 1 */
f = 1; f = 1;
if (f == 0) if (f == 0)
d.x = d.y = 0; d.x = d.y = 0.0f;
} }
} }
@ -314,39 +306,34 @@ stepmove_player (int pl_nr)
player_check_powerup (pl_nr); player_check_powerup (pl_nr);
fpos.x = p->pos.x >> 8; _pos.x = CUTINT(p->pos.x);
fpos.y = p->pos.y >> 8; _pos.y = CUTINT(p->pos.y);
_pos.x = p->pos.x & 255;
_pos.y = p->pos.y & 255;
/* check if we can go though a tunnel */ /* check if we can go though a tunnel */
if (_pos.x == 0 && _pos.y == 0 && map.field[fpos.x][fpos.y].type == FT_tunnel if (_pos.x == 0.0f && _pos.y == 0.0f && map.field[(int)p->pos.x][(int)p->pos.y].type == FT_tunnel
&& p->tunnelto == -1) { && p->tunnelto == -1) {
d_printf ("Tunnel [%d] Player %s is going to (%d,%d)\n", d_printf ("Tunnel [%d] Player %s is going to (%d,%d)\n",
map.field[fpos.x][fpos.y].special, p->name, map.field[(int)p->pos.x][(int)p->pos.y].special, p->name,
map.tunnel[map.field[fpos.x][fpos.y].special].x, map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x,
map.tunnel[map.field[fpos.x][fpos.y].special].y); map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y);
d.x = d.y = 0; d.x = d.y = 0.0f;
if (map. if (map.
bfield[map.tunnel[map.field[fpos.x][fpos.y].special].x][map. bfield[map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x]
tunnel[map. [map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y])
field[fpos.x][fpos.
y].
special].y])
d_printf (" *** End of tunnel is with an bomb.\n"); d_printf (" *** End of tunnel is with an bomb.\n");
else { else {
p->pos.x = map.tunnel[map.field[fpos.x][fpos.y].special].x << 8; p->pos.x = map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x << 8;
p->pos.y = map.tunnel[map.field[fpos.x][fpos.y].special].y << 8; p->pos.y = map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y << 8;
p->tunnelto = GAME_TUNNEL_TO; p->tunnelto = GAME_TUNNEL_TO;
speed = p->speed; speed = p->speed * timefactor;
} }
} }
} }
if (d.x == 0 && d.y == 0) if (d.x == 0.0f && d.y == 0.0f)
return 0; return 0;
return (p->speed - speed); return (p->speed - (speed/timefactor));
}; };
@ -404,7 +391,7 @@ move_player (int pl_nr)
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_playermove (pl_nr, (p->old_m == 0)); net_game_send_playermove (pl_nr, (p->old_m == 0));
if (p->tunnelto == 0 && (map.field[postofield(p->pos.x)][postofield(p->pos.y)].type != FT_tunnel || !field_check_alldirs (p->pos.x>>8, p->pos.y>>8, FT_nothing))) if (p->tunnelto == 0 && (map.field[postofield(p->pos.x)][postofield(p->pos.y)].type != FT_tunnel || !field_check_alldirs (postofield(p->pos.x), postofield(p->pos.y), FT_nothing)))
p->tunnelto = -1; p->tunnelto = -1;
} }
@ -415,42 +402,28 @@ move_player (int pl_nr)
p->m = 0; p->m = 0;
/* check the players position */ /* check the players position */
if ((p->pos.x & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == left || p->d == right)) if ((CUTINT(p->pos.x) > EXPLOSION_SAVE_DISTANCE && (p->d == left || p->d == right))
if (!check_field ((p->pos.x >> 8) + 1, (p->pos.y >> 8))) && (!check_field (p->pos.x + 1.0f, p->pos.y)))
player_died (p, -1); player_died (p, -1);
if ((p->pos.y & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == up || p->d == down)) if ((CUTINT(p->pos.y) > EXPLOSION_SAVE_DISTANCE && (p->d == up || p->d == down))
if (!check_field ((p->pos.x >> 8), (p->pos.y >> 8) + 1)) && (!check_field (p->pos.x, p->pos.y + 1.0f)))
player_died (p, -1); player_died (p, -1);
if (((p->pos.x & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE) if (((CUTINT(p->pos.x) < (1.0f - EXPLOSION_SAVE_DISTANCE) && (p->d == left || p->d == right))
&& (p->d == left || p->d == right)) || (CUTINT(p->pos.y) < (1.0f - EXPLOSION_SAVE_DISTANCE)
|| ((p->pos.y & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE)
&& (p->d == up || p->d == down))) && (p->d == up || p->d == down)))
if (!check_field (p->pos.x >> 8, p->pos.y >> 8)) && (!check_field (p->pos.x, p->pos.y)))
player_died (p, -1); player_died (p, -1);
} }
}; };
inline int postofield (int pos) {
int rp = pos & 8;
if (rp > 0 && rp <= 128)
return (pos >> 8);
else
return ((pos >> 8)+1);
}
void void
player_drop_bomb (int pl_nr) player_drop_bomb (int pl_nr)
{ {
_player *player = &bman.players[pl_nr]; _player *player = &bman.players[pl_nr];
_bomb *bomb = NULL; _bomb *bomb = NULL;
int i, int i;
_x,
_y;
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
i = player_findfreebomb (player); i = player_findfreebomb (player);
@ -458,26 +431,8 @@ player_drop_bomb (int pl_nr)
if (i >= 0 && i < MAX_BOMBS && PS_IS_alife (player->state)) { // free bomb found if (i >= 0 && i < MAX_BOMBS && PS_IS_alife (player->state)) { // free bomb found
// get the best position for the bomb. // get the best position for the bomb.
bomb = &player->bombs[i]; bomb = &player->bombs[i];
bomb->pos.x = player->pos.x >> 8; bomb->pos.x = rintf (player->pos.x);
bomb->pos.y = player->pos.y >> 8; bomb->pos.y = rintf (player->pos.y);
_x = player->pos.x & 255;
_y = player->pos.y & 255;
if (_x > 0 && _x <= 128)
_x = 0;
else if (_x > 128) {
bomb->pos.x += 1;
_x = 0;
}
if (_y > 0 && _y <= 128)
_y = 0;
else if (_y > 12) {
bomb->pos.y += 1;
_y = 0;
}
bomb->pos.x = bomb->pos.x << 8;
bomb->pos.y = bomb->pos.y << 8;
get_bomb_on (bomb->pos.x, bomb->pos.y, bombs); get_bomb_on (bomb->pos.x, bomb->pos.y, bombs);
if (bombs[0].x != -1) // is there already a bomb if (bombs[0].x != -1) // is there already a bomb
@ -495,7 +450,7 @@ player_drop_bomb (int pl_nr)
} }
bomb->mode = BM_normal; bomb->mode = BM_normal;
bomb->ex_nr = -1; bomb->ex_nr = -1;
map.bfield[bomb->pos.x >> 8][bomb->pos.y >> 8] = 1; map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 1;
if (bman.gametype != GT_single) { if (bman.gametype != GT_single) {
net_game_send_bomb (pl_nr, i); net_game_send_bomb (pl_nr, i);
if (GT_MP_PTPS) if (GT_MP_PTPS)
@ -511,17 +466,17 @@ player_drop_bomb (int pl_nr)
check the field - 4 pixels from every side.. so it's not anymore that tricky to get check the field - 4 pixels from every side.. so it's not anymore that tricky to get
away from bombs.. */ away from bombs.. */
void void
get_player_on (short int x, short int y, int pl_nr[]) get_player_on (float x, float y, int pl_nr[])
{ {
int i, int i,
p; p;
for (i = 0, p = 0; p < MAX_PLAYERS; p++) for (i = 0, p = 0; p < MAX_PLAYERS; p++)
if (PS_IS_alife (bman.players[p].state) && bman.players[p].tunnelto <= 0) { if (PS_IS_alife (bman.players[p].state) && bman.players[p].tunnelto <= 0) {
if (bman.players[p].pos.x - EXPLOSION_SAVE_DISTANCE > x - 256 if ((bman.players[p].pos.x - EXPLOSION_SAVE_DISTANCE) > x - 1.0f
&& bman.players[p].pos.x + EXPLOSION_SAVE_DISTANCE < x + 256 && (bman.players[p].pos.x + EXPLOSION_SAVE_DISTANCE) < x + 1.0f
&& bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE > y - 256 && (bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE) > y - 1.0f
&& bman.players[p].pos.y + EXPLOSION_SAVE_DISTANCE < y + 256) { && (bman.players[p].pos.y + EXPLOSION_SAVE_DISTANCE) < y + 1.0f) {
pl_nr[i] = p; pl_nr[i] = p;
i++; i++;
} }
@ -593,7 +548,6 @@ player_animation (_player * player)
int int
dead_playerani () dead_playerani ()
{ {
int i, int i,
b = 0; b = 0;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
@ -609,24 +563,22 @@ dead_playerani ()
void void
player_calcstep (_player * pl) player_calcstep (_player * pl)
{ {
_pointf d;
_point d;
int fx,
fy;
player_animation (pl); player_animation (pl);
fx = pl->pos.x >> 8; d.x = 0;
fy = pl->pos.y >> 8; d.y = 0;
if (map.field[fx][fy].type != FT_block && map.field[fx][fy].type != FT_stone) { if (pl->d == left)
d.x = 0; d.x = -pl->speed * timefactor;
d.y = 0; else if (pl->d == right)
if (pl->d == left) d.x = pl->speed * timefactor;
d.x = -16; else if (pl->d == up)
else if (pl->d == right) d.y = -pl->speed * timefactor;
d.x = 16; else if (pl->d == down)
else if (pl->d == up) d.y = pl->speed * timefactor;
d.y = -16;
else if (pl->d == down) if (map.field[postofield(pl->pos.x+d.x)][postofield(pl->pos.y+d.y)].type != FT_block
d.y = 16; && map.field[postofield(pl->pos.x+d.x)][postofield(pl->pos.y+d.y)].type != FT_stone) {
pl->pos.x += d.x; pl->pos.x += d.x;
pl->pos.y += d.y; pl->pos.y += d.y;
} }
@ -648,22 +600,12 @@ player_calcpos ()
pl = &bman.players[p]; pl = &bman.players[p];
if (PS_IS_netplayer (pl->state) && PS_IS_alife (pl->state) && pl->m != 0) { if (PS_IS_netplayer (pl->state) && PS_IS_alife (pl->state) && pl->m != 0) {
if (pl->speeddat == 0 || pl->speed == 1 || pl->speed == 3)
pl->speeddat = 1;
else
pl->speeddat = 0;
oldm = pl->m; oldm = pl->m;
oldd = pl->d; oldd = pl->d;
if (pl->speed > 1) if (pl->speed > 0.0)
stepmove_player (p); stepmove_player (p);
if (pl->speeddat) {
pl->m = oldm;
pl->d = oldd;
player_calcstep (pl);
}
} }
} }
}; };

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.44 2003/08/27 21:14:50 stpohle Exp $ */ /* $Id: single.c,v 1.45 2003/11/05 12:15:25 stpohle Exp $ */
/* single player */ /* single player */
#include "basic.h" #include "basic.h"
@ -437,20 +437,15 @@ ai_findnearbombs (_point pos)
inline int inline int
ai_checkpos (_player * pl, _point * pos) ai_checkpos (_player * pl, _point * pos)
{ {
_point _p; _pointf _p;
_p.x = pl->pos.x & 255; _p.x = CUTINT (pl->pos.x);
_p.y = pl->pos.y & 255; _p.y = CUTINT (pl->pos.y);
pos->x = pl->pos.x >> 8; pos->x = rintf (pl->pos.x);
pos->y = pl->pos.y >> 8; pos->y = rintf (pl->pos.y);
if (_p.x > 128) return ((_p.x < 0.15f || _p.x > 0.85f) && (_p.y < 0.15f || _p.y > 0.85f));
(pos->x)++;
if (_p.y > 128)
(pos->y)++;
return ((_p.x < 42 || _p.x > 213) && (_p.y < 42 || _p.y > 213));
}; };
@ -668,7 +663,7 @@ single_loop ()
} }
} }
if (pl->m == 0 && map.field[pl->pos.x >> 8][pl->pos.y >> 8].type == FT_tunnel) if (pl->m == 0 && map.field[(int)pl->pos.x][(int)pl->pos.y].type == FT_tunnel)
pl->m = 1; pl->m = 1;
} }
player_ilness_loop (p); player_ilness_loop (p);

@ -1,4 +1,4 @@
/* $Id: special.c,v 1.26 2003/08/29 22:04:19 stpohle Exp $ */ /* $Id: special.c,v 1.27 2003/11/05 12:15:25 stpohle Exp $ */
/* special.c - procedues to control the specials */ /* special.c - procedues to control the specials */
#include "bomberclone.h" #include "bomberclone.h"
@ -38,8 +38,8 @@ special_row (int p_nr)
{ {
_bomb *b = NULL; _bomb *b = NULL;
_player *p = &bman.players[p_nr]; _player *p = &bman.players[p_nr];
int x = p->pos.x >> 8, int x = (int)p->pos.x,
y = p->pos.y >> 8, y = (int)p->pos.y,
dx = 0, dx = 0,
dy = 0, dy = 0,
t = 0, t = 0,
@ -74,8 +74,8 @@ special_row (int p_nr)
b->state = BS_ticking; b->state = BS_ticking;
b->r = p->range; b->r = p->range;
b->ex_nr = -1; b->ex_nr = -1;
b->pos.x = x << 8; b->pos.x = x;
b->pos.y = y << 8; b->pos.y = y;
b->to = BOMB_TIMEOUT * TIME_FACTOR + t; // 5 Secs * 200 b->to = BOMB_TIMEOUT * TIME_FACTOR + t; // 5 Secs * 200
map.bfield[x][y] = 1; map.bfield[x][y] = 1;
if (bman.gametype != GT_single) { if (bman.gametype != GT_single) {
@ -95,17 +95,17 @@ special_liquidmoved (int p_nr)
_player *p = &bman.players[p_nr]; _player *p = &bman.players[p_nr];
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
int x = p->pos.x >> 8, int x = (int)p->pos.x,
y = p->pos.y >> 8, y = (int)p->pos.y,
dx = 0, dx = 0,
dy = 0, dy = 0,
x1, x1,
y1, y1,
i; i;
if ((p->pos.x & 0xff) || (p->pos.y & 0xff)) { if ((CUTINT (p->pos.x) != 0.0f) || (CUTINT (p->pos.y) != 0.0f))
return; return;
}
switch (p->d) { switch (p->d) {
case left: case left:
dx = -1; dx = -1;
@ -135,7 +135,7 @@ special_liquidmoved (int p_nr)
|| (map.field[x1][y1].type != FT_nothing && map.field[x1][y1].type != FT_tunnel)) || (map.field[x1][y1].type != FT_nothing && map.field[x1][y1].type != FT_tunnel))
return; return;
get_bomb_on (x << 8, y << 8, bombs); get_bomb_on (x, y, bombs);
// move all bombs on that field (there should be only 1) // move all bombs on that field (there should be only 1)
for (i = 0; bombs[i].x != -1; i++) { for (i = 0; bombs[i].x != -1; i++) {
b = &bman.players[bombs[i].x].bombs[bombs[i].y]; b = &bman.players[bombs[i].x].bombs[bombs[i].y];
@ -165,17 +165,17 @@ special_push (int p_nr)
_player *p = &bman.players[p_nr]; _player *p = &bman.players[p_nr];
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
int x = p->pos.x >> 8, int x = (int)p->pos.x,
y = p->pos.y >> 8, y = (int)p->pos.y,
dx = 0, dx = 0,
dy = 0, dy = 0,
x1, x1,
y1, y1,
i; i;
if ((p->pos.x & 0xff) || (p->pos.y & 0xff)) { if ((CUTINT (p->pos.x) != 0.0f) || (CUTINT (p->pos.y) != 0.0f))
return; return;
}
switch (p->d) { switch (p->d) {
case left: case left:
dx = -1; dx = -1;
@ -205,7 +205,7 @@ special_push (int p_nr)
|| (map.field[x1][y1].type != FT_nothing && map.field[x1][y1].type != FT_tunnel)) || (map.field[x1][y1].type != FT_nothing && map.field[x1][y1].type != FT_tunnel))
return; return;
get_bomb_on (x << 8, y << 8, bombs); get_bomb_on (x , y , bombs);
// move all bombs on that field (there should be only 1) // move all bombs on that field (there should be only 1)
for (i = 0; bombs[i].x != -1; i++) { for (i = 0; bombs[i].x != -1; i++) {
b = &bman.players[bombs[i].x].bombs[bombs[i].y]; b = &bman.players[bombs[i].x].bombs[bombs[i].y];

Loading…
Cancel
Save