aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruruk2014-06-22 13:38:47 +0200
committeruruk2014-06-22 13:38:47 +0200
commit8ae41648f9b7240aee5418afad3da4d6035b0c6e (patch)
treeee3f4dafc684b11f386f078e90ac404abc7f8b65
parentf36cfb629ce6d23fc0f7a4437ea3b71daa11833f (diff)
downloadscummvm-rg350-8ae41648f9b7240aee5418afad3da4d6035b0c6e.tar.gz
scummvm-rg350-8ae41648f9b7240aee5418afad3da4d6035b0c6e.tar.bz2
scummvm-rg350-8ae41648f9b7240aee5418afad3da4d6035b0c6e.zip
CGE2: Implement snSwap().
-rw-r--r--engines/cge2/cge2.h1
-rw-r--r--engines/cge2/snail.cpp49
2 files changed, 49 insertions, 1 deletions
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index 17d68fb221..130b1bac08 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -169,6 +169,7 @@ public:
int mapCross(const V2D &a, const V2D &b);
Sprite *spriteAt(V2D pos);
void keyClick();
+ void swapInPocket(Sprite *spr, Sprite *xspr);
void optionTouch(int opt, uint16 mask);
void switchColorMode();
diff --git a/engines/cge2/snail.cpp b/engines/cge2/snail.cpp
index 824d4e3c1d..4a932e5fb0 100644
--- a/engines/cge2/snail.cpp
+++ b/engines/cge2/snail.cpp
@@ -427,7 +427,38 @@ void CGE2Engine::snSend(Sprite *spr, int val) {
}
void CGE2Engine::snSwap(Sprite *spr, int val) {
- warning("STUB: CGE2Engine::snSwap()");
+ bool tak = _taken;
+ Sprite *xspr = locate(val);
+ if (spr && xspr) {
+ bool was1 = (_vga->_showQ->locate(spr->_ref) != nullptr);
+ bool xwas1 = (_vga->_showQ->locate(val) != nullptr);
+
+ int tmp = spr->_scene;
+ spr->setScene(xspr->_scene);
+ xspr->setScene(tmp);
+
+ SWAP(spr->_pos2D, xspr->_pos2D);
+ SWAP(spr->_pos3D, xspr->_pos3D);
+ if (spr->_flags._kept)
+ swapInPocket(spr, xspr);
+ if (xwas1 != was1) {
+ if (was1) {
+ hide1(spr);
+ _spare->dispose(spr);
+ } else
+ expandSprite(spr);
+ if (xwas1) {
+ hide1(xspr);
+ _spare->dispose(xspr);
+ } else {
+ expandSprite(xspr);
+ _taken = false;
+ }
+ }
+ }
+ if (_taken)
+ _spare->dispose(xspr);
+ _taken = tak;
}
void CGE2Engine::snCover(Sprite *spr, int val) {
@@ -689,6 +720,22 @@ void CGE2Engine::hide1(Sprite *spr) {
_commandHandlerTurbo->addCommand(kCmdGhost, -1, 0, spr->ghost());
}
+void CGE2Engine::swapInPocket(Sprite *spr, Sprite *xspr) {
+ int i, j;
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < kPocketMax; j++) {
+ Sprite *&poc = _heroTab[i]->_pocket[j];
+ if (poc == spr) {
+ spr->_flags._kept = false;
+ poc = xspr;
+ xspr->_flags._kept = true;
+ xspr->_flags._port = false;
+ return;
+ }
+ }
+ }
+}
+
Sprite *CGE2Engine::expandSprite(Sprite *spr) {
if (spr)
_vga->_showQ->insert(spr);