Skip to content

Commit

Permalink
Add oil barrels to map preview.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyp committed Jun 5, 2012
1 parent 353357b commit 5b07a7b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
1 change: 1 addition & 0 deletions data/base/palette.txt
Expand Up @@ -86,3 +86,4 @@ E0,E0,E0,ff // team11 - white
32,4b,a0,ff // blueprint planned by ally
ff,80,40,ff // construction bar text
00,ff,00,ff // power queue bar text
80,c0,00,ff // WZCOL_MAP_PREVIEW_BARREL
3 changes: 2 additions & 1 deletion lib/ivis_opengl/piepalette.h
Expand Up @@ -110,8 +110,9 @@
#define WZCOL_BLUEPRINT_PLANNED_BY_ALLY psPalette[85]
#define WZCOL_CONSTRUCTION_BARTEXT psPalette[86]
#define WZCOL_POWERQUEUE_BARTEXT psPalette[87]
#define WZCOL_MAP_PREVIEW_BARREL psPalette[88]

#define WZCOL_MAX 88
#define WZCOL_MAX 89

//*************************************************************************

Expand Down
38 changes: 27 additions & 11 deletions src/game.cpp
Expand Up @@ -6579,7 +6579,8 @@ static void plotFeature(char *backDropSprite)
UDWORD sizeOfSaveFeature = 0;
char *pFileData = NULL;
char aFileName[256];
const PIELIGHT color = WZCOL_MAP_PREVIEW_OIL;
const PIELIGHT colourOil = WZCOL_MAP_PREVIEW_OIL;
const PIELIGHT colourBarrel = WZCOL_MAP_PREVIEW_BARREL;

psLevel = levFindDataSet(game.map);
strcpy(aFileName, psLevel->apDataFiles[0]);
Expand All @@ -6604,14 +6605,23 @@ static void plotFeature(char *backDropSprite)
Position pos = ini.vector3i("position");

// we only care about oil
PIELIGHT const *colour = NULL;
if (name.startsWith("OilResource"))
{
colour = &colourOil;
}
else if (name.startsWith("OilDrum"))
{
colour = &colourBarrel;
}
if (colour != NULL)
{
// and now we blit the color to the texture
xx = map_coord(pos.x);
yy = map_coord(pos.y);
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx)] = color.byte.r;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx) + 1] = color.byte.g;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx) + 2] = color.byte.b;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx)] = colour->byte.r;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx) + 1] = colour->byte.g;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx) + 2] = colour->byte.b;
}
ini.endGroup();
}
Expand Down Expand Up @@ -6655,20 +6665,26 @@ static void plotFeature(char *backDropSprite)
psSaveFeature = (SAVE_FEATURE_V2*) pFileData;

// we only care about oil
PIELIGHT const *colour = NULL;
if (strncmp(psSaveFeature->name, "OilResource", 11) == 0)
{
endian_udword(&psSaveFeature->x);
endian_udword(&psSaveFeature->y);
xx = map_coord(psSaveFeature->x);
yy = map_coord(psSaveFeature->y);
colour = &colourOil;
}
else if (strncmp(psSaveFeature->name, "OilDrum", 7) == 0)
{
colour = &colourBarrel;
}
else
{
continue;
}
endian_udword(&psSaveFeature->x);
endian_udword(&psSaveFeature->y);
xx = map_coord(psSaveFeature->x);
yy = map_coord(psSaveFeature->y);
// and now we blit the color to the texture
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx)] = color.byte.r;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx) + 1] = color.byte.g;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx) + 2] = color.byte.b;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx)] = colour->byte.r;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx) + 1] = colour->byte.g;
backDropSprite[3 * ((yy * BACKDROP_HACK_WIDTH) + xx) + 2] = colour->byte.b;
}
}

0 comments on commit 5b07a7b

Please sign in to comment.