check if the new positoin is not already a target for another item and dropitemsondeath wasn't send with the servermode

origin
stpohle 22 years ago
parent 05a6f1e911
commit 1b6eb9d627

@ -22,5 +22,6 @@ extern void flitems_draw (_flyingitem *flitem);
extern _flyingitem *flitems_additem (_pointf from, _point to, signed char type);
extern void flitems_reset ();
extern _point flitems_randompos (int p_nr);
extern int flitems_checkfreepos (_point to);
#endif

@ -117,6 +117,7 @@ struct pkg_servermode {
unsigned char type;
unsigned char state;
unsigned char gametype;
unsigned char dropitemsondeath;
unsigned char players;
unsigned char mapstate;
unsigned char maxplayer;

@ -1,4 +1,4 @@
/* $Id: flyingitems.c,v 1.1 2004/01/25 23:02:20 stpohle Exp $ */
/* $Id: flyingitems.c,v 1.2 2004/01/26 05:39:38 stpohle Exp $ */
#include "bomberclone.h"
#include "flyingitems.h"
@ -41,6 +41,12 @@ void flitems_loop () {
_flyingitem **old = &flitems_first; // pointer of the preview next pointer
for (; flitem != NULL; flitem = flitem->next) {
/* restore the old position */
stonelist_add (floorf (flitem->pos.x), floorf (flitem->pos.y));
stonelist_add (floorf (flitem->pos.x), floorf (flitem->pos.y)+1);
stonelist_add (floorf (flitem->pos.x)+1, floorf (flitem->pos.y));
stonelist_add (floorf (flitem->pos.x)+1, floorf (flitem->pos.y)+1);
flitem->step += (2*timediff);
if (flitem->type == FT_nothing || flitem->step >= 1.0f) {
/* finished delete element and put it on the right place */
@ -55,10 +61,6 @@ void flitems_loop () {
flitem->next = NULL;
}
else { /* still moving draw item */
stonelist_add (floorf (flitem->pos.x), floorf (flitem->pos.y));
stonelist_add (floorf (flitem->pos.x), floorf (flitem->pos.y)+1);
stonelist_add (floorf (flitem->pos.x)+1, floorf (flitem->pos.y));
stonelist_add (floorf (flitem->pos.x)+1, floorf (flitem->pos.y)+1);
flitem->pos.x = (1.0f - flitem->step) * (flitem->from.x - flitem->to.x) + flitem->to.x;
flitem->pos.y = (1.0f - flitem->step) * (flitem->from.y - flitem->to.y) + flitem->to.y;
flitems_draw (flitem);
@ -119,6 +121,7 @@ _point flitems_randompos (int p_nr) {
/* check if the field is good */
check = (to.x > 0 && to.y > 0 && to.x < map.size.x-1 && to.y < map.size.y-1 &&
flitems_checkfreepos (to) &&
(map.field[to.x][to.y].type == FT_nothing
|| (map.field[to.x][to.y].type == FT_stone && map.field[to.x][to.y].special == FT_nothing)));
} while ( !check && maxtry > 200);
@ -185,3 +188,14 @@ void flitems_draw (_flyingitem *flitem) {
gfx_blit (gfx.powerup[0].image, &src, gfx.screen, &dest, (((int)flitems->pos.y + 1.0)*256) + 255);
gfx_blit (srci, &src, gfx.screen, &dest, (((int)flitems->pos.y + 1.0)*256) + 256);
};
/* check if not a flying item is going to this position */
int flitems_checkfreepos (_point to) {
_flyingitem *item = flitems_first;
while (item != NULL && ((int)item->to.x != to.x || (int)item->to.y != to.y))
item = item->next;
return (item == NULL);
};

@ -348,6 +348,7 @@ do_servermode (struct pkg_servermode *s_mod, _net_addr * addr)
if (GT_MP_PTPS) {
bman.state = s_mod->state;
bman.gametype = s_mod->gametype;
bman.dropitemsondeath = s_mod->dropitemsondeath;
map.state = s_mod->mapstate;
bman.players_nr_s = s_mod->players;
@ -372,6 +373,7 @@ send_servermode (_net_addr * addr, int pl_nr)
s_mod.h.len = HTON16 (sizeof (struct pkg_servermode));
s_mod.h.flags = PKGF_ackreq;
s_mod.type = bman.gametype;
s_mod.dropitemsondeath = bman.dropitemsondeath;
s_mod.mapstate = map.state;
if (bman.state == GS_quit) /* do not send GS_quit */
s_mod.state = GS_startup;

Loading…
Cancel
Save