Update of /cvsroot/netrek/client/netrekxp/src In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv11055/src Modified Files: data.c death.c local.c map.c mswindow.c newwin.c option.c Log Message: Removed the constant border refresh - trying to cut down on cpu usage. Loaded planet bitmaps into both local and map icon bitmap structures, for more efficient drawing. Index: mswindow.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/mswindow.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- mswindow.c 21 May 2006 09:56:38 -0000 1.24 +++ mswindow.c 21 May 2006 18:53:03 -0000 1.25 @@ -196,6 +196,7 @@ win = (Window *)window;\ if (bitmap->hwnd != win->hwnd)\ {\ + LineToConsole("DBICON - mismatch windows\n");\ hdc = GetDC (win->hwnd);\ usebitmaphwnd = 0;\ }\ @@ -547,6 +548,14 @@ free (planet_agri2[i]); free (planet_rock1[i]); free (planet_rock2[i]); + free (mplanet_earth[i]); + free (mplanet_klingus[i]); + free (mplanet_orion[i]); + free (mplanet_romulus[i]); + free (mplanet_agri1[i]); + free (mplanet_agri2[i]); + free (mplanet_rock1[i]); + free (mplanet_rock2[i]); } free (planet_bitmaps[0]); free (planet_bitmaps[1]); @@ -557,10 +566,22 @@ free (planet_bitmaps[6]); free (planet_bitmaps[7]); free (planet_unknown); - + free (mplanet_bitmaps[0]); + free (mplanet_bitmaps[1]); + free (mplanet_bitmaps[2]); + free (mplanet_bitmaps[3]); + free (mplanet_bitmaps[4]); + free (mplanet_bitmaps[5]); + free (mplanet_bitmaps[6]); + free (mplanet_bitmaps[7]); + free (mplanet_unknown); + free (army_bitmap); + free (marmy_bitmap); free (wrench_bitmap); + free (mwrench_bitmap); free (fuel_bitmap); + free (mfuel_bitmap); for (i = 0; i < PLANET_VIEWS; i++) free (bplanets[i]); Index: newwin.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/newwin.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- newwin.c 21 May 2006 09:56:39 -0000 1.25 +++ newwin.c 21 May 2006 18:53:03 -0000 1.26 @@ -659,6 +659,98 @@ } /******************************************************************************/ +/*** loadmplanetsC() - colorized map planets, using same bitmaps but more efficient + drawing if we assign another set to map HWND +/******************************************************************************/ +void loadmplanetsC() +{ + int j; + + /* Load the eight 5x1 mplanet bitmaps */ + mplanet_bitmaps[0] = + W_StoreBitmap3 ("bitmaps/planlibm/color/earth.bmp", + BMP_CPLANET_WIDTH * NUMTEAMS, BMP_CPLANET_HEIGHT, BMP_EARTH, mapw, + LR_DEFAULTCOLOR); + mplanet_bitmaps[1] = + W_StoreBitmap3 ("bitmaps/planlibm/color/klingus.bmp", + BMP_CPLANET_WIDTH * NUMTEAMS, BMP_CPLANET_HEIGHT, BMP_KLINGUS, mapw, + LR_DEFAULTCOLOR); + mplanet_bitmaps[2] = + W_StoreBitmap3 ("bitmaps/planlibm/color/orion.bmp", + BMP_CPLANET_WIDTH * NUMTEAMS, BMP_CPLANET_HEIGHT, BMP_ORION, mapw, + LR_DEFAULTCOLOR); + mplanet_bitmaps[3] = + W_StoreBitmap3 ("bitmaps/planlibm/color/romulus.bmp", + BMP_CPLANET_WIDTH * NUMTEAMS, BMP_CPLANET_HEIGHT, BMP_ROMULUS, mapw, + LR_DEFAULTCOLOR); + mplanet_bitmaps[4] = + W_StoreBitmap3 ("bitmaps/planlibm/color/agri1.bmp", + BMP_CPLANET_WIDTH * NUMTEAMS, BMP_CPLANET_HEIGHT, BMP_AGRI1, mapw, + LR_DEFAULTCOLOR); + mplanet_bitmaps[5] = + W_StoreBitmap3 ("bitmaps/planlibm/color/agri2.bmp", + BMP_CPLANET_WIDTH * NUMTEAMS, BMP_CPLANET_HEIGHT, BMP_AGRI2, mapw, + LR_DEFAULTCOLOR); + mplanet_bitmaps[6] = + W_StoreBitmap3 ("bitmaps/planlibm/color/rock1.bmp", + BMP_CPLANET_WIDTH * NUMTEAMS, BMP_CPLANET_HEIGHT, BMP_ROCK1, mapw, + LR_DEFAULTCOLOR); + mplanet_bitmaps[7] = + W_StoreBitmap3 ("bitmaps/planlibm/color/rock2.bmp", + BMP_CPLANET_WIDTH * NUMTEAMS, BMP_CPLANET_HEIGHT, BMP_ROCK2, mapw, + LR_DEFAULTCOLOR); + + /* Make pointers to the bitmaps */ + for (j = 0; j < NUMTEAMS; j++) + { + mplanet_earth[j] = + W_PointBitmap2 (mplanet_bitmaps[0], j, 0, BMP_CPLANET_WIDTH, + BMP_CPLANET_HEIGHT); + mplanet_klingus[j]= + W_PointBitmap2 (mplanet_bitmaps[1], j, 0, BMP_CPLANET_WIDTH, + BMP_CPLANET_HEIGHT); + mplanet_orion[j]= + W_PointBitmap2 (mplanet_bitmaps[2], j, 0, BMP_CPLANET_WIDTH, + BMP_CPLANET_HEIGHT); + mplanet_romulus[j]= + W_PointBitmap2 (mplanet_bitmaps[3], j, 0, BMP_CPLANET_WIDTH, + BMP_CPLANET_HEIGHT); + mplanet_agri1[j]= + W_PointBitmap2 (mplanet_bitmaps[4], j, 0, BMP_CPLANET_WIDTH, + BMP_CPLANET_HEIGHT); + mplanet_agri2[j]= + W_PointBitmap2 (mplanet_bitmaps[5], j, 0, BMP_CPLANET_WIDTH, + BMP_CPLANET_HEIGHT); + mplanet_rock1[j]= + W_PointBitmap2 (mplanet_bitmaps[6], j, 0, BMP_CPLANET_WIDTH, + BMP_CPLANET_HEIGHT); + mplanet_rock2[j]= + W_PointBitmap2 (mplanet_bitmaps[7], j, 0, BMP_CPLANET_WIDTH, + BMP_CPLANET_HEIGHT); + } + + /* Load the unknown planet bitmap */ + mplanet_unknown = + W_StoreBitmap3 ("bitmaps/planlibm/color/unknown.bmp", + BMP_CPLANET_WIDTH, BMP_CPLANET_HEIGHT, BMP_PLANET_UNKNOWN, mapw, + LR_DEFAULTCOLOR); + + /* Load the resource bitmaps */ + marmy_bitmap = + W_StoreBitmap3 ("bitmaps/planlibm/color/army.bmp", + BMP_ARMY_WIDTH, BMP_ARMY_HEIGHT, BMP_ARMYBMP, mapw, + LR_DEFAULTCOLOR); + mwrench_bitmap = + W_StoreBitmap3 ("bitmaps/planlibm/color/wrench.bmp", + BMP_WRENCH_WIDTH, BMP_WRENCH_HEIGHT, BMP_WRENCHBMP, mapw, + LR_DEFAULTCOLOR); + mfuel_bitmap = + W_StoreBitmap3 ("bitmaps/planlibm/color/fuel.bmp", + BMP_FUEL_WIDTH, BMP_FUEL_HEIGHT, BMP_FUELBMP, mapw, + LR_DEFAULTCOLOR); +} + +/******************************************************************************/ /*** handleMessageWindowKeyDown() /******************************************************************************/ static void @@ -997,7 +1089,7 @@ planetBitmap = intDefault ("planetBitmap", planetBitmap); planetBitmapGalaxy = intDefault ("planetBitmapGalaxy", planetBitmapGalaxy); loadplanetsC(); // Always load new color planet bitmaps..for now - + loadmplanetsC(); switch (planetBitmap) // Case 3 = new color, but we never use Planlib { case 1: Index: local.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/local.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- local.c 21 May 2006 09:56:38 -0000 1.24 +++ local.c 21 May 2006 18:53:03 -0000 1.25 @@ -26,7 +26,6 @@ /* Local Variables */ #define XPI 3.1415926 -static int playalert = 0; static int clearcount = 0; static int clearzone[4][(MAXTORP + 1) * MAXPLAYER + (MAXPLASMA + 1) * MAXPLAYER + MAXPLANETS]; @@ -327,6 +326,133 @@ } } +/******************************************************************************/ +/*** planetBitmapC() +/******************************************************************************/ +static inline W_Icon +planetBitmapC (register struct planet *p) +/* + * Choose the color bitmap for a planet. + */ +{ + int i; + W_Icon (*planet_bits); + + if ((p->pl_info & me->p_team) +#ifdef RECORDGAME + || playback +#endif + ) + { + /* Logic for planet assignment: + 1) Check if it's a homeworld. If so, find which homeworld it is + 2) Check if it's a core planet + 2a) Check if it's agri + 3) Check if it's agri + 4) Default planet bitmap + 5) Switch statement by owner to determine color + */ + if (p->pl_flags & PLHOME) + { + if (!strcmp(p->pl_name, "Earth")) + planet_bits = planet_earth; + else if (!strcmp(p->pl_name, "Klingus")) + planet_bits = planet_klingus; + else if (!strcmp(p->pl_name, "Romulus")) + planet_bits = planet_romulus; + else if (!strcmp(p->pl_name, "Orion")) + planet_bits = planet_orion; + else // This should never be called + planet_bits = planet_rock1; + } + else if (p->pl_flags & PLCORE) // Not functional yet due to server + { + if (p->pl_flags & PLAGRI) + planet_bits = planet_agri1; + else + planet_bits = planet_rock1; + } + else if (p->pl_flags & PLAGRI) + planet_bits = planet_agri2; + else + planet_bits = planet_rock2; + + switch (p->pl_owner) + { + case FED: + i = 0; + break; + case KLI: + i = 2; + break; + case ORI: + i = 3; + break; + case ROM: + i = 4; + break; + default: // IND + i = 1; + break; + } + return planet_bits[i]; + } + else + { + return planet_unknown; + } +} + +/******************************************************************************/ +/*** planetResourcesC() +/******************************************************************************/ +static inline void +planetResourcesC (register struct planet *p, int destwidth, int destheight, + int dx, int dy, W_Window window) +/* + * Draw the resources for a colorized planet. + */ +{ + if ((p->pl_info & me->p_team) +#ifdef RECORDGAME + || playback +#endif + ) + { + /* Select resources */ + if (p->pl_armies > 4) + W_WriteScaleBitmap(dx - 7 * destwidth / 8, + dy - (destheight / 2), + destwidth/3, + destheight, + BMP_ARMY_WIDTH, + BMP_ARMY_HEIGHT, + 0, + army_bitmap, planetColor(p), + window); + if (p->pl_flags & PLREPAIR) + W_WriteScaleBitmap(dx - (destwidth / 2), + dy - (5 * destheight / 6), + destwidth, + destheight/3, + BMP_WRENCH_WIDTH, + BMP_WRENCH_HEIGHT, + 0, + wrench_bitmap, planetColor(p), + window); + if (p->pl_flags & PLFUEL) + W_WriteScaleBitmap(dx + 3 * destwidth / 5, + dy - (destheight / 2), + destwidth/3, + destheight, + BMP_FUEL_WIDTH, + BMP_FUEL_HEIGHT, + 0, + fuel_bitmap, planetColor(p), + window); + } + return; +} static void DrawPlanets (void) @@ -2148,25 +2274,27 @@ clearlcount++; } + /* Change border color to signify alert status */ - /* Decided to always redraw alert borders, was causing too many problems with - the infrequent draw rate - BB */ if (oldalert != (me->p_flags & (PFGREEN | PFYELLOW | PFRED))) - playalert = 1; - oldalert = (me->p_flags & (PFGREEN | PFYELLOW | PFRED)); - switch (oldalert) { - case PFGREEN: - if (extraAlertBorder) + oldalert = (me->p_flags & (PFGREEN | PFYELLOW | PFRED)); + switch (oldalert) { - W_ChangeBorder (w, gColor); - W_ChangeBorder (mapw, gColor); - } - W_ChangeBorder (baseWin, gColor); + case PFGREEN: + if (extraAlertBorder) + { +#ifndef DOUBLE_BUFFERING + W_ChangeBorder (w, gColor); + W_ChangeBorder (mapw, gColor); +#else + W_ChangeBorderDB (localSDB, gColor); + W_ChangeBorderDB (mapSDB, gColor); +#endif + } + W_ChangeBorder (baseWin, gColor); #if defined(SOUND) - if (playalert) - { if (newSound) // Kill any channels with WARNING_WAV or RED_ALERT_WAV (group 2) Mix_HaltGroup(2); else @@ -2174,20 +2302,25 @@ Abort_Sound(WARNING_SOUND); Abort_Sound(RED_ALERT_SOUND); } - } + #endif - break; - case PFYELLOW: - if (extraAlertBorder) - { - W_ChangeBorder (w, yColor); - W_ChangeBorder (mapw, yColor); - } - W_ChangeBorder (baseWin, yColor); + + break; + case PFYELLOW: + if (extraAlertBorder) + { +#ifndef DOUBLE_BUFFERING + W_ChangeBorder (w, yColor); + W_ChangeBorder (mapw, yColor); +#else + W_ChangeBorderDB (localSDB, yColor); + W_ChangeBorderDB (mapSDB, yColor); +#endif + } + W_ChangeBorder (baseWin, yColor); #if defined(SOUND) - if (playalert) - { + if (newSound) // Kill any channels with RED_ALERT_WAV (group 2) { Mix_HaltGroup(2); @@ -2198,29 +2331,33 @@ Abort_Sound(RED_ALERT_SOUND); Play_Sound(WARNING_SOUND); } - } + #endif - break; - case PFRED: - if (extraAlertBorder) - { - W_ChangeBorder (w, rColor); - W_ChangeBorder (mapw, rColor); - } - W_ChangeBorder (baseWin, rColor); - + + break; + case PFRED: + if (extraAlertBorder) + { +#ifndef DOUBLE_BUFFERING + W_ChangeBorder (w, rColor); + W_ChangeBorder (mapw, rColor); +#else + W_ChangeBorderDB (localSDB, rColor); + W_ChangeBorderDB (mapSDB, rColor); +#endif + } + W_ChangeBorder (baseWin, rColor); + #if defined(SOUND) - if (playalert) - { if (newSound) Play_Sound(RED_ALERT_WAV); else Play_Sound(RED_ALERT_SOUND); - } #endif - break; + + break; + } } - playalert = 0; #if defined(SOUND) if (newSound) Index: death.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/death.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- death.c 21 May 2006 09:56:38 -0000 1.7 +++ death.c 21 May 2006 18:53:03 -0000 1.8 @@ -57,6 +57,8 @@ } W_ChangeBorder (baseWin, gColor); oldalert = PFGREEN; + if (doubleBuffering) /* Force a border refresh */ + oldalert = 0; } if (W_IsMapped (statwin)) { Index: option.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/option.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- option.c 21 May 2006 09:56:39 -0000 1.15 +++ option.c 21 May 2006 18:53:03 -0000 1.16 @@ -897,6 +897,7 @@ W_ClearWindow (w); W_ClearWindow (mapw); redrawall = 1; + oldalert = 0; /* Force a border refresh */ } else if (op->op_option == &partitionPlist) RedrawPlayerList (); Index: data.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/data.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- data.c 21 May 2006 09:56:38 -0000 1.23 +++ data.c 21 May 2006 18:53:03 -0000 1.24 @@ -309,14 +309,17 @@ ori_bitmapsHR[NUM_TYPES], ind_bitmapsHR[NUM_TYPES]; // Planets -W_Icon planet_unknown; -W_Icon planet_bitmaps[8]; +W_Icon planet_unknown, mplanet_unknown; +W_Icon planet_bitmaps[8], mplanet_bitmaps[8]; W_Icon planet_earth[NUMTEAMS], planet_klingus[NUMTEAMS], planet_orion[NUMTEAMS], planet_romulus[NUMTEAMS], planet_agri1[NUMTEAMS], planet_agri2[NUMTEAMS], planet_rock1[NUMTEAMS], planet_rock2[NUMTEAMS]; -W_Icon army_bitmap; -W_Icon wrench_bitmap; -W_Icon fuel_bitmap; +W_Icon mplanet_earth[NUMTEAMS], mplanet_klingus[NUMTEAMS], mplanet_orion[NUMTEAMS], + mplanet_romulus[NUMTEAMS], mplanet_agri1[NUMTEAMS], mplanet_agri2[NUMTEAMS], + mplanet_rock1[NUMTEAMS], mplanet_rock2[NUMTEAMS]; +W_Icon army_bitmap, marmy_bitmap; +W_Icon wrench_bitmap, mwrench_bitmap; +W_Icon fuel_bitmap, mfuel_bitmap; W_Icon base_planets; W_Icon base_mplanets; W_Icon bplanets[PLANET_VIEWS]; Index: map.c =================================================================== RCS file: /cvsroot/netrek/client/netrekxp/src/map.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- map.c 21 May 2006 09:56:38 -0000 1.11 +++ map.c 21 May 2006 18:53:03 -0000 1.12 @@ -253,16 +253,16 @@ } /******************************************************************************/ -/*** planetBitmapC() +/*** mplanetBitmapC() /******************************************************************************/ -extern inline W_Icon -planetBitmapC (register struct planet *p) +static inline W_Icon +mplanetBitmapC (register struct planet *p) /* - * Choose the color bitmap for a planet. + * Choose the map color bitmap for a planet. */ { int i; - W_Icon (*planet_bits); + W_Icon (*mplanet_bits); if ((p->pl_info & me->p_team) #ifdef RECORDGAME @@ -281,27 +281,27 @@ if (p->pl_flags & PLHOME) { if (!strcmp(p->pl_name, "Earth")) - planet_bits = planet_earth; + mplanet_bits = mplanet_earth; else if (!strcmp(p->pl_name, "Klingus")) - planet_bits = planet_klingus; + mplanet_bits = mplanet_klingus; else if (!strcmp(p->pl_name, "Romulus")) - planet_bits = planet_romulus; + mplanet_bits = mplanet_romulus; else if (!strcmp(p->pl_name, "Orion")) - planet_bits = planet_orion; + mplanet_bits = mplanet_orion; else // This should never be called - planet_bits = planet_rock1; + mplanet_bits = mplanet_rock1; } else if (p->pl_flags & PLCORE) // Not functional yet due to server { if (p->pl_flags & PLAGRI) - planet_bits = planet_agri1; + mplanet_bits = mplanet_agri1; else - planet_bits = planet_rock1; + mplanet_bits = mplanet_rock1; } else if (p->pl_flags & PLAGRI) - planet_bits = planet_agri2; + mplanet_bits = mplanet_agri2; else - planet_bits = planet_rock2; + mplanet_bits = mplanet_rock2; switch (p->pl_owner) { @@ -321,22 +321,22 @@ i = 1; break; } - return planet_bits[i]; + return mplanet_bits[i]; } else { - return planet_unknown; + return mplanet_unknown; } } /******************************************************************************/ -/*** planetResourcesC() +/*** mplanetResourcesC() /******************************************************************************/ -extern inline void -planetResourcesC (register struct planet *p, int destwidth, int destheight, +static inline void +mplanetResourcesC (register struct planet *p, int destwidth, int destheight, int dx, int dy, W_Window window) /* - * Draw the resources for a colorized planet. + * Draw the map resources for a colorized planet. */ { if ((p->pl_info & me->p_team) @@ -354,7 +354,7 @@ BMP_ARMY_WIDTH, BMP_ARMY_HEIGHT, 0, - army_bitmap, planetColor(p), + marmy_bitmap, planetColor(p), window); if (p->pl_flags & PLREPAIR) W_WriteScaleBitmap(dx - (destwidth / 2), @@ -364,7 +364,7 @@ BMP_WRENCH_WIDTH, BMP_WRENCH_HEIGHT, 0, - wrench_bitmap, planetColor(p), + mwrench_bitmap, planetColor(p), window); if (p->pl_flags & PLFUEL) W_WriteScaleBitmap(dx + 3 * destwidth / 5, @@ -374,7 +374,7 @@ BMP_FUEL_WIDTH, BMP_FUEL_HEIGHT, 0, - fuel_bitmap, planetColor(p), + mfuel_bitmap, planetColor(p), window); } return; @@ -481,11 +481,11 @@ BMP_CPLANET_WIDTH, BMP_CPLANET_HEIGHT, 0, - planetBitmapC(l), planetColor(l), + mplanetBitmapC(l), planetColor(l), mapw); /* Draw planet resources */ - planetResourcesC(l, BMP_MPLANET_WIDTH, BMP_MPLANET_HEIGHT, dx, dy, mapw); + mplanetResourcesC(l, BMP_MPLANET_WIDTH, BMP_MPLANET_HEIGHT, dx, dy, mapw); } else { @@ -515,11 +515,11 @@ BMP_CPLANET_WIDTH, BMP_CPLANET_HEIGHT, 0, - planetBitmapC (l), + mplanetBitmapC (l), planetColor (l), mapw); /* Draw planet resources */ - planetResourcesC(l, BMP_MPLANET_WIDTH, BMP_MPLANET_HEIGHT, dx, dy, mapw); + mplanetResourcesC(l, BMP_MPLANET_WIDTH, BMP_MPLANET_HEIGHT, dx, dy, mapw); } else {