Reduced number of UpdateRects

origin
patty21 23 years ago
parent 9ccc3e2ace
commit 19f6054919

@ -4,29 +4,6 @@
#include "network.h" #include "network.h"
#include "gfx.h" #include "gfx.h"
void
restore_bomb_screen ()
{
int p,
i;
_bomb *bomb;
for (p = 0; p < MAX_PLAYERS; p++)
for (i = 0; i < MAX_BOMBS; i++) {
bomb = &bman.players[p].bombs[i];
if (bomb->state == BS_ticking) {
draw_stone (bomb->pos.x, bomb->pos.y);
if (bomb->pos.x > 1)
draw_stone (bomb->pos.x - 1, bomb->pos.y);
if (bomb->pos.y > 1)
draw_stone (bomb->pos.x, bomb->pos.y - 1);
if (bomb->pos.x < bman.fieldsize.x)
draw_stone (bomb->pos.x + 1, bomb->pos.y);
if (bomb->pos.y < bman.fieldsize.y)
draw_stone (bomb->pos.x, bomb->pos.y + 1);
}
}
};
void void
@ -53,7 +30,7 @@ draw_bomb (_bomb * bomb)
src.x = 0; src.x = 0;
src.y = src.h * bomb->frame; src.y = src.h * bomb->frame;
draw_stone (bomb->pos.x, bomb->pos.y);
SDL_BlitSurface (gfx.bomb.image, &src, gfx.screen, &dest); SDL_BlitSurface (gfx.bomb.image, &src, gfx.screen, &dest);
gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h); gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h);
@ -83,11 +60,12 @@ bomb_explode (int p, int b)
}; };
void int
bomb_loop () bomb_loop ()
{ {
int p, int p,
i; i,
b=0;
_player *player; _player *player;
_bomb *bomb; _bomb *bomb;
@ -111,6 +89,7 @@ bomb_loop ()
} }
draw_bomb (bomb); draw_bomb (bomb);
} }
b++;
} }
else if (bomb->state == BS_exploding) { else if (bomb->state == BS_exploding) {
if (bomb->to > 0) { if (bomb->to > 0) {
@ -122,10 +101,12 @@ bomb_loop ()
bomb->state = BS_off; bomb->state = BS_off;
} }
bomb->to--; bomb->to--;
b++;
} }
} }
} }
} }
return b;
}; };
void void
@ -216,12 +197,12 @@ restore_explosion (_bomb * bomb)
if (i == 0 && d == 3) if (i == 0 && d == 3)
draw_stone (_x, _y); draw_stone (_x, _y);
if (i > 0) if (i > 0)
draw_stone (_x, _y); draw_stone (_x, _y);
_x = _x + dx; _x = _x + dx;
_y = _y + dy; _y = _y + dy;
} }
// delete the stone completly if there was any in the way // delete the stone completly if there was any in the way
if (bomb->firer[d] <= bomb->r && bman.field[_x][_y].type != FT_block if (bomb->firer[d] <= bomb->r && bman.field[_x][_y].type != FT_block
&& bomb->ex_nr != bman.field[_x][_y].ex_nr) { && bomb->ex_nr != bman.field[_x][_y].ex_nr) {
@ -243,6 +224,12 @@ restore_explosion (_bomb * bomb)
net_game_send_field (_x, _y); net_game_send_field (_x, _y);
} }
} }
_x=bomb->pos.x;
_y=bomb->pos.y;
gfx_AddUpdateRect (gfx.offset.x + (_x-bomb->firer[left]) * gfx.block.x,
gfx.offset.y + (_y-bomb->firer[up]) * gfx.block.y,
gfx.block.x*(bomb->firer[left]+bomb->firer[right]+1),
gfx.block.x*(bomb->firer[up]+bomb->firer[down]+1));
}; };

@ -1,4 +1,4 @@
/* $Id: bomberclone.h,v 1.18 2003/05/10 00:36:03 patty21 Exp $ */ /* $Id: bomberclone.h,v 1.19 2003/05/11 03:27:18 patty21 Exp $ */
/* bomberclone.h */ /* bomberclone.h */
#ifndef _BOMBERCLONE_H_ #ifndef _BOMBERCLONE_H_
@ -129,7 +129,7 @@ struct __bomberclone {
char fieldpath[512]; // path of the field file char fieldpath[512]; // path of the field file
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
unsigned char gametype; unsigned char gametype;
unsigned char multitype; unsigned char multitype;
unsigned char state; unsigned char state;
@ -177,7 +177,7 @@ extern void field_set_playerposition (int usermap);
extern void tileset_random (); extern void tileset_random ();
// everything what is declared in players.c // everything what is declared in players.c
extern void dead_playerani (); extern int dead_playerani ();
extern void draw_player (_player * player); extern void draw_player (_player * player);
extern void restore_players_screen (); extern void restore_players_screen ();
extern void move_player (); extern void move_player ();
@ -197,8 +197,7 @@ extern void player_check_powerup (_player * p);
extern void player_set_gfx (_player *p, signed char gfx_nr); extern void player_set_gfx (_player *p, signed char gfx_nr);
// for the bomb.. // for the bomb..
extern void bomb_loop (); extern int bomb_loop ();
extern void restore_bomb_screen ();
extern void get_bomb_on (int x, int y, _point bombs[]); extern void get_bomb_on (int x, int y, _point bombs[]);
extern void draw_fire (int x, int y, int d, int frame); extern void draw_fire (int x, int y, int d, int frame);
extern void do_explosion (int p, int b); extern void do_explosion (int p, int b);

@ -74,6 +74,7 @@ chat_drawbox ()
src.w = src.x + chat.window.w - 4; src.w = src.x + chat.window.w - 4;
src.h = src.y + 16; src.h = src.y + 16;
draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK >> 1); draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK >> 1);
gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h);
}; };
@ -115,7 +116,6 @@ chat_show (int x1, int y1, int x2, int y2)
chat.window.h = y2 - y1; chat.window.h = y2 - y1;
chat_drawbox (); chat_drawbox ();
keybinput_new (&chat.input); keybinput_new (&chat.input);
gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h);
chat.changed = 1; chat.changed = 1;
chat.lineschanged = 1; chat.lineschanged = 1;
} }

@ -1,4 +1,4 @@
/* $Id: field.c,v 1.16 2003/05/10 23:12:17 patty21 Exp $ */ /* $Id: field.c,v 1.17 2003/05/11 03:27:18 patty21 Exp $ */
/* field.c - procedures which are needed to control the field */ /* field.c - procedures which are needed to control the field */
#include <stdlib.h> #include <stdlib.h>
@ -70,8 +70,6 @@ draw_stone (int x, int y)
draw_fire (x, y, d, -1); draw_fire (x, y, d, -1);
} }
if (i == 0) // we don't have to do this anymore because this was happend in draw_fire
gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h);
return; return;
}; };

@ -31,6 +31,6 @@ draw_text (int x, int y, char *text, int white)
dest.x += gfx.font.size.x-4; dest.x += gfx.font.size.x-4;
} }
gfx_AddUpdateRect (x, y, dest.x - x, dest.h); // gfx_AddUpdateRect (x, y, dest.x - x, dest.h);
}; };

@ -18,15 +18,13 @@ game_draw_info ()
{ {
int i, int i,
x, x,
j, j;
gfx_oldRects;
char text[255]; char text[255];
char scrtext[255]; char scrtext[255];
SDL_Rect src, dest; SDL_Rect src, dest;
redraw_logo (0, 0, gfx.res.x, 3*16); redraw_logo (0, 0, gfx.res.x, 3*16);
gfx_AddUpdateRect (0,0, gfx.res.x, 3*16); if (bman.updatestatusbar) {gfx_AddUpdateRect (0,0, gfx.res.x, 3*16);bman.updatestatusbar=0;}
gfx_oldRects = UpdateRects_nr;
bman.players_nr = 0; bman.players_nr = 0;
/* draw Player names */ /* draw Player names */
@ -78,28 +76,29 @@ game_draw_info ()
draw_text (100, 32, "Press F4 to start the game", 1); draw_text (100, 32, "Press F4 to start the game", 1);
else if (bman.state == GS_ready) else if (bman.state == GS_ready)
draw_text (100, 32, "Waiting for the Server to Start", 1); draw_text (100, 32, "Waiting for the Server to Start", 1);
gfx_AddUpdateRect (100, 32, gfx.res.x - 100, 16); // gfx_AddUpdateRect (100, 32, gfx.res.x - 100, 16);
redraw_logo (0, gfx.res.y - gfx.font.size.y, gfx.res.x, gfx.res.y); redraw_logo (0, gfx.res.y - gfx.font.size.y, gfx.res.x, gfx.res.y);
for (x = 0; x < bman.fieldsize.x; x++)
draw_stone (x, bman.fieldsize.y-1);
if (debug) { /* do some debug informations on the screen */ if (debug) { /* do some debug informations on the screen */
for (x = 0; x < bman.fieldsize.x; x++)
draw_stone (x, bman.fieldsize.y-1);
if (GT_MP_PTP) {
sprintf (text, "NET_STAT: ["); sprintf (text, "NET_STAT: [");
for (i = 0 ; i < MAX_PLAYERS; i++) for (i = 0 ; i < MAX_PLAYERS; i++)
sprintf (text, "%s%3d ", text, bman.players[i].net.pkgopt.send_set); sprintf (text, "%s%3d ", text, bman.players[i].net.pkgopt.send_set);
text[strlen(text)+1] = 0; text[strlen(text)+1] = 0;
text[strlen(text)] = ']'; text[strlen(text)] = ']';
sprintf (text, "%s GFX_RECTS:%d", text, UpdateRects_nr);
draw_text (0, gfx.res.y - (gfx.font.size.y << 1), text, 1); draw_text (0, gfx.res.y - (gfx.font.size.y << 1), text, 1);
}
sprintf (text, "TILESET: %s Timediff: %d", gfx.tileset, timediff); sprintf (text, "TILESET: %s Timediff: %d", gfx.tileset, timediff);
sprintf (text, "%s GFX_RECTS:%d", text, UpdateRects_nr);
draw_text (0, gfx.res.y - gfx.font.size.y, text, 1); draw_text (0, gfx.res.y - gfx.font.size.y, text, 1);
gfx_AddUpdateRect (0, gfx.res.y - (gfx.font.size.y << 1), gfx.res.x, gfx.font.size.y << 1); gfx_AddUpdateRect (0, gfx.res.y - (gfx.font.size.y << 1), gfx.res.x, gfx.font.size.y << 1);
} }
if (chat.visible == 0) { if (chat.visible == 0 && GT_MP_PTP) {
SDL_Flip (gfx.screen);
chat_show (4, 3*16, gfx.res.x - 4, gfx.offset.y); chat_show (4, 3*16, gfx.res.x - 4, gfx.offset.y);
} }
}; };
@ -112,6 +111,7 @@ game_loop ()
Uint8 *keys; Uint8 *keys;
int done = 0; int done = 0;
Uint32 timeloop1; Uint32 timeloop1;
int move=0;
int gameovertimeout = TIME_FACTOR * 5; // gameovertimeout int gameovertimeout = TIME_FACTOR * 5; // gameovertimeout
unsigned char key_bomb = 0; // last state of the bomb key unsigned char key_bomb = 0; // last state of the bomb key
@ -125,7 +125,7 @@ game_loop ()
timestamp = SDL_GetTicks (); // needed for time sync. timestamp = SDL_GetTicks (); // needed for time sync.
d_gamedetail ("GAME START"); d_gamedetail ("GAME START");
draw_players();
while (!done && (bman.state == GS_running || bman.state == GS_ready)) { while (!done && (bman.state == GS_running || bman.state == GS_ready)) {
if (SDL_PollEvent (&event) != 0) if (SDL_PollEvent (&event) != 0)
switch (event.type) { switch (event.type) {
@ -176,17 +176,14 @@ game_loop ()
bman.state = GS_startup; bman.state = GS_startup;
done = 1; done = 1;
} }
move=bman.players[bman.p_nr].m;
chat_loop (&event); chat_loop (&event);
if (move ||dead_playerani () || GT_MP_PTP) restore_players_screen ();
restore_players_screen ();
restore_bomb_screen ();
player_ilness_loop (); player_ilness_loop ();
if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife) if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife)
move_player (); move_player ();
player_calcpos (); player_calcpos ();
dead_playerani (); /* we need it to draw dead players */
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
network_loop (); network_loop ();
@ -195,11 +192,10 @@ game_loop ()
/* this will even set the variable "bman.player_nr" /* this will even set the variable "bman.player_nr"
to let us know how much Players are still left */ to let us know how much Players are still left */
game_draw_info ();
bomb_loop ();
draw_players ();
if (bomb_loop () || move || GT_MP_PTP) draw_players ();
move=0;
game_draw_info ();
gfx_UpdateRects (); gfx_UpdateRects ();
/* 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
@ -212,7 +208,7 @@ game_loop ()
gameovertimeout--; gameovertimeout--;
if (gameovertimeout <= 0) { if (gameovertimeout <= 0) {
d_printf ("GAME: Game Over 'Cause only one or noone anymore alife\n"); d_printf ("GAME: Game Over 'Cause only one or none anymore alife\n");
done = 1; done = 1;
} }

@ -1,4 +1,4 @@
/* $Id: network.c,v 1.16 2003/05/08 14:35:49 stpohle Exp $ */ /* $Id: network.c,v 1.17 2003/05/11 03:27:18 patty21 Exp $ */
/* /*
network routines. network routines.
*/ */
@ -637,6 +637,7 @@ net_delplayer (int pl_nr)
} }
if (bman.notifygamemaster) if (bman.notifygamemaster)
gamesrv_sendmode (bman.maxplayer, j); gamesrv_sendmode (bman.maxplayer, j);
bman.updatestatusbar=1;
} }
} }

@ -167,6 +167,7 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr)
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 (bman.players[i].state))
j++; j++;
bman.updatestatusbar=1;
if (bman.notifygamemaster) if (bman.notifygamemaster)
gamesrv_sendmode (bman.maxplayer, j); gamesrv_sendmode (bman.maxplayer, j);
} }

@ -58,7 +58,9 @@ restore_players_screen ()
{ {
int i, int i,
x, x,
xs,
xe, xe,
y, y,
ys, ys,
ye; ye;
@ -84,10 +86,13 @@ restore_players_screen ()
ys = 0; ys = 0;
if (ye >= bman.fieldsize.y) if (ye >= bman.fieldsize.y)
ye = bman.fieldsize.y - 1; ye = bman.fieldsize.y - 1;
xs=x;
for (; x <= xe; x++) for (; x <= xe; x++)
for (y = ys; y <= ye; y++) for (y = ys; y <= ye; y++)
draw_stone (x, y); draw_stone (x, y);
gfx_AddUpdateRect(xs*gfx.block.x+gfx.offset.x,ys*gfx.block.y+gfx.offset.y,gfx.block.x*3,gfx.block.y*3);
} }
}; };
@ -126,7 +131,7 @@ player_check_powerup (_player * p)
/* we found a bomb powerup */ /* we found a bomb powerup */
case FT_bomb: case FT_bomb:
if (p->bombs_n < MAX_BOMBS && p->ill[PI_nobomb].to <= 0) if (p->bombs_n < MAX_BOMBS && p->ill[PI_nobomb].to <= 0)
p->bombs_n++; {p->bombs_n++;bman.updatestatusbar=1;}
bman.field[fx][fy].type = FT_nothing; bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_field (fx, fy); net_game_send_field (fx, fy);
@ -135,7 +140,7 @@ player_check_powerup (_player * p)
/* we found a fire powerup */ /* we found a fire powerup */
case FT_fire: case FT_fire:
if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0) if (p->range < MAX_RANGE && p->ill[PI_range].to <= 0)
p->range++; {p->range++;bman.updatestatusbar=1;}
bman.field[fx][fy].type = FT_nothing; bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_field (fx, fy); net_game_send_field (fx, fy);
@ -144,7 +149,7 @@ player_check_powerup (_player * p)
/* we found a shoe powerup */ /* we found a shoe powerup */
case FT_shoe: case FT_shoe:
if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0) if (p->speed < MAX_SPEED && p->ill[PI_slow].to <= 0)
p->speed *= SPEEDMUL; {p->speed *= SPEEDMUL;bman.updatestatusbar=1;}
bman.field[fx][fy].type = FT_nothing; bman.field[fx][fy].type = FT_nothing;
if (bman.gametype != GT_single) if (bman.gametype != GT_single)
net_game_send_field (fx, fy); net_game_send_field (fx, fy);
@ -153,6 +158,7 @@ player_check_powerup (_player * p)
/* we found a death ?powerup? */ /* we found a death ?powerup? */
case FT_death: case FT_death:
player_set_ilness (p, -1); player_set_ilness (p, -1);
bman.updatestatusbar=1;
net_game_send_ill (bman.p_nr); net_game_send_ill (bman.p_nr);
bman.field[fx][fy].type = FT_nothing; bman.field[fx][fy].type = FT_nothing;
@ -419,14 +425,15 @@ player_animation (_player * player)
}; };
void int
dead_playerani () dead_playerani ()
{ {
int i; int i,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 (bman.players[i].state))
player_animation (&bman.players[i]); {player_animation (&bman.players[i]);b++;}
return b;
}; };
@ -637,7 +644,7 @@ player_set_ilness (_player * p, int t)
break; break;
} }
bman.updatestatusbar=1;
p->ill[type].to += TIME_FACTOR * IL_TIMEOUT; p->ill[type].to += TIME_FACTOR * IL_TIMEOUT;
}; };
@ -663,6 +670,7 @@ player_clear_ilness (_player * p, int type)
p->ill[type].to = 0; p->ill[type].to = 0;
net_game_send_ill (bman.p_nr); net_game_send_ill (bman.p_nr);
bman.updatestatusbar=1;
}; };

Loading…
Cancel
Save