Skip to content

Commit

Permalink
Fix some of -Wnarrowing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
AMDmi3 committed Dec 14, 2012
1 parent 472cf22 commit 22cb269
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions include/GfxPrimitives.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ bool OneSideClip(T1& c, T2& d, const T3 clip_c, const T4 clip_d) {
// Create a SDL rect
INLINE SDL_Rect MakeRect(int x, int y, int w, int h)
{
SDL_Rect r = {x, y, w, h};
SDL_Rect r = {(Sint16)x, (Sint16)y, (Uint16)w, (Uint16)h};
return r;
}

Expand Down Expand Up @@ -408,8 +408,8 @@ INLINE void DrawImageAdv(SDL_Surface * bmpDest, const SmartPointer<SDL_Surface>
//////////////
// Draw the image with a huge amount of options
INLINE void DrawImageAdv(SDL_Surface * bmpDest, SDL_Surface * bmpSrc, int sx, int sy, int dx, int dy, int w, int h) {
SDL_Rect r1 = { dx, dy, 0, 0 };
SDL_Rect r2 = { sx, sy, w, h };
SDL_Rect r1 = { (Sint16)dx, (Sint16)dy, 0, 0 };
SDL_Rect r2 = { (Sint16)sx, (Sint16)sy, (Uint16)w, (Uint16)h };
DrawImageAdv( bmpDest, bmpSrc, r1, r2);
}
INLINE void DrawImageAdv(SDL_Surface * bmpDest, const SmartPointer<SDL_Surface> & bmpSrc, int sx, int sy, int dx, int dy, int w, int h) {
Expand All @@ -433,7 +433,7 @@ INLINE void DrawImage(SDL_Surface * bmpDest, SDL_Surface * bmpSrc, SDL_Rect& rDe
errors << "DrawImage: bmpSrc == NULL" << endl;
return;
}
SDL_Rect rSource = { 0, 0, bmpSrc->w, bmpSrc->h };
SDL_Rect rSource = { 0, 0, (Uint16)bmpSrc->w, (Uint16)bmpSrc->h };
DrawImageAdv(bmpDest, bmpSrc, rDest, rSource);
}
INLINE void DrawImage(SDL_Surface * bmpDest, const SmartPointer<SDL_Surface> & bmpSrc, SDL_Rect& rDest) {
Expand All @@ -443,7 +443,7 @@ INLINE void DrawImage(SDL_Surface * bmpDest, const SmartPointer<SDL_Surface> & b
///////////////
// Simply draw the image
INLINE void DrawImage(SDL_Surface * bmpDest, SDL_Surface * bmpSrc, int x, int y) {
SDL_Rect r = { x, y, 0, 0 };
SDL_Rect r = { (Sint16)x, (Sint16)y, 0, 0 };
DrawImage( bmpDest, bmpSrc, r);
}
INLINE void DrawImage(SDL_Surface * bmpDest, const SmartPointer<SDL_Surface> & bmpSrc, int x, int y) {
Expand Down
2 changes: 1 addition & 1 deletion include/SkinnedGUI/CGuiSkinnedLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class CGuiSkinnedLayout: public CContainerWidget
virtual void MoveTo( int x, int y );
virtual void Resize( int x, int y, int w, int h);

SDL_Rect getClientRect() { SDL_Rect r = { iClientX, iClientY, iClientWidth, iClientHeight }; return r; }
SDL_Rect getClientRect() { SDL_Rect r = { (Sint16)iClientX, (Sint16)iClientY, (Uint16)iClientWidth, (Uint16)iClientHeight }; return r; }

void incModalsRunning();
void decModalsRunning();
Expand Down
2 changes: 1 addition & 1 deletion include/SkinnedGUI/CWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class CWidget {

WidgetType getType() { return iType; }

SDL_Rect getRect() { SDL_Rect r = { getX(), getY(), getWidth(), getHeight() }; return r; }
SDL_Rect getRect() { SDL_Rect r = { (Sint16)getX(), (Sint16)getY(), (Uint16)getWidth(), (Uint16)getHeight() }; return r; }

const std::string& getName() { return sName; }
void setName(const std::string& _n) { sName = _n; }
Expand Down
2 changes: 1 addition & 1 deletion src/client/CClient_Draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2681,7 +2681,7 @@ void CClient::DrawPlayerWaitingColumn(SDL_Surface * bmpDest, int x, int y, std::
{
const int h = getBottomBarTop() - y;

SDL_Rect newclip = {x, y, WAIT_COL_W, h};
SDL_Rect newclip = { (Sint16)x, (Sint16)y, (Uint16)WAIT_COL_W, (Uint16)h };
ScopedSurfaceClip clip(bmpDest, newclip);

DrawRectFill(bmpDest, x, y, x + WAIT_COL_W, y + h, tLX->clScoreBackground);
Expand Down
12 changes: 6 additions & 6 deletions src/client/GfxPrimitives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ void DrawImageAdv(SDL_Surface * bmpDest, SDL_Surface * bmpSrc, SDL_Rect& rDest,
// Draw the image tiled on the dest surface
void DrawImageTiled(SDL_Surface *bmpDest, SDL_Surface *bmpSrc, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
{
SDL_Rect newClip = {dx,dy,dw,dh};
SDL_Rect newClip = { (Sint16)dx, (Sint16)dy, (Uint16)dw, (Uint16)dh };
ScopedSurfaceClip clip(bmpDest,newClip);
MOD(sx, (int)bmpSrc->w); MOD(sy, (int)bmpSrc->h);

Expand Down Expand Up @@ -1256,8 +1256,8 @@ void DrawImageResampledAdv(SDL_Surface * bmpDest, SDL_Surface * bmpSrc, int sx,
{
if(!bmpSrc || !bmpDest) return;

SDL_Rect src = { sx, sy, sw, sh };
SDL_Rect dst = { dx, dy, (int)((float)sw * xratio), (int)((float)sh * yratio) };
SDL_Rect src = { (Sint16)sx, (Sint16)sy, (Uint16)sw, (Uint16)sh };
SDL_Rect dst = { (Sint16)dx, (Sint16)dy, (Uint16)((float)sw * xratio), (Uint16)((float)sh * yratio) };

// Source clipping
if (!ClipRefRectWith((SDLRect&)src, (SDLRect&)bmpSrc->clip_rect))
Expand All @@ -1277,8 +1277,8 @@ void DrawImageResampledAdv(SDL_Surface * bmpDest, SDL_Surface * bmpSrc, int sx,
{
if(!bmpSrc || !bmpDest) return;

SDL_Rect src = { sx, sy, sw, sh };
SDL_Rect dst = { dx, dy, dw, dh };
SDL_Rect src = { (Sint16)sx, (Sint16)sy, (Uint16)sw, (Uint16)sh };
SDL_Rect dst = { (Sint16)dx, (Sint16)dy, (Uint16)dw, (Uint16)dh };

// Source clipping
if (!ClipRefRectWith((SDLRect&)src, (SDLRect&)bmpSrc->clip_rect))
Expand Down Expand Up @@ -2348,7 +2348,7 @@ static void DrawRectFill_Overlay(SDL_Surface *bmpDest, const SDL_Rect& r, Color
// Draws a filled rectangle
void DrawRectFill(SDL_Surface *bmpDest, int x, int y, int x2, int y2, Color color)
{
SDL_Rect r = { x, y, x2 - x, y2 - y };
SDL_Rect r = { (Sint16)x, (Sint16)y, (Uint16)(x2 - x), (Uint16)(y2 - y) };

switch (color.a) {
case SDL_ALPHA_OPAQUE:
Expand Down
10 changes: 5 additions & 5 deletions src/client/SkinnedGUI/CListview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ CWidgetSubitem::~CWidgetSubitem()
SDL_Rect CWidgetSubitem::getWidgetRect(int item_h)
{
CItemStyle *style = getCurrentStyle();
SDL_Rect r = {style->cBorder.getLeftW(), 0, cWidget->getWidth(), cWidget->getHeight()};
SDL_Rect r = { (Sint16)style->cBorder.getLeftW(), 0, (Uint16)cWidget->getWidth(), (Uint16)cWidget->getHeight()};
switch (iVAlign) {
case algTop:
r.y = style->cBorder.getTopW();
Expand Down Expand Up @@ -412,10 +412,10 @@ void CListviewColumn::Draw(SDL_Surface *bmpDest, int x, int y, int w, int h)
style->cBackground.Draw(bmpDest, x, y, w, h);

// Text
SDL_Rect r = {x + style->cBorder.getLeftW(), y + style->cBorder.getTopW(),
w - ((style->bmpSortArrow.get().get() && iSortDirection != sort_None) ? style->bmpSortArrow->w : 0) -
style->cBorder.getLeftW() - style->cBorder.getRightW(),
h - style->cBorder.getTopW() - style->cBorder.getBottomW()};
SDL_Rect r = { (Sint16)(x + style->cBorder.getLeftW()), (Sint16)(y + style->cBorder.getTopW()),
(Uint16)(w - ((style->bmpSortArrow.get().get() && iSortDirection != sort_None) ? style->bmpSortArrow->w : 0) -
style->cBorder.getLeftW() - style->cBorder.getRightW()),
(Uint16)(h - style->cBorder.getTopW() - style->cBorder.getBottomW()) };

style->cText.tFontRect = &r;
DrawGameText(bmpDest, sText, style->cFont, style->cText);
Expand Down
6 changes: 3 additions & 3 deletions src/gusanos/allegro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void rectfill(ALLEGRO_BITMAP *bmp, int x1, int y1, int x2, int y2, Uint32 color)
sub_to_abs_coords(bmp, x2, y2);
if(bmp->surf->format->BitsPerPixel == 8) {
// currently, DrawRectFill cannot handle 8bit and/or allegcol_to_Col is wrong
SDL_Rect r = { x1, y1, x2-x1, y2-y1 };
SDL_Rect r = { (Sint16)x1, (Sint16)y1, (Uint16)(x2-x1), (Uint16)(y2-y1) };
SDL_FillRect(bmp->surf.get(), &r, color);
}
else
Expand Down Expand Up @@ -425,8 +425,8 @@ void dumpUsedColors(SDL_Surface* surf) {
void blit(ALLEGRO_BITMAP *source, ALLEGRO_BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height) {
sub_to_abs_coords(source, source_x, source_y);
sub_to_abs_coords(dest, dest_x, dest_y);
SDL_Rect srcrect = { source_x, source_y, width, height };
SDL_Rect dstrect = { dest_x, dest_y, width, height };
SDL_Rect srcrect = { (Sint16)source_x, (Sint16)source_y, (Uint16)width, (Uint16)height };
SDL_Rect dstrect = { (Sint16)dest_x, (Sint16)dest_y, (Uint16)width, (Uint16)height };
DrawImageAdv(dest->surf.get(), source->surf.get(), dstrect, srcrect);
// This doesn' work. We need colorkey handling:
// CopySurface(dest->surf.get(), source->surf.get(), source_x, source_y, dest_x, dest_y, width, height);
Expand Down

0 comments on commit 22cb269

Please sign in to comment.