ref: 9398314af60cc03063f3182eff05d00d4e9a6a78
parent: c8630a8669a23912b629ed7389500bf0ce9f4e48
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon May 13 11:42:22 EDT 2019
Shut up some MSVC2003 warnings, and comment on another one I'm not fixing that last one, since I'd rather futureproof the code in the event the SDL2 devs update the function to use size_t.
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -358,6 +358,9 @@
if (data)
{
+ // For some dumbass reason, SDL2 measures size with a signed int.
+ // Has anyone ever told the devs that an int can be as little as 16 bits long? Real portable.
+ // But hey, if I ever need to create an RWops from an array that's -32768 bytes long, they've got me covered!
SDL_RWops *fp = SDL_RWFromConstMem(data, size);
printf("Loading surface from resource %s for surface id %d\n", res, surf_no);
@@ -490,9 +493,9 @@
SDL_Rect destRect = RectToSDLRectScaled(rect);
// Set colour and draw
- const unsigned char col_red = col & 0x0000FF;
- const unsigned char col_green = (col & 0x00FF00) >> 8;
- const unsigned char col_blue = (col & 0xFF0000) >> 16;
+ const unsigned char col_red = (unsigned char)(col & 0xFF);
+ const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF);
+ const unsigned char col_blue = (unsigned char)((col >> 16) & 0xFF);
SDL_SetRenderDrawColor(gRenderer, col_red, col_green, col_blue, 0xFF);
SDL_RenderFillRect(gRenderer, &destRect);
}
@@ -503,9 +506,9 @@
SDL_Rect destRect = RectToSDLRectScaled(rect);
// Set colour and draw
- const unsigned char col_red = col & 0x0000FF;
- const unsigned char col_green = (col & 0x00FF00) >> 8;
- const unsigned char col_blue = (col & 0xFF0000) >> 16;
+ const unsigned char col_red = (unsigned char)(col & 0xFF);
+ const unsigned char col_green = (unsigned char)((col >> 8) & 0xFF);
+ const unsigned char col_blue = (unsigned char)((col >> 16) & 0xFF);
SDL_FillRect(surf[surf_no].surface, &destRect, SDL_MapRGB(surf[surf_no].surface->format, col_red, col_green, col_blue));
surf[surf_no].needs_updating = true;
}