mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-30 18:04:09 +03:00
Remove unnecessary Sint16 casts
These casts are sprinkled all throughout the graphics code when creating and initializing an SDL_Rect on the same line. Unfortunately, most of these are unnecessary, and at worst are wasteful because they result in narrowing a 4-byte integer into a 2-byte one when they don't need to (SDL_Rects are made up of 4-byte integers). Now, removing them reveals why they were placed there in the first place - a warning is raised (-Wnarrowing) that implicit narrowing conversions are prohibited in initializer lists in C++11. (Notably, if the conversion wasn't narrowing, or implicit, or done in an initializer list, it would be fine. This is a really specific prohibition that doesn't apply if any of its sub-cases are true.) We don't use C++11, but this warning can be easily vanquished by a simple explicit cast to int (similar to the error of implicitly converting void* to any other pointer in C++, which works just fine in C), and we only need to do it when the warning is raised (not every single time we make an SDL_Rect), so there we go.
This commit is contained in:
@@ -382,7 +382,7 @@ SDL_Surface* ApplyFilter( SDL_Surface* _src )
|
||||
|
||||
void FillRect( SDL_Surface* _surface, const int _x, const int _y, const int _w, const int _h, const int r, int g, int b )
|
||||
{
|
||||
SDL_Rect rect = {Sint16(_x),Sint16(_y),Sint16(_w),Sint16(_h)};
|
||||
SDL_Rect rect = {_x, _y, _w, _h};
|
||||
Uint32 color = SDL_MapRGB(_surface->format, r, g, b);
|
||||
SDL_FillRect(_surface, &rect, color);
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void FillRect( SDL_Surface* _surface, const int color )
|
||||
|
||||
void FillRect( SDL_Surface* _surface, const int x, const int y, const int w, const int h, int rgba )
|
||||
{
|
||||
SDL_Rect rect = {Sint16(x) ,Sint16(y) ,Sint16(w) ,Sint16(h) };
|
||||
SDL_Rect rect = {x, y, w, h};
|
||||
SDL_FillRect(_surface, &rect, rgba);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user