From 8fae34df055ecc90cce6324a8c9eb09112e21e31 Mon Sep 17 00:00:00 2001 From: uruk Date: Tue, 15 Jul 2014 16:22:43 +0200 Subject: CGE2: Implement snRoom(). --- engines/cge2/cge2.h | 2 +- engines/cge2/snail.cpp | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'engines') diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index d97ba3d675..b152b617d3 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -246,7 +246,7 @@ public: void snWalk(Sprite *spr, int val); void snReach(Sprite *spr, int val); void snSound(Sprite *spr, int wav); - void snRoom(Sprite *spr, int val); + void snRoom(Sprite *spr, bool on); void snDim(Sprite *spr, int val); void snGhost(Bitmap *bmp); void snSay(Sprite *spr, int val); diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp index 7ba0c3638e..284cecff3f 100644 --- a/engines/cge2/snail.cpp +++ b/engines/cge2/snail.cpp @@ -688,8 +688,27 @@ void CGE2Engine::snSound(Sprite *spr, int wav) { _sound->setRepeat(1); } -void CGE2Engine::snRoom(Sprite *spr, int val) { - warning("STUB: CGE2Engine::snRoom()"); +void CGE2Engine::snRoom(Sprite *spr, bool on) { + if (!isHero(spr)) + return; + int sx = spr->_ref & 1; + Sprite **p = _heroTab[sx]->_pocket; + if (on) { + if (freePockets(sx) == 0 && p[kPocketMax] == nullptr) { + SWAP(p[kPocketMax], p[kPocketMax - 1]); + snHide(p[kPocketMax], 1); + } + } else { + if (p[kPocketMax]) { + for (int i = 0; i < kPocketMax; i++) { + if (p[i] == nullptr) { + snHide(p[kPocketMax], 0); + SWAP(p[kPocketMax], p[i]); + break; + } + } + } + } } void CGE2Engine::snDim(Sprite *spr, int val) { -- cgit v1.2.3