From f3e81b5f17872186f7c67a551876dd78f268865c Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 22 Mar 2017 04:11:49 +0200 Subject: FULLPIPE: Use Common::String in all scene object names --- engines/fullpipe/gfx.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'engines/fullpipe/gfx.cpp') diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 619f41d6da..6fd720a52d 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -41,7 +41,6 @@ Background::Background() { _bigPictureArray1Count = 0; _bigPictureArray2Count = 0; _bigPictureArray = 0; - _bgname = 0; _palette = 0; } @@ -260,7 +259,6 @@ GameObject::GameObject() { _priority = 0; _field_20 = 0; _field_8 = 0; - _objectName = 0; } GameObject::GameObject(GameObject *src) { @@ -268,8 +266,7 @@ GameObject::GameObject(GameObject *src) { _flags = 0; _id = src->_id; - _objectName = (char *)calloc(strlen(src->_objectName) + 1, 1); - strncpy(_objectName, src->_objectName, strlen(src->_objectName)); + _objectName = src->_objectName; _ox = src->_ox; _oy = src->_oy; @@ -279,7 +276,6 @@ GameObject::GameObject(GameObject *src) { } GameObject::~GameObject() { - free(_objectName); } bool GameObject::load(MfcArchive &file) { -- cgit v1.2.3 From 56ec429537ee86a5e8cda0f027a21f217f1c16a2 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 22 Mar 2017 04:29:46 +0200 Subject: FULLPIPE: Change some more _memfilename usage to Common::String --- engines/fullpipe/gfx.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'engines/fullpipe/gfx.cpp') diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 6fd720a52d..5a89f1d419 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -470,7 +470,7 @@ Picture::~Picture() { } void Picture::freePicture() { - debugC(5, kDebugMemory, "Picture::freePicture(): file: %s", _memfilename); + debugC(5, kDebugMemory, "Picture::freePicture(): file: %s", _memfilename.c_str()); if (_bitmap) { if (testFlags() && !_field_54) { @@ -532,7 +532,7 @@ bool Picture::load(MfcArchive &file) { getData(); - debugC(5, kDebugLoading, "Picture::load: loaded <%s>", _memfilename); + debugC(5, kDebugLoading, "Picture::load: loaded <%s>", _memfilename.c_str()); return true; } @@ -552,7 +552,7 @@ void Picture::setAOIDs() { } void Picture::init() { - debugC(5, kDebugLoading, "Picture::init(), %s", _memfilename); + debugC(5, kDebugLoading, "Picture::init(), %s", _memfilename.c_str()); MemoryObject::getData(); @@ -585,7 +585,7 @@ void Picture::getDibInfo() { } if (!_data) { - warning("Picture::getDibInfo: data is empty <%s>", _memfilename); + warning("Picture::getDibInfo: data is empty <%s>", _memfilename.c_str()); MemoryObject::load(); } @@ -611,7 +611,7 @@ void Picture::draw(int x, int y, int style, int angle) { int x1 = x; int y1 = y; - debugC(7, kDebugDrawing, "Picture::draw(%d, %d, %d, %d) (%s)", x, y, style, angle, _memfilename); + debugC(7, kDebugDrawing, "Picture::draw(%d, %d, %d, %d) (%s)", x, y, style, angle, _memfilename.c_str()); if (x != -1) x1 = x; -- cgit v1.2.3 From 83fef244fb4b9389278f3412d9ba446d6fc967a3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 22 Mar 2017 04:33:28 +0200 Subject: FULLPIPE: Plug a memory leak in getDibInfo() --- engines/fullpipe/gfx.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/fullpipe/gfx.cpp') diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 5a89f1d419..0dbe693a60 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -591,8 +591,9 @@ void Picture::getDibInfo() { } Common::MemoryReadStream *s = new Common::MemoryReadStream(_data + off - 32, 32); - _bitmap->load(s); + delete s; + _bitmap->_pixels = _data; _bitmap->decode((int32 *)(_paletteData ? _paletteData : g_fp->_globalPalette)); -- cgit v1.2.3 From f669aca3f27c6fc058f8ba94af3bffb3a0ddde5a Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 22 Mar 2017 22:20:18 +0200 Subject: FULLPIPE: Fix mismatched free() when deleting _bitmap _bitmap is initialized with new, so it needs to be freed with delete, not free() --- engines/fullpipe/gfx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/fullpipe/gfx.cpp') diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 0dbe693a60..f08e49a8a7 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -475,7 +475,7 @@ void Picture::freePicture() { if (_bitmap) { if (testFlags() && !_field_54) { freeData(); - free(_bitmap); + delete _bitmap; _bitmap = 0; } } -- cgit v1.2.3 From 95c776e1eb61115df7c77f9cabd24414c1ff9234 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 22 Mar 2017 22:59:55 +0200 Subject: FULLPIPE: Refactor _pixels so that it's not part of the Bitmap class --- engines/fullpipe/gfx.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'engines/fullpipe/gfx.cpp') diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index f08e49a8a7..c316f5f616 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -486,7 +486,6 @@ void Picture::freePicture() { } if (_convertedBitmap) { - free(_convertedBitmap->_pixels); delete _convertedBitmap; _convertedBitmap = 0; } @@ -594,11 +593,7 @@ void Picture::getDibInfo() { _bitmap->load(s); delete s; - _bitmap->_pixels = _data; - - _bitmap->decode((int32 *)(_paletteData ? _paletteData : g_fp->_globalPalette)); - - _bitmap->_pixels = 0; + _bitmap->decode(_data, (int32 *)(_paletteData ? _paletteData : g_fp->_globalPalette)); } Bitmap *Picture::getPixelData() { @@ -763,7 +758,6 @@ Bitmap::Bitmap() { _y = 0; _width = 0; _height = 0; - _pixels = 0; _type = 0; _dataSize = 0; _flags = 0; @@ -780,20 +774,16 @@ Bitmap::Bitmap(Bitmap *src) { _type = src->_type; _width = src->_width; _height = src->_height; - _pixels = src->_pixels; _surface = new Graphics::TransparentSurface(*src->_surface); _copied_surface = true; _flipping = src->_flipping; } Bitmap::~Bitmap() { - if (!_copied_surface) _surface->free(); delete _surface; _surface = 0; - - _pixels = 0; } void Bitmap::load(Common::ReadStream *s) { @@ -822,15 +812,15 @@ bool Bitmap::isPixelHitAtPos(int x, int y) { return ((*((int32 *)_surface->getBasePtr(x - _x, y - _y)) & 0xff) != 0); } -void Bitmap::decode(int32 *palette) { +void Bitmap::decode(byte *pixels, int32 *palette) { _surface = new Graphics::TransparentSurface; _surface->create(_width, _height, Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); if (_type == MKTAG('R', 'B', '\0', '\0')) - putDibRB(palette); + putDibRB(pixels, palette); else - putDibCB(palette); + putDibCB(pixels, palette); } void Bitmap::putDib(int x, int y, int32 *palette, byte alpha) { @@ -862,7 +852,7 @@ void Bitmap::putDib(int x, int y, int32 *palette, byte alpha) { g_fp->_system->copyRectToScreen(g_fp->_backgroundSurface->getBasePtr(x1, y1), g_fp->_backgroundSurface->pitch, x1, y1, sub.width(), sub.height()); } -bool Bitmap::putDibRB(int32 *palette) { +bool Bitmap::putDibRB(byte *pixels, int32 *palette) { uint32 *curDestPtr; int endy; int x; @@ -887,7 +877,7 @@ bool Bitmap::putDibRB(int32 *palette) { y = endy; - srcPtr = (uint16 *)_pixels; + srcPtr = (uint16 *)pixels; bool breakup = false; for (y = endy; y >= starty && !breakup; y--) { @@ -964,7 +954,7 @@ bool Bitmap::putDibRB(int32 *palette) { return false; } -void Bitmap::putDibCB(int32 *palette) { +void Bitmap::putDibCB(byte *pixels, int32 *palette) { uint32 *curDestPtr; int endx; int endy; @@ -983,10 +973,10 @@ void Bitmap::putDibCB(int32 *palette) { bpp = cb05_format ? 2 : 1; pitch = (bpp * _width + 3) & 0xFFFFFFFC; - byte *srcPtr = &_pixels[pitch * endy]; + byte *srcPtr = &pixels[pitch * endy]; if (endy < _height) - srcPtr = &_pixels[pitch * (_height - 1)]; + srcPtr = &pixels[pitch * (_height - 1)]; int starty = 0; int startx = 0; -- cgit v1.2.3