diff --git a/.travis.yml b/.travis.yml index c7ff08eaa..f457d5f99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ git: matrix: include: - os: osx - osx_image: xcode9.1 + osx_image: xcode9.2 env: - CMAKE_OPTIONS="-DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7" diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 154720022..a773373ef 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -342,10 +342,9 @@ void GLSprite::Draw(int pass) sector_t *cursec = actor ? actor->Sector : particle ? particle->subsector->sector : nullptr; if (cursec != nullptr) { - PalEntry finalcol(ThingColor.a, - ThingColor.r * cursec->SpecialColors[sector_t::sprites].r / 255, - ThingColor.g * cursec->SpecialColors[sector_t::sprites].g / 255, - ThingColor.b * cursec->SpecialColors[sector_t::sprites].b / 255); + const PalEntry finalcol = fullbright + ? ThingColor + : ThingColor.Modulate(cursec->SpecialColors[sector_t::sprites]); gl_RenderState.SetObjectColor(finalcol); } diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 3d4224520..69551f28a 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -385,18 +385,18 @@ void GLSceneDrawer::DrawPlayerSprites(sector_t * viewsector, bool hudModelStep) // now draw the different layers of the weapon. // For stencil render styles brightmaps need to be disabled. gl_RenderState.EnableBrightmap(!(RenderStyle.Flags & STYLEF_ColorIsFixed)); - PalEntry finalcol(ThingColor.a, - ThingColor.r * viewsector->SpecialColors[sector_t::sprites].r / 255, - ThingColor.g * viewsector->SpecialColors[sector_t::sprites].g / 255, - ThingColor.b * viewsector->SpecialColors[sector_t::sprites].b / 255); + const bool bright = isBright(psp); + const PalEntry finalcol = bright + ? ThingColor + : ThingColor.Modulate(viewsector->SpecialColors[sector_t::sprites]); gl_RenderState.SetObjectColor(finalcol); if (psp->GetState() != nullptr) { FColormap cmc = cm; int ll = lightlevel; - if (isBright(psp)) + if (bright) { if (fakesec == viewsector || in_area != area_below) { @@ -487,4 +487,4 @@ void GLSceneDrawer::DrawTargeterSprites() { if (psp->GetState() != nullptr) DrawPSprite(player, psp, psp->x, psp->y, false, 0, false); } -} \ No newline at end of file +} diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index d8af38b11..2313d573d 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -78,6 +78,30 @@ const uint8_t IcePalette[16][3] = { 148,148,172 } }; +static bool IndexOutOfRange(const int color) +{ + const bool outOfRange = color < 0 || color > 255; + + if (outOfRange) + { + Printf("Palette index %i is out of range [0..255]\n", color); + } + + return outOfRange; +} + +static bool IndexOutOfRange(const int start, const int end) +{ + const bool outOfRange = IndexOutOfRange(start); + return IndexOutOfRange(end) || outOfRange; +} + +static bool IndexOutOfRange(const int start1, const int end1, const int start2, const int end2) +{ + const bool outOfRange = IndexOutOfRange(start1, end1); + return IndexOutOfRange(start2, end2) || outOfRange; +} + /****************************************************/ /****************************************************/ @@ -348,6 +372,11 @@ FNativePalette *FRemapTable::GetNative() void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2) { + if (IndexOutOfRange(start, end, pal1, pal2)) + { + return; + } + double palcol, palstep; if (start > end) @@ -368,7 +397,7 @@ void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2) palstep = (pal2 - palcol) / (end - start); for (int i = start; i <= end; palcol += palstep, ++i) { - int j = GPalette.Remap[i], k = GPalette.Remap[int(palcol)]; + int j = GPalette.Remap[i], k = GPalette.Remap[int(round(palcol))]; Remap[j] = k; Palette[j] = GPalette.BaseColors[k]; Palette[j].a = j == 0 ? 0 : 255; @@ -383,6 +412,11 @@ void FRemapTable::AddIndexRange(int start, int end, int pal1, int pal2) void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, int _r2, int _g2, int _b2) { + if (IndexOutOfRange(start, end)) + { + return; + } + double r1 = _r1; double g1 = _g1; double b1 = _b1; @@ -442,6 +476,11 @@ void FRemapTable::AddColorRange(int start, int end, int _r1,int _g1, int _b1, in void FRemapTable::AddDesaturation(int start, int end, double r1, double g1, double b1, double r2, double g2, double b2) { + if (IndexOutOfRange(start, end)) + { + return; + } + r1 = clamp(r1, 0.0, 2.0); g1 = clamp(g1, 0.0, 2.0); b1 = clamp(b1, 0.0, 2.0); @@ -490,6 +529,11 @@ void FRemapTable::AddDesaturation(int start, int end, double r1, double g1, doub void FRemapTable::AddColourisation(int start, int end, int r, int g, int b) { + if (IndexOutOfRange(start, end)) + { + return; + } + for (int i = start; i < end; ++i) { double br = GPalette.BaseColors[i].r; @@ -515,6 +559,11 @@ void FRemapTable::AddColourisation(int start, int end, int r, int g, int b) void FRemapTable::AddTint(int start, int end, int r, int g, int b, int amount) { + if (IndexOutOfRange(start, end)) + { + return; + } + for (int i = start; i < end; ++i) { float br = GPalette.BaseColors[i].r;