diff options
author | uruk | 2014-06-06 14:57:34 +0200 |
---|---|---|
committer | uruk | 2014-06-06 14:57:34 +0200 |
commit | f2c006976541e00411b4f9154efe9ab16c633472 (patch) | |
tree | b237791cab6d68858bcbb4adc433f32aa1bb4ec6 /engines/cge2 | |
parent | c6fd9bf8ce06a9512ec6e8ff6d844718576d26a0 (diff) | |
download | scummvm-rg350-f2c006976541e00411b4f9154efe9ab16c633472.tar.gz scummvm-rg350-f2c006976541e00411b4f9154efe9ab16c633472.tar.bz2 scummvm-rg350-f2c006976541e00411b4f9154efe9ab16c633472.zip |
CGE2: Change BitmapPtr *_shpList -> BitmapPtr _shpList.
Update rest of the code accordingly.
Diffstat (limited to 'engines/cge2')
-rw-r--r-- | engines/cge2/bitmap.cpp | 3 | ||||
-rw-r--r-- | engines/cge2/cge2_main.cpp | 10 | ||||
-rw-r--r-- | engines/cge2/events.cpp | 7 | ||||
-rw-r--r-- | engines/cge2/hero.cpp | 9 | ||||
-rw-r--r-- | engines/cge2/vga13h.cpp | 70 | ||||
-rw-r--r-- | engines/cge2/vga13h.h | 6 |
6 files changed, 29 insertions, 76 deletions
diff --git a/engines/cge2/bitmap.cpp b/engines/cge2/bitmap.cpp index 47714284d3..ff7c3e1998 100644 --- a/engines/cge2/bitmap.cpp +++ b/engines/cge2/bitmap.cpp @@ -122,7 +122,8 @@ Bitmap::~Bitmap() { } void Bitmap::release() { - delete[] _v; + if (_v != nullptr) + delete[] _v; _v = nullptr; } diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index e1a2b0b4fe..99447efad2 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -737,13 +737,13 @@ bool CGE2Engine::showTitle(const char *name) { return false; _bitmapPalette = _vga->_sysPal; - BitmapPtr *LB = new BitmapPtr[2]; - LB[0] = new Bitmap(this, name); - LB[1] = NULL; - _bitmapPalette = NULL; + BitmapPtr LB = new Bitmap[1]; + LB[0] = Bitmap(this, name); + _bitmapPalette = nullptr; Sprite D(this, LB, 1); D._flags._kill = true; + strcpy(D._file, "hatter"); warning("STUB: Sprite::showTitle() - Flags changed compared to CGE1's Sprite type."); D.gotoxyz(kScrWidth >> 1, -(kPanHeight >> 1)); _vga->sunset(); @@ -758,7 +758,7 @@ bool CGE2Engine::showTitle(const char *name) { _vga->update(); warning("STUB: CGE2Engine::showTitle()"); - + return true; } diff --git a/engines/cge2/events.cpp b/engines/cge2/events.cpp index 5c0300f1e1..c036d5d676 100644 --- a/engines/cge2/events.cpp +++ b/engines/cge2/events.cpp @@ -74,10 +74,9 @@ Mouse::Mouse(CGE2Engine *vm) : Sprite(vm), _busy(NULL), _hold(NULL), _hx(0), _vm setSeq(_stdSeq8); - BitmapPtr *MC = new BitmapPtr[3]; - MC[0] = new Bitmap(_vm, "MOUSE"); - MC[1] = new Bitmap(_vm, "DUMMY"); - MC[2] = NULL; + BitmapPtr MC = new Bitmap[2]; + MC[0] = Bitmap(_vm, "MOUSE"); + MC[1] = Bitmap(_vm, "DUMMY"); setShapeList(MC, 2); step(1); diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp index 30fd252a7e..04ff05ce93 100644 --- a/engines/cge2/hero.cpp +++ b/engines/cge2/hero.cpp @@ -189,12 +189,7 @@ Sprite *Hero::expand() { // It's very similar to Sprite's expand, but doesn't bo } else setSeq(_stdSeq8); - BitmapPtr *bmp = new BitmapPtr[shpcnt]; - for (int i = 0; i < shpcnt; i++) - bmp[i] = &_dim[0][i]; - setShapeList(bmp, shpcnt); - delete[] bmp; - bmp = nullptr; + setShapeList(_dim[0], shpcnt); } } _reachStart = atoi(_vm->token(text)); @@ -219,7 +214,7 @@ void Hero::setCurrent() { break; } - _ext->_shpList = &_dim[_curDim = i]; + _ext->_shpList = _dim[_curDim = i]; } void Hero::hStep() { diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp index 01d0bf325b..b8fe54d437 100644 --- a/engines/cge2/vga13h.cpp +++ b/engines/cge2/vga13h.cpp @@ -91,7 +91,7 @@ Sprite::Sprite(CGE2Engine *vm) _flags._frnt = 1; } -Sprite::Sprite(CGE2Engine *vm, BitmapPtr *shpP, int cnt) +Sprite::Sprite(CGE2Engine *vm, BitmapPtr shpP, int cnt) : _siz(_vm, 0, 0), _seqPtr(kNoSeq), _seqCnt(0), _shpCnt(0), _next(NULL), _prev(NULL), _time(0), _ext(NULL), _ref(-1), _scene(0), _vm(vm), @@ -119,17 +119,17 @@ BitmapPtr Sprite::getShp() { int i = e->_seq[_seqPtr]._now; if (i >= _shpCnt) error("Invalid PHASE in SPRITE::Shp() %s", _file); - return e->_shpList[i]; + return e->_shpList + i; } -void Sprite::setShapeList(BitmapPtr *shp, int cnt) { +void Sprite::setShapeList(BitmapPtr shp, int cnt) { _shpCnt = cnt; _siz.x = 0; _siz.y = 0; if (shp) { for (int i = 0; i < cnt; i++) { - BitmapPtr p = *(shp + i); + BitmapPtr p = shp + i; if (p->_w > _siz.x) _siz.x = p->_w; if (p->_h > _siz.y) @@ -202,9 +202,7 @@ Sprite *Sprite::expand() { if (!*_file) return this; - Common::Array<BitmapPtr> shplist; - for (int i = 0; i < _shpCnt; ++i) - shplist.push_back(NULL); + BitmapPtr shplist = new Bitmap[_shpCnt]; int cnt[kActions], shpcnt = 0, @@ -328,9 +326,8 @@ Sprite *Sprite::expand() { s->_dly = _vm->number(p); break; case kIdPhase: { - BitmapPtr bmp = new Bitmap(_vm, p); - shplist[shpcnt] = bmp; - if (!shplist[shpcnt]->moveHi()) + shplist[shpcnt] = Bitmap(_vm, p); + if (!shplist[shpcnt].moveHi()) error("No EMS"); shpcnt++; break; @@ -346,7 +343,7 @@ Sprite *Sprite::expand() { if (!shpcnt) error("No shapes - %s", fname); } else // no sprite description: try to read immediately from .BMP - shplist[shpcnt++] = new Bitmap (_vm, _file); + shplist[shpcnt++] = Bitmap(_vm, _file); if (curSeq) { if (maxnow >= shpcnt) @@ -359,12 +356,7 @@ Sprite *Sprite::expand() { _seqCnt = (shpcnt < ARRAYSIZE(_stdSeq8)) ? shpcnt : ARRAYSIZE(_stdSeq8); } - // Set the shape list - BitmapPtr *shapeList = new BitmapPtr[shplist.size()]; - for (uint i = 0; i < shplist.size(); ++i) - shapeList[i] = shplist[i]; - - setShapeList(shapeList, shpcnt); + setShapeList(shplist, shpcnt); if (_file[2] == '~') { // FLY-type sprite Seq *nextSeq = _ext->_seq; @@ -401,7 +393,7 @@ Sprite *Sprite::contract() { if (e->_shpList) { for (int i = 0; i < _shpCnt; i++) - e->_shpList[i]->release(); + e->_shpList[i].release(); delete[] e->_shpList; e->_shpList = nullptr; } @@ -1055,53 +1047,19 @@ void Bitmap::hide(int16 x, int16 y) { /*--------------------------------------------------------------------------*/ HorizLine::HorizLine(CGE2Engine *vm) : Sprite(vm), _vm(vm) { - // Set the sprite list - BitmapPtr *HL = new BitmapPtr[2]; - HL[0] = new Bitmap(_vm, "HLINE"); - HL[1] = NULL; - - setShapeList(HL, 1); - - warning("HorizLine::HorizLine() - Recheck this!"); + warning("HorizLine::HorizLine()"); } SceneLight::SceneLight(CGE2Engine *vm) : Sprite(vm), _vm(vm) { - // Set the sprite list - BitmapPtr *PR = new BitmapPtr[2]; - PR[0] = new Bitmap(_vm, "PRESS"); - PR[1] = NULL; - - setShapeList(PR, 1); - - warning("SceneLight::SceneLight() - Recheck this!"); + warning("SceneLight::SceneLight()"); } Speaker::Speaker(CGE2Engine *vm): Sprite(vm), _vm(vm) { - // Set the sprite list - BitmapPtr *SP = new BitmapPtr[3]; - SP[0] = new Bitmap(_vm, "SPK_L"); - SP[1] = new Bitmap(_vm, "SPK_R"); - SP[2] = NULL; - - setShapeList(SP, 2); - - warning("Speaker::Speaker() - Recheck this!"); + warning("Speaker::Speaker()"); } PocLight::PocLight(CGE2Engine *vm): Sprite(vm), _vm(vm) { - // Set the sprite list - BitmapPtr *LI = new BitmapPtr[5]; - LI[0] = new Bitmap(_vm, "LITE0"); - LI[1] = new Bitmap(_vm, "LITE1"); - LI[2] = new Bitmap(_vm, "LITE2"); - LI[3] = new Bitmap(_vm, "LITE3"); - LI[4] = NULL; - - setShapeList(LI, 4); - - _flags._kill = false; - - warning("PocLight::PocLight() - Recheck this!"); + warning("PocLight::PocLight()"); } } // End of namespace CGE2 diff --git a/engines/cge2/vga13h.h b/engines/cge2/vga13h.h index 9144595053..09eb61accf 100644 --- a/engines/cge2/vga13h.h +++ b/engines/cge2/vga13h.h @@ -116,7 +116,7 @@ public: V2D _p1; BitmapPtr _b0; BitmapPtr _b1; - BitmapPtr *_shpList; + BitmapPtr _shpList; int _location; Seq *_seq; char *_name; @@ -171,10 +171,10 @@ public: return _ext != NULL; } Sprite(CGE2Engine *vm); - Sprite(CGE2Engine *vm, BitmapPtr *shp, int cnt); + Sprite(CGE2Engine *vm, BitmapPtr shp, int cnt); virtual ~Sprite(); BitmapPtr getShp(); - void setShapeList(BitmapPtr *shp, int cnt); + void setShapeList(BitmapPtr shp, int cnt); void moveShapesHi(); void moveShapesLo(); int labVal(Action snq, int lab); |