mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Fix char overflow in Analogue Mode
In aa7b63fa5f
, I didn't notice that the
result was implicitly being converted to int by the min/max from before.
I instead added it to the existing char, but that resulted in a char
overflow (it's unsigned, so thankfully not undefined behavior).
But of course the entire point of that commit is to make it explicitly
clear when you are converting between types, intentionally or otherwise,
in min/max comparisons. So despite causing a regression (which I have
now fixed), at least it did its job.
This commit is contained in:
parent
816a0b9eb7
commit
b7cbdfe8f9
1 changed files with 7 additions and 6 deletions
|
@ -336,6 +336,7 @@ SDL_Surface* ApplyFilter( SDL_Surface* _src )
|
|||
Uint8 red = (pixelOffset & _src->format->Rmask) >> 16 ;
|
||||
|
||||
double mult;
|
||||
int tmp; /* needed to avoid char overflow */
|
||||
if(isscrolling && sampley > 220 && ((rand() %10) < 4))
|
||||
{
|
||||
mult = 0.6;
|
||||
|
@ -345,12 +346,12 @@ SDL_Surface* ApplyFilter( SDL_Surface* _src )
|
|||
mult = 0.2;
|
||||
}
|
||||
|
||||
red += fRandom() * mult * 254;
|
||||
red = SDL_min(red, 255);
|
||||
green += fRandom() * mult * 254;
|
||||
green = SDL_min(green, 255);
|
||||
blue += fRandom() * mult * 254;
|
||||
blue = SDL_min(blue, 255);
|
||||
tmp = red + fRandom() * mult * 254;
|
||||
red = SDL_min(tmp, 255);
|
||||
tmp = green + fRandom() * mult * 254;
|
||||
green = SDL_min(tmp, 255);
|
||||
tmp = blue + fRandom() * mult * 254;
|
||||
blue = SDL_min(tmp, 255);
|
||||
|
||||
if(y % 2 == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue