diff --git a/lib/ivis_common/piepalette.h b/lib/ivis_common/piepalette.h index 8ae0da6f8..091f5687d 100644 --- a/lib/ivis_common/piepalette.h +++ b/lib/ivis_common/piepalette.h @@ -66,6 +66,7 @@ #define WZCOL_MENU_SHADOW psPalette[41] #define WZCOL_DBLUE psPalette[42] #define WZCOL_LBLUE psPalette[43] + #define WZCOL_MAX 44 //************************************************************************* diff --git a/lib/ivis_opengl/piepalette.c b/lib/ivis_opengl/piepalette.c index a2b149630..227fa0631 100644 --- a/lib/ivis_opengl/piepalette.c +++ b/lib/ivis_opengl/piepalette.c @@ -95,8 +95,8 @@ void pal_Init(void) WZCOL_MAP_PREVIEW_AIPLAYER = pal_Colour(0, 0x7f, 0); WZCOL_GREY = pal_Colour(0x55, 0x55, 0x55); WZCOL_MENU_SHADOW = WZCOL_BLACK; - WZCOL_DBLUE =pal_Colour(0x0f,0x08,0x56); - WZCOL_LBLUE =pal_Colour(0x1c,0x9f,0xfb); + WZCOL_DBLUE = pal_Colour(0x0f,0x08,0x56); + WZCOL_LBLUE = pal_Colour(0x1c,0x9f,0xfb); } void pal_ShutDown(void) diff --git a/lib/ivis_opengl/screen.c b/lib/ivis_opengl/screen.c index ec98ed7ba..8550371c2 100644 --- a/lib/ivis_opengl/screen.c +++ b/lib/ivis_opengl/screen.c @@ -61,7 +61,7 @@ static GLuint backDropTexture = ~0; GLuint fbo; // Our handle to the FBO GLuint FBOtexture; // The texture we are going to use GLuint FBOdepthbuffer; // Our handle to the depth render buffer -static BOOL FBOinit = false; +static BOOL FBOinit = false; /* Initialise the double buffered display */ BOOL screenInitialise( @@ -390,26 +390,24 @@ void screenDumpToDisk(const char* path) { if (screendump_num != 0) screendump_required = true; } -// checkGLErrors( char *label) -// -// if a openGL error has occured, we query the error code, and see what it was. + +/** + * Checks if an OpenGL error has occurred. + * \param label Label to print when an OpenGL occurred. + */ void checkGLErrors(const char *label) { - GLenum errCode; - const GLubyte *errStr; + const GLenum errCode = glGetError(); - if ((errCode = glGetError()) != GL_NO_ERROR) - { - errStr = gluErrorString(errCode); - debug(LOG_ERROR,"OpenGL ERROR in %s: ",label); - debug(LOG_ERROR,"%s, %d(0x%0x)",(char*)errStr,errCode,errCode); - } + if (errCode == GL_NO_ERROR) + return; + + debug(LOG_ERROR, "OpenGL ERROR in %s: %s, (0x%0x)", label, gluErrorString(errCode), errCode); } -// Init_FBO( int width, int height ) -// FBO create routine + BOOL Init_FBO( int width, int height ) { -GLenum status; + GLenum status; // check to make sure user has FBO available, and we didn't create a FBO before. if(GLEE_EXT_framebuffer_object && !FBOinit) { @@ -433,7 +431,7 @@ GLenum status; // attach that texture to the color glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - GL_TEXTURE_2D, FBOtexture, 0); + GL_TEXTURE_2D, FBOtexture, 0); glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); // unbind FBO // make sure everything went OK @@ -488,7 +486,7 @@ GLenum status; return true; } -// Delete_FBO() + void Delete_FBO(void) { if(FBOinit) diff --git a/lib/ivis_opengl/screen.h b/lib/ivis_opengl/screen.h index 23afb992f..77fa7c3df 100644 --- a/lib/ivis_opengl/screen.h +++ b/lib/ivis_opengl/screen.h @@ -59,6 +59,7 @@ extern void screenToggleMode(void); extern int wz_texture_compression; extern void screenDoDumpToDiskIfRequired(void); + extern BOOL Init_FBO( int width, int height ); extern void Delete_FBO(void); extern void checkGLErrors(const char *label); // reports what the openGL error was diff --git a/src/game.c b/src/game.c index bbdfc3dda..d451fb5a4 100644 --- a/src/game.c +++ b/src/game.c @@ -11816,20 +11816,17 @@ static BOOL getNameFromComp(UDWORD compType, char *pDest, UDWORD compIndex) } // ----------------------------------------------------------------------------------------- // END -//====================================================== -//BOOL plotStructurePreview16( -// char *backDropSprite, // the premade map texture -// UBYTE scale, // scale of the map texture -// UDWORD offX, // X offset for map -// UDWORD offY, // Y offset for map -// Vector2i playeridpos[]) // holds the position on map that player's HQ is located -// -// adds clancolors for the map preview texture. -// What basically happens in this routine is we read the map, and then for -// every structure on said map, we either color it via clan colors (which -// are the same as the radar colors), and it plots its pixel on the bitmap. -// Also added position number of starting location (which is determined by -// the map maker(!)) This info is needed so we can blit players location. + +/** + * \param[out] backDropSprite The premade map texture. + * \param scale Scale of the map texture. + * \param offX,offY X and Y offset for map + * \param[out] playeridpos Will contain the position on the map where the player's HQ are located. + * + * Reads the current map and colours the map preview for any structures + * present. Additionally we load the player's HQ location into playeridpos so + * we know the player's starting location. + */ BOOL plotStructurePreview16(char *backDropSprite, UBYTE scale, UDWORD offX, UDWORD offY,Vector2i playeridpos[]) { SAVE_STRUCTURE sSave; // close eyes now. @@ -11937,6 +11934,7 @@ BOOL plotStructurePreview16(char *backDropSprite, UBYTE scale, UDWORD offX, UDWO endian_udword(&psSaveStructure2->player); endian_udword(&psSaveStructure2->burnStart); endian_udword(&psSaveStructure2->burnDamage); + // we are specifically looking for the HQ, and it seems this is the only way to // find it via parsing map. // We store the coordinates of the structure, into a array for as many players as are on the map. @@ -12244,7 +12242,7 @@ BOOL plotStructurePreview16(char *backDropSprite, UBYTE scale, UDWORD offX, UDWO color.rgba = clanColours[playerid].rgba; // kludge to fix black, so you can see it on some maps. if ( playerid == 3 ) // in this case 3 = pallete entry for black. - { + { color = WZCOL_GREY; } } @@ -12252,9 +12250,10 @@ BOOL plotStructurePreview16(char *backDropSprite, UBYTE scale, UDWORD offX, UDWO { // Use a dark green color for the AI color = WZCOL_MAP_PREVIEW_AIPLAYER ; } + if(HQ) { // This shows where the HQ is on the map in a special color. - // We could do the same for anything else (oil/whatever) also. + // We could do the same for anything else (oil/whatever) also. // Possible future enhancement? color.byte.b=0xff; color.byte.g=0; @@ -12266,14 +12265,13 @@ BOOL plotStructurePreview16(char *backDropSprite, UBYTE scale, UDWORD offX, UDWO { for(y = (yy*scale);y< (yy*scale)+scale ;y++) { - backDropSprite[3 * (((offY + y) * BACKDROP_HACK_WIDTH) + x + offX)] = color.byte.r; + backDropSprite[3 * (((offY + y) * BACKDROP_HACK_WIDTH) + x + offX)] = color.byte.r; backDropSprite[3 * (((offY + y) * BACKDROP_HACK_WIDTH) + x + offX) + 1] = color.byte.g; backDropSprite[3 * (((offY + y) * BACKDROP_HACK_WIDTH) + x + offX) + 2] = color.byte.b; } - } - } + // NOTE: would do fallback if FBO is not available here. -return true; + return true; } diff --git a/src/multiint.c b/src/multiint.c index 68ff1eb0a..44d2645c8 100644 --- a/src/multiint.c +++ b/src/multiint.c @@ -187,13 +187,13 @@ void loadMapPreview(void) UDWORD fileSize; char *pFileData = NULL; LEVEL_DATASET *psLevel = NULL; + UDWORD i, j, x, y, height, offX2, offY2; UBYTE scale,col; MAPTILE *psTile,*WTile; UDWORD oursize; Vector2i playerpos[MAX_PLAYERS]; // Will hold player positions char *ptr = NULL, *imageData = NULL, *fboData = NULL; -//============================= if(psMapTiles) { @@ -386,6 +386,7 @@ void loadMapPreview(void) free(fboData); free(imageData); + hideTime = gameTime; mapShutdown(); Delete_FBO();