From 1305bc8aa8b46459dfea08ad52309a57dbda64d8 Mon Sep 17 00:00:00 2001 From: uruk Date: Wed, 2 Jul 2014 22:57:49 +0200 Subject: CGE2: Add, implement and use saveHeroPos(). --- engines/cge2/cge2.h | 1 + engines/cge2/cge2_main.cpp | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) (limited to 'engines') diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h index e3606b821b..af16311ab2 100644 --- a/engines/cge2/cge2.h +++ b/engines/cge2/cge2.h @@ -155,6 +155,7 @@ public: void sceneDown(); void closePocket(); void switchScene(int scene); + void saveHeroPos(); void showBak(int ref); void loadTab(); int newRandom(int range); diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp index 2e70125fa6..dead21d5a4 100644 --- a/engines/cge2/cge2_main.cpp +++ b/engines/cge2/cge2_main.cpp @@ -505,14 +505,9 @@ void CGE2Engine::switchScene(int scene) { */ _req = scene; - for (int i = 0; i < 2; i++) { - Hero *h = _heroTab[i]->_ptr; - if (h->_scene == _now) { - delete _heroTab[i]->_posTab[_now]; - V2D *temp = new V2D(this, h->_pos3D._x.trunc(), h->_pos3D._z.trunc()); - _heroTab[i]->_posTab[_now] = temp; - } - } + + saveHeroPos(); + *(_eyeTab[_now]) = *_eye; if (scene < 0) _commandHandler->addCallback(kCmdExec, -1, 0, kQGame); // quit game @@ -530,6 +525,17 @@ void CGE2Engine::switchScene(int scene) { } } +void CGE2Engine::saveHeroPos() { + for (int i = 0; i < 2; i++) { + Hero *h = _heroTab[i]->_ptr; + if (h->_scene == _now) { + delete _heroTab[i]->_posTab[_now]; + V2D *temp = new V2D(this, h->_pos3D._x.trunc(), h->_pos3D._z.trunc()); + _heroTab[i]->_posTab[_now] = temp; + } + } +} + void CGE2Engine::showBak(int ref) { Sprite *spr = _spare->take(ref); if (spr != nullptr) { -- cgit v1.2.3