Fixed CPU usage bug if the player have got a special..

origin
stpohle 23 years ago
parent bc3143c124
commit 7874c516ab

@ -1,3 +1,7 @@
- PowerUps will be painted diffrent now. Depend
on what it is.
- New Font Drawing enginge, so we can draw in with - New Font Drawing enginge, so we can draw in with
diffrent fonts and colors. diffrent fonts and colors.
@ -8,7 +12,7 @@
- Added Sound Support (thanks to Henrik Enqvist for - Added Sound Support (thanks to Henrik Enqvist for
the help and the sound files.) the help and the sound files.)
- Added new powerups (Patty) - Added new special powerups (Patty)
- Fixed make install, so the source will be able to - Fixed make install, so the source will be able to
install correctly now with the data packages install correctly now with the data packages

@ -53,6 +53,7 @@ mw_shutdown ()
chat_show (-1, -1, -1, -1); chat_show (-1, -1, -1, -1);
gfx_free_players (); gfx_free_players ();
for (i = 0; i < MAX_PLAYERS; i++) for (i = 0; i < MAX_PLAYERS; i++)
SDL_FreeSurface (mw_plgfx[i]); SDL_FreeSurface (mw_plgfx[i]);
}; };
@ -82,9 +83,13 @@ mw_draw_status ()
px = gfx.res.x / 320; px = gfx.res.x / 320;
x = (gfx.res.x - px * 320) / 2; x = (gfx.res.x - px * 320) / 2;
for (pnr = 0; pnr < px; pnr++) for (pnr = 0; pnr < px; pnr++) {
font_draw (pnr * 320 + x, 24, " Wins Points", 1); font_setcolor (128,128,128,0);
font_draw (pnr * 320 + x - 2, 22, " Wins Points", 0);
font_setcolor (192,192,255,0);
font_draw (pnr * 320 + x, 24, " Wins Points", 0);
}
/* 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);
@ -105,9 +110,10 @@ mw_draw_status ()
if (PS_IS_used (bman.players[pnr].state)) { if (PS_IS_used (bman.players[pnr].state)) {
if (bman.lastwinner == pnr) if (bman.lastwinner == pnr)
font_draw (x + x1 * 320, y, text, 0); font_setcolor (255,255,192,0);
else else
font_draw (x + x1 * 320, y, text, 0); font_setcolor (192,192,192,0);
font_draw (x + x1 * 320, y, text, 0);
} }
x1++; x1++;
if (x1 >= px) { if (x1 >= px) {

@ -26,10 +26,11 @@ special_trigger (int p_nr)
if (z) { if (z) {
bman.last_ex_nr = ex_nr + 6; bman.last_ex_nr = ex_nr + 6;
p->special.numuse--; p->special.numuse--;
if (!p->special.numuse) special_clear(p_nr); if (!p->special.numuse)
} special_clear (p_nr);
}
} }
@ -74,8 +75,8 @@ special_row (int p_nr)
b->state = BS_ticking; b->state = BS_ticking;
b->r = p->range; b->r = p->range;
b->ex_nr = -1; b->ex_nr = -1;
b->pos.x = x<<8; b->pos.x = x << 8;
b->pos.y = y<<8; b->pos.y = y << 8;
b->to = BOMB_TIMEOUT * TIME_FACTOR + t; // 5 Secs * 200 b->to = BOMB_TIMEOUT * TIME_FACTOR + t; // 5 Secs * 200
bman.bfield[x][y] = 1; bman.bfield[x][y] = 1;
if (bman.gametype != GT_single) { if (bman.gametype != GT_single) {
@ -93,7 +94,7 @@ special_push (int p_nr)
_bomb *b = NULL; _bomb *b = NULL;
_player *p = &bman.players[p_nr]; _player *p = &bman.players[p_nr];
_point bombs[MAX_PLAYERS * MAX_BOMBS]; _point bombs[MAX_PLAYERS * MAX_BOMBS];
int x = p->pos.x >> 8, int x = p->pos.x >> 8,
y = p->pos.y >> 8, y = p->pos.y >> 8,
dx = 0, dx = 0,
@ -102,7 +103,9 @@ special_push (int p_nr)
y1, y1,
i; i;
if ((p->pos.x & 0xff) || (p->pos.y & 0xff)) {return;} if ((p->pos.x & 0xff) || (p->pos.y & 0xff)) {
return;
}
switch (p->d) { switch (p->d) {
case left: case left:
dx = -1; dx = -1;
@ -119,88 +122,103 @@ special_push (int p_nr)
} }
x += dx; x += dx;
y += dy; y += dy;
// check that player is beside a bomb // check that player is beside a bomb
if (!bman.bfield[x][y]) if (!bman.bfield[x][y])
return; return;
x1 = x + dx; x1 = x + dx;
y1 = y + dy; y1 = y + dy;
// check the field behind the bomb // check the field behind the bomb
if (bman.bfield[x1][y1] || bman.field[x1][y1].type != FT_nothing) if (bman.bfield[x1][y1] || bman.field[x1][y1].type != FT_nothing)
return; return;
get_bomb_on (x << 8, y << 8, bombs); get_bomb_on (x << 8, y << 8, 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 = &bman.players[bombs[i].x].bombs[bombs[i].y];
if (b->state != BS_exploding) { if (b->state != BS_exploding) {
b->moveto.x = x1<<8; b->moveto.x = x1 << 8;
b->moveto.y = y1<<8; b->moveto.y = y1 << 8;
b->moves=p->speed; b->moves = p->speed;
bman.bfield[x][y]=0; bman.bfield[x][y] = 0;
bman.bfield[x1][y1]=1; bman.bfield[x1][y1] = 1;
draw_stone(x,y); draw_stone (x, y);
field_update(x,y); field_update (x, y);
if (bman.gametype != GT_single) { if (bman.gametype != GT_single) {
net_game_send_bomb (bombs[i].x, bombs[i].y);} net_game_send_bomb (bombs[i].x, bombs[i].y);
} }
}
} }
} }
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 = &bman.players[p_nr].special;
s->to=0;
s->numuse=0; s->to = 0;
s->type=s_nr; s->numuse = 0;
switch(s_nr) { s->type = s_nr;
case SP_trigger: switch (s_nr) {
s->numuse=SPECIAL_TRIGGER_NUMUSE; case SP_trigger:
s->to=SPECIAL_TRIGGER_TIME*TIME_FACTOR; s->numuse = SPECIAL_TRIGGER_NUMUSE;
break; s->to = SPECIAL_TRIGGER_TIME * TIME_FACTOR;
case SP_row : break;
s->to=SPECIAL_ROW_TIME*TIME_FACTOR; case SP_row:
break; s->to = SPECIAL_ROW_TIME * TIME_FACTOR;
case SP_push : break;
s->to=SPECIAL_PUSH_TIME*TIME_FACTOR; case SP_push:
break; s->to = SPECIAL_PUSH_TIME * TIME_FACTOR;
} break;
}
bman.updatestatusbar = 1;
} }
void void
special_clear (int p_nr) { special_clear (int p_nr)
bman.players[p_nr].special.type=0; {
bman.updatestatusbar=1; bman.players[p_nr].special.type = 0;
bman.updatestatusbar = 1;
} }
void void
special_loop (int p_nr) { special_loop (int p_nr)
{
_special *s = &bman.players[p_nr].special; _special *s = &bman.players[p_nr].special;
if (!s->type) return;
bman.updatestatusbar=1; if (!s->type)
if (s->to) { return;
if (s->to) {
s->to--; s->to--;
if (!s->to) special_clear (p_nr); if (!s->to)
} special_clear (p_nr);
}
} }
void void
special_use (int p_nr) { special_use (int p_nr)
{
switch (bman.players[p_nr].special.type) { switch (bman.players[p_nr].special.type) {
case SP_trigger: case SP_trigger:
special_trigger (p_nr); special_trigger (p_nr);
break; break;
case SP_row:if (bman.players[p_nr].m) case SP_row:
if (bman.players[p_nr].m)
special_row (p_nr); special_row (p_nr);
break; break;
case SP_push:if (bman.players[p_nr].m) case SP_push:
if (bman.players[p_nr].m)
special_push (p_nr); special_push (p_nr);
break; break;
case SP_kick:break; case SP_kick:
}} break;
}
}

Loading…
Cancel
Save