Mercurial > hg > openttd
changeset 18358:90d7214be2a3 draft
(svn r23194) -Codechange: don't cast away const needlessly
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 12 Nov 2011 08:26:30 +0000 |
parents | 21b01031dbd7 |
children | 58955df25ef4 |
files | src/3rdparty/squirrel/squirrel/sqdebug.cpp src/3rdparty/squirrel/squirrel/sqvm.cpp src/3rdparty/squirrel/squirrel/sqvm.h src/blitter/32bpp_anim.cpp src/blitter/32bpp_base.cpp src/blitter/32bpp_base.hpp src/blitter/32bpp_optimized.cpp src/blitter/8bpp_base.cpp src/blitter/8bpp_base.hpp src/blitter/base.hpp src/blitter/null.hpp |
diffstat | 11 files changed, 25 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/3rdparty/squirrel/squirrel/sqdebug.cpp +++ b/src/3rdparty/squirrel/squirrel/sqdebug.cpp @@ -91,7 +91,7 @@ } } -void SQVM::Raise_IdxError(SQObject &o) +void SQVM::Raise_IdxError(const SQObject &o) { SQObjectPtr oval = PrintObjVal(o); Raise_Error(_SC("the index '%.50s' does not exist"), _stringval(oval));
--- a/src/3rdparty/squirrel/squirrel/sqvm.cpp +++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp @@ -459,7 +459,7 @@ #define sarg1 (*(const_cast<SQInt32 *>(&_i_._arg1))) #define arg2 (_i_._arg2) #define arg3 (_i_._arg3) -#define sarg3 ((SQInteger)*((signed char *)&_i_._arg3)) +#define sarg3 ((SQInteger)*((const signed char *)&_i_._arg3)) SQRESULT SQVM::Suspend() { @@ -742,7 +742,7 @@ continue; case _OP_LOAD: TARGET = ci->_literals[arg1]; continue; case _OP_LOADINT: TARGET = (SQInteger)arg1; continue; - case _OP_LOADFLOAT: TARGET = *((SQFloat *)&arg1); continue; + case _OP_LOADFLOAT: TARGET = *((const SQFloat *)&arg1); continue; case _OP_DLOAD: TARGET = ci->_literals[arg1]; STK(arg2) = ci->_literals[arg3];continue; case _OP_TAILCALL: temp_reg = STK(arg1); @@ -1434,7 +1434,7 @@ _table(self)->Remove(key); } else { - Raise_IdxError((SQObject &)key); + Raise_IdxError((const SQObject &)key); return false; } }
--- a/src/3rdparty/squirrel/squirrel/sqvm.h +++ b/src/3rdparty/squirrel/squirrel/sqvm.h @@ -84,7 +84,7 @@ void Raise_Error(const SQChar *s, ...); void Raise_Error(SQObjectPtr &desc); - void Raise_IdxError(SQObject &o); + void Raise_IdxError(const SQObject &o); void Raise_CompareError(const SQObject &o1, const SQObject &o2); void Raise_ParamTypeError(SQInteger nparam,SQInteger typemask,SQInteger type);
--- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -44,7 +44,7 @@ const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); src_px++; - const uint8 *src_n_ln = src_n + *(uint32 *)src_n; + const uint8 *src_n_ln = src_n + *(const uint32 *)src_n; src_n += 4; uint32 *dst_end = dst + bp->skip_left; @@ -296,7 +296,7 @@ assert(!_screen_disable_anim); assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); uint32 *dst = (uint32 *)video; - uint32 *usrc = (uint32 *)src; + const uint32 *usrc = (const uint32 *)src; uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf; for (; height > 0; height--) { @@ -309,7 +309,7 @@ dst += _screen.pitch; /* Copy back the anim-buffer */ memcpy(anim_line, usrc, width * sizeof(uint8)); - usrc = (uint32 *)((uint8 *)usrc + width); + usrc = (const uint32 *)((const uint8 *)usrc + width); anim_line += this->anim_buf_width; /* Okay, it is *very* likely that the image we stored is using @@ -336,12 +336,12 @@ assert(!_screen_disable_anim); assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); uint32 *udst = (uint32 *)dst; - uint32 *src = (uint32 *)video; - uint8 *anim_line; + const uint32 *src = (const uint32 *)video; + const uint8 *anim_line; if (this->anim_buf == NULL) return; - anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf; + anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf; for (; height > 0; height--) { memcpy(udst, src, width * sizeof(uint32));
--- a/src/blitter/32bpp_base.cpp +++ b/src/blitter/32bpp_base.cpp @@ -12,7 +12,7 @@ #include "../stdafx.h" #include "32bpp_base.hpp" -void *Blitter_32bppBase::MoveTo(const void *video, int x, int y) +void *Blitter_32bppBase::MoveTo(void *video, int x, int y) { return (uint32 *)video + x + y * _screen.pitch; } @@ -39,7 +39,7 @@ void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height) { uint32 *dst = (uint32 *)video; - uint32 *usrc = (uint32 *)src; + const uint32 *usrc = (const uint32 *)src; for (; height > 0; height--) { memcpy(dst, usrc, width * sizeof(uint32)); @@ -51,7 +51,7 @@ void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, int height) { uint32 *udst = (uint32 *)dst; - uint32 *src = (uint32 *)video; + const uint32 *src = (const uint32 *)video; for (; height > 0; height--) { memcpy(udst, src, width * sizeof(uint32)); @@ -63,7 +63,7 @@ void Blitter_32bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) { uint32 *udst = (uint32 *)dst; - uint32 *src = (uint32 *)video; + const uint32 *src = (const uint32 *)video; for (; height > 0; height--) { memcpy(udst, src, width * sizeof(uint32));
--- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -20,7 +20,7 @@ class Blitter_32bppBase : public Blitter { public: /* virtual */ uint8 GetScreenDepth() { return 32; } - /* virtual */ void *MoveTo(const void *video, int x, int y); + /* virtual */ void *MoveTo(void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour); /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour); /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
--- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -40,7 +40,7 @@ /* skip upper lines in src_px and src_n */ for (uint i = bp->skip_top; i != 0; i--) { src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); - src_n += *(uint32 *)src_n; + src_n += *(const uint32 *)src_n; } /* skip lines in dst */ @@ -58,7 +58,7 @@ src_px++; /* next src_n line begins here */ - const uint8 *src_n_ln = src_n + *(uint32 *)src_n; + const uint8 *src_n_ln = src_n + *(const uint32 *)src_n; src_n += 4; /* we will end this line when we reach this point */
--- a/src/blitter/8bpp_base.cpp +++ b/src/blitter/8bpp_base.cpp @@ -23,7 +23,7 @@ } while (--height); } -void *Blitter_8bppBase::MoveTo(const void *video, int x, int y) +void *Blitter_8bppBase::MoveTo(void *video, int x, int y) { return (uint8 *)video + x + y * _screen.pitch; } @@ -44,7 +44,7 @@ void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height) { uint8 *dst = (uint8 *)video; - uint8 *usrc = (uint8 *)src; + const uint8 *usrc = (const uint8 *)src; for (; height > 0; height--) { memcpy(dst, usrc, width * sizeof(uint8)); @@ -56,7 +56,7 @@ void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int height) { uint8 *udst = (uint8 *)dst; - uint8 *src = (uint8 *)video; + const uint8 *src = (const uint8 *)video; for (; height > 0; height--) { memcpy(udst, src, width * sizeof(uint8)); @@ -68,7 +68,7 @@ void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) { uint8 *udst = (uint8 *)dst; - uint8 *src = (uint8 *)video; + const uint8 *src = (const uint8 *)video; for (; height > 0; height--) { memcpy(udst, src, width * sizeof(uint8));
--- a/src/blitter/8bpp_base.hpp +++ b/src/blitter/8bpp_base.hpp @@ -19,7 +19,7 @@ public: /* virtual */ uint8 GetScreenDepth() { return 8; } /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal); - /* virtual */ void *MoveTo(const void *video, int x, int y); + /* virtual */ void *MoveTo(void *video, int x, int y); /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour); /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour); /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
--- a/src/blitter/base.hpp +++ b/src/blitter/base.hpp @@ -87,7 +87,7 @@ * @param y How much you want to scroll to the bottom. * @return A new destination pointer moved the the requested place. */ - virtual void *MoveTo(const void *video, int x, int y) = 0; + virtual void *MoveTo(void *video, int x, int y) = 0; /** * Draw a pixel with a given colour on the video-buffer.
--- a/src/blitter/null.hpp +++ b/src/blitter/null.hpp @@ -21,7 +21,7 @@ /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) {}; /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) {}; /* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator); - /* virtual */ void *MoveTo(const void *video, int x, int y) { return NULL; }; + /* virtual */ void *MoveTo(void *video, int x, int y) { return NULL; }; /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour) {}; /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour) {}; /* virtual */ void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width) {};