From 3c29d61f6705a6f05d86fa2599a6992d2d17e3ac Mon Sep 17 00:00:00 2001 From: lukaslw Date: Fri, 1 Aug 2014 17:38:04 +0200 Subject: PRINCE: Code clean-up --- engines/prince/mhwanh.cpp | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'engines/prince/mhwanh.cpp') diff --git a/engines/prince/mhwanh.cpp b/engines/prince/mhwanh.cpp index 3bd034e4a7..ef94ef71f9 100644 --- a/engines/prince/mhwanh.cpp +++ b/engines/prince/mhwanh.cpp @@ -28,8 +28,7 @@ namespace Prince { -MhwanhDecoder::MhwanhDecoder() - : _surface(NULL), _palette(0), _paletteColorCount(0) { +MhwanhDecoder::MhwanhDecoder() : _surface(nullptr), _palette(nullptr) { } MhwanhDecoder::~MhwanhDecoder() { @@ -37,38 +36,36 @@ MhwanhDecoder::~MhwanhDecoder() { } void MhwanhDecoder::destroy() { - if (_surface) { + if (_surface != nullptr) { _surface->free(); delete _surface; - _surface = 0; + _surface = nullptr; + } + if (_palette != nullptr) { + free(_palette); + _palette = nullptr; } - - delete [] _palette; _palette = 0; - _paletteColorCount = 0; } bool MhwanhDecoder::loadStream(Common::SeekableReadStream &stream) { destroy(); - _paletteColorCount = 256; stream.seek(0); stream.skip(0x20); // Read the palette - _palette = new byte[_paletteColorCount * 3]; - for (uint16 i = 0; i < _paletteColorCount; i++) { - _palette[i * 3 + 0] = stream.readByte(); + _palette = (byte *)malloc(kPaletteColorCount * 3); + for (uint16 i = 0; i < kPaletteColorCount; i++) { + _palette[i * 3] = stream.readByte(); _palette[i * 3 + 1] = stream.readByte(); _palette[i * 3 + 2] = stream.readByte(); } _surface = new Graphics::Surface(); _surface->create(640, 480, Graphics::PixelFormat::createFormatCLUT8()); - for (int h = 0; h < 480; ++h) { + for (int h = 0; h < 480; h++) { stream.read(_surface->getBasePtr(0, h), 640); } return true; } -} - -/* vim: set tabstop=4 noexpandtab: */ +} // End of namespace Prince -- cgit v1.2.3