diff options
author | truelight <truelight@openttd.org> | 2007-05-14 15:20:50 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2007-05-14 15:20:50 +0000 |
commit | d7b4fb80d0e14ca3f8d56cda920e7f0d4e81419d (patch) | |
tree | 8b4e24cad04a15b76b5449bbb993f8b8fa1dccca | |
parent | 62fe9c2e420238ba4db54f8cf56afc25b1167051 (diff) | |
download | openttd-d7b4fb80d0e14ca3f8d56cda920e7f0d4e81419d.tar.xz |
(svn r9835) -Codechange: use Pixel typedef instead of byte where ever possible
-rw-r--r-- | src/gfx.cpp | 12 | ||||
-rw-r--r-- | src/screenshot.cpp | 2 | ||||
-rw-r--r-- | src/video/dedicated_v.cpp | 6 | ||||
-rw-r--r-- | src/video/null_v.cpp | 6 | ||||
-rw-r--r-- | src/video/sdl_v.cpp | 2 | ||||
-rw-r--r-- | src/video/win32_v.cpp | 2 |
6 files changed, 15 insertions, 15 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp index fa7fc671f..a37343720 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -64,12 +64,12 @@ static byte _dirty_blocks[DIRTY_BYTES_PER_LINE * MAX_SCREEN_HEIGHT / 8]; void memcpy_pitch(void *dst, void *src, int w, int h, int srcpitch, int dstpitch) { - byte *dstp = (byte*)dst; - byte *srcp = (byte*)src; + Pixel *dstp = (Pixel *)dst; + Pixel *srcp = (Pixel *)src; assert(h >= 0); for (; h != 0; --h) { - memcpy(dstp, srcp, w); + memcpy(dstp, srcp, w * sizeof(Pixel)); dstp += dstpitch; srcp += srcpitch; } @@ -110,7 +110,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo) } for (ht = height; ht > 0; --ht) { - memcpy(dst, src, width); + memcpy(dst, src, width * sizeof(Pixel)); src -= p; dst -= p; } @@ -136,7 +136,7 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo) /* the y-displacement may be 0 therefore we have to use memmove, * because source and destination may overlap */ for (ht = height; ht > 0; --ht) { - memmove(dst, src, width); + memmove(dst, src, width * sizeof(Pixel)); src += p; dst += p; } @@ -175,7 +175,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int color) if (!HASBIT(color, PALETTE_MODIFIER_GREYOUT)) { if (!HASBIT(color, USE_COLORTABLE)) { do { - memset(dst, color, right); + memset(dst, color, right * sizeof(Pixel)); dst += dpi->pitch; } while (--bottom); } else { diff --git a/src/screenshot.cpp b/src/screenshot.cpp index c2903699b..9cbaad628 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -449,7 +449,7 @@ void SetScreenshotFormat(int i) static void CurrentScreenCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n) { for (; n > 0; --n) { - memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width); + memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width * sizeof(Pixel)); ++y; buf += pitch; } diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index b3e11a118..046dc2ac8 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -112,7 +112,7 @@ static void CloseWindowsConsoleThread() #endif -static void *_dedicated_video_mem; +static Pixel *_dedicated_video_mem; extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm); extern void SwitchMode(int new_mode); @@ -122,7 +122,7 @@ static const char *DedicatedVideoStart(const char * const *parm) { _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; - _dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]); + _dedicated_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel)); SetDebugString("net=6"); @@ -283,7 +283,7 @@ static void DedicatedVideoMainLoop() next_tick = cur_ticks + 30; GameLoop(); - _screen.dst_ptr = (Pixel*)_dedicated_video_mem; + _screen.dst_ptr = _dedicated_video_mem; UpdateWindows(); } CSleep(1); diff --git a/src/video/null_v.cpp b/src/video/null_v.cpp index cae43bc0c..fd15954d9 100644 --- a/src/video/null_v.cpp +++ b/src/video/null_v.cpp @@ -7,13 +7,13 @@ #include "../window.h" #include "null_v.h" -static void* _null_video_mem = NULL; +static Pixel *_null_video_mem = NULL; static const char* NullVideoStart(const char* const* parm) { _screen.width = _screen.pitch = _cur_resolution[0]; _screen.height = _cur_resolution[1]; - _null_video_mem = malloc(_cur_resolution[0] * _cur_resolution[1]); + _null_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel)); return NULL; } @@ -27,7 +27,7 @@ static void NullVideoMainLoop() for (i = 0; i < 1000; i++) { GameLoop(); - _screen.dst_ptr = (Pixel*)_null_video_mem; + _screen.dst_ptr = _null_video_mem; UpdateWindows(); } } diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 668d993b4..9a70b55a6 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -195,7 +195,7 @@ static bool CreateMainSurface(int w, int h) _screen.width = newscreen->w; _screen.height = newscreen->h; - _screen.pitch = newscreen->pitch; + _screen.pitch = newscreen->pitch / sizeof(Pixel); _sdl_screen = newscreen; InitPalette(); diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 578f323c9..cee533c7c 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -671,7 +671,7 @@ static bool AllocateDibSection(int w, int h) if (_wnd.double_size) { w = ALIGN(w, 4); - _wnd.alloced_bits = _wnd.buffer_bits = (Pixel*)malloc(w * h); + _wnd.alloced_bits = _wnd.buffer_bits = (Pixel *)malloc(w * h * sizeof(Pixel)); w *= 2; h *= 2; } |