From 832a292f0a1fd2f34fb05ef1e142c3749ac7abf6 Mon Sep 17 00:00:00 2001 From: stpohle Date: Tue, 10 Jun 2003 21:09:43 +0000 Subject: [PATCH] Player Selection CPU Usage Bug fixed --- src/multiwait.c | 28 +++++++++++++++++++--------- src/packets.c | 3 ++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/multiwait.c b/src/multiwait.c index 702b8c3..1ec1054 100644 --- a/src/multiwait.c +++ b/src/multiwait.c @@ -14,7 +14,8 @@ extern int UpdateRects_nr; -static int mw_y = 0, +static int mw_player = 0, + mw_chat = 0, mw_frame = 0, mw_frameto = 0; static SDL_Surface *mw_plgfx[MAX_PLAYERS]; @@ -41,6 +42,8 @@ mw_init () SDL_FreeSurface (tmp); network_loop (); } + + bman.updatestatusbar = 1; }; @@ -124,7 +127,7 @@ mw_draw_status () y += 32; } - mw_y = y; + mw_player = y; }; @@ -146,7 +149,7 @@ mw_draw_gfxselect (int selgfx) dest.h = src.h = gfx.players[i].size.y; dest.x = i * xstep + (xstep >> 1) - (gfx.players[i].size.x >> 1); - dest.y = mw_y + 8; + dest.y = mw_player + 8; redraw_logo (dest.x, dest.y, dest.w, dest.h); @@ -187,7 +190,7 @@ mw_draw_gfxselect (int selgfx) dest.h = src.h = gfx.players[i].size.y; dest.x = i * xstep + (xstep >> 1) - (gfx.players[i].size.x >> 1); - dest.y = mw_y + 8; + dest.y = mw_player + 8; redraw_logo (dest.x, dest.y, dest.w, dest.h); @@ -209,7 +212,7 @@ mw_draw_gfxselect (int selgfx) } } - mw_y += 8 + gfx.players[0].size.y; + mw_chat = mw_player + 8 + gfx.players[0].size.y; } @@ -217,7 +220,7 @@ void mw_draw_chat () { if (chat.visible == 0) { - chat_show (16, mw_y + 16, gfx.res.x - 16, gfx.res.y - 32); + chat_show (16, mw_chat + 16, gfx.res.x - 16, gfx.res.y - 32); chat_addline ("Press [STRG] or [CTRL] - to select a player"); if (GT_MP_PTPM) chat_addline ("F4 - to start the game"); @@ -266,9 +269,13 @@ wait_for_players () SDL_Flip (gfx.screen); } else { /* we have a connect so draw status */ - mw_draw_status (); + if (bman.updatestatusbar) { + mw_draw_status (); + gfx_AddUpdateRect (0, 0, gfx.res.x, mw_player); + bman.updatestatusbar = 0; + } mw_draw_gfxselect (selgfx); - gfx_AddUpdateRect (0, 0, gfx.res.x, mw_y); + gfx_AddUpdateRect (0, mw_player, gfx.res.x, mw_chat); mw_draw_chat (); } @@ -336,19 +343,22 @@ wait_for_players () bman.players[bman.p_nr].gfx_nr = -1; } net_change_playerid (bman.p_nr, 1); + bman.updatestatusbar = 1; } if ((GT_MP_PTPM) && ready && keys[SDLK_F4] && (!keypressed)) { done = 1; + bman.updatestatusbar = 1; } if ((GT_MP_PTPM) && keys[SDLK_F5] && (!keypressed)) { /* Map modification */ mapmenu (); + draw_logo(); mw_draw_status (); mw_draw_gfxselect (selgfx); UpdateRects_nr = 0; - gfx_AddUpdateRect (0, 0, gfx.res.x, mw_y); + gfx_AddUpdateRect (0, 0, gfx.res.x, gfx.res.y); chat.changed = 1; chat.lineschanged = 1; chat_drawbox (); diff --git a/src/packets.c b/src/packets.c index c7ba2de..f56b25c 100644 --- a/src/packets.c +++ b/src/packets.c @@ -171,7 +171,6 @@ 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); } @@ -192,6 +191,8 @@ do_playerid (struct pkg_playerid *p_id, _net_addr * addr) net_change_playerid (addr->pl_nr, (GT_MP_PTPM)); d_playerdetail ("*** PLAYER List ***"); + + bman.updatestatusbar = 1; };