aboutsummaryrefslogtreecommitdiff
path: root/engines/prince/mhwanh.cpp
diff options
context:
space:
mode:
authorlukaslw2014-08-01 17:38:04 +0200
committerlukaslw2014-08-01 17:38:04 +0200
commit3c29d61f6705a6f05d86fa2599a6992d2d17e3ac (patch)
tree9c0033d66c9a1cbf1cb5c52ca27b8159d194d432 /engines/prince/mhwanh.cpp
parentb3589c76da856239828377a3011525a888b04920 (diff)
downloadscummvm-rg350-3c29d61f6705a6f05d86fa2599a6992d2d17e3ac.tar.gz
scummvm-rg350-3c29d61f6705a6f05d86fa2599a6992d2d17e3ac.tar.bz2
scummvm-rg350-3c29d61f6705a6f05d86fa2599a6992d2d17e3ac.zip
PRINCE: Code clean-up
Diffstat (limited to 'engines/prince/mhwanh.cpp')
-rw-r--r--engines/prince/mhwanh.cpp27
1 files changed, 12 insertions, 15 deletions
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