Fixed crash in snake movement code
This commit is contained in:
parent
519ea7f54d
commit
cb26714a27
43
rc.c
43
rc.c
|
@ -3545,32 +3545,35 @@ int movesprite(sprite_t *s) {
|
|||
int shoot = B_FALSE;
|
||||
if (player && (s->y - player->y <= (TILEH*4)) ) {
|
||||
closeplayer = player;
|
||||
} else {
|
||||
} else if (player2 && (s->y - player2->y <= (TILEH*4))) {
|
||||
closeplayer = player2;
|
||||
} else {
|
||||
closeplayer = NULL;
|
||||
}
|
||||
|
||||
|
||||
if (s->bullet == NULL) { // if we don't already have a bullet
|
||||
// if we are facing the player
|
||||
if ( (closeplayer->x < s->x) && (s->dir == D_LEFT) ) {
|
||||
shoot = B_TRUE;
|
||||
} else if ( (closeplayer->x > s->x) && (s->dir == D_RIGHT) ) {
|
||||
shoot = B_TRUE;
|
||||
if (closeplayer) {
|
||||
if (s->bullet == NULL) { // if we don't already have a bullet
|
||||
// if we are facing the player
|
||||
if ( (closeplayer->x < s->x) && (s->dir == D_LEFT) ) {
|
||||
shoot = B_TRUE;
|
||||
} else if ( (closeplayer->x > s->x) && (s->dir == D_RIGHT) ) {
|
||||
shoot = B_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (shoot) {
|
||||
// if our shooting timer is okay
|
||||
if (s->timer1 == 0) {
|
||||
ss = addsprite(P_SPIT,s->x,s->y - s->img->h/2,"spit" );
|
||||
ss->ys = 0;
|
||||
ss->xs = s->dir * (getspeed(s)*2);
|
||||
ss->dir = s->dir;
|
||||
ss->owner = s;
|
||||
if (shoot) {
|
||||
// if our shooting timer is okay
|
||||
if (s->timer1 == 0) {
|
||||
ss = addsprite(P_SPIT,s->x,s->y - s->img->h/2,"spit" );
|
||||
ss->ys = 0;
|
||||
ss->xs = s->dir * (getspeed(s)*2);
|
||||
ss->dir = s->dir;
|
||||
ss->owner = s;
|
||||
|
||||
s->bullet = ss;
|
||||
s->bullet = ss;
|
||||
|
||||
// start timer for shooting again
|
||||
s->timer1 = 200;
|
||||
// start timer for shooting again
|
||||
s->timer1 = 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue