Fixed game crash when two vehicles crash
This commit is contained in:
@@ -163,9 +163,9 @@ public:
|
||||
*/
|
||||
static inline Colour16 MakeGrey(Colour16 colour)
|
||||
{
|
||||
uint r = colour.r;
|
||||
uint g = colour.g;
|
||||
uint b = colour.b;
|
||||
uint8 r = colour.r;
|
||||
uint8 g = colour.g;
|
||||
uint8 b = colour.b;
|
||||
|
||||
/* To avoid doubles and stuff, multiple it with a total of 65536 (16bits), then
|
||||
* divide by it to normalize the value to a byte again. See heightmap.cpp for
|
||||
@@ -175,6 +175,23 @@ public:
|
||||
return To16(grey, grey, grey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a colour dark grey, for specialized 32bpp remapping.
|
||||
* @param r red component
|
||||
* @param g green component
|
||||
* @param b blue component
|
||||
* @return the brightness value of the new colour, now dark grey.
|
||||
*/
|
||||
static inline uint8 MakeDark(Colour16 colour)
|
||||
{
|
||||
uint8 r = colour.r;
|
||||
uint8 g = colour.g;
|
||||
uint8 b = colour.b;
|
||||
|
||||
/* Magic-numbers are ~66% of those used in MakeGrey() */
|
||||
return (((r << 3) * 13063) + ((g << 2) * 25647) + ((b << 3) * 4981)) / 65536;
|
||||
}
|
||||
|
||||
enum { DEFAULT_BRIGHTNESS = 8 };
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,17 @@ void Blitter_16bppSimple::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
|
||||
}
|
||||
break;
|
||||
|
||||
case BM_CRASH_REMAP:
|
||||
if (src->m == 0) {
|
||||
if (src->a != 0) {
|
||||
uint8 g = MakeDark(src->c);
|
||||
*dst = ComposeColourRGBA(g, g, g, src->a, *dst);
|
||||
}
|
||||
} else {
|
||||
if (bp->remap[src->m] != 0) *dst = ComposeColourPA(AdjustBrightness(LookupColourInPalette(bp->remap[src->m]), src->v), src->a, *dst);
|
||||
}
|
||||
break;
|
||||
|
||||
case BM_TRANSPARENT:
|
||||
/* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
|
||||
* This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
|
||||
@@ -72,6 +83,7 @@ void Blitter_16bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
|
||||
case BM_NORMAL: Draw<BM_NORMAL> (bp, zoom); return;
|
||||
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
|
||||
case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
|
||||
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user