Putting animation frames to the float thing.. even timeouts are not float..

origin
stpohle 22 years ago
parent b69ff0ae4e
commit 4ffbe4c045

@ -1,4 +1,4 @@
/* $Id: basic.h,v 1.5 2003/11/05 12:15:25 stpohle Exp $ */ /* $Id: basic.h,v 1.6 2003/11/08 06:27:58 stpohle Exp $ */
/* basic types which we need everywhere */ /* basic types which we need everywhere */
#ifndef _BC_BASIC_H_ #ifndef _BC_BASIC_H_
@ -46,16 +46,18 @@
#define MAX_FIELDANIMATION 2048 /* number of points on the field to be animated exploding #define MAX_FIELDANIMATION 2048 /* number of points on the field to be animated exploding
stoned or powerups*/ stoned or powerups*/
#define EXPLOSIONTIMEOUT 20 #define EXPLOSIONTIMEOUT 0.75
#define ANI_FIRETIMEOUT 2 #define ANI_FIRETIMEOUT 2
#define ANI_BOMBTIMEOUT 1 #define ANI_BOMBTIMEOUT 1
#define ANI_PLAYERTIMEOUT 1 #define ANI_PLAYERTIMEOUT 1
#define ANI_PLAYERILLTIMEOUT 1 #define ANI_PLAYERILLTIMEOUT 1
#define ANI_STONETIMEOUT 5 #define ANI_STONETIMEOUT 5
#define TIME_FACTOR 50 // #define TIME_FACTOR 50
#define BOMB_TIMEOUT 5 #define BOMB_TIMEOUT 5
#define IL_TIMEOUT 20 #define ILL_TIMEOUT 20
#define ILL_SLOWSPEED 0.01
#define ILL_FASTSPEED 0.5
#define LEN_PLAYERNAME 10 #define LEN_PLAYERNAME 10
#define LEN_SERVERNAME 41 #define LEN_SERVERNAME 41
@ -76,7 +78,7 @@
#define MENU_BG_SHADE_DARK -64 #define MENU_BG_SHADE_DARK -64
#define MENU_BG_SHADE_BRIGHT 64 #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 MW_IS_GFX_SELECT(__gfx_nr,__result) for (__result = (MAX_PLAYERS-1); (players[__result].gfx_nr != __gfx_nr) && (__result >= 0); __result--);
#define CUTINT(__x) (__x-floorf(__x)) // cut the integer part off #define CUTINT(__x) (__x-floorf(__x)) // cut the integer part off
#define postofield(__x) ((int)(rintf(__x))) // position to int with rounding #define postofield(__x) ((int)(rintf(__x))) // position to int with rounding
@ -95,18 +97,6 @@ enum _backgound { // to load some diffrent logos..
}; };
enum _gametype {
GT_single = 0,
GT_multi
};
enum _multitype {
MT_ptpm, // udp ptp master
MT_ptps // udp ptp client
};
enum _gamestate { enum _gamestate {
GS_startup = 0, GS_startup = 0,
GS_quit, GS_quit,
@ -195,7 +185,7 @@ enum _bombmode {
}; };
enum _playerstateflags { enum _playerstateflags { // not Set | Set
PSF_used = 1, // Player Unused | Player Used PSF_used = 1, // Player Unused | Player Used
PSF_net = 2, // Local Player | AI / Network Player PSF_net = 2, // Local Player | AI / Network Player
PSF_alife = 4, // Player is Dead | Player is Alife PSF_alife = 4, // Player is Dead | Player is Alife
@ -210,6 +200,7 @@ enum _playerstateflags {
#define PS_IS_playing(__ps) (((__ps) & (PSFM_used)) == (PSFM_used)) #define PS_IS_playing(__ps) (((__ps) & (PSFM_used)) == (PSFM_used))
#define PS_IS_used(__ps) (((__ps) & (PSFM_used)) != 0) #define PS_IS_used(__ps) (((__ps) & (PSFM_used)) != 0)
enum _direction { // to handle directions better enum _direction { // to handle directions better
left = 0, left = 0,
right, right,

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.5 2003/11/05 12:15:25 stpohle Exp $ */ /* $Id: bomberclone.h,v 1.6 2003/11/08 06:27:58 stpohle Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -49,7 +49,7 @@
#include "keybinput.h" #include "keybinput.h"
struct { struct {
int to; // if (to > 0) the ilness is still working float to; // if (to > 0) the ilness is still working
int data; int data;
} typedef _playerilness; } typedef _playerilness;
@ -59,9 +59,8 @@ struct {
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 */
int to; // timeout in ms after dropping the bomb. (loops * 0.0005sec) float to; // timeout in ms after dropping the bomb. (loops * 0.0005sec)
int frame; // frame of the animation float frame; // frame of the animation
int frameto; // timeout for the frame
unsigned char r; // range of the bomb unsigned char r; // range of the bomb
unsigned char state; // state of the bomb BS_* unsigned char state; // state of the bomb BS_*
unsigned char mode; // mode of the bomb BM_* unsigned char mode; // mode of the bomb BM_*
@ -73,25 +72,23 @@ struct {
struct { struct {
int type; // type of the special int type; // type of the special
int to; // timeout float to; // timeout
int numuse; // num of uses left int numuse; // num of uses left
int use; /* currently used set by special_use int use; /* currently used set by special_use
and deleted in special_loop */ and deleted in special_loop */
} typedef _special; } typedef _special;
struct { struct {
_gfxplayer *gfx; // pointer to the gfx information _gfxplayer *gfx; // pointer to the gfx information
int gfx_nr; // number of the player GFX int gfx_nr; // number of the player GFX
int frame; // step of the animation float frame; // step of the animation (only integer part will shown)
int frameto; // timeout for the animation
int illframe; int illframe;
int illframeto;
_pointf pos; // position on the field _pointf pos; // position on the field
_pointf old; // the old position _pointf old; // the old position
int tunnelto; /* timeout for dont show and move player float 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
@ -126,16 +123,15 @@ struct {
struct { struct {
char datapath[512]; char datapath[512];
_player players[MAX_PLAYERS];
int p_nr; // Playernumber 0 if you host a game or the number of the one you are. int p_nr; // Playernumber 0 if you host a game or the number of the one you are.
int p_servnr; // Playernumber of the Server
int last_ex_nr; // number of the last explosion int last_ex_nr; // number of the last explosion
int updatestatusbar; // 1 if statusbar has to be updated int updatestatusbar; // 1 if statusbar has to be updated
unsigned char gametype; unsigned char gametype;
unsigned char multitype; unsigned char multitype;
unsigned char state; unsigned char state;
int init_timeout; // gametimeout init value int init_timeout; // gametimeout init value
int timeout; // game timeout float timeout; // game timeout
char playername[LEN_PLAYERNAME]; char playername[LEN_PLAYERNAME];
int players_nr_s; // number of players at the beginning int players_nr_s; // number of players at the beginning
int players_nr; // number of player who are alife int players_nr; // number of player who are alife
@ -174,8 +170,10 @@ struct {
extern _bomberclone bman; extern _bomberclone bman;
extern _player players[MAX_PLAYERS];
extern Uint32 timestamp; extern Uint32 timestamp;
extern float timefactor; extern float timefactor;
extern float timediff;
extern int debug; extern int debug;
// Game routines.. // Game routines..
@ -258,11 +256,12 @@ extern void d_gamedetail (char *head);
extern void d_printf (char *fmt,...); extern void d_printf (char *fmt,...);
extern void d_bitprint (int bits, int nr); extern void d_bitprint (int bits, int nr);
extern void d_fatal (char *fmt,...); extern void d_fatal (char *fmt,...);
extern void debug_ingameinfo();
// single.c // single.c
extern void single_game_new (); extern void single_game_new ();
extern void single_create_ai (int players); extern void single_create_ai (int num_players);
extern void single_loop(); extern void single_loop();
extern void single_playergame (); extern void single_playergame ();
extern void single_menu (); extern void single_menu ();

@ -1,4 +1,4 @@
/* $Id: map.h,v 1.3 2003/09/23 20:28:24 stpohle Exp $ */ /* $Id: map.h,v 1.4 2003/11/08 06:27:58 stpohle Exp $ */
/* map.h */ /* map.h */
#ifndef _MAP_H_ #ifndef _MAP_H_
@ -6,15 +6,14 @@
struct __ex_field { struct __ex_field {
unsigned char count; unsigned char count;
unsigned char frame; unsigned char frame; // we may have to change this.. because the frames
} typedef _ex_field; } typedef _ex_field; // might have all put to float.
struct __field { struct __field {
unsigned char type; unsigned char type;
signed char mixframe; // data for the mixed frame signed char mixframe; // data for the mixed frame
Sint16 frame; // frame (frame > 0 && FS_stone) float frame; // frame (frame > 0 && FS_stone)
Sint32 frameto; // frame to
unsigned char special; // to save special stones, or the tunnel number unsigned char special; // to save special stones, or the tunnel number
_ex_field ex[4]; // count up every explosion there is on this field for ever direction _ex_field ex[4]; // count up every explosion there is on this field for ever direction
Sint32 ex_nr; // number to identify the explosion. Sint32 ex_nr; // number to identify the explosion.

@ -18,13 +18,14 @@ network.h file... for everything what have to do with the network stuff
#define DYN_PKG_MIN_MISSING 1 #define DYN_PKG_MIN_MISSING 1
#define PKG_SENDSETOPT 2 #define PKG_SENDSETOPT 2
#define GT_MP_PTPM (bman.multitype == MT_ptpm && bman.gametype == GT_multi) #define GT_MP_PTPM (bman.p_nr == bman.p_servnr && bman.sock >= 0)
#define GT_MP_PTPS (bman.multitype == MT_ptps && bman.gametype == GT_multi) #define GT_MP_PTPS (bman.p_nr != bman.p_servnr && bman.sock >= 0)
#define GT_MP_PTP ((bman.multitype == MT_ptps || bman.multitype == MT_ptpm) && bman.gametype == GT_multi) #define GT_MP (bman.sock >= 0)
#define GT_SP (bman.sock <= 0)
#define GS_WAITRUNNING (bman.state == GS_wait || bman.state == GS_ready || bman.state == GS_running) #define GS_WAITRUNNING (bman.state == GS_wait || bman.state == GS_ready || bman.state == GS_running)
#define NET_CANSEND(__pl) (( __pl == 0 || GT_MP_PTPM || (bman.players[__pl].net.flags & NETF_firewall) == 0)) #define NET_CANSEND(__pl) (( __pl == 0 || GT_MP_PTPM || (players[__pl].net.flags & NETF_firewall) == 0))
/* Little / Big Endian Convert */ /* Little / Big Endian Convert */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN #if SDL_BYTEORDER == SDL_BIG_ENDIAN
@ -42,7 +43,9 @@ network.h file... for everything what have to do with the network stuff
/* converting of float to int and other direction */ /* converting of float to int and other direction */
#define FTOI16(__x) ((Sint16)((float)(__x * 256.0f))) #define FTOI16(__x) ((Sint16)((float)(__x * 256.0f)))
#define FTOI32(__x) ((Sint32)((float)(__x * 1024.0f)))
#define I16TOF(__x) (((float)__x) / 256.0f) #define I16TOF(__x) (((float)__x) / 256.0f)
#define I32TOF(__x) (((float)__x) / 1024.0f)
#ifdef _WIN32 #ifdef _WIN32
#define _sockaddr sockaddr #define _sockaddr sockaddr

@ -76,7 +76,12 @@ struct pkg_field {
struct pkgheader h; struct pkgheader h;
unsigned char x; unsigned char x;
unsigned char y; unsigned char y;
_field field; unsigned char type;
signed char mixframe; // data for the mixed frame
Sint16 frame; // frame (frame > 0 && FS_stone)
unsigned char special; // to save special stones, or the tunnel number
_ex_field ex[4]; // count up every explosion there is on this field for ever direction
Sint32 ex_nr; // number to identify the explosion.
}; };

@ -1,4 +1,4 @@
/* $Id: bomb.c,v 1.47 2003/11/05 12:15:25 stpohle Exp $ */ /* $Id: bomb.c,v 1.48 2003/11/08 06:27:58 stpohle Exp $ */
/* everything what have to do with the bombs */ /* everything what have to do with the bombs */
#include "bomberclone.h" #include "bomberclone.h"
@ -9,8 +9,8 @@ draw_bomb (_bomb * bomb)
{ {
SDL_Rect src, SDL_Rect src,
dest; dest;
int x = bomb->pos.x, int x = floorf (bomb->pos.x),
y = bomb->pos.y; y = floorf (bomb->pos.y);
if (x < 0 || y < 0 || x >= map.size.x || y >= map.size.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); d_printf ("FATAL: Draw Bomb out of range [%f,%f]\n", x, y);
@ -18,16 +18,11 @@ draw_bomb (_bomb * bomb)
} }
if (bomb->state != BS_trigger if (bomb->state != BS_trigger
|| ((bomb->state == BS_trigger) && (bomb->to < BOMB_TIMEOUT * TIME_FACTOR))) { || ((bomb->state == BS_trigger) && (bomb->to < BOMB_TIMEOUT))) {
/* check the framenumber */ /* check the framenumber */
if (bomb->frameto-- == 0) { bomb->frame += timefactor;
bomb->frameto = ANI_BOMBTIMEOUT; if (bomb->frame < 0 || bomb->frame >= gfx.bomb.frames)
bomb->frame++; bomb->frame = 0.0f;
};
if (bomb->frame < 0 || bomb->frame >= gfx.bomb.frames || bomb->frameto > ANI_BOMBTIMEOUT) {
bomb->frame = 0;
bomb->frameto = ANI_BOMBTIMEOUT;
}
} }
dest.w = src.w = gfx.bomb.image->w; dest.w = src.w = gfx.bomb.image->w;
@ -35,7 +30,7 @@ draw_bomb (_bomb * bomb)
dest.x = gfx.offset.x + x * gfx.block.x; dest.x = gfx.offset.x + x * gfx.block.x;
dest.y = gfx.offset.y + y * gfx.block.y; 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 * (int)bomb->frame;
stonelist_add (x, y); stonelist_add (x, y);
if (bomb->mode != BM_normal) { if (bomb->mode != BM_normal) {
stonelist_add (x+1, y); stonelist_add (x+1, y);
@ -51,14 +46,14 @@ void
bomb_explode (int p, int b, int net) bomb_explode (int p, int b, int net)
{ {
int d; int d;
_bomb *bomb = &bman.players[p].bombs[b]; _bomb *bomb = &players[p].bombs[b];
d_printf ("Bomb Explode p:%d, b:%d [%f,%f]\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
bman.players[p].bomb_lastex = b; players[p].bomb_lastex = b;
bomb->to = EXPLOSIONTIMEOUT; /* set the timeout for the fireexplosion */ bomb->to = EXPLOSIONTIMEOUT; /* set the timeout for the fireexplosion */
bomb->state = BS_exploding; bomb->state = BS_exploding;
@ -150,11 +145,11 @@ bomb_move (_bomb * bomb)
/* if a network game is running send bomb data with the /* if a network game is running send bomb data with the
current information */ current information */
if (GT_MP_PTP) { if (GT_MP) {
int b = -1, i = 0; int b = -1, i = 0;
do { do {
if (&bman.players[bman.p_nr].bombs[i] == bomb) if (&players[bman.p_nr].bombs[i] == bomb)
b = i; b = i;
i++; i++;
} while (b == -1 && i < MAX_BOMBS); } while (b == -1 && i < MAX_BOMBS);
@ -182,27 +177,29 @@ bomb_loop ()
_bomb *bomb; _bomb *bomb;
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
player = &bman.players[p]; player = &players[p];
if ((bman.players[p].state & PSFM_used) != 0) { if ((players[p].state & PSFM_used) != 0) {
for (i = 0; i < MAX_BOMBS; i++) { for (i = 0; i < MAX_BOMBS; i++) {
bomb = &player->bombs[i]; bomb = &player->bombs[i];
switch (bomb->state) { switch (bomb->state) {
case BS_ticking: case BS_ticking:
case BS_trigger: case BS_trigger:
if (GT_MP_PTPM || bman.gametype == GT_single) { if (GT_MP_PTPM || GT_SP) {
if (--bomb->to == 0) // bomb will have to explode in the next loop bomb->to -= timediff;
if (bomb->to <= 0.0f) // bomb will have to explode in the next loop
bomb_explode (p, i, 1); bomb_explode (p, i, 1);
else else
draw_bomb (bomb); draw_bomb (bomb);
} }
else { else {
if (--bomb->to == 0) { // bomb did not explode -> resend bombdata bomb->to -= timediff;
if (bomb->to <= 0.0f) { // bomb did not explode -> resend bombdata
if (bomb->state == BS_ticking) if (bomb->state == BS_ticking)
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; bomb->to = BOMB_TIMEOUT;
else else
bomb->to = SPECIAL_TRIGGER_TIMEOUT * TIME_FACTOR; bomb->to = SPECIAL_TRIGGER_TIMEOUT;
net_game_send_bomb (bman.p_nr, i); net_game_send_bomb (bman.p_nr, i);
bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR); bomb->to = bomb->to + 2 * RESENDCACHE_RETRY;
} }
draw_bomb (bomb); draw_bomb (bomb);
} }
@ -214,15 +211,15 @@ bomb_loop ()
break; break;
case BS_exploding: case BS_exploding:
if (bomb->to > 0) { if (bomb->to > 0.0f) {
do_explosion (p, i); do_explosion (p, i);
} }
if (bomb->to == 0) { // explosion done if (bomb->to <= 0.0f) { // explosion done
restore_explosion (bomb); restore_explosion (bomb);
bomb->to = 0; bomb->to = 0.0f;
bomb->state = BS_off; bomb->state = BS_off;
} }
bomb->to--; bomb->to -= timediff;
b++; b++;
break; break;
} }
@ -244,9 +241,9 @@ get_bomb_on (float x, float y, _point bombs[])
_bomb *bomb; _bomb *bomb;
for (i = 0, p = 0; p < MAX_PLAYERS; p++) for (i = 0, p = 0; p < MAX_PLAYERS; p++)
if ((bman.players[p].state & PSFM_used) != 0) { if ((players[p].state & PSFM_used) != 0) {
for (b = 0; b < MAX_BOMBS; b++) { for (b = 0; b < MAX_BOMBS; b++) {
bomb = &bman.players[p].bombs[b]; bomb = &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-1.0f < x && bomb->pos.x+1.0f > x && bomb->pos.y-1.0f < y && bomb->pos.y+1.0f > 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;
@ -277,7 +274,7 @@ draw_fire (int x, int y, int d, int frame)
dest.x = gfx.offset.x + x * gfx.block.x; dest.x = gfx.offset.x + x * gfx.block.x;
dest.y = gfx.offset.y + y * gfx.block.y; dest.y = gfx.offset.y + y * gfx.block.y;
src.y = frame * src.w; src.y = (int)frame * src.w;
src.x = d * src.w; src.x = d * src.w;
gfx_blit (gfx.fire.image, &src, gfx.screen, &dest, (y * 100)); gfx_blit (gfx.fire.image, &src, gfx.screen, &dest, (y * 100));
@ -335,8 +332,7 @@ restore_explosion (_bomb * bomb)
&& bomb->ex_nr != map.field[_x][_y].ex_nr) { && bomb->ex_nr != map.field[_x][_y].ex_nr) {
map.field[_x][_y].ex_nr = bomb->ex_nr; map.field[_x][_y].ex_nr = bomb->ex_nr;
map.field[_x][_y].frame = 0; map.field[_x][_y].frame = 0.0f;
map.field[_x][_y].frameto = 0;
if (map.field[_x][_y].special != FT_nothing) { if (map.field[_x][_y].special != FT_nothing) {
map.field[_x][_y].type = map.field[_x][_y].special; map.field[_x][_y].type = map.field[_x][_y].special;
map.field[_x][_y].special = FT_nothing; map.field[_x][_y].special = FT_nothing;
@ -368,7 +364,7 @@ restore_explosion (_bomb * bomb)
int int
explosion_check_field (int x, int y, int p, int b) explosion_check_field (int x, int y, int p, int b)
{ {
_bomb *bomb = &bman.players[p].bombs[b]; _bomb *bomb = &players[p].bombs[b];
int pl[MAX_PLAYERS]; int pl[MAX_PLAYERS];
int i; int i;
_point bo[MAX_PLAYERS * MAX_BOMBS]; _point bo[MAX_PLAYERS * MAX_BOMBS];
@ -383,7 +379,7 @@ explosion_check_field (int x, int y, int p, int b)
// 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++) {
tmpbomb = &bman.players[bo[i].x].bombs[bo[i].y]; tmpbomb = &players[bo[i].x].bombs[bo[i].y];
if (tmpbomb != bomb && tmpbomb->state != BS_exploding) { if (tmpbomb != bomb && tmpbomb->state != BS_exploding) {
tmpbomb->ex_nr = bomb->ex_nr; // set the ex_nr to identify explosions tmpbomb->ex_nr = bomb->ex_nr; // set the ex_nr to identify explosions
bomb_explode (bo[i].x, bo[i].y, 1); bomb_explode (bo[i].x, bo[i].y, 1);
@ -392,19 +388,17 @@ explosion_check_field (int x, int y, int p, int b)
// check if any player is in the explosion // check if any player is in the explosion
for (i = 0; pl[i] != -1; i++) { for (i = 0; pl[i] != -1; i++) {
tmpplayer = &bman.players[pl[i]]; tmpplayer = &players[pl[i]];
if (((tmpplayer->state & PSF_alife) != 0) if (((tmpplayer->state & PSF_alife) != 0)
&& (bman.gametype == GT_single && (GT_SP || (GT_MP && (&players[bman.p_nr] == tmpplayer))))
|| (GT_MP_PTP && (&bman.players[bman.p_nr] == tmpplayer))))
player_died (tmpplayer, p); player_died (tmpplayer, p);
} }
// let the stones right beside explode // let the stones right beside explode
if (map.field[x][y].type != FT_nothing && map.field[x][y].type != FT_tunnel if (map.field[x][y].type != FT_nothing && map.field[x][y].type != FT_tunnel
&& map.field[x][y].type != FT_block && bomb->ex_nr != map.field[x][y].ex_nr) && map.field[x][y].type != FT_block && bomb->ex_nr != map.field[x][y].ex_nr)
if (map.field[x][y].frame == 0) { if (map.field[x][y].frame <= 0.0f) {
map.field[x][y].frameto = ANI_STONETIMEOUT; map.field[x][y].frame = 1.0f;
map.field[x][y].frame = 1;
stonelist_add (x, y); stonelist_add (x, y);
} }
@ -423,10 +417,6 @@ draw_explosion (_bomb * bomb)
dy; dy;
_point p; _point p;
bomb->frameto--;
if (bomb->frameto < 0 || bomb->frameto > ANI_FIRETIMEOUT)
bomb->frameto = ANI_FIRETIMEOUT;
for (d = 0; d < 4; d++) { for (d = 0; d < 4; d++) {
switch (d) { switch (d) {
case (left): case (left):
@ -450,11 +440,9 @@ draw_explosion (_bomb * bomb)
p.y = bomb->pos.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) { map.field[p.x][p.y].ex[d].frame += timefactor;
map.field[p.x][p.y].ex[d].frame++;
if (map.field[p.x][p.y].ex[d].frame >= gfx.fire.frames) if (map.field[p.x][p.y].ex[d].frame >= gfx.fire.frames)
map.field[p.x][p.y].ex[d].frame = 0; map.field[p.x][p.y].ex[d].frame = 0.0f;
}
stonelist_add (p.x, p.y); stonelist_add (p.x, p.y);
draw_fire (p.x, p.y, d, -1); draw_fire (p.x, p.y, d, -1);
p.x += dx; p.x += dx;
@ -467,7 +455,7 @@ draw_explosion (_bomb * bomb)
void void
do_explosion (int p, int b) do_explosion (int p, int b)
{ {
_bomb *bomb = &bman.players[p].bombs[b]; _bomb *bomb = &players[p].bombs[b];
int dx = 0, int dx = 0,
dy = 0, dy = 0,
d; d;

@ -22,8 +22,8 @@ game_init (int argc, char **argv)
bman.serverlist[i].name[0] = 0; bman.serverlist[i].name[0] = 0;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
bman.players[i].gfx = NULL; /* we will select them in the wait_for_players loop */ players[i].gfx = NULL; /* we will select them in the wait_for_players loop */
bman.players[i].gfx_nr = -1; /* and even now in the singleplayer menu */ players[i].gfx_nr = -1; /* and even now in the singleplayer menu */
} }
stonelist_del (); stonelist_del ();

@ -35,7 +35,7 @@ void d_playerdetail (char *head) {
d_printf ("---------------> %s\n", head); d_printf ("---------------> %s\n", head);
d_printf ("Nr Name GFX Sta Pkt Win [Addr]\n"); d_printf ("Nr Name GFX Sta Pkt Win [Addr]\n");
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
d_printf ("%2d %16s %3d %3d %3d %3d [%s:%s]\n",i, bman.players[i].name, bman.players[i].gfx_nr, bman.players[i].state, bman.players[i].points, bman.players[i].wins, bman.players[i].net.addr.host, bman.players[i].net.addr.port); d_printf ("%2d %16s %3d %3d %3d %3d [%s:%s]\n",i, players[i].name, players[i].gfx_nr, players[i].state, players[i].points, players[i].wins, players[i].net.addr.host, players[i].net.addr.port);
}; };
@ -59,3 +59,16 @@ void d_fatal (char *fmt,...) {
vfprintf (stdout, fmt, args); vfprintf (stdout, fmt, args);
va_end (args); va_end (args);
} }
void debug_ingameinfo() {
int i;
char text[255];
for (i = 0; i < map.size.x; i++)
stonelist_add (i, map.size.y-1);
redraw_logo (0, gfx.res.y-font[0].size.y, gfx.res.y, gfx.res.x);
sprintf (text, "TDiff: %2.3f TFactor: %2.3f", timediff, timefactor);
font_gfxdraw (0, gfx.res.y-font[0].size.y, text, 0, (map.size.y*256)+10);
};

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.47 2003/11/05 12:15:25 stpohle Exp $ */ /* $Id: field.c,v 1.48 2003/11/08 06:27:58 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"
@ -64,6 +64,8 @@ _stonelist_add (int x, int y, int recursive)
_stonelist_add (x, y - 1, 0); _stonelist_add (x, y - 1, 0);
} }
}; };
inline void inline void
stonelist_add (int x, int y) stonelist_add (int x, int y)
{ {
@ -119,7 +121,7 @@ draw_stone (int x, int y)
field_animation_add (x, y); field_animation_add (x, y);
if (stone->frame < gfx.field[FT_stone].frames) { if (stone->frame < gfx.field[FT_stone].frames) {
src.y = stone->frame * gfx.field[FT_stone].h; src.y = (int)stone->frame * gfx.field[FT_stone].h;
dest.h = src.h = gfx.field[FT_stone].h; dest.h = src.h = gfx.field[FT_stone].h;
dest.y -= (gfx.field[stone->type].h - gfx.field[stone->type].w); dest.y -= (gfx.field[stone->type].h - gfx.field[stone->type].w);
srcimg = gfx.field[FT_stone].image; srcimg = gfx.field[FT_stone].image;
@ -187,8 +189,8 @@ draw_stone (int x, int y)
draw_fire (x, y, d, -1); draw_fire (x, y, d, -1);
} }
if (debug) // if (debug)
font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, (y*256) - 6); // font_gfxdraw (dest.x, dest.y, (map.bfield[x][y] == 0) ? "0" : "1", 0, (y*256) + 10);
return; return;
}; };
@ -222,7 +224,7 @@ void
field_clear (int x, int y) field_clear (int x, int y)
{ {
map.field[x][y].type = FT_nothing; map.field[x][y].type = FT_nothing;
if (bman.gametype != GT_single) if (GT_MP)
net_game_send_field (x, y); net_game_send_field (x, y);
} }
@ -232,7 +234,8 @@ void
field_animation () field_animation ()
{ {
int i, int i,
j; j,
oldframe;
_field *stone; _field *stone;
for (i = 0; i < MAX_FIELDANIMATION; i++) for (i = 0; i < MAX_FIELDANIMATION; i++)
@ -241,17 +244,11 @@ field_animation ()
/* check if there is a need to animate this */ /* check if there is a need to animate this */
stone = &map.field[fieldani[i].x][fieldani[i].y]; stone = &map.field[fieldani[i].x][fieldani[i].y];
if ((stone->type == FT_stone && stone->frame > 0) || (stone->type >= FT_death)) { if ((stone->type == FT_stone && stone->frame > 0.0f) || (stone->type >= FT_death)) {
/* animate this stone */ /* animate this stone */
if (stone->type == FT_stone) { if (stone->type == FT_stone) {
if (stone->frameto == 0) if (stone->frame < gfx.field[FT_stone].frames)
if (stone->frame < gfx.field[FT_stone].frames) { stone->frame += timefactor;
stone->frame++;
stone->frameto = ANI_STONETIMEOUT;
}
if (stone->frameto > 0)
stone->frameto--;
} }
else { /* animation is a powerup */ else { /* animation is a powerup */
/* select right powerup animation */ /* select right powerup animation */
@ -263,15 +260,13 @@ field_animation ()
j = PWUP_good; j = PWUP_good;
/* do the animation of the FT_mixed */ /* do the animation of the FT_mixed */
if (stone->frameto-- <= 0 || stone->frameto > ANI_STONETIMEOUT) { oldframe = (int)stone->frame;
stone->frameto = ANI_STONETIMEOUT; stone->frame += timefactor;
stone->frame++; if ((int)stone->frame != oldframe && stone->type == FT_mixed) {
if (stone->type == FT_mixed) {
stone->mixframe++; stone->mixframe++;
if (stone->mixframe < FT_death || stone->mixframe >= FT_mixed) if (stone->mixframe < FT_death || stone->mixframe >= FT_mixed)
stone->mixframe = FT_death; stone->mixframe = FT_death;
} }
}
if (stone->frame >= gfx.powerup[j].frames) if (stone->frame >= gfx.powerup[j].frames)
stone->frame = 0; stone->frame = 0;
@ -338,7 +333,7 @@ void
field_loop () field_loop ()
{ {
/* single game or multiplayer master, so check field state */ /* single game or multiplayer master, so check field state */
if ((GT_MP_PTPM || bman.gametype == GT_single) && bman.state == GS_running) { if ((GT_MP_PTPM || GT_SP) && bman.state == GS_running) {
/* timeout for rechecking every 5 secs the field */ /* timeout for rechecking every 5 secs the field */
if (map.state == MS_normal && map.map_selection == MAPS_randgen if (map.state == MS_normal && map.map_selection == MAPS_randgen

@ -1,4 +1,4 @@
/* $Id: font.c,v 1.9 2003/08/29 21:26:47 stpohle Exp $ */ /* $Id: font.c,v 1.10 2003/11/08 06:27:58 stpohle Exp $ */
// Using Fonts in SDL // Using Fonts in SDL
#include <string.h> #include <string.h>
@ -53,7 +53,7 @@ font_gfxdraw (int x, int y, char *text, int size, int ypos)
c = text[i]; c = text[i];
src.x = font[size].size.x * (c & 15); src.x = font[size].size.x * (c & 15);
src.y = font[size].size.y * ((c & 240) >> 4); src.y = font[size].size.y * ((c & 240) >> 4);
gfx_blit (font[size].image, &src, gfx.screen, &dest, y); gfx_blit (font[size].image, &src, gfx.screen, &dest, ypos);
dest.x += font[size].size.x; dest.x += font[size].size.x;
} }

@ -1,4 +1,4 @@
/* $Id: game.c,v 1.57 2003/11/05 12:15:25 stpohle Exp $ /* $Id: game.c,v 1.58 2003/11/08 06:27:58 stpohle Exp $
game.c - procedures for the game. */ game.c - procedures for the game. */
#include <string.h> #include <string.h>
@ -13,8 +13,7 @@
extern int blitdb_nr, extern int blitdb_nr,
blitrects_nr; blitrects_nr;
static Uint32 timediff, static Uint32 game_timediff, game_timediff1;
timediff1;
void void
game_draw_info () game_draw_info ()
@ -40,23 +39,23 @@ game_draw_info ()
/* In Multiplayer mode draw Player names and /* In Multiplayer mode draw Player names and
count the players who are still alife. */ count the players who are still alife. */
for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++) for (x = 0, j = 0, i = 0; i < MAX_PLAYERS; i++)
if ((bman.players[i].state & PSFM_used) != 0) { if ((players[i].state & PSFM_used) != 0) {
if (bman.players[i].gfx_nr != -1 && PS_IS_used (bman.players[i].state)) { if (players[i].gfx_nr != -1 && PS_IS_used (players[i].state)) {
src.x = 3 * bman.players[i].gfx->smal_size.x; src.x = 3 * players[i].gfx->smal_size.x;
src.y = 0; src.y = 0;
src.w = dest.w = bman.players[i].gfx->smal_size.x; src.w = dest.w = players[i].gfx->smal_size.x;
src.h = dest.h = bman.players[i].gfx->smal_size.y; src.h = dest.h = players[i].gfx->smal_size.y;
dest.x = x; dest.x = x;
dest.y = j - 4; dest.y = j - 4;
SDL_BlitSurface (bman.players[i].gfx->smal_image, &src, gfx.screen, &dest); SDL_BlitSurface (players[i].gfx->smal_image, &src, gfx.screen, &dest);
} }
sprintf (scrtext, "%10s:%2d", bman.players[i].name, bman.players[i].points); sprintf (scrtext, "%10s:%2d", players[i].name, players[i].points);
if (!PS_IS_alife (bman.players[i].state)) { // Player is dead if (!PS_IS_alife (players[i].state)) { // Player is dead
if ((bman.players[i].state & PSF_used) != PSF_used) if ((players[i].state & PSF_used) != PSF_used)
font_setcolor (128, 128, 128, 0); font_setcolor (128, 128, 128, 0);
else else
font_setcolor (0, 0, 128, 0); font_setcolor (0, 0, 128, 0);
@ -77,19 +76,19 @@ game_draw_info ()
font_setcolor (255, 255, 255, 0); font_setcolor (255, 255, 255, 0);
x = gfx.res.x - 120; x = gfx.res.x - 120;
sprintf (text, "Bombs: %2d", bman.players[bman.p_nr].bombs_n); sprintf (text, "Bombs: %2d", players[bman.p_nr].bombs_n);
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", players[bman.p_nr].range);
font_draw (x, 16, text, 0); font_draw (x, 16, text, 0);
sprintf (text, "Speed: %1.1f", bman.players[bman.p_nr].speed*10); sprintf (text, "Speed: %1.1f", 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 (players[bman.p_nr].special.type != 0) {
dest.x = x - 32; dest.x = x - 32;
dest.y = 16; dest.y = 16;
dest.w = gfx.smal_special[bman.players[bman.p_nr].special.type - 1]->w; dest.w = gfx.smal_special[players[bman.p_nr].special.type - 1]->w;
dest.h = gfx.smal_special[bman.players[bman.p_nr].special.type - 1]->h; dest.h = gfx.smal_special[players[bman.p_nr].special.type - 1]->h;
SDL_BlitSurface (gfx.smal_special[bman.players[bman.p_nr].special.type - 1], NULL, SDL_BlitSurface (gfx.smal_special[players[bman.p_nr].special.type - 1], NULL,
gfx.screen, &dest); gfx.screen, &dest);
} }
@ -106,8 +105,11 @@ game_draw_info ()
} }
} }
if (chat.visible == 0 && GT_MP_PTP) if (chat.visible == 0 && GT_MP)
chat_show (4, 4.5*16, gfx.res.x - 4, gfx.offset.y); chat_show (4, 4.5*16, gfx.res.x - 4, gfx.offset.y);
if (debug)
debug_ingameinfo();
}; };
@ -118,14 +120,14 @@ game_loop ()
Uint8 *keys; Uint8 *keys;
int done = 0; int done = 0;
Uint32 timeloop1; Uint32 timeloop1;
int gameovertimeout = TIME_FACTOR * 5; // gameovertimeout float gameovertimeout = 5.0; // gameovertimeout
unsigned char key_bomb = 0; // last state of the bomb key unsigned char key_bomb = 0; // last state of the bomb key
gfx_blitupdaterectclear (); gfx_blitupdaterectclear ();
draw_logo (); draw_logo ();
draw_field (); draw_field ();
if (GT_MP_PTP) if (GT_MP)
net_game_fillsockaddr (); net_game_fillsockaddr ();
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
@ -146,22 +148,22 @@ game_loop ()
keys = SDL_GetKeyState (NULL); keys = SDL_GetKeyState (NULL);
/* only do movements if we're alife and GS_running */ /* only do movements if we're alife and GS_running */
if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife && bman.state == GS_running) { if ((players[bman.p_nr].state & PSFM_alife) == PSFM_alife && bman.state == GS_running) {
if (keys[SDLK_UP]) { if (keys[SDLK_UP]) {
bman.players[bman.p_nr].d = up; players[bman.p_nr].d = up;
bman.players[bman.p_nr].m = 1; players[bman.p_nr].m = 1;
} }
if (keys[SDLK_DOWN]) { if (keys[SDLK_DOWN]) {
bman.players[bman.p_nr].d = down; players[bman.p_nr].d = down;
bman.players[bman.p_nr].m = 1; players[bman.p_nr].m = 1;
} }
if (keys[SDLK_RIGHT]) { if (keys[SDLK_RIGHT]) {
bman.players[bman.p_nr].d = right; players[bman.p_nr].d = right;
bman.players[bman.p_nr].m = 1; players[bman.p_nr].m = 1;
} }
if (keys[SDLK_LEFT]) { if (keys[SDLK_LEFT]) {
bman.players[bman.p_nr].d = left; players[bman.p_nr].d = left;
bman.players[bman.p_nr].m = 1; players[bman.p_nr].m = 1;
} }
if (keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) { if (keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) {
if (key_bomb == 0) if (key_bomb == 0)
@ -171,7 +173,7 @@ game_loop ()
else else
key_bomb = 0; key_bomb = 0;
if ((keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]) && bman.players[bman.p_nr].special.type) { if ((keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]) && players[bman.p_nr].special.type) {
special_use (bman.p_nr); special_use (bman.p_nr);
} }
} }
@ -200,15 +202,15 @@ game_loop ()
player_ilness_loop (bman.p_nr); player_ilness_loop (bman.p_nr);
special_loop (); special_loop ();
if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife) if ((players[bman.p_nr].state & PSFM_alife) == PSFM_alife)
move_player (bman.p_nr); move_player (bman.p_nr);
if (GT_MP_PTP) if (GT_MP)
player_calcpos (); player_calcpos ();
if (bman.gametype != GT_single) if (GT_MP)
network_loop (); network_loop ();
else
single_loop (); single_loop ();
/* this will even set the variable "bman.player_nr" /* this will even set the variable "bman.player_nr"
@ -221,10 +223,10 @@ game_loop ()
/* check if there is only one player left and the game is in multiplayer mode /* check if there is only one player left and the game is in multiplayer mode
and if there the last dieing animation is done */ and if there the last dieing animation is done */
if ((bman.players_nr < 2 if ((bman.players_nr < 2
&& (GT_MP_PTP || (bman.gametype == GT_single && bman.ai_players > 0))) && (GT_MP || (GT_SP && bman.ai_players > 0)))
|| (bman.gametype == GT_single && bman.ai_players == 0 && bman.players_nr < 1) || (GT_SP && bman.ai_players == 0 && bman.players_nr < 1)
|| (bman.timeout <= 0 && map.state != MS_normal)) || (bman.timeout <= 0.0f && map.state != MS_normal))
gameovertimeout--; gameovertimeout -= timediff;
if (gameovertimeout <= 0) { if (gameovertimeout <= 0) {
d_printf ("GAME: Game Over\n"); d_printf ("GAME: Game Over\n");
@ -237,17 +239,18 @@ game_loop ()
// calculate time sync. // calculate time sync.
timeloop1 = SDL_GetTicks (); timeloop1 = SDL_GetTicks ();
timediff = timeloop1 - timestamp; // only for debugging needed game_timediff = timeloop1 - timestamp; // only for debugging needed
while (timeloop1 - timestamp >= 0 && timeloop1 - timestamp < 20) { while (timeloop1 - timestamp >= 0 && timeloop1 - timestamp < 20) {
s_delay (20 - (timeloop1 - timestamp) - 1); s_delay (20 - (timeloop1 - timestamp) - 1);
timeloop1 = SDL_GetTicks (); timeloop1 = SDL_GetTicks ();
} }
timediff1 = timeloop1 - timestamp; game_timediff1 = timeloop1 - timestamp;
timestamp = timeloop1; timestamp = timeloop1;
timefactor = ((float)timediff1) / 20.0f; timefactor = ((float)game_timediff1) / 20.0f;
timediff = ((float)game_timediff1) / 1000.0f;
} }
chat_show (-1, -1, -1, -1); chat_show (-1, -1, -1, -1);
@ -270,21 +273,21 @@ game_end ()
/* count the points */ /* count the points */
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_used (bman.players[i].state)) { if (PS_IS_used (players[i].state)) {
if (PS_IS_alife (bman.players[i].state)) { if (PS_IS_alife (players[i].state)) {
bman.lastwinner = i; bman.lastwinner = i;
bman.players[i].wins++; players[i].wins++;
bman.players[i].points += bman.players_nr_s; players[i].points += bman.players_nr_s;
} }
} }
if (!GT_MP_PTP) if (GT_SP)
game_showresult (); game_showresult ();
/* check which player is now free,i.e. disconnected during the game and was playing */ /* check which player is now free,i.e. disconnected during the game and was playing */
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if ((bman.players[i].state & PSF_used) == 0) if ((players[i].state & PSF_used) == 0)
bman.players[i].state = 0; players[i].state = 0;
} }
@ -299,47 +302,46 @@ game_start ()
bman.players_nr_s = 0; bman.players_nr_s = 0;
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
if (PS_IS_used (bman.players[p].state)) { if (PS_IS_used (players[p].state)) {
bman.players_nr_s++; bman.players_nr_s++;
if (bman.players[p].gfx_nr == -1) { if (players[p].gfx_nr == -1) {
bman.players[p].gfx = NULL; players[p].gfx = NULL;
bman.players[p].state &= (0xff - (PSF_alife + PSF_playing)); players[p].state &= (0xff - (PSF_alife + PSF_playing));
} }
else { else {
bman.players[p].state |= PSF_alife + PSF_playing; players[p].state |= PSF_alife + PSF_playing;
bman.players[p].gfx = &gfx.players[bman.players[p].gfx_nr]; players[p].gfx = &gfx.players[players[p].gfx_nr];
} }
} }
else else
bman.players[p].state = 0; players[p].state = 0;
bman.players[p].bombs_n = START_BOMBS; players[p].bombs_n = START_BOMBS;
bman.players[p].range = START_RANGE; players[p].range = START_RANGE;
bman.players[p].speed = START_SPEED; players[p].speed = START_SPEED;
bman.players[p].special.type = SP_nothing; players[p].special.type = SP_nothing;
bman.players[p].m = 0; players[p].m = 0;
bman.players[p].old.x = 0; players[p].old.x = 0;
bman.players[p].old.y = 0; players[p].old.y = 0;
bman.updatestatusbar=1; bman.updatestatusbar=1;
bman.players[p].frame = 0; players[p].frame = 0.0f;
bman.players[p].frameto = 0; players[p].d = 0;
bman.players[p].d = 0; players[p].pos.x = -1;
bman.players[p].pos.x = -1; players[p].pos.y = -1;
bman.players[p].pos.y = -1; players[p].tunnelto = 0.0f;
bman.players[p].tunnelto = 0;
/* all types of illnes turn them off */ /* all types of illnes turn them off */
for (i = 0; i < PI_max; i++) for (i = 0; i < PI_max; i++)
bman.players[p].ill[i].to = 0; players[p].ill[i].to = 0.0f;
// reset bombs // reset bombs
for (i = 0; i < MAX_BOMBS; i++) { for (i = 0; i < MAX_BOMBS; i++) {
bman.players[p].bombs[i].state = BS_off; players[p].bombs[i].state = BS_off;
bman.players[p].bombs[i].ex_nr = -1; players[p].bombs[i].ex_nr = -1;
bman.players[p].bombs[i].speed = 0; players[p].bombs[i].speed = 0;
bman.players[p].bombs[i].dest.x = 0; players[p].bombs[i].dest.x = 0;
bman.players[p].bombs[i].dest.y = 0; players[p].bombs[i].dest.y = 0;
bman.players[p].bombs[i].mode = BM_normal; players[p].bombs[i].mode = BM_normal;
} }
} }
@ -378,7 +380,7 @@ void game_showresult () {
y += font[2].size.x; y += font[2].size.x;
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)) if (PS_IS_alife (players[p].state))
i++; i++;
if (i == 1) if (i == 1)
@ -408,7 +410,7 @@ void game_showresult () {
font_draw (x, gfx.res.y - font[0].size.y - 2, text, 0); font_draw (x, gfx.res.y - font[0].size.y - 2, text, 0);
for (i = 1, p = 0; p < MAX_PLAYERS; p++) { for (i = 1, p = 0; p < MAX_PLAYERS; p++) {
if (PS_IS_used (bman.players[p].state)) { if (PS_IS_used (players[p].state)) {
if (!i) { if (!i) {
i = 1; i = 1;
x = (gfx.res.x / 2) + 16; x = (gfx.res.x / 2) + 16;
@ -420,25 +422,25 @@ void game_showresult () {
} }
font_setcolor (128, 128, 128, 0); font_setcolor (128, 128, 128, 0);
font_drawbold (x + 80, y + 4, bman.players[p].name, 0, 2); font_drawbold (x + 80, y + 4, players[p].name, 0, 2);
if (PS_IS_alife (bman.players[p].state)) if (PS_IS_alife (players[p].state))
font_setcolor (255, 255, 0, 0); font_setcolor (255, 255, 0, 0);
else else
font_setcolor (196, 196, 196, 0); font_setcolor (196, 196, 196, 0);
font_draw (x + 80, y + 4, bman.players[p].name, 0); font_draw (x + 80, y + 4, players[p].name, 0);
sprintf (text, "%3d", bman.players[p].wins); sprintf (text, "%3d", players[p].wins);
font_draw (x + 80 + (LEN_PLAYERNAME+2) * font[0].size.x, y + 4, text, 0); font_draw (x + 80 + (LEN_PLAYERNAME+2) * font[0].size.x, y + 4, text, 0);
sprintf (text, "%3d", bman.players[p].points); sprintf (text, "%3d", players[p].points);
font_draw (x + 80 + (LEN_PLAYERNAME+5) * font[0].size.x, y + 4, text, 0); font_draw (x + 80 + (LEN_PLAYERNAME+5) * font[0].size.x, y + 4, text, 0);
dest.x = x; dest.x = x;
dest.y = y - 32; dest.y = y - 32;
src.w = dest.w = bman.players[p].gfx->ani.w; src.w = dest.w = players[p].gfx->ani.w;
src.h = dest.h = bman.players[p].gfx->ani.h; src.h = dest.h = players[p].gfx->ani.h;
src.x = bman.players[p].gfx->ani.w * down; src.x = players[p].gfx->ani.w * down;
src.y = 0; src.y = 0;
gfx_blit (bman.players[p].gfx->ani.image, &src, gfx.screen, &dest, 1); gfx_blit (players[p].gfx->ani.image, &src, gfx.screen, &dest, 1);
} }
} }

@ -359,9 +359,9 @@ gamesrv_playerinfo (struct game_entry *gse)
pos++; pos++;
for (i = 1; (i - 1 < LEN_GAMENAME) && (pos[i] != 0) for (i = 1; (i - 1 < LEN_GAMENAME) && (pos[i] != 0)
&& (pos[i] != '\n'); i++) && (pos[i] != '\n'); i++)
bman.players[j].name[i - 1] = pos[i]; players[j].name[i - 1] = pos[i];
bman.players[j].name[i - 1] = 0;pos+=i-1; players[j].name[i - 1] = 0;pos+=i-1;
d_printf ("Name: %s\n", bman.players[j].name); d_printf ("Name: %s\n", players[j].name);
} }
// draw box and players // draw box and players
j=pl*font[0].size.y+font[1].size.y+50; j=pl*font[0].size.y+font[1].size.y+50;
@ -377,7 +377,7 @@ gamesrv_playerinfo (struct game_entry *gse)
y = y + 2 + (font[1].size.y << 1); y = y + 2 + (font[1].size.y << 1);
for(i=0;i<pl;i++) { for(i=0;i<pl;i++) {
sprintf (data, "%s", bman.players[i].name); sprintf (data, "%s", players[i].name);
font_setcolor (128,128,128,0); font_setcolor (128,128,128,0);
font_draw (x - (font[0].size.x * strlen (data) / 2), y, data, 0); font_draw (x - (font[0].size.x * strlen (data) / 2), y, data, 0);
font_setcolor (255,255,255,0); font_setcolor (255,255,255,0);
@ -531,7 +531,7 @@ gamesrv_sendmode (int maxplayer, int curplayers)
sprintf (data, "%sI6\n", data); sprintf (data, "%sI6\n", data);
sprintf (data, "%sN%s\n", data, bman.gamename); sprintf (data, "%sN%s\n", data, bman.gamename);
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if PS_IS_used (bman.players[i].state) sprintf (data, "%sR%s\n", data, bman.players[i].name); if PS_IS_used (players[i].state) sprintf (data, "%sR%s\n", data, players[i].name);
len = strlen (data); len = strlen (data);
network_server_port (bman.gamemaster, host, LEN_SERVERNAME, port, LEN_PORT); network_server_port (bman.gamemaster, host, LEN_SERVERNAME, port, LEN_PORT);

@ -1,4 +1,4 @@
/* $Id: main.c,v 1.16 2003/11/05 12:15:25 stpohle Exp $ */ /* $Id: main.c,v 1.17 2003/11/08 06:27:59 stpohle Exp $ */
#include "bomberclone.h" #include "bomberclone.h"
#include "network.h" #include "network.h"
@ -9,8 +9,12 @@
_bomberclone bman; // Holds GameData _bomberclone bman; // Holds GameData
_player players[MAX_PLAYERS]; // holds all Playerdata
Uint32 timestamp; // timestamp Uint32 timestamp; // timestamp
float timefactor; // factor for the time float timefactor = 0.0f; /* factor for the time time of the last loop
1.0f would be 20ms */
float timediff = 0.0f; /* last loop timedifference in seconds */
int int
main (int argc, char **argv) main (int argc, char **argv)

@ -1,4 +1,4 @@
/* $Id: map.c,v 1.12 2003/11/05 12:15:25 stpohle Exp $ */ /* $Id: map.c,v 1.13 2003/11/08 06:27:59 stpohle Exp $ */
/* map handling, like generate and load maps. */ /* map handling, like generate and load maps. */
#include "bomberclone.h" #include "bomberclone.h"
@ -154,8 +154,7 @@ map_genrandom ()
for (d = 0; d < 4; d++) for (d = 0; d < 4; d++)
map.field[x][y].ex[d].frame = map.field[x][y].ex[d].count = 0; map.field[x][y].ex[d].frame = map.field[x][y].ex[d].count = 0;
map.field[x][y].ex_nr = -1; map.field[x][y].ex_nr = -1;
map.field[x][y].frame = 0; map.field[x][y].frame = 0.0f;
map.field[x][y].frameto = 0;
map.field[x][y].special = FT_nothing; map.field[x][y].special = FT_nothing;
} }
} }
@ -163,8 +162,8 @@ map_genrandom ()
/* will set the playerposition but in a way that we won't start on a block */ /* will set the playerposition but in a way that we won't start on a block */
/* i am just too lazy to write this all again and again */ /* i am just too lazy to write this all again and again */
#define PLX bman.players[i].pos.x #define PLX players[i].pos.x
#define PLY bman.players[i].pos.y #define PLY players[i].pos.y
void void
map_set_playerposition (int usermap) map_set_playerposition (int usermap)
{ {
@ -192,10 +191,10 @@ map_set_playerposition (int usermap)
PLY = s_random (map.size.y - 2) + 1; PLY = s_random (map.size.y - 2) + 1;
for (dx = 10, dy = 10, j = 0; (j < i && j < MAX_PLAYERS && (dx > 1 || dy > 1)); j++) { /* is ther any other player */ for (dx = 10, dy = 10, j = 0; (j < i && j < MAX_PLAYERS && (dx > 1 || dy > 1)); j++) { /* is ther any other player */
dx = PLX - bman.players[j].pos.x; dx = PLX - players[j].pos.x;
if (dx < 0) if (dx < 0)
dx = -dx; dx = -dx;
dy = PLY - bman.players[j].pos.y; dy = PLY - players[j].pos.y;
if (dy < 0) if (dy < 0)
dy = -dy; dy = -dy;
} }
@ -279,8 +278,8 @@ map_set_playerposition (int usermap)
} }
mx = my = 100; mx = my = 100;
for (j = 0; j <= i; j++) { /* search smalest distance */ for (j = 0; j <= i; j++) { /* search smalest distance */
dy = PLY - bman.players[j].pos.y; dy = PLY - players[j].pos.y;
dx = PLX - bman.players[j].pos.x; dx = PLX - players[j].pos.x;
if (dy < 0) if (dy < 0)
dy = -dy; dy = -dy;
if (dx < 0) if (dx < 0)
@ -410,8 +409,7 @@ map_load (FILE * fmap)
for (d = 0; d < 4; d++) for (d = 0; d < 4; d++)
map.field[i][sizey].ex[d].frame = map.field[i][sizey].ex[d].count = 0; map.field[i][sizey].ex[d].frame = map.field[i][sizey].ex[d].count = 0;
map.field[i][sizey].ex_nr = -1; map.field[i][sizey].ex_nr = -1;
map.field[i][sizey].frame = 0; map.field[i][sizey].frame = 0.0f;
map.field[i][sizey].frameto = 0;
map.field[i][sizey].special = FT_nothing; map.field[i][sizey].special = FT_nothing;
} }
sizey++; sizey++;

@ -1,4 +1,4 @@
/* $Id: mapmenu.c,v 1.11 2003/08/29 23:50:39 stpohle Exp $ */ /* $Id: mapmenu.c,v 1.12 2003/11/08 06:27:59 stpohle Exp $ */
/* map/tileset selection menu */ /* map/tileset selection menu */
#include "bomberclone.h" #include "bomberclone.h"
@ -378,7 +378,7 @@ mapinfo ()
keybinput_new (&ki); keybinput_new (&ki);
while (!done && bman.state == GS_wait) { while (!done && bman.state == GS_wait) {
if (bman.gametype == GT_multi && bman.sock != -1) { if (GT_MP && bman.sock != -1) {
network_loop (); network_loop ();
eventstate = SDL_PollEvent (&event); eventstate = SDL_PollEvent (&event);
} }

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.29 2003/07/25 12:28:50 stpohle Exp $ */ /* $Id: menu.c,v 1.30 2003/11/08 06:27:59 stpohle Exp $ */
/* menu's for the game */ /* menu's for the game */
#include <SDL.h> #include <SDL.h>
@ -132,7 +132,7 @@ menu_loop (char *menutitle, _menu menu[], int lastselect)
while (menuselect != -1 && done == 0) { while (menuselect != -1 && done == 0) {
/* do the network loop if we have to */ /* do the network loop if we have to */
if (bman.gametype == GT_multi && bman.sock != -1) { if (GT_MP) {
network_loop (); network_loop ();
eventstate = SDL_PollEvent (&event); eventstate = SDL_PollEvent (&event);
} }
@ -257,7 +257,7 @@ menu_get_text (char *title, char *text, int len)
SDL_Flip (gfx.screen); SDL_Flip (gfx.screen);
/* do the network loop if we have to */ /* do the network loop if we have to */
if (bman.gametype == GT_multi && bman.sock != -1) { if (GT_MP) {
network_loop (); network_loop ();
eventstate = SDL_PollEvent (&event); eventstate = SDL_PollEvent (&event);
} }
@ -377,7 +377,7 @@ menu_displaymessage (char *title, char *text)
while (done == 0 || (done == 1 && keypressed == 1)) { while (done == 0 || (done == 1 && keypressed == 1)) {
/* do the network loop if we have to */ /* do the network loop if we have to */
if (bman.gametype == GT_multi && bman.sock != -1) { if (GT_MP) {
network_loop (); network_loop ();
eventstate = SDL_PollEvent (&event); eventstate = SDL_PollEvent (&event);
} }
@ -415,10 +415,13 @@ menu_clearkeybuff ()
SDL_Event event; SDL_Event event;
Uint8 *keys; Uint8 *keys;
int i; int i;
SDL_PollEvent (&event); SDL_PollEvent (&event);
keys = SDL_GetKeyState (NULL); keys = SDL_GetKeyState (NULL);
if (!(keys[SDLK_RETURN])) if (!(keys[SDLK_RETURN]))
return; return;
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++) {
s_delay (25); s_delay (25);
SDL_PollEvent (&event); SDL_PollEvent (&event);
@ -426,6 +429,7 @@ menu_clearkeybuff ()
if (!(keys[SDLK_RETURN])) if (!(keys[SDLK_RETURN]))
return; return;
} }
menu_displaytext ("", " Press Return ", 64, 0, 0); menu_displaytext ("", " Press Return ", 64, 0, 0);
while (keys[SDLK_RETURN]) { while (keys[SDLK_RETURN]) {
s_delay (25); s_delay (25);
@ -523,7 +527,7 @@ menu_dir_select (char *title, char *path, signed char dirflags)
} }
/* do the network loop if we have to */ /* do the network loop if we have to */
if (bman.gametype == GT_multi && bman.sock != -1) { if (GT_MP) {
network_loop (); network_loop ();
eventstate = SDL_PollEvent (&event); eventstate = SDL_PollEvent (&event);
} }

@ -96,21 +96,21 @@ mw_draw_status ()
/* 2. the names with points */ /* 2. the names with points */
for (x1 = pnr = 0, y = 48; pnr < MAX_PLAYERS; pnr++) { for (x1 = pnr = 0, y = 48; pnr < MAX_PLAYERS; pnr++) {
redraw_logo (x1 * 320, y - 4, 320, 32); redraw_logo (x1 * 320, y - 4, 320, 32);
if (bman.players[pnr].gfx_nr != -1 && PS_IS_used (bman.players[pnr].state)) { if (players[pnr].gfx_nr != -1 && PS_IS_used (players[pnr].state)) {
src.x = 3 * bman.players[pnr].gfx->smal_size.x; src.x = 3 * players[pnr].gfx->smal_size.x;
src.y = 0; src.y = 0;
src.w = dest.w = bman.players[pnr].gfx->smal_size.x; src.w = dest.w = players[pnr].gfx->smal_size.x;
src.h = dest.h = bman.players[pnr].gfx->smal_size.y; src.h = dest.h = players[pnr].gfx->smal_size.y;
dest.x = x1 * 320; dest.x = x1 * 320;
dest.y = y - 4; dest.y = y - 4;
gfx_blit (bman.players[pnr].gfx->smal_image, &src, gfx.screen, &dest, 0xFFFF); gfx_blit (players[pnr].gfx->smal_image, &src, gfx.screen, &dest, 0xFFFF);
} }
sprintf (text, " %10s %2d %2d", bman.players[pnr].name, bman.players[pnr].wins, sprintf (text, " %10s %2d %2d", players[pnr].name, players[pnr].wins,
bman.players[pnr].points); players[pnr].points);
if (PS_IS_used (bman.players[pnr].state)) { if (PS_IS_used (players[pnr].state)) {
if (bman.lastwinner == pnr) if (bman.lastwinner == pnr)
font_setcolor (255, 255, 192, 0); font_setcolor (255, 255, 192, 0);
@ -148,7 +148,7 @@ mw_draw_gfxselect (int selgfx)
xstep = gfx.res.x / MAX_PLAYERS; xstep = gfx.res.x / MAX_PLAYERS;
if (bman.players[bman.p_nr].gfx_nr == -1) { if (players[bman.p_nr].gfx_nr == -1) {
/* draw selection */ /* draw selection */
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
dest.w = src.w = gfx.players[i].ani.w; dest.w = src.w = gfx.players[i].ani.w;
@ -210,7 +210,7 @@ mw_draw_gfxselect (int selgfx)
if (select < MAX_PLAYERS && select >= 0) { if (select < MAX_PLAYERS && select >= 0) {
/* this player have been selected */ /* this player have been selected */
if (bman.players[bman.p_nr].gfx_nr == i) if (players[bman.p_nr].gfx_nr == i)
gfx_blit (gfx.players[i].ani.image, &src, gfx.screen, &dest, 0xFFFF); gfx_blit (gfx.players[i].ani.image, &src, gfx.screen, &dest, 0xFFFF);
else else
gfx_blit (mw_plgfx[i], &src, gfx.screen, &dest, 0xFFFF); gfx_blit (mw_plgfx[i], &src, gfx.screen, &dest, 0xFFFF);
@ -273,7 +273,7 @@ wait_for_players ()
/* check if all players are ready, and more as one player is connected */ /* check if all players are ready, and more as one player is connected */
if (GT_MP_PTPM) if (GT_MP_PTPM)
for (ready = 0, i = 0; i < MAX_PLAYERS; i++) for (ready = 0, i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_playing (bman.players[i].state)) if (PS_IS_playing (players[i].state))
ready++; ready++;
if (ready > 1) if (ready > 1)
ready = 1; ready = 1;
@ -324,7 +324,7 @@ wait_for_players ()
if (bman.p_nr != -1) { if (bman.p_nr != -1) {
if (keys[SDLK_LEFT] && (!keypressed) && bman.players[bman.p_nr].gfx_nr == -1) { if (keys[SDLK_LEFT] && (!keypressed) && players[bman.p_nr].gfx_nr == -1) {
i = 0; i = 0;
while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) { while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) {
selgfx--; selgfx--;
@ -334,7 +334,7 @@ wait_for_players ()
} }
} }
if (keys[SDLK_RIGHT] && (!keypressed) && bman.players[bman.p_nr].gfx_nr == -1) { if (keys[SDLK_RIGHT] && (!keypressed) && players[bman.p_nr].gfx_nr == -1) {
i = 0; i = 0;
while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) { while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) {
selgfx++; selgfx++;
@ -345,7 +345,7 @@ wait_for_players ()
} }
/* just make sure this player is not selected twice */ /* just make sure this player is not selected twice */
if (bman.players[bman.p_nr].gfx_nr == -1) { if (players[bman.p_nr].gfx_nr == -1) {
MW_IS_GFX_SELECT (selgfx, i); MW_IS_GFX_SELECT (selgfx, i);
while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) { while (selgfx < 0 || selgfx >= MAX_PLAYERS || i != -1) {
selgfx++; selgfx++;
@ -356,12 +356,12 @@ wait_for_players ()
} }
if ((keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) && (!keypressed)) { if ((keys[SDLK_LCTRL] || keys[SDLK_RCTRL]) && (!keypressed)) {
if (bman.players[bman.p_nr].gfx_nr == -1) if (players[bman.p_nr].gfx_nr == -1)
/* select player */ /* select player */
bman.players[bman.p_nr].gfx_nr = selgfx; players[bman.p_nr].gfx_nr = selgfx;
else else
/* deselect player */ /* deselect player */
bman.players[bman.p_nr].gfx_nr = -1; players[bman.p_nr].gfx_nr = -1;
net_change_playerid (bman.p_nr, 1); net_change_playerid (bman.p_nr, 1);
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
} }

@ -24,8 +24,6 @@ networkmenu_joingame ()
/* connect if we have an Servername */ /* connect if we have an Servername */
if (bman.servername[0] != 0) { if (bman.servername[0] != 0) {
bman.sock = -1; bman.sock = -1;
bman.gametype = GT_multi;
bman.multitype = MT_ptps;
join_multiplayer_game (); join_multiplayer_game ();
bman.servername[0] = 0; bman.servername[0] = 0;
} }
@ -54,8 +52,6 @@ netmenu ()
break; break;
case (1): // Create a new Game case (1): // Create a new Game
bman.sock = -1; bman.sock = -1;
bman.gametype = GT_multi;
bman.multitype = MT_ptpm;
host_multiplayer_game (); host_multiplayer_game ();
break; break;
case (2): // Options case (2): // Options
@ -196,9 +192,9 @@ multiplayer_firstrun ()
bman.state = GS_wait; bman.state = GS_wait;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
bman.players[i].name[0] = 0; players[i].name[0] = 0;
bman.players[i].gfx_nr = -1; players[i].gfx_nr = -1;
bman.players[i].gfx = NULL; players[i].gfx = NULL;
} }
/* /*
@ -255,7 +251,6 @@ host_multiplayer_game ()
game_end (); game_end ();
} }
} }
network_shutdown (); network_shutdown ();
}; };

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.42 2003/09/12 18:10:36 stpohle Exp $ */ /* $Id: network.c,v 1.43 2003/11/08 06:27:59 stpohle Exp $ */
/* /*
network routines. network routines.
*/ */
@ -60,8 +60,8 @@ net_dyn_pkgoption ()
_net_pkgopt *npkg; _net_pkgopt *npkg;
for (p = 0; p < MAX_PLAYERS; p++) for (p = 0; p < MAX_PLAYERS; p++)
if (PS_IS_netplayer (bman.players[p].state)) { if (PS_IS_netplayer (players[p].state)) {
npkg = &bman.players[p].net.pkgopt; npkg = &players[p].net.pkgopt;
if (npkg->to_2sec > DYN_PKG_MAX_MISSING) { if (npkg->to_2sec > DYN_PKG_MAX_MISSING) {
if (npkg->send_set < 10) if (npkg->send_set < 10)
@ -108,16 +108,16 @@ network_init ()
// reset playernumber and number of connected players // reset playernumber and number of connected players
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
bman.players[i].net.addr.host[0] = 0; players[i].net.addr.host[0] = 0;
bman.players[i].net.addr.port[0] = 0; players[i].net.addr.port[0] = 0;
bman.players[i].name[0] = 0; players[i].name[0] = 0;
bman.players[i].gfx_nr = -1; players[i].gfx_nr = -1;
bman.players[i].net.timestamp = timestamp; players[i].net.timestamp = timestamp;
bman.players[i].points = 0; players[i].points = 0;
bman.players[i].wins = 0; players[i].wins = 0;
bman.players[i].net.pingreq = 20; players[i].net.pingreq = 20;
bman.players[i].net.pingack = 22; players[i].net.pingack = 22;
bman.players[i].state = 0; players[i].state = 0;
} }
bman.lastwinner = -1; bman.lastwinner = -1;
@ -139,31 +139,31 @@ network_init ()
// if we are the server set up my data // if we are the server set up my data
if (GT_MP_PTPM) { if (GT_MP_PTPM) {
strncpy (bman.players[0].name, bman.playername, LEN_PLAYERNAME); strncpy (players[0].name, bman.playername, LEN_PLAYERNAME);
bman.p_nr = 0; bman.p_nr = 0;
bman.players[0].state = PSF_used; players[0].state = PSF_used;
if (bman.notifygamemaster) if (bman.notifygamemaster)
gamesrv_sendmode (bman.maxplayer, 1); gamesrv_sendmode (bman.maxplayer, 1);
} }
// if client send Data to the server // if client send Data to the server
if (GT_MP_PTPS) { if (GT_MP_PTPS) {
network_server_port (bman.servername, bman.players[0].net.addr.host, network_server_port (bman.servername, players[0].net.addr.host,
LEN_SERVERNAME, bman.players[0].net.addr.port, LEN_PORT); LEN_SERVERNAME, players[0].net.addr.port, LEN_PORT);
d_printf ("Connect To: %s[:%s]\n", bman.players[0].net.addr.host, d_printf ("Connect To: %s[:%s]\n", players[0].net.addr.host,
bman.players[0].net.addr.port); players[0].net.addr.port);
dns_filladdr (bman.players[0].net.addr.host, LEN_SERVERNAME, bman.players[0].net.addr.port, dns_filladdr (players[0].net.addr.host, LEN_SERVERNAME, players[0].net.addr.port,
LEN_PORT, bman.net_ai_family, &bman.players[0].net.addr.sAddr); LEN_PORT, bman.net_ai_family, &players[0].net.addr.sAddr);
bman.players[0].net.addr.port[0] = bman.players[0].net.addr.host[0] = 0; players[0].net.addr.port[0] = players[0].net.addr.host[0] = 0;
dns_filladdr (bman.players[0].net.addr.host, LEN_SERVERNAME, bman.players[0].net.addr.port, dns_filladdr (players[0].net.addr.host, LEN_SERVERNAME, players[0].net.addr.port,
LEN_PORT, bman.net_ai_family, &bman.players[0].net.addr.sAddr); LEN_PORT, bman.net_ai_family, &players[0].net.addr.sAddr);
if (bman.firewall) if (bman.firewall)
i = NETF_firewall; i = NETF_firewall;
else else
i = 0; i = 0;
send_playerid (&bman.players[0].net.addr, bman.playername, NULL, NULL, -1, -1, i); send_playerid (&players[0].net.addr, bman.playername, NULL, NULL, -1, -1, i);
} }
return 0; return 0;
@ -180,13 +180,13 @@ network_shutdown ()
if (GT_MP_PTPM) { if (GT_MP_PTPM) {
for (i = 1; i < MAX_PLAYERS; i++) for (i = 1; i < MAX_PLAYERS; i++)
if (bman.players[i].net.addr.host[0] != 0) if (players[i].net.addr.host[0] != 0)
send_quit (&bman.players[i].net.addr, NULL, NULL); send_quit (&players[i].net.addr, NULL, NULL);
if (bman.notifygamemaster) if (bman.notifygamemaster)
gamesrv_quit (); gamesrv_quit ();
} }
else if (bman.players[0].net.addr.host[0] != 0) else if (players[0].net.addr.host[0] != 0)
send_quit (&bman.players[0].net.addr, NULL, NULL); send_quit (&players[0].net.addr, NULL, NULL);
udp_close (bman.sock); udp_close (bman.sock);
@ -209,23 +209,23 @@ net_check_timeout (int pl_nr)
{ {
int timeout = UDP_TIMEOUT; int timeout = UDP_TIMEOUT;
if ((bman.players[pl_nr].state & (PSF_net + PSF_used)) == (PSF_used + PSF_net) if ((players[pl_nr].state & (PSF_net + PSF_used)) == (PSF_used + PSF_net)
&& timestamp - bman.players[pl_nr].net.timestamp > timeout && timestamp - players[pl_nr].net.timestamp > timeout
&& bman.players[pl_nr].net.pingreq != bman.players[pl_nr].net.pingack) { && players[pl_nr].net.pingreq != players[pl_nr].net.pingack) {
d_printf ("net_check_timeout pl_nr=%d, ack=%d, req=%d, timediff=%d\n", pl_nr, d_printf ("net_check_timeout pl_nr=%d, ack=%d, req=%d, timediff=%d\n", pl_nr,
bman.players[pl_nr].net.pingack, bman.players[pl_nr].net.pingreq, players[pl_nr].net.pingack, players[pl_nr].net.pingreq,
timestamp - bman.players[pl_nr].net.timestamp); timestamp - players[pl_nr].net.timestamp);
bman.players[pl_nr].net.timestamp = timestamp; players[pl_nr].net.timestamp = timestamp;
bman.players[pl_nr].net.pingack = bman.players[pl_nr].net.pingreq; players[pl_nr].net.pingack = players[pl_nr].net.pingreq;
send_ping (&bman.players[pl_nr].net.addr, bman.players[pl_nr].net.pingack + 100, send_ping (&players[pl_nr].net.addr, players[pl_nr].net.pingack + 100,
PKG_pingreq); PKG_pingreq);
} }
if ((bman.players[pl_nr].state & (PSF_net + PSF_used)) == (PSF_used + PSF_net) if ((players[pl_nr].state & (PSF_net + PSF_used)) == (PSF_used + PSF_net)
&& timestamp - bman.players[pl_nr].net.timestamp > timeout && timestamp - players[pl_nr].net.timestamp > timeout
&& bman.players[pl_nr].net.pingreq == bman.players[pl_nr].net.pingack) { && players[pl_nr].net.pingreq == players[pl_nr].net.pingack) {
d_printf ("net_check_timeout pl_nr=%d, ack=%d, req=%d, timediff=%d\n", pl_nr, d_printf ("net_check_timeout pl_nr=%d, ack=%d, req=%d, timediff=%d\n", pl_nr,
bman.players[pl_nr].net.pingack, bman.players[pl_nr].net.pingreq, players[pl_nr].net.pingack, players[pl_nr].net.pingreq,
timestamp - bman.players[pl_nr].net.timestamp); timestamp - players[pl_nr].net.timestamp);
return 1; return 1;
} }
return 0; return 0;
@ -316,39 +316,39 @@ draw_netupdatestate ()
dest; dest;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_used (bman.players[i].state)) { if (PS_IS_used (players[i].state)) {
y += 48; y += 48;
redraw_logo (0, y, gfx.res.x, y + 48); redraw_logo (0, y, gfx.res.x, y + 48);
if (bman.players[i].gfx_nr != -1) { if (players[i].gfx_nr != -1) {
dest.w = src.w = bman.players[i].gfx->smal_size.x; dest.w = src.w = players[i].gfx->smal_size.x;
dest.h = src.h = bman.players[i].gfx->smal_size.y; dest.h = src.h = players[i].gfx->smal_size.y;
src.x = bman.players[i].gfx->smal_size.x * down; src.x = players[i].gfx->smal_size.x * down;
src.y = 0; src.y = 0;
dest.x = 50; dest.x = 50;
dest.y = y; dest.y = y;
SDL_BlitSurface (bman.players[i].gfx->smal_image, &src, gfx.screen, &dest); SDL_BlitSurface (players[i].gfx->smal_image, &src, gfx.screen, &dest);
gfx_blitupdaterectadd (&dest); gfx_blitupdaterectadd (&dest);
} }
if (bman.players[i].net.net_istep == 0) if (players[i].net.net_istep == 0)
sprintf (text, "%s - State : READY", bman.players[i].name); sprintf (text, "%s - State : READY", players[i].name);
else else
sprintf (text, "%s - State : DOWNLOAD", bman.players[i].name); sprintf (text, "%s - State : DOWNLOAD", players[i].name);
font_draw (70, y, text, 0); font_draw (70, y, text, 0);
text[0] = 0; text[0] = 0;
if (bman.players[i].net.net_istep == 3) if (players[i].net.net_istep == 3)
sprintf (text, "Getting Tunnel Data %d.", bman.players[i].net.net_status); sprintf (text, "Getting Tunnel Data %d.", players[i].net.net_status);
if (bman.players[i].net.net_istep == 2) if (players[i].net.net_istep == 2)
sprintf (text, "Getting Field Data %d of %d.", bman.players[i].net.net_status, sprintf (text, "Getting Field Data %d of %d.", players[i].net.net_status,
map.size.x); map.size.x);
if (bman.players[i].net.net_istep == 1) if (players[i].net.net_istep == 1)
sprintf (text, "Getting Player Data %d of %d.", bman.players[i].net.net_status, sprintf (text, "Getting Player Data %d of %d.", players[i].net.net_status,
MAX_PLAYERS); MAX_PLAYERS);
font_draw (70, y + 32, text, 0); font_draw (70, y + 32, text, 0);
@ -369,22 +369,22 @@ net_change_playerid (int pl_nr, unsigned char senddata)
Send to all connected clients the update Send to all connected clients the update
*/ */
for (i = 1; i < MAX_PLAYERS; i++) for (i = 1; i < MAX_PLAYERS; i++)
if (bman.players[i].net.addr.host[0] != 0) if (players[i].net.addr.host[0] != 0)
send_playerid (&bman.players[i].net.addr, bman.players[pl_nr].name, send_playerid (&players[i].net.addr, players[pl_nr].name,
bman.players[pl_nr].net.addr.host, bman.players[pl_nr].net.addr.port, players[pl_nr].net.addr.host, players[pl_nr].net.addr.port,
pl_nr, bman.players[pl_nr].gfx_nr, bman.players[pl_nr].net.flags); pl_nr, players[pl_nr].gfx_nr, players[pl_nr].net.flags);
} }
else { else {
/* /*
Send only to the Server the update and only if in_nr == bman.in_nr Send only to the Server the update and only if in_nr == bman.in_nr
*/ */
if (pl_nr == bman.p_nr && senddata) if (pl_nr == bman.p_nr && senddata)
send_playerid (&bman.players[0].net.addr, bman.players[pl_nr].name, send_playerid (&players[0].net.addr, players[pl_nr].name,
bman.players[pl_nr].net.addr.host, bman.players[pl_nr].net.addr.port, players[pl_nr].net.addr.host, players[pl_nr].net.addr.port,
pl_nr, bman.players[pl_nr].gfx_nr, bman.players[pl_nr].net.flags); pl_nr, players[pl_nr].gfx_nr, players[pl_nr].net.flags);
} }
player_set_gfx (&bman.players[pl_nr], bman.players[pl_nr].gfx_nr); player_set_gfx (&players[pl_nr], players[pl_nr].gfx_nr);
}; };
@ -420,9 +420,9 @@ net_transmit_gamedata ()
prepare everything for the loop prepare everything for the loop
*/ */
for (x = 0; x < MAX_PLAYERS; x++) { for (x = 0; x < MAX_PLAYERS; x++) {
bman.players[x].net.timestamp = 0; players[x].net.timestamp = 0;
bman.players[x].net.net_status = -1; players[x].net.net_status = -1;
bman.players[x].net.net_istep = 3; players[x].net.net_istep = 3;
} }
y = -1; y = -1;
@ -439,7 +439,7 @@ net_transmit_gamedata ()
/* if PTPM check if all players are ready */ /* if PTPM check if all players are ready */
if (GT_MP_PTPM) { if (GT_MP_PTPM) {
for (p = 1, i = 1; p < MAX_PLAYERS; p++) for (p = 1, i = 1; p < MAX_PLAYERS; p++)
if (PS_IS_playing (bman.players[p].state) && bman.players[p].net.net_istep != 0) if (PS_IS_playing (players[p].state) && players[p].net.net_istep != 0)
i = 0; i = 0;
if (i == 1) { /* all players are ready */ if (i == 1) { /* all players are ready */
done = 1; done = 1;
@ -453,22 +453,22 @@ net_transmit_gamedata ()
/* /*
get tunneldata get tunneldata
*/ */
if ((y < GAME_MAX_TUNNELS - 1 && y == bman.players[bman.p_nr].net.net_status) if ((y < GAME_MAX_TUNNELS - 1 && y == players[bman.p_nr].net.net_status)
|| y == -1) { || y == -1) {
y++; y++;
downtimestamp = timestamp; downtimestamp = timestamp;
send_tunneldata (&bman.players[0].net.addr, y, -1, -1); send_tunneldata (&players[0].net.addr, y, -1, -1);
} }
else if (y < GAME_MAX_TUNNELS && y != bman.players[bman.p_nr].net.net_status else if (y < GAME_MAX_TUNNELS && y != players[bman.p_nr].net.net_status
&& y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
/* we have got no tunnel data*/ /* we have got no tunnel data*/
y--; y--;
} }
else if (y == GAME_MAX_TUNNELS - 1 && bman.players[bman.p_nr].net.net_status == y) { else if (y == GAME_MAX_TUNNELS - 1 && players[bman.p_nr].net.net_status == y) {
/* we have got all tunnel data */ /* we have got all tunnel data */
y = -1; y = -1;
bman.players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_istep = --net_istep;
bman.players[bman.p_nr].net.net_status = -1; players[bman.p_nr].net.net_status = -1;
} }
} }
@ -476,23 +476,23 @@ net_transmit_gamedata ()
/* /*
get field data get field data
*/ */
if ((y < map.size.y - 1 && y == bman.players[bman.p_nr].net.net_status) if ((y < map.size.y - 1 && y == players[bman.p_nr].net.net_status)
|| y == -1) { || y == -1) {
/* send field data req */ /* send field data req */
y++; y++;
downtimestamp = timestamp; downtimestamp = timestamp;
send_getfield (&bman.players[0].net.addr, y); send_getfield (&players[0].net.addr, y);
} }
else if (y < map.size.y && y != bman.players[bman.p_nr].net.net_status else if (y < map.size.y && y != players[bman.p_nr].net.net_status
&& y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { && y >= 0 && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
/* getdata timed out - we have got no field data */ /* getdata timed out - we have got no field data */
y--; y--;
} }
else if (y == map.size.y - 1 && bman.players[bman.p_nr].net.net_status == y) { else if (y == map.size.y - 1 && players[bman.p_nr].net.net_status == y) {
/* we have got all field data */ /* we have got all field data */
y = -1; y = -1;
bman.players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_istep = --net_istep;
bman.players[bman.p_nr].net.net_status = -1; players[bman.p_nr].net.net_status = -1;
} }
} }
@ -500,31 +500,31 @@ net_transmit_gamedata ()
/* /*
get player data get player data
*/ */
if ((y < MAX_PLAYERS - 1 && y == bman.players[bman.p_nr].net.net_status) || y == -1) { if ((y < MAX_PLAYERS - 1 && y == players[bman.p_nr].net.net_status) || y == -1) {
/* send player date req */ /* send player date req */
y++; y++;
downtimestamp = timestamp; downtimestamp = timestamp;
send_getplayerdata (&bman.players[0].net.addr, y); send_getplayerdata (&players[0].net.addr, y);
} }
if (y < MAX_PLAYERS && y != bman.players[bman.p_nr].net.net_status && y >= 0 if (y < MAX_PLAYERS && y != players[bman.p_nr].net.net_status && y >= 0
&& timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
/* we have got no player data */ /* we have got no player data */
y--; y--;
} }
if (y == MAX_PLAYERS - 1 && bman.players[bman.p_nr].net.net_status == y) { if (y == MAX_PLAYERS - 1 && players[bman.p_nr].net.net_status == y) {
/* we have got all playerdata */ /* we have got all playerdata */
y = -1; y = -1;
bman.players[bman.p_nr].net.net_istep = --net_istep; players[bman.p_nr].net.net_istep = --net_istep;
bman.players[bman.p_nr].net.net_status = -1; players[bman.p_nr].net.net_status = -1;
downtimestamp = timestamp; downtimestamp = timestamp;
send_playerstatus (&bman.players[0].net.addr, bman.p_nr, 0, 0); send_playerstatus (&players[0].net.addr, bman.p_nr, 0, 0);
} }
} }
if (net_istep == 0 && bman.players[bman.p_nr].net.net_status == -1 if (net_istep == 0 && players[bman.p_nr].net.net_status == -1
&& timestamp - downtimestamp > DOWNLOAD_TIMEOUT) { && timestamp - downtimestamp > DOWNLOAD_TIMEOUT) {
/* server did not send informations back */ /* server did not send informations back */
downtimestamp = timestamp; downtimestamp = timestamp;
send_playerstatus (&bman.players[0].net.addr, bman.p_nr, 0, 0); send_playerstatus (&players[0].net.addr, bman.p_nr, 0, 0);
} }
} }
@ -558,7 +558,7 @@ net_transmit_gamedata ()
/* player is only watching so just go after we have got everything /* player is only watching so just go after we have got everything
go to show the field */ go to show the field */
if (GT_MP_PTPS && bman.state == GS_update && net_istep == 0 if (GT_MP_PTPS && bman.state == GS_update && net_istep == 0
&& bman.players[bman.p_nr].gfx_nr == -1) { && players[bman.p_nr].gfx_nr == -1) {
done = 1; done = 1;
bman.state = GS_running; bman.state = GS_running;
} }
@ -573,13 +573,13 @@ net_game_send_player (int p_nr)
if (GT_MP_PTPM) { if (GT_MP_PTPM) {
for (p = 0; p < MAX_PLAYERS; p++) for (p = 0; p < MAX_PLAYERS; p++)
if (PS_IS_netplayer (bman.players[p].state) && p != bman.p_nr) if (PS_IS_netplayer (players[p].state) && p != bman.p_nr)
send_playerdata (&bman.players[p].net.addr, p_nr, &bman.players[p_nr]); send_playerdata (&players[p].net.addr, p_nr, &players[p_nr]);
} }
else if (p_nr == bman.p_nr) { else if (p_nr == bman.p_nr) {
for (p = 0; p < MAX_PLAYERS; p++) for (p = 0; p < MAX_PLAYERS; p++)
if (PS_IS_netplayer (bman.players[p].state) && p != bman.p_nr && NET_CANSEND(p)) if (PS_IS_netplayer (players[p].state) && p != bman.p_nr && NET_CANSEND(p))
send_playerdata (&bman.players[p].net.addr, p_nr, &bman.players[p_nr]); send_playerdata (&players[p].net.addr, p_nr, &players[p_nr]);
} }
}; };
@ -591,12 +591,12 @@ net_game_send_playermove (int p_nr, int mustsend)
_player *pl; _player *pl;
for (p = 0; p < MAX_PLAYERS; p++) for (p = 0; p < MAX_PLAYERS; p++)
if (PS_IS_netplayer (bman.players[p].state) && p != bman.p_nr) { if (PS_IS_netplayer (players[p].state) && p != bman.p_nr) {
pl = &bman.players[p_nr]; pl = &players[p_nr];
pl->net.pkgopt.send_to--; pl->net.pkgopt.send_to--;
if ((pl->net.pkgopt.send_to <= 0 || mustsend) && NET_CANSEND(p)) if ((pl->net.pkgopt.send_to <= 0 || mustsend) && NET_CANSEND(p))
send_playermove (&bman.players[p].net.addr, p_nr, pl); send_playermove (&players[p].net.addr, p_nr, pl);
/* network packet send control */ /* network packet send control */
if (pl->net.pkgopt.send_to <= 0 || pl->net.pkgopt.send_to > pl->net.pkgopt.send_set) if (pl->net.pkgopt.send_to <= 0 || pl->net.pkgopt.send_to > pl->net.pkgopt.send_set)
@ -610,7 +610,7 @@ net_game_send_bomb (int p, int b)
int pl; int pl;
/* check if we are slave and send something else as dropping a bomb */ /* check if we are slave and send something else as dropping a bomb */
if (GT_MP_PTPS && bman.players[p].bombs[b].state != BS_ticking && bman.players[p].bombs[b].state != BS_trigger) if (GT_MP_PTPS && players[p].bombs[b].state != BS_ticking && players[p].bombs[b].state != BS_trigger)
return; return;
d_printf ("Send BombData %d, %d\n", p, b); d_printf ("Send BombData %d, %d\n", p, b);
@ -619,8 +619,8 @@ net_game_send_bomb (int p, int b)
return; return;
for (pl = 0; pl < MAX_PLAYERS; pl++) for (pl = 0; pl < MAX_PLAYERS; pl++)
if (PS_IS_netplayer (bman.players[pl].state) && pl != bman.p_nr && NET_CANSEND(pl)) if (PS_IS_netplayer (players[pl].state) && pl != bman.p_nr && NET_CANSEND(pl))
send_bombdata (&bman.players[pl].net.addr, p, b, &bman.players[p].bombs[b]); send_bombdata (&players[pl].net.addr, p, b, &players[p].bombs[b]);
}; };
@ -635,8 +635,8 @@ net_game_send_field (int x, int y)
return; return;
for (pl = 0; pl < MAX_PLAYERS; pl++) for (pl = 0; pl < MAX_PLAYERS; pl++)
if (PS_IS_netplayer (bman.players[pl].state) && pl != bman.p_nr && NET_CANSEND(pl)) if (PS_IS_netplayer (players[pl].state) && pl != bman.p_nr && NET_CANSEND(pl))
send_field (&bman.players[pl].net.addr, x, y, &map.field[x][y]); send_field (&players[pl].net.addr, x, y, &map.field[x][y]);
}; };
@ -658,19 +658,19 @@ net_delplayer (int pl_nr)
bman.state = GS_startup; bman.state = GS_startup;
} }
else { else {
strncpy (host, bman.players[pl_nr].net.addr.host, LEN_SERVERNAME); strncpy (host, players[pl_nr].net.addr.host, LEN_SERVERNAME);
strncpy (port, bman.players[pl_nr].net.addr.port, LEN_PORT); strncpy (port, players[pl_nr].net.addr.port, LEN_PORT);
bman.players[pl_nr].state &= (0xFF - (PSF_used + PSF_net + PSF_alife)); /* delete players[pl_nr].state &= (0xFF - (PSF_used + PSF_net + PSF_alife)); /* delete
player flags */ player flags */
bman.players[pl_nr].net.net_istep = 0; // needed for disconnect during the update players[pl_nr].net.net_istep = 0; // needed for disconnect during the update
bman.players_nr_s--; bman.players_nr_s--;
bman.players[pl_nr].gfx_nr = -1; players[pl_nr].gfx_nr = -1;
if (GT_MP_PTPM && (GS_WAITRUNNING || bman.state == GS_update)) { if (GT_MP_PTPM && (GS_WAITRUNNING || bman.state == GS_update)) {
for (i = 1; i < MAX_PLAYERS; i++) for (i = 1; i < MAX_PLAYERS; i++)
if (PS_IS_netplayer (bman.players[i].state)) { if (PS_IS_netplayer (players[i].state)) {
send_quit (&bman.players[i].net.addr, host, port); send_quit (&players[i].net.addr, host, port);
j++; j++;
} }
if (bman.notifygamemaster) if (bman.notifygamemaster)
@ -694,10 +694,10 @@ net_game_fillsockaddr ()
int i; int i;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (bman.players[i].net.addr.host[0] != 0 && bman.players[i].net.addr.host[0] != 0) if (players[i].net.addr.host[0] != 0 && players[i].net.addr.host[0] != 0)
dns_filladdr (bman.players[i].net.addr.host, LEN_SERVERNAME, dns_filladdr (players[i].net.addr.host, LEN_SERVERNAME,
bman.players[i].net.addr.port, LEN_PORT, bman.net_ai_family, players[i].net.addr.port, LEN_PORT, bman.net_ai_family,
&bman.players[i].net.addr.sAddr); &players[i].net.addr.sAddr);
}; };
@ -707,8 +707,8 @@ net_send_servermode ()
int i; int i;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_netplayer (bman.players[i].state) && i != bman.p_nr && NET_CANSEND(i)) if (PS_IS_netplayer (players[i].state) && i != bman.p_nr && NET_CANSEND(i))
send_servermode (&bman.players[i].net.addr, i); send_servermode (&players[i].net.addr, i);
if (GT_MP_PTPM && bman.notifygamemaster) /* send notification the the gamemaster */ if (GT_MP_PTPM && bman.notifygamemaster) /* send notification the the gamemaster */
gamesrv_sendmode (bman.maxplayer, bman.players_nr_s); gamesrv_sendmode (bman.maxplayer, bman.players_nr_s);
@ -723,11 +723,11 @@ net_send_players ()
j; j;
for (j = 0; j < MAX_PLAYERS; j++) for (j = 0; j < MAX_PLAYERS; j++)
if (PS_IS_netplayer (bman.players[j].state) && j != bman.p_nr) if (PS_IS_netplayer (players[j].state) && j != bman.p_nr)
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
send_playerid (&bman.players[j].net.addr, bman.players[i].name, send_playerid (&players[j].net.addr, players[i].name,
bman.players[i].net.addr.host, bman.players[i].net.addr.port, i, players[i].net.addr.host, players[i].net.addr.port, i,
bman.players[i].gfx_nr, bman.players[i].net.flags); players[i].gfx_nr, players[i].net.flags);
}; };
@ -739,8 +739,8 @@ net_send_chat (char *text, signed char notigamesrv)
int i; int i;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_netplayer (bman.players[i].state) && i != bman.p_nr && NET_CANSEND(i)) if (PS_IS_netplayer (players[i].state) && i != bman.p_nr && NET_CANSEND(i))
send_chat (&bman.players[i].net.addr, text); send_chat (&players[i].net.addr, text);
if (GT_MP_PTPM && bman.notifygamemaster && notigamesrv == 1 && bman.broadcasted_chat) /* send notification the the gamemaster */ if (GT_MP_PTPM && bman.notifygamemaster && notigamesrv == 1 && bman.broadcasted_chat) /* send notification the the gamemaster */
gamesrv_sendchat (text); gamesrv_sendchat (text);
@ -755,8 +755,8 @@ net_game_send_ill (int p_nr)
d_printf ("net_game_send_ill (%d)\n", p_nr); d_printf ("net_game_send_ill (%d)\n", p_nr);
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_netplayer (bman.players[i].state) && i != bman.p_nr && NET_CANSEND(i)) if (PS_IS_netplayer (players[i].state) && i != bman.p_nr && NET_CANSEND(i))
send_ill (&bman.players[i].net.addr, p_nr, &bman.players[p_nr]); send_ill (&players[i].net.addr, p_nr, &players[p_nr]);
}; };
@ -773,13 +773,13 @@ net_new_game ()
bman.players_nr = 0; bman.players_nr = 0;
bman.players_nr_s = 0; bman.players_nr_s = 0;
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
if (PS_IS_used (bman.players[p].state)) if (PS_IS_used (players[p].state))
bman.players_nr_s++; bman.players_nr_s++;
else else
bman.players[p].state = 0; players[p].state = 0;
} }
bman.players[bman.p_nr].state &= (0xFF - PSF_net); // we are the local player players[bman.p_nr].state &= (0xFF - PSF_net); // we are the local player
bman.last_ex_nr = 1; bman.last_ex_nr = 1;
}; };
@ -799,8 +799,8 @@ net_game_send_special (int pl_nr, int ex_nr)
return; return;
for (pl = 0; pl < MAX_PLAYERS; pl++) for (pl = 0; pl < MAX_PLAYERS; pl++)
if (PS_IS_netplayer (bman.players[pl].state) && pl != pl_nr && NET_CANSEND(pl)) if (PS_IS_netplayer (players[pl].state) && pl != pl_nr && NET_CANSEND(pl))
send_special (&bman.players[pl].net.addr, pl_nr, bman.players[pl_nr].special.type, ex_nr); send_special (&players[pl].net.addr, pl_nr, players[pl_nr].special.type, ex_nr);
}; };
@ -816,6 +816,6 @@ net_send_mapinfo ()
d_printf ("Send Mapinfo\n"); d_printf ("Send Mapinfo\n");
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_netplayer (bman.players[i].state) && i != bman.p_nr && NET_CANSEND(i)) if (PS_IS_netplayer (players[i].state) && i != bman.p_nr && NET_CANSEND(i))
send_mapinfo (&bman.players[i].net.addr); send_mapinfo (&players[i].net.addr);
}; };

@ -20,6 +20,9 @@ struct _inpkg_index inpkg_index[PKG_IN_INDEX_NUM];
int inpkg_index_pos = 0; int inpkg_index_pos = 0;
/***
*** help function to get the playernumber from the address.
***/
int int
get_player_nr (char *host, char *port) get_player_nr (char *host, char *port)
{ {
@ -27,15 +30,18 @@ get_player_nr (char *host, char *port)
res; res;
for (i = 0, res = -1; (i < MAX_PLAYERS && res == -1); i++) { for (i = 0, res = -1; (i < MAX_PLAYERS && res == -1); i++) {
if (bman.players[i].net.addr.host[0] != 0) if (players[i].net.addr.host[0] != 0)
if ((strcmp (bman.players[i].net.addr.host, host) == 0) && if ((strcmp (players[i].net.addr.host, host) == 0) &&
(strcmp (bman.players[i].net.addr.port, port) == 0)) (strcmp (players[i].net.addr.port, port) == 0))
res = i; res = i;
} }
return res; return res;
} }
/***
*** Packettype: error
***/
void void
send_error (_net_addr * addr, char *text) send_error (_net_addr * addr, char *text)
{ {
@ -64,9 +70,10 @@ do_error (struct pkg_error *data, _net_addr * addr)
}; };
/* /***
update the playerinformations in the game *** Packettype: pingack/pingreq
*/ *** Update Playerinformation, add players into the current game
***/
void void
do_playerid (struct pkg_playerid *p_id, _net_addr * addr) do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
{ {
@ -93,7 +100,7 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
if (((GT_MP_PTPM && (bman.state == GS_wait && addr->pl_nr != -1)) || // PTPM change setting if (((GT_MP_PTPM && (bman.state == GS_wait && addr->pl_nr != -1)) || // PTPM change setting
(GT_MP_PTPS && addr->pl_nr == 0)) && p_id->pl_nr >= 0 && p_id->pl_nr < MAX_PLAYERS) { // PTPS and information send by PTPM (GT_MP_PTPS && addr->pl_nr == 0)) && p_id->pl_nr >= 0 && p_id->pl_nr < MAX_PLAYERS) { // PTPS and information send by PTPM
pl = &bman.players[p_id->pl_nr]; pl = &players[p_id->pl_nr];
pl->state = p_id->state; pl->state = p_id->state;
if (p_id->pl_nr != bman.p_nr && PS_IS_used (pl->state)) if (p_id->pl_nr != bman.p_nr && PS_IS_used (pl->state))
@ -126,13 +133,13 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
/* find free player slot */ /* find free player slot */
if (addr->pl_nr == -1) if (addr->pl_nr == -1)
for (i = 0; (i < MAX_PLAYERS && PS_IS_used (bman.players[i].state)); i++); for (i = 0; (i < MAX_PLAYERS && PS_IS_used (players[i].state)); i++);
else else
i = addr->pl_nr; i = addr->pl_nr;
if ((i < MAX_PLAYERS) && (i < bman.maxplayer)) { if ((i < MAX_PLAYERS) && (i < bman.maxplayer)) {
/* free in_pl slot ... fill in data */ /* free in_pl slot ... fill in data */
pl = &bman.players[i]; pl = &players[i];
pl->state = PSF_used + PSF_net; pl->state = PSF_used + PSF_net;
if (strncmp (pl->name, p_id->name, LEN_PLAYERNAME) == 0) if (strncmp (pl->name, p_id->name, LEN_PLAYERNAME) == 0)
@ -164,15 +171,15 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
send_servermode (addr, i); send_servermode (addr, i);
send_mapinfo (addr); send_mapinfo (addr);
for (j = 0; j < MAX_PLAYERS; j++) for (j = 0; j < MAX_PLAYERS; j++)
if (bman.players[j].net.addr.host[0] != 0 || bman.players[j].name[0] != 0) if (players[j].net.addr.host[0] != 0 || players[j].name[0] != 0)
send_playerid (addr, bman.players[j].name, send_playerid (addr, players[j].name,
bman.players[j].net.addr.host, players[j].net.addr.host,
bman.players[j].net.addr.port, j, players[j].net.addr.port, j,
bman.players[j].gfx_nr, bman.players[i].net.flags); players[j].gfx_nr, players[i].net.flags);
addr->pl_nr = i; addr->pl_nr = i;
for (j = 0, i = 0; i < bman.maxplayer; i++) for (j = 0, i = 0; i < bman.maxplayer; i++)
if (PS_IS_used (bman.players[i].state)) if (PS_IS_used (players[i].state))
j++; j++;
if (bman.notifygamemaster) if (bman.notifygamemaster)
gamesrv_sendmode (bman.maxplayer, j); gamesrv_sendmode (bman.maxplayer, j);
@ -235,9 +242,9 @@ send_playerid (_net_addr * addr, char *name, char *pladdr, char *plport,
p_id.pl_nr = pl_nr; p_id.pl_nr = pl_nr;
p_id.gfx_nr = gfx_nr; p_id.gfx_nr = gfx_nr;
if (pl_nr != -1) { if (pl_nr != -1) {
p_id.points = HTON16 (bman.players[pl_nr].points); p_id.points = HTON16 (players[pl_nr].points);
p_id.wins = HTON16 (bman.players[pl_nr].wins); p_id.wins = HTON16 (players[pl_nr].wins);
p_id.state = bman.players[pl_nr].state; p_id.state = players[pl_nr].state;
} }
else { else {
p_id.points = 0; p_id.points = 0;
@ -249,6 +256,9 @@ send_playerid (_net_addr * addr, char *name, char *pladdr, char *plport,
}; };
/***
*** Packettype: servermode
***/
void void
do_servermode (struct pkg_servermode *s_mod, _net_addr * addr) do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
{ {
@ -259,19 +269,12 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
if (s_mod->pl_nr >= 0 && s_mod->pl_nr < MAX_PLAYERS) { if (s_mod->pl_nr >= 0 && s_mod->pl_nr < MAX_PLAYERS) {
bman.p_nr = s_mod->pl_nr; bman.p_nr = s_mod->pl_nr;
bman.players[bman.p_nr].state &= (0xFF - PSF_net); players[bman.p_nr].state &= (0xFF - PSF_net);
strncpy (bman.players[s_mod->pl_nr].name, bman.playername, LEN_PLAYERNAME); strncpy (players[s_mod->pl_nr].name, bman.playername, LEN_PLAYERNAME);
} }
if (s_mod->type == GT_multi)
bman.gametype = GT_multi;
else
bman.gametype = GT_single;
bman.state = s_mod->state; bman.state = s_mod->state;
map.state = s_mod->mapstate; map.state = s_mod->mapstate;
if (s_mod->multitype == MT_ptpm)
bman.multitype = MT_ptps;
bman.players_nr_s = s_mod->players; bman.players_nr_s = s_mod->players;
bman.lastwinner = s_mod->last_winner; bman.lastwinner = s_mod->last_winner;
@ -314,6 +317,9 @@ send_servermode (_net_addr * addr, int pl_nr)
}; };
/***
*** Packettype: field
***/
void void
send_field (_net_addr * addr, int x, int y, _field * field) send_field (_net_addr * addr, int x, int y, _field * field)
{ {
@ -330,11 +336,14 @@ send_field (_net_addr * addr, int x, int y, _field * field)
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; return;
memcpy (&f_dat.field, &map.field[x][y], sizeof (_field));
f_dat.field.frame = HTON16 (f_dat.field.frame); memcpy (&f_dat.ex, &map.field[x][y].ex, 4*sizeof (_ex_field));
f_dat.field.frameto = HTON32 (f_dat.field.frameto);
f_dat.field.ex_nr = HTON32 (f_dat.field.ex_nr); f_dat.type = map.field[x][y].type;
f_dat.mixframe = map.field[x][y].mixframe;
f_dat.special = map.field[x][y].special;
f_dat.frame = HTON16 (FTOI16 (map.field[x][y].frame));
f_dat.ex_nr = HTON32 (map.field[x][y].ex_nr);
send_pkg ((struct pkg *) &f_dat, addr); send_pkg ((struct pkg *) &f_dat, addr);
}; };
@ -348,23 +357,28 @@ do_field (struct pkg_field *f_dat, _net_addr * addr)
if (f_dat->x < map.size.x && f_dat->y < map.size.y) { if (f_dat->x < map.size.x && f_dat->y < map.size.y) {
/* convert the fielddata */ /* convert the fielddata */
memcpy (&map.field[f_dat->x][f_dat->y], &f_dat->field, sizeof (_field)); map.field[f_dat->x][f_dat->y].type = f_dat->type;
map.field[f_dat->x][f_dat->y].frame = NTOH16 (map.field[f_dat->x][f_dat->y].frame); map.field[f_dat->x][f_dat->y].mixframe = f_dat->mixframe;
map.field[f_dat->x][f_dat->y].frameto = NTOH32 (map.field[f_dat->x][f_dat->y].frameto); map.field[f_dat->x][f_dat->y].special = f_dat->special;
map.field[f_dat->x][f_dat->y].ex_nr = NTOH32 (map.field[f_dat->x][f_dat->y].ex_nr); memcpy (&map.field[f_dat->x][f_dat->y].ex, &f_dat->ex, 4*sizeof (_ex_field));
map.field[f_dat->x][f_dat->y].frame = I16TOF (NTOH16 (f_dat->frame));
map.field[f_dat->x][f_dat->y].ex_nr = NTOH32 (f_dat->ex_nr);
} }
if (bman.state == GS_running) if (bman.state == GS_running)
stonelist_add (f_dat->x, f_dat->y); stonelist_add (f_dat->x, f_dat->y);
if (NTOH32 (f_dat->field.ex_nr) > bman.last_ex_nr) if (NTOH32 (f_dat->ex_nr) > bman.last_ex_nr)
bman.last_ex_nr = NTOH32 (f_dat->field.ex_nr); bman.last_ex_nr = NTOH32 (f_dat->ex_nr);
d_printf ("do_field (%d,%d) ex_nr = %d, special = %d, type = %d\n", d_printf ("do_field (%d,%d) ex_nr = %d, special = %d, type = %d\n",
f_dat->x, f_dat->y, NTOH32 (f_dat->field.ex_nr), f_dat->x, f_dat->y, NTOH32 (f_dat->ex_nr),
f_dat->field.special, f_dat->field.type); f_dat->special, f_dat->type);
}; };
/***
*** Packettype: pingack/pingreq
***/
void void
do_ping (struct pkg_ping *p_dat, _net_addr * addr) do_ping (struct pkg_ping *p_dat, _net_addr * addr)
{ {
@ -373,18 +387,17 @@ do_ping (struct pkg_ping *p_dat, _net_addr * addr)
if (p_dat->h.typ == PKG_pingack) if (p_dat->h.typ == PKG_pingack)
/* ping was an answer */ /* ping was an answer */
bman.players[addr->pl_nr].net.pingack = NTOH32 (p_dat->data); players[addr->pl_nr].net.pingack = NTOH32 (p_dat->data);
else else
/* send the answer */ /* send the answer */
send_ping (addr, NTOH32 (p_dat->data), PKG_pingack); send_ping (addr, NTOH32 (p_dat->data), PKG_pingack);
d_printf ("do_ping pl_nr[%d] (%s:%s) req=%d, ack=%d\n", addr->pl_nr, d_printf ("do_ping pl_nr[%d] (%s:%s) req=%d, ack=%d\n", addr->pl_nr,
addr->host, addr->port, bman.players[addr->pl_nr].net.pingreq, addr->host, addr->port, players[addr->pl_nr].net.pingreq,
bman.players[addr->pl_nr].net.pingack); players[addr->pl_nr].net.pingack);
}; };
void void
send_ping (_net_addr * addr, int data, unsigned char typ) send_ping (_net_addr * addr, int data, unsigned char typ)
{ {
@ -409,14 +422,17 @@ send_ping (_net_addr * addr, int data, unsigned char typ)
} }
d_printf ("send_ping Player[%d] (%s:%s) req=%d, ack=%d\n", addr->pl_nr, d_printf ("send_ping Player[%d] (%s:%s) req=%d, ack=%d\n", addr->pl_nr,
addr->host, addr->port, bman.players[addr->pl_nr].net.pingreq, addr->host, addr->port, players[addr->pl_nr].net.pingreq,
bman.players[addr->pl_nr].net.pingack); players[addr->pl_nr].net.pingack);
bman.players[addr->pl_nr].net.timestamp = timestamp; /* we need to set it here, so we can check players[addr->pl_nr].net.timestamp = timestamp; /* we need to set it here, so we can check
for the timeout again */ for the timeout again */
}; };
/***
*** Packettype: playerdata
***/
void void
send_playerdata (_net_addr * addr, int p_nr, _player * pl) send_playerdata (_net_addr * addr, int p_nr, _player * pl)
{ {
@ -440,7 +456,7 @@ send_playerdata (_net_addr * addr, int p_nr, _player * pl)
p_dat.wins = HTON16 (pl->wins); p_dat.wins = HTON16 (pl->wins);
p_dat.points = HTON16 (pl->points); p_dat.points = HTON16 (pl->points);
p_dat.dead_by = pl->dead_by; p_dat.dead_by = pl->dead_by;
p_dat.frame = pl->frame; p_dat.frame = HTON16 (FTOI16 (pl->frame));
p_dat.p_nr = p_nr; p_dat.p_nr = p_nr;
send_pkg ((struct pkg *) &p_dat, addr); send_pkg ((struct pkg *) &p_dat, addr);
@ -461,7 +477,7 @@ do_playerdata (struct pkg_playerdata *p_dat, _net_addr * addr)
d_printf ("do_playerdata (From: %d) p_nr: %d\n", addr->pl_nr, p_dat->p_nr); d_printf ("do_playerdata (From: %d) p_nr: %d\n", addr->pl_nr, p_dat->p_nr);
bman.updatestatusbar = 1; // force an update bman.updatestatusbar = 1; // force an update
pl = &bman.players[p_dat->p_nr]; pl = &players[p_dat->p_nr];
player_set_gfx (pl, p_dat->gfx_nr); player_set_gfx (pl, p_dat->gfx_nr);
if (bman.state == GS_running && bman.p_nr != p_dat->p_nr) { if (bman.state == GS_running && bman.p_nr != p_dat->p_nr) {
@ -476,7 +492,7 @@ do_playerdata (struct pkg_playerdata *p_dat, _net_addr * addr)
pl->d = p_dat->d; pl->d = p_dat->d;
pl->bombs_n = p_dat->bombs_n; pl->bombs_n = p_dat->bombs_n;
pl->range = p_dat->range; pl->range = p_dat->range;
pl->frame = p_dat->frame; pl->frame = I16TOF (NTOH16 (p_dat->frame));
pl->state = p_dat->state; pl->state = p_dat->state;
} }
@ -487,7 +503,7 @@ do_playerdata (struct pkg_playerdata *p_dat, _net_addr * addr)
if (PS_IS_alife (pl->state) && PS_IS_dead (p_dat->state)) { if (PS_IS_alife (pl->state) && PS_IS_dead (p_dat->state)) {
/* player just died */ /* player just died */
if (p_dat->p_nr != p_dat->dead_by) { if (p_dat->p_nr != p_dat->dead_by) {
bman.players[p_dat->dead_by].points++; players[p_dat->dead_by].points++;
net_game_send_player (p_dat->dead_by); net_game_send_player (p_dat->dead_by);
} }
} }
@ -506,32 +522,14 @@ do_playerdata (struct pkg_playerdata *p_dat, _net_addr * addr)
if (bman.state == GS_update && PS_IS_used (p_dat->state)) if (bman.state == GS_update && PS_IS_used (p_dat->state))
bman.players_nr_s++; bman.players_nr_s++;
if (bman.state == GS_update && bman.players[bman.p_nr].net.net_istep == 1) if (bman.state == GS_update && players[bman.p_nr].net.net_istep == 1)
bman.players[bman.p_nr].net.net_status = p_dat->p_nr; players[bman.p_nr].net.net_status = p_dat->p_nr;
} }
void /***
send_playermove (_net_addr * addr, int p_nr, _player * pl) *** Packettype: ill
{ ***/
struct pkg_playermove p_dat;
p_dat.h.typ = PKG_playermove;
p_dat.h.len = HTON16 (sizeof (struct pkg_playermove));
p_dat.h.flags = 0;
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;
p_dat.speed = pl->speed;
p_dat.tunnelto = HTON16 (pl->tunnelto);
send_pkg ((struct pkg *) &p_dat, addr);
};
void void
do_ill (struct pkg_ill *ill, _net_addr * addr) do_ill (struct pkg_ill *ill, _net_addr * addr)
{ {
@ -545,11 +543,9 @@ do_ill (struct pkg_ill *ill, _net_addr * addr)
return; return;
for (i = 0; i < PI_max; i++) for (i = 0; i < PI_max; i++)
bman.players[ill->pl_nr].ill[i].to = NTOH16 (ill->to[i]); players[ill->pl_nr].ill[i].to = I16TOF (NTOH16 (ill->to[i]));
}; };
void void
send_ill (_net_addr * addr, int p_nr, _player * pl) send_ill (_net_addr * addr, int p_nr, _player * pl)
{ {
@ -562,11 +558,33 @@ send_ill (_net_addr * addr, int p_nr, _player * pl)
ill.pl_nr = p_nr; ill.pl_nr = p_nr;
for (i = 0; i < PI_max; i++) for (i = 0; i < PI_max; i++)
ill.to[i] = HTON16 (pl->ill[i].to); ill.to[i] = HTON16 (FTOI16 (pl->ill[i].to));
send_pkg ((struct pkg *) &ill, addr); send_pkg ((struct pkg *) &ill, addr);
}; };
/***
*** Packettype: playermove
***/
void
send_playermove (_net_addr * addr, int p_nr, _player * pl)
{
struct pkg_playermove p_dat;
p_dat.h.typ = PKG_playermove;
p_dat.h.len = HTON16 (sizeof (struct pkg_playermove));
p_dat.h.flags = 0;
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;
p_dat.speed = pl->speed;
p_dat.tunnelto = HTON16 (pl->tunnelto);
send_pkg ((struct pkg *) &p_dat, addr);
};
void void
do_playermove (struct pkg_playermove *p_dat, _net_addr * addr) do_playermove (struct pkg_playermove *p_dat, _net_addr * addr)
@ -580,7 +598,7 @@ do_playermove (struct pkg_playermove *p_dat, _net_addr * addr)
return; return;
/* check if the right player is sending the information */ /* check if the right player is sending the information */
pl = &bman.players[p_dat->p_nr]; pl = &players[p_dat->p_nr];
if (addr->pl_nr != 0 && addr->pl_nr != p_dat->p_nr) if (addr->pl_nr != 0 && addr->pl_nr != p_dat->p_nr)
return; return;
@ -589,10 +607,13 @@ do_playermove (struct pkg_playermove *p_dat, _net_addr * addr)
pl->speed = p_dat->speed; pl->speed = p_dat->speed;
pl->pos.x = I16TOF (HTON16 (p_dat->pos.x)); pl->pos.x = I16TOF (HTON16 (p_dat->pos.x));
pl->pos.y = I16TOF (HTON16 (p_dat->pos.y)); pl->pos.y = I16TOF (HTON16 (p_dat->pos.y));
pl->tunnelto = HTON16 (p_dat->tunnelto); pl->tunnelto = I16TOF (HTON16 (p_dat->tunnelto));
} }
/***
*** Packettype: bombdata
***/
void void
do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
{ {
@ -613,7 +634,7 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
I16TOF(NTOH16 (b_dat->x)), I16TOF(NTOH16 (b_dat->y)), 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 = &players[b_dat->p_nr].bombs[b_dat->b_nr];
if (bomb->state == BS_exploding) { if (bomb->state == BS_exploding) {
d_printf ("do_bombdata ---> bomb is already exploding\n"); d_printf ("do_bombdata ---> bomb is already exploding\n");
return; return;
@ -636,7 +657,7 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
bomb->pos.y = I16TOF (NTOH16 (b_dat->y)); 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 = I32TOF (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 */
@ -657,7 +678,6 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr)
bman.last_ex_nr = bomb->ex_nr; bman.last_ex_nr = bomb->ex_nr;
}; };
void void
send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb) send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb)
{ {
@ -667,7 +687,7 @@ send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb)
b_dat.h.len = HTON16 (sizeof (struct pkg_bombdata)); b_dat.h.len = HTON16 (sizeof (struct pkg_bombdata));
b_dat.x = HTON16 (FTOI16 (bomb->pos.x)); b_dat.x = HTON16 (FTOI16 (bomb->pos.x));
b_dat.y = HTON16 (FTOI16 (bomb->pos.y)); b_dat.y = HTON16 (FTOI16 (bomb->pos.y));
b_dat.to = HTON32 (bomb->to); b_dat.to = HTON32 (FTOI32 (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);
b_dat.state = (bomb->mode << 4) | (bomb->state); b_dat.state = (bomb->mode << 4) | (bomb->state);
@ -681,7 +701,11 @@ send_bombdata (_net_addr * addr, int p, int b, _bomb * bomb)
send_pkg ((struct pkg *) &b_dat, addr); send_pkg ((struct pkg *) &b_dat, addr);
}; };
/* recive a request for some tunneldata or receive tunneldata */
/***
*** Packettype: bombdata
*** recive a request for some tunneldata or receive tunneldata
***/
void void
do_tunneldata (struct pkg_tunneldata *tun_pkg, _net_addr * addr) do_tunneldata (struct pkg_tunneldata *tun_pkg, _net_addr * addr)
{ {
@ -693,17 +717,16 @@ do_tunneldata (struct pkg_tunneldata *tun_pkg, _net_addr * addr)
&& NTOH16 (tun_pkg->target.x) == -1) { && NTOH16 (tun_pkg->target.x) == -1) {
send_tunneldata (addr, tun_pkg->tunnel_nr, send_tunneldata (addr, tun_pkg->tunnel_nr,
map.tunnel[tun_pkg->tunnel_nr].x, map.tunnel[tun_pkg->tunnel_nr].y); map.tunnel[tun_pkg->tunnel_nr].x, map.tunnel[tun_pkg->tunnel_nr].y);
bman.players[addr->pl_nr].net.net_status = tun_pkg->tunnel_nr; players[addr->pl_nr].net.net_status = tun_pkg->tunnel_nr;
bman.players[addr->pl_nr].net.net_istep = 3; players[addr->pl_nr].net.net_istep = 3;
} }
else if (addr->pl_nr == 0 && tun_pkg->tunnel_nr < GAME_MAX_TUNNELS) { else if (addr->pl_nr == 0 && tun_pkg->tunnel_nr < GAME_MAX_TUNNELS) {
map.tunnel[tun_pkg->tunnel_nr].x = NTOH16 (tun_pkg->target.x); map.tunnel[tun_pkg->tunnel_nr].x = NTOH16 (tun_pkg->target.x);
map.tunnel[tun_pkg->tunnel_nr].y = NTOH16 (tun_pkg->target.y); map.tunnel[tun_pkg->tunnel_nr].y = NTOH16 (tun_pkg->target.y);
bman.players[bman.p_nr].net.net_status = tun_pkg->tunnel_nr; players[bman.p_nr].net.net_status = tun_pkg->tunnel_nr;
} }
}; };
/* send a tunneldata request (x && y == -1) or send tunneldata */ /* send a tunneldata request (x && y == -1) or send tunneldata */
void void
send_tunneldata (_net_addr * addr, int tunnelnr, int x, int y) send_tunneldata (_net_addr * addr, int tunnelnr, int x, int y)
@ -726,6 +749,9 @@ send_tunneldata (_net_addr * addr, int tunnelnr, int x, int y)
}; };
/***
*** Packettype: quit
***/
void void
send_quit (_net_addr * addr, char *plhost, char * plport) send_quit (_net_addr * addr, char *plhost, char * plport)
{ {
@ -749,8 +775,6 @@ send_quit (_net_addr * addr, char *plhost, char * plport)
send_pkg ((struct pkg *) &q_dat, addr); send_pkg ((struct pkg *) &q_dat, addr);
}; };
void void
do_quit (struct pkg_quit *q_dat, _net_addr * addr) do_quit (struct pkg_quit *q_dat, _net_addr * addr)
{ {
@ -773,6 +797,10 @@ do_quit (struct pkg_quit *q_dat, _net_addr * addr)
} }
}; };
/***
*** Packettype: getfield
***/
void void
send_getfield (_net_addr * addr, int line) send_getfield (_net_addr * addr, int line)
{ {
@ -797,14 +825,17 @@ do_getfield (struct pkg_getfield *gf_dat, _net_addr * addr)
if (addr->pl_nr != -1 && bman.state == GS_update && GT_MP_PTPM) { if (addr->pl_nr != -1 && bman.state == GS_update && GT_MP_PTPM) {
if (addr->pl_nr > 0 && addr->pl_nr < MAX_PLAYERS) { if (addr->pl_nr > 0 && addr->pl_nr < MAX_PLAYERS) {
bman.players[addr->pl_nr].net.net_status = gf_dat->line; players[addr->pl_nr].net.net_status = gf_dat->line;
bman.players[addr->pl_nr].net.net_istep = 2; players[addr->pl_nr].net.net_istep = 2;
} }
} }
send_fieldline (addr, gf_dat->line); send_fieldline (addr, gf_dat->line);
}; };
/***
*** Packettype: fieldline
***/
void void
send_fieldline (_net_addr * addr, int line) send_fieldline (_net_addr * addr, int line)
{ {
@ -823,8 +854,7 @@ send_fieldline (_net_addr * addr, int line)
for (i = 0; i < MAX_FIELDSIZE_X; i++) { for (i = 0; i < MAX_FIELDSIZE_X; i++) {
f_dat.type[i] = map.field[i][line].type; f_dat.type[i] = map.field[i][line].type;
f_dat.special[i] = map.field[i][line].special; f_dat.special[i] = map.field[i][line].special;
map.field[i][line].frame = 0; map.field[i][line].frame = 0.0f;
map.field[i][line].frameto = 0;
map.field[i][line].ex_nr = 0; map.field[i][line].ex_nr = 0;
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
map.field[i][line].ex[j].frame = map.field[i][line].ex[j].count = 0; map.field[i][line].ex[j].frame = map.field[i][line].ex[j].count = 0;
@ -853,20 +883,22 @@ do_fieldline (struct pkg_fieldline *f_dat, _net_addr * addr)
return; return;
} }
if (bman.state == GS_update && bman.players[bman.p_nr].net.net_istep == 2) if (bman.state == GS_update && players[bman.p_nr].net.net_istep == 2)
bman.players[bman.p_nr].net.net_status = f_dat->line; players[bman.p_nr].net.net_status = f_dat->line;
for (i = 0; i < MAX_FIELDSIZE_X; i++) { for (i = 0; i < MAX_FIELDSIZE_X; i++) {
map.field[i][f_dat->line].type = f_dat->type[i]; map.field[i][f_dat->line].type = f_dat->type[i];
map.field[i][f_dat->line].special = f_dat->special[i]; map.field[i][f_dat->line].special = f_dat->special[i];
map.field[i][f_dat->line].frameto = 0; map.field[i][f_dat->line].frame = 0.0f;
map.field[i][f_dat->line].frame = 0;
for (d = 0; d < 4; d++) for (d = 0; d < 4; d++)
map.field[i][f_dat->line].ex[d].frame = map.field[i][f_dat->line].ex[d].count = 0; map.field[i][f_dat->line].ex[d].frame = map.field[i][f_dat->line].ex[d].count = 0;
} }
}; };
/***
*** Packettype: getplayerdata
***/
void void
send_getplayerdata (_net_addr * addr, int pl) send_getplayerdata (_net_addr * addr, int pl)
{ {
@ -891,14 +923,17 @@ do_getplayerdata (struct pkg_getplayerdata *gp_dat, _net_addr * addr)
if (addr->pl_nr != -1 && bman.state == GS_update && GT_MP_PTPM) { if (addr->pl_nr != -1 && bman.state == GS_update && GT_MP_PTPM) {
if (addr->pl_nr > 0 && addr->pl_nr < MAX_PLAYERS) { if (addr->pl_nr > 0 && addr->pl_nr < MAX_PLAYERS) {
bman.players[addr->pl_nr].net.net_status = gp_dat->pl_nr; players[addr->pl_nr].net.net_status = gp_dat->pl_nr;
bman.players[addr->pl_nr].net.net_istep = 1; players[addr->pl_nr].net.net_istep = 1;
} }
} }
send_playerdata (addr, gp_dat->pl_nr, &bman.players[gp_dat->pl_nr]); send_playerdata (addr, gp_dat->pl_nr, &players[gp_dat->pl_nr]);
}; };
/***
*** Packettype: playerstatus
***/
void void
do_playerstatus (struct pkg_playerstatus *stat, _net_addr * addr) do_playerstatus (struct pkg_playerstatus *stat, _net_addr * addr)
{ {
@ -917,16 +952,15 @@ do_playerstatus (struct pkg_playerstatus *stat, _net_addr * addr)
return; return;
} }
bman.players[addr->pl_nr].net.net_status = stat->status; players[addr->pl_nr].net.net_status = stat->status;
bman.players[addr->pl_nr].net.net_istep = stat->net_istep; players[addr->pl_nr].net.net_istep = stat->net_istep;
if (GT_MP_PTPM) if (GT_MP_PTPM)
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (bman.players[i].net.addr.host[0] != 0) if (players[i].net.addr.host[0] != 0)
send_playerstatus (&bman.players[i].net.addr, stat->pl_nr, send_playerstatus (&players[i].net.addr, stat->pl_nr,
stat->net_istep, stat->status); stat->net_istep, stat->status);
}; };
void void
send_playerstatus (_net_addr * addr, int pl_nr, int net_istep, int status) send_playerstatus (_net_addr * addr, int pl_nr, int net_istep, int status)
{ {
@ -946,6 +980,9 @@ send_playerstatus (_net_addr * addr, int pl_nr, int net_istep, int status)
}; };
/***
*** Packettype: chat
***/
void void
do_chat (struct pkg_chat *chat_pkg, _net_addr * addr) do_chat (struct pkg_chat *chat_pkg, _net_addr * addr)
{ {
@ -974,6 +1011,9 @@ send_chat (_net_addr * addr, char *text)
}; };
/***
*** Packettype: pkgack
***/
void void
send_pkgack (_net_addr * addr, unsigned char typ, short int id) send_pkgack (_net_addr * addr, unsigned char typ, short int id)
{ {
@ -999,8 +1039,11 @@ do_pkgack (struct pkg_pkgack *p_ack, _net_addr * addr)
rscache_del (); rscache_del ();
}; };
/* Player Special
* moves/bombs... whatever will be send as we use it */ /***
*** Packettype: special
*** moves/bombs... whatever will be send as we use it
***/
void void
do_special (struct pkg_special *sp_pkg, _net_addr * addr) do_special (struct pkg_special *sp_pkg, _net_addr * addr)
{ {
@ -1015,7 +1058,7 @@ do_special (struct pkg_special *sp_pkg, _net_addr * addr)
if (addr->pl_nr != 0 && addr->pl_nr != sp_pkg->pl_nr) if (addr->pl_nr != 0 && addr->pl_nr != sp_pkg->pl_nr)
return; return;
bman.players[sp_pkg->pl_nr].special.type = sp_pkg->typ; players[sp_pkg->pl_nr].special.type = sp_pkg->typ;
bman.last_ex_nr = NTOH32 (sp_pkg->ex_nr); bman.last_ex_nr = NTOH32 (sp_pkg->ex_nr);
special_use (sp_pkg->pl_nr); special_use (sp_pkg->pl_nr);
}; };
@ -1036,6 +1079,9 @@ send_special (_net_addr * addr, int p_nr, int typ, int ex_nr)
}; };
/***
*** Packettype: bcmservchat
***/
void void
do_bcmservchat (struct pkg_bcmservchat *packet, _net_addr * addr) do_bcmservchat (struct pkg_bcmservchat *packet, _net_addr * addr)
{ {
@ -1050,6 +1096,9 @@ do_bcmservchat (struct pkg_bcmservchat *packet, _net_addr * addr)
}; };
/***
*** Packettype: mapinfo
***/
void void
send_mapinfo (_net_addr * addr) send_mapinfo (_net_addr * addr)
{ {
@ -1111,6 +1160,13 @@ do_mapinfo (struct pkg_mapinfo *map_pkg, _net_addr * addr)
}; };
/***
*** general packet handling, like check for double recived packets
*** network type. Autoreply on PKGF_ackreq and such things.
***/
/* check incoming packet, if we have got the same already if so return != -1
if we haven't got it yet, Add to the incache and return -1 */
int int
inpkg_check (unsigned char typ, short int id, _net_addr * addr) inpkg_check (unsigned char typ, short int id, _net_addr * addr)
{ {
@ -1123,7 +1179,7 @@ inpkg_check (unsigned char typ, short int id, _net_addr * addr)
inpkg_index[i].typ == typ && inpkg_index[i].id == id) inpkg_index[i].typ == typ && inpkg_index[i].id == id)
pos = i; pos = i;
if (pos == -1) { if (pos == -1) {
/* packet unknown ... add to index */ /* add to index */
if (++inpkg_index_pos >= PKG_IN_INDEX_NUM) if (++inpkg_index_pos >= PKG_IN_INDEX_NUM)
inpkg_index_pos = 0; inpkg_index_pos = 0;
@ -1135,7 +1191,7 @@ inpkg_check (unsigned char typ, short int id, _net_addr * addr)
}; };
/* sends the packet and if PKGF_ackreq is set add packet to the resendcache */
void void
send_pkg (struct pkg *packet, _net_addr * addr) send_pkg (struct pkg *packet, _net_addr * addr)
{ {
@ -1166,14 +1222,18 @@ fwd_pkg (struct pkg *packet, _net_addr * addr)
|| packet->h.typ == PKG_bombdata || packet->h.typ == PKG_chat || packet->h.typ == PKG_bombdata || packet->h.typ == PKG_chat
|| packet->h.typ == PKG_special) || packet->h.typ == PKG_special)
for (pl = 1; pl < MAX_PLAYERS; pl++) for (pl = 1; pl < MAX_PLAYERS; pl++)
if (PS_IS_netplayer (bman.players[pl].state) if (PS_IS_netplayer (players[pl].state)
&& ((bman.players[pl].net.flags & NETF_firewall) == NETF_firewall && ((players[pl].net.flags & NETF_firewall) == NETF_firewall
|| (bman.players[addr->pl_nr].net.flags & NETF_firewall) == || (players[addr->pl_nr].net.flags & NETF_firewall) ==
NETF_firewall) && pl != addr->pl_nr) NETF_firewall) && pl != addr->pl_nr)
send_pkg (packet, &bman.players[pl].net.addr); send_pkg (packet, &players[pl].net.addr);
}; };
/* entry point for all incoming network data. determinate packet type and
forward it to all needed functions, like inpkg_check()--> send answer if needed,
if we are the server then forward the packet if needed
and go into the do_PACKETTYP function */
int int
do_pkg (struct pkg *packet, _net_addr * addr) do_pkg (struct pkg *packet, _net_addr * addr)
{ {
@ -1185,8 +1245,8 @@ do_pkg (struct pkg *packet, _net_addr * addr)
} }
/* get the addr and set the ping timeout value */ /* get the addr and set the ping timeout value */
addr->pl_nr = get_player_nr (addr->host, addr->port); addr->pl_nr = get_player_nr (addr->host, addr->port);
bman.players[addr->pl_nr].net.timestamp = timestamp; players[addr->pl_nr].net.timestamp = timestamp;
bman.players[addr->pl_nr].net.pingreq = bman.players[addr->pl_nr].net.pingack + 5; players[addr->pl_nr].net.pingreq = players[addr->pl_nr].net.pingack + 5;
/* test if we have any important packet */ /* test if we have any important packet */
if (packet->h.flags & PKGF_ackreq && packet->h.typ != PKG_bcmservchat) if (packet->h.flags & PKGF_ackreq && packet->h.typ != PKG_bcmservchat)
@ -1197,7 +1257,7 @@ do_pkg (struct pkg *packet, _net_addr * addr)
/* we have got this packet already */ /* we have got this packet already */
d_printf ("-----packet ignored\n"); d_printf ("-----packet ignored\n");
if (addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS) if (addr->pl_nr >= 0 && addr->pl_nr < MAX_PLAYERS)
bman.players[addr->pl_nr].net.pkgopt.to_2sec++; players[addr->pl_nr].net.pkgopt.to_2sec++;
return 0; return 0;
} }

@ -1,3 +1,11 @@
/* $Id: pkgcache.c,v 1.7 2003/11/08 06:27:59 stpohle Exp $
* Resendcache work, We need this to resend lost packets over the network.
* we will keep every packet with the PKGF_ackreq flag as long as we haven't
* got any answer from the destination host. And resend the packet after a givin
* time. The maximum time for a resend is 10 times if we haven't got any reply
* by then we delete the packet from the cache. By doing this the game will not
* anymore sync. with all clients.
*/
#include "bomberclone.h" #include "bomberclone.h"
#include "network.h" #include "network.h"
#include "packets.h" #include "packets.h"
@ -134,15 +142,14 @@ rscache_loop ()
/* send it again */ /* send it again */
d_printf d_printf
("Data Send Timeout (%s:%s) Resend now Package Fill %d, Pos %d\n", ("Data Send Timeout (%s:%s) Resend now Package Fill %d, Pos %d\n",
resend_cache.entry->addr.host, resend_cache.entry->addr.port, resend_cache.fill, resend_cache.entry->addr.host, resend_cache.entry->addr.port, resend_cache.fill,pos);
pos);
udp_send (bman.sock, (char *) &resend_cache.entry->packet, udp_send (bman.sock, (char *) &resend_cache.entry->packet,
NTOH16 (resend_cache.entry->packet.h.len), &resend_cache.entry->addr.sAddr, NTOH16 (resend_cache.entry->packet.h.len), &resend_cache.entry->addr.sAddr,
bman.net_ai_family); bman.net_ai_family);
resend_cache.entry->timestamp = timestamp; resend_cache.entry->timestamp = timestamp;
resend_cache.entry->retry++; resend_cache.entry->retry++;
if (resend_cache.entry->addr.pl_nr >= 0 && resend_cache.entry->addr.pl_nr < MAX_PLAYERS) if (resend_cache.entry->addr.pl_nr >= 0 && resend_cache.entry->addr.pl_nr < MAX_PLAYERS)
bman.players[resend_cache.entry->addr.pl_nr].net.pkgopt.to_2sec++; players[resend_cache.entry->addr.pl_nr].net.pkgopt.to_2sec++;
} }
if (timestamp - resend_cache.entry->timestamp >= timeout if (timestamp - resend_cache.entry->timestamp >= timeout
@ -151,7 +158,7 @@ rscache_loop ()
resend_cache.entry->addr.host, resend_cache.entry->addr.port, resend_cache.entry->addr.host, resend_cache.entry->addr.port,
resend_cache.fill, pos); resend_cache.fill, pos);
if (resend_cache.entry->addr.pl_nr >= 0 && resend_cache.entry->addr.pl_nr < MAX_PLAYERS) if (resend_cache.entry->addr.pl_nr >= 0 && resend_cache.entry->addr.pl_nr < MAX_PLAYERS)
bman.players[resend_cache.entry->addr.pl_nr].net.pkgopt.to_2sec++; players[resend_cache.entry->addr.pl_nr].net.pkgopt.to_2sec++;
rscache_del (); rscache_del ();
} }

@ -28,7 +28,7 @@ draw_player (_player * player)
dest.y = dest.y =
gfx.offset.y + player->gfx->offset.y + player->pos.y * gfx.block.y; gfx.offset.y + player->gfx->offset.y + player->pos.y * gfx.block.y;
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 = (int)player->frame * player->gfx->ani.h;
gfx_blit (player->gfx->ani.image, &src, gfx.screen, &dest, (player->pos.y * 256) + 128); gfx_blit (player->gfx->ani.image, &src, gfx.screen, &dest, (player->pos.y * 256) + 128);
@ -80,29 +80,29 @@ 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 >= 0.0f ) { if ((PS_IS_used (players[i].state)) && players[i].old.x >= 0.0f ) {
if (bman.players[i].old.x < 0.0f || bman.players[i].old.x >= map.size.x if (players[i].old.x < 0.0f || players[i].old.x >= map.size.x
|| bman.players[i].old.y < 0.0f || bman.players[i].old.y >= map.size.y) || players[i].old.y < 0.0f || players[i].old.y >= map.size.y)
d_printf ("FATAL: Restore Player out of range : playernr %d [%f,%f]\n", i, d_printf ("FATAL: Restore Player out of range : playernr %d [%f,%f]\n", i,
bman.players[i].old.x, bman.players[i].old.y); players[i].old.x, players[i].old.y);
else { else {
// start and end position for the stones to redraw X Position // start and end position for the stones to redraw X Position
if (CUTINT(bman.players[i].old.x) > 0.5f) { if (CUTINT(players[i].old.x) > 0.5f) {
x = bman.players[i].old.x; x = players[i].old.x;
xe = bman.players[i].old.x + 2; xe = players[i].old.x + 2;
} }
else { else {
x = bman.players[i].old.x - 1; x = players[i].old.x - 1;
xe = bman.players[i].old.x + 1; xe = 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;
// start and end position for the stones to redraw X Position // start and end position for the stones to redraw X Position
ys = bman.players[i].old.y - 1; ys = players[i].old.y - 1;
ye = bman.players[i].old.y + 1; ye = 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)
@ -120,7 +120,7 @@ restore_players_screen ()
void void
player_check_powerup (int p_nr) player_check_powerup (int p_nr)
{ {
_player *p = &bman.players[p_nr]; _player *p = &players[p_nr];
int fx = p->pos.x; int fx = p->pos.x;
int fy = p->pos.y; int fy = p->pos.y;
int ft, int ft,
@ -186,7 +186,7 @@ player_check_powerup (int p_nr)
case FT_death: case FT_death:
player_set_ilness (p, -1); player_set_ilness (p, -1);
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
if (bman.gametype != GT_single) if (GT_SP)
net_game_send_ill (bman.p_nr); net_game_send_ill (bman.p_nr);
field_clear (fx, fy); field_clear (fx, fy);
break; break;
@ -227,7 +227,7 @@ 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 = &players[pl_nr];
int i, int i,
j, j,
f; f;
@ -365,14 +365,14 @@ move_player (int pl_nr)
int oldd, int oldd,
stepsleft, stepsleft,
speed; speed;
_player *p = &bman.players[pl_nr]; _player *p = &players[pl_nr];
oldd = p->d; oldd = p->d;
if (p->tunnelto > 0) { if (p->tunnelto > 0) {
p->tunnelto--; p->tunnelto--;
p->m = 0; p->m = 0;
if (p->tunnelto <= 0 && GT_MP_PTP) if (p->tunnelto <= 0 && GT_MP)
net_game_send_playermove (bman.p_nr, 1); net_game_send_playermove (bman.p_nr, 1);
} }
else { else {
@ -388,7 +388,7 @@ move_player (int pl_nr)
} }
/* network packet send control - send data if it's time to send or if we need to */ /* network packet send control - send data if it's time to send or if we need to */
if (bman.gametype != GT_single) if (GT_MP)
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 (postofield(p->pos.x), postofield(p->pos.y), 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)))
@ -396,7 +396,7 @@ move_player (int pl_nr)
} }
/* the player just stopt moving so send data */ /* the player just stopt moving so send data */
if (bman.gametype != GT_single && p->m == 0 && p->old_m != 0) if (GT_MP && p->m == 0 && p->old_m != 0)
net_game_send_playermove (pl_nr, 1); net_game_send_playermove (pl_nr, 1);
p->old_m = p->m; // save the old state p->old_m = p->m; // save the old state
p->m = 0; p->m = 0;
@ -421,7 +421,7 @@ void
player_drop_bomb (int pl_nr) player_drop_bomb (int pl_nr)
{ {
_player *player = &bman.players[pl_nr]; _player *player = &players[pl_nr];
_bomb *bomb = NULL; _bomb *bomb = NULL;
int i; int i;
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
@ -442,19 +442,19 @@ player_drop_bomb (int pl_nr)
bomb->r = player->range; bomb->r = player->range;
if (player->special.type == SP_trigger) { if (player->special.type == SP_trigger) {
bomb->state = BS_trigger; bomb->state = BS_trigger;
bomb->to = SPECIAL_TRIGGER_TIMEOUT * TIME_FACTOR; // 5 Secs * 200 bomb->to = SPECIAL_TRIGGER_TIMEOUT;
} }
else { else {
bomb->state = BS_ticking; bomb->state = BS_ticking;
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200 bomb->to = BOMB_TIMEOUT;
} }
bomb->mode = BM_normal; bomb->mode = BM_normal;
bomb->ex_nr = -1; bomb->ex_nr = -1;
map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 1; map.bfield[(int)bomb->pos.x][(int)bomb->pos.y] = 1;
if (bman.gametype != GT_single) { if (GT_MP) {
net_game_send_bomb (pl_nr, i); net_game_send_bomb (pl_nr, i);
if (GT_MP_PTPS) if (GT_MP_PTPS)
bomb->to = bomb->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR); bomb->to = bomb->to + 2 * RESENDCACHE_RETRY;
} }
snd_play (SND_bombdrop); snd_play (SND_bombdrop);
@ -472,11 +472,11 @@ get_player_on (float x, float y, int pl_nr[])
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 (players[p].state) && players[p].tunnelto <= 0) {
if ((bman.players[p].pos.x - EXPLOSION_SAVE_DISTANCE) > x - 1.0f if ((players[p].pos.x - EXPLOSION_SAVE_DISTANCE) > x - 1.0f
&& (bman.players[p].pos.x + EXPLOSION_SAVE_DISTANCE) < x + 1.0f && (players[p].pos.x + EXPLOSION_SAVE_DISTANCE) < x + 1.0f
&& (bman.players[p].pos.y - EXPLOSION_SAVE_DISTANCE) > y - 1.0f && (players[p].pos.y - EXPLOSION_SAVE_DISTANCE) > y - 1.0f
&& (bman.players[p].pos.y + EXPLOSION_SAVE_DISTANCE) < y + 1.0f) { && (players[p].pos.y + EXPLOSION_SAVE_DISTANCE) < y + 1.0f) {
pl_nr[i] = p; pl_nr[i] = p;
i++; i++;
} }
@ -495,11 +495,11 @@ player_died (_player * player, signed char dead_by)
bman.updatestatusbar = 1; // force an update bman.updatestatusbar = 1; // force an update
if (PS_IS_alife (player->state) && dead_by >= 0 && dead_by < MAX_PLAYERS) if (PS_IS_alife (player->state) && dead_by >= 0 && dead_by < MAX_PLAYERS)
if (bman.p_nr != dead_by) if (bman.p_nr != dead_by)
bman.players[dead_by].points++; players[dead_by].points++;
player->frame = 0; player->frame = 0;
player->state &= (0xFF - PSF_alife); player->state &= (0xFF - PSF_alife);
player->dead_by = dead_by; player->dead_by = dead_by;
if (GT_MP_PTP) if (GT_MP)
net_game_send_player (bman.p_nr); net_game_send_player (bman.p_nr);
snd_play (SND_dead); snd_play (SND_dead);
}; };
@ -510,8 +510,8 @@ draw_players ()
{ {
int p; int p;
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
if (PS_IS_playing (bman.players[p].state) && bman.players[p].tunnelto <= 0) if (PS_IS_playing (players[p].state) && players[p].tunnelto <= 0)
draw_player (&bman.players[p]); draw_player (&players[p]);
} }
}; };
@ -523,25 +523,16 @@ player_animation (_player * player)
return; return;
if (PS_IS_alife (player->state)) { if (PS_IS_alife (player->state)) {
if (player->frame < player->gfx->ani.frames if ((int)player->frame < player->gfx->ani.frames)
&& (player->frameto <= 0 || player->frameto > ANI_PLAYERTIMEOUT)) { player->frame += timefactor;
player->frameto = ANI_PLAYERTIMEOUT; if ((int)player->frame >= player->gfx->ani.frames)
player->frame++; player->frame = 0.0f;
}
if (player->frame >= player->gfx->ani.frames)
player->frame = 0;
} }
if (PS_IS_dead (player->state)) { if (PS_IS_dead (player->state)) {
if (player->frame < gfx.dead.frames if ((int)player->frame < gfx.dead.frames)
&& (player->frameto <= 0 || player->frameto > ANI_PLAYERTIMEOUT * 2)) { player->frame += timefactor;
player->frameto = ANI_PLAYERTIMEOUT * 2;
player->frame++;
} }
}
if (player->frameto > 0)
player->frameto--;
}; };
@ -550,9 +541,10 @@ dead_playerani ()
{ {
int i, int i,
b = 0; b = 0;
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
if (PS_IS_dead (bman.players[i].state)) { if (PS_IS_dead (players[i].state)) {
player_animation (&bman.players[i]); player_animation (&players[i]);
b++; b++;
} }
@ -597,7 +589,7 @@ player_calcpos ()
p; p;
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
pl = &bman.players[p]; pl = &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) {
oldm = pl->m; oldm = pl->m;
@ -621,40 +613,36 @@ player_ilness_loop (int pl_nr)
int pl[MAX_PLAYERS + 1]; int pl[MAX_PLAYERS + 1];
/* do the illness for the network players */ /* do the illness for the network players */
if (GT_MP_PTP) { if (GT_MP) {
for (pnr = 0; pnr < MAX_PLAYERS; pnr++) for (pnr = 0; pnr < MAX_PLAYERS; pnr++)
if (pnr != pl_nr && PS_IS_alife (bman.players[pnr].state)) { if (pnr != pl_nr && PS_IS_alife (players[pnr].state)) {
p = &bman.players[pnr]; p = &players[pnr];
for (type = 0; type < PI_max; type++) for (type = 0; type < PI_max; type++)
if (p->ill[type].to > 0) { if (p->ill[type].to > 0) {
p->ill[type].to--; p->ill[type].to -= timediff;
p->illframeto--; p->illframe += timefactor;
if (p->illframeto <= 0 || p->illframeto > ANI_PLAYERILLTIMEOUT) {
p->illframeto = ANI_PLAYERILLTIMEOUT;
p->illframe++;
if (p->illframe < 0 || p->illframe >= gfx.ill.frames) if (p->illframe < 0 || p->illframe >= gfx.ill.frames)
p->illframe = 0; p->illframe = 0;
} }
} }
} }
}
/* check if we have contact with an other ill player */ /* check if we have contact with an other ill player */
p = &bman.players[pl_nr]; p = &players[pl_nr];
get_player_on (p->pos.x, p->pos.y, pl); get_player_on (p->pos.x, p->pos.y, pl);
for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++) for (i = 0; (pl[i] != -1 && i < MAX_PLAYERS); i++)
if (pl[i] != pl_nr) { if (pl[i] != pl_nr) {
send = 0; send = 0;
for (type = 0; type < PI_max; type++) { for (type = 0; type < PI_max; type++) {
if (bman.players[pl[i]].ill[type].to > p->ill[type].to) { if (players[pl[i]].ill[type].to > p->ill[type].to) {
tmp = p->ill[type].to; tmp = p->ill[type].to;
player_set_ilness (p, type); player_set_ilness (p, type);
p->ill[type].to = bman.players[pl[i]].ill[type].to; p->ill[type].to = players[pl[i]].ill[type].to;
if (tmp <= 0) if (tmp <= 0)
send = 1; send = 1;
} }
} }
if (send != 0 && GT_MP_PTP) if (send != 0 && GT_MP)
net_game_send_ill (pl_nr); net_game_send_ill (pl_nr);
} }
@ -665,13 +653,9 @@ player_ilness_loop (int pl_nr)
if (p->ill[type].to == 0) if (p->ill[type].to == 0)
player_clear_ilness (p, type); player_clear_ilness (p, type);
else { else {
p->illframeto--; p->illframe += timediff;
if (p->illframeto <= 0 || p->illframeto > ANI_PLAYERILLTIMEOUT) {
p->illframeto = ANI_PLAYERILLTIMEOUT;
p->illframe++;
if (p->illframe < 0 || p->illframe >= gfx.ill.frames) if (p->illframe < 0 || p->illframe >= gfx.ill.frames)
p->illframe = 0; p->illframe = 0;
}
if (type == PI_keys) { if (type == PI_keys) {
/* switch direction for player key illness */ /* switch direction for player key illness */
@ -721,7 +705,7 @@ player_set_ilness (_player * p, int t)
else else
p->ill[type].data = p->speed; p->ill[type].data = p->speed;
} }
p->speed = 6; p->speed = ILL_SLOWSPEED;
break; break;
case PI_fast: case PI_fast:
if (p->ill[type].to == 0) { if (p->ill[type].to == 0) {
@ -733,7 +717,7 @@ player_set_ilness (_player * p, int t)
p->ill[type].data = p->speed; p->ill[type].data = p->speed;
} }
p->speed = 150; p->speed = ILL_FASTSPEED;
break; break;
case PI_range: case PI_range:
if (p->ill[type].to == 0) if (p->ill[type].to == 0)
@ -747,7 +731,7 @@ player_set_ilness (_player * p, int t)
break; break;
} }
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
p->ill[type].to += TIME_FACTOR * IL_TIMEOUT; p->ill[type].to += ILL_TIMEOUT;
}; };
@ -770,7 +754,7 @@ player_clear_ilness (_player * p, int type)
break; break;
} }
p->ill[type].to = 0; p->ill[type].to = 0;
if (bman.gametype != GT_single) if (GT_MP)
net_game_send_ill (bman.p_nr); net_game_send_ill (bman.p_nr);
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
}; };

@ -1,4 +1,4 @@
/* $Id: single.c,v 1.45 2003/11/05 12:15:25 stpohle Exp $ */ /* $Id: single.c,v 1.46 2003/11/08 06:27:59 stpohle Exp $ */
/* single player */ /* single player */
#include "basic.h" #include "basic.h"
@ -14,20 +14,20 @@ single_game_new ()
// set players variables, only the variables which depend on single games // set players variables, only the variables which depend on single games
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
if (PS_IS_used (bman.players[p].state)) { if (PS_IS_used (players[p].state)) {
bman.players_nr_s++; bman.players_nr_s++;
bman.players_nr++; bman.players_nr++;
bman.players[p].state = PSF_used + PSF_alife + PSF_playing; players[p].state = PSF_used + PSF_alife + PSF_playing;
} }
else else
bman.players[p].state = 0; players[p].state = 0;
} }
bman.players[bman.p_nr].state = PSFM_alife; players[bman.p_nr].state = PSFM_alife;
player_set_gfx (&bman.players[bman.p_nr], bman.players[bman.p_nr].gfx_nr); player_set_gfx (&players[bman.p_nr], players[bman.p_nr].gfx_nr);
bman.last_ex_nr = 1; bman.last_ex_nr = 1;
bman.gametype = GT_single; bman.sock = -1;
bman.state = GS_running; bman.state = GS_running;
}; };
@ -539,7 +539,7 @@ ai_checknewpos (_point pos, int d)
/* create a giving number of ai players */ /* create a giving number of ai players */
void void
single_create_ai (int players) single_create_ai (int num_players)
{ {
int p, int p,
count, count,
@ -547,11 +547,11 @@ single_create_ai (int players)
i = 0; i = 0;
_player *pl; _player *pl;
for (count = 0; count < players; count++) { for (count = 0; count < num_players; count++) {
/* find free players */ /* find free players */
for (pl = NULL, p = 0; (pl == NULL && p < MAX_PLAYERS); p++) for (pl = NULL, p = 0; (pl == NULL && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (bman.players[p].state))) { if (!(PS_IS_used (players[p].state))) {
pl = &bman.players[p]; pl = &players[p];
sprintf (pl->name, "AI %d", count + 1); sprintf (pl->name, "AI %d", count + 1);
pl->state |= PSF_used + PSF_alife + PSF_playing; pl->state |= PSF_used + PSF_alife + PSF_playing;
do { do {
@ -576,15 +576,15 @@ single_playergame ()
/* delete player from the game */ /* delete player from the game */
for (p = 0; p < MAX_PLAYERS; p++) { for (p = 0; p < MAX_PLAYERS; p++) {
bman.players[p].points = 0; players[p].points = 0;
bman.players[p].wins = 0; players[p].wins = 0;
bman.players[p].state = 0; players[p].state = 0;
bman.players[p].gfx_nr = -1; players[p].gfx_nr = -1;
bman.players[p].gfx = NULL; players[p].gfx = NULL;
} }
for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++) for (bman.p_nr = -1, p = 0; (bman.p_nr == -1 && p < MAX_PLAYERS); p++)
if (!(PS_IS_used (bman.players[p].state))) if (!(PS_IS_used (players[p].state)))
bman.p_nr = p; bman.p_nr = p;
if (bman.p_nr >= MAX_PLAYERS) { if (bman.p_nr >= MAX_PLAYERS) {
@ -592,11 +592,11 @@ single_playergame ()
exit (1); exit (1);
} }
if ((bman.players[bman.p_nr].gfx_nr = single_select_player ()) == -1) if ((players[bman.p_nr].gfx_nr = single_select_player ()) == -1)
return; return;
bman.players[bman.p_nr].state = PSF_used + PSF_alife + PSF_playing; players[bman.p_nr].state = PSF_used + PSF_alife + PSF_playing;
strncpy (bman.players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME); strncpy (players[bman.p_nr].name, bman.playername, LEN_PLAYERNAME);
single_create_ai (bman.ai_players); single_create_ai (bman.ai_players);
bman.state = GS_ready; bman.state = GS_ready;
@ -623,8 +623,8 @@ single_loop ()
_airunaway rawdir; _airunaway rawdir;
for (p = 0; p < MAX_PLAYERS; p++) for (p = 0; p < MAX_PLAYERS; p++)
if (p != bman.p_nr && PS_IS_alife (bman.players[p].state)) { if (p != bman.p_nr && PS_IS_alife (players[p].state)) {
pl = &bman.players[p]; pl = &players[p];
i = ai_checkpos (pl, &plpos); i = ai_checkpos (pl, &plpos);
@ -672,7 +672,7 @@ single_loop ()
}; };
/* singleplayer menü with some options you can make */ /* singleplayer menü with some options you can make */
void void
single_menu () single_menu ()
{ {

@ -1,4 +1,4 @@
/* $Id: special.c,v 1.27 2003/11/05 12:15:25 stpohle Exp $ */ /* $Id: special.c,v 1.28 2003/11/08 06:27:59 stpohle Exp $ */
/* special.c - procedues to control the specials */ /* special.c - procedues to control the specials */
#include "bomberclone.h" #include "bomberclone.h"
@ -11,7 +11,7 @@ special_trigger (int p_nr)
z = 0, z = 0,
ex_nr = bman.last_ex_nr; ex_nr = bman.last_ex_nr;
_player *p = &bman.players[p_nr]; _player *p = &players[p_nr];
// all triggered bombs will explode // all triggered bombs will explode
for (i = 0; i < MAX_BOMBS; i++) for (i = 0; i < MAX_BOMBS; i++)
@ -21,7 +21,7 @@ special_trigger (int p_nr)
z++; // count the bombs which will explode z++; // count the bombs which will explode
} }
if (p_nr == bman.p_nr && GT_MP_PTP && z) if (p_nr == bman.p_nr && GT_MP && z)
net_game_send_special (p_nr, ex_nr); net_game_send_special (p_nr, ex_nr);
if (z) { if (z) {
@ -37,7 +37,7 @@ void
special_row (int p_nr) special_row (int p_nr)
{ {
_bomb *b = NULL; _bomb *b = NULL;
_player *p = &bman.players[p_nr]; _player *p = &players[p_nr];
int x = (int)p->pos.x, int x = (int)p->pos.x,
y = (int)p->pos.y, y = (int)p->pos.y,
dx = 0, dx = 0,
@ -76,12 +76,12 @@ special_row (int p_nr)
b->ex_nr = -1; b->ex_nr = -1;
b->pos.x = x; b->pos.x = x;
b->pos.y = y; b->pos.y = y;
b->to = BOMB_TIMEOUT * TIME_FACTOR + t; // 5 Secs * 200 b->to = BOMB_TIMEOUT + t; // 5 Secs * 200
map.bfield[x][y] = 1; map.bfield[x][y] = 1;
if (bman.gametype != GT_single) { if (GT_MP) {
net_game_send_bomb (p_nr, i); net_game_send_bomb (p_nr, i);
if (GT_MP_PTPS) if (GT_MP_PTPS)
b->to = b->to + ((2 * RESENDCACHE_RETRY) / TIME_FACTOR); b->to = b->to + 2 * RESENDCACHE_RETRY;
} }
} }
} }
@ -92,7 +92,7 @@ void
special_liquidmoved (int p_nr) special_liquidmoved (int p_nr)
{ {
_bomb *b = NULL; _bomb *b = NULL;
_player *p = &bman.players[p_nr]; _player *p = &players[p_nr];
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
int x = (int)p->pos.x, int x = (int)p->pos.x,
@ -138,7 +138,7 @@ special_liquidmoved (int p_nr)
get_bomb_on (x, y, 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 = &players[bombs[i].x].bombs[bombs[i].y];
if (b->state != BS_exploding) { if (b->state != BS_exploding) {
b->dest.x = dx; b->dest.x = dx;
b->dest.y = dy; b->dest.y = dy;
@ -150,7 +150,7 @@ special_liquidmoved (int p_nr)
map.bfield[x][y] = 0; map.bfield[x][y] = 0;
map.bfield[x1][y1] = 1; map.bfield[x1][y1] = 1;
stonelist_add (x, y); stonelist_add (x, y);
if (bman.gametype != GT_single) { if (GT_MP) {
net_game_send_bomb (bombs[i].x, bombs[i].y); net_game_send_bomb (bombs[i].x, bombs[i].y);
} }
} }
@ -162,7 +162,7 @@ void
special_push (int p_nr) special_push (int p_nr)
{ {
_bomb *b = NULL; _bomb *b = NULL;
_player *p = &bman.players[p_nr]; _player *p = &players[p_nr];
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
int x = (int)p->pos.x, int x = (int)p->pos.x,
@ -208,7 +208,7 @@ special_push (int p_nr)
get_bomb_on (x , y , 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 = &players[bombs[i].x].bombs[bombs[i].y];
if (b->state != BS_exploding) { if (b->state != BS_exploding) {
b->dest.x = dx; b->dest.x = dx;
b->dest.y = dy; b->dest.y = dy;
@ -217,7 +217,7 @@ special_push (int p_nr)
map.bfield[x][y] = 0; map.bfield[x][y] = 0;
map.bfield[x1][y1] = 1; map.bfield[x1][y1] = 1;
stonelist_add (x, y); stonelist_add (x, y);
if (bman.gametype != GT_single) { if (GT_MP) {
net_game_send_bomb (bombs[i].x, bombs[i].y); net_game_send_bomb (bombs[i].x, bombs[i].y);
} }
} }
@ -228,7 +228,7 @@ special_push (int p_nr)
void void
special_pickup (int p_nr, int s_nr) special_pickup (int p_nr, int s_nr)
{ {
_special *s = &bman.players[p_nr].special; _special *s = &players[p_nr].special;
s->to = 0; s->to = 0;
s->numuse = 0; s->numuse = 0;
@ -236,15 +236,15 @@ special_pickup (int p_nr, int s_nr)
switch (s_nr) { switch (s_nr) {
case SP_trigger: case SP_trigger:
s->numuse = SPECIAL_TRIGGER_NUMUSE; s->numuse = SPECIAL_TRIGGER_NUMUSE;
s->to = SPECIAL_TRIGGER_TIME * TIME_FACTOR; s->to = SPECIAL_TRIGGER_TIME;
break; break;
case SP_row: case SP_row:
s->to = SPECIAL_ROW_TIME * TIME_FACTOR; s->to = SPECIAL_ROW_TIME;
break; break;
case SP_push: case SP_push:
case SP_moved: case SP_moved:
case SP_liquid: case SP_liquid:
s->to = SPECIAL_PUSH_TIME * TIME_FACTOR; s->to = SPECIAL_PUSH_TIME;
break; break;
} }
@ -255,22 +255,22 @@ special_pickup (int p_nr, int s_nr)
void void
special_clear (int p_nr) special_clear (int p_nr)
{ {
if (bman.players[p_nr].special.type == SP_trigger) { if (players[p_nr].special.type == SP_trigger) {
_bomb *bomb; _bomb *bomb;
int i; int i;
/* put all bombs to normal and if the timeout is higher as usual /* put all bombs to normal and if the timeout is higher as usual
set it to normal */ set it to normal */
for (i = 0; i < MAX_BOMBS; i++) { for (i = 0; i < MAX_BOMBS; i++) {
bomb = &bman.players[p_nr].bombs[i]; bomb = &players[p_nr].bombs[i];
if (bomb->state == BS_trigger) { if (bomb->state == BS_trigger) {
bomb->state = BS_ticking; bomb->state = BS_ticking;
if (bomb->to > BOMB_TIMEOUT * TIME_FACTOR) if (bomb->to > BOMB_TIMEOUT)
bomb->to = BOMB_TIMEOUT * TIME_FACTOR; // 5 Secs * 200 bomb->to = BOMB_TIMEOUT;
} }
} }
} }
bman.players[p_nr].special.type = 0; players[p_nr].special.type = 0;
bman.updatestatusbar = 1; bman.updatestatusbar = 1;
} }
@ -282,7 +282,7 @@ special_loop ()
int p_nr; int p_nr;
for (p_nr = 0; p_nr < MAX_PLAYERS; p_nr++) { for (p_nr = 0; p_nr < MAX_PLAYERS; p_nr++) {
s = &bman.players[p_nr].special; s = &players[p_nr].special;
if (s->use) { if (s->use) {
switch (s->type) { switch (s->type) {
@ -290,25 +290,25 @@ special_loop ()
special_trigger (p_nr); special_trigger (p_nr);
break; break;
case SP_row: case SP_row:
if (bman.players[p_nr].m) if (players[p_nr].m)
special_row (p_nr); special_row (p_nr);
break; break;
case SP_push: case SP_push:
if (bman.players[p_nr].m) if (players[p_nr].m)
special_push (p_nr); special_push (p_nr);
break; break;
case SP_liquid: case SP_liquid:
case SP_moved: case SP_moved:
if (bman.players[p_nr].m) if (players[p_nr].m)
special_liquidmoved (p_nr); special_liquidmoved (p_nr);
break; break;
} }
s->use = 0; s->use = 0;
} }
if (s->type && s->to) { if (s->type && (s->to > 0.0f)) {
s->to--; s->to -= timediff;
if (!s->to) if (s->to <= 0.0f)
special_clear (p_nr); special_clear (p_nr);
} }
} }
@ -318,5 +318,5 @@ special_loop ()
void void
special_use (int p_nr) special_use (int p_nr)
{ {
bman.players[p_nr].special.use = 1; players[p_nr].special.use = 1;
} }

@ -1,4 +1,4 @@
/* $Id: tileset.c,v 1.9 2003/08/29 23:50:39 stpohle Exp $ */ /* $Id: tileset.c,v 1.10 2003/11/08 06:27:59 stpohle Exp $ */
/* load and select tilesets */ /* load and select tilesets */
#include "bomberclone.h" #include "bomberclone.h"
@ -55,11 +55,11 @@ tileset_load (char *tilesetname)
/* Calculate the Best Size of the Images */ /* Calculate the Best Size of the Images */
gfx.block.x = gfx.res.x / (map.size.x + 1); gfx.block.x = gfx.res.x / (map.size.x + 1);
if (GT_MP_PTP && gfx.res.y == 480) if (GT_MP && gfx.res.y == 480)
gfx.block.y = (gfx.res.y - 120) / (map.size.y + 1); gfx.block.y = (gfx.res.y - 120) / (map.size.y + 1);
else if (GT_MP_PTP && gfx.res.y == 600) else if (GT_MP && gfx.res.y == 600)
gfx.block.y = (gfx.res.y - 140) / (map.size.y + 1); gfx.block.y = (gfx.res.y - 140) / (map.size.y + 1);
else if (GT_MP_PTP && gfx.res.y > 600) else if (GT_MP && gfx.res.y > 600)
gfx.block.y = (gfx.res.y - 160) / (map.size.y + 1); gfx.block.y = (gfx.res.y - 160) / (map.size.y + 1);
else else
gfx.block.y = (gfx.res.y - 48) / (map.size.y + 1); gfx.block.y = (gfx.res.y - 48) / (map.size.y + 1);

Loading…
Cancel
Save