diff --git a/TODO b/TODO index 5d04b14..9389396 100644 --- a/TODO +++ b/TODO @@ -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) diff --git a/bomberclone.prj b/bomberclone.prj index c0f725b..a2dfeee 100644 --- a/bomberclone.prj +++ b/bomberclone.prj @@ -1,4 +1,4 @@ -# Anjuta Version 1.0.2 +# Anjuta Version 1.1.97 Compatibility Level: 1 @@ -39,16 +39,17 @@ echo "T $target H $host B $buid" >cross-target.txt props.file.type=project -anjuta.version=1.0.2 +anjuta.version=1.1.97 anjuta.compatibility.level=1 project.name=bomberclone project.type=GENERIC project.target.type=EXECUTABLE -project.version=0.9.9 +project.version=0.11.0 project.author=steffen project.source.target=bomberclone project.has.gettext=0 +project.gui.command= project.programming.language=C project.excluded.modules=intl @@ -65,22 +66,25 @@ project.menu.need.terminal=0 project.configure.options= 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.use.tabs=1 -preferences.indent.opening=0 -preferences.indent.closing=0 -preferences.tabsize=4 preferences.indent.size=4 -preferences.autoformat.style=Custom style -preferences.autoformat.custom.style=-br -brs -l100 -lc100 -lp -hnl -bc -nip -nce -ncdw -bli1 -i4 -ts1-bad -bap -preferences.autoformat.disable=0 -preferences.debugger.command=gdb -preferences.ui.designer=glade '$(project.name).glade' -preferences.help.browser=devhelp -s '$(current.file.selection)' +preferences.tabsize=4 +preferences.indent.closing=0 module.include.name=include module.include.type= -module.include.expanded=1 module.include.files=\ basic.h\ bomberclone.h\ @@ -97,7 +101,6 @@ module.include.files=\ module.source.name=src module.source.type= -module.source.expanded=1 module.source.files=\ sysfunc.c\ udp.c\ @@ -130,25 +133,20 @@ module.source.files=\ module.pixmap.name=pixmaps module.pixmap.type= -module.pixmap.expanded=0 module.pixmap.files= module.data.name=data module.data.type= -module.data.expanded=0 module.data.files= module.help.name=help module.help.type= -module.help.expanded=0 module.help.files= module.doc.name=doc module.doc.type= -module.doc.expanded=0 module.doc.files= -module.po.expanded=0 module.po.files= compiler.options.supports= @@ -157,11 +155,12 @@ compiler.options.library.paths= compiler.options.libraries= compiler.options.libraries.selected= 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.optimize.buttons=0 1 0 0 compiler.options.other.buttons=1 0 compiler.options.other.c.flags= compiler.options.other.l.flags= compiler.options.other.l.libs= -project.source.paths= +project.src.paths= diff --git a/configure.in b/configure.in index 21f278b..64fe415 100644 --- a/configure.in +++ b/configure.in @@ -4,7 +4,7 @@ dnl If you don't want it to overwrite it, dnl Please disable it in the Anjuta project configuration AC_INIT(configure.in) -AM_INIT_AUTOMAKE(bomberclone, 0.10.1) +AM_INIT_AUTOMAKE(bomberclone, 0.11.0) AM_CONFIG_HEADER AM_CONFIG_HEADER(config.h) @@ -79,28 +79,28 @@ AC_SUBST(MATHLIB) dnl Check for OpenGL ***********************+ -AC_MSG_CHECKING(for OpenGL support) -have_opengl=no -AC_TRY_COMPILE([ - #if defined(__APPLE__) && defined(__MACH__) - #include - #include - #else - #include - #include - #endif -],[ -],[ -have_opengl=yes -]) -AC_MSG_RESULT($have_opengl) -if test x$have_opengl = xyes; then - CFLAGS="$CFLAGS" - LIBS="$LIBS $SYS_GL_LIBS" - AC_DEFINE(HAVE_OPENGL, [1], [OpenGL Headers found]) -else - AC_MSG_WARN(Unable to find OpenGL headers and libraries) -fi +dnl AC_MSG_CHECKING(for OpenGL support) +dnl have_opengl=no +dnl AC_TRY_COMPILE([ +dnl #if defined(__APPLE__) && defined(__MACH__) +dnl #include +dnl #include +dnl #else +dnl #include +dnl #include +dnl #endif +dnl ],[ +dnl ],[ +dnl have_opengl=yes +dnl ]) +dnl AC_MSG_RESULT($have_opengl) +dnl if test x$have_opengl = xyes; then +dnl CFLAGS="$CFLAGS" +dnl LIBS="$LIBS $SYS_GL_LIBS" +dnl AC_DEFINE(HAVE_OPENGL, [1], [OpenGL Headers found]) +dnl else +dnl AC_MSG_WARN(Unable to find OpenGL headers and libraries) +dnl fi diff --git a/include/basic.h b/include/basic.h index fa5ed46..ae33167 100644 --- a/include/basic.h +++ b/include/basic.h @@ -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 */ #ifndef _BC_BASIC_H_ @@ -19,7 +19,7 @@ #define GAME_TUNNEL_TO 50 /* wait 5 game cycls before move and show player again */ -#define EXPLOSION_SAVE_DISTANCE 64 +#define EXPLOSION_SAVE_DISTANCE 0.25 #define SPECIAL_TRIGGER_TIMEOUT 15 #define SPECIAL_TRIGGER_NUMUSE 5 // 0=unlimited #define SPECIAL_TRIGGER_TIME 25 @@ -28,7 +28,7 @@ #define START_BOMBS 1 #define START_RANGE 2 -#define START_SPEED 16 +#define START_SPEED 0.05 #define SPEEDMUL 1.2 #define MAX_PLAYERS 8 @@ -77,6 +77,9 @@ #define MENU_BG_SHADE_BRIGHT 64 #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 @@ -242,4 +245,10 @@ struct { Sint16 y; } typedef _point; + +struct { + float x; + float y; +} typedef _pointf; + #endif diff --git a/include/bomberclone.h b/include/bomberclone.h index edf17d3..12deab8 100644 --- a/include/bomberclone.h +++ b/include/bomberclone.h @@ -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 */ #ifndef _BOMBERCLONE_H_ @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef _WIN32 #include #include @@ -54,7 +55,7 @@ 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 firerst[4]; /* just save here where the direction was going to stop (-1) if the exp is still growing */ @@ -66,7 +67,7 @@ struct { unsigned char mode; // mode of the bomb BM_* int ex_nr; // explosion number _point dest; // destination to move the bomb to - int speed; // bomb moving speed + float speed; // bomb moving speed } typedef _bomb; @@ -88,11 +89,10 @@ struct { int illframe; int illframeto; - _point pos; /* position (without the offset) - _x = pos.x & 255; fx = pos.x >> 8; */ - _point old; // the old position - int tunnelto; /* timeout for dont show and move player - needed on the tunnel effect */ + _pointf pos; // position on the field + _pointf old; // the old position + int tunnelto; /* timeout for dont show and move player + needed on the tunnel effect */ signed char d; // direction signed char m; // player is moving ? @@ -102,8 +102,7 @@ struct { int bomb_lastex; // number of the bomb which explode the last time _bomb bombs[MAX_BOMBS]; // number of bombs who are ticking. int range; // range of the bombs - int speed; // how fast we can go (0 = slow, 1 = normal... 3 = fastest) - int speeddat; // some data i need to do the speed thing + float speed; // how fast we can go (0 = slow, 1 = normal... 3 = fastest) _playerilness ill[PI_max]; // all possible types _special special; // special the player has @@ -176,6 +175,7 @@ struct { extern _bomberclone bman; extern Uint32 timestamp; +extern float timefactor; extern int debug; // Game routines.. @@ -206,7 +206,7 @@ extern void restore_players_screen (); extern void move_player (int pl_nr); extern int stepmove_player (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 draw_players (); 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 int player_findfreebomb (_player *player); extern int player_checkpos (int x, int y); -extern inline int postofield (int pos); +// extern inline int postofield (int pos); // for the bomb.. extern int bomb_loop (); extern void bomb_explode (int p, int b, int net); extern inline void bomb_action (_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 do_explosion (int p, int b); extern void restore_explosion (_bomb * bomb); diff --git a/include/network.h b/include/network.h index 7a3066d..cdd85c5 100644 --- a/include/network.h +++ b/include/network.h @@ -40,6 +40,10 @@ network.h file... for everything what have to do with the network stuff #define HTON32(__i) (__i) #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 #define _sockaddr sockaddr #else diff --git a/src/bomb.c b/src/bomb.c index bee843a..c5583e9 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -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 */ #include "bomberclone.h" @@ -12,8 +12,8 @@ draw_bomb (_bomb * bomb) int x = bomb->pos.x, y = bomb->pos.y; - if (x < 0 || y < 0 || x>>8 >= map.size.x || y>>8 >= map.size.y) { - d_printf ("FATAL: Draw Bomb out of range [%d,%d]\n", x, y); + if (x < 0 || y < 0 || x >= map.size.x || y >= map.size.y) { + d_printf ("FATAL: Draw Bomb out of range [%f,%f]\n", x, y); return; } @@ -32,18 +32,18 @@ draw_bomb (_bomb * bomb) dest.w = src.w = gfx.bomb.image->w; dest.h = src.h = gfx.block.y; - dest.x = gfx.offset.x + (x >> 8) * gfx.block.x + gfx.postab[bomb->pos.x & 0x0FF]; - dest.y = gfx.offset.y + (y >> 8) * gfx.block.y + gfx.postab[bomb->pos.y & 0x0FF]; + dest.x = gfx.offset.x + x * gfx.block.x; + dest.y = gfx.offset.y + y * gfx.block.y; src.x = 0; src.y = src.h * bomb->frame; - stonelist_add (x>>8, y>>8); + stonelist_add (x, y); if (bomb->mode != BM_normal) { - stonelist_add ((x>>8)+1, y>>8); - stonelist_add (x>>8, (y>>8)+1); - stonelist_add ((x>>8)+1, (y>>8)+1); + stonelist_add (x+1, y); + stonelist_add (x, y+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; _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) bomb->ex_nr = bman.last_ex_nr++; // set bomb explosion id @@ -80,33 +80,35 @@ void bomb_move (_bomb * bomb) { 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 */ - stonelist_add (bomb->pos.x>>8, bomb->pos.y>>8); + map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 0; /* delete bfield */ + stonelist_add (bomb->pos.x, bomb->pos.y); /* do this once, and again if the direction is still ok */ do { /* get the current position of the bomb */ - fpos.x = bomb->pos.x >> 8; - fpos.y = bomb->pos.y >> 8; - rpos.x = bomb->pos.x & 0xFF; - rpos.y = bomb->pos.y & 0xFF; - + fpos.x = rintf (bomb->pos.x); + fpos.y = rintf (bomb->pos.y); + rpos.x = fpos.x - bomb->pos.x; + 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.. depend on what is the smaler one */ if (bomb->dest.x < 0) step = rpos.x; else if (bomb->dest.x > 0) - step = 0x100 - rpos.x; + step = 1.0f - rpos.x; else if (bomb->dest.y < 0) step = rpos.y; else if (bomb->dest.y > 0) - step = 0x100 - rpos.y; + step = 1.0f - rpos.y; - if (step > bomb->speed || step == 0) - step = bomb->speed; - + if (step > (timefactor * bomb->speed) || step == 0) + step = (timefactor * bomb->speed); + /* move the bomb to the new position */ if (bomb->dest.x < 0) bomb->pos.x -= step; @@ -119,15 +121,15 @@ bomb_move (_bomb * bomb) /* if we are on a complete field, check if we 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) bomb->mode = BM_normal; else if (bomb->mode == BM_moving || bomb->mode == BM_liquid) { /* it is a moving liquid bomb so check for another field */ _point b, d; - b.x = bomb->pos.x >> 8; - b.y = bomb->pos.y >> 8; + b.x = bomb->pos.x; + b.y = bomb->pos.y; d.x = b.x + bomb->dest.x; d.y = b.y + bomb->dest.y; @@ -163,10 +165,10 @@ bomb_move (_bomb * bomb) } } 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 */ - stonelist_add (bomb->pos.x>>8, bomb->pos.y>>8); + map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 1; /* set new bfield */ + stonelist_add (bomb->pos.x, bomb->pos.y); } @@ -234,7 +236,7 @@ bomb_loop () /* check if on the givin place is a bomb bombs[].x = player, bombs[].y = bombnumber */ void -get_bomb_on (short int x, short int y, _point bombs[]) +get_bomb_on (float x, float y, _point bombs[]) { int p, b, @@ -246,7 +248,7 @@ get_bomb_on (short int x, short int y, _point bombs[]) for (b = 0; b < MAX_BOMBS; b++) { bomb = &bman.players[p].bombs[b]; 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].y = b; i++; @@ -257,6 +259,7 @@ get_bomb_on (short int x, short int y, _point bombs[]) bombs[i].x = bombs[i].y = -1; }; + /* if frame == -1 we will draw the framenumber in the field.ex data */ void @@ -277,7 +280,7 @@ draw_fire (int x, int y, int d, int frame) src.y = frame * 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, dy = 0, _x, _y; - _point bpos; - - bpos.x = bomb->pos.x >> 8; - bpos.y = bomb->pos.y >> 8; for (d = 0; d < 4; d++) { switch (d) { @@ -313,8 +312,8 @@ restore_explosion (_bomb * bomb) break; } - _x = bpos.x; - _y = bpos.y; + _x = bomb->pos.x; + _y = bomb->pos.y; for (i = 0; i < bomb->firer[d]; i++) { 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); } } - _x = bpos.x; - _y = bpos.y; + _x = bomb->pos.x; + _y = bomb->pos.y; /* delete field from the bfield map */ 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) return FT_block; - get_player_on (x << 8, y << 8, pl); - get_bomb_on (x << 8, y << 8, bo); + get_player_on (x, y, pl); + get_bomb_on (x, y, bo); // check if any bomb have to explode.. for (i = 0; bo[i].x != -1; i++) { @@ -422,11 +421,7 @@ draw_explosion (_bomb * bomb) r, dx, dy; - _point p, - bpos; - - bpos.x = bomb->pos.x >> 8; - bpos.y = bomb->pos.y >> 8; + _point p; bomb->frameto--; if (bomb->frameto < 0 || bomb->frameto > ANI_FIRETIMEOUT) @@ -451,8 +446,8 @@ draw_explosion (_bomb * bomb) dy = 1; break; } - p.x = bpos.x; - p.y = bpos.y; + p.x = bomb->pos.x; + p.y = bomb->pos.y; for (r = 0; r < bomb->firer[d]; r++) { if (bomb->frameto == 0) { @@ -476,10 +471,6 @@ do_explosion (int p, int b) int dx = 0, dy = 0, d; - _point bpos; - - bpos.x = bomb->pos.x >> 8; - bpos.y = bomb->pos.y >> 8; for (d = 0; d < 4; d++) { switch (d) { @@ -507,18 +498,18 @@ do_explosion (int p, int b) dx = bomb->firer[d] * dx; 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) && bomb->firerst[d] == -1) { bomb->firer[d]++; - map.field[bpos.x + dx][bpos.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].count++; + 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 */ // draw_fire (bomb->pos.x + dx, bomb->pos.y + dy, d, gfx.fire.frames>>1); } else { bomb->firerst[d] = bomb->firer[d]; - stonelist_add (bpos.x + dx, bpos.y + dy); + stonelist_add (bomb->pos.x + dx, bomb->pos.y + dy); } } } diff --git a/src/field.c b/src/field.c index 4410cd4..8009566 100644 --- a/src/field.c +++ b/src/field.c @@ -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 */ #include "bomberclone.h" @@ -154,14 +154,14 @@ draw_stone (int x, int y) } 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) - 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 */ srcimg = gfx.field[i].image; 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 @@ -177,7 +177,7 @@ draw_stone (int x, int y) 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].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 @@ -188,7 +188,7 @@ draw_stone (int x, int y) } 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; }; diff --git a/src/game.c b/src/game.c index 7dade42..640728c 100644 --- a/src/game.c +++ b/src/game.c @@ -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. */ #include @@ -81,7 +81,7 @@ game_draw_info () font_draw (x, 0, text, 0); sprintf (text, "Range: %2d", bman.players[bman.p_nr].range); 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); if (bman.players[bman.p_nr].special.type != 0) { dest.x = x - 32; @@ -97,7 +97,7 @@ game_draw_info () font_draw (100, 32, "Press F4 to start the game", 0); else if (bman.state == GS_ready) font_draw (100, 32, "Waiting for the Server to Start", 0); - + if (map.state == MS_hurrywarn) { font_setcolor (255,255,255,1); font_drawbold ((gfx.res.x - strlen ("HURRY HURRY")*font[1].size.x)/2, 32, "HURRY HURRY", 1, 2); @@ -246,6 +246,8 @@ game_loop () timediff1 = timeloop1 - timestamp; timestamp = timeloop1; + + timefactor = ((float)timediff1) / 20.0f; } chat_show (-1, -1, -1, -1); diff --git a/src/main.c b/src/main.c index 12df088..7b65c54 100644 --- a/src/main.c +++ b/src/main.c @@ -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 "network.h" @@ -10,6 +10,7 @@ _bomberclone bman; // Holds GameData Uint32 timestamp; // timestamp +float timefactor; // factor for the time int main (int argc, char **argv) diff --git a/src/map.c b/src/map.c index 21ee824..78b6e17 100644 --- a/src/map.c +++ b/src/map.c @@ -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. */ #include "bomberclone.h" @@ -202,8 +202,8 @@ map_set_playerposition (int usermap) /* check if there is no block */ if ((dx > 1 || dy > 1) - && ((map.field[PLX][PLY].type != FT_block && maxloop > 100) - || map.field[PLX][PLY].type == FT_nothing)) { + && ((map.field[(int)PLX][(int)PLY].type != FT_block && maxloop > 100) + || map.field[(int)PLX][(int)PLY].type == FT_nothing)) { /* get (up or down) dx and (left or right) dy */ dx = s_random (2); if (dx == 0) @@ -213,18 +213,18 @@ map_set_playerposition (int usermap) dy = -1; /* first check if there is and free place for us */ - if (!((map.field[PLX + dx][PLY].type != FT_block && maxloop > 100) || - map.field[PLX + dx][PLY].type == FT_nothing)) + if (!((map.field[(int)PLX + dx][(int)PLY].type != FT_block && maxloop > 100) || + map.field[(int)PLX + dx][(int)PLY].type == FT_nothing)) dx = -dx; - if (!((map.field[PLX + dx][PLY].type != FT_block && maxloop > 100) || - map.field[PLX + dx][PLY].type == FT_nothing)) + if (!((map.field[(int)PLX + dx][(int)PLY].type != FT_block && maxloop > 100) || + map.field[(int)PLX + dx][(int)PLY].type == FT_nothing)) PLX = -1; - if (!((map.field[PLX][PLY + dy].type != FT_block && maxloop > 100) || - map.field[PLX][PLY + dy].type == FT_nothing)) + if (!((map.field[(int)PLX][(int)PLY + dy].type != FT_block && maxloop > 100) || + map.field[(int)PLX][(int)PLY + dy].type == FT_nothing)) dy = -dy; - if (!((map.field[PLX][PLY + dy].type != FT_block && maxloop > 100) || - map.field[PLX][PLY + dy].type == FT_nothing)) + if (!((map.field[(int)PLX][(int)PLY + dy].type != FT_block && maxloop > 100) || + map.field[(int)PLX][(int)PLY + dy].type == FT_nothing)) PLY = -1; } else { @@ -233,17 +233,17 @@ map_set_playerposition (int usermap) } /* make some space */ - if (PLX != -1 && PLY != -1) { - if (map.field[PLX][PLY].type != FT_tunnel) - map.field[PLX][PLY].type = FT_nothing; - if (map.field[PLX + dx][PLY].type != FT_tunnel) - map.field[PLX + dx][PLY].type = FT_nothing; - if (map.field[PLX][PLY + dy].type != FT_tunnel) - map.field[PLX][PLY + dy].type = FT_nothing; + if (PLX >= 0.0f && PLY >= 0.0f) { + if (map.field[(int)PLX][(int)PLY].type != FT_tunnel) + map.field[(int)PLX][(int)PLY].type = FT_nothing; + if (map.field[(int)PLX + dx][(int)PLY].type != FT_tunnel) + map.field[(int)PLX + dx][(int)PLY].type = FT_nothing; + if (map.field[(int)PLX][(int)PLY + dy].type != FT_tunnel) + 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 */ if (usermap) { 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; PLY = 2 * (s_random ((map.size.y - 1) / 2)) + 1; - if (map.field[PLX][PLY].type != FT_tunnel) - map.field[PLX][PLY].type = FT_nothing; + if (map.field[(int)PLX][(int)PLY].type != FT_tunnel) + map.field[(int)PLX][(int)PLY].type = FT_nothing; dx = s_random (4); // bit 1 = up/down bit 2 = left/right /* up and down */ - if (((dx & 1) == 0 && PLX > 1) || PLX >= map.size.x - 2) { - if (map.field[PLX - 1][PLY].type != FT_tunnel) - map.field[PLX - 1][PLY].type = FT_nothing; + if (((dx & 1) == 0 && PLX > 1.0f) || PLX >= map.size.x - 2) { + if (map.field[(int)PLX - 1][(int)PLY].type != FT_tunnel) + map.field[(int)PLX - 1][(int)PLY].type = FT_nothing; } else { - if (map.field[PLX + 1][PLY].type != FT_tunnel) - map.field[PLX + 1][PLY].type = FT_nothing; + if (map.field[(int)PLX + 1][(int)PLY].type != FT_tunnel) + map.field[(int)PLX + 1][(int)PLY].type = FT_nothing; } /* left and right */ if (((dx & 2) == 0 && PLY > 1) || PLY >= map.size.y - 2) { - if (map.field[PLX][PLY - 1].type != FT_tunnel) - map.field[PLX][PLY - 1].type = FT_nothing; + if (map.field[(int)PLX][(int)PLY - 1].type != FT_tunnel) + map.field[(int)PLX][(int)PLY - 1].type = FT_nothing; } else { - if (map.field[PLX][PLY + 1].type != FT_tunnel) - map.field[PLX][PLY + 1].type = FT_nothing; + if (map.field[(int)PLX][(int)PLY + 1].type != FT_tunnel) + map.field[(int)PLX][(int)PLY + 1].type = FT_nothing; } } mx = my = 100; @@ -298,13 +298,7 @@ map_set_playerposition (int usermap) p++; } } - - for (i = 0; i < MAX_PLAYERS; i++) { - PLX = PLX << 8; - PLY = PLY << 8; - } }; - #undef PLX #undef PLY diff --git a/src/packets.c b/src/packets.c index 884be1f..4c9d241 100644 --- a/src/packets.c +++ b/src/packets.c @@ -430,8 +430,8 @@ send_playerdata (_net_addr * addr, int p_nr, _player * pl) else p_dat.h.flags = PKGF_ackreq; - p_dat.pos.x = HTON16 (pl->pos.x); - p_dat.pos.y = HTON16 (pl->pos.y); + p_dat.pos.x = HTON16 (FTOI16 (pl->pos.x)); + p_dat.pos.y = HTON16 (FTOI16 (pl->pos.y)); p_dat.bombs_n = pl->bombs_n; p_dat.d = pl->d; 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); } else if (bman.state != GS_running || bman.p_nr != p_dat->p_nr) { - pl->pos.x = NTOH16 (p_dat->pos.x); - pl->pos.y = NTOH16 (p_dat->pos.y); + pl->pos.x = I16TOF (NTOH16 (p_dat->pos.x)); + pl->pos.y = I16TOF (NTOH16 (p_dat->pos.y)); pl->dead_by = p_dat->dead_by; pl->points = NTOH16 (p_dat->points); 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.flags = 0; - p_dat.pos.x = HTON16 (pl->pos.x); - p_dat.pos.y = HTON16 (pl->pos.y); + p_dat.pos.x = HTON16 (FTOI16 (pl->pos.x)); + p_dat.pos.y = HTON16 (FTOI16 (pl->pos.y)); p_dat.m = pl->m; p_dat.d = pl->d; 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->d = p_dat->d; pl->speed = p_dat->speed; - pl->pos.x = HTON16 (p_dat->pos.x); - pl->pos.y = HTON16 (p_dat->pos.y); + pl->pos.x = I16TOF (HTON16 (p_dat->pos.x)); + pl->pos.y = I16TOF (HTON16 (p_dat->pos.y)); pl->tunnelto = HTON16 (p_dat->tunnelto); } @@ -597,7 +597,7 @@ void do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) { _bomb *bomb; - + if (addr->pl_nr == -1) return; @@ -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 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)); 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"); 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 - stonelist_add (bomb->pos.x >> 8, bomb->pos.y >> 8); + map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 0; //remove bomb at old location + stonelist_add (bomb->pos.x, bomb->pos.y); } if (bomb->state == BS_off && (b_dat->state == BS_ticking || b_dat->state == BS_trigger)) snd_play (SND_bombdrop); - bomb->pos.x = NTOH16 (b_dat->x); - bomb->pos.y = NTOH16 (b_dat->y); + /* convert position back to float */ + 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) bomb->to = NTOH32 (b_dat->to); /* only set if the bomb isn't already ticking to make sure the timeout won't be resetted 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->ex_nr = NTOH32 (b_dat->ex_nr); bomb->state = b_dat->state & 0x0F; 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.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.len = HTON16 (sizeof (struct pkg_bombdata)); - b_dat.x = HTON16 (bomb->pos.x); - b_dat.y = HTON16 (bomb->pos.y); + b_dat.x = HTON16 (FTOI16 (bomb->pos.x)); + b_dat.y = HTON16 (FTOI16 (bomb->pos.y)); b_dat.to = HTON32 (bomb->to); b_dat.r = bomb->r; 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.p_nr = p; 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.desty = HTON16 (bomb->dest.y); @@ -724,6 +725,7 @@ send_tunneldata (_net_addr * addr, int tunnelnr, int x, int y) } }; + void send_quit (_net_addr * addr, char *plhost, char * plport) { diff --git a/src/player.c b/src/player.c index 17334f1..7be9d31 100644 --- a/src/player.c +++ b/src/player.c @@ -12,10 +12,10 @@ draw_player (_player * player) dest; int i; - if ((player->pos.x >> 8) < 0 || (player->pos.x >> 8) >= map.size.x || - (player->pos.y >> 8) < 0 || (player->pos.y >> 8) >= map.size.y) { - d_printf ("FATAL: Draw Player out of range : [%d,%d]\n", (player->pos.x >> 8), - (player->pos.y >> 8)); + if ((int)player->pos.x < 0 || (int)player->pos.x >= map.size.x || + (int)player->pos.y < 0 || (int)player->pos.y >= map.size.y) { + d_printf ("FATAL: Draw Player out of range : [%f,%f]\n", player->pos.x, + player->pos.y); return; } @@ -24,15 +24,13 @@ draw_player (_player * player) dest.w = src.w = player->gfx->ani.w; dest.h = src.h = player->gfx->ani.h; dest.x = - gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x + - gfx.postab[player->pos.x & 255]; + gfx.offset.x + player->gfx->offset.x + player->pos.x * gfx.block.x; dest.y = - gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y + - gfx.postab[player->pos.y & 255]; + gfx.offset.y + player->gfx->offset.y + player->pos.y * gfx.block.y; src.x = player->d * player->gfx->ani.w; 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 (PS_IS_alife (player->state)) { @@ -43,12 +41,10 @@ draw_player (_player * player) src.x = 0; src.y = (2 * gfx.block.y) * player->illframe; dest.x = - (-(gfx.block.x >> 1)) + gfx.offset.x + (player->pos.x >> 8) * gfx.block.x + - gfx.postab[player->pos.x & 255]; + gfx.offset.x + ((player->pos.x-0.5f) * gfx.block.x); dest.y = - gfx.offset.y + ((player->pos.y >> 8) - 1) * gfx.block.y + - gfx.postab[player->pos.y & 255]; - gfx_blit (gfx.ill.image, &src, gfx.screen, &dest, player->pos.y + 129); + gfx.offset.y + ((player->pos.y - 1.0f) * gfx.block.y); + gfx_blit (gfx.ill.image, &src, gfx.screen, &dest, (player->pos.y*256) + 129); } } } @@ -59,11 +55,9 @@ draw_player (_player * player) dest.h = src.h = player->gfx->ani.h; dest.x = - gfx.offset.x + player->gfx->offset.x + (player->pos.x >> 8) * gfx.block.x + - gfx.postab[player->pos.x & 255]; + gfx.offset.x + player->gfx->offset.x + player->pos.x * gfx.block.x; dest.y = - gfx.offset.y + player->gfx->offset.y + (player->pos.y >> 8) * gfx.block.y + - gfx.postab[player->pos.y & 255]; + gfx.offset.y + player->gfx->offset.y + player->pos.y * gfx.block.y; src.x = 0; src.y = (2 * gfx.block.y) * player->frame; @@ -86,31 +80,34 @@ restore_players_screen () ye; 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 - || (bman.players[i].old.y >> 8) < 0 || (bman.players[i].old.y >> 8) >= map.size.y) - d_printf ("FATAL: Restore Player out of range : playernr %d [%d,%d]\n", i, - (bman.players[i].old.x >> 8), (bman.players[i].old.y >> 8)); + if (bman.players[i].old.x < 0.0f || bman.players[i].old.x >= map.size.x + || 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 [%f,%f]\n", i, + bman.players[i].old.x, bman.players[i].old.y); else { - if ((bman.players[i].old.x & 0xFF) > 128) { - x = (bman.players[i].old.x >> 8); - xe = (bman.players[i].old.x >> 8) + 2; + // start and end position for the stones to redraw X Position + if (CUTINT(bman.players[i].old.x) > 0.5f) { + x = bman.players[i].old.x; + xe = bman.players[i].old.x + 2; } else { - x = (bman.players[i].old.x >> 8) - 1; - xe = (bman.players[i].old.x >> 8) + 1; + x = bman.players[i].old.x - 1; + xe = bman.players[i].old.x + 1; } if (x < 0) x = 0; if (xe >= map.size.x) xe = map.size.x - 1; - ys = (bman.players[i].old.y >> 8) - 1; - ye = (bman.players[i].old.y >> 8) + 1; + // start and end position for the stones to redraw X Position + ys = bman.players[i].old.y - 1; + ye = bman.players[i].old.y + 1; if (ys < 0) ys = 0; if (ye >= map.size.y) ye = map.size.y - 1; + // redrawing of the stone xs = x; for (; x <= xe; x++) for (y = ys; y <= ye; y++) @@ -124,10 +121,8 @@ void player_check_powerup (int p_nr) { _player *p = &bman.players[p_nr]; - int fx = p->pos.x >> 8; - int fy = p->pos.y >> 8; - int _x = p->pos.x & 255; - int _y = p->pos.y & 255; + int fx = p->pos.x; + int fy = p->pos.y; int ft, i; @@ -135,11 +130,12 @@ player_check_powerup (int p_nr) return; /* Get the right field position */ - if (_x > 128) + if (CUTINT(p->pos.x) > 0.5) fx = fx + 1; - if (_y > 128) + if (CUTINT(p->pos.y) > 0.5) fy = fy + 1; ft = map.field[fx][fy].type; + /* we found a mixed powerup */ if (ft == FT_mixed) { i = s_random (6); @@ -232,59 +228,55 @@ stepmove_player (int pl_nr) _point bomb1[MAX_PLAYERS * MAX_BOMBS], bomb2[MAX_PLAYERS * MAX_BOMBS]; _player *p = &bman.players[pl_nr]; - int speed = 0, - i, + int i, j, f; - _point fpos, // field position - - _pos, // position inside the field - - d; - + _pointf _pos, // position inside the field + d; // distance to move + float speed = 0.0f; + + if (p->m == 1) { - fpos.x = p->pos.x >> 8; - fpos.y = p->pos.y >> 8; - _pos.x = p->pos.x & 255; - _pos.y = p->pos.y & 255; + _pos.x = CUTINT(p->pos.x); + _pos.y = CUTINT(p->pos.y); // 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; - 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; // 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; - 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; /* get the distance/speed until we reach the next position */ if (p->d == left) speed = _pos.x; else if (p->d == right) - speed = 256 - _pos.x; + speed = 1.0f - _pos.x; else if (p->d == up) speed = _pos.y; else - speed = 256 - _pos.y; + speed = 1.0f - _pos.y; - if (speed > p->speed || speed == 0) - speed = p->speed; + if (speed > (p->speed * timefactor) || speed == 0) + speed = p->speed * timefactor; // check the new field position - d.x = d.y = 0; - if (p->d == left && _pos.y == 0 - && ((_pos.x == 0 && check_field (fpos.x - 1, fpos.y)) || (_pos.x > 0))) + d.x = d.y = 0.0f; + if (p->d == left && _pos.y == 0.0f + && ((_pos.x == 0.0f && check_field (p->pos.x - 1.0f, p->pos.y)) || (_pos.x > 0.0f))) d.x = -speed; - if (p->d == right && _pos.y == 0 - && ((_pos.x == 0 && check_field (fpos.x + 1, fpos.y)) || (_pos.x > 0))) + if (p->d == right && _pos.y == 0.0f + && ((_pos.x == 0.0f && check_field (p->pos.x + 1.0f, p->pos.y)) || (_pos.x > 0.0f))) d.x = speed; - if (p->d == up && _pos.x == 0 - && ((_pos.y == 0 && check_field (fpos.x, fpos.y - 1)) || (_pos.y > 0))) + if (p->d == up && _pos.x == 0.0f + && ((_pos.y == 0.0f && check_field (p->pos.x, p->pos.y - 1.0f)) || (_pos.y > 0.0f))) d.y = -speed; - if (p->d == down && _pos.x == 0 - && ((_pos.y == 0 && check_field (fpos.x, fpos.y + 1)) || (_pos.y > 0))) + if (p->d == down && _pos.x == 0.0f + && ((_pos.y == 0.0f && check_field (p->pos.x, p->pos.y + 1.0f)) || (_pos.y > 0.0f))) d.y = speed; // 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) /* 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) { /* new pos bomb, old pos bomb... check if it's the same 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 */ f = 1; 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); - fpos.x = p->pos.x >> 8; - fpos.y = p->pos.y >> 8; - _pos.x = p->pos.x & 255; - _pos.y = p->pos.y & 255; + _pos.x = CUTINT(p->pos.x); + _pos.y = CUTINT(p->pos.y); /* 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) { d_printf ("Tunnel [%d] Player %s is going to (%d,%d)\n", - map.field[fpos.x][fpos.y].special, p->name, - map.tunnel[map.field[fpos.x][fpos.y].special].x, - map.tunnel[map.field[fpos.x][fpos.y].special].y); - d.x = d.y = 0; + map.field[(int)p->pos.x][(int)p->pos.y].special, p->name, + map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x, + map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y); + d.x = d.y = 0.0f; if (map. - bfield[map.tunnel[map.field[fpos.x][fpos.y].special].x][map. - tunnel[map. - field[fpos.x][fpos. - y]. - special].y]) + bfield[map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].x] + [map.tunnel[map.field[(int)p->pos.x][(int)p->pos.y].special].y]) d_printf (" *** End of tunnel is with an bomb.\n"); else { - p->pos.x = map.tunnel[map.field[fpos.x][fpos.y].special].x << 8; - p->pos.y = map.tunnel[map.field[fpos.x][fpos.y].special].y << 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[(int)p->pos.x][(int)p->pos.y].special].y << 8; 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 (p->speed - speed); + return (p->speed - (speed/timefactor)); }; @@ -404,7 +391,7 @@ move_player (int pl_nr) if (bman.gametype != GT_single) 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; } @@ -415,42 +402,28 @@ move_player (int pl_nr) p->m = 0; /* check the players position */ - if ((p->pos.x & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == left || p->d == right)) - if (!check_field ((p->pos.x >> 8) + 1, (p->pos.y >> 8))) + if ((CUTINT(p->pos.x) > EXPLOSION_SAVE_DISTANCE && (p->d == left || p->d == right)) + && (!check_field (p->pos.x + 1.0f, p->pos.y))) player_died (p, -1); - if ((p->pos.y & 0xFF) > EXPLOSION_SAVE_DISTANCE && (p->d == up || p->d == down)) - if (!check_field ((p->pos.x >> 8), (p->pos.y >> 8) + 1)) + if ((CUTINT(p->pos.y) > EXPLOSION_SAVE_DISTANCE && (p->d == up || p->d == down)) + && (!check_field (p->pos.x, p->pos.y + 1.0f))) player_died (p, -1); - if (((p->pos.x & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE) - && (p->d == left || p->d == right)) - || ((p->pos.y & 0xFF) < (0x100 - EXPLOSION_SAVE_DISTANCE) + if (((CUTINT(p->pos.x) < (1.0f - EXPLOSION_SAVE_DISTANCE) && (p->d == left || p->d == right)) + || (CUTINT(p->pos.y) < (1.0f - EXPLOSION_SAVE_DISTANCE) && (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); - } }; -inline int postofield (int pos) { - int rp = pos & 8; - - if (rp > 0 && rp <= 128) - return (pos >> 8); - else - return ((pos >> 8)+1); -} - - void player_drop_bomb (int pl_nr) { _player *player = &bman.players[pl_nr]; _bomb *bomb = NULL; - int i, - _x, - _y; + int i; _point bombs[MAX_PLAYERS * MAX_BOMBS]; 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 // get the best position for the bomb. bomb = &player->bombs[i]; - bomb->pos.x = player->pos.x >> 8; - bomb->pos.y = player->pos.y >> 8; - _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; + bomb->pos.x = rintf (player->pos.x); + bomb->pos.y = rintf (player->pos.y); get_bomb_on (bomb->pos.x, bomb->pos.y, bombs); 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->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) { net_game_send_bomb (pl_nr, i); 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 away from bombs.. */ 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, p; for (i = 0, p = 0; p < MAX_PLAYERS; p++) if (PS_IS_alife (bman.players[p].state) && bman.players[p].tunnelto <= 0) { - if (bman.players[p].pos.x - EXPLOSION_SAVE_DISTANCE > x - 256 - && bman.players[p].pos.x + EXPLOSION_SAVE_DISTANCE < x + 256 - && bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE > y - 256 - && bman.players[p].pos.y + EXPLOSION_SAVE_DISTANCE < y + 256) { + if ((bman.players[p].pos.x - EXPLOSION_SAVE_DISTANCE) > x - 1.0f + && (bman.players[p].pos.x + EXPLOSION_SAVE_DISTANCE) < x + 1.0f + && (bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE) > y - 1.0f + && (bman.players[p].pos.y + EXPLOSION_SAVE_DISTANCE) < y + 1.0f) { pl_nr[i] = p; i++; } @@ -593,7 +548,6 @@ player_animation (_player * player) int dead_playerani () { - int i, b = 0; for (i = 0; i < MAX_PLAYERS; i++) @@ -609,24 +563,22 @@ dead_playerani () void player_calcstep (_player * pl) { + _pointf d; - _point d; - int fx, - fy; player_animation (pl); - fx = pl->pos.x >> 8; - fy = pl->pos.y >> 8; - if (map.field[fx][fy].type != FT_block && map.field[fx][fy].type != FT_stone) { - d.x = 0; - d.y = 0; - if (pl->d == left) - d.x = -16; - else if (pl->d == right) - d.x = 16; - else if (pl->d == up) - d.y = -16; - else if (pl->d == down) - d.y = 16; + d.x = 0; + d.y = 0; + if (pl->d == left) + d.x = -pl->speed * timefactor; + else if (pl->d == right) + d.x = pl->speed * timefactor; + else if (pl->d == up) + d.y = -pl->speed * timefactor; + else if (pl->d == down) + d.y = pl->speed * timefactor; + + if (map.field[postofield(pl->pos.x+d.x)][postofield(pl->pos.y+d.y)].type != FT_block + && map.field[postofield(pl->pos.x+d.x)][postofield(pl->pos.y+d.y)].type != FT_stone) { pl->pos.x += d.x; pl->pos.y += d.y; } @@ -648,22 +600,12 @@ player_calcpos () pl = &bman.players[p]; 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; oldd = pl->d; - if (pl->speed > 1) + if (pl->speed > 0.0) stepmove_player (p); - if (pl->speeddat) { - pl->m = oldm; - pl->d = oldd; - player_calcstep (pl); - } } } - }; diff --git a/src/single.c b/src/single.c index 1fe14f6..917a588 100644 --- a/src/single.c +++ b/src/single.c @@ -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 */ #include "basic.h" @@ -437,20 +437,15 @@ ai_findnearbombs (_point pos) inline int ai_checkpos (_player * pl, _point * pos) { - _point _p; + _pointf _p; - _p.x = pl->pos.x & 255; - _p.y = pl->pos.y & 255; + _p.x = CUTINT (pl->pos.x); + _p.y = CUTINT (pl->pos.y); - pos->x = pl->pos.x >> 8; - pos->y = pl->pos.y >> 8; + pos->x = rintf (pl->pos.x); + pos->y = rintf (pl->pos.y); - if (_p.x > 128) - (pos->x)++; - if (_p.y > 128) - (pos->y)++; - - return ((_p.x < 42 || _p.x > 213) && (_p.y < 42 || _p.y > 213)); + return ((_p.x < 0.15f || _p.x > 0.85f) && (_p.y < 0.15f || _p.y > 0.85f)); }; @@ -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; } player_ilness_loop (p); diff --git a/src/special.c b/src/special.c index d1b54f7..1eafcff 100644 --- a/src/special.c +++ b/src/special.c @@ -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 */ #include "bomberclone.h" @@ -38,8 +38,8 @@ special_row (int p_nr) { _bomb *b = NULL; _player *p = &bman.players[p_nr]; - int x = p->pos.x >> 8, - y = p->pos.y >> 8, + int x = (int)p->pos.x, + y = (int)p->pos.y, dx = 0, dy = 0, t = 0, @@ -74,8 +74,8 @@ special_row (int p_nr) b->state = BS_ticking; b->r = p->range; b->ex_nr = -1; - b->pos.x = x << 8; - b->pos.y = y << 8; + b->pos.x = x; + b->pos.y = y; b->to = BOMB_TIMEOUT * TIME_FACTOR + t; // 5 Secs * 200 map.bfield[x][y] = 1; if (bman.gametype != GT_single) { @@ -95,17 +95,17 @@ special_liquidmoved (int p_nr) _player *p = &bman.players[p_nr]; _point bombs[MAX_PLAYERS * MAX_BOMBS]; - int x = p->pos.x >> 8, - y = p->pos.y >> 8, + int x = (int)p->pos.x, + y = (int)p->pos.y, dx = 0, dy = 0, x1, y1, i; - if ((p->pos.x & 0xff) || (p->pos.y & 0xff)) { + if ((CUTINT (p->pos.x) != 0.0f) || (CUTINT (p->pos.y) != 0.0f)) return; - } + switch (p->d) { case left: 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)) 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) for (i = 0; bombs[i].x != -1; i++) { 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]; _point bombs[MAX_PLAYERS * MAX_BOMBS]; - int x = p->pos.x >> 8, - y = p->pos.y >> 8, + int x = (int)p->pos.x, + y = (int)p->pos.y, dx = 0, dy = 0, x1, y1, i; - if ((p->pos.x & 0xff) || (p->pos.y & 0xff)) { + if ((CUTINT (p->pos.x) != 0.0f) || (CUTINT (p->pos.y) != 0.0f)) return; - } + switch (p->d) { case left: 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)) 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) for (i = 0; bombs[i].x != -1; i++) { b = &bman.players[bombs[i].x].bombs[bombs[i].y];