diff options
author | Colin Snover | 2017-11-14 13:03:15 -0600 |
---|---|---|
committer | Eugene Sandulenko | 2017-11-18 22:35:12 +0100 |
commit | 350ddcee102b56029c42016b8c116fc839936e1c (patch) | |
tree | 14404e13d8b0d3944da742a7db6f503e193648ff /engines | |
parent | c85f409a0b2fa1094ebd1a51c088d2d830383d38 (diff) | |
download | scummvm-rg350-350ddcee102b56029c42016b8c116fc839936e1c.tar.gz scummvm-rg350-350ddcee102b56029c42016b8c116fc839936e1c.tar.bz2 scummvm-rg350-350ddcee102b56029c42016b8c116fc839936e1c.zip |
FULLPIPE: Take references instead of pointers for required arguments in statics, remove unnecessary Picture allocation
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/gfx.cpp | 6 | ||||
-rw-r--r-- | engines/fullpipe/gfx.h | 2 | ||||
-rw-r--r-- | engines/fullpipe/statics.cpp | 86 | ||||
-rw-r--r-- | engines/fullpipe/statics.h | 7 |
4 files changed, 46 insertions, 55 deletions
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 3abf2fc7a6..ecc9f8c915 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -664,9 +664,9 @@ void Picture::setPaletteData(const Palette &pal) { } } -void Picture::copyMemoryObject2(Picture *src) { - if (_width == src->_width && _height == src->_height) { - if (src->_memoryObject2 && src->_memoryObject2->_rows && _memoryObject2) { +void Picture::copyMemoryObject2(Picture &src) { + if (_width == src._width && _height == src._height) { + if (src._memoryObject2 && src._memoryObject2->_rows && _memoryObject2) { byte *data = loadData(); _memoryObject2->copyData(data, _dataSize); setAOIDs(); diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index b92e94b79d..a2f7230c6b 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -112,7 +112,7 @@ public: const Palette &getPaletteData() const { return _paletteData; } void setPaletteData(const Palette &pal); - void copyMemoryObject2(Picture *src); + void copyMemoryObject2(Picture &src); int _x, _y; diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index f487f17103..289dfa9c0c 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -179,7 +179,7 @@ StaticANIObject::StaticANIObject(StaticANIObject *src) : GameObject(src) { _objtype = kObjTypeStaticANIObject; for (uint i = 0; i < src->_staticsList.size(); i++) - _staticsList.push_back(new Statics(src->_staticsList[i], 0)); + _staticsList.push_back(new Statics(*src->_staticsList[i], false)); _movement = 0; _statics = 0; @@ -580,11 +580,11 @@ void StaticANIObject::freeMovementsPixelData() { } Statics *StaticANIObject::addReverseStatics(Statics *st) { + assert(st); Statics *res = getStaticsById(st->_staticsId ^ 0x4000); if (!res) { - res = new Statics(st, true); - + res = new Statics(*st, true); _staticsList.push_back(res); } @@ -1396,27 +1396,20 @@ Common::Point *StaticANIObject::calcStepLen(Common::Point *p) { Statics::Statics() { _staticsId = 0; - _picture = nullptr; _data = nullptr; } -Statics::~Statics() { - delete _picture; -} - -Statics::Statics(Statics *src, bool reverse) : DynamicPhase(src, reverse) { - _staticsId = src->_staticsId; +Statics::Statics(Statics &src, bool reverse) : DynamicPhase(src, reverse) { + _staticsId = src._staticsId; if (reverse) { _staticsId ^= 0x4000; - _staticsName = sO_MirroredTo + src->_staticsName; + _staticsName = sO_MirroredTo + src._staticsName; } else { - _staticsName = src->_staticsName; + _staticsName = src._staticsName; } - _memfilename = src->_memfilename; - - _picture = new Picture(); + _memfilename = src._memfilename; } bool Statics::load(MfcArchive &file) { @@ -1429,8 +1422,7 @@ bool Statics::load(MfcArchive &file) { _staticsName = file.readPascalString(); debugC(7, kDebugLoading, "statics: <%s> id: %d (%x)", transCyrillic(_staticsName), _staticsId, _staticsId); - _picture = new Picture(); - _picture->load(file); + _picture.load(file); return true; } @@ -1613,7 +1605,7 @@ Movement::Movement(Movement *src, int *oldIdxs, int newSize, StaticANIObject *an src->setDynamicPhaseIndex(i); if (i < newSize - 1) - _dynamicPhases.push_back(new DynamicPhase(src->_currDynamicPhase, 0)); + _dynamicPhases.push_back(new DynamicPhase(*src->_currDynamicPhase, 0)); _framePosOffsets[i]->x = src->_framePosOffsets[i]->x; _framePosOffsets[i]->y = src->_framePosOffsets[i]->y; @@ -2140,18 +2132,18 @@ DynamicPhase::DynamicPhase() { _data = nullptr; } -DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) { - _field_7C = src->_field_7C; +DynamicPhase::DynamicPhase(DynamicPhase &src, bool reverse) { + _field_7C = src._field_7C; _field_7E = 0; debugC(1, kDebugAnimation, "DynamicPhase::DynamicPhase(src, %d)", reverse); if (reverse) { - if (!src->_bitmap) - src->init(); + if (!src._bitmap) + src.init(); - _bitmap = BitmapPtr(src->_bitmap->reverseImage()); - _dataSize = src->_dataSize; + _bitmap = BitmapPtr(src._bitmap->reverseImage()); + _dataSize = src._dataSize; if (g_fp->_currArchive) { _mfield_14 = 0; @@ -2160,43 +2152,43 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) { _mflags |= 1; - _someX = src->_someX; - _someY = src->_someY; + _someX = src._someX; + _someY = src._someY; } else { - _mfield_14 = src->_mfield_14; - _mfield_8 = src->_mfield_8; - _mflags = src->_mflags; + _mfield_14 = src._mfield_14; + _mfield_8 = src._mfield_8; + _mflags = src._mflags; - _memfilename = src->_memfilename; - _dataSize = src->_dataSize; - _mfield_10 = src->_mfield_10; - _libHandle = src->_libHandle; + _memfilename = src._memfilename; + _dataSize = src._dataSize; + _mfield_10 = src._mfield_10; + _libHandle = src._libHandle; - if (src->_bitmap) { + if (src._bitmap) { _field_54 = 1; - _bitmap = BitmapPtr(src->_bitmap->reverseImage(false)); + _bitmap = BitmapPtr(src._bitmap->reverseImage(false)); } - _someX = src->_someX; - _someY = src->_someY; + _someX = src._someX; + _someY = src._someY; } - _rect = src->_rect; + _rect = src._rect; - _width = src->_width; - _height = src->_height; - _field_7C = src->_field_7C; + _width = src._width; + _height = src._height; + _field_7C = src._field_7C; - if (src->getExCommand()) - _exCommand = src->getExCommand()->createClone(); + if (src.getExCommand()) + _exCommand = src.getExCommand()->createClone(); else _exCommand = 0; - _initialCountdown = src->_initialCountdown; - _field_6A = src->_field_6A; - _dynFlags = src->_dynFlags; + _initialCountdown = src._initialCountdown; + _field_6A = src._field_6A; + _dynFlags = src._dynFlags; - setPaletteData(src->getPaletteData()); + setPaletteData(src.getPaletteData()); copyMemoryObject2(src); } diff --git a/engines/fullpipe/statics.h b/engines/fullpipe/statics.h index 24d9fd078f..46b4a4bf9c 100644 --- a/engines/fullpipe/statics.h +++ b/engines/fullpipe/statics.h @@ -78,7 +78,7 @@ class DynamicPhase : public StaticPhase { public: DynamicPhase(); - DynamicPhase(DynamicPhase *src, bool reverse); + DynamicPhase(DynamicPhase &src, bool reverse); virtual bool load(MfcArchive &file); @@ -89,12 +89,11 @@ class Statics : public DynamicPhase { public: int16 _staticsId; Common::String _staticsName; - Picture *_picture; + Picture _picture; public: Statics(); - Statics(Statics *src, bool reverse); - virtual ~Statics(); + Statics(Statics &src, bool reverse); virtual bool load(MfcArchive &file); virtual void init(); |