diff options
author | uruk | 2014-07-17 15:41:49 +0200 |
---|---|---|
committer | uruk | 2014-07-17 15:41:49 +0200 |
commit | d9e82f8f8e1db2f5a3b03a512643b46553bcc88a (patch) | |
tree | 2ef521de7f96e8780fac2c1fd5e4bf69aa75959a | |
parent | a82bd2d9c600cd50fc29c3078f9f2d8c79ea18ff (diff) | |
download | scummvm-rg350-d9e82f8f8e1db2f5a3b03a512643b46553bcc88a.tar.gz scummvm-rg350-d9e82f8f8e1db2f5a3b03a512643b46553bcc88a.tar.bz2 scummvm-rg350-d9e82f8f8e1db2f5a3b03a512643b46553bcc88a.zip |
CGE2: Get rid of _sprite.
-rw-r--r-- | engines/cge2/cge2.cpp | 2 | ||||
-rw-r--r-- | engines/cge2/cge2.h | 3 | ||||
-rw-r--r-- | engines/cge2/cge2_main.cpp | 54 | ||||
-rw-r--r-- | engines/cge2/vga13h.cpp | 3 |
4 files changed, 29 insertions, 33 deletions
diff --git a/engines/cge2/cge2.cpp b/engines/cge2/cge2.cpp index b820ba53a7..cddf833c24 100644 --- a/engines/cge2/cge2.cpp +++ b/engines/cge2/cge2.cpp @@ -45,7 +45,6 @@ CGE2Engine::CGE2Engine(OSystem *syst, const ADGameDescription *gameDescription) : Engine(syst), _gameDescription(gameDescription), _randomSource("cge") { _resman = nullptr; _vga = nullptr; - _sprite = nullptr; _midiPlayer = nullptr; _fx = nullptr; _sound = nullptr; @@ -142,7 +141,6 @@ void CGE2Engine::deinit() { delete _eyeTab[i]; } delete _eye; - delete _sprite; delete _commandHandler; delete _commandHandlerTurbo; delete _font; diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index b152b617d3..6f07102ea5 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -152,7 +152,7 @@ public: void initToolbar(); void loadHeroes(); void loadScript(const char *fname); - void loadSprite(const char *fname, int ref, int scene, V3D &pos); + Sprite *loadSprite(const char *fname, int ref, int scene, V3D &pos); void badLab(const char *fn); void sceneUp(int cav); void sceneDown(); @@ -289,7 +289,6 @@ public: ResourceManager *_resman; Vga *_vga; - Sprite *_sprite; MusicPlayer *_midiPlayer; Fx *_fx; Sound *_sound; diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index d0a11643e3..d9fcbb2a97 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -156,7 +156,7 @@ void CGE2Engine::badLab(const char *fn) { error("Misplaced label in %s!", fn); } -void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) { +Sprite *CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) { int shpcnt = 0; int seqcnt = 0; int cnt[kActions]; @@ -275,40 +275,43 @@ void CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos) { ++shpcnt; // Make sprite of choosen type: + Sprite *sprite = nullptr; char c = *fname | 0x20; if (c >= 'a' && c <= 'z' && fname[1] == '0' && fname[2] == '\0') { h = new Hero(this); if (h) { h->gotoxyz(pos); - _sprite = h; + sprite = h; } } else { - _sprite = new Sprite(this); - if (_sprite) - _sprite->gotoxyz(pos); + sprite = new Sprite(this); + if (sprite) + sprite->gotoxyz(pos); } - if (_sprite) { - _sprite->_ref = ref; - _sprite->_scene = scene; + if (sprite) { + sprite->_ref = ref; + sprite->_scene = scene; - _sprite->_flags._frnt = frnt; - _sprite->_flags._east = east; - _sprite->_flags._port = port; - _sprite->_flags._tran = tran; - _sprite->_flags._kill = true; + sprite->_flags._frnt = frnt; + sprite->_flags._east = east; + sprite->_flags._port = port; + sprite->_flags._tran = tran; + sprite->_flags._kill = true; // Extract the filename, without the extension - Common::strlcpy(_sprite->_file, fname, sizeof(_sprite->_file)); - char *p = strchr(_sprite->_file, '.'); + Common::strlcpy(sprite->_file, fname, sizeof(sprite->_file)); + char *p = strchr(sprite->_file, '.'); if (p) *p = '\0'; - _sprite->_shpCnt = shpcnt; - _sprite->_seqCnt = seqcnt; + sprite->_shpCnt = shpcnt; + sprite->_seqCnt = seqcnt; for (int i = 0; i < kActions; i++) - _sprite->_actionCtrl[i]._cnt = cnt[i]; + sprite->_actionCtrl[i]._cnt = cnt[i]; + + return sprite; } } @@ -360,16 +363,16 @@ void CGE2Engine::loadScript(const char *fname) { ok = true; // no break: OK - _sprite = nullptr; - loadSprite(SpN, SpI, SpA, P); - if (_sprite) { + Sprite *sprite = loadSprite(SpN, SpI, SpA, P); + if (sprite) { if (BkG) - _sprite->_flags._back = true; + sprite->_flags._back = true; int n = _spare->count(); - if (_spare->locate(_sprite->_ref) == nullptr) - _spare->dispose(_sprite); - _sprite = nullptr; + if (_spare->locate(sprite->_ref) == nullptr) + _spare->dispose(sprite); + else + delete sprite; if (_spare->count() == n) error("Durplicated reference! %s", SpN); } @@ -445,7 +448,6 @@ void CGE2Engine::sceneUp(int cav) { _vga->copyPage(1, 0); _vga->show(); - _sprite = _vga->_showQ->first(); _vga->sunrise(_vga->_sysPal); _dark = false; diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp index 02d536c3e8..ea82fb7880 100644 --- a/engines/cge2/vga13h.cpp +++ b/engines/cge2/vga13h.cpp @@ -114,9 +114,6 @@ Sprite::Sprite(CGE2Engine *vm, BitmapPtr shpP, int cnt) } Sprite::~Sprite() { - if (_vm->_sprite == this) - _vm->_sprite = nullptr; - contract(); } |