diff --git a/ChangeLog b/ChangeLog index bed0ed8..9a8dbd2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,15 @@ -$Id: ChangeLog,v 1.117 2007/01/12 11:15:42 stpohle Exp $ +$Id: ChangeLog,v 1.118 2007/01/12 22:42:30 stpohle Exp $ Version 0.11.7.1 (still in progress) ================ +- Fixed some drawing issues with flying bombs. + +- The last special item use was lost on clients in a network game. + special.use (was reset during special_clean) + special.clean variable added to save the cleaning state. + tested and works. + - Fixed: kicked bombs can travel in time. (map.bfield was set too early) rewrote full bomb kicked system. diff --git a/TODO b/TODO index 7c29b94..7bb980f 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ -$Id: TODO,v 1.45 2006/08/19 23:41:47 stpohle Exp $ - -- kicking bombs.. maybe bombs will have to get floated points.. to make this better. +$Id: TODO,v 1.46 2007/01/12 22:42:30 stpohle Exp $ - explosions.. sometimes bombs can explode more times, slow networks (very slow) diff --git a/include/player.h b/include/player.h index a073160..e7d8c6a 100644 --- a/include/player.h +++ b/include/player.h @@ -1,4 +1,4 @@ -/* $Id: player.h,v 1.10 2005/02/20 19:11:20 stpohle Exp $ +/* $Id: player.h,v 1.11 2007/01/12 22:42:31 stpohle Exp $ * playerinclude file */ @@ -67,6 +67,7 @@ struct { int numuse; // num of uses left int use; /* currently used set by special_use and deleted in special_loop */ + int clear; // do we need to clear this special } typedef _special; diff --git a/src/bomb.c b/src/bomb.c index 997e919..21855ce 100644 --- a/src/bomb.c +++ b/src/bomb.c @@ -1,4 +1,4 @@ -/* $Id: bomb.c,v 1.66 2007/01/12 11:15:44 stpohle Exp $ */ +/* $Id: bomb.c,v 1.67 2007/01/12 22:42:31 stpohle Exp $ */ /* everything what have to do with the bombs */ #include "bomberclone.h" @@ -6,9 +6,7 @@ #include "bomb.h" #include -void -draw_bomb (_bomb * bomb) -{ +void draw_bomb (_bomb * bomb) { SDL_Rect src, dest; int x = floorf (bomb->oldpos.x), y = floorf (bomb->oldpos.y); @@ -50,6 +48,7 @@ draw_bomb (_bomb * bomb) /* save the current position */ bomb->oldpos = bomb->pos; + if (bomb->mode == BM_kicked) y++; gfx_blit (gfx.bomb.image, &src, gfx.screen, &dest, (y * 256) + 2); }; @@ -61,9 +60,7 @@ draw_bomb (_bomb * bomb) * to - timeout * firer[d] - range of the bomb. */ -void -bomb_explode (_bomb *bomb, int net) -{ +void bomb_explode (_bomb *bomb, int net) { int d; d_printf ("Bomb Explode p:%d, b:%d [%f,%f]\n", bomb->id.p, bomb->id.b, bomb->pos.x, bomb->pos.y); @@ -97,9 +94,7 @@ bomb_explode (_bomb *bomb, int net) /* moves the bomb with it's speed, dest.x|y = dx, dy of the current move */ -void -bomb_move (_bomb * bomb) -{ +void bomb_move (_bomb * bomb) { int keepdir = 0; _pointf fpos, rpos; @@ -203,9 +198,7 @@ bomb_move (_bomb * bomb) } -void -bomb_loop () -{ +void bomb_loop () { int p, i; _player *player; @@ -265,8 +258,10 @@ bomb_loop () }; -/* check if on the givin place is a bomb - bombs[].x = player, bombs[].y = bombnumber */ +/* + * check if on the givin place is a bomb + * bombs[].x = player, bombs[].y = bombnumber + */ void get_bomb_on (float x, float y, _point bombs[]) { int p, b, @@ -362,9 +357,7 @@ void explosion_restore (_bomb *bomb) { /* * draw the explosion as far as she got */ -void -explosion_draw (_bomb * bomb) -{ +void explosion_draw (_bomb * bomb) { int d, r; _point p; diff --git a/src/game.c b/src/game.c index a999eea..a6822d3 100644 --- a/src/game.c +++ b/src/game.c @@ -1,4 +1,4 @@ -/* $Id: game.c,v 1.117 2007/01/12 11:15:44 stpohle Exp $ +/* $Id: game.c,v 1.118 2007/01/12 22:42:31 stpohle Exp $ game.c - procedures for the game. */ #include @@ -520,6 +520,8 @@ game_start () players[p].speed = bman.start_speed; players[p].collect_shoes = 0; players[p].special.type = SP_nothing; + players[p].special.use = 0; + players[p].special.clear = 0; players[p].m = 0; players[p].old.x = 0; players[p].old.y = 0; diff --git a/src/network.c b/src/network.c index 76969f1..2698b56 100644 --- a/src/network.c +++ b/src/network.c @@ -1,4 +1,4 @@ -/* $Id: network.c,v 1.78 2006/08/19 23:07:13 stpohle Exp $ */ +/* $Id: network.c,v 1.79 2007/01/12 22:42:31 stpohle Exp $ */ /* network routines. */ @@ -874,9 +874,7 @@ net_game_send_dropitems (int pl_nr, _flyingitem ** fiptr, int cnt) this routine will set up some things for the network game after this the data should be transfered to the other clients. */ -void -net_new_game () -{ +void net_new_game () { int p; /* set all multiplayer depending datas */ @@ -899,12 +897,10 @@ net_new_game () /* send special use elements into the network, to make sure nothing bad happens with explosions we send the ex_nr number too */ -void -net_game_send_special (int pl_nr, int ex_nr, int type) -{ +void net_game_send_special (int pl_nr, int ex_nr, int type) { int pl; - d_printf ("Send Special Data %d\n", pl_nr); + d_printf ("Send Special Data pl_nr:%d ex_nr:%d type:%d\n", pl_nr, ex_nr, type); if (pl_nr < 0 || pl_nr >= MAX_PLAYERS) return; diff --git a/src/packets.c b/src/packets.c index a0c1dd5..9ae5b5b 100644 --- a/src/packets.c +++ b/src/packets.c @@ -21,14 +21,12 @@ struct _inpkg_index inpkg_index[PKG_IN_INDEX_NUM]; int inpkg_index_pos = 0; -/*** - *** help function to get the playernumber from the address. - *** this function does not indicate which player it is, this function only checks - *** if the packet comed from a known player - ***/ -int -get_player_nr (char *host, char *port) -{ +/* + * help function to get the playernumber from the address. + * this function does not indicate which player it is, this function only checks + * if the packet comed from a known player + */ +int get_player_nr (char *host, char *port) { int i, res; @@ -42,12 +40,10 @@ get_player_nr (char *host, char *port) } -/*** - *** Packettype: error - ***/ -void -send_error (_net_addr * addr, char *text) -{ +/* + * Packettype: error + */ +void send_error (_net_addr * addr, char *text) { struct pkg_error p_err; d_printf ("Send Network Error : %s\n", text); @@ -61,9 +57,7 @@ send_error (_net_addr * addr, char *text) }; -void -do_error (struct pkg_error *data, _net_addr * addr) -{ +void do_error (struct pkg_error *data, _net_addr * addr) { d_printf ("Network Error from %s:%s : '%s'\n", addr->host, addr->port, data->text); /* check if the packet comes from the server, the server @@ -78,19 +72,17 @@ do_error (struct pkg_error *data, _net_addr * addr) -/*** - *** Packettype: joingame - *** client sends this to the server if he want's to join - *** - *** 1) check if this package comes from a already joined and known player - *** if so: just send the current playerlist back. - *** else: - *** 2) find free playerslot and add the player there - *** 3) send to all players the new playerid - ***/ -void -do_joingame (struct pkg_joingame *p_jg, _net_addr * addr) -{ +/* + * Packettype: joingame + * client sends this to the server if he want's to join + * + * 1) check if this package comes from a already joined and known player + * if so: just send the current playerlist back. + * else: + * 2) find free playerslot and add the player there + * 3) send to all players the new playerid + */ +void do_joingame (struct pkg_joingame *p_jg, _net_addr * addr) { _player *pl; int i, vma, @@ -208,9 +200,7 @@ do_joingame (struct pkg_joingame *p_jg, _net_addr * addr) }; -void -send_joingame (_net_addr * addr, char *name, int secondplayer) -{ +void send_joingame (_net_addr * addr, char *name, int secondplayer) { struct pkg_joingame p_jg; int vmi, vma, @@ -999,12 +989,10 @@ do_playermove (struct pkg_playermove *p_dat, _net_addr * addr) } -/*** - *** Packettype: bombdata - ***/ -void -do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) -{ +/* + * Packettype: bombdata + */ +void do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) { _bomb *bomb; if (addr->pl_nr == -1) @@ -1057,6 +1045,11 @@ do_bombdata (struct pkg_bombdata *b_dat, _net_addr * addr) bomb->r = b_dat->r; bomb->ex_nr = NTOH32 (b_dat->ex_nr); bomb->state = b_dat->state & 0x0F; + + if (bomb->mode != b_dat->state >> 4) { // bombmode changed set source to current position + bomb->source.x = bomb->pos.x; + bomb->source.y = bomb->pos.y; + } bomb->mode = b_dat->state >> 4; bomb->fdata = I16TOF (NTOH16 (b_dat->fdata)); bomb->dest.x = NTOH16 (b_dat->destx); @@ -1535,9 +1528,7 @@ do_dropitems (struct pkg_dropitem *di_pkg, _net_addr * addr) *** Packettype: special *** moves/bombs... whatever will be send as we use it ***/ -void -do_special (struct pkg_special *sp_pkg, _net_addr * addr) -{ +void do_special (struct pkg_special *sp_pkg, _net_addr * addr) { d_printf ("do_special (addr %d, pl_nr %d, typ %d)\n", addr->pl_nr, sp_pkg->pl_nr, sp_pkg->typ); if (addr->pl_nr == -1 || sp_pkg->pl_nr == -1 || sp_pkg->pl_nr == bman.p_nr || sp_pkg->pl_nr == bman.p2_nr) @@ -1550,9 +1541,9 @@ do_special (struct pkg_special *sp_pkg, _net_addr * addr) special_use (sp_pkg->pl_nr); } - /* cleas special */ + /* clear special */ else if (sp_pkg->typ == SP_clear) - special_clear (sp_pkg->pl_nr); + players[sp_pkg->pl_nr].special.clear = 1; }; diff --git a/src/special.c b/src/special.c index eaa4148..5e14922 100644 --- a/src/special.c +++ b/src/special.c @@ -1,4 +1,4 @@ -/* $Id: special.c,v 1.38 2007/01/12 11:15:44 stpohle Exp $ */ +/* $Id: special.c,v 1.39 2007/01/12 22:42:31 stpohle Exp $ */ /* special.c - procedues to control the specials */ #include "bomberclone.h" @@ -6,12 +6,10 @@ #include "player.h" #include "bomb.h" -void -special_trigger (int p_nr) -{ +void special_trigger (int p_nr) { int i, z = 0, - ex_nr = bman.last_ex_nr; + ex_nr = bman.last_ex_nr; _player *p = &players[p_nr]; @@ -35,9 +33,7 @@ special_trigger (int p_nr) } -void -special_row (int p_nr) -{ +void special_row (int p_nr) { _bomb *b = NULL; _player *p = &players[p_nr]; int x = (int) p->pos.x, @@ -80,9 +76,7 @@ special_row (int p_nr) } -void -special_liquidmoved (int p_nr) -{ +void special_liquidmoved (int p_nr) { _bomb *b = NULL; _player *p = &players[p_nr]; _point bombs[MAX_PLAYERS * MAX_BOMBS]; @@ -226,8 +220,7 @@ void special_kick (int p_nr) { /* calculate a new destination for the bomb (the new dest has to be in the direction of that bomb with max angle of 45 degree and distance SPECIAL_KICK_MAXDIST - if the bomb kickt to the border of maze, nothing happens.) - */ + if the bomb kickt to the border of maze, nothing happens.) */ do { trycnt--; r = s_random (SPECIAL_KICK_MAXDIST) + 1; @@ -301,9 +294,7 @@ special_pickup (int p_nr, int s_nr) } -void -special_clear (int p_nr) -{ +void special_clear (int p_nr) { if (players[p_nr].special.type == SP_trigger) { _bomb *bomb; int i; @@ -311,7 +302,7 @@ special_clear (int p_nr) set it to normal */ for (i = 0; i < MAX_BOMBS; i++) { bomb = &players[p_nr].bombs[i]; - if (bomb->state == BS_trigger) { + if (bomb->state == BS_trigger && !players[p_nr].special.use) { bomb->state = BS_ticking; if (bomb->to > bman.bomb_tickingtime) bomb->to = bman.bomb_tickingtime; @@ -326,9 +317,7 @@ special_clear (int p_nr) } -void -special_loop () -{ +void special_loop () { _special *s; int p_nr; @@ -358,21 +347,22 @@ special_loop () special_kick (p_nr); break; } - - s->use = 0; - } - - if (s->type && (s->to > 0.0f)) { - s->to -= timediff; - if (s->to <= 0.0f) - special_clear (p_nr); - } -} + s->use = 0; + } + + if (s->type && (s->to > 0.0f)) { + s->to -= timediff; + if (s->to <= 0.0f) s->clear = 1; + } + + if (s->clear) { + s->clear = 0; + special_clear (p_nr); + } + } } -void -special_use (int p_nr) -{ +void special_use (int p_nr) { players[p_nr].special.use = 1; }