Reduced number of UpdateRects

origin
patty21 23 years ago
parent 9ccc3e2ace
commit 19f6054919

@ -4,29 +4,6 @@
#include "network.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
@ -53,7 +30,7 @@ draw_bomb (_bomb * bomb)
src.x = 0;
src.y = src.h * bomb->frame;
draw_stone (bomb->pos.x, bomb->pos.y);
SDL_BlitSurface (gfx.bomb.image, &src, gfx.screen, &dest);
gfx_AddUpdateRect (dest.x, dest.y, dest.w, dest.h);
@ -83,11 +60,12 @@ bomb_explode (int p, int b)
};
void
int
bomb_loop ()
{
int p,
i;
i,
b=0;
_player *player;
_bomb *bomb;
@ -111,6 +89,7 @@ bomb_loop ()
}
draw_bomb (bomb);
}
b++;
}
else if (bomb->state == BS_exploding) {
if (bomb->to > 0) {
@ -122,10 +101,12 @@ bomb_loop ()
bomb->state = BS_off;
}
bomb->to--;
b++;
}
}
}
}
return b;
};
void
@ -216,12 +197,12 @@ restore_explosion (_bomb * bomb)
if (i == 0 && d == 3)
draw_stone (_x, _y);
if (i > 0)
draw_stone (_x, _y);
_x = _x + dx;
_y = _y + dy;
}
// delete the stone completly if there was any in the way
if (bomb->firer[d] <= bomb->r && bman.field[_x][_y].type != FT_block
&& bomb->ex_nr != bman.field[_x][_y].ex_nr) {
@ -243,6 +224,12 @@ restore_explosion (_bomb * bomb)
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 */
#ifndef _BOMBERCLONE_H_
@ -129,7 +129,7 @@ struct __bomberclone {
char fieldpath[512]; // path of the field file
int last_ex_nr; // number of the last explosion
int updatestatusbar; // 1 if statusbar has to be updated
unsigned char gametype;
unsigned char multitype;
unsigned char state;
@ -177,7 +177,7 @@ extern void field_set_playerposition (int usermap);
extern void tileset_random ();
// everything what is declared in players.c
extern void dead_playerani ();
extern int dead_playerani ();
extern void draw_player (_player * player);
extern void restore_players_screen ();
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);
// for the bomb..
extern void bomb_loop ();
extern void restore_bomb_screen ();
extern int bomb_loop ();
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 do_explosion (int p, int b);

@ -74,7 +74,8 @@ chat_drawbox ()
src.w = src.x + chat.window.w - 4;
src.h = src.y + 16;
draw_shadefield (gfx.screen, &src, CHAT_BG_SHADE_DARK >> 1);
};
gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h);
};
void
@ -115,7 +116,6 @@ chat_show (int x1, int y1, int x2, int y2)
chat.window.h = y2 - y1;
chat_drawbox ();
keybinput_new (&chat.input);
gfx_AddUpdateRect (chat.window.x, chat.window.y, chat.window.w, chat.window.h);
chat.changed = 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 */
#include <stdlib.h>
@ -70,8 +70,6 @@ draw_stone (int x, int y)
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;
};

@ -31,6 +31,6 @@ draw_text (int x, int y, char *text, int white)
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,
x,
j,
gfx_oldRects;
j;
char text[255];
char scrtext[255];
SDL_Rect src, dest;
redraw_logo (0, 0, gfx.res.x, 3*16);
gfx_AddUpdateRect (0,0, gfx.res.x, 3*16);
gfx_oldRects = UpdateRects_nr;
if (bman.updatestatusbar) {gfx_AddUpdateRect (0,0, gfx.res.x, 3*16);bman.updatestatusbar=0;}
bman.players_nr = 0;
/* draw Player names */
@ -78,28 +76,29 @@ game_draw_info ()
draw_text (100, 32, "Press F4 to start the game", 1);
else if (bman.state == GS_ready)
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);
for (x = 0; x < bman.fieldsize.x; x++)
draw_stone (x, bman.fieldsize.y-1);
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: [");
for (i = 0 ; i < MAX_PLAYERS; i++)
sprintf (text, "%s%3d ", text, bman.players[i].net.pkgopt.send_set);
text[strlen(text)+1] = 0;
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);
}
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);
gfx_AddUpdateRect (0, gfx.res.y - (gfx.font.size.y << 1), gfx.res.x, gfx.font.size.y << 1);
}
if (chat.visible == 0) {
SDL_Flip (gfx.screen);
if (chat.visible == 0 && GT_MP_PTP) {
chat_show (4, 3*16, gfx.res.x - 4, gfx.offset.y);
}
};
@ -112,6 +111,7 @@ game_loop ()
Uint8 *keys;
int done = 0;
Uint32 timeloop1;
int move=0;
int gameovertimeout = TIME_FACTOR * 5; // gameovertimeout
unsigned char key_bomb = 0; // last state of the bomb key
@ -125,7 +125,7 @@ game_loop ()
timestamp = SDL_GetTicks (); // needed for time sync.
d_gamedetail ("GAME START");
draw_players();
while (!done && (bman.state == GS_running || bman.state == GS_ready)) {
if (SDL_PollEvent (&event) != 0)
switch (event.type) {
@ -176,17 +176,14 @@ game_loop ()
bman.state = GS_startup;
done = 1;
}
move=bman.players[bman.p_nr].m;
chat_loop (&event);
restore_players_screen ();
restore_bomb_screen ();
if (move ||dead_playerani () || GT_MP_PTP) restore_players_screen ();
player_ilness_loop ();
if ((bman.players[bman.p_nr].state & PSFM_alife) == PSFM_alife)
move_player ();
player_calcpos ();
dead_playerani (); /* we need it to draw dead players */
if (bman.gametype != GT_single)
network_loop ();
@ -195,11 +192,10 @@ game_loop ()
/* this will even set the variable "bman.player_nr"
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 ();
/* check if there is only one player left and the game is in multiplayer mode
@ -212,7 +208,7 @@ game_loop ()
gameovertimeout--;
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;
}

@ -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.
*/
@ -637,6 +637,7 @@ net_delplayer (int pl_nr)
}
if (bman.notifygamemaster)
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++)
if (PS_IS_used (bman.players[i].state))
j++;
bman.updatestatusbar=1;
if (bman.notifygamemaster)
gamesrv_sendmode (bman.maxplayer, j);
}

@ -58,7 +58,9 @@ restore_players_screen ()
{
int i,
x,
xs,
xe,
y,
ys,
ye;
@ -84,10 +86,13 @@ restore_players_screen ()
ys = 0;
if (ye >= bman.fieldsize.y)
ye = bman.fieldsize.y - 1;
xs=x;
for (; x <= xe; x++)
for (y = ys; y <= ye; 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 */
case FT_bomb:
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;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
@ -135,7 +140,7 @@ player_check_powerup (_player * p)
/* we found a fire powerup */
case FT_fire:
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;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
@ -144,7 +149,7 @@ player_check_powerup (_player * p)
/* we found a shoe powerup */
case FT_shoe:
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;
if (bman.gametype != GT_single)
net_game_send_field (fx, fy);
@ -153,6 +158,7 @@ player_check_powerup (_player * p)
/* we found a death ?powerup? */
case FT_death:
player_set_ilness (p, -1);
bman.updatestatusbar=1;
net_game_send_ill (bman.p_nr);
bman.field[fx][fy].type = FT_nothing;
@ -419,14 +425,15 @@ player_animation (_player * player)
};
void
int
dead_playerani ()
{
int i;
int i,b=0;
for (i = 0; i < MAX_PLAYERS; i++)
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;
}
bman.updatestatusbar=1;
p->ill[type].to += TIME_FACTOR * IL_TIMEOUT;
};
@ -663,6 +670,7 @@ player_clear_ilness (_player * p, int type)
p->ill[type].to = 0;
net_game_send_ill (bman.p_nr);
bman.updatestatusbar=1;
};

Loading…
Cancel
Save