diff options
author | alberth <alberth@openttd.org> | 2009-06-27 20:53:45 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2009-06-27 20:53:45 +0000 |
commit | 9b070b5405d11c74d89a747e912e627e39850f7c (patch) | |
tree | 5143dbacaa7e860b2253b091bd195f4e2d287efc /src | |
parent | 812ad41f23b7ed52a161ed15b15a2af3a7edb41f (diff) | |
download | openttd-9b070b5405d11c74d89a747e912e627e39850f7c.tar.xz |
(svn r16677) -Codechange: Dimension width and height are unsigned.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/geometry_type.hpp | 4 | ||||
-rw-r--r-- | src/gfx.cpp | 10 | ||||
-rw-r--r-- | src/misc_gui.cpp | 4 | ||||
-rw-r--r-- | src/openttd.cpp | 4 | ||||
-rw-r--r-- | src/settings_gui.cpp | 4 | ||||
-rw-r--r-- | src/strings.cpp | 2 | ||||
-rw-r--r-- | src/video/allegro_v.cpp | 12 | ||||
-rw-r--r-- | src/video/sdl_v.cpp | 14 | ||||
-rw-r--r-- | src/video/win32_v.cpp | 4 |
9 files changed, 29 insertions, 29 deletions
diff --git a/src/core/geometry_type.hpp b/src/core/geometry_type.hpp index 6258ffd1d..db8083538 100644 --- a/src/core/geometry_type.hpp +++ b/src/core/geometry_type.hpp @@ -25,8 +25,8 @@ struct Point { /** Dimensions (a width and height) of a rectangle in 2D */ struct Dimension { - int width; - int height; + uint width; + uint height; }; /** Specification of a rectangle with absolute coordinates of all edges */ diff --git a/src/gfx.cpp b/src/gfx.cpp index c67dba176..482427a72 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -483,7 +483,7 @@ static int DrawString(int left, int right, int top, char *str, const char *last, * but once SETX is used you cannot be sure the actual content of the * string is centered, so it doesn't really matter. */ align = SA_LEFT | SA_FORCE; - initial_left = left = max(left, (left + right - GetStringBoundingBox(str).width) / 2); + initial_left = left = max(left, (left + right - (int)GetStringBoundingBox(str).width) / 2); } /* We add the begin of the string, but don't add it twice */ @@ -798,7 +798,7 @@ Dimension GetStringBoundingBox(const char *str) { FontSize size = _cur_fontsize; Dimension br; - int max_width; + uint max_width; WChar c; br.width = br.height = max_width = 0; @@ -809,10 +809,10 @@ Dimension GetStringBoundingBox(const char *str) br.width += GetCharacterWidth(size, c); } else { switch (c) { - case SCC_SETX: br.width = max((int)*str++, br.width); break; + case SCC_SETX: br.width = max((uint)*str++, br.width); break; case SCC_SETXY: - br.width = max((int)*str++, br.width); - br.height = max((int)*str++, br.height); + br.width = max((uint)*str++, br.width); + br.height = max((uint)*str++, br.height); break; case SCC_TINYFONT: size = FS_SMALL; break; case SCC_BIGFONT: size = FS_LARGE; break; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index bead99f04..4ebdb53ec 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -802,8 +802,8 @@ void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], bool * Clamp value to below main toolbar and above statusbar. If tooltip would * go below window, flip it so it is shown above the cursor */ int y = Clamp(_cursor.pos.y + _cursor.size.y + _cursor.offs.y + 5, 22, _screen.height - 12); - if (y + br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - br.height - 5; - int x = Clamp(_cursor.pos.x - (br.width >> 1), 0, _screen.width - br.width); + if (y + (int)br.height > _screen.height - 12) y = _cursor.pos.y + _cursor.offs.y - (int)br.height - 5; + int x = Clamp(_cursor.pos.x - (int)(br.width >> 1), 0, _screen.width - (int)br.width); const Widget *wid = InitializeWidgetArrayFromNestedWidgets(_nested_tooltips_widgets, lengthof(_nested_tooltips_widgets), _tooltips_widgets, &generated_tooltips_widgets); diff --git a/src/openttd.cpp b/src/openttd.cpp index 1dc8eb73c..9f9fd127d 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -555,8 +555,8 @@ int ttd_main(int argc, char *argv[]) /* The width and height must be at least 1 pixel, this * way all internal drawing routines work correctly. */ - if (_cur_resolution.width <= 0) _cur_resolution.width = 1; - if (_cur_resolution.height <= 0) _cur_resolution.height = 1; + if (_cur_resolution.width == 0) _cur_resolution.width = 1; + if (_cur_resolution.height == 0) _cur_resolution.height = 1; #if defined(ENABLE_NETWORK) if (dedicated_host) { diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index b276eaf13..da247b73c 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -89,8 +89,8 @@ static int GetCurRes() int i; for (i = 0; i != _num_resolutions; i++) { - if (_resolutions[i].width == _screen.width && - _resolutions[i].height == _screen.height) { + if ((int)_resolutions[i].width == _screen.width && + (int)_resolutions[i].height == _screen.height) { break; } } diff --git a/src/strings.cpp b/src/strings.cpp index 861efedf2..edf7d8819 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1210,7 +1210,7 @@ static char *GetSpecialNameString(char *buff, int ind, int64 *argv, const char * if (IsInsideMM(ind, (SPECSTR_RESOLUTION_START - 0x70E4), (SPECSTR_RESOLUTION_END - 0x70E4) + 1)) { int i = ind - (SPECSTR_RESOLUTION_START - 0x70E4); buff += seprintf( - buff, last, "%dx%d", _resolutions[i].width, _resolutions[i].height + buff, last, "%ux%u", _resolutions[i].width, _resolutions[i].height ); return buff; } diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 0e90daf90..de0a08eed 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -137,8 +137,8 @@ static void GetVideoModes() int n = 0; for (int i = 0; modes[i].bpp != 0; i++) { - int w = modes[i].width; - int h = modes[i].height; + uint w = modes[i].width; + uint h = modes[i].height; if (w >= 640 && h >= 480) { int j; for (j = 0; j < n; j++) { @@ -158,7 +158,7 @@ static void GetVideoModes() destroy_gfx_mode_list(mode_list); } -static void GetAvailableVideoMode(int *w, int *h) +static void GetAvailableVideoMode(uint *w, uint *h) { /* No video modes, so just try it and see where it ends */ if (_num_resolutions == 0) return; @@ -170,9 +170,9 @@ static void GetAvailableVideoMode(int *w, int *h) /* use the closest possible resolution */ int best = 0; - uint delta = abs((_resolutions[0].width - *w) * (_resolutions[0].height - *h)); + uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h); for (int i = 1; i != _num_resolutions; ++i) { - uint newdelta = abs((_resolutions[i].width - *w) * (_resolutions[i].height - *h)); + uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h); if (newdelta < delta) { best = i; delta = newdelta; @@ -182,7 +182,7 @@ static void GetAvailableVideoMode(int *w, int *h) *h = _resolutions[best].height; } -static bool CreateMainSurface(int w, int h) +static bool CreateMainSurface(uint w, uint h) { int bpp = BlitterFactoryBase::GetCurrentBlitter()->GetScreenDepth(); if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals"); diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 932832699..f00ab10bc 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -124,8 +124,8 @@ static void GetVideoModes() } else { int n = 0; for (int i = 0; modes[i]; i++) { - int w = modes[i]->w; - int h = modes[i]->h; + uint w = modes[i]->w; + uint h = modes[i]->h; int j; for (j = 0; j < n; j++) { if (_resolutions[j].width == w && _resolutions[j].height == h) break; @@ -142,7 +142,7 @@ static void GetVideoModes() } } -static void GetAvailableVideoMode(int *w, int *h) +static void GetAvailableVideoMode(uint *w, uint *h) { /* All modes available? */ if (_all_modes || _num_resolutions == 0) return; @@ -154,9 +154,9 @@ static void GetAvailableVideoMode(int *w, int *h) /* Use the closest possible resolution */ int best = 0; - uint delta = abs((_resolutions[0].width - *w) * (_resolutions[0].height - *h)); + uint delta = Delta(_resolutions[0].width, *w) * Delta(_resolutions[0].height, *h); for (int i = 1; i != _num_resolutions; ++i) { - uint newdelta = abs((_resolutions[i].width - *w) * (_resolutions[i].height - *h)); + uint newdelta = Delta(_resolutions[i].width, *w) * Delta(_resolutions[i].height, *h); if (newdelta < delta) { best = i; delta = newdelta; @@ -177,7 +177,7 @@ static void GetAvailableVideoMode(int *w, int *h) #define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_CALL SDL_RWFromFile(file, "rb"), 1) #endif -static bool CreateMainSurface(int w, int h) +static bool CreateMainSurface(uint w, uint h) { SDL_Surface *newscreen, *icon; char caption[50]; @@ -185,7 +185,7 @@ static bool CreateMainSurface(int w, int h) GetAvailableVideoMode(&w, &h); - DEBUG(driver, 1, "SDL: using mode %dx%dx%d", w, h, bpp); + DEBUG(driver, 1, "SDL: using mode %ux%ux%d", w, h, bpp); if (bpp == 0) usererror("Can't use a blitter that blits 0 bpp for normal visuals"); diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index d3adb5723..b5e79b493 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -738,7 +738,7 @@ static void FindResolutions() uint j; for (j = 0; j < n; j++) { - if (_resolutions[j].width == (int)dm.dmPelsWidth && _resolutions[j].height == (int)dm.dmPelsHeight) break; + if (_resolutions[j].width == dm.dmPelsWidth && _resolutions[j].height == dm.dmPelsHeight) break; } /* In the previous loop we have checked already existing/added resolutions if @@ -776,7 +776,7 @@ const char *VideoDriver_Win32::Start(const char * const *parm) FindResolutions(); - DEBUG(driver, 2, "Resolution for display: %dx%d", _cur_resolution.width, _cur_resolution.height); + DEBUG(driver, 2, "Resolution for display: %ux%u", _cur_resolution.width, _cur_resolution.height); /* fullscreen uses those */ _wnd.width_org = _cur_resolution.width; |