[Scummvm-git-logs] scummvm master -> 1a598e05468dbf09c0013bca67445b0ef4dd7e82
sev-
noreply at scummvm.org
Sat Dec 5 23:21:26 UTC 2026
This automated email contains information about 52 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
1faf7c5f6c NGI: Switch scene 38 to its controller
eeb2d11222 NGI: Keep the roaming objects of a scene between visits
8fb2ff2cce NGI: Switch scene 32 to its controller
f5602f7b5a NGI: Switch scene 33 to its controller
2506a6cd31 NGI: Switch scene 34 to its controller
2f99882a94 NGI: Switch scene 22 to its controller
6b203f2a33 NGI: Port CScene::FindAniObject (x, y) and use it in the controllers
e5a27859c7 NGI: Switch scene 23 to its controller
fc9725cc03 NGI: Switch scene 25 to its controller
309682fbfd NGI: Switch scene 26 to its controller
6471d5d275 NGI: Switch scene 28 to its controller
d2cfc55951 NGI: Switch scene 6 to its controller
635bd64c09 NGI: Switch scene 8 to its controller
f13eaed742 NGI: Switch scene 9 to its controller
be58e5070c NGI: Switch scene 11 to its controller
8a0c48ae57 NGI: Switch scene 14 to its controller
e4f65b7ba3 NGI: Port CMovement::GetStepToFrame
01ba972043 NGI: Switch scene 18 to its controller
ca3a9d6719 NGI: Switch scene 27 to its controller
a6d7d5642b NGI: Switch scene 29 to its controller
f65de1319c NGI: Physics data structures (materials, registrator, params, bound box)
bea181b603 NGI: Physics geometries (IGeom family, VisForPhys, query callbacks)
afeb770849 NGI: Physical objects and ground (CPhysicalObject, CPhysGround)
1fcdd4299a NGI: Physics listener, debug drawing and the scene wiring (CPhysListener, CPhysDebugDraw)
705a7c22f0 NGI: Physics joints (IJoint, the joint definitions, CJointBuilder)
000a3976ea NGI: Physics XML loading and the physics test
34eb7b19f0 NGI: Send ENABLE_CHARACTER from old animations (COldAniObject::Update)
3557b47f77 NGI: Float model stage 3: AniObject stores the top left on 201509
374dc10c83 NGI: CFlyPack::AddFly sets the static and the center like the original
743acfe0e3 NGI: Saves by target name, footer version 4, extension block, Android load and autosave on quit
3a882592f1 NGI: Sound volume curve and ConfMan settings, save sections of the managers, saving flag
b543fcdf52 NGI: Not implemented box for the platform buttons of the Android menu and the notebook
62398f3ee7 NGI: CConfirmationDlg, the confirmation dialog of the main menu
81cbb94b29 NGI: CScFinalController, the ending scenes
3606d19754 NGI: CGuiSlider and CGuiCheckbox, hitAlpha of the GUI elements
8447e48cd7 NGI: CScOptionsController, the options scene of the main menu
5658cc9abc NGI: Rename CreditsController to ModalCredits
bc1043693d NGI: CCreditsController, the credits of the options scene
e4f04d29a3 NGI: CSplashScreen and CSplashScreenController, the start sequence
5e77f695a5 NGI: Float center API (CVisibleObject::GetCenter, SetCenter)
0523b5115f NGI: Float stage 4: the slide as one float vector (D49)
0ecf43697c NGI: Scene 29 uses the float center, scene 19 gets the controller of scene 18
25e67199c1 NGI: Float stage 4 leftovers: the walk starts at the center, Stop and Show keep the fraction
3d371ae12a NGI: CFPController::TestScroll and TouchScroll recalculate the cursor position after the camera moved
5cd3751e8c NGI: Float stage 5: scale and rotation in CMovement::SetFrame and CAniObject::GetFullSize (D50)
0b6bcc5072 NGI: Test mode screenshots by the engine (shot=, shotms=, shotquit)
af06fd4801 NGI: Mark the Android-only constants added with the UI work
87ce9989c4 NGI: Resolve the ADDPIC pictures when the scene is created, as CScene::Init (D62)
3d18fe345b NGI: CAniObject::GetFullSize returns floats, the camera of TouchScroll and TestScroll adds the float steps
5c3c98931d NGI: Use the float centre (CVisibleObject::GetCenter, SetCenter) in the Android code
8ac95a7688 NGI: Guard the cells of scene 18 at a cold boot of scene 19
1a598e0546 NGI: CFPController::MctlStartMove takes the target as floats
Commit: 1faf7c5f6c6f0556ca5d3ff367b0874b76c88a44
https://github.com/scummvm/scummvm/commit/1faf7c5f6c6f0556ca5d3ff367b0874b76c88a44
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:20+01:00
Commit Message:
NGI: Switch scene 38 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc38controller.cpp
engines/ngi/fullpipe/mobile/sc38controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc38controller.cpp b/engines/ngi/fullpipe/mobile/sc38controller.cpp
index fc02dbb3637..42dcf22fcbd 100644
--- a/engines/ngi/fullpipe/mobile/sc38controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc38controller.cpp
@@ -226,8 +226,6 @@ void Sc38Controller::onHand() {
_scene->runQueue(QU_GLV_TOSMALL);
else if (state == ST_GLV_NOHAMMER)
_scene->runQueue(QU_GLV_TOSMALL_NOHMR);
- else
- return;
_bossChatter._counter = 0;
}
}
@@ -272,8 +270,7 @@ void Sc38Controller::testBottle() {
float z = command->getParamFloat("z", 0.0f);
if (z < -1000.0f)
z = _bottle->_z;
- _bottle->setPosition(Common::Point((int)x, (int)y));
- _bottle->_z = (int)z;
+ _bottle->setOldAniPos((int)x, (int)y, (int)z);
g_ngi->setState(sO_Bottle_38, g_ngi->getStateValue(sO_Bottle_38, sO_BlockedShe));
}
}
@@ -325,8 +322,7 @@ void Sc38Controller::onShow() {
_dominos->_flags &= ~4;
_domino1->_flags &= ~4;
} else if (g_ngi->getStateId(sO_Boss) == g_ngi->getStateValue(sO_Boss, sO_WithoutHammer)) {
- _dominos->setPosition(Common::Point(598, 464));
- _dominos->_z = 21;
+ _dominos->setOldAniPos(598, 464, 21);
}
g_ngi->lift().initLift(_scene, hero(), QU_SC38_ENTERLIFT, QU_SC38_EXITLIFT);
@@ -392,11 +388,9 @@ void Sc38Controller::onMessage(const Common::String &message, const Common::Stri
} else if (message == "MSG_HIDE_MUG") {
_scene->findAniObjectById(ANI_MUG38, 0)->_flags &= ~4;
} else if (message == "MSG_SC38_MOVEDOMINO1") {
- _domino0->setPosition(Common::Point(539, 482));
- _domino0->_z = 25;
+ _domino0->setOldAniPos(539, 482, 25);
} else if (message == "MSG_SC38_MOVEDOMINO2") {
- _domino0->setPosition(Common::Point(549, 482));
- _domino0->_z = 25;
+ _domino0->setOldAniPos(549, 482, 25);
} else {
FPController::onMessage(message, param, queue);
}
diff --git a/engines/ngi/fullpipe/mobile/sc38controller.h b/engines/ngi/fullpipe/mobile/sc38controller.h
index f6c91c3458f..c30f4279fec 100644
--- a/engines/ngi/fullpipe/mobile/sc38controller.h
+++ b/engines/ngi/fullpipe/mobile/sc38controller.h
@@ -34,6 +34,7 @@ public:
void cleanXml() override;
bool canSwipeMan(float x, float y) override;
void checkTutorial() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
Commit: eeb2d112220b5e6acbc386ddb6b0e0503af30de5
https://github.com/scummvm/scummvm/commit/eeb2d112220b5e6acbc386ddb6b0e0503af30de5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:20+01:00
Commit Message:
NGI: Keep the roaming objects of a scene between visits
Changed paths:
engines/ngi/fullpipe/scenes.cpp
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index 2ced1731e63..a70ff2698cb 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -594,8 +594,7 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
_inventoryScene = nullptr;
Scene *common = findScene(SC_COMMON);
scene->_commonQueueScene = common == scene ? nullptr : common;
- scene->_roamingPictures.clear();
- scene->_roamingAnis.clear();
+ // the roaming objects stay between visits (CScene::RemoveRoamingObjects 121682: destructor)
for (const PicAniInfo &ref : scene->_roamingObjects) {
Scene *source = findScene(ref.sceneId);
if (!source)
Commit: 8fb2ff2cce0aadf6e3361a947417f863bcb9ba42
https://github.com/scummvm/scummvm/commit/8fb2ff2cce0aadf6e3361a947417f863bcb9ba42
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:20+01:00
Commit Message:
NGI: Switch scene 32 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc32controller.cpp
engines/ngi/fullpipe/mobile/sc32controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc32controller.cpp b/engines/ngi/fullpipe/mobile/sc32controller.cpp
index 0e937c6e230..dbafa487309 100644
--- a/engines/ngi/fullpipe/mobile/sc32controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc32controller.cpp
@@ -78,7 +78,7 @@ void Sc32Controller::onSpin(MessageQueue *queue) {
if (!queue || queue->getCount() == 0)
return;
if (queue->getCount() > 6) {
- while (queue->getCount() > 7)
+ while (queue->getCount() > 6)
queue->removeCommand(queue->getCurCommandNum() + 1, true);
}
Command *next = queue->getCommandByIndex(queue->getCurCommandNum() + 1);
diff --git a/engines/ngi/fullpipe/mobile/sc32controller.h b/engines/ngi/fullpipe/mobile/sc32controller.h
index f3e62bab2b1..01eea3c8bbc 100644
--- a/engines/ngi/fullpipe/mobile/sc32controller.h
+++ b/engines/ngi/fullpipe/mobile/sc32controller.h
@@ -36,6 +36,7 @@ public:
~Sc32Controller() override;
void onSceneInit() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
int getCursorType(float x, float y) override;
void onUpdate(uint32 elapsed) override;
Commit: f5602f7b5aa619316350a511ee26a27ac94496dd
https://github.com/scummvm/scummvm/commit/f5602f7b5aa619316350a511ee26a27ac94496dd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:20+01:00
Commit Message:
NGI: Switch scene 33 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc33controller.cpp
engines/ngi/fullpipe/mobile/sc33controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc33controller.cpp b/engines/ngi/fullpipe/mobile/sc33controller.cpp
index ebe8b09935c..c79c051d6c4 100644
--- a/engines/ngi/fullpipe/mobile/sc33controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc33controller.cpp
@@ -164,8 +164,7 @@ void Sc33Controller::onShow() {
}
AniObject *tumba = _scene->findAniObjectById(ANI_SC33_TUMBA, 0);
tumba->setStatic(ST_SC33_TUMBA_STATE1, false);
- tumba->setPosition(Common::Point(289, 427));
- tumba->_z = 40;
+ tumba->setOldAniPos(289, 427, 40);
}
_marginY = 200;
_marginX = 300;
diff --git a/engines/ngi/fullpipe/mobile/sc33controller.h b/engines/ngi/fullpipe/mobile/sc33controller.h
index e7b1c412014..ad8ee785c14 100644
--- a/engines/ngi/fullpipe/mobile/sc33controller.h
+++ b/engines/ngi/fullpipe/mobile/sc33controller.h
@@ -32,6 +32,7 @@ public:
explicit Sc33Controller(int sceneId);
~Sc33Controller() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
Commit: 2506a6cd31ea60c27b2012d081cd4e02376af3de
https://github.com/scummvm/scummvm/commit/2506a6cd31ea60c27b2012d081cd4e02376af3de
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:20+01:00
Commit Message:
NGI: Switch scene 34 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc34controller.cpp
engines/ngi/fullpipe/mobile/sc34controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc34controller.cpp b/engines/ngi/fullpipe/mobile/sc34controller.cpp
index 96e3beef36c..535db1307c1 100644
--- a/engines/ngi/fullpipe/mobile/sc34controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc34controller.cpp
@@ -71,7 +71,8 @@ bool Sc34Controller::canSwipeMan(float x, float y) {
// CSc34Controller::DoShowBox (192808)
void Sc34Controller::doShowBox() {
_stool->moveToStaticChain(ST_STL34_BOX2);
- _scene->findAniObjectById(ANI_STOOL_34, 0)->setPosition(Common::Point(919, 410));
+ AniObject *stool = _scene->findAniObjectById(ANI_STOOL_34, 0);
+ stool->setOldAniPos(919, 410, stool->_z);
}
// CSc34Controller::DoHideStool (192844)
@@ -199,7 +200,7 @@ bool Sc34Controller::onMouseDown(float x, float y) {
const float heroY = (float)center.y;
AniObject *under = _scene->findAniObjectAtPos((int)x, (int)y);
MessageQueue *queue;
- if (under && under->_id == ANI_VENT_34 && under->_copyId == 0) {
+ if (under && under->_id == ANI_VENT_34) {
if (fabsf(heroX - 887.0f) > 3.0f || fabsf(heroY - 369.0f) > 3.0f) {
if (fabsf(heroX - 917.0f) <= 3.0f) {
if (fabsf(heroY - 285.0f) <= 3.0f) {
@@ -423,7 +424,7 @@ void Sc34Controller::onMessage(const Common::String &message, const Common::Stri
g_ngi->_aniHandler->attachObject(hero()->_id);
FPController::onMouseLKeyUp(0, _savedX, _savedY);
} else if (message == "MSG_MOVECACTUS") {
- _cactus->setPosition(Common::Point(519, 371));
+ _cactus->setOldAniPos(519, 371, _cactus->_z);
} else if (message == "MSG_BREAK_GRIT") {
AniObject *grit;
int frame;
diff --git a/engines/ngi/fullpipe/mobile/sc34controller.h b/engines/ngi/fullpipe/mobile/sc34controller.h
index cb292ca2cc5..9e264e80152 100644
--- a/engines/ngi/fullpipe/mobile/sc34controller.h
+++ b/engines/ngi/fullpipe/mobile/sc34controller.h
@@ -37,6 +37,7 @@ public:
void cleanXml() override;
bool canSwipeMan(float x, float y) override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
Commit: 2f99882a94a998d3781ab71063a1602096e425d9
https://github.com/scummvm/scummvm/commit/2f99882a94a998d3781ab71063a1602096e425d9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 22 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc22controller.cpp
engines/ngi/fullpipe/mobile/sc22controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc22controller.cpp b/engines/ngi/fullpipe/mobile/sc22controller.cpp
index 9e04dbb3511..52a16d462d0 100644
--- a/engines/ngi/fullpipe/mobile/sc22controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc22controller.cpp
@@ -122,7 +122,7 @@ void Sc22Controller::onMouseDown() {
queue->setIntState(2);
if (!_scene->runQueueObject(queue, nullptr, 2)) {
// CLogger::WriteLog(1, ...)
- warning("sc22::OnMouseDown: m_scene->RunQueue returned false!");
+ warning("sc22::OnMouseDown: m_scene->RunQueue() returned false!");
}
}
@@ -166,7 +166,7 @@ void Sc22Controller::onClickHandle(bool fromQueue) {
g_ngi->_inventory->removeItem("ANI_INV_STOOL", -1);
if (!_scene->runQueueWithAni(QU_SC22_PUTSTOOL, hero(), 2)) {
// CLogger::WriteLog(1, ...)
- warning("sc22::OnClickHandle: m_scene->RunQueue returned false!");
+ warning("sc22::OnClickHandle: m_scene->RunQueue() returned false!");
}
_busy = true;
return;
@@ -206,7 +206,7 @@ void Sc22Controller::onClickHandle(bool fromQueue) {
return;
if (!_scene->runQueueWithAni(QU_SC22_HANDLEDOWN, hero(), 2)) {
// CLogger::WriteLog(1, ...)
- warning("sc22::OnClickHandle: m_scene->RunQueue returned false!");
+ warning("sc22::OnClickHandle: m_scene->RunQueue() returned false!");
}
_busy = true;
return;
@@ -223,7 +223,7 @@ void Sc22Controller::onClickHandle(bool fromQueue) {
}
if (!_scene->runQueueWithAni(QU_SC22_TOSTOOL, hero(), 2)) {
// CLogger::WriteLog(1, ...)
- warning("sc22::OnClickHandle: m_scene->RunQueue returned false!");
+ warning("sc22::OnClickHandle: m_scene->RunQueue() returned false!");
}
_busy = true;
return;
@@ -239,7 +239,7 @@ void Sc22Controller::onClickHandle(bool fromQueue) {
}
if (!_scene->runQueueWithAni(QU_SC22_TRYHANDLE, hero(), 2)) {
// CLogger::WriteLog(1, ...)
- warning("sc22::OnClickHandle: m_scene->RunQueue returned false!");
+ warning("sc22::OnClickHandle: m_scene->RunQueue() returned false!");
}
}
@@ -358,6 +358,11 @@ void Sc22Controller::onUpdate(uint32 elapsed) {
FPController::onUpdate(elapsed);
}
+// CSc22Controller::OnMouseLKeyDown (18261C)
+bool Sc22Controller::onMouseLKeyDown(uint32 id, float x, float y) {
+ return FPController::onMouseLKeyDown(id, x, y);
+}
+
// CSc22Controller::OnMouseLKeyUp (182624)
bool Sc22Controller::onMouseLKeyUp(uint32 id, float x, float y) {
if (!controllerRunsSceneLogic())
@@ -365,7 +370,7 @@ bool Sc22Controller::onMouseLKeyUp(uint32 id, float x, float y) {
const bool handled = FPController::onMouseLKeyUp(id, x, y);
if (!handled) {
GameObject *hit = g_ngi->_inputController->getInteractHitObject();
- if (hit && hit->_id == ANI_HANDLE_L && hit->_copyId == 0) {
+ if (hit && hit->_id == ANI_HANDLE_L) {
onClickHandle(false);
return true;
}
diff --git a/engines/ngi/fullpipe/mobile/sc22controller.h b/engines/ngi/fullpipe/mobile/sc22controller.h
index d2b599e885e..9ce8d6b43b1 100644
--- a/engines/ngi/fullpipe/mobile/sc22controller.h
+++ b/engines/ngi/fullpipe/mobile/sc22controller.h
@@ -34,10 +34,12 @@ public:
void cleanXml() override;
bool canSwipeMan(float x, float y) override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
void onUpdate(uint32 elapsed) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
bool onMouseLKeyUp(uint32 id, float x, float y) override;
void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
void updateScroll() override;
@@ -59,6 +61,7 @@ private:
AniObject *_giraffe = nullptr; // +228: ANI_GIRAFFE_MIDDLE
AniObject *_stool = nullptr; // +232: ANI_TABURETTE
bool _busy = false; // +236: the hero works with the stool or the handle
+ // +240: a pointer that the constructor and OnShow clear, never read, so no field
bool _musicPlaying = false; // +244: the music of the coin slot plays
bool _hammerKicked = false; // +245: the hammer hit the metal, the end of the music is due
};
Commit: 6b203f2a33c9e6b102e22e1d47de207b0a9714d9
https://github.com/scummvm/scummvm/commit/6b203f2a33c9e6b102e22e1d47de207b0a9714d9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Port CScene::FindAniObject (x, y) and use it in the controllers
Changed paths:
engines/ngi/fullpipe/mobile/sc34controller.cpp
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/scene.cpp
engines/ngi/scene.h
diff --git a/engines/ngi/fullpipe/mobile/sc34controller.cpp b/engines/ngi/fullpipe/mobile/sc34controller.cpp
index 535db1307c1..3a615600e26 100644
--- a/engines/ngi/fullpipe/mobile/sc34controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc34controller.cpp
@@ -198,7 +198,7 @@ bool Sc34Controller::onMouseDown(float x, float y) {
const Common::Point center = hero()->getCenter();
const float heroX = (float)center.x;
const float heroY = (float)center.y;
- AniObject *under = _scene->findAniObjectAtPos((int)x, (int)y);
+ GameObject *under = _scene->findAniObjectAt(x, y);
MessageQueue *queue;
if (under && under->_id == ANI_VENT_34) {
if (fabsf(heroX - 887.0f) > 3.0f || fabsf(heroY - 369.0f) > 3.0f) {
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 8fa0a2b38d4..784d59099e2 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -252,6 +252,13 @@ bool PictureObject::hit(int x, int y) {
return res;
}
+// CVisibleObject::Hit (1277B6); the baked rectangle stands for the hit region (D46)
+bool PictureObject::visibleHit(float x, float y) {
+ if (!_hitRegion.isEmpty())
+ return _hitRegion.contains(x - _x, y - _y);
+ return hitTextureRect(x, y);
+}
+
void PictureObject::setOXY2() {
_ox2 = _x;
_oy2 = _y;
@@ -376,6 +383,13 @@ Common::Rect GameObject::getBounds() const {
return Common::Rect(topLeft.x, topLeft.y, topLeft.x + static_cast<int>(size.x * _scaleX), topLeft.y + static_cast<int>(size.y * _scaleY));
}
+// CVisibleObject::Hit (1277B6)
+bool GameObject::visibleHit(float x, float y) {
+ if (_hitregion)
+ return _hitregion->hit(x, y);
+ return hitTextureRect(x, y);
+}
+
// CVisibleObject::Hit (1277B6) without a hit region: the rectangle of the texture, no alpha test
bool GameObject::hitTextureRect(float x, float y) const {
Common::Point topLeft;
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 406188c6e56..20adc6d4e9b 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -240,6 +240,8 @@ class GameObject : public CObject {
Common::Rect getBounds() const;
/** CVisibleObject::Hit (1277B6) of an object without a hit region */
bool hitTextureRect(float x, float y) const;
+ /** CVisibleObject::Hit (1277B6): the hit region, else the rectangle of the texture */
+ virtual bool visibleHit(float x, float y);
bool getPicAniInfo(PicAniInfo &info);
bool setPicAniInfo(const PicAniInfo &info);
@@ -267,6 +269,7 @@ public:
Common::Rect _hitRegion; // XML region in picture coordinates.
bool isPointInside(int x, int y);
bool hit(int x, int y);
+ bool visibleHit(float x, float y) override;
void setOXY2();
Texture *_picture;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index b06315b543e..0c310269b65 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -1782,6 +1782,30 @@ void Scene::getRenderables(Common::Array<GameObject *> &result) const {
result.push_back(group);
}
+// CScene::FindAniObject (11F8A8): no flag test, only the hit; of equal z the first wins
+GameObject *Scene::findAniObjectAt(float x, float y) {
+ float lowestZ = 1000.0f;
+ GameObject *found = nullptr;
+ Common::Array<GameObject *> group;
+ for (AniObject *ani : _aniObjects)
+ group.push_back(ani);
+ Common::sort(group.begin(), group.end(), lessByKey);
+ Common::Array<GameObject *> roaming;
+ for (PictureObject *picture : _roamingPictures)
+ roaming.push_back(picture);
+ for (AniObject *ani : _roamingAnis)
+ roaming.push_back(ani);
+ Common::sort(roaming.begin(), roaming.end(), lessByKey);
+ group.push_back(roaming);
+ for (GameObject *object : group) {
+ if (object->visibleHit(x, y) && lowestZ > object->_z) {
+ lowestZ = object->_z;
+ found = object;
+ }
+ }
+ return found;
+}
+
// CScene::IsAnyoneMoves (11FD24)
bool Scene::isAnyoneMoves() const {
for (const AniObject *ani : _aniObjects) {
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 5c1ba2cdf63..ab3992f9fc0 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -259,6 +259,8 @@ class Scene : public Background {
void getVisObjsVHitInteract(Common::Array<GameObject *> &result, float x, float y);
/** CScene::GetVisObjVHitInteract (11FE6C): the first of them */
GameObject *getVisObjVHitInteract(float x, float y);
+ /** CScene::FindAniObject (11F8A8): the hit object of the lowest z, no flag test */
+ GameObject *findAniObjectAt(float x, float y);
AniObject *findAniObjectAtPos(int x, int y);
PictureObject *findPictureObjectAtPos(int x, int y);
int getPictureObjectIdAtPos(int x, int y);
Commit: e5a27859c7e281ea28595babb4fae6586eeaf727
https://github.com/scummvm/scummvm/commit/e5a27859c7e281ea28595babb4fae6586eeaf727
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 23 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc23controller.cpp
engines/ngi/fullpipe/mobile/sc23controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc23controller.cpp b/engines/ngi/fullpipe/mobile/sc23controller.cpp
index 6a4b230d866..273fb838da9 100644
--- a/engines/ngi/fullpipe/mobile/sc23controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc23controller.cpp
@@ -379,9 +379,11 @@ void Sc23Controller::onShow() {
AniObject *wheel = _scene->findAniObjectById(ANI_CALENDWHEEL, i);
if (!wheel) {
wheel = new AniObject(source);
- _scene->addAni(wheel, false);
+ // CScene::AddAni(wheel, 0): the copy number
+ wheel->assignCopyId(&_scene->_aniObjects);
+ _scene->addAni(wheel, true);
wheel->setStatic(ST_CND_0, false);
- wheel->setPosition(Common::Point((int)_wheelPos[i * 2], (int)_wheelPos[i * 2 + 1]));
+ wheel->setOldAniPos((int)_wheelPos[i * 2], (int)_wheelPos[i * 2 + 1], wheel->_z);
}
_wheels.push_back(wheel);
}
@@ -619,14 +621,16 @@ void Sc23MiniController::onShow() {
float wheelY = origin.y;
for (int i = 0; i < 4; i++) {
button = new AniObject(button);
- _scene->addAni(button, false);
+ button->assignCopyId(&_scene->_aniObjects);
+ _scene->addAni(button, true);
button->_flags |= 4;
buttonX += _buttonOffsets[i * 2];
buttonY += _buttonOffsets[i * 2 + 1];
button->setCenter(Common::Point((int)buttonX, (int)buttonY));
wheel = new AniObject(wheel);
- _scene->addAni(wheel, false);
+ wheel->assignCopyId(&_scene->_aniObjects);
+ _scene->addAni(wheel, true);
wheel->_flags |= 4;
wheelX += _wheelOffsets[i * 2];
wheelY += _wheelOffsets[i * 2 + 1];
diff --git a/engines/ngi/fullpipe/mobile/sc23controller.h b/engines/ngi/fullpipe/mobile/sc23controller.h
index 1fd2d2a9b0f..ee4f612b943 100644
--- a/engines/ngi/fullpipe/mobile/sc23controller.h
+++ b/engines/ngi/fullpipe/mobile/sc23controller.h
@@ -38,6 +38,7 @@ public:
explicit Sc23Controller(int sceneId);
~Sc23Controller() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
@@ -86,6 +87,7 @@ public:
explicit Sc23MiniController(int sceneId);
~Sc23MiniController() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
Commit: fc9725cc03f2933bacb840be12dfbfc82ea337f5
https://github.com/scummvm/scummvm/commit/fc9725cc03f2933bacb840be12dfbfc82ea337f5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 25 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc25controller.cpp
engines/ngi/fullpipe/mobile/sc25controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc25controller.cpp b/engines/ngi/fullpipe/mobile/sc25controller.cpp
index 9fbf3f2ee64..fd14b340a26 100644
--- a/engines/ngi/fullpipe/mobile/sc25controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc25controller.cpp
@@ -224,7 +224,6 @@ bool Sc25Controller::trySwitchUp() {
return false;
MessageQueue *queue = new MessageQueue(interact->_messageQueue, 0, 0);
- queue->_scene = _scene;
if (queue->getCommandByIndex(0)->_args.getValOrDefault("type") == "GO_MCTL")
queue->removeCommand(0, true);
const Common::Point heroPos = interact->getHeroPos();
@@ -402,7 +401,11 @@ void Sc25Controller::doStartBeardeds() {
AniObject *ani = new AniObject(source);
_beardeds.push_back(ani);
ani->setStatic(ST_BRDCMN_EMPTY, false);
- _scene->addAni(ani, false);
+ // CScene::AddAni(ani, 0); Scene::addAni clears the flags of copy 0, the original keeps them
+ const int16 flags = ani->_flags;
+ ani->assignCopyId(&_scene->_aniObjects);
+ _scene->addAni(ani, true);
+ ani->_flags = flags;
}
_beardedsActive = true;
}
@@ -433,8 +436,6 @@ void Sc25Controller::onShow() {
_scrollY = false;
g_ngi->playSound(SND_25_006, 1);
}
- _boardSelectable = false;
- _idleReady = false;
if (_waterPresent)
_water->_flags |= 4;
else
diff --git a/engines/ngi/fullpipe/mobile/sc25controller.h b/engines/ngi/fullpipe/mobile/sc25controller.h
index 7ac3c832358..7518972c1f2 100644
--- a/engines/ngi/fullpipe/mobile/sc25controller.h
+++ b/engines/ngi/fullpipe/mobile/sc25controller.h
@@ -34,6 +34,7 @@ public:
explicit Sc25Controller(int sceneId);
~Sc25Controller() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
Commit: 309682fbfd839ac3d107439740a89c99c7233b12
https://github.com/scummvm/scummvm/commit/309682fbfd839ac3d107439740a89c99c7233b12
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 26 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc26controller.cpp
engines/ngi/fullpipe/mobile/sc26controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc26controller.cpp b/engines/ngi/fullpipe/mobile/sc26controller.cpp
index e71ca3555b4..f1d6b8f4364 100644
--- a/engines/ngi/fullpipe/mobile/sc26controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc26controller.cpp
@@ -150,14 +150,14 @@ void Sc26Controller::doTestVent() {
if (isState(sO_Valve2_26, sO_Opened)) {
if (!_scene->runQueue(QU_SC26_AUTOCLOSE2, 4)) {
// CLogger::WriteLog(1, ...)
- warning("sc26::DoTestVent: m_scene->RunQueue returned false!");
+ warning("sc26::DoTestVent: m_scene->RunQueue(QU) returned false!");
}
g_ngi->playSound(SND_26_020, 0);
}
if (isState(sO_Valve3_26, sO_Opened)) {
if (!_scene->runQueue(QU_SC26_AUTOCLOSE3, 4)) {
// CLogger::WriteLog(1, ...)
- warning("sc26::DoTestVent: m_scene->RunQueue returned false!");
+ warning("sc26::DoTestVent: m_scene->RunQueue(QU) returned false!");
}
g_ngi->playSound(SND_26_020, 0);
}
@@ -169,7 +169,7 @@ void Sc26Controller::doTestVent() {
g_ngi->stopAllSoundInstances(SND_26_018);
if (!_scene->runQueue(QU_SC26_AUTOCLOSE1, 4)) {
// CLogger::WriteLog(1, ...)
- warning("sc26::DoTestVent: m_scene->RunQueue returned false!");
+ warning("sc26::DoTestVent: m_scene->RunQueue(QU) returned false!");
}
}
} else if (_activeVent->_copyId == 2) {
@@ -180,7 +180,7 @@ void Sc26Controller::doTestVent() {
g_ngi->stopAllSoundInstances(SND_26_018);
if (!_scene->runQueue(QU_SC26_AUTOCLOSE1, 4)) {
// CLogger::WriteLog(1, ...)
- warning("sc26::DoTestVent: m_scene->RunQueue returned false!");
+ warning("sc26::DoTestVent: m_scene->RunQueue(QU) returned false!");
}
}
}
@@ -191,19 +191,19 @@ bool Sc26Controller::onClickVent(AniObject *vent) {
if (vent->_copyId == 0 && isState(sO_Hatch_26, sO_Opened))
return false;
if (hero()->getMessageQueue()) {
- MessageQueue *queue = hero()->getMessageQueue();
- Command *cmd = queue->getCurCommand();
+ Command *cmd = hero()->getMessageQueue()->getCurCommand();
if (cmd) {
- for (Common::StringMap::const_iterator it = cmd->_args.begin(); it != cmd->_args.end(); ++it) {
+ const Common::StringMap args = cmd->_args;
+ for (Common::StringMap::const_iterator it = args.begin(); it != args.end(); ++it) {
if (it->_value == "MSG_SC26_CLICKVENT") {
- hero()->getMessageQueue()->interrupt(false);
+ hero()->getMessageQueue()->stop(false);
hero()->setQueue(nullptr);
}
}
}
}
if (hero()->getMessageQueue() && canInterruptManQueue()) {
- hero()->getMessageQueue()->interrupt(false);
+ hero()->getMessageQueue()->stop(false);
hero()->setQueue(nullptr);
}
if (hero()->getMessageQueue())
@@ -307,8 +307,7 @@ void Sc26Controller::onMessage(const Common::String &message, const Common::Stri
updateDrop();
} else if (message == "MSG_SC26_MOVELUK") {
AniObject *hatch = _scene->findAniObjectById(ANI_LUK26, 0);
- hatch->setPosition(Common::Point(94, 381));
- hatch->_z = 27;
+ hatch->setOldAniPos(94, 381, 27);
} else {
FPController::onMessage(message, param, queue);
}
diff --git a/engines/ngi/fullpipe/mobile/sc26controller.h b/engines/ngi/fullpipe/mobile/sc26controller.h
index ad5fbb7455a..29d500e321e 100644
--- a/engines/ngi/fullpipe/mobile/sc26controller.h
+++ b/engines/ngi/fullpipe/mobile/sc26controller.h
@@ -28,12 +28,13 @@ namespace NGI {
class PictureObject;
-/** CSc26Controller (the pool and the five valves); sceneHandler26 runs the scene until wired */
+/** CSc26Controller (the pool and the five valves) */
class Sc26Controller : public FPController {
public:
explicit Sc26Controller(int sceneId);
~Sc26Controller() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
int getCursorType(float x, float y) override;
void onUpdate(uint32 elapsed) override;
Commit: 6471d5d27559104def1da888e57c096d2cbac82d
https://github.com/scummvm/scummvm/commit/6471d5d27559104def1da888e57c096d2cbac82d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 28 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc28controller.cpp
engines/ngi/fullpipe/mobile/sc28controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc28controller.cpp b/engines/ngi/fullpipe/mobile/sc28controller.cpp
index d2a4e6cc7a5..ad2b2a47e2e 100644
--- a/engines/ngi/fullpipe/mobile/sc28controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc28controller.cpp
@@ -57,7 +57,7 @@ void Sc28Controller::doStartWork1() {
AniObject *worker = _scene->findAniObjectById(ANI_MAN_28, 0);
worker->setStatic(ST_MAN28_RIGHT, false);
const Common::Point heroPos = hero()->getPosition();
- worker->setPosition(Common::Point(heroPos.x + 50, heroPos.y + 50));
+ worker->setOldAniPos(heroPos.x + 50, heroPos.y + 50, worker->_z);
worker->_z = hero()->_z;
worker->_flags |= 4;
if (!_scene->isQueueStarted(QU_SC28_LIFT1_WORK))
@@ -167,7 +167,7 @@ void Sc28Controller::tryVtorpers() {
}
if (!started) {
// CLogger::WriteLog(1, ...)
- warning("sc28::TryVtorPers: m_scene->RunQueue returned false!");
+ warning("sc28::TryVtorPers: m_scene->RunQueue() returned false!");
}
_headLeft = !_headLeft;
} else {
@@ -190,7 +190,7 @@ void Sc28Controller::tryVtorpers() {
started = _scene->runQueueObject(queue, nullptr, 3);
if (!started) {
// CLogger::WriteLog(1, ...)
- warning("sc28::TryVtorPers: m_scene->RunQueue returned false!");
+ warning("sc28::TryVtorPers: m_scene->RunQueue() returned false!");
}
}
_vtorpersLeft = !_vtorpersLeft;
diff --git a/engines/ngi/fullpipe/mobile/sc28controller.h b/engines/ngi/fullpipe/mobile/sc28controller.h
index 5ec590b4b5a..8e80ba78678 100644
--- a/engines/ngi/fullpipe/mobile/sc28controller.h
+++ b/engines/ngi/fullpipe/mobile/sc28controller.h
@@ -33,12 +33,13 @@ namespace NGI {
class Interact;
class PictureObject;
-/** CSc28Controller (lift cabins, flies); sceneHandler28 runs the scene until wired */
+/** CSc28Controller (lift cabins, flies) */
class Sc28Controller : public FPController {
public:
explicit Sc28Controller(int sceneId);
~Sc28Controller() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onSceneInit() override;
void onShow() override;
void onHide() override;
Commit: d2cfc559519ca20e962fb6c4dd78a04a3ea51a57
https://github.com/scummvm/scummvm/commit/d2cfc559519ca20e962fb6c4dd78a04a3ea51a57
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 6 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc06controller.cpp
engines/ngi/fullpipe/mobile/sc06controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc06controller.cpp b/engines/ngi/fullpipe/mobile/sc06controller.cpp
index 6106f34c0aa..8940decb5ee 100644
--- a/engines/ngi/fullpipe/mobile/sc06controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc06controller.cpp
@@ -62,10 +62,9 @@ void runQueueForCopy(Scene *scene, int queueId, int copyId) {
delete copy;
}
-// the original runs the scene's queue itself (-1 before its first command); we run copies
+// CMessageQueue::GetCurCommandNum (10C7E2)
int getCurCommandNum(const MessageQueue *queue) {
- warnOnce("CMessageQueue::GetCurCommandNum of a queue of the scene (the engine runs copies of the queues, the template never runs)");
- return -1;
+ return queue->_curIndex;
}
// CInteractionController::FindInteraction(name), CMessageQueue +56 (current command)
@@ -212,8 +211,7 @@ void Sc06Controller::doShootBall() {
const Common::Point position = hero()->getPosition();
const float x = (float)position.x - 60.0f;
const float y = (float)position.y - 60.0f;
- _flyingBall->setPosition(Common::Point((int)x, (int)y));
- _flyingBall->_z = 27;
+ _flyingBall->setOldAniPos((int)x, (int)y, 27);
}
// CSc06Controller::StartDragMan (16B064): the hero swings his arm back
@@ -356,7 +354,7 @@ void Sc06Controller::manNextFunc(uint32 elapsed) {
CursorController *cursor = g_ngi->_inputController;
const float dx = cursor->_hotSceneX - (float)_dragX;
const float dy = cursor->_hotSceneY - (float)_dragY;
- frame = (int)(sqrt((double)dx * (double)dx + (double)(dy * dy)) * 0.1);
+ frame = (int)(sqrt((double)(dx * dx + dy * dy)) * 0.1);
if (frame > 8)
frame = 8;
_aimAngle = ((float)frame * 2.2f) + 205.0f;
@@ -531,8 +529,11 @@ void Sc06Controller::skipArcade() {
MessageQueue *drops = _scene->findMessageQueue(QU_SC6_DROPS3);
if (drops && getCurCommandNum(drops) != -1 && _ballInBag) {
if (getCurCommandNum(drops) == 0) {
- // ANI_BALLDROP plays backwards: CMovement +61 set, +92 = frame count - 1 - itself
- warnOnce("CSc06Controller::SkipArcade: the movement of ANI_BALLDROP is turned back (CMovement +61, +92)");
+ // ANI_BALLDROP plays backwards
+ if (Movement *movement = _ballDrop->_movement) {
+ movement->_reverse = true;
+ movement->_curFrame = (int)movement->_phases.size() - 1 - movement->_curFrame;
+ }
}
_skipArcade = true;
return;
@@ -816,8 +817,7 @@ void Sc06Controller::onShow() {
ball->_flags &= ~4;
ball->setStatic(ST_NBL_NORM);
_ballDrop->setStatic(ST_BDP_NORM);
- _ballDrop->setPosition(Common::Point(1059, 162));
- _ballDrop->_z = 27;
+ _ballDrop->setOldAniPos(1059, 162, 27);
_ballDrop->_flags |= 4;
_balls.push_back(ball);
for (int i = 3; i != 0; --i) {
diff --git a/engines/ngi/fullpipe/mobile/sc06controller.h b/engines/ngi/fullpipe/mobile/sc06controller.h
index 6897c7756ee..57a775bd822 100644
--- a/engines/ngi/fullpipe/mobile/sc06controller.h
+++ b/engines/ngi/fullpipe/mobile/sc06controller.h
@@ -33,7 +33,7 @@ namespace NGI {
class PictureObject;
struct BehaviorMove;
-/** CSc06Controller: the arcade of scene 6 (scene logic only if controllerRunsSceneLogic()) */
+/** CSc06Controller: the arcade of scene 6 */
class Sc06Controller : public FPController {
public:
explicit Sc06Controller(int sceneId);
@@ -45,6 +45,7 @@ public:
void checkTutorial() override;
void onRemoveCopies() override;
void onSceneInit() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
void onKeyUp(uint32 key) override;
Commit: 635bd64c095623b90ec5534995cdc4871d1946b4
https://github.com/scummvm/scummvm/commit/635bd64c095623b90ec5534995cdc4871d1946b4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 8 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc08controller.cpp
engines/ngi/fullpipe/mobile/sc08controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc08controller.cpp b/engines/ngi/fullpipe/mobile/sc08controller.cpp
index a61264a25c9..2dd4ef0e767 100644
--- a/engines/ngi/fullpipe/mobile/sc08controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc08controller.cpp
@@ -246,8 +246,7 @@ void Sc08Controller::doStep2() {
g_ngi->arcadeInterface().setCounter(5);
_scene->findPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= ~4;
hero()->setStatic(ST_MAN8_HANDSUP);
- hero()->setPosition(Common::Point(386, 236));
- hero()->_z = 10;
+ hero()->setOldAniPos(386, 236, 10);
hero()->_flags |= 4;
_scene->runQueue(QU_SC8_FINISH, 2);
_inAir = false;
@@ -369,8 +368,7 @@ void Sc08Controller::doStep1() {
g_ngi->arcadeInterface().setCounter(4);
_scene->findPictureObjectById(PIC_SC8_LADDER, 0)->_flags &= ~4;
hero()->setStatic(ST_MAN8_HANDSUP);
- hero()->setPosition(Common::Point(376, 280));
- hero()->_z = 10;
+ hero()->setOldAniPos(376, 280, 10);
MessageQueue *queue = new MessageQueue(_scene, true, 1); // CMessageQueue(scene, 1, 1)
Command *command = new Command(hero()->_id, kCmdStartMovement, MV_MAN8_BADLUCK, 0, 0, 0, 1, 0, 0, 0);
diff --git a/engines/ngi/fullpipe/mobile/sc08controller.h b/engines/ngi/fullpipe/mobile/sc08controller.h
index 50063371ed6..b6d96304970 100644
--- a/engines/ngi/fullpipe/mobile/sc08controller.h
+++ b/engines/ngi/fullpipe/mobile/sc08controller.h
@@ -44,6 +44,7 @@ public:
void cleanXml() override;
void skipArcade() override;
void checkTutorial() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
void onKeyUp(uint32 key) override;
Commit: f13eaed7425c1318c8deb556cd5eadfa4fb3a70e
https://github.com/scummvm/scummvm/commit/f13eaed7425c1318c8deb556cd5eadfa4fb3a70e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 9 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc09controller.cpp
engines/ngi/fullpipe/mobile/sc09controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc09controller.cpp b/engines/ngi/fullpipe/mobile/sc09controller.cpp
index c2746d273ac..b4a930800df 100644
--- a/engines/ngi/fullpipe/mobile/sc09controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc09controller.cpp
@@ -401,7 +401,7 @@ void Sc09Controller::startEating(AniObject *ball) {
if (_gulper) {
_gulper->stopMovement();
_gulper->moveToStaticChain(ST_GLT_SIT);
- warnOnce("CBehaviorController::OnSetQueue is not ported (CSc09Controller::StartEating)");
+ _scene->_behaviorController->onSetQueue(_gulper->_id);
MessageQueue *queue = _scene->findMessageQueue(QU_SC9_EATBALL);
if (queue) {
MessageQueue *copy = new MessageQueue(queue, 0, 0);
@@ -581,7 +581,7 @@ void Sc09Controller::readSettingsXml() {
warning("Could not read sc_9_settings.xml");
}
-// CSc09Controller::OnShow (172604): only the camera margins are active
+// CSc09Controller::OnShow (172604)
void Sc09Controller::onShow() {
FPController::onShow();
if (controllerRunsSceneLogic()) {
@@ -613,8 +613,7 @@ void Sc09Controller::onShow() {
doUpdatePath();
_gulper->_flags |= 4;
_gulper->setStatic(ST_GLT_SIT);
- _gulper->setPosition(Common::Point(1537, 182));
- _gulper->_z = 20;
+ _gulper->setOldAniPos(1537, 182, 20);
_onLadder = false;
_dragIndex = -1;
_dragPhase = -1;
diff --git a/engines/ngi/fullpipe/mobile/sc09controller.h b/engines/ngi/fullpipe/mobile/sc09controller.h
index 37861277034..c7730107266 100644
--- a/engines/ngi/fullpipe/mobile/sc09controller.h
+++ b/engines/ngi/fullpipe/mobile/sc09controller.h
@@ -31,7 +31,7 @@ namespace NGI {
class GameVar;
-// CSc09Controller: the arcade of scene 9 (STUBs in the .cpp)
+// CSc09Controller: the arcade of scene 9
class Sc09Controller : public FPController {
public:
explicit Sc09Controller(int sceneId);
@@ -39,6 +39,7 @@ public:
void cleanXml() override;
void checkTutorial() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
void onSceneInit() override;
Commit: be58e5070c74091ef05bcaa9c6f16bd7c5eb01a4
https://github.com/scummvm/scummvm/commit/be58e5070c74091ef05bcaa9c6f16bd7c5eb01a4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 11 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc11controller.cpp
engines/ngi/fullpipe/mobile/sc11controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc11controller.cpp b/engines/ngi/fullpipe/mobile/sc11controller.cpp
index 190f000ed10..5fa8be26335 100644
--- a/engines/ngi/fullpipe/mobile/sc11controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc11controller.cpp
@@ -34,6 +34,7 @@
#include "ngi/interaction.h"
#include "ngi/messages.h"
#include "ngi/motion.h"
+#include "ngi/preloadmanager.h"
#include "ngi/scene.h"
#include "ngi/sound.h"
#include "ngi/statics.h"
@@ -67,15 +68,6 @@ float renderMargin() {
return (float)g_ngi->_wideOfs;
}
-// CInteractionController::FindInteraction(name, 0, 0): looked up by objects, the name is checked
-Interact *findInteractionByName(const char *name, int objectId) {
- Interact *interaction = getGameLoaderInteractionController()->findInteraction(objectId, ANI_MAN, 0);
- if (interaction && interaction->_actionName == name) {
- return interaction;
- }
- return nullptr;
-}
-
// sc_11_settings.xml (CSc11Controller::ReadSettingsXml)
class Scene11SettingsParser : public Common::XMLParser {
public:
@@ -212,7 +204,12 @@ void Sc11Controller::onArcadeClick() {
// CSc11Controller::DoSwingerJumpdown (174534)
void Sc11Controller::doSwingerJumpdown() {
- _scene->runQueue(QU_SWR_JUMPDOWN, 2);
+ MessageQueue *queue = _scene->findMessageQueue(QU_SWR_JUMPDOWN);
+ if (queue) {
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ copy->setIntState(2);
+ _scene->runQueueObject(copy, nullptr, 4);
+ }
_swingerSwinging = false;
_swingerStands = true;
_swingerEdge = (int)(float)_scene->_x;
@@ -238,7 +235,11 @@ void Sc11Controller::tryHitMan() {
if ((float)hero()->getCenter().x > 345.0f) {
if ((float)hero()->getCenter().x < 355.0f) {
hero()->setStatic(ST_MAN_RIGHT);
- _scene->runQueueWithAni(QU_SC11_MANFALL, hero());
+ MessageQueue *queue = _scene->findMessageQueue(QU_SC11_MANFALL);
+ if (queue) {
+ MessageQueue *copy = new MessageQueue(queue, 0, 0);
+ _scene->runQueueObject(copy, hero(), 4);
+ }
}
}
}
@@ -356,7 +357,7 @@ void Sc11Controller::swingNextFunc2(AniObject *ani) {
// CSc11Controller::DoRestartMan (174C50): the man stands up after the jump
void Sc11Controller::doRestartMan() {
- _scene->runQueueWithAni(QU_SC11_RESTARTMAN, hero(), 2);
+ _scene->runQueue(QU_SC11_RESTARTMAN, 2, true);
getGameLoaderInteractionController()->_enabled = true;
_scene->_motionController->activate();
}
@@ -464,8 +465,7 @@ void Sc11Controller::doRetire() {
_swing->_flags |= 4;
hero()->_flags |= 4;
hero()->setStatic(ST_MAN11_SWING);
- // CVisibleObject::SetPos(685, 373, z): the z of the hero stays
- hero()->setPosition(Common::Point(685, 373));
+ hero()->setOldAniPos(685, 373, hero()->_z);
hero()->startMovement(MV_MAN11_JUMPFROMSWING, 0, -1);
_follow = hero();
g_ngi->_hintManager->hideHint(_scene);
@@ -526,8 +526,7 @@ void Sc11Controller::doJumpToTruba() {
hero()->_flags |= 4;
const float x = (float)(691.0 - sine * 267.0);
const float y = (float)(cosine * 267.0 + 218.0);
- hero()->setPosition(Common::Point((int)x, (int)y));
- hero()->_z = 10;
+ hero()->setOldAniPos((int)x, (int)y, 10);
hero()->setStatic(ST_MAN11_STARTJUMP);
_follow = hero();
@@ -600,8 +599,7 @@ void Sc11Controller::doBumpTruba(double angle) {
hero()->_flags |= 4;
const float x = (float)(691.0 - sine * 267.0);
const float y = (float)(cosine * 267.0 + 218.0);
- hero()->setPosition(Common::Point((int)x, (int)y));
- hero()->_z = 10;
+ hero()->setOldAniPos((int)x, (int)y, 10);
hero()->setStatic(ST_MAN11_STARTJUMP);
MakeQueueStruct mkQueue;
@@ -636,8 +634,7 @@ void Sc11Controller::doMissTruba(double angle) {
hero()->_flags |= 4;
const float x = (float)(691 - (int)(sine * 267.0));
const float y = (float)((int)(cosine * 267.0) + 218);
- hero()->setPosition(Common::Point((int)x, (int)y));
- hero()->_z = 0;
+ hero()->setOldAniPos((int)x, (int)y, 0);
hero()->setStatic(ST_MAN11_STARTJUMP);
MakeQueueStruct mkQueue;
@@ -726,15 +723,10 @@ void Sc11Controller::doManToPipe() {
started->setIntState(2);
}
} else {
- Interact *interaction = findInteractionByName("INT_070", PIC_SC11_LTRUBA);
+ Interact *interaction = getGameLoaderInteractionController()->findInteractionByName("INT_070");
if (interaction && interaction->_messageQueue) {
- // CScene::RunQueueWithAni(scene, queue, hero, 2)
- MessageQueue *queue = new MessageQueue(interaction->_messageQueue, 0, 0);
- queue->_scene = _scene;
- queue->setIntState(2);
- if (!queue->run(hero())) {
- delete queue;
- }
+ // CScene::RunQueueWithAni (1228AE)
+ _scene->runQueueObject(interaction->_messageQueue, hero(), 2);
}
}
}
@@ -888,7 +880,7 @@ void Sc11Controller::onHide() {
FPController::onHide();
if (logic) {
g_ngi->_exitManager->resetExitIntersect(PIC_SC11_LTRUBA, false);
- warnOnce("CAniObject::UnloadMovement / CPreloadManager::OnUnloadMove (CSc11Controller::OnHide): MV_KCH_MOVE2 is not unloaded");
+ g_ngi->_preloadManager->onUnloadMove(_swing->unloadMovement(MV_KCH_MOVE2));
g_ngi->_hintManager->hideHint(_scene);
}
}
@@ -1097,12 +1089,8 @@ void Sc11Controller::updateScroll() {
FPController::updateScroll();
return;
}
- bool smooth = _arcadeRunning;
- if (!smooth) {
- // INT_071 (the man jumps to the swing) runs while its current command (+56) is not -1
- warnOnce("CSc11Controller::UpdateScroll: the running state of the queue of the interaction INT_071 (CMessageQueue +56) is not known, it counts as not running");
- }
- _smooth = smooth;
+ // INT_071 (the man jumps to the swing) runs while the current command of its queue is not -1
+ _smooth = _arcadeRunning || interactionCommandNum("INT_071") != -1;
if (_follow) {
const Common::Point center = _follow->getCenter();
_heroCenterX = (float)center.x;
diff --git a/engines/ngi/fullpipe/mobile/sc11controller.h b/engines/ngi/fullpipe/mobile/sc11controller.h
index d1b6c3cddaa..22fb77ec4a0 100644
--- a/engines/ngi/fullpipe/mobile/sc11controller.h
+++ b/engines/ngi/fullpipe/mobile/sc11controller.h
@@ -40,6 +40,7 @@ public:
bool canShowHelp() override;
void checkTutorial() override;
void skipArcade() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
void onKeyUp(uint32 key) override;
Commit: 8a0c48ae57ec9ee919cd4023226190545f5e686d
https://github.com/scummvm/scummvm/commit/8a0c48ae57ec9ee919cd4023226190545f5e686d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 14 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc14controller.cpp
engines/ngi/fullpipe/mobile/sc14controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc14controller.cpp b/engines/ngi/fullpipe/mobile/sc14controller.cpp
index 6a18cb66ded..1fbf14c0610 100644
--- a/engines/ngi/fullpipe/mobile/sc14controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc14controller.cpp
@@ -48,11 +48,6 @@ namespace NGI {
namespace {
-// CMessageQueue::Stop(queue, 0): the engine has no counterpart (the queue is not stopped)
-void stopQueue(MessageQueue *) {
- warnOnce("CMessageQueue::Stop: the queue is not stopped (CSc14Controller::DoWinArcade, CSc14Controller::DoManSurrender)");
-}
-
// CInteractionController::FindInteraction(scene, objectId, -1) + CInteract::Run: true if found
bool runInteraction(Scene *scene, int objectId) {
Interact *interaction = getGameLoaderInteractionController()->findInteraction(scene, objectId, -1);
@@ -221,6 +216,7 @@ void Sc14Controller::doShowBallFly() {
_flyingBall->_z = 5;
_flyingBall->startMovement(MV_BAL14_SPIN, 0, -1);
_ballFlying = true;
+ debugC(1, kDebugInfo, "INFO t %u SC14 throw: ball %d.%d at %d,%d", g_system->getMillis(), _flyingBall->_id, _flyingBall->_copyId, (int)_ballX, (int)_ballY);
}
// CSc14Controller::DoShowBallFallgrandma2 (1789F8): ball that hit the grandma stays in front of her
@@ -334,8 +330,10 @@ void Sc14Controller::doWinArcade() {
g_ngi->setState(sO_Grandma, g_ngi->getStateValue(sO_Grandma, sO_In_15));
MessageQueue *grandmaQueue = _grandma->getMessageQueue();
if (grandmaQueue)
- stopQueue(grandmaQueue);
- stopQueue(_scene->findMessageQueue(QU_SC14_STARTARCADE));
+ grandmaQueue->stop(false);
+ MessageQueue *startQueue = _scene->findMessageQueue(QU_SC14_STARTARCADE);
+ if (startQueue)
+ startQueue->stop(false);
_grandma->setStatic(ST_GMA_SIT, false);
_grandma->_flags &= ~4;
g_ngi->_taskManager->deactivateTask("KICK_GRANDMA_SC14");
@@ -377,6 +375,7 @@ bool Sc14Controller::onLButtonUp() {
hero()->setCurFrame(11);
_kickFrame = hero()->getCurFrame();
+ debugC(1, kDebugInfo, "INFO t %u SC14 let go: ball %s, hero x %d, ball x %d", g_system->getMillis(), _flyingBall ? "flies" : "none", (int)_manX, _flyingBall ? _flyingBall->getPosition().x : 0);
// analytics total_moves_ANI_GRANDMA: not ported
stopDragging();
if (_flyingBall && (float)(_manX - (float)_flyingBall->getPosition().x) < _kickMaxDx) {
@@ -427,6 +426,7 @@ void Sc14Controller::doGrandmaShoot() {
// CSc14Controller::DoFallBall (179444): the ball falls to the ground, the grandma throws the next
void Sc14Controller::doFallBall() {
+ debugC(1, kDebugInfo, "INFO t %u SC14 ball falls", g_system->getMillis());
_flyingBall->stopMovement();
_flyingBall->_z = 27;
MessageQueue *queue = new MessageQueue(_scene, true, 1);
@@ -453,7 +453,8 @@ void Sc14Controller::doGrandmaForward() {
// CSc14Controller::DoManHit (179664): the ball hits the hero, he falls (the grandma comes forward)
void Sc14Controller::doManHit() {
- if (!hero()->_movement || hero()->_movement->_id != MV_MAN14_FALL) {
+ debugC(1, kDebugInfo, "INFO t %u SC14 ball hits the hero, hits left %d", g_system->getMillis(), _hitsLeft);
+ if (!hero()->_movement || hero()->_lastMovementId != MV_MAN14_FALL) {
stopDragging();
hero()->moveToStaticChain(ST_MAN_RIGHT);
hero()->startMovement(MV_MAN14_FALL, 0, -1);
@@ -478,6 +479,7 @@ void Sc14Controller::doManForward() {
// CSc14Controller::DoGrandmaHit (179788): ball hits the grandma, she backs off (last hit ends it)
void Sc14Controller::doGrandmaHit() {
+ debugC(1, kDebugInfo, "INFO t %u SC14 ball hits the grandma, hits left %d", g_system->getMillis(), _hitsLeft);
_flyingBall->stopMovement();
_flyingBall->_flags &= ~4;
if (_manKicking)
@@ -495,12 +497,12 @@ void Sc14Controller::doGrandmaHit() {
_scene->runQueueObject(queue, _grandma, 2);
doManForward();
} else {
- g_ngi->lift().enableButton(sO_Level4, ST_LBN_4N);
+ g_ngi->lift().enableButton(sO_Level4, projectId("ST_LBN_4N"));
g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
// CFPController::FlurryArcadeEnd("ANI_GRANDMA"): the analytics event is not ported
g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_ARCADE_14", 100, "UNDEF");
hero()->moveToStaticChain(ST_MAN_RIGHT);
- hero()->setPosition(Common::Point(1020, 454));
+ hero()->setOldAniPos(1020, 454, hero()->_z);
stopDragging();
_manCanKick = false;
_scene->runQueue(QU_SC14_WINARCADE, 2);
@@ -591,7 +593,7 @@ void Sc14Controller::skipArcade() {
FPController::skipArcade();
return;
}
- g_ngi->lift().enableButton(sO_Level4, ST_LBN_4N);
+ g_ngi->lift().enableButton(sO_Level4, projectId("ST_LBN_4N"));
g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
g_ngi->arcadeInterface().scrollOut();
if (_manKicking) {
@@ -606,10 +608,7 @@ void Sc14Controller::skipArcade() {
_ballFlying = false;
stopArcade();
_grandmaHere = false;
- // CVisibleObject::StopQueue
- MessageQueue *grandmaQueue = _grandma->getMessageQueue();
- if (grandmaQueue)
- stopQueue(grandmaQueue);
+ _grandma->stopQueue(); // CVisibleObject::StopQueue (EF19A)
if (_grandma->_movement)
_grandma->stopMovement();
_grandma->setStatic(ST_GMA_SIT, false);
@@ -686,7 +685,7 @@ void Sc14Controller::onShow() {
_scene->addAni(copy, true);
}
_grandma->setStatic(ST_GMA_SIT, false);
- _grandma->setPosition(Common::Point(713, 457));
+ _grandma->setOldAniPos(713, 457, _grandma->_z);
Movement *throwing = _grandma->getMovement(MV_GMA_THROW);
if (throwing)
throwing->_loopDelay = (int)(float)(_grandmaFrameDelayK * 83.0f);
@@ -715,7 +714,7 @@ void Sc14Controller::onKeyUp(uint32 key) {
return;
if (key == 87) {
doWinArcade();
- g_ngi->lift().enableButton(sO_Level4, ST_LBN_4N);
+ g_ngi->lift().enableButton(sO_Level4, projectId("ST_LBN_4N"));
g_ngi->lift().initLift(_scene, hero(), QU_SC14_ENTERLIFT, QU_SC14_EXITLIFT);
} else if (key == 81) {
skipArcade();
@@ -744,7 +743,7 @@ void Sc14Controller::onUpdate(uint32 elapsed) {
if (_manFrameTimer)
manNextFunc(elapsed);
AniObject *man = hero();
- if (man->_movement && man->_movement->_id == MV_MAN14_KICK) {
+ if (man->_movement && man->_lastMovementId == MV_MAN14_KICK) {
const Common::Point center = man->getCenter();
_manX = center.x;
_manY = center.y;
diff --git a/engines/ngi/fullpipe/mobile/sc14controller.h b/engines/ngi/fullpipe/mobile/sc14controller.h
index 2390303227c..6bdd9ecfda8 100644
--- a/engines/ngi/fullpipe/mobile/sc14controller.h
+++ b/engines/ngi/fullpipe/mobile/sc14controller.h
@@ -39,6 +39,7 @@ public:
bool canShowHelp() override;
void skipArcade() override;
void checkTutorial() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
void onRender(Common::Point scroll) override;
Commit: e4f65b7ba3e9aee07f963a7be725fbb4f5431824
https://github.com/scummvm/scummvm/commit/e4f65b7ba3e9aee07f963a7be725fbb4f5431824
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Port CMovement::GetStepToFrame
Changed paths:
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index dd6e52fd59b..54092275f3d 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -2412,6 +2412,22 @@ Common::Point Movement::getCenterMovementSize(int idx, int dynidx) {
return Common::Point((int)roundf(dx), (int)roundf(dy));
}
+// CMovement::GetStepToFrame (EF05E)
+void Movement::getStepToFrame(int frame, float &dx, float &dy) const {
+ dx = 0.0f;
+ dy = 0.0f;
+ if (frame >= (int)_phases.size() || frame < 0 || frame >= (int)_framePosOffsets.size())
+ return;
+ for (int i = 0; i <= frame; i++) {
+ dx += (float)_framePosOffsets[i].x;
+ dy += (float)_framePosOffsets[i].y;
+ }
+ const Dims first = _phases[0]->getDimensions();
+ const Dims current = _phases[frame]->getDimensions();
+ dx -= (float)(first.x - current.x) * 0.5f;
+ dy -= (float)(first.y - current.y) * 0.5f;
+}
+
Common::Point Movement::getMovementSize(int idx, int dynidx) {
int oldox = _x;
int oldoy = _y;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 9095351d17a..e33bcfe7709 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -165,6 +165,8 @@ class Movement : public GameObject {
// 2015 (CMovement::GetMovementSize): displacement of the sprite center, used to plan walks
Common::Point getCenterMovementSize(int idx, int dynidx);
void getCenterDisplacement(float &dx, float &dy) const;
+ /** CMovement::GetStepToFrame (EF05E) */
+ void getStepToFrame(int frame, float &dx, float &dy) const;
void initStatics(AniObject *ani);
void updateCurrDynamicPhase();
Commit: 01ba972043caa329d7bbffc9311502109ff77fca
https://github.com/scummvm/scummvm/commit/01ba972043caa329d7bbffc9311502109ff77fca
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 18 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc18controller.cpp
engines/ngi/fullpipe/mobile/sc18controller.h
engines/ngi/fullpipe/mobile/sc19controller.cpp
diff --git a/engines/ngi/fullpipe/mobile/sc18controller.cpp b/engines/ngi/fullpipe/mobile/sc18controller.cpp
index 902789d8e10..a76167dae85 100644
--- a/engines/ngi/fullpipe/mobile/sc18controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc18controller.cpp
@@ -55,10 +55,16 @@ static void setLadderVes(const char *first, const char *second, const Common::St
}
}
-// CVisibleObject::SetPos(vector3) with the depth
+// the virtual SetPos (+ 80) of an OLDANI: COldAniObject::SetPos (161924)
static void setPos(AniObject *ani, float x, float y, int z) {
- ani->setPosition(Common::Point((int)x, (int)y));
- ani->_z = z;
+ ani->setOldAniPos((int)x, (int)y, z);
+}
+
+// CScene::AddAni(ani, 0); Scene::addAni(true) would clear the state of a copy 0
+static void addAniKeepState(Scene *scene, AniObject *ani) {
+ ani->assignCopyId(&scene->_aniObjects);
+ scene->addAni(ani, false);
+ scene->_renderableAnis.push_back(ani);
}
// CSc18Controller::CSc18Controller (17D710)
@@ -119,6 +125,7 @@ void Sc18Controller::saveState() {
// CSc18Controller::PrepareBoyTo (17D8AC)
void Sc18Controller::prepareBoyTo() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 boy flies to the swing", g_system->getMillis());
_boy->stopMovement(false);
_boy->_flags |= 4;
setPos(_boy, _boyX, _boyY, 50);
@@ -127,6 +134,7 @@ void Sc18Controller::prepareBoyTo() {
// CSc18Controller::PrepareGirlTo (17D914)
void Sc18Controller::prepareGirlTo() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 girl flies to the swing", g_system->getMillis());
_girl->stopMovement(false);
_girl->_flags |= 4;
setPos(_girl, _girlX, _girlY, 50);
@@ -135,6 +143,7 @@ void Sc18Controller::prepareGirlTo() {
// CSc18Controller::PrepareManTo (17D978)
void Sc18Controller::prepareManTo() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 hero boards the swing", g_system->getMillis());
hero()->setCenter(Common::Point(967, 379));
hero()->setStatic(ST_MAN_RIGHT, false);
hero()->_z = 35;
@@ -161,6 +170,7 @@ void Sc18Controller::tickCellsNoswing() {
// CSc18Controller::DoShowBoyJump (17DA88)
void Sc18Controller::doShowBoyJump() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 boy jumps off", g_system->getMillis());
const Common::Point center = _cells[_boyCell].ani->getCenter();
_boy->_flags |= 4;
_boy->setStatic(ST_BOY18_FLYFROM, false);
@@ -175,6 +185,7 @@ void Sc18Controller::doShowBoyJump() {
// CSc18Controller::DoShowGirlJump (17DB6C)
void Sc18Controller::doShowGirlJump() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 girl jumps off", g_system->getMillis());
const Common::Point center = _cells[_boyCell].ani->getCenter();
float x = (float)center.x - 62.0f;
float y = (float)center.y - 10.0f;
@@ -194,6 +205,7 @@ void Sc18Controller::doShowGirlJump() {
// CSc18Controller::DoShowBoyJumpto (17DC60)
void Sc18Controller::doShowBoyJumpto() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 boy lands on the swing", g_system->getMillis());
_boy->stopMovement(false);
_boy->_flags &= ~4;
_cells[_targetCell].kind = 2;
@@ -205,6 +217,7 @@ void Sc18Controller::doShowBoyJumpto() {
// CSc18Controller::DoShowGirlJumpto (17DCD8)
void Sc18Controller::doShowGirlJumpto() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 girl lands on the swing", g_system->getMillis());
_girl->stopMovement(false);
_girl->_flags &= ~4;
_cells[_targetCell].kind = 4;
@@ -311,11 +324,16 @@ void Sc18Controller::tickCells() {
float y = ((float)(int)(sin(angle) * 575.0) + _centerY) + 87.0f;
cell.x = x;
cell.y = y;
- if (cell.ani->_movement)
- warning("STUB/untested: CMovement::GetStepToFrame (the slide of the swing movement is not added)");
AniObject *ani = _cells[i].ani;
+ if (ani->_movement && ani->_movement->_curFrame != -1) {
+ float stepX;
+ float stepY;
+ ani->_movement->getStepToFrame(ani->_movement->_curFrame, stepX, stepY);
+ x += stepX;
+ y += stepY;
+ }
if (ani->_movement) {
- const int movementId = ani->_movement->_id;
+ const int movementId = ani->_lastMovementId;
if ((movementId & ~2) == MV_KSL_JUMPBOY) {
x -= 5.0f;
} else if (movementId == MV_KSL_CALMDOWN) {
@@ -368,12 +386,13 @@ void Sc18Controller::tickCells() {
if (_manOnWheel) {
if ((int)i == _manCell) {
const double a = _cells[i].angle;
- if (a >= 2.9670597283903573 && prev < 2.9670597283903573) {
+ if (a >= 2.9670597283903573 && prev < 2.9670597283903573)
g_ngi->_gameLoader->preloadScene(SC_19, TrubaRight); // CGame::SetScene
- } else if (a >= 0.43633231299858194 && prev < 0.43633231299858194) {
+ if (a < 0.43633231299858194 || prev >= 0.43633231299858194) {
+ if (a >= 4.188790204786387 && prev < 4.188790204786387)
+ _scene->_x += 1200;
+ } else {
g_ngi->_gameLoader->preloadScene(SC_18, TrubaRight); // CGame::SetScene
- } else if (a >= 4.188790204786387 && prev < 4.188790204786387) {
- _scene->_x += 1200;
}
}
if (_manRides > 0) {
@@ -397,13 +416,14 @@ void Sc18Controller::tickCells() {
// CSc18Controller::DoShowManJump (17E620)
void Sc18Controller::doShowManJump() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 hero jumps off", g_system->getMillis());
const Common::Point center = _cells[_manJumpCell].ani->getCenter();
hero()->_flags |= 4;
hero()->setCenter(Common::Point((int)((float)center.x + 62.0f), (int)((float)center.y + 5.0f)));
hero()->setStatic(ST_MAN18_JUMP, false);
hero()->_z = 35;
MessageQueue *queue = nullptr;
- switch (_riderKind) {
+ switch (_manRides) {
case 1:
queue = copyQueue(_scene, QU_SC19_MANJUMP1);
break;
@@ -431,6 +451,7 @@ void Sc18Controller::doShowManJump() {
// CSc18Controller::DoShowManJumpto (17E770)
void Sc18Controller::doShowManJumpto() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 hero sits on the swing", g_system->getMillis());
hero()->setStatic(ST_MAN_RIGHT, false);
setSaving(false);
hero()->_flags &= ~4;
@@ -448,6 +469,7 @@ void Sc18Controller::doShowManJumpto() {
// CSc18Controller::UpdateNumRides (17E850)
void Sc18Controller::updateNumRides() {
+ debugC(1, kDebugInfo, "INFO t %u SC18 num rides", g_system->getMillis());
int rides = atoi(g_ngi->getState(sO_DudeSwinged).c_str());
rides++;
if (rides > 1) {
@@ -561,9 +583,9 @@ void Sc18Controller::initSwitch1819() {
_chair = wheelScene->findAniObjectById(ANI_KRESLO, 0);
_centerX = 1024.0f;
_centerY = 242.0f;
- _scene->addAni(_chair, false);
- _scene->addAni(_boy, false);
- _scene->addAni(_girl, false);
+ addAniKeepState(_scene, _chair);
+ addAniKeepState(_scene, _boy);
+ addAniKeepState(_scene, _girl);
_wheelActive = true;
}
_angle = 0.0f;
@@ -698,14 +720,17 @@ void Sc18Controller::onHide() {
for (uint i = 0; i < _cells.size(); i++) {
WheelCell &cell = _cells[i];
- cell.movementId = cell.ani->_movement ? cell.ani->_movement->_id : 0;
+ cell.movementId = cell.ani->_lastMovementId;
cell.visible = (cell.ani->_flags & 4) != 0;
cell.staticsId = cell.ani->getStaticsId();
cell.frame = cell.ani->getCurFrame();
if (i != 0) {
if (_scene->_sceneId != SC_18)
_scene->removeAni(cell.ani);
- warning("STUB/untested: CAniObject::RemoveThis (the extra swings are not released)");
+ // CAniObject::RemoveThis (EEB54): CScene::RemoveAni, then the destructor
+ _scene->removeAni(cell.ani);
+ delete cell.ani;
+ cell.ani = nullptr;
} else {
cell.ani->_flags &= ~4;
if (_scene->_sceneId != SC_18)
@@ -790,10 +815,10 @@ void Sc18Controller::onUpdate(uint32 elapsed) {
else
_scene->_motionController->activate();
if (_wheelRuns) {
- float angle = (float)((double)_lastAngle + (double)elapsed * 0.013962634224014083 / 83.0);
+ double angle = (double)_lastAngle + (double)elapsed * 0.013962634224014083 / 83.0;
if (angle > kTwoPi)
- angle = (float)(angle - kTwoPi);
- _angle = angle;
+ angle -= kTwoPi;
+ _angle = (float)angle;
_wheel->_rotation = _angle;
}
}
diff --git a/engines/ngi/fullpipe/mobile/sc18controller.h b/engines/ngi/fullpipe/mobile/sc18controller.h
index 77d24e7b18f..64c01a56d5f 100644
--- a/engines/ngi/fullpipe/mobile/sc18controller.h
+++ b/engines/ngi/fullpipe/mobile/sc18controller.h
@@ -36,6 +36,7 @@ public:
explicit Sc18Controller(int sceneId);
~Sc18Controller() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
diff --git a/engines/ngi/fullpipe/mobile/sc19controller.cpp b/engines/ngi/fullpipe/mobile/sc19controller.cpp
index ec52456d44b..adc0a968969 100644
--- a/engines/ngi/fullpipe/mobile/sc19controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc19controller.cpp
@@ -55,10 +55,10 @@ void Sc19Controller::onShow() {
AniObject *cordie = _scene->findAniObjectById(ANI_CORDIE, 0);
cordie->stopMovement(false);
if (g_ngi->getState(sO_Sugar) == sO_Present) {
- cordie->setPosition(Common::Point(227, 377));
+ cordie->setOldAniPos(227, 377, cordie->_z);
cordie->setStatic(ST_CDI_SUGAR, false);
} else {
- cordie->setPosition(Common::Point(230, 315));
+ cordie->setOldAniPos(230, 315, cordie->_z);
cordie->setStatic(ST_CDI_EMPTY2, false);
}
}
@@ -108,8 +108,7 @@ void Sc19Controller::onMessage(const Common::String &message, const Common::Stri
AniObject *cordie = _scene->findAniObjectById(ANI_CORDIE, 0);
cordie->setStatic(ST_CDI_SUGAR, false);
cordie = _scene->findAniObjectById(ANI_CORDIE, 0);
- cordie->setPosition(Common::Point(227, 377));
- cordie->_z = 20;
+ cordie->setOldAniPos(227, 377, 20);
} else {
FPController::onMessage(message, param, queue);
}
Commit: ca3a9d6719060ec851d5199b708764fd3607a2f9
https://github.com/scummvm/scummvm/commit/ca3a9d6719060ec851d5199b708764fd3607a2f9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 27 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc27controller.cpp
engines/ngi/fullpipe/mobile/sc27controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc27controller.cpp b/engines/ngi/fullpipe/mobile/sc27controller.cpp
index a5016088f3e..9abecc1224a 100644
--- a/engines/ngi/fullpipe/mobile/sc27controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc27controller.cpp
@@ -22,6 +22,7 @@
#include "common/formats/xmlparser.h"
#include "common/hashmap.h"
#include "common/str.h"
+#include "common/system.h"
#include "ngi/ngi.h"
#include "ngi/behavior.h"
@@ -56,11 +57,6 @@ void stopMovementAndQueue(AniObject *ani) {
queue->interrupt(false);
}
-// CBehaviorController::OnSetQueue (F3774): CBehaviorAni::Stop, not ported
-void behaviorOnSetQueue(AniObject *ani) {
- warnOnce("CBehaviorController::OnSetQueue (CBehaviorAni::Stop, CSc27Controller)");
-}
-
// a double from its two words (the constants of GenerateTest are read from the code)
double doubleFromWords(uint32 high, uint32 low) {
const uint64 bits = ((uint64)high << 32) | low;
@@ -125,8 +121,10 @@ private:
Sc27Controller::Sc27Controller(int sceneId) : FPController(sceneId), _tutorial("ARCADE_TUTORIAL_27") {
}
-// CSc27Controller::~CSc27Controller (189DA8): RemoveCopies left out, the scene destroys the objects
+// CSc27Controller::~CSc27Controller (189DA8): the scene deletes its animations itself when it goes
Sc27Controller::~Sc27Controller() {
+ if (_scene && !_scene->_destroying)
+ removeCopies();
}
// CSc27Controller::CanSwipeMan (188148): not while the arcade runs
@@ -169,6 +167,7 @@ void Sc27Controller::manNextFunc(uint32 elapsed) {
if (!_maxPhase) {
if (frame > 4) {
_maxPhase = true;
+ debugC(1, kDebugInfo, "INFO t %u SC27 drawn back", g_system->getMillis());
} else {
_manTimer = 0;
frame = frame + 1;
@@ -206,7 +205,7 @@ void Sc27Controller::switchMaid() {
if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSwab)) {
if (_maid->_movement || _maid->getMessageQueue()) {
stopMovementAndQueue(_maid);
- behaviorOnSetQueue(_maid);
+ _scene->_behaviorController->onSetQueue(_maid->_id);
}
_maid->moveToStaticChain(ST_MID_SWAB2);
_scene->runQueue(QU_MID_SWITCH, 3);
@@ -218,7 +217,7 @@ void Sc27Controller::switchMaidBack() {
if (g_ngi->getStateId(sO_Maid) == g_ngi->getStateValue(sO_Maid, sO_WithSwab)) {
if (_maid->_movement || _maid->getMessageQueue()) {
stopMovementAndQueue(_maid);
- behaviorOnSetQueue(_maid);
+ _scene->_behaviorController->onSetQueue(_maid->_id);
}
_maid->moveToStaticChain(ST_MID_SWAB);
_scene->runQueue(QU_MID_SWITCHBACK, 3);
@@ -227,6 +226,7 @@ void Sc27Controller::switchMaidBack() {
// CSc27Controller::DoPushButton (188568): no bets left, the driver pushes the button
void Sc27Controller::doPushButton() {
+ debugC(1, kDebugInfo, "INFO t %u SC27 no bets left, the driver pushes the button", g_system->getMillis());
if (g_ngi->getStateId(sO_Driver) == g_ngi->getStateValue(sO_Driver, sO_WithSteering)) {
if (!_driver->_movement || _driver->getMessageQueue())
stopMovementAndQueue(_driver);
@@ -398,6 +398,7 @@ void Sc27Controller::showNextBet() {
// CSc27Controller::DoWin (18903C): the driver gives the vent, the controls are free again
void Sc27Controller::doWin() {
+ debugC(1, kDebugInfo, "INFO t %u SC27 win", g_system->getMillis());
// Flurry events (analytics) are not ported
_startEvent = true;
g_ngi->arcadeInterface().scrollOut();
@@ -410,7 +411,7 @@ void Sc27Controller::doWin() {
getGameLoaderInteractionController()->enable();
_scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
g_ngi->_hintManager->hideHint(_scene);
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ setSaving(true);
}
// CSc27Controller::DoWinArcade (189174): MSG_CMN_WINARCADE and the key W
@@ -432,7 +433,7 @@ void Sc27Controller::doTakeBet(MessageQueue *queue) {
if (!_arcadeRunning)
g_ngi->_hintManager->showHint(_scene, 0, 0);
_startEvent = false;
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ setSaving(false);
hero()->startMovement(MV_MAN27_THROWBET, 0, -1);
hero()->getMovement(MV_MAN27_THROWBET)->_loopDelay = 83 * (int)_frameDelayK;
_scene->_motionController->deactivate();
@@ -451,6 +452,7 @@ void Sc27Controller::skipArcade() {
return;
}
g_ngi->arcadeInterface().scrollOut();
+ debugC(1, kDebugInfo, "INFO t %u SC27 skip, %d bets move", g_system->getMillis(), _movingBets);
if (_movingBets != 0) {
_skipArcade = true;
} else {
@@ -472,7 +474,7 @@ void Sc27Controller::skipArcade() {
getGameLoaderInteractionController()->enable();
_scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
g_ngi->_hintManager->hideHint(_scene);
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ setSaving(true);
// CFPController::FlurryArcadeSkip "ANI_BET": analytics, not ported
_startEvent = true;
}
@@ -497,7 +499,7 @@ void Sc27Controller::prepareNextBet(int highlighted) {
queue->setIntState(2);
_batHandler->_z = 985;
queue->addCommandToEnd(movementCommand(_batHandler, movementId));
- queue->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET", 0, 3));
+ queue->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET"));
// CScene::RunQueue(queue, 4, 0): added to the scene and run, the object does not get it
if (!queue->run(nullptr)) {
delete queue;
@@ -511,13 +513,14 @@ void Sc27Controller::prepareNextBet(int highlighted) {
_scene->_behaviorController->enableAllQueuesForAni(hero(), 1);
_arcadeRunning = false;
g_ngi->_hintManager->hideHint(_scene);
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ setSaving(true);
// Flurry events (analytics) are not ported
}
}
// CSc27Controller::DoRestart (1897A8): the bets that fell are put back, the next one is made ready
void Sc27Controller::doRestart() {
+ debugC(1, kDebugInfo, "INFO t %u SC27 restart", g_system->getMillis());
// Flurry events (analytics) are not ported
_wiping = false;
for (uint i = 0; i < _fallenBets.size(); ++i) {
@@ -531,6 +534,7 @@ void Sc27Controller::doRestart() {
// CSc27Controller::OnStopAll (18989C): won, or the driver pushes the button, or next bet
void Sc27Controller::onStopAll() {
+ debugC(1, kDebugInfo, "INFO t %u SC27 all bets stopped", g_system->getMillis());
if (!_wiping) {
if (!_buttonPushed) {
int highlighted = 0;
@@ -589,7 +593,7 @@ void Sc27Controller::onBetClick(MessageQueue *queue) {
MessageQueue *started = mctlStartMove(181, 456, true, ST_MAN_RIGHT, mirror);
if (started)
- started->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET", 0, 3));
+ started->addCommandToEnd(messageCommand("MSG_SC27_CLICKBET"));
}
// CSc27Controller::RemoveCopies (189D00): the copies of the bets leave the scene
@@ -641,6 +645,7 @@ void Sc27Controller::doShootBet(AniObject *ani) {
ani->setCenter(Common::Point((int)x, (int)bet._y));
ani->_flags |= 4;
_bets.push_back(bet);
+ debugC(1, kDebugInfo, "INFO t %u SC27 bet thrown, power %d", g_system->getMillis(), (int)bet._power);
switchMaid();
}
@@ -836,7 +841,7 @@ void Sc27Controller::onHide() {
// CFPController::FlurryArcadeClean "ANI_BET" and the lose events: analytics, not ported
if (g_ngi->arcadeInterface().getState() != ArcadeInterface::kHidden)
g_ngi->arcadeInterface().scrollOut();
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc27Controller)");
+ setSaving(true);
removeCopies();
g_ngi->_hintManager->hideHint(_scene);
FPController::onHide();
diff --git a/engines/ngi/fullpipe/mobile/sc27controller.h b/engines/ngi/fullpipe/mobile/sc27controller.h
index 111f496fa2b..9b3f9e335e9 100644
--- a/engines/ngi/fullpipe/mobile/sc27controller.h
+++ b/engines/ngi/fullpipe/mobile/sc27controller.h
@@ -43,6 +43,7 @@ public:
bool canShowHelp() override;
void skipArcade() override;
void checkTutorial() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
int getCursorType(float x, float y) override;
Commit: a6d7d5642b1654d0642c2b9aef828f4412cfd4ac
https://github.com/scummvm/scummvm/commit/a6d7d5642b1654d0642c2b9aef828f4412cfd4ac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Switch scene 29 to its controller
Changed paths:
engines/ngi/fullpipe/mobile/sc29controller.cpp
engines/ngi/fullpipe/mobile/sc29controller.h
diff --git a/engines/ngi/fullpipe/mobile/sc29controller.cpp b/engines/ngi/fullpipe/mobile/sc29controller.cpp
index e5d4ae96897..25d91d5b4e8 100644
--- a/engines/ngi/fullpipe/mobile/sc29controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc29controller.cpp
@@ -21,6 +21,7 @@
#include "common/hashmap.h"
#include "common/str.h"
+#include "common/system.h"
#include "ngi/ngi.h"
#include "ngi/behavior.h"
@@ -62,10 +63,10 @@ Sc29Controller::Sc29Controller(int sceneId) : FPController(sceneId), _tutorial("
_shootDelay = 6225;
}
-// CSc29Controller::~CSc29Controller (18E378): no RemoveCopies, Scene::~Scene deletes the copies
+// CSc29Controller::~CSc29Controller (18E378): the scene deletes its animations itself when it goes
Sc29Controller::~Sc29Controller() {
- if (!_greenBalls.empty() || !_flyingGreenBalls.empty() || !_redBalls.empty() || !_flyingRedBalls.empty() || !_bearders.empty())
- warning("STUB/untested: CSc29Controller::~CSc29Controller (RemoveCopies is not run, the scene deletes the copies)");
+ if (_scene && !_scene->_destroying)
+ removeCopies();
}
// CSc29Controller::CleanXml (18C9F8)
@@ -86,7 +87,8 @@ bool Sc29Controller::canSwipeMan(float x, float y) {
bool Sc29Controller::doJump() {
AniObject *man = hero();
bool result;
- if (!man->_movement || man->_movement->_id == MV_MAN29_RUN || man->_movement->_id == MV_MAN29_STANDUP) {
+ if (!man->_movement || man->_lastMovementId == MV_MAN29_RUN || man->_lastMovementId == MV_MAN29_STANDUP) {
+ debugC(1, kDebugInfo, "INFO t %u SC29 jump at %d", g_system->getMillis(), (int)_manX);
result = true;
_rideBackEnabled = false;
_manIsHit = false;
@@ -106,7 +108,8 @@ bool Sc29Controller::doJump() {
bool Sc29Controller::doBend() {
AniObject *man = hero();
bool result;
- if (!man->_movement || man->_movement->_id == MV_MAN29_RUN || man->_movement->_id == MV_MAN29_STANDUP) {
+ if (!man->_movement || man->_lastMovementId == MV_MAN29_RUN || man->_lastMovementId == MV_MAN29_STANDUP) {
+ debugC(1, kDebugInfo, "INFO t %u SC29 bend at %d", g_system->getMillis(), (int)_manX);
result = true;
_rideBackEnabled = false;
_manIsHit = false;
@@ -135,11 +138,13 @@ void Sc29Controller::tryShoot() {
if (!(_manX < 1310.0f))
return;
if (random31() > 0x3FFFFFFF && !_shooter1->_movement && _shooter1->_statics->_staticsId == ST_STR1_RIGHT) {
+ debugC(1, kDebugInfo, "INFO t %u SC29 shooter 1 shoots, hero at %d", g_system->getMillis(), (int)_manX);
_shooter1->startMovement(MV_STR1_SHOOT, 0, -1);
_shootCountdown = 0;
return;
}
if (!_shooter2->_movement && _shooter2->_statics->_staticsId == ST_STR2_RIGHT && (_shooter2->_flags & 4)) {
+ debugC(1, kDebugInfo, "INFO t %u SC29 shooter 2 shoots, hero at %d", g_system->getMillis(), (int)_manX);
_shooter2->startMovement(MV_STR2_SHOOT, 0, -1);
_shootCountdown = 0;
}
@@ -170,8 +175,8 @@ bool Sc29Controller::hitsManRed(AniObject *ani, int maxX) {
return false;
AniObject *man = hero();
// (id & ~4) != MV_MAN29_BEND: neither the bend (2091) nor the run (2095)
- if (man->_movement && (man->_movement->_id & ~4) != MV_MAN29_BEND &&
- (man->_movement->_id != MV_MAN29_JUMP || (man->_movement->_curFrame > 2 && man->_movement->_curFrame <= 6)))
+ if (man->_movement && (man->_lastMovementId & ~4) != MV_MAN29_BEND &&
+ (man->_lastMovementId != MV_MAN29_JUMP || (man->getCurFrame() > 2 && man->getCurFrame() <= 6)))
return false;
return _arcadeIsOn;
}
@@ -185,8 +190,8 @@ bool Sc29Controller::hitsManGreen(AniObject *ani, int maxX) {
return false;
AniObject *man = hero();
if (man->_movement) {
- const int id = man->_movement->_id;
- if (id != MV_MAN29_JUMP && id != MV_MAN29_RUN && (id != MV_MAN29_BEND || (man->_movement->_curFrame > 0 && man->_movement->_curFrame <= 5)))
+ const int id = man->_lastMovementId;
+ if (id != MV_MAN29_JUMP && id != MV_MAN29_RUN && (id != MV_MAN29_BEND || (man->getCurFrame() > 0 && man->getCurFrame() <= 5)))
return false;
}
return _arcadeIsOn;
@@ -251,6 +256,7 @@ void Sc29Controller::updateButtons(uint32 elapsed) {
// CSc29Controller::DoJumpfromL (18D230): the hero steps off the porter at the left pipe
void Sc29Controller::doJumpfromL() {
+ debugC(1, kDebugInfo, "INFO t %u SC29 the hero jumps off at the left pipe", g_system->getMillis());
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
hero()->_flags |= 8; // +64
@@ -268,6 +274,7 @@ void Sc29Controller::updateManRide() {
// CSc29Controller::DoJumpfromR (18D2E4): the hero steps off the porter at the right pipe
void Sc29Controller::doJumpfromR() {
+ debugC(1, kDebugInfo, "INFO t %u SC29 the hero jumps off at the right pipe", g_system->getMillis());
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
if (!_scene->runQueue(QU_SC29_MANFROM_R, 2))
@@ -275,7 +282,7 @@ void Sc29Controller::doJumpfromR() {
_arcadeIsOn = false;
_rideBackEnabled = false;
g_ngi->_hintManager->hideHint(_scene);
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ setSaving(true);
}
// CSc29Controller::UpdateManRideRight (18D374)
@@ -300,7 +307,8 @@ void Sc29Controller::updateManRideRight() {
// CSc29Controller::DoJumptoR (18D458): the hero steps on the porter at the right pipe
void Sc29Controller::doJumptoR() {
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ debugC(1, kDebugInfo, "INFO t %u SC29 the hero jumps on the porter at the right pipe", g_system->getMillis());
+ setSaving(false);
_scene->_motionController->deactivate();
getGameLoaderInteractionController()->disable();
if (!_scene->runQueue(QU_SC29_MANTO_R, 2))
@@ -354,7 +362,7 @@ void Sc29Controller::countLoopBeardeds(uint32 elapsed) {
if (!_bearders[i]._ani->_movement && _bearders[i]._ani->_statics->_staticsId == ST_BRDCMN_GOR)
_bearders[i]._ani->startMovement(MV_BRDCMN_GOR, 0, -1);
ani = _bearders[i]._ani;
- if (ani->_movement && ani->_movement->_id == MV_BRDCMN_GOR) {
+ if (ani->_movement && ani->_lastMovementId == MV_BRDCMN_GOR) {
const float manX = _manX;
x = x - (float)elapsed * 0.048f;
if ((manX - x) < 60.0f || (x - manX) < -260.0f || !_arcadeIsOn) {
@@ -385,7 +393,8 @@ bool Sc29Controller::canShowHelp() {
// CSc29Controller::DoJumptoL (18D958)
void Sc29Controller::doJumptoL() {
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ debugC(1, kDebugInfo, "INFO t %u SC29 the hero jumps on the porter", g_system->getMillis());
+ setSaving(false);
_scene->_motionController->deactivate();
getGameLoaderInteractionController()->disable();
if (!_scene->runQueue(QU_SC29_MANTO_L, 2))
@@ -405,6 +414,7 @@ void Sc29Controller::doJumptoL() {
// CSc29Controller::TryEscapeShooters (18DAC0)
void Sc29Controller::tryEscapeShooters() {
if (!_shooter1->_movement && !_shooter2->_movement && _shooter1->_statics->_staticsId == ST_STR1_RIGHT) {
+ debugC(1, kDebugInfo, "INFO t %u SC29 the hero escapes the shooters", g_system->getMillis());
_shootCountdown = 0;
_shooter1->setStatic(ST_STR1_STAND, false);
_shooter2->setStatic(ST_STR2_STAND, false);
@@ -449,7 +459,7 @@ void Sc29Controller::onClickPorter() {
if (_manX != 351.0f || _manY != 443.0f) {
MessageQueue *queue = mctlStartMove(351, 443, true, ST_MAN_RIGHT, false);
if (queue)
- queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK", 0, 3));
+ queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK"));
}
} else {
Common::Point center = man->getCenter();
@@ -464,7 +474,7 @@ void Sc29Controller::onClickPorter() {
if (_manX != 1582.0f || _manY != 445.0f) {
MessageQueue *queue = mctlStartMove(1582, 445, true, ST_MAN_RIGHT, true);
if (queue)
- queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK", 0, 3));
+ queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK"));
}
}
}
@@ -472,6 +482,7 @@ void Sc29Controller::onClickPorter() {
// CSc29Controller::DoHitMan (18DEA8)
void Sc29Controller::doHitMan() {
AniObject *man = hero();
+ debugC(1, kDebugInfo, "INFO t %u SC29 the hero is hit at %d", g_system->getMillis(), (int)_manX);
_manIsHit = true;
man->moveToStaticChain(ST_MAN29_RUNR);
man->setCenter(Common::Point((int)_manX, (int)_manY));
@@ -493,16 +504,16 @@ void Sc29Controller::doHitMan() {
g_ngi->arcadeInterface().scrollOut();
g_ngi->_achievementsManager->blockActivatingCounter("ACHIEVEMENT_ARCADE_29", 100);
queue->addCommandToEnd(movementCommand(man, MV_MAN29_STANDUP_NORM));
- queue->addCommandToEnd(messageCommand("MSG_SC29_STOPRIDE", 0, 3));
+ queue->addCommandToEnd(messageCommand("MSG_SC29_STOPRIDE"));
_manIsRiding = false;
_arcadeIsOn = false;
_reachedFarRight = false;
_rideBackEnabled = false;
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ setSaving(true);
} else {
queue->addCommandToEnd(movementCommand(man, MV_MAN29_STANDUP));
}
- queue->addCommandToEnd(messageCommand("MSG_SC29_STOP_HITQUEUE", 0, 3));
+ queue->addCommandToEnd(messageCommand("MSG_SC29_STOP_HITQUEUE"));
_scene->runQueueObject(queue, man, 2);
_hitQueue = queue;
}
@@ -539,6 +550,7 @@ void Sc29Controller::removeCopies() {
// CSc29Controller::DoWinArcadeNow (18E5C8)
void Sc29Controller::doWinArcadeNow() {
+ debugC(1, kDebugInfo, "INFO t %u SC29 win arcade", g_system->getMillis());
if (_shooter2->_flags & 4) {
_shootCountdown = 0;
_shooter1->setStatic(ST_STR1_STAND, false);
@@ -639,6 +651,7 @@ void Sc29Controller::doShootGreen() {
const Common::Point center = _shooter1->getCenter();
const float x = center.x - 113.0f;
const float y = center.y - 48.0f;
+ debugC(1, kDebugInfo, "INFO t %u SC29 green shell flies, hits in %d ms", g_system->getMillis(), (int)((x - _manX - 25.0f) / (_greenSpeed + _manSpeed)));
AniObject *ball = _greenBalls.front();
_greenBalls.pop_front();
ball->setStatic(ST_SHG_NORM, false);
@@ -654,6 +667,7 @@ void Sc29Controller::doShootRed() {
const Common::Point center = _shooter2->getCenter();
const float x = center.x - 101.0f;
const float y = center.y - 14.0f;
+ debugC(1, kDebugInfo, "INFO t %u SC29 red shell flies, hits in %d ms", g_system->getMillis(), (int)((x - _manX - 25.0f) / (_redSpeed + _manSpeed)));
AniObject *ball = _redBalls.front();
_redBalls.pop_front();
ball->setStatic(ST_SHR_NORM, false);
@@ -753,7 +767,7 @@ void Sc29Controller::onShow() {
// CSc29Controller::OnHide (18F0C8)
void Sc29Controller::onHide() {
if (controllerRunsSceneLogic()) {
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ setSaving(true);
// the analytics event of a lost arcade is not ported
removeCopies();
g_ngi->_hintManager->hideHint(_scene);
@@ -864,7 +878,7 @@ void Sc29Controller::onMessage(const Common::String &message, const Common::Stri
_scene->_motionController->activate();
getGameLoaderInteractionController()->enable();
g_ngi->_hintManager->hideHint(_scene);
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked during the arcade, CSc29Controller)");
+ setSaving(true);
} else if (message == "MSG_SC29_SHOOTGREEN") {
doShootGreen();
} else if (message == "MSG_SC29_SHOOTRED") {
diff --git a/engines/ngi/fullpipe/mobile/sc29controller.h b/engines/ngi/fullpipe/mobile/sc29controller.h
index ff28c3a6d84..70d45478030 100644
--- a/engines/ngi/fullpipe/mobile/sc29controller.h
+++ b/engines/ngi/fullpipe/mobile/sc29controller.h
@@ -42,6 +42,7 @@ public:
bool canShowHelp() override;
void checkTutorial() override;
void skipArcade() override;
+ bool controllerRunsSceneLogic() const override { return true; }
void onShow() override;
void onHide() override;
void onKeyUp(uint32 key) override;
Commit: f65de1319c4112a566ffc367e0809f76ec7335d7
https://github.com/scummvm/scummvm/commit/f65de1319c4112a566ffc367e0809f76ec7335d7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Physics data structures (materials, registrator, params, bound box)
Changed paths:
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/physics.cpp
engines/ngi/physics.h
engines/ngi/vector2.h
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index 71f7e7807d6..d4a5ec795b3 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -214,6 +214,18 @@ Settings &NGIEngine::settings() {
return *_settings;
}
+PhysMaterials &NGIEngine::physMaterials() {
+ if (!_physMaterials)
+ _physMaterials.reset(new PhysMaterials());
+ return *_physMaterials;
+}
+
+PhysRegistrator &NGIEngine::physRegistrator() {
+ if (!_physRegistrator)
+ _physRegistrator.reset(new PhysRegistrator());
+ return *_physRegistrator;
+}
+
void NGIEngine::restartGame() {
_floaters->deleteAllFlies();
if (_tremble)
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index ead5482ac80..7d7c6bdfb85 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -106,6 +106,8 @@ class ExitManager;
class Tremble;
class Map;
class Settings;
+class PhysMaterials;
+class PhysRegistrator;
class ArcadeInterface;
class MessageQueueBuilder;
class BitmapFont;
@@ -345,6 +347,11 @@ public:
/** CGame +112, made when first asked for (Android) */
Common::ScopedPtr<Settings> _settings;
Settings &settings();
+ /** CSingleton<CPhysMaterials>, <CPhysRegistrator>: made when first asked for */
+ Common::ScopedPtr<PhysMaterials> _physMaterials;
+ Common::ScopedPtr<PhysRegistrator> _physRegistrator;
+ PhysMaterials &physMaterials();
+ PhysRegistrator &physRegistrator();
Common::ScopedPtr<AniHandler> _aniHandler;
Common::Array<Common::Point> _arcadeKeys;
diff --git a/engines/ngi/physics.cpp b/engines/ngi/physics.cpp
index 4a1f80a3e24..da4becae1fc 100644
--- a/engines/ngi/physics.cpp
+++ b/engines/ngi/physics.cpp
@@ -24,6 +24,7 @@
#include "ngi/ngi.h"
#include "ngi/physics.h"
+#include "ngi/xmlnode.h"
namespace NGI {
@@ -35,6 +36,187 @@ static void stub(const char *name) {
warning("STUB/untested: %s", name);
}
+// CBoundBox (117140 ... 117354)
+void BoundBox::setWorldRect(const Vector4 &rect) {
+ _worldRect = rect;
+}
+
+Vector4 BoundBox::getWorldRect() const {
+ return _worldRect;
+}
+
+Vector2 BoundBox::getCenter() const {
+ const Vector4 rect = getWorldRect();
+ Vector2 center;
+ center.x = (rect.x + rect.z) * 0.5f;
+ center.y = (rect.y + rect.w) * 0.5f;
+ return center;
+}
+
+Vector4 BoundBox::getLocalRect() const {
+ Vector4 rect;
+ rect.x = (_worldRect.x - _worldRect.z) * 0.5f;
+ rect.z = (_worldRect.z - _worldRect.x) * 0.5f;
+ rect.y = (_worldRect.y - _worldRect.w) * 0.5f;
+ rect.w = (_worldRect.w - _worldRect.y) * 0.5f;
+ return rect;
+}
+
+void BoundBox::setAABB(const b2AABB &aabb) {
+ _aabb = aabb;
+}
+
+const b2AABB &BoundBox::getAABB() const {
+ return _aabb;
+}
+
+bool BoundBox::intersect(const b2AABB &aabb) const {
+ bool result = aabb.Contains(_aabb);
+ if (result)
+ return true;
+ result = _aabb.Contains(aabb);
+ if (result)
+ return true;
+
+ // the corners of one box inside the other, the edges are not compared
+ const float left = aabb.lowerBound.x;
+ const float top = aabb.lowerBound.y;
+ const float right = aabb.upperBound.x;
+ const float bottom = aabb.upperBound.y;
+ if (left > _aabb.lowerBound.x && left < _aabb.upperBound.x && top > _aabb.lowerBound.y && top < _aabb.upperBound.y)
+ return true;
+ if (right > _aabb.lowerBound.x && right < _aabb.upperBound.x && bottom > _aabb.lowerBound.y && bottom < _aabb.upperBound.y)
+ return true;
+ if (_aabb.lowerBound.x > left && _aabb.lowerBound.x < right && _aabb.lowerBound.y > top && _aabb.lowerBound.y < bottom)
+ return true;
+ if (_aabb.upperBound.x > left && _aabb.upperBound.x < right && _aabb.upperBound.y > top && _aabb.upperBound.y < bottom)
+ return true;
+ return false;
+}
+
+bool BoundBox::intersect(const BoundBox &box) const {
+ return intersect(box.getAABB());
+}
+
+// CGeomRegion and the data structures
+
+PhysRegistrator::PhysRegistrator() {
+ _categories["catbits_default"] = 1;
+ _categories["catbits_all"] = 0xFFFF;
+ _nextBit = 2;
+ registerCategory("catbits_hero");
+ registerCategory("catbits_immovable");
+ registerCategory("catbits_onesided");
+}
+
+uint32 PhysRegistrator::getCategory(const Common::String &name) const {
+ const auto entry = _categories.find(name);
+ if (entry == _categories.end())
+ return 0;
+ return entry->_value;
+}
+
+uint32 PhysRegistrator::registerCategory(const Common::String &name) {
+ const uint32 bit = _nextBit;
+ if (!_categories.contains(name))
+ _categories[name] = bit;
+ _nextBit *= 2;
+ return bit;
+}
+
+PhysMaterials::PhysMaterials() {
+ Material material;
+ material._friction = 0.5f;
+ material._density = 0.5f;
+ material._restitution = 0.5f;
+ material._ignitability = 0.5f;
+ material._name = "DEFAULT";
+ material._description = "DEFAULT";
+ setMaterial("DEFAULT", material);
+
+ material._friction = 0.6f;
+ material._density = 0.8f;
+ material._restitution = 0.01f;
+ material._ignitability = 0.0f;
+ material._name = "METAL";
+ material._description = "METAL";
+ setMaterial("METAL", material);
+
+ material._friction = 0.8f;
+ material._density = 0.6f;
+ material._restitution = 0.0f;
+ material._ignitability = 0.0f;
+ material._name = "STONE";
+ material._description = "STONE";
+ setMaterial("STONE", material);
+
+ material._friction = 0.7f;
+ material._density = 0.08f;
+ material._restitution = 0.02f;
+ material._ignitability = 0.2f;
+ material._name = "WOOD";
+ material._description = "WOOD";
+ setMaterial("WOOD", material);
+
+ material._friction = 0.9f;
+ material._density = 0.1f;
+ material._restitution = 0.0f;
+ material._ignitability = 0.2f;
+ material._name = "TURF";
+ material._description = "TURF";
+ setMaterial("TURF", material);
+
+ material._friction = 0.9f;
+ material._density = 0.1f;
+ material._restitution = 0.8f;
+ material._ignitability = 0.5f;
+ material._name = "ERASER";
+ material._description = "ERASER";
+ setMaterial("ERASER", material);
+}
+
+void PhysMaterials::setMaterial(const Common::String &name, const Material &material) {
+ _materials[name] = material;
+}
+
+void PhysMaterials::setMaterials(const XmlNode &node) {
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (node[i].name() != "MATERIAL")
+ continue;
+ const Common::String name = node[i].attrStr("name", "");
+ if (name.empty())
+ continue;
+
+ Material material;
+ material._name = name;
+ material._description = node[i].attrStr("description", "");
+ material._density = node[i].attrFloat("density", 0.0f);
+ material._friction = node[i].attrFloat("friction", 0.0f);
+ material._restitution = node[i].attrFloat("restitution", 0.0f);
+ material._ignitability = node[i].attrFloat("ignitability", 0.0f);
+ setMaterial(name, material);
+ }
+}
+
+Material PhysMaterials::getMaterial(const Common::String &name) {
+ const auto entry = _materials.find(name);
+ if (entry != _materials.end())
+ return entry->_value;
+ return _materials["DEFAULT"];
+}
+
+GeomParams::GeomParams() {
+ _material = g_ngi->physMaterials().getMaterial("DEFAULT");
+ _categoryBits = g_ngi->physRegistrator().getCategory("catbits_default");
+ _maskBits = g_ngi->physRegistrator().getCategory("catbits_all");
+}
+
+PhysObjParams::PhysObjParams() {
+ _categoryBits = g_ngi->physRegistrator().getCategory("catbits_default");
+ _maskBits = g_ngi->physRegistrator().getCategory("catbits_all");
+ _material = g_ngi->physMaterials().getMaterial("DEFAULT");
+}
+
PhysListener::PhysListener() {
stub("PhysListener::PhysListener");
}
@@ -362,24 +544,6 @@ uint32 PhysGround::init(void *arg2) {
return 0;
}
-PhysMaterials::PhysMaterials() {
- stub("PhysMaterials::PhysMaterials");
-}
-
-void PhysMaterials::setMaterial(void **arg2, void *arg3) {
- stub("PhysMaterials::setMaterial");
-}
-
-uint32 PhysMaterials::setMaterials(void *arg2) {
- stub("PhysMaterials::setMaterials");
- return 0;
-}
-
-void *PhysMaterials::getMaterial(int arg2, void **arg3) {
- stub("PhysMaterials::getMaterial");
- return nullptr;
-}
-
VisForPhys::VisForPhys() {
stub("VisForPhys::VisForPhys");
}
@@ -832,20 +996,6 @@ void PhysDebugDraw::drawAABB(float *arg2, int *arg3) {
PhysController::PhysController() {
}
-PhysRegistrator::PhysRegistrator() {
- stub("PhysRegistrator::PhysRegistrator");
-}
-
-int PhysRegistrator::getCategory(void **arg2) {
- stub("PhysRegistrator::getCategory");
- return 0;
-}
-
-int PhysRegistrator::registerCategory(int *arg2) {
- stub("PhysRegistrator::registerCategory");
- return 0;
-}
-
QueryGeomsInRegion::QueryGeomsInRegion() {
stub("QueryGeomsInRegion::QueryGeomsInRegion");
}
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index 38fbd9fe993..096c9f8d757 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -23,22 +23,84 @@
#define NGI_PHYSICS_H
#include "ngi/box2d/Box2D.h"
+
+#include "common/array.h"
+#include "common/hashmap.h"
+#include "common/str.h"
+
#include "ngi/objects.h"
#include "ngi/gfx.h"
#include "ngi/vector2.h"
namespace NGI {
-// Android physics (Box2D), stubs from scripts/ngi_gen_stubs.py (each warns "STUB/untested")
+// Android physics (Box2D): the glue around the imported Box2D 2.2.1 (docs/android-physics.md).
+// Classes not ported yet are stubs from scripts/ngi_gen_stubs.py (each warns "STUB/untested").
+
+class XmlNode;
+
+/** Android SMaterial (CPhysMaterials, XML MATERIAL) */
+struct Material {
+ float _friction = 0.0f; // +0
+ float _density = 0.0f; // +4
+ float _restitution = 0.0f; // +8
+ float _ignitability = 0.0f; // +12
+ Common::String _name; // +16
+ Common::String _description; // +20
+};
-/** Android SGeomParams: the layout is not known yet. */
+/** Android CBoundBox: the world rectangle of a body in pixels and its Box2D box in meters */
+struct BoundBox {
+ Vector4 _worldRect = Vector4(); // +0
+ Vector4 _reserved = Vector4(); // +16, cleared by GetBoundBox, never read
+ b2AABB _aabb = b2AABB(); // +32
+
+ BoundBox() {}
+ void setWorldRect(const Vector4 &rect); // 117140
+ Vector4 getWorldRect() const; // 11715E
+ Vector2 getCenter() const; // 11719A
+ Vector4 getLocalRect() const; // 1171D2
+ void setAABB(const b2AABB &aabb); // 11722C
+ const b2AABB &getAABB() const; // 11724A
+ bool intersect(const b2AABB &aabb) const; // 11724E
+ bool intersect(const BoundBox &box) const; // 117354
+};
+
+/** Android SGeomParams: the parameters of a geometry (CPhysGround builds its edges from them) */
struct GeomParams {
- int _unused = 0;
+ int _type = -1; // +0
+ float _x = 0.0f; // +4
+ float _y = 0.0f; // +8
+ float _left = -10.0f; // +12, the defaults are as the constructor stores them (11525C)
+ float _top = 10.0f; // +16
+ float _right = -10.0f; // +20
+ float _bottom = 10.0f; // +24
+ float _radius = 10.0f; // +28
+ Common::Array<Vector2> _points; // +32
+ uint32 _categoryBits; // +44
+ uint32 _maskBits; // +48
+ Material _material; // +52
+
+ GeomParams(); // 11525C
};
-/** Android SPhysObjParams: the layout is not known yet. */
+/** Android SPhysObjParams: the parameters of a physical object (XML PHYSOBJ) */
struct PhysObjParams {
- int _unused = 0;
+ int _id = 0; // +0
+ float _x = 0.0f; // +4
+ float _y = 0.0f; // +8
+ float _velocityX = 0.0f; // +12
+ float _velocityY = 0.0f; // +16
+ float _forceX = 0.0f; // +20
+ float _forceY = 0.0f; // +24
+ float _linearDamping = 0.0f; // +28
+ float _angularDamping = 0.1f; // +32
+ int _physFlags = 5; // +36: 2 static, 4 rotatable
+ uint32 _categoryBits; // +40
+ uint32 _maskBits; // +44
+ Material _material; // +48
+
+ PhysObjParams(); // 117A18
};
class PhysListener;
@@ -157,14 +219,17 @@ public:
uint32 init(void *arg2); // 115BD4
};
-/** Android CPhysMaterials: the material table (XML PHYSICS > MATERIALS) */
+/** Android CPhysMaterials (CSingleton): the material table (built in ones and XML MATERIALS) */
class PhysMaterials {
public:
- PhysMaterials();
+ PhysMaterials(); // 116814
virtual ~PhysMaterials() {}
- void setMaterial(void **arg2, void *arg3); // 11678A
- uint32 setMaterials(void *arg2); // 116B9C
- void *getMaterial(int arg2, void **arg3); // 116D10
+ void setMaterial(const Common::String &name, const Material &material); // 11678A
+ void setMaterials(const XmlNode &node); // 116B9C
+ Material getMaterial(const Common::String &name); // 116D10
+
+private:
+ Common::HashMap<Common::String, Material> _materials; // +8
};
/** Android CVisForPhys: the picture of a geometry */
@@ -378,13 +443,17 @@ public:
virtual ~PhysController() {}
};
-/** Android CPhysRegistrator */
+/** Android CPhysRegistrator (CSingleton): category bits by name (1, 0xFFFF, 2, 4 ..) */
class PhysRegistrator {
public:
- PhysRegistrator();
+ PhysRegistrator(); // 1178B0
virtual ~PhysRegistrator() {}
- int getCategory(void **arg2); // 1170FC
- int registerCategory(int *arg2); // 117804
+ uint32 getCategory(const Common::String &name) const; // 1170FC
+ uint32 registerCategory(const Common::String &name); // 117804
+
+private:
+ Common::HashMap<Common::String, uint32> _categories; // +8
+ uint32 _nextBit; // +32
};
/** Android QueryGeomsInRegion: b2QueryCallback */
diff --git a/engines/ngi/vector2.h b/engines/ngi/vector2.h
index ed6b299a95a..2278546a088 100644
--- a/engines/ngi/vector2.h
+++ b/engines/ngi/vector2.h
@@ -37,6 +37,14 @@ struct Vector3 {
float z;
};
+/** Android: vector4 (a rectangle: left, top, right, bottom) */
+struct Vector4 {
+ float x;
+ float y;
+ float z;
+ float w;
+};
+
} // End of namespace NGI
#endif // NGI_VECTOR2_H
Commit: bea181b603d0c54df68568653f67d1d88672dcfd
https://github.com/scummvm/scummvm/commit/bea181b603d0c54df68568653f67d1d88672dcfd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Physics geometries (IGeom family, VisForPhys, query callbacks)
Changed paths:
A engines/ngi/physdraw.cpp
A engines/ngi/physgeom.cpp
engines/ngi/module.mk
engines/ngi/physics.cpp
engines/ngi/physics.h
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index aef3d210625..657b77fcd43 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -23,6 +23,8 @@ MODULE_OBJS = \
movetoinfo.o \
ngi.o \
ngiarchive.o \
+ physdraw.o \
+ physgeom.o \
physics.o \
preloadmanager.o \
region.o \
diff --git a/engines/ngi/physdraw.cpp b/engines/ngi/physdraw.cpp
new file mode 100644
index 00000000000..7fb2fd1dbbb
--- /dev/null
+++ b/engines/ngi/physdraw.cpp
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// The debug drawing of the Android physics: line, quad and circle on the background surface
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/physics.h"
+
+namespace NGI {
+
+static uint32 colorOf(float red, float green, float blue) {
+ const Graphics::PixelFormat &format = g_ngi->_backgroundSurface.format;
+ return format.RGBToColor(static_cast<uint8>(red * 255.0f), static_cast<uint8>(green * 255.0f), static_cast<uint8>(blue * 255.0f));
+}
+
+// the alpha is not blended: the software renderer draws the outlines opaque
+void physDrawLine(float red, float green, float blue, float alpha, float x0, float y0, float x1, float y1) {
+ g_ngi->_backgroundSurface.drawLine(static_cast<int>(x0), static_cast<int>(y0), static_cast<int>(x1), static_cast<int>(y1), colorOf(red, green, blue));
+}
+
+void physDrawEmptyQuad(float red, float green, float blue, float alpha, float x, float y, float width, float height) {
+ const Common::Rect rect(static_cast<int>(x), static_cast<int>(y), static_cast<int>(x + width), static_cast<int>(y + height));
+ g_ngi->_backgroundSurface.frameRect(rect, colorOf(red, green, blue));
+}
+
+void physDrawCircle(float red, float green, float blue, float alpha, float x, float y, float radius) {
+ g_ngi->_backgroundSurface.drawEllipse(static_cast<int>(x - radius), static_cast<int>(y - radius), static_cast<int>(x + radius),
+ static_cast<int>(y + radius), colorOf(red, green, blue), false);
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/physgeom.cpp b/engines/ngi/physgeom.cpp
new file mode 100644
index 00000000000..80e37b3e013
--- /dev/null
+++ b/engines/ngi/physgeom.cpp
@@ -0,0 +1,710 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// The geometries of the Android physics (IGeom and its children, CVisForPhys, the query callbacks)
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/objects.h"
+#include "ngi/physics.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/xmlnode.h"
+
+namespace NGI {
+
+// the pixels of the game are 30 to the meter
+static const float kScale = 30.0f;
+
+// CIDList::FindId: a name that is not known gives 0
+static int findObjectId(const Common::String &name) {
+ uint32 id = 0;
+ if (!g_ngi->_gameProject->_objectIds.findId(name, id))
+ warning("Unknown object id '%s'", name.c_str());
+ return id;
+}
+
+Vector2 GeomRegion::getSize() const {
+ Vector2 size;
+ size.x = _right - _left;
+ size.y = _bottom - _top;
+ return size;
+}
+
+Vector2 GeomRegion::getLocalCenter() const {
+ Vector2 center;
+ center.x = (_left + _right) * 0.5f;
+ center.y = (_bottom + _top) * 0.5f;
+ return center;
+}
+
+static GeomRegion rectRegion(const Vector4 &rect) {
+ GeomRegion region;
+ region._left = rect.x;
+ region._top = rect.y;
+ region._right = rect.z;
+ region._bottom = rect.w;
+ return region;
+}
+
+// CVisForPhys
+
+VisForPhys::VisForPhys(const XmlNode &node, Geom *geom) {
+ _dx = node.attrInt("dx", 0);
+ _dy = node.attrInt("dy", 0);
+ const bool dontScale = node.attrBool("dontScale", false);
+ _geom = geom;
+ _window._right = 1.0f;
+ _window._bottom = 1.0f;
+ _dontScale = dontScale;
+ _stroke = node.attrBool("stroke", false);
+ const float red = node.attrFloat("R", 0.0f);
+ const float green = node.attrFloat("G", 0.0f);
+ const float blue = node.attrFloat("B", 0.0f);
+ const float alpha = node.attrFloat("A", 0.0f);
+ _red = red / 255.0f;
+ _green = green / 255.0f;
+ _blue = blue / 255.0f;
+ _alpha = alpha / 255.0f;
+ _thickness = node.attrInt("thickness", 0);
+
+ Scene *scene = _geom->getPhysObj()->_scene;
+ GameObject *object = scene->findVisibleObject(findObjectId(node.attrStr("id", "")), 0);
+ setVisibleObj(object, _dontScale);
+}
+
+VisForPhys::VisForPhys(const VisForPhys &source, Geom *geom) {
+ _dx = source._dx;
+ _dy = source._dy;
+ _dontScale = source._dontScale;
+ _window = source._window;
+ _geom = geom;
+ _red = source._red;
+ _green = source._green;
+ _blue = source._blue;
+ _alpha = source._alpha;
+ _thickness = source._thickness;
+ _stroke = source._stroke;
+ setVisibleObj(source._visObj, false);
+}
+
+VisForPhys::~VisForPhys() {
+ removeVisObj();
+}
+
+// The original deletes it (CGameObject::RemoveThis). The scene owns it here: take it out first;
+// an object the scene has freed already is not touched.
+void VisForPhys::removeVisObj() {
+ if (!_visObj)
+ return;
+ PhysicalObject *physObj = _geom ? _geom->getPhysObj() : nullptr;
+ Scene *scene = physObj ? physObj->_scene : nullptr;
+ if (scene) {
+ if (_visObj->_objtype == kObjTypeStaticANIObject) {
+ AniObject *ani = static_cast<AniObject *>(_visObj);
+ for (uint i = 0; i < scene->_aniObjects.size(); i++) {
+ if (scene->_aniObjects[i] == ani) {
+ scene->removeAni(ani);
+ delete ani;
+ break;
+ }
+ }
+ } else if (_visObj->_objtype == kObjTypePictureObject) {
+ scene->removePicture(static_cast<PictureObject *>(_visObj));
+ }
+ }
+ _visObj = nullptr;
+}
+
+void VisForPhys::setPos(float x, float y) {
+ if (_visObj)
+ _visObj->setCenter(Common::Point(static_cast<int>(x + static_cast<float>(_dx)), static_cast<int>(static_cast<float>(_dy) + y)));
+}
+
+void VisForPhys::setZ(float z) {
+ if (_visObj)
+ _visObj->_z = z;
+}
+
+void VisForPhys::setRotate() {
+ if (_visObj)
+ _visObj->_rotation = _geom->getPhysObj()->_body->GetAngle();
+}
+
+static float truncated(float value) {
+ return static_cast<float>(static_cast<int>(value * 10000.0f)) / 10000.0f;
+}
+
+void VisForPhys::recalcVisible() {
+ const GeomRegion region = _geom->getRegion();
+ bool loadedHere = false;
+ bool loaded;
+ if (_visObj->_objtype == kObjTypeStaticANIObject)
+ loaded = static_cast<AniObject *>(_visObj)->isTextureLoaded();
+ else
+ loaded = static_cast<PictureObject *>(_visObj)->isTextureLoaded();
+ if (!loaded) {
+ if (_visObj->_objtype == kObjTypeStaticANIObject)
+ static_cast<AniObject *>(_visObj)->load();
+ else
+ static_cast<PictureObject *>(_visObj)->load();
+ loadedHere = true;
+ }
+
+ Vector2 fullSize;
+ if (_visObj->_objtype == kObjTypeStaticANIObject) {
+ const Common::Point size = static_cast<AniObject *>(_visObj)->getFullSize();
+ fullSize.x = size.x;
+ fullSize.y = size.y;
+ } else {
+ const Dims size = static_cast<PictureObject *>(_visObj)->getFullSize();
+ fullSize.x = size.x;
+ fullSize.y = size.y;
+ }
+ const Vector2 size = region.getSize();
+ const float scaleX = size.x / fullSize.x;
+ const float scaleY = size.y / fullSize.y;
+
+ if (_dontScale) {
+ if (truncated(_window._right - _window._left) != truncated(scaleX) || truncated(_window._bottom - _window._top) != truncated(scaleY)) {
+ const float left = (1.0f - scaleX) * static_cast<float>(g_ngi->_rnd.getRandomNumber(0x7FFFFFFF)) * 4.656613e-10f;
+ _window._left = left;
+ _window._right = left + scaleX;
+ const float top = (1.0f - scaleY) * static_cast<float>(g_ngi->_rnd.getRandomNumber(0x7FFFFFFF)) * 4.656613e-10f;
+ _window._top = top;
+ _window._bottom = top + scaleY;
+ }
+ _visObj->_windowLeft = _window._left;
+ _visObj->_windowTop = _window._top;
+ _visObj->_windowRight = _window._right;
+ _visObj->_windowBottom = _window._bottom;
+ } else {
+ _visObj->_scaleX = scaleX;
+ _visObj->_scaleY = scaleY;
+ }
+
+ if (loadedHere) {
+ if (_visObj->_objtype == kObjTypeStaticANIObject)
+ static_cast<AniObject *>(_visObj)->unload();
+ else
+ static_cast<PictureObject *>(_visObj)->unload();
+ }
+}
+
+void VisForPhys::setVisibleObj(GameObject *object, bool dontScale) {
+ removeVisObj();
+ _dontScale = dontScale;
+ if (!object)
+ return;
+
+ Scene *scene = _geom->getPhysObj()->_scene;
+ if (object->_objtype == kObjTypeStaticANIObject) {
+ AniObject *copy = new AniObject(static_cast<AniObject *>(object));
+ _visObj = copy;
+ scene->addAni(copy, false); // CScene::AddGameObject
+ } else if (object->_objtype == kObjTypePictureObject) {
+ PictureObject *copy = new PictureObject(static_cast<PictureObject *>(object));
+ _visObj = copy;
+ scene->addPicture(copy);
+ } else {
+ warning("STUB/untested: VisForPhys::setVisibleObj: object %d is neither a picture nor an animation", object->_id);
+ return;
+ }
+
+ _visObj->_objectFlags |= 1;
+ recalcVisible();
+}
+
+void VisForPhys::onRender(float scrollX, float scrollY) {
+ if (!_stroke)
+ return;
+
+ const Vector2 size = _geom->getRegion().getSize();
+ const BoundBox box = _geom->getPhysObj()->getBoundBox();
+ const float x = box.getWorldRect().x - scrollX;
+ const float y = box.getWorldRect().y - scrollY;
+ for (int i = 0; i < _thickness; i++) {
+ const float offset = static_cast<float>(2 * i);
+ physDrawEmptyQuad(_red, _green, _blue, _alpha, x - static_cast<float>(i), y - static_cast<float>(i), offset + size.x, offset + size.y);
+ }
+}
+
+// IGeom
+
+Geom::Geom() {
+}
+
+Geom::Geom(PhysicalObject *physObj) : _physObj(physObj) {
+}
+
+Geom::Geom(const Geom &source) {
+ _region = source._region;
+ _params = source._params;
+ if (source._visObj)
+ _visObj = new VisForPhys(*source._visObj, this);
+}
+
+Geom::~Geom() {
+ delete _visObj;
+}
+
+void Geom::setPhysObject(PhysicalObject *physObj) {
+ _physObj = physObj;
+}
+
+void Geom::setPos(float x, float y) {
+ if (_visObj)
+ _visObj->setPos(x, y);
+}
+
+PhysicalObject *Geom::getPhysObj() const {
+ return _physObj;
+}
+
+VisForPhys *Geom::getVisObj() const {
+ return _visObj;
+}
+
+void Geom::setVisObj(VisForPhys *visObj) {
+ delete _visObj;
+ _visObj = visObj;
+}
+
+Vector2 Geom::getWorldCenter() const {
+ const b2AABB &aabb = _fixture->GetAABB(0);
+ Vector2 center;
+ center.x = ((aabb.lowerBound.x + aabb.upperBound.x) * 0.5f) * kScale;
+ center.y = ((aabb.lowerBound.y + aabb.upperBound.y) * 0.5f) * kScale;
+ return center;
+}
+
+void Geom::updateVis(float scaleX, float scaleY) {
+ if (!_visObj)
+ return;
+ const Vector2 center = getWorldCenter();
+ _visObj->setPos(center.x * scaleX, center.y * scaleY);
+ _visObj->setRotate();
+}
+
+const GeomRegion &Geom::getRegion() const {
+ return _region;
+}
+
+Vector4 Geom::getBoundingBox() const {
+ const b2AABB &aabb = _fixture->GetAABB(0);
+ Vector4 rect;
+ rect.x = aabb.lowerBound.x * kScale;
+ rect.y = aabb.lowerBound.y * kScale;
+ rect.z = aabb.upperBound.x * kScale;
+ rect.w = aabb.upperBound.y * kScale;
+ return rect;
+}
+
+void Geom::scale(float value) {
+}
+
+Common::Array<Vector2> Geom::getVertices() {
+ return Common::Array<Vector2>();
+}
+
+// The "catbits" attribute only decides whether the object's bits are taken, as in the original
+void Geom::init(const XmlNode &node) {
+ const int categoryBits = node.attrInt("catbits", 0);
+ const int maskBits = node.attrInt("maskbits", 0);
+ if (categoryBits == 0 && _physObj)
+ _params._categoryBits = _physObj->_params._categoryBits;
+ if (maskBits == 0 && _physObj)
+ _params._maskBits = _physObj->_params._maskBits;
+
+ const Common::String material = node.attrStr("material", "");
+ if (!material.empty())
+ _params._material = g_ngi->physMaterials().getMaterial(material);
+ else if (_physObj)
+ _params._material = _physObj->_params._material;
+
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (node[i].name() == "VISOBJ") {
+ delete _visObj;
+ _visObj = nullptr;
+ _visObj = new VisForPhys(node[i], this);
+ }
+ }
+}
+
+void Geom::init(GeomParams ¶ms) {
+ _params = params;
+}
+
+static void setFixtureDef(b2FixtureDef &def, const Geom &geom, const b2Shape *shape) {
+ def.shape = shape;
+ def.friction = geom._params._material._friction;
+ def.restitution = geom._params._material._restitution;
+ def.density = geom._params._material._density;
+ def.filter.categoryBits = geom._params._categoryBits;
+ def.filter.maskBits = geom._params._maskBits;
+}
+
+static b2Fixture *createFixture(Geom &geom, b2FixtureDef &def) {
+ b2Fixture *fixture = geom._physObj->_body->CreateFixture(&def);
+ geom._fixture = fixture;
+ fixture->SetUserData(&geom);
+ return fixture;
+}
+
+static void setBoxShape(b2PolygonShape &shape, const GeomRegion ®ion) {
+ const Vector2 size = region.getSize();
+ const Vector2 center = region.getLocalCenter();
+ shape.SetAsBox((size.x * 0.5f) / kScale, (size.y * 0.5f) / kScale, b2Vec2(center.x / kScale, center.y / kScale), 0.0f);
+}
+
+static b2PolygonShape *polygonShape(Geom &geom) {
+ b2Shape *shape = geom._fixture->GetShape();
+ if (!shape || shape->GetType() != b2Shape::e_polygon)
+ return nullptr;
+ return static_cast<b2PolygonShape *>(shape);
+}
+
+static Common::Array<Vector2> polygonVertices(const Geom &geom) {
+ Common::Array<Vector2> vertices;
+ const b2Shape *shape = geom._fixture->GetShape();
+ const b2PolygonShape *polygon = static_cast<const b2PolygonShape *>(shape);
+ const b2Transform &xf = geom._fixture->GetBody()->GetTransform();
+ const float sine = xf.q.s;
+ const float cosine = xf.q.c;
+ for (int i = 0; i < polygon->m_vertexCount; i++) {
+ const b2Vec2 &vertex = polygon->m_vertices[i];
+ Vector2 point;
+ point.x = ((cosine * vertex.x - sine * vertex.y) + xf.p.x) * kScale;
+ point.y = ((sine * vertex.x + cosine * vertex.y) + xf.p.y) * kScale;
+ vertices.push_back(point);
+ }
+ return vertices;
+}
+
+// IGeomBox
+
+GeomBox::GeomBox() {
+}
+
+GeomBox::GeomBox(PhysicalObject *physObj) : Geom(physObj) {
+}
+
+void GeomBox::init(const XmlNode &node) {
+ _region._left = node.attrFloat("left", 0.0f);
+ _region._right = node.attrFloat("right", 0.0f);
+ _region._top = node.attrFloat("top", 0.0f);
+ _region._bottom = node.attrFloat("bottom", 0.0f);
+ Geom::init(node);
+}
+
+void GeomBox::init(GeomParams ¶ms) {
+ Geom::init(params);
+ _region._left = _params._left;
+ _region._right = _params._right;
+ _region._top = _params._top;
+ _region._bottom = _params._bottom;
+}
+
+b2Fixture *GeomBox::createGeom() {
+ b2PolygonShape shape;
+ setBoxShape(shape, _region);
+ b2FixtureDef def;
+ setFixtureDef(def, *this, &shape);
+ return createFixture(*this, def);
+}
+
+void GeomBox::scale(const Vector4 &rect) {
+ _region = rectRegion(rect);
+ b2PolygonShape *shape = polygonShape(*this);
+ if (shape)
+ setBoxShape(*shape, _region);
+}
+
+Common::Array<Vector2> GeomBox::getVertices() {
+ return polygonVertices(*this);
+}
+
+// IGeomCircle
+
+GeomCircle::GeomCircle() {
+}
+
+GeomCircle::GeomCircle(PhysicalObject *physObj) : Geom(physObj) {
+}
+
+void GeomCircle::init(const XmlNode &node) {
+ _params._x = node.attrFloat("x", 0.0f);
+ _params._y = node.attrFloat("y", 0.0f);
+ const float radius = node.attrFloat("radius", 0.0f);
+ _params._radius = radius;
+ _region._right = radius;
+ _region._bottom = radius;
+ _region._left = -radius;
+ _region._top = -radius;
+ Geom::init(node);
+}
+
+void GeomCircle::init(GeomParams ¶ms) {
+ Geom::init(params);
+ const float radius = _params._radius;
+ _region._left = -radius;
+ _region._right = radius;
+ _region._top = -radius;
+ _region._bottom = radius;
+}
+
+b2Fixture *GeomCircle::createGeom() {
+ b2CircleShape shape;
+ shape.m_radius = _params._radius / kScale;
+ shape.m_p.Set(_params._x / kScale, _params._y / kScale);
+ b2FixtureDef def;
+ setFixtureDef(def, *this, &shape);
+ return createFixture(*this, def);
+}
+
+static b2CircleShape *circleShape(Geom &geom) {
+ b2Shape *shape = geom._fixture->GetShape();
+ if (!shape || shape->GetType() != b2Shape::e_circle)
+ return nullptr;
+ return static_cast<b2CircleShape *>(shape);
+}
+
+void GeomCircle::scale(const Vector4 &rect) {
+ _region = rectRegion(rect);
+ b2CircleShape *shape = circleShape(*this);
+ if (shape)
+ shape->m_radius = (_region.getSize().x * 0.5f) / kScale;
+}
+
+// the original only moves the left side of the region
+void GeomCircle::scale(float value) {
+ _region._left = -value;
+ b2CircleShape *shape = circleShape(*this);
+ if (shape)
+ shape->m_radius = value / kScale;
+}
+
+// IGeomEdge
+
+GeomEdge::GeomEdge() {
+}
+
+GeomEdge::GeomEdge(PhysicalObject *physObj) : Geom(physObj) {
+}
+
+void GeomEdge::init(const XmlNode &node) {
+ _region._left = node.attrFloat("left", 0.0f);
+ _region._right = node.attrFloat("right", 0.0f);
+ _region._top = node.attrFloat("top", 0.0f);
+ _region._bottom = node.attrFloat("bottom", 0.0f);
+ Geom::init(node);
+}
+
+void GeomEdge::init(GeomParams ¶ms) {
+ Geom::init(params);
+ _region._left = _params._left;
+ _region._right = _params._right;
+ _region._top = _params._top;
+ _region._bottom = _params._bottom;
+}
+
+b2Fixture *GeomEdge::createGeom() {
+ b2EdgeShape shape;
+ shape.Set(b2Vec2(_region._left / kScale, _region._top / kScale), b2Vec2(_region._right / kScale, _region._bottom / kScale));
+ // no restitution, as the original
+ b2FixtureDef def;
+ setFixtureDef(def, *this, &shape);
+ def.restitution = 0.0f;
+ return createFixture(*this, def);
+}
+
+void GeomEdge::scale(const Vector4 &rect) {
+ _region = rectRegion(rect);
+ b2Shape *shape = _fixture->GetShape();
+ if (shape && shape->GetType() == b2Shape::e_edge) {
+ static_cast<b2EdgeShape *>(shape)->Set(b2Vec2(_region._left / kScale, _region._top / kScale),
+ b2Vec2(_region._right / kScale, _region._bottom / kScale));
+ }
+}
+
+void GeomEdge::setPoints(const Vector2 &first, const Vector2 &second) {
+ _region._left = first.x;
+ _region._bottom = second.y;
+ _region._top = first.y;
+ _region._right = second.x;
+}
+
+// IGeomPolygon
+
+GeomPolygon::GeomPolygon() {
+}
+
+GeomPolygon::GeomPolygon(PhysicalObject *physObj) : Geom(physObj) {
+}
+
+void GeomPolygon::init(const XmlNode &node) {
+ _region._left = node.attrFloat("left", 0.0f);
+ _region._right = node.attrFloat("right", 0.0f);
+ _region._top = node.attrFloat("top", 0.0f);
+ _region._bottom = node.attrFloat("bottom", 0.0f);
+ Geom::init(node);
+}
+
+void GeomPolygon::init(GeomParams ¶ms) {
+ _vertices = params._points;
+ const Vector4 rect = getRect(params);
+ params._left = rect.x;
+ params._top = rect.y;
+ params._right = rect.z;
+ params._bottom = rect.w;
+ Geom::init(params);
+ _region._left = _params._left;
+ _region._right = _params._right;
+ _region._top = _params._top;
+ _region._bottom = _params._bottom;
+}
+
+Vector4 GeomPolygon::getRect(const GeomParams ¶ms) {
+ Vector4 rect = Vector4();
+ if (params._points.empty())
+ return rect;
+
+ rect.x = params._points[0].x;
+ rect.z = params._points[0].x;
+ rect.y = params._points[0].y;
+ rect.w = params._points[0].y;
+ for (uint i = 1; i < params._points.size(); i++) {
+ const float x = params._points[i].x;
+ const float y = params._points[i].y;
+ rect.x = MIN(x, rect.x);
+ rect.y = MIN(y, rect.y);
+ rect.z = MAX(x, rect.z);
+ rect.w = MAX(y, rect.w);
+ }
+ return rect;
+}
+
+Common::Array<Vector2> GeomPolygon::getVertices() {
+ return _vertices;
+}
+
+b2Fixture *GeomPolygon::createGeom() {
+ b2Vec2 points[b2_maxPolygonVertices];
+ const int count = MIN<int>(_vertices.size(), b2_maxPolygonVertices);
+ for (int i = 0; i < count; i++)
+ points[i].Set(_vertices[i].x / kScale, _vertices[i].y / kScale);
+ b2PolygonShape shape;
+ shape.Set(points, count);
+ b2FixtureDef def;
+ setFixtureDef(def, *this, &shape);
+ return createFixture(*this, def);
+}
+
+// the original makes a box of the polygon
+void GeomPolygon::scale(const Vector4 &rect) {
+ _region = rectRegion(rect);
+ b2PolygonShape *shape = polygonShape(*this);
+ if (shape)
+ setBoxShape(*shape, _region);
+}
+
+// IGeomTriangle
+
+GeomTriangle::GeomTriangle() {
+}
+
+GeomTriangle::GeomTriangle(PhysicalObject *physObj) : Geom(physObj) {
+}
+
+void GeomTriangle::init(const XmlNode &node) {
+ _region._left = node.attrFloat("left", 0.0f);
+ _region._right = node.attrFloat("right", 0.0f);
+ _region._top = node.attrFloat("top", 0.0f);
+ _region._bottom = node.attrFloat("bottom", 0.0f);
+ Geom::init(node);
+}
+
+void GeomTriangle::init(GeomParams ¶ms) {
+ Geom::init(params);
+ _region._left = _params._left;
+ _region._right = _params._right;
+ _region._top = _params._top;
+ _region._bottom = _params._bottom;
+}
+
+b2Fixture *GeomTriangle::createGeom() {
+ const Vector2 size = _region.getSize();
+ b2Vec2 points[3];
+ points[0].Set((-size.x * 0.5f) / kScale, (-size.y * 0.5f) / kScale);
+ points[1].Set((size.x * 0.5f) / kScale, (size.y * 0.5f) / kScale);
+ points[2].Set((-size.x * 0.5f) / kScale, (size.y * 0.5f) / kScale);
+ b2PolygonShape shape;
+ shape.Set(points, _vertexCount);
+ b2FixtureDef def;
+ setFixtureDef(def, *this, &shape);
+ return createFixture(*this, def);
+}
+
+// the original makes a box of the triangle
+void GeomTriangle::scale(const Vector4 &rect) {
+ _region = rectRegion(rect);
+ b2PolygonShape *shape = polygonShape(*this);
+ if (shape)
+ setBoxShape(*shape, _region);
+}
+
+Common::Array<Vector2> GeomTriangle::getVertices() {
+ return polygonVertices(*this);
+}
+
+void GeomTriangle::update(uint32 elapsed) {
+ if (!_visObj)
+ return;
+ const Vector2 pos = _physObj->getPos();
+ _visObj->setPos(pos.x, pos.y);
+ _visObj->setRotate();
+}
+
+// QueryCallback, QueryGeomsInRegion
+
+QueryCallback::QueryCallback() {
+}
+
+bool QueryCallback::ReportFixture(b2Fixture *fixture) {
+ b2Body *body = fixture->GetBody();
+ if (body->GetType() == b2_dynamicBody && fixture->GetShape()->TestPoint(body->GetTransform(), _point)) {
+ _fixture = fixture;
+ return false;
+ }
+ return true;
+}
+
+bool QueryGeomsInRegion::ReportFixture(b2Fixture *fixture) {
+ if (fixture->GetBody()->GetType() == b2_dynamicBody) {
+ Geom *geom = static_cast<Geom *>(fixture->GetUserData());
+ if (geom)
+ _geoms.push_back(geom);
+ }
+ return true;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/physics.cpp b/engines/ngi/physics.cpp
index da4becae1fc..840785694e3 100644
--- a/engines/ngi/physics.cpp
+++ b/engines/ngi/physics.cpp
@@ -429,9 +429,13 @@ int PhysicalObject::setRotation(float arg2) {
return 0;
}
-PhysicalObject *PhysicalObject::getPos(int arg2) {
- stub("PhysicalObject::getPos");
- return nullptr;
+Vector2 PhysicalObject::getPos() const {
+ Vector2 pos = Vector2();
+ if (_body) {
+ pos.x = _body->GetPosition().x * 30.0f;
+ pos.y = _body->GetPosition().y * 30.0f;
+ }
+ return pos;
}
int PhysicalObject::setGravityScale(float arg2) {
@@ -448,13 +452,33 @@ void PhysicalObject::physicalStop() {
stub("PhysicalObject::physicalStop");
}
-void PhysicalObject::calcB2AABB(int arg2) {
- stub("PhysicalObject::calcB2AABB");
+b2AABB PhysicalObject::calcB2AABB() const {
+ b2AABB result = b2AABB();
+ if (_geoms.empty())
+ return result;
+
+ result = _geoms[0]->_fixture->GetAABB(0);
+ for (uint i = 1; i < _geoms.size(); i++) {
+ const b2AABB &aabb = _geoms[i]->_fixture->GetAABB(0);
+ result.lowerBound.x = MIN(result.lowerBound.x, aabb.lowerBound.x);
+ result.lowerBound.y = MIN(result.lowerBound.y, aabb.lowerBound.y);
+ result.upperBound.x = MAX(result.upperBound.x, aabb.upperBound.x);
+ result.upperBound.y = MAX(result.upperBound.y, aabb.upperBound.y);
+ }
+ return result;
}
-PhysicalObject *PhysicalObject::getBoundBox(int arg2) {
- stub("PhysicalObject::getBoundBox");
- return nullptr;
+BoundBox PhysicalObject::getBoundBox() const {
+ const b2AABB aabb = calcB2AABB();
+ BoundBox box;
+ box.setAABB(aabb);
+ Vector4 rect;
+ rect.x = aabb.lowerBound.x * 30.0f;
+ rect.y = aabb.lowerBound.y * 30.0f;
+ rect.z = aabb.upperBound.x * 30.0f;
+ rect.w = aabb.upperBound.y * 30.0f;
+ box.setWorldRect(rect);
+ return box;
}
float PhysicalObject::setMass(float arg2) {
@@ -544,45 +568,6 @@ uint32 PhysGround::init(void *arg2) {
return 0;
}
-VisForPhys::VisForPhys() {
- stub("VisForPhys::VisForPhys");
-}
-
-VisForPhys::VisForPhys(void *arg2, Geom *arg3) {
- stub("VisForPhys::VisForPhys");
-}
-
-VisForPhys::VisForPhys(VisForPhys *arg2, Geom *arg3) {
- stub("VisForPhys::VisForPhys");
-}
-
-void VisForPhys::setPos(float arg2, float arg3) {
- stub("VisForPhys::setPos");
-}
-
-int VisForPhys::setZ(float arg2) {
- stub("VisForPhys::setZ");
- return 0;
-}
-
-int VisForPhys::setRotate() {
- stub("VisForPhys::setRotate");
- return 0;
-}
-
-float VisForPhys::recalcVisible() {
- stub("VisForPhys::recalcVisible");
- return 0.0f;
-}
-
-void VisForPhys::setVisibleObj(bool arg2) {
- stub("VisForPhys::setVisibleObj");
-}
-
-void VisForPhys::onRender(float arg2, float arg3) {
- stub("VisForPhys::onRender");
-}
-
JointBuilder::JointBuilder() {
stub("JointBuilder::JointBuilder");
}
@@ -596,258 +581,6 @@ void *JointBuilder::buildJoint(void *arg2) {
return nullptr;
}
-Geom::Geom() {
- stub("Geom::Geom");
-}
-
-Geom::Geom(PhysicalObject *arg2) {
- stub("Geom::Geom");
-}
-
-Geom::Geom(VisForPhys **arg2) {
- stub("Geom::Geom");
-}
-
-void Geom::scale() {
- stub("Geom::scale");
-}
-
-void Geom::getVertices() {
- stub("Geom::getVertices");
-}
-
-int Geom::setPhysObject(int arg2) {
- stub("Geom::setPhysObject");
- return 0;
-}
-
-void Geom::setPos(float arg2, float arg3) {
- stub("Geom::setPos");
-}
-
-int Geom::getPhysObj() {
- stub("Geom::getPhysObj");
- return 0;
-}
-
-int Geom::getVisObj() {
- stub("Geom::getVisObj");
- return 0;
-}
-
-void Geom::setVisObj(VisForPhys *arg2) {
- stub("Geom::setVisObj");
-}
-
-Geom *Geom::getWorldCenter(int arg2) {
- stub("Geom::getWorldCenter");
- return nullptr;
-}
-
-int Geom::updateVis(float arg2, float arg3) {
- stub("Geom::updateVis");
- return 0;
-}
-
-void Geom::getRegion(int arg2) {
- stub("Geom::getRegion");
-}
-
-void Geom::getRegion() {
- stub("Geom::getRegion");
-}
-
-Geom *Geom::getBoundingBox(int arg2) {
- stub("Geom::getBoundingBox");
- return nullptr;
-}
-
-void Geom::init(void *arg2) {
- stub("Geom::init");
-}
-
-GeomParams *Geom::init(GeomParams *arg2) {
- stub("Geom::init");
- return nullptr;
-}
-
-GeomBox::GeomBox() {
- stub("GeomBox::GeomBox");
-}
-
-GeomBox::GeomBox(PhysicalObject *arg2) {
- stub("GeomBox::GeomBox");
-}
-
-void *GeomBox::createGeom() {
- stub("GeomBox::createGeom");
- return nullptr;
-}
-
-float GeomBox::scale(int arg2, int arg3, int arg4, int arg5) {
- stub("GeomBox::scale");
- return 0.0f;
-}
-
-void GeomBox::init(void *arg2) {
- stub("GeomBox::init");
-}
-
-GeomParams *GeomBox::init(GeomParams *arg2) {
- stub("GeomBox::init");
- return nullptr;
-}
-
-GeomBox *GeomBox::getVertices(int arg2) {
- stub("GeomBox::getVertices");
- return nullptr;
-}
-
-GeomCircle::GeomCircle() {
- stub("GeomCircle::GeomCircle");
-}
-
-GeomCircle::GeomCircle(PhysicalObject *arg2) {
- stub("GeomCircle::GeomCircle");
-}
-
-void GeomCircle::scale() {
- stub("GeomCircle::scale");
-}
-
-void *GeomCircle::createGeom() {
- stub("GeomCircle::createGeom");
- return nullptr;
-}
-
-void GeomCircle::scale(float arg2, float arg3, int arg4) {
- stub("GeomCircle::scale");
-}
-
-void GeomCircle::init(void *arg2) {
- stub("GeomCircle::init");
-}
-
-GeomParams *GeomCircle::init(GeomParams *arg2) {
- stub("GeomCircle::init");
- return nullptr;
-}
-
-GeomEdge::GeomEdge() {
- stub("GeomEdge::GeomEdge");
-}
-
-GeomEdge::GeomEdge(PhysicalObject *arg2) {
- stub("GeomEdge::GeomEdge");
-}
-
-void GeomEdge::scale(int arg2, int arg3, int arg4, int arg5) {
- stub("GeomEdge::scale");
-}
-
-void *GeomEdge::createGeom() {
- stub("GeomEdge::createGeom");
- return nullptr;
-}
-
-void GeomEdge::setPoints(int *arg2, int *arg3) {
- stub("GeomEdge::setPoints");
-}
-
-void GeomEdge::init(void *arg2) {
- stub("GeomEdge::init");
-}
-
-GeomParams *GeomEdge::init(GeomParams *arg2) {
- stub("GeomEdge::init");
- return nullptr;
-}
-
-GeomPolygon::GeomPolygon() {
- stub("GeomPolygon::GeomPolygon");
-}
-
-GeomPolygon::GeomPolygon(PhysicalObject *arg2) {
- stub("GeomPolygon::GeomPolygon");
-}
-
-void GeomPolygon::getRect(int arg2, int arg3) {
- stub("GeomPolygon::getRect");
-}
-
-GeomPolygon *GeomPolygon::getVertices(int arg2) {
- stub("GeomPolygon::getVertices");
- return nullptr;
-}
-
-void *GeomPolygon::createGeom() {
- stub("GeomPolygon::createGeom");
- return nullptr;
-}
-
-float GeomPolygon::scale(int arg2, int arg3, int arg4, int arg5) {
- stub("GeomPolygon::scale");
- return 0.0f;
-}
-
-void GeomPolygon::init(void *arg2) {
- stub("GeomPolygon::init");
-}
-
-void GeomPolygon::init(uint32 arg2, uint32 arg3) {
- stub("GeomPolygon::init");
-}
-
-GeomTriangle::GeomTriangle() {
- stub("GeomTriangle::GeomTriangle");
-}
-
-GeomTriangle::GeomTriangle(PhysicalObject *arg2) {
- stub("GeomTriangle::GeomTriangle");
-}
-
-void *GeomTriangle::createGeom() {
- stub("GeomTriangle::createGeom");
- return nullptr;
-}
-
-float GeomTriangle::scale(int arg2, int arg3, int arg4, int arg5) {
- stub("GeomTriangle::scale");
- return 0.0f;
-}
-
-void GeomTriangle::update(uint32 arg2) {
- stub("GeomTriangle::update");
-}
-
-void GeomTriangle::init(void *arg2) {
- stub("GeomTriangle::init");
-}
-
-GeomParams *GeomTriangle::init(GeomParams *arg2) {
- stub("GeomTriangle::init");
- return nullptr;
-}
-
-GeomTriangle *GeomTriangle::getVertices(int arg2) {
- stub("GeomTriangle::getVertices");
- return nullptr;
-}
-
-GeomRegion::GeomRegion() {
- stub("GeomRegion::GeomRegion");
-}
-
-GeomRegion *GeomRegion::getSize(float *arg2) {
- stub("GeomRegion::getSize");
- return nullptr;
-}
-
-GeomRegion *GeomRegion::getLocalCenter(float *arg2) {
- stub("GeomRegion::getLocalCenter");
- return nullptr;
-}
-
Joint::Joint() {
stub("Joint::Joint");
}
@@ -996,13 +729,4 @@ void PhysDebugDraw::drawAABB(float *arg2, int *arg3) {
PhysController::PhysController() {
}
-QueryGeomsInRegion::QueryGeomsInRegion() {
- stub("QueryGeomsInRegion::QueryGeomsInRegion");
-}
-
-int QueryGeomsInRegion::reportFixture(Geom **arg2, Geom *arg3) {
- stub("QueryGeomsInRegion::reportFixture");
- return 0;
-}
-
} // End of namespace NGI
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index 096c9f8d757..4649a501dbe 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -115,7 +115,6 @@ class GeomCircle;
class GeomEdge;
class GeomPolygon;
class GeomTriangle;
-class GeomRegion;
class Joint;
class JointDef;
class JointDistanceDef;
@@ -165,6 +164,11 @@ public:
/** Android CPhysicalObject (XML PHYSOBJ): a body with geometries */
class PhysicalObject : public GameObject {
public:
+ Scene *_scene = nullptr; // +20
+ PhysObjParams _params; // +40
+ b2Body *_body = nullptr; // +112
+ float _gravityScale = 1.0f; // +116
+ Common::Array<Geom *> _geoms; // +120
PhysicalObject();
PhysicalObject(Scene *arg2);
PhysicalObject(char **arg2);
@@ -186,12 +190,12 @@ public:
void getVel(int arg2); // 1173D0
int getRotation(); // 1173EA
int setRotation(float arg2); // 1173FA
- PhysicalObject *getPos(int arg2); // 117418
+ Vector2 getPos() const; // 117418
int setGravityScale(float arg2); // 117448
int setGravityMode(int arg2); // 117458
void physicalStop(); // 117474
- void calcB2AABB(int arg2); // 1174B0
- PhysicalObject *getBoundBox(int arg2); // 117548
+ b2AABB calcB2AABB() const; // 1174B0
+ BoundBox getBoundBox() const; // 117548
float setMass(float arg2); // 1175C4
int getMass(); // 117612
int scale(int arg2, int arg3, int arg4, int arg5); // 117618
@@ -232,19 +236,45 @@ private:
Common::HashMap<Common::String, Material> _materials; // +8
};
-/** Android CVisForPhys: the picture of a geometry */
+/** Android CGeomRegion: the local rectangle of a geometry in pixels */
+struct GeomRegion {
+ float _left = 0.0f; // +0
+ float _top = 0.0f; // +4
+ float _right = 0.0f; // +8
+ float _bottom = 0.0f; // +12
+
+ Vector2 getSize() const; // 11414A
+ Vector2 getLocalCenter() const; // 114318
+};
+
+/** Android CVisForPhys: a copy of a scene object that follows a geometry (XML VISOBJ) */
class VisForPhys {
public:
- VisForPhys();
- VisForPhys(void *arg2, Geom *arg3);
- VisForPhys(VisForPhys *arg2, Geom *arg3);
- virtual ~VisForPhys() {}
- void setPos(float arg2, float arg3); // 1140E4
- int setZ(float arg2); // 114132
- int setRotate(); // 114830
- float recalcVisible(); // 114928
- void setVisibleObj(bool arg2); // 114AA8
- void onRender(float arg2, float arg3); // 114D40
+ VisForPhys(const XmlNode &node, Geom *geom); // 114B70
+ VisForPhys(const VisForPhys &source, Geom *geom); // 114CE4
+ virtual ~VisForPhys(); // 1140D0
+ void setPos(float x, float y); // 1140E4
+ void setZ(float z); // 114132
+ void setRotate(); // 114830
+ void recalcVisible(); // 114928
+ void setVisibleObj(GameObject *object, bool dontScale); // 114AA8
+ void onRender(float scrollX, float scrollY); // 114D40
+
+ int _dx = 0; // +0
+ int _dy = 0; // +4
+ bool _dontScale = false; // +8
+ GeomRegion _window; // +12: the window of the texture for dontScale
+ bool _stroke = false; // +28
+ float _red = 0.0f; // +32
+ float _green = 0.0f; // +36
+ float _blue = 0.0f; // +40
+ float _alpha = 0.0f; // +44
+ int _thickness = 0; // +48
+ GameObject *_visObj = nullptr; // +52
+ Geom *_geom; // +56
+
+private:
+ void removeVisObj();
};
/** Android CJointBuilder: builds the joints of a PHYSOBJ */
@@ -256,103 +286,101 @@ public:
void *buildJoint(void *arg2); // 116284
};
-/** Android IGeom: a shape of a physical object */
+/** Android IGeom: a shape of a physical object (a fixture of its body) */
class Geom {
public:
- Geom();
- Geom(PhysicalObject *arg2);
- Geom(VisForPhys **arg2);
- virtual ~Geom() {}
- void scale(); // 113C46
- void getVertices(); // 113C54
- int setPhysObject(int arg2); // 11468C
- void setPos(float arg2, float arg3); // 11481A
- int getPhysObj(); // 11482C
- int getVisObj(); // 11486E
- void setVisObj(VisForPhys *arg2); // 114872
- Geom *getWorldCenter(int arg2); // 114890
- int updateVis(float arg2, float arg3); // 1148D4
- void getRegion(int arg2); // 114918
- void getRegion(); // 114E58
- Geom *getBoundingBox(int arg2); // 114E5C
- void init(void *arg2); // 114EE4
- GeomParams *init(GeomParams *arg2); // 115760
+ Geom(); // 11535C
+ explicit Geom(PhysicalObject *physObj); // 115474
+ Geom(const Geom &source); // 1156C0
+ virtual ~Geom(); // 1146A4
+ virtual void init(const XmlNode &node); // 114EE4
+ virtual void init(GeomParams ¶ms); // 115760
+ virtual b2Fixture *createGeom() = 0;
+ virtual void updateVis(float scaleX, float scaleY); // 1148D4
+ virtual void scale(const Vector4 &rect) = 0;
+ virtual void scale(float value); // 113C46
+ virtual Common::Array<Vector2> getVertices(); // 113C54
+
+ void setPhysObject(PhysicalObject *physObj); // 11468C
+ void setPos(float x, float y); // 11481A
+ PhysicalObject *getPhysObj() const; // 11482C
+ VisForPhys *getVisObj() const; // 11486E
+ void setVisObj(VisForPhys *visObj); // 114872
+ Vector2 getWorldCenter() const; // 114890
+ const GeomRegion &getRegion() const; // 114918, 114E58
+ Vector4 getBoundingBox() const; // 114E5C
+
+ GeomParams _params; // +4
+ PhysicalObject *_physObj = nullptr; // +80
+ VisForPhys *_visObj = nullptr; // +84
+ GeomRegion _region; // +88
+ b2Fixture *_fixture = nullptr; // +104
};
/** Android IGeomBox */
class GeomBox : public Geom {
public:
- GeomBox();
- GeomBox(PhysicalObject *arg2);
- ~GeomBox() override {}
- void *createGeom(); // 114414
- float scale(int arg2, int arg3, int arg4, int arg5); // 1144F4
- void init(void *arg2); // 1150BC
- GeomParams *init(GeomParams *arg2); // 11576A
- GeomBox *getVertices(int arg2); // 115838
+ GeomBox(); // 1153AC
+ explicit GeomBox(PhysicalObject *physObj); // 1154C8
+ void init(const XmlNode &node) override; // 1150BC
+ void init(GeomParams ¶ms) override; // 11576A
+ b2Fixture *createGeom() override; // 114414
+ void scale(const Vector4 &rect) override; // 1144F4
+ Common::Array<Vector2> getVertices() override; // 115838
};
/** Android IGeomCircle */
class GeomCircle : public Geom {
public:
- GeomCircle();
- GeomCircle(PhysicalObject *arg2);
- ~GeomCircle() override {}
- void scale(); // 113D34
- void *createGeom(); // 113EFC
- void scale(float arg2, float arg3, int arg4); // 1142A4
- void init(void *arg2); // 115174
- GeomParams *init(GeomParams *arg2); // 11579E
+ GeomCircle(); // 1153FC
+ explicit GeomCircle(PhysicalObject *physObj); // 115518
+ void init(const XmlNode &node) override; // 115174
+ void init(GeomParams ¶ms) override; // 11579E
+ b2Fixture *createGeom() override; // 113EFC
+ void scale(const Vector4 &rect) override; // 1142A4
+ void scale(float value) override; // 113D34
};
/** Android IGeomEdge */
class GeomEdge : public Geom {
public:
- GeomEdge();
- GeomEdge(PhysicalObject *arg2);
- ~GeomEdge() override {}
- void scale(int arg2, int arg3, int arg4, int arg5); // 113D80
- void *createGeom(); // 113F74
- void setPoints(int *arg2, int *arg3); // 114E9C
- void init(void *arg2); // 1151CC
- GeomParams *init(GeomParams *arg2); // 1157B8
+ GeomEdge(); // 115420
+ explicit GeomEdge(PhysicalObject *physObj); // 11553C
+ void init(const XmlNode &node) override; // 1151CC
+ void init(GeomParams ¶ms) override; // 1157B8
+ b2Fixture *createGeom() override; // 113F74
+ void scale(const Vector4 &rect) override; // 113D80
+ void setPoints(const Vector2 &first, const Vector2 &second); // 114E9C
};
/** Android IGeomPolygon */
class GeomPolygon : public Geom {
public:
- GeomPolygon();
- GeomPolygon(PhysicalObject *arg2);
- ~GeomPolygon() override {}
- void getRect(int arg2, int arg3); // 113C80
- GeomPolygon *getVertices(int arg2); // 113E38
- void *createGeom(); // 11401C
- float scale(int arg2, int arg3, int arg4, int arg5); // 114348
- void init(void *arg2); // 115060
- void init(uint32 arg2, uint32 arg3); // 1157D2
+ GeomPolygon(); // 115444
+ explicit GeomPolygon(PhysicalObject *physObj); // 115560
+ void init(const XmlNode &node) override; // 115060
+ void init(GeomParams ¶ms) override; // 1157D2
+ b2Fixture *createGeom() override; // 11401C
+ void scale(const Vector4 &rect) override; // 114348
+ Common::Array<Vector2> getVertices() override; // 113E38
+ virtual Vector4 getRect(const GeomParams ¶ms); // 113C80
+
+ Common::Array<Vector2> _vertices; // +140
};
-/** Android IGeomTriangle */
+/** Android IGeomTriangle (the vertex count is at +140, where the polygon has its vertices) */
class GeomTriangle : public Geom {
public:
- GeomTriangle();
- GeomTriangle(PhysicalObject *arg2);
- ~GeomTriangle() override {}
- void *createGeom(); // 11416C
- float scale(int arg2, int arg3, int arg4, int arg5); // 1145C0
- void update(uint32 arg2); // 11484A
- void init(void *arg2); // 115118
- GeomParams *init(GeomParams *arg2); // 115784
- GeomTriangle *getVertices(int arg2); // 1158FC
-};
-
-/** Android CGeomRegion */
-class GeomRegion {
-public:
- GeomRegion();
- virtual ~GeomRegion() {}
- GeomRegion *getSize(float *arg2); // 11414A
- GeomRegion *getLocalCenter(float *arg2); // 114318
+ GeomTriangle(); // 1153D0
+ explicit GeomTriangle(PhysicalObject *physObj); // 1154EC
+ void init(const XmlNode &node) override; // 115118
+ void init(GeomParams ¶ms) override; // 115784
+ b2Fixture *createGeom() override; // 11416C
+ void scale(const Vector4 &rect) override; // 1145C0
+ Common::Array<Vector2> getVertices() override; // 1158FC
+ virtual void update(uint32 elapsed); // 11484A
+
+ int _vertexCount = 3; // +140
};
/** Android IJoint */
@@ -456,14 +484,29 @@ private:
uint32 _nextBit; // +32
};
-/** Android QueryGeomsInRegion: b2QueryCallback */
-class QueryGeomsInRegion {
+/** Android QueryCallback: finds the dynamic fixture that contains a point */
+class QueryCallback : public b2QueryCallback {
public:
- QueryGeomsInRegion();
- virtual ~QueryGeomsInRegion() {}
- int reportFixture(Geom **arg2, Geom *arg3); // 1196AC
+ QueryCallback(); // 118B30
+ bool ReportFixture(b2Fixture *fixture) override;
+
+ b2Vec2 _point = b2Vec2(0.0f, 0.0f); // +4
+ b2Fixture *_fixture = nullptr; // +12
};
+/** Android QueryGeomsInRegion: collects the geometries of the dynamic fixtures in an AABB */
+class QueryGeomsInRegion : public b2QueryCallback {
+public:
+ bool ReportFixture(b2Fixture *fixture) override; // 1196AC
+
+ Common::Array<Geom *> _geoms; // +4
+};
+
+/** CRender::DrawLine, DrawEmptyQuad, DrawCircle: the debug drawing of the physics (physdraw.cpp) */
+void physDrawLine(float red, float green, float blue, float alpha, float x0, float y0, float x1, float y1);
+void physDrawEmptyQuad(float red, float green, float blue, float alpha, float x, float y, float width, float height);
+void physDrawCircle(float red, float green, float blue, float alpha, float x, float y, float radius);
+
} // End of namespace NGI
#endif // NGI_PHYSICS_H
Commit: afeb770849a4507a5d0d77509bd747ff9d180808
https://github.com/scummvm/scummvm/commit/afeb770849a4507a5d0d77509bd747ff9d180808
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Physical objects and ground (CPhysicalObject, CPhysGround)
Changed paths:
engines/ngi/physics.cpp
engines/ngi/physics.h
diff --git a/engines/ngi/physics.cpp b/engines/ngi/physics.cpp
index 840785694e3..efc3e4a243c 100644
--- a/engines/ngi/physics.cpp
+++ b/engines/ngi/physics.cpp
@@ -23,7 +23,9 @@
#include "common/hashmap.h"
#include "ngi/ngi.h"
+#include "ngi/objects.h"
#include "ngi/physics.h"
+#include "ngi/scene.h"
#include "ngi/xmlnode.h"
namespace NGI {
@@ -217,239 +219,279 @@ PhysObjParams::PhysObjParams() {
_material = g_ngi->physMaterials().getMaterial("DEFAULT");
}
-PhysListener::PhysListener() {
- stub("PhysListener::PhysListener");
-}
+// CPhysicalObject
-PhysListener::PhysListener(Scene *arg2) {
- stub("PhysListener::PhysListener");
+static int findObjectId(const Common::String &name) {
+ uint32 id = 0;
+ if (!g_ngi->_gameProject->_objectIds.findId(name, id))
+ warning("Unknown object id '%s'", name.c_str());
+ return id;
}
-int PhysListener::beginContact(int arg2) {
- stub("PhysListener::beginContact");
- return 0;
+PhysicalObject::PhysicalObject(Scene *scene) : _scene(scene) {
+ _title = "empty";
+ _params._categoryBits = g_ngi->physRegistrator().getCategory("catbits_default");
+ _params._maskBits = g_ngi->physRegistrator().getCategory("catbits_all");
}
-int PhysListener::endContact(int arg2) {
- stub("PhysListener::endContact");
- return 0;
-}
-
-int PhysListener::postSolve(uint32 *arg2, int arg3) {
- stub("PhysListener::postSolve");
- return 0;
-}
-
-int PhysListener::initWorld() {
- stub("PhysListener::initWorld");
- return 0;
-}
-
-int PhysListener::getWorld() {
- stub("PhysListener::getWorld");
- return 0;
-}
-
-int PhysListener::onShow() {
- stub("PhysListener::onShow");
- return 0;
+PhysicalObject::PhysicalObject(PhysicalObject *source) : GameObject(source), _scene(source->_scene), _locale(source->_locale),
+ _params(source->_params), _gravityScale(source->_gravityScale) {
}
-void PhysListener::clearWorld() {
- stub("PhysListener::clearWorld");
+PhysicalObject::~PhysicalObject() {
+ for (Geom *geom : _geoms)
+ delete geom;
}
-void PhysListener::onHide() {
- stub("PhysListener::onHide");
-}
+// CGameObject::Init, then the object's own attributes and its geometries
+void PhysicalObject::init(const XmlNode &node) {
+ _id = findObjectId(node.attrStr("id", ""));
+ _objectFlags = node.attrInt("flags", 0);
+ _title = node.attrStr("title", "empty");
+ _locale = node.attrBool("locale", false);
-void PhysListener::render() {
- stub("PhysListener::render");
-}
+ _params._physFlags = node.attrInt("physflags", 0);
+ _params._categoryBits = node.attrInt("catbits", g_ngi->physRegistrator().getCategory("catbits_default"));
+ _params._maskBits = node.attrInt("maskbits", g_ngi->physRegistrator().getCategory("catbits_all"));
+ _params._x = node.attrFloat("x", 0.0f);
+ _params._y = node.attrFloat("y", 0.0f);
+ _params._material = g_ngi->physMaterials().getMaterial(node.attrStr("material", "DEFAULT"));
-int PhysListener::findPhysicalObject(uint32 arg2) {
- stub("PhysListener::findPhysicalObject");
- return 0;
+ for (uint i = 0; i < node.childCount(); i++) {
+ const Common::String &name = node[i].name();
+ Geom *geom = nullptr;
+ if (name == "VELOCITY") {
+ _params._velocityX = node[i].attrFloat("x", 0.0f);
+ _params._velocityY = node[i].attrFloat("y", 0.0f);
+ } else if (name == "FORCE") {
+ _params._forceX = node[i].attrFloat("x", 0.0f);
+ _params._forceY = node[i].attrFloat("y", 0.0f);
+ } else if (name == "GEOMBOX") {
+ geom = new GeomBox(this);
+ } else if (name == "GEOMTRIANGLE") {
+ geom = new GeomTriangle(this);
+ } else if (name == "GEOMCIRCLE") {
+ geom = new GeomCircle(this);
+ } else if (name == "GEOMEDGE") {
+ geom = new GeomEdge(this);
+ }
+ if (geom) {
+ geom->init(node[i]);
+ _geoms.push_back(geom);
+ }
+ }
}
-int PhysListener::findPhysicalObject(float arg2, float arg3) {
- stub("PhysListener::findPhysicalObject");
+int PhysicalObject::processMessage(Command *command) {
return 0;
}
-float PhysListener::onMouseLDown(uint32 arg2, void *arg3) {
- stub("PhysListener::onMouseLDown");
- return 0.0f;
+void PhysicalObject::removeThis() {
+ for (Geom *geom : _geoms)
+ delete geom;
+ _geoms.clear();
+ clearPhysics();
+ getPhysListener()->removeObject(this);
+ delete this; // CGameObject::RemoveThis
}
-int PhysListener::onMouseLUp(void *arg2) {
- stub("PhysListener::onMouseLUp");
- return 0;
+void PhysicalObject::init(const PhysObjParams ¶ms) {
+ _id = params._id;
+ _params = params;
}
-void PhysListener::onMouseMove(uint32 arg2, float arg3, float arg4) {
- stub("PhysListener::onMouseMove");
-}
+void PhysicalObject::initPhysics() {
+ b2BodyDef def;
+ def.type = (_params._physFlags & 2) ? b2_staticBody : b2_dynamicBody;
+ def.position.Set(_params._x / 30.0f, _params._y / 30.0f);
+ def.linearVelocity.Set(_params._velocityX, _params._velocityY);
+ if (!(_params._physFlags & 4))
+ def.fixedRotation = true;
-void PhysListener::fixtureDestroyed(int arg2) {
- stub("PhysListener::fixtureDestroyed");
-}
+ _body = getPhysListener()->getWorld()->CreateBody(&def);
+ _body->SetUserData(this);
+ _body->ApplyForceToCenter(b2Vec2(_params._forceX, _params._forceY));
+ _body->SetLinearDamping(_params._linearDamping);
+ _body->SetAngularDamping(_params._angularDamping);
-void PhysListener::setScale(int arg2, int arg3) {
- stub("PhysListener::setScale");
-}
-
-void PhysListener::createGround(float arg2, float arg3, int arg4, float arg5) {
- stub("PhysListener::createGround");
-}
-
-PhysListener *PhysListener::getWorldRegion(int arg2) {
- stub("PhysListener::getWorldRegion");
- return nullptr;
-}
-
-int PhysListener::init(void *arg2) {
- stub("PhysListener::init");
- return 0;
-}
-
-int PhysListener::preSolve(uint32 *arg2, int arg3) {
- stub("PhysListener::preSolve");
- return 0;
+ for (Geom *geom : _geoms) {
+ geom->setPhysObject(this);
+ geom->createGeom();
+ }
}
-PhysListener *PhysListener::removeObject(PhysicalObject *arg2, int arg3) {
- stub("PhysListener::removeObject");
- return nullptr;
+void PhysicalObject::clearPhysics() {
+ if (_body) {
+ getPhysListener()->getWorld()->DestroyBody(_body);
+ _body = nullptr;
+ }
}
-void PhysListener::checkOutworldObjects() {
- stub("PhysListener::checkOutworldObjects");
+void PhysicalObject::update(uint32 elapsed) {
+ for (Geom *geom : _geoms)
+ geom->updateVis(getPhysListener()->_scale.x, getPhysListener()->_scale.y);
}
-void PhysListener::doStep() {
- stub("PhysListener::doStep");
+void PhysicalObject::render(const Vector2 &scroll) {
+ for (Geom *geom : _geoms) {
+ if (geom->getVisObj())
+ geom->getVisObj()->onRender(scroll.x, scroll.y);
+ }
}
-int PhysListener::update(uint32 arg2) {
- stub("PhysListener::update");
- return 0;
+void PhysicalObject::setPos(Vector2 pos) {
+ if (_body) {
+ _body->SetTransform(b2Vec2(pos.x / 30.0f, pos.y / 30.0f), _body->GetAngle());
+ _body->SetAwake(true);
+ }
}
-void PhysListener::findGeomsInRegion(int arg2, int arg3, int arg4, float arg5, Geom ***arg6) {
- stub("PhysListener::findGeomsInRegion");
+void PhysicalObject::setPos(float x, float y) {
+ Vector2 pos;
+ pos.x = x;
+ pos.y = y;
+ setPos(pos);
}
-void PhysListener::findObjectsInRegion(int arg2, int arg3, int arg4, int arg5, int *arg6) {
- stub("PhysListener::findObjectsInRegion");
+Vector4 PhysicalObject::getRect() const {
+ return getBoundBox().getWorldRect();
}
-PhysicalObject::PhysicalObject() {
- stub("PhysicalObject::PhysicalObject");
+PhysListener *PhysicalObject::getPhysListener() const {
+ return _scene->_physListener.get();
}
-PhysicalObject::PhysicalObject(Scene *arg2) {
- stub("PhysicalObject::PhysicalObject");
+void PhysicalObject::addForce(const Vector2 &force) {
+ if (_body)
+ _body->ApplyForceToCenter(b2Vec2(force.x, force.y));
}
-PhysicalObject::PhysicalObject(char **arg2) {
- stub("PhysicalObject::PhysicalObject");
+void PhysicalObject::setVel(float x, float y) {
+ if (_body)
+ _body->SetLinearVelocity(b2Vec2(x, y));
}
-int PhysicalObject::processMessage(Command *arg2) {
- stub("PhysicalObject::processMessage");
- return 0;
+Vector2 PhysicalObject::getVel() const {
+ Vector2 vel = Vector2();
+ if (_body) {
+ vel.x = _body->GetLinearVelocity().x;
+ vel.y = _body->GetLinearVelocity().y;
+ }
+ return vel;
}
-void PhysicalObject::setPos(uint32 arg2) {
- stub("PhysicalObject::setPos");
+float PhysicalObject::getRotation() const {
+ return _body ? _body->GetAngle() : 0.0f;
}
-void PhysicalObject::clearPhysics() {
- stub("PhysicalObject::clearPhysics");
+void PhysicalObject::setRotation(float angle) {
+ if (_body) {
+ _body->SetTransform(_body->GetPosition(), angle);
+ _body->SetAwake(true);
+ }
}
-int PhysicalObject::removeThis() {
- stub("PhysicalObject::removeThis");
- return 0;
+void PhysicalObject::setGravityScale(float scale) {
+ _gravityScale = scale;
+ if (_body)
+ _body->SetGravityScale(scale);
}
-void PhysicalObject::render(uint32 arg2, uint32 arg3) {
- stub("PhysicalObject::render");
+void PhysicalObject::setGravityMode(bool enable) {
+ if (_body)
+ _body->SetGravityScale(enable ? _gravityScale : 0.0f);
}
-int PhysicalObject::init(uint32 *arg2) {
- stub("PhysicalObject::init");
- return 0;
+void PhysicalObject::physicalStop() {
+ if (!_body)
+ return;
+ _body->SetLinearVelocity(b2Vec2_zero);
+ _body->SetLinearDamping(0.0f);
+ if (_body->GetType() != b2_staticBody)
+ _body->SetAngularVelocity(0.0f);
+ _body->SetAngularDamping(0.0f);
}
-void PhysicalObject::setPos(float arg2, float arg3, float arg4) {
- stub("PhysicalObject::setPos");
+void PhysicalObject::setMass(float mass) {
+ b2MassData data;
+ data.mass = mass;
+ data.center = _body->GetLocalCenter();
+ data.I = _body->GetInertia();
+ _body->SetMassData(&data);
}
-float PhysicalObject::initPhysics() {
- stub("PhysicalObject::initPhysics");
- return 0.0f;
+float PhysicalObject::getMass() const {
+ return _body->GetMass();
}
-PhysicalObject *PhysicalObject::getRect(int arg2) {
- stub("PhysicalObject::getRect");
- return nullptr;
+void PhysicalObject::scale(const Vector4 &rect) {
+ for (Geom *geom : _geoms)
+ geom->scale(rect);
}
-int PhysicalObject::getPhysListener() {
- stub("PhysicalObject::getPhysListener");
- return 0;
+void PhysicalObject::scale(float value) {
+ for (Geom *geom : _geoms)
+ geom->scale(value);
}
-void PhysicalObject::update() {
- stub("PhysicalObject::update");
+void PhysicalObject::setMaskBits(uint32 bits) {
+ _params._maskBits = bits;
+ for (Geom *geom : _geoms)
+ geom->_params._maskBits = bits;
}
-void PhysicalObject::addForce(int arg2) {
- stub("PhysicalObject::addForce");
+void PhysicalObject::setCategoryBits(uint32 bits) {
+ _params._categoryBits = bits;
+ for (Geom *geom : _geoms)
+ geom->_params._categoryBits = bits;
}
-int PhysicalObject::setVel(float arg2, float arg3, float arg4) {
- stub("PhysicalObject::setVel");
- return 0;
+void PhysicalObject::setSensor(bool sensor) {
+ for (Geom *geom : _geoms)
+ geom->_fixture->SetSensor(sensor);
}
-void PhysicalObject::getVel(int arg2) {
- stub("PhysicalObject::getVel");
+void PhysicalObject::setRotatable(bool rotatable) {
+ if (rotatable)
+ _params._physFlags |= 4;
+ else
+ _params._physFlags &= ~4;
+ _body->SetFixedRotation(!(_params._physFlags & 4));
}
-int PhysicalObject::getRotation() {
- stub("PhysicalObject::getRotation");
- return 0;
+int PhysicalObject::getRotatable() const {
+ return (_params._physFlags & 4) ? -1 : 0;
}
-int PhysicalObject::setRotation(float arg2) {
- stub("PhysicalObject::setRotation");
- return 0;
+Common::Array<Vector2> PhysicalObject::getVertexsAt(int index) {
+ if (index < static_cast<int>(_geoms.size()))
+ return _geoms[index]->getVertices();
+ return Common::Array<Vector2>();
}
-Vector2 PhysicalObject::getPos() const {
- Vector2 pos = Vector2();
- if (_body) {
- pos.x = _body->GetPosition().x * 30.0f;
- pos.y = _body->GetPosition().y * 30.0f;
+void PhysicalObject::removeGeom(Geom *geom) {
+ for (uint i = 0; i < _geoms.size(); i++) {
+ if (_geoms[i] == geom) {
+ _body->DestroyFixture(geom->_fixture);
+ _geoms.remove_at(i);
+ return;
+ }
}
- return pos;
}
-int PhysicalObject::setGravityScale(float arg2) {
- stub("PhysicalObject::setGravityScale");
- return 0;
+// the geometry is found by its type, as the original compares the first field of the parameters
+void PhysicalObject::removeGeom(int type) {
+ for (uint i = 0; i < _geoms.size(); i++) {
+ if (_geoms[i]->_params._type == type) {
+ _geoms.remove_at(i);
+ return;
+ }
+ }
}
-int PhysicalObject::setGravityMode(int arg2) {
- stub("PhysicalObject::setGravityMode");
- return 0;
-}
-
-void PhysicalObject::physicalStop() {
- stub("PhysicalObject::physicalStop");
+void PhysicalObject::addGeom(Geom *geom) {
+ _geoms.push_back(geom);
+ geom->setPhysObject(this);
}
b2AABB PhysicalObject::calcB2AABB() const {
@@ -481,93 +523,209 @@ BoundBox PhysicalObject::getBoundBox() const {
return box;
}
-float PhysicalObject::setMass(float arg2) {
- stub("PhysicalObject::setMass");
- return 0.0f;
+Vector2 PhysicalObject::getPos() const {
+ Vector2 pos = Vector2();
+ if (_body) {
+ pos.x = _body->GetPosition().x * 30.0f;
+ pos.y = _body->GetPosition().y * 30.0f;
+ }
+ return pos;
+}
+
+// CPhysGround
+
+PhysGround::PhysGround(Scene *scene) : PhysicalObject(scene) {
+}
+
+void PhysGround::addPoint(float x, float y) {
+ Vector2 point;
+ point.x = x;
+ point.y = y;
+ _points.push_back(point);
+}
+
+void PhysGround::init(const XmlNode &node) {
+ _id = findObjectId(node.attrStr("id", ""));
+ _objectFlags = node.attrInt("flags", 0);
+ _title = node.attrStr("title", "empty");
+ _locale = node.attrBool("locale", false);
+
+ _params._physFlags = 3;
+ _params._categoryBits = node.attrInt("catbits", g_ngi->physRegistrator().getCategory("catbits_default"));
+ _params._maskBits = node.attrInt("maskbits", g_ngi->physRegistrator().getCategory("catbits_all"));
+ _params._x = node.attrFloat("x", 0.0f);
+ _params._y = node.attrFloat("y", 0.0f);
+ _params._material._density = 0.0f;
+ _params._material._friction = 0.6f;
+
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (node[i].name() == "POINT")
+ addPoint(node[i].attrFloat("x", 0.0f), node[i].attrFloat("y", 0.0f));
+ }
+}
+
+// The edges are added every time, also when the world is made again (as the original)
+void PhysGround::initPhysics() {
+ if (_points.size() < 2)
+ return;
+
+ b2BodyDef def;
+ def.type = b2_staticBody;
+ def.position.Set(_points[0].x / 30.0f, _points[0].y / 30.0f);
+ _body = getPhysListener()->getWorld()->CreateBody(&def);
+ _body->SetUserData(this);
+
+ Vector2 previous = _points[0];
+ for (uint i = 1; i < _points.size(); i++) {
+ GeomParams params;
+ params._material._friction = _params._material._friction;
+ params._material._density = _params._material._density;
+ GeomEdge *edge = new GeomEdge();
+ edge->init(params);
+ edge->setPoints(previous, _points[i]);
+ addGeom(edge);
+ edge->createGeom();
+ previous = _points[i];
+ }
+ _params._physFlags |= 2;
+ setPos(_params._x, _params._y);
+}
+
+PhysListener::PhysListener() {
+ stub("PhysListener::PhysListener");
}
-int PhysicalObject::getMass() {
- stub("PhysicalObject::getMass");
+PhysListener::PhysListener(Scene *arg2) {
+ stub("PhysListener::PhysListener");
+ _scene = arg2;
+}
+
+int PhysListener::beginContact(int arg2) {
+ stub("PhysListener::beginContact");
return 0;
}
-int PhysicalObject::scale(int arg2, int arg3, int arg4, int arg5) {
- stub("PhysicalObject::scale");
+int PhysListener::endContact(int arg2) {
+ stub("PhysListener::endContact");
return 0;
}
-int PhysicalObject::scale(float arg2) {
- stub("PhysicalObject::scale");
+int PhysListener::postSolve(uint32 *arg2, int arg3) {
+ stub("PhysListener::postSolve");
return 0;
}
-void PhysicalObject::setMaskBits(int arg2) {
- stub("PhysicalObject::setMaskBits");
+int PhysListener::initWorld() {
+ stub("PhysListener::initWorld");
+ return 0;
}
-void PhysicalObject::setCategoryBits(int arg2) {
- stub("PhysicalObject::setCategoryBits");
+b2World *PhysListener::getWorld() const {
+ return _world;
}
-int PhysicalObject::setSensor(int arg2) {
- stub("PhysicalObject::setSensor");
+int PhysListener::onShow() {
+ stub("PhysListener::onShow");
return 0;
}
-float PhysicalObject::setRotatable(int arg2) {
- stub("PhysicalObject::setRotatable");
+void PhysListener::clearWorld() {
+ stub("PhysListener::clearWorld");
+}
+
+void PhysListener::onHide() {
+ stub("PhysListener::onHide");
+}
+
+void PhysListener::render() {
+ stub("PhysListener::render");
+}
+
+int PhysListener::findPhysicalObject(uint32 arg2) {
+ stub("PhysListener::findPhysicalObject");
+ return 0;
+}
+
+int PhysListener::findPhysicalObject(float arg2, float arg3) {
+ stub("PhysListener::findPhysicalObject");
+ return 0;
+}
+
+float PhysListener::onMouseLDown(uint32 arg2, void *arg3) {
+ stub("PhysListener::onMouseLDown");
return 0.0f;
}
-int PhysicalObject::getRotatable() {
- stub("PhysicalObject::getRotatable");
+int PhysListener::onMouseLUp(void *arg2) {
+ stub("PhysListener::onMouseLUp");
return 0;
}
-PhysicalObject *PhysicalObject::getVertexsAt(int arg2, int arg3) {
- stub("PhysicalObject::getVertexsAt");
- return nullptr;
+void PhysListener::onMouseMove(uint32 arg2, float arg3, float arg4) {
+ stub("PhysListener::onMouseMove");
}
-void PhysicalObject::removeGeom(Geom *arg2) {
- stub("PhysicalObject::removeGeom");
+void PhysListener::fixtureDestroyed(int arg2) {
+ stub("PhysListener::fixtureDestroyed");
}
-void PhysicalObject::removeGeom(int arg2) {
- stub("PhysicalObject::removeGeom");
+void PhysListener::setScale(int arg2, int arg3) {
+ stub("PhysListener::setScale");
}
-uint32 PhysicalObject::init(void *arg2) {
- stub("PhysicalObject::init");
+void PhysListener::createGround(float arg2, float arg3, int arg4, float arg5) {
+ stub("PhysListener::createGround");
+}
+
+PhysListener *PhysListener::getWorldRegion(int arg2) {
+ stub("PhysListener::getWorldRegion");
+ return nullptr;
+}
+
+int PhysListener::init(void *arg2) {
+ stub("PhysListener::init");
return 0;
}
-void PhysicalObject::addGeom(Geom *arg2) {
- stub("PhysicalObject::addGeom");
+int PhysListener::preSolve(uint32 *arg2, int arg3) {
+ stub("PhysListener::preSolve");
+ return 0;
}
-PhysGround::PhysGround() {
- stub("PhysGround::PhysGround");
+void PhysListener::removeObject(PhysicalObject *object) {
+ for (uint i = 0; i < _objects.size(); i++) {
+ if (_objects[i] == object) {
+ _objects.remove_at(i);
+ break;
+ }
+ }
}
-PhysGround::PhysGround(Scene *arg2) {
- stub("PhysGround::PhysGround");
+void PhysListener::addObject(PhysicalObject *object) {
+ _objects.push_back(object);
}
-PhysicalObject *PhysGround::initPhysics() {
- stub("PhysGround::initPhysics");
- return nullptr;
+void PhysListener::checkOutworldObjects() {
+ stub("PhysListener::checkOutworldObjects");
}
-void PhysGround::addPoint(uint32 arg2, uint32 arg3) {
- stub("PhysGround::addPoint");
+void PhysListener::doStep() {
+ stub("PhysListener::doStep");
}
-uint32 PhysGround::init(void *arg2) {
- stub("PhysGround::init");
+int PhysListener::update(uint32 arg2) {
+ stub("PhysListener::update");
return 0;
}
+void PhysListener::findGeomsInRegion(int arg2, int arg3, int arg4, float arg5, Geom ***arg6) {
+ stub("PhysListener::findGeomsInRegion");
+}
+
+void PhysListener::findObjectsInRegion(int arg2, int arg3, int arg4, int arg5, int *arg6) {
+ stub("PhysListener::findObjectsInRegion");
+}
+
JointBuilder::JointBuilder() {
stub("JointBuilder::JointBuilder");
}
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index 4649a501dbe..093cbe54b11 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -130,6 +130,11 @@ class QueryGeomsInRegion;
/** Android CPhysListener: the Box2D world of a scene (XML PHYSICS), b2ContactListener */
class PhysListener {
public:
+ Scene *_scene = nullptr; // +108
+ b2World *_world = nullptr; // +112
+ Vector2 _scale = Vector2(); // +192
+ Common::Array<PhysicalObject *> _objects; // +200
+
PhysListener();
PhysListener(Scene *arg2);
virtual ~PhysListener() {}
@@ -137,7 +142,7 @@ public:
int endContact(int arg2); // 11896A
int postSolve(uint32 *arg2, int arg3); // 1189C4
int initWorld(); // 118BA4
- int getWorld(); // 118C28
+ b2World *getWorld() const; // 118C28
int onShow(); // 118C2C
void clearWorld(); // 118C34
void onHide(); // 118C6A
@@ -153,7 +158,8 @@ public:
PhysListener *getWorldRegion(int arg2); // 119098
int init(void *arg2); // 119118
int preSolve(uint32 *arg2, int arg3); // 119568
- PhysListener *removeObject(PhysicalObject *arg2, int arg3); // 1196FE
+ void removeObject(PhysicalObject *object); // 1196FE
+ void addObject(PhysicalObject *object); // 1197C0
void checkOutworldObjects(); // 1197CE
void doStep(); // 119854
int update(uint32 arg2); // 1199C8
@@ -161,66 +167,92 @@ public:
void findObjectsInRegion(int arg2, int arg3, int arg4, int arg5, int *arg6); // 119B60
};
+/** Android ContactPoint: a point of a contact (kept by CPhysListener::PreSolve) */
+struct ContactPoint {
+ b2Fixture *_fixtureA = nullptr; // +0
+ b2Fixture *_fixtureB = nullptr; // +4
+ b2Vec2 _normal = b2Vec2(0.0f, 0.0f); // +8
+ b2Vec2 _position = b2Vec2(0.0f, 0.0f); // +16
+ b2PointState _state = b2_nullState; // +24
+};
+
+/** Android _COLLISION_INFO: what a physical object is told about a contact */
+struct CollisionInfo {
+ PhysicalObject *_other = nullptr; // +0: the object on the other side
+ Geom *_otherGeom = nullptr; // +4: its geometry (Begin and EndContact)
+ ContactPoint _point; // +8 (PreSolve)
+ const b2ContactImpulse *_impulse = nullptr; // +36 (PostSolve)
+ b2Contact *_contact = nullptr; // +40
+};
+
/** Android CPhysicalObject (XML PHYSOBJ): a body with geometries */
class PhysicalObject : public GameObject {
public:
+ explicit PhysicalObject(Scene *scene); // 117B30
+ explicit PhysicalObject(PhysicalObject *source); // 117C60
+ ~PhysicalObject() override; // 116F08
+ using GameObject::setPos;
+
+ virtual void init(const XmlNode &node); // 117E88
+ virtual int processMessage(Command *command); // 116DC4
+ virtual void removeThis(); // 116E06
+ virtual void init(const PhysObjParams ¶ms); // 116E6A
+ virtual void initPhysics(); // 11703C
+ virtual void clearPhysics(); // 116DE8
+ virtual void update(uint32 elapsed); // 11736E
+ virtual void render(const Vector2 &scroll); // 116E40
+ virtual void onCollide(CollisionInfo &info) {} // 116DC8
+ virtual void beginContact(CollisionInfo &info) {} // 116DCA
+ virtual void endContact(CollisionInfo &info) {} // 116DCC
+ virtual void preSolve(CollisionInfo &info) {} // 116DCE
+ virtual void postSolve(CollisionInfo &info) {} // 116DD0
+ virtual void setPos(Vector2 pos); // 116FCC
+ virtual void setPos(float x, float y); // 116DD2
+ virtual BoundBox getBoundBox() const; // 117548
+ virtual Vector4 getRect() const; // 11716C
+
+ PhysListener *getPhysListener() const; // 117368
+ void addForce(const Vector2 &force); // 117398
+ void setVel(float x, float y); // 1173B0
+ Vector2 getVel() const; // 1173D0
+ float getRotation() const; // 1173EA
+ void setRotation(float angle); // 1173FA
+ Vector2 getPos() const; // 117418
+ void setGravityScale(float scale); // 117448
+ void setGravityMode(bool enable); // 117458
+ void physicalStop(); // 117474
+ b2AABB calcB2AABB() const; // 1174B0
+ void setMass(float mass); // 1175C4
+ float getMass() const; // 117612
+ void scale(const Vector4 &rect); // 117618
+ void scale(float value); // 11764A
+ void setMaskBits(uint32 bits); // 117666
+ void setCategoryBits(uint32 bits); // 11767A
+ void setSensor(bool sensor); // 11768E
+ void setRotatable(bool rotatable); // 1176AA
+ int getRotatable() const; // 1176D8
+ Common::Array<Vector2> getVertexsAt(int index); // 1176E0
+ void removeGeom(Geom *geom); // 117D4C
+ void removeGeom(int type); // 117DD8
+ void addGeom(Geom *geom); // 11813C
+
Scene *_scene = nullptr; // +20
+ bool _locale = false; // +36
PhysObjParams _params; // +40
b2Body *_body = nullptr; // +112
float _gravityScale = 1.0f; // +116
Common::Array<Geom *> _geoms; // +120
- PhysicalObject();
- PhysicalObject(Scene *arg2);
- PhysicalObject(char **arg2);
- ~PhysicalObject() override {}
- int processMessage(Command *arg2); // 116DC4
- using GameObject::setPos;
- void setPos(uint32 arg2); // 116DD2
- void clearPhysics(); // 116DE8
- int removeThis(); // 116E06
- void render(uint32 arg2, uint32 arg3); // 116E40
- int init(uint32 *arg2); // 116E6A
- void setPos(float arg2, float arg3, float arg4); // 116FCC
- float initPhysics(); // 11703C
- PhysicalObject *getRect(int arg2); // 11716C
- int getPhysListener(); // 117368
- void update(); // 11736E
- void addForce(int arg2); // 117398
- int setVel(float arg2, float arg3, float arg4); // 1173B0
- void getVel(int arg2); // 1173D0
- int getRotation(); // 1173EA
- int setRotation(float arg2); // 1173FA
- Vector2 getPos() const; // 117418
- int setGravityScale(float arg2); // 117448
- int setGravityMode(int arg2); // 117458
- void physicalStop(); // 117474
- b2AABB calcB2AABB() const; // 1174B0
- BoundBox getBoundBox() const; // 117548
- float setMass(float arg2); // 1175C4
- int getMass(); // 117612
- int scale(int arg2, int arg3, int arg4, int arg5); // 117618
- int scale(float arg2); // 11764A
- void setMaskBits(int arg2); // 117666
- void setCategoryBits(int arg2); // 11767A
- int setSensor(int arg2); // 11768E
- float setRotatable(int arg2); // 1176AA
- int getRotatable(); // 1176D8
- PhysicalObject *getVertexsAt(int arg2, int arg3); // 1176E0
- void removeGeom(Geom *arg2); // 117D4C
- void removeGeom(int arg2); // 117DD8
- uint32 init(void *arg2); // 117E88
- void addGeom(Geom *arg2); // 11813C
};
-/** Android CPhysGround: XML PHYSGROUND: the static ground */
+/** Android CPhysGround: XML PHYSGROUND: the static ground, a chain of edges */
class PhysGround : public PhysicalObject {
public:
- PhysGround();
- PhysGround(Scene *arg2);
- ~PhysGround() override {}
- PhysicalObject *initPhysics(); // 115A10
- void addPoint(uint32 arg2, uint32 arg3); // 115BA8
- uint32 init(void *arg2); // 115BD4
+ explicit PhysGround(Scene *scene); // 115B40
+ void init(const XmlNode &node) override; // 115BD4
+ void initPhysics() override; // 115A10
+ void addPoint(float x, float y); // 115BA8
+
+ Common::Array<Vector2> _points; // +132
};
/** Android CPhysMaterials (CSingleton): the material table (built in ones and XML MATERIALS) */
Commit: 1fcdd4299a1c8499e85844b0351d0314ffb49af1
https://github.com/scummvm/scummvm/commit/1fcdd4299a1c8499e85844b0351d0314ffb49af1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Physics listener, debug drawing and the scene wiring (CPhysListener, CPhysDebugDraw)
Changed paths:
engines/ngi/physdraw.cpp
engines/ngi/physics.cpp
engines/ngi/physics.h
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/physdraw.cpp b/engines/ngi/physdraw.cpp
index 7fb2fd1dbbb..9cc27569e25 100644
--- a/engines/ngi/physdraw.cpp
+++ b/engines/ngi/physdraw.cpp
@@ -48,4 +48,82 @@ void physDrawCircle(float red, float green, float blue, float alpha, float x, fl
static_cast<int>(y + radius), colorOf(red, green, blue), false);
}
+// CPhysDebugDraw: every point goes through x * scale - scroll
+
+PhysDebugDraw::PhysDebugDraw() {
+}
+
+void PhysDebugDraw::setScale(float x, float y) {
+ _scaleX = x;
+ _scaleY = y;
+}
+
+void PhysDebugDraw::setScroll(float x, float y) {
+ _scrollX = x;
+ _scrollY = y;
+}
+
+// The original prints with the font of CDebugger, which is not here
+void PhysDebugDraw::drawString(int x, int y, const char *format, ...) {
+ warning("STUB/untested: PhysDebugDraw::drawString");
+}
+
+void PhysDebugDraw::DrawPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) {
+ const float firstX = _scaleX * vertices[0].x - _scrollX;
+ const float firstY = _scaleY * vertices[0].y - _scrollY;
+ for (int i = 1; i < vertexCount; i++) {
+ const float x0 = _scaleX * vertices[i - 1].x - _scrollX;
+ const float y0 = _scaleY * vertices[i - 1].y - _scrollY;
+ const float x1 = _scaleX * vertices[i].x - _scrollX;
+ const float y1 = _scaleY * vertices[i].y - _scrollY;
+ physDrawLine(color.r, color.g, color.b, 1.0f, x0, y0, x1, y1);
+ if (i == vertexCount - 1)
+ physDrawLine(color.r, color.g, color.b, 1.0f, x1, y1, firstX, firstY);
+ }
+}
+
+// the original draws the outline only
+void PhysDebugDraw::DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) {
+ DrawPolygon(vertices, vertexCount, color);
+}
+
+void PhysDebugDraw::DrawCircle(const b2Vec2 ¢er, float32 radius, const b2Color &color) {
+ physDrawCircle(color.r, color.g, color.b, 1.0f, _scaleX * center.x - _scrollX, _scaleY * center.y - _scrollY,
+ sqrtf(_scaleX * _scaleY) * radius);
+}
+
+void PhysDebugDraw::DrawSolidCircle(const b2Vec2 ¢er, float32 radius, const b2Vec2 &axis, const b2Color &color) {
+ DrawCircle(center, radius, color);
+}
+
+void PhysDebugDraw::DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color) {
+ physDrawLine(color.r, color.g, color.b, 1.0f, _scaleX * p1.x - _scrollX, _scaleY * p1.y - _scrollY,
+ _scaleX * p2.x - _scrollX, _scaleY * p2.y - _scrollY);
+}
+
+// the second axis scales its start with the x factor for both coordinates, as the original
+void PhysDebugDraw::DrawTransform(const b2Transform &xf) {
+ const float x = xf.p.x;
+ const float y = xf.p.y;
+ const float axisX = x + xf.q.c * 0.4f;
+ const float axisY = y + xf.q.s * 0.4f;
+ physDrawLine(1.0f, 0.0f, 0.0f, 1.0f, _scaleX * x - _scrollX, _scaleY * y - _scrollY, _scaleX * axisX - _scrollX,
+ _scaleY * axisY - _scrollY);
+ const float upX = x + (-xf.q.s) * 0.4f;
+ const float upY = y + xf.q.c * 0.4f;
+ physDrawLine(0.0f, 1.0f, 0.0f, 1.0f, _scaleX * x - _scrollX, _scaleX * y - _scrollY, _scaleX * upX - _scrollX,
+ _scaleY * upY - _scrollY);
+}
+
+// the size is not used, the quad is one pixel
+void PhysDebugDraw::drawPoint(const b2Vec2 &point, float size, const b2Color &color) {
+ physDrawEmptyQuad(color.r, color.g, color.b, 1.0f, _scaleX * point.x - _scrollX, _scaleY * point.y - _scrollY, 1.0f, 1.0f);
+}
+
+// the quad starts at the upper bound, as the original
+void PhysDebugDraw::drawAABB(const b2AABB &aabb, const b2Color &color) {
+ physDrawEmptyQuad(color.r, color.g, color.b, 1.0f, _scaleX * aabb.upperBound.x, _scaleY * aabb.upperBound.y,
+ _scaleX * (aabb.upperBound.x - aabb.lowerBound.x), _scaleY * (aabb.upperBound.y - aabb.lowerBound.y));
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/physics.cpp b/engines/ngi/physics.cpp
index efc3e4a243c..3f698f11bd7 100644
--- a/engines/ngi/physics.cpp
+++ b/engines/ngi/physics.cpp
@@ -26,6 +26,7 @@
#include "ngi/objects.h"
#include "ngi/physics.h"
#include "ngi/scene.h"
+#include "ngi/scenecontroller.h"
#include "ngi/xmlnode.h"
namespace NGI {
@@ -591,105 +592,323 @@ void PhysGround::initPhysics() {
setPos(_params._x, _params._y);
}
-PhysListener::PhysListener() {
- stub("PhysListener::PhysListener");
+// CDestructionListener
+
+void DestructionListener::SayGoodbye(b2Joint *joint) {
+ if (_listener->_mouseJoint != joint)
+ _listener->jointDestroyed(joint);
+ else
+ _listener->_mouseJoint = nullptr;
}
-PhysListener::PhysListener(Scene *arg2) {
- stub("PhysListener::PhysListener");
- _scene = arg2;
+void DestructionListener::SayGoodbye(b2Fixture *fixture) {
+ _listener->fixtureDestroyed(fixture);
}
-int PhysListener::beginContact(int arg2) {
- stub("PhysListener::beginContact");
- return 0;
+// CPhysListener
+
+PhysListener::PhysListener(Scene *scene) : _scene(scene), _destructionListener(this) {
+ _worldAABB.lowerBound.Set(0.0f, 25.6f);
+ _worldAABB.upperBound.Set(34.1333f, 0.0f);
+ _jointBuilder = new JointBuilder(this);
}
-int PhysListener::endContact(int arg2) {
- stub("PhysListener::endContact");
- return 0;
+PhysListener::~PhysListener() {
+ delete _jointBuilder;
+ delete _debugDraw;
+ while (!_objects.empty())
+ _objects[0]->removeThis();
+ delete _world;
+ _world = nullptr;
}
-int PhysListener::postSolve(uint32 *arg2, int arg3) {
- stub("PhysListener::postSolve");
- return 0;
+void PhysListener::BeginContact(b2Contact *contact) {
+ b2Fixture *fixtureA = contact->GetFixtureA();
+ b2Fixture *fixtureB = contact->GetFixtureB();
+ PhysicalObject *objectA = static_cast<PhysicalObject *>(fixtureA->GetBody()->GetUserData());
+ PhysicalObject *objectB = static_cast<PhysicalObject *>(fixtureB->GetBody()->GetUserData());
+ if (objectA) {
+ CollisionInfo info;
+ info._other = objectB;
+ info._otherGeom = static_cast<Geom *>(fixtureB->GetUserData());
+ info._contact = contact;
+ objectA->beginContact(info);
+ }
+ if (objectB) {
+ CollisionInfo info;
+ info._other = objectA;
+ info._otherGeom = static_cast<Geom *>(fixtureA->GetUserData());
+ info._contact = contact;
+ objectB->beginContact(info);
+ }
+ if (_scene->_controller)
+ _scene->_controller->beginContact(contact);
+}
+
+void PhysListener::EndContact(b2Contact *contact) {
+ b2Fixture *fixtureA = contact->GetFixtureA();
+ b2Fixture *fixtureB = contact->GetFixtureB();
+ PhysicalObject *objectA = static_cast<PhysicalObject *>(fixtureA->GetBody()->GetUserData());
+ PhysicalObject *objectB = static_cast<PhysicalObject *>(fixtureB->GetBody()->GetUserData());
+ if (objectA) {
+ CollisionInfo info;
+ info._other = objectB;
+ info._otherGeom = static_cast<Geom *>(fixtureB->GetUserData());
+ info._contact = contact;
+ objectA->endContact(info);
+ }
+ if (objectB) {
+ CollisionInfo info;
+ info._other = objectA;
+ info._otherGeom = static_cast<Geom *>(fixtureA->GetUserData());
+ info._contact = contact;
+ objectB->endContact(info);
+ }
+ if (_scene->_controller)
+ _scene->_controller->endContact(contact);
+}
+
+void PhysListener::PostSolve(b2Contact *contact, const b2ContactImpulse *impulse) {
+ b2Fixture *fixtureA = contact->GetFixtureA();
+ b2Fixture *fixtureB = contact->GetFixtureB();
+ for (int i = 0; i < contact->GetManifold()->pointCount; i++) {
+ PhysicalObject *objectA = static_cast<PhysicalObject *>(fixtureA->GetBody()->GetUserData());
+ PhysicalObject *objectB = static_cast<PhysicalObject *>(fixtureB->GetBody()->GetUserData());
+ if (objectA) {
+ CollisionInfo info;
+ info._other = objectB;
+ info._impulse = impulse;
+ info._contact = contact;
+ objectA->postSolve(info);
+ }
+ if (objectB) {
+ CollisionInfo info;
+ info._other = objectA;
+ info._impulse = impulse;
+ info._contact = contact;
+ objectB->postSolve(info);
+ }
+ }
+ if (_scene->_controller)
+ _scene->_controller->postSolve(contact, impulse);
}
-int PhysListener::initWorld() {
- stub("PhysListener::initWorld");
- return 0;
+void PhysListener::PreSolve(b2Contact *contact, const b2Manifold *oldManifold) {
+ const b2Manifold *manifold = contact->GetManifold();
+ if (manifold->pointCount == 0)
+ return;
+
+ b2Fixture *fixtureA = contact->GetFixtureA();
+ b2Fixture *fixtureB = contact->GetFixtureB();
+ b2PointState state1[b2_maxManifoldPoints];
+ b2PointState state2[b2_maxManifoldPoints];
+ b2GetPointStates(state1, state2, oldManifold, manifold);
+ b2WorldManifold worldManifold;
+ worldManifold.Initialize(manifold, fixtureA->GetBody()->GetTransform(), fixtureA->GetShape()->m_radius,
+ fixtureB->GetBody()->GetTransform(), fixtureB->GetShape()->m_radius);
+
+ for (int i = 0; i < manifold->pointCount; i++) {
+ if (_contacts.size() >= _maxContacts)
+ break;
+
+ ContactPoint point;
+ point._fixtureA = fixtureA;
+ point._fixtureB = fixtureB;
+ point._normal = worldManifold.normal;
+ point._position = worldManifold.points[i];
+ point._state = state2[i];
+ _contacts.push_back(point);
+
+ PhysicalObject *objectA = static_cast<PhysicalObject *>(fixtureA->GetBody()->GetUserData());
+ PhysicalObject *objectB = static_cast<PhysicalObject *>(fixtureB->GetBody()->GetUserData());
+ if (objectA) {
+ CollisionInfo info;
+ info._other = objectB;
+ info._point = point;
+ info._contact = contact;
+ objectA->preSolve(info);
+ }
+ if (objectB) {
+ CollisionInfo info;
+ info._other = objectA;
+ info._point = point;
+ info._contact = contact;
+ objectB->preSolve(info);
+ }
+ }
+ if (_scene->_controller)
+ _scene->_controller->preSolve(contact, oldManifold);
+}
+
+// The XML objects of the node are made by the loader (CScene::CreateObjects), after this
+void PhysListener::init(const XmlNode &node) {
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (node[i].name() == "MATERIALS")
+ g_ngi->physMaterials().setMaterials(node[i]);
+ }
+
+ _field188 = false;
+ _gravity.x = 0.0f;
+ _gravity.y = 10.0f;
+ _velocityIterations = 8;
+ _positionIterations = 3;
+ _fps = 60.0f;
+ _worldRegion = getWorldRegion();
+ _worldAABB.lowerBound.x = _worldRegion.x / 30.0f;
+ _worldAABB.lowerBound.y = _worldRegion.w / 30.0f;
+ _worldAABB.upperBound.x = _worldRegion.z / 30.0f;
+ _worldAABB.upperBound.y = _worldRegion.y / 30.0f;
+ _mouseJoint = nullptr;
+ _debugDraw = new PhysDebugDraw();
+ Vector2 scale;
+ scale.x = 1.0f;
+ scale.y = 1.0f;
+ setScale(scale);
+}
+
+void PhysListener::initWorld() {
+ _accumulator = 0.0f;
+ delete _world;
+ _world = new b2World(b2Vec2(_gravity.x, _gravity.y));
+ _world->SetDestructionListener(&_destructionListener);
+ _world->SetContactListener(this);
+ _world->SetDebugDraw(_debugDraw);
+ if (_scene->_controller)
+ _scene->_controller->onInitPhysics();
+ for (PhysicalObject *object : _objects)
+ object->initPhysics();
}
b2World *PhysListener::getWorld() const {
return _world;
}
-int PhysListener::onShow() {
- stub("PhysListener::onShow");
- return 0;
+void PhysListener::onShow() {
+ initWorld();
}
void PhysListener::clearWorld() {
- stub("PhysListener::clearWorld");
+ for (PhysicalObject *object : _objects)
+ object->clearPhysics();
+ delete _world;
+ _world = nullptr;
}
void PhysListener::onHide() {
- stub("PhysListener::onHide");
+ clearWorld();
}
void PhysListener::render() {
- stub("PhysListener::render");
}
-int PhysListener::findPhysicalObject(uint32 arg2) {
- stub("PhysListener::findPhysicalObject");
- return 0;
+PhysicalObject *PhysListener::findPhysicalObject(uint32 id) const {
+ for (PhysicalObject *object : _objects) {
+ if (id == (static_cast<uint16>(object->_id) | (static_cast<uint32>(object->_copyId) << 16)))
+ return object;
+ }
+ return nullptr;
}
-int PhysListener::findPhysicalObject(float arg2, float arg3) {
- stub("PhysListener::findPhysicalObject");
- return 0;
+static b2AABB pointAABB(const b2Vec2 &point) {
+ b2AABB aabb;
+ aabb.lowerBound.Set(point.x - 0.001f, point.y - 0.001f);
+ aabb.upperBound.Set(point.x + 0.001f, point.y + 0.001f);
+ return aabb;
}
-float PhysListener::onMouseLDown(uint32 arg2, void *arg3) {
- stub("PhysListener::onMouseLDown");
- return 0.0f;
+PhysicalObject *PhysListener::findPhysicalObject(float x, float y) {
+ _mouseTarget.x = x / 30.0f;
+ _mouseTarget.y = y / 30.0f;
+ const b2AABB aabb = pointAABB(_mouseTarget);
+ QueryCallback callback;
+ callback._point = _mouseTarget;
+ _world->QueryAABB(&callback, aabb);
+ if (callback._fixture)
+ return static_cast<PhysicalObject *>(callback._fixture->GetBody()->GetUserData());
+ return nullptr;
}
-int PhysListener::onMouseLUp(void *arg2) {
- stub("PhysListener::onMouseLUp");
- return 0;
-}
+void PhysListener::onMouseLDown(uint32 id, const Vector2 &pos) {
+ _mouseTarget.x = pos.x / 30.0f;
+ _mouseTarget.y = pos.y / 30.0f;
+ if (!_mouseEnabled || !_ground || _mouseJoint)
+ return;
-void PhysListener::onMouseMove(uint32 arg2, float arg3, float arg4) {
- stub("PhysListener::onMouseMove");
-}
+ const b2AABB aabb = pointAABB(_mouseTarget);
+ QueryCallback callback;
+ callback._point = _mouseTarget;
+ _world->QueryAABB(&callback, aabb);
+ if (!callback._fixture)
+ return;
-void PhysListener::fixtureDestroyed(int arg2) {
- stub("PhysListener::fixtureDestroyed");
+ b2Body *body = callback._fixture->GetBody();
+ b2MouseJointDef def;
+ def.bodyA = _ground;
+ def.bodyB = body;
+ def.collideConnected = false;
+ def.target = _mouseTarget;
+ def.maxForce = body->GetMass() * 1000.0f;
+ def.frequencyHz = 5.0f;
+ def.dampingRatio = 0.7f;
+ _mouseJoint = static_cast<b2MouseJoint *>(_world->CreateJoint(&def));
+ if (!body->IsAwake())
+ body->SetAwake(true);
+}
+
+void PhysListener::onMouseLUp(const Vector2 &pos) {
+ if (_mouseJoint) {
+ _world->DestroyJoint(_mouseJoint);
+ _mouseJoint = nullptr;
+ }
}
-void PhysListener::setScale(int arg2, int arg3) {
- stub("PhysListener::setScale");
+void PhysListener::onMouseMove(uint32 id, float x, float y) {
+ _mouseTarget.x = x / 30.0f;
+ _mouseTarget.y = y / 30.0f;
+ if (_mouseJoint)
+ _mouseJoint->SetTarget(_mouseTarget);
}
-void PhysListener::createGround(float arg2, float arg3, int arg4, float arg5) {
- stub("PhysListener::createGround");
+void PhysListener::fixtureDestroyed(b2Fixture *fixture) {
+ if (fixture->GetUserData() && _scene->_controller)
+ _scene->_controller->geomDestroyed(static_cast<Geom *>(fixture->GetUserData()));
}
-PhysListener *PhysListener::getWorldRegion(int arg2) {
- stub("PhysListener::getWorldRegion");
- return nullptr;
+void PhysListener::setScale(const Vector2 &scale) {
+ _scale = scale;
+ _debugDraw->setScale(_scale.x * 30.0f, _scale.y * 30.0f);
}
-int PhysListener::init(void *arg2) {
- stub("PhysListener::init");
- return 0;
+Material PhysListener::getMaterial(const Common::String &name) {
+ return g_ngi->physMaterials().getMaterial(name);
}
-int PhysListener::preSolve(uint32 *arg2, int arg3) {
- stub("PhysListener::preSolve");
- return 0;
+void PhysListener::createGround(float x0, float y0, float x1, float y1) {
+ b2BodyDef def;
+ _ground = _world->CreateBody(&def);
+
+ b2EdgeShape edge;
+ edge.Set(b2Vec2(x0 / 30.0f, y0 / 30.0f), b2Vec2(x1 / 30.0f, y1 / 30.0f));
+ b2Fixture *fixture = _ground->CreateFixture(&edge, 0.0f);
+ b2Filter filter;
+ filter.categoryBits = g_ngi->physRegistrator().getCategory("catbits_default");
+ filter.maskBits = g_ngi->physRegistrator().getCategory("catbits_all");
+ filter.groupIndex = 0;
+ fixture->SetFilterData(filter);
+}
+
+// the visible part of the game screen, centered over the scene
+Vector4 PhysListener::getWorldRegion() const {
+ const float width = static_cast<float>(g_ngi->gameWidth());
+ const float height = static_cast<float>(g_ngi->_backgroundSurface.h);
+ const float marginX = (static_cast<float>(_scene->_dims.x) - width) * 0.5f;
+ const float marginY = (static_cast<float>(_scene->_dims.y) - height) * 0.5f;
+ Vector4 region;
+ region.x = 0.0f - marginX;
+ region.y = 0.0f - marginY;
+ region.z = width + marginX;
+ region.w = height + marginY;
+ return region;
}
void PhysListener::removeObject(PhysicalObject *object) {
@@ -706,24 +925,81 @@ void PhysListener::addObject(PhysicalObject *object) {
}
void PhysListener::checkOutworldObjects() {
- stub("PhysListener::checkOutworldObjects");
+ Common::Array<PhysicalObject *> outside;
+ for (PhysicalObject *object : _objects) {
+ if (!object->getBoundBox().intersect(_worldAABB))
+ outside.push_back(object);
+ }
+ if (!outside.empty() && _scene->_controller)
+ _scene->_controller->outWorldObjects(outside);
}
void PhysListener::doStep() {
- stub("PhysListener::doStep");
+ const float step = 1.0f / _fps;
+ const uint32 elapsed = static_cast<uint32>(step * 1000.0f);
+ if (_scene->_controller)
+ _scene->_controller->onUpdatePhysics(elapsed);
+
+ _worldAABB.lowerBound.x = _worldRegion.x / 30.0f;
+ _worldAABB.lowerBound.y = _worldRegion.y / 30.0f;
+ _worldAABB.upperBound.x = _worldRegion.z / 30.0f;
+ _worldAABB.upperBound.y = _worldRegion.w / 30.0f;
+ _debugDraw->SetFlags(2 * _drawJoints + 4 * _drawAABBs + _drawShapes + 8 * _drawPairs + 16 * _drawCentersOfMass);
+ _world->SetWarmStarting(_warmStarting > 0);
+ _world->SetContinuousPhysics(_continuousPhysics > 0);
+ _world->SetSubStepping(_subStepping > 0);
+ _contacts.clear();
+ _world->Step(step, _velocityIterations, _positionIterations);
+ if (_scene->_controller)
+ _scene->_controller->onPostSolvePhysics(elapsed);
+
+ if (_mouseJoint) {
+ const b2Vec2 anchor = _mouseJoint->GetAnchorB();
+ const b2Vec2 target = _mouseJoint->GetTarget();
+ _debugDraw->drawPoint(anchor, 4.0f, b2Color(0.0f, 1.0f, 0.0f));
+ _debugDraw->drawPoint(target, 4.0f, b2Color(0.0f, 1.0f, 0.0f));
+ _debugDraw->DrawSegment(anchor, target, b2Color(0.8f, 0.8f, 0.8f));
+ }
+
+ for (PhysicalObject *object : _objects)
+ object->update(elapsed);
+ checkOutworldObjects();
}
-int PhysListener::update(uint32 arg2) {
- stub("PhysListener::update");
- return 0;
+// the accumulator runs in milliseconds against half the frame rate, as the original
+void PhysListener::update(uint32 elapsed) {
+ if (_world && !_paused) {
+ _accumulator += static_cast<float>(elapsed);
+ while (_accumulator > _fps * 0.5f) {
+ _accumulator -= _fps * 0.5f;
+ doStep();
+ }
+ }
}
-void PhysListener::findGeomsInRegion(int arg2, int arg3, int arg4, float arg5, Geom ***arg6) {
- stub("PhysListener::findGeomsInRegion");
+Common::Array<Geom *> PhysListener::findGeomsInRegion(const Vector4 ®ion) {
+ b2AABB aabb;
+ aabb.lowerBound.Set(region.x / 30.0f, region.y / 30.0f);
+ aabb.upperBound.Set(region.z / 30.0f, region.w / 30.0f);
+ QueryGeomsInRegion callback;
+ _world->QueryAABB(&callback, aabb);
+ return callback._geoms;
}
-void PhysListener::findObjectsInRegion(int arg2, int arg3, int arg4, int arg5, int *arg6) {
- stub("PhysListener::findObjectsInRegion");
+void PhysListener::findObjectsInRegion(const Vector4 ®ion, Common::Array<PhysicalObject *> &objects) {
+ const Common::Array<Geom *> geoms = findGeomsInRegion(region);
+ for (Geom *geom : geoms) {
+ PhysicalObject *object = geom->getPhysObj();
+ if (!object)
+ continue;
+ bool found = false;
+ for (PhysicalObject *known : objects) {
+ if (known == object)
+ found = true;
+ }
+ if (!found)
+ objects.push_back(object);
+ }
}
JointBuilder::JointBuilder() {
@@ -834,57 +1110,4 @@ void *JointWheelDef::createJoint(Joint *arg2) {
return nullptr;
}
-PhysDebugDraw::PhysDebugDraw() {
- stub("PhysDebugDraw::PhysDebugDraw");
-}
-
-int PhysDebugDraw::setScale(int arg2, int arg3) {
- stub("PhysDebugDraw::setScale");
- return 0;
-}
-
-int PhysDebugDraw::setScroll(int arg2, int arg3) {
- stub("PhysDebugDraw::setScroll");
- return 0;
-}
-
-void PhysDebugDraw::drawString(int arg2, int arg3, char *arg4, int arg5) {
- stub("PhysDebugDraw::drawString");
-}
-
-void PhysDebugDraw::drawPolygon(float *arg2, int arg3, int *arg4) {
- stub("PhysDebugDraw::drawPolygon");
-}
-
-void PhysDebugDraw::drawSolidPolygon(float *arg2, int arg3, int *arg4) {
- stub("PhysDebugDraw::drawSolidPolygon");
-}
-
-void PhysDebugDraw::drawCircle(float *arg2, float arg3, int *arg4) {
- stub("PhysDebugDraw::drawCircle");
-}
-
-void PhysDebugDraw::drawSolidCircle(float *arg2, float arg3, int arg4, int *arg5) {
- stub("PhysDebugDraw::drawSolidCircle");
-}
-
-void PhysDebugDraw::drawSegment(float *arg2, float *arg3, int *arg4) {
- stub("PhysDebugDraw::drawSegment");
-}
-
-void PhysDebugDraw::drawTransform(float *arg2) {
- stub("PhysDebugDraw::drawTransform");
-}
-
-void PhysDebugDraw::drawPoint(float *arg2, int arg3, int *arg4) {
- stub("PhysDebugDraw::drawPoint");
-}
-
-void PhysDebugDraw::drawAABB(float *arg2, int *arg3) {
- stub("PhysDebugDraw::drawAABB");
-}
-
-PhysController::PhysController() {
-}
-
} // End of namespace NGI
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index 093cbe54b11..ab53eec0cae 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -127,46 +127,6 @@ class PhysController;
class PhysRegistrator;
class QueryGeomsInRegion;
-/** Android CPhysListener: the Box2D world of a scene (XML PHYSICS), b2ContactListener */
-class PhysListener {
-public:
- Scene *_scene = nullptr; // +108
- b2World *_world = nullptr; // +112
- Vector2 _scale = Vector2(); // +192
- Common::Array<PhysicalObject *> _objects; // +200
-
- PhysListener();
- PhysListener(Scene *arg2);
- virtual ~PhysListener() {}
- int beginContact(int arg2); // 118910
- int endContact(int arg2); // 11896A
- int postSolve(uint32 *arg2, int arg3); // 1189C4
- int initWorld(); // 118BA4
- b2World *getWorld() const; // 118C28
- int onShow(); // 118C2C
- void clearWorld(); // 118C34
- void onHide(); // 118C6A
- void render(); // 118C72
- int findPhysicalObject(uint32 arg2); // 118C78
- int findPhysicalObject(float arg2, float arg3); // 118C98
- float onMouseLDown(uint32 arg2, void *arg3); // 118D38
- int onMouseLUp(void *arg2); // 118E42
- void onMouseMove(uint32 arg2, float arg3, float arg4); // 118E5C
- void fixtureDestroyed(int arg2); // 118EB0
- void setScale(int arg2, int arg3); // 118ED4
- void createGround(float arg2, float arg3, int arg4, float arg5); // 118F40
- PhysListener *getWorldRegion(int arg2); // 119098
- int init(void *arg2); // 119118
- int preSolve(uint32 *arg2, int arg3); // 119568
- void removeObject(PhysicalObject *object); // 1196FE
- void addObject(PhysicalObject *object); // 1197C0
- void checkOutworldObjects(); // 1197CE
- void doStep(); // 119854
- int update(uint32 arg2); // 1199C8
- void findGeomsInRegion(int arg2, int arg3, int arg4, float arg5, Geom ***arg6); // 119AD4
- void findObjectsInRegion(int arg2, int arg3, int arg4, int arg5, int *arg6); // 119B60
-};
-
/** Android ContactPoint: a point of a contact (kept by CPhysListener::PreSolve) */
struct ContactPoint {
b2Fixture *_fixtureA = nullptr; // +0
@@ -255,6 +215,124 @@ public:
Common::Array<Vector2> _points; // +132
};
+/** Android CPhysDebugDraw: b2Draw implementation, the outlines of the world (scaled, scrolled) */
+class PhysDebugDraw : public b2Draw {
+public:
+ PhysDebugDraw(); // 1181CC
+ void setScale(float x, float y); // 1181F8
+ void setScroll(float x, float y); // 118202
+ void drawString(int x, int y, const char *format, ...); // 11820C
+ void DrawPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) override; // 1182D0
+ void DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) override; // 1183E6
+ void DrawCircle(const b2Vec2 ¢er, float32 radius, const b2Color &color) override; // 1184F8
+ void DrawSolidCircle(const b2Vec2 ¢er, float32 radius, const b2Vec2 &axis, const b2Color &color) override; // 118576
+ void DrawSegment(const b2Vec2 &p1, const b2Vec2 &p2, const b2Color &color) override; // 1185F4
+ void DrawTransform(const b2Transform &xf) override; // 118684
+ void drawPoint(const b2Vec2 &point, float size, const b2Color &color); // 1187B8
+ void drawAABB(const b2AABB &aabb, const b2Color &color); // 11881C
+
+ float _scaleX = 0.0f; // +8
+ float _scaleY = 0.0f; // +12
+ float _scrollX = 0.0f; // +16
+ float _scrollY = 0.0f; // +20
+};
+
+/** Android IPhysController: base of the scene controllers, called by CPhysListener */
+class PhysController {
+public:
+ virtual ~PhysController() {}
+ virtual void jointDestroyed(b2Joint *joint) {}
+ virtual void geomDestroyed(Geom *geom) {}
+ virtual void beginContact(b2Contact *contact) {}
+ virtual void endContact(b2Contact *contact) {}
+ virtual void preSolve(b2Contact *contact, const b2Manifold *oldManifold) {}
+ virtual void postSolve(b2Contact *contact, const b2ContactImpulse *impulse) {}
+ virtual void onUpdatePhysics(uint32 elapsed) {}
+ virtual void onPostSolvePhysics(uint32 elapsed) {}
+ virtual void onInitPhysics() {}
+ virtual void outWorldObjects(Common::Array<PhysicalObject *> &objects) {}
+};
+
+/** Android CDestructionListener: tells the physics listener about fixtures and joints that go */
+class DestructionListener : public b2DestructionListener {
+public:
+ explicit DestructionListener(PhysListener *listener) : _listener(listener) {}
+ void SayGoodbye(b2Joint *joint) override; // 118E96
+ void SayGoodbye(b2Fixture *fixture) override; // 118EC8
+
+ PhysListener *_listener; // +4
+};
+
+/** Android CPhysListener: the Box2D world of a scene (XML PHYSICS), b2ContactListener */
+class PhysListener : public b2ContactListener {
+public:
+ explicit PhysListener(Scene *scene); // 119248
+ ~PhysListener() override; // 119358
+ void BeginContact(b2Contact *contact) override; // 118910
+ void EndContact(b2Contact *contact) override; // 11896A
+ void PreSolve(b2Contact *contact, const b2Manifold *oldManifold) override; // 119568
+ void PostSolve(b2Contact *contact, const b2ContactImpulse *impulse) override; // 1189C4
+
+ void init(const XmlNode &node); // 119118
+ void initWorld(); // 118BA4
+ b2World *getWorld() const; // 118C28
+ void onShow(); // 118C2C
+ void clearWorld(); // 118C34
+ void onHide(); // 118C6A
+ void render(); // 118C72
+ PhysicalObject *findPhysicalObject(uint32 id) const; // 118C78
+ PhysicalObject *findPhysicalObject(float x, float y); // 118C98
+ void onMouseLDown(uint32 id, const Vector2 &pos); // 118D38
+ void onMouseRDown(uint32 id, const Vector2 &pos) {} // 118E40
+ void onMouseLUp(const Vector2 &pos); // 118E42
+ void onMouseRUp(uint32 id, const Vector2 &pos) {} // 118E5A
+ void onMouseMove(uint32 id, float x, float y); // 118E5C
+ void jointDestroyed(b2Joint *joint) {} // 118E94
+ void fixtureDestroyed(b2Fixture *fixture); // 118EB0
+ void setScale(const Vector2 &scale); // 118ED4
+ Material getMaterial(const Common::String &name); // 118F0C
+ void createGround(float x0, float y0, float x1, float y1); // 118F40
+ Vector4 getWorldRegion() const; // 119098
+ void removeObject(PhysicalObject *object); // 1196FE
+ void addObject(PhysicalObject *object); // 1197C0
+ void checkOutworldObjects(); // 1197CE
+ void doStep(); // 119854
+ void update(uint32 elapsed); // 1199C8
+ Common::Array<Geom *> findGeomsInRegion(const Vector4 ®ion); // 119AD4
+ void findObjectsInRegion(const Vector4 ®ion, Common::Array<PhysicalObject *> &objects); // 119B60
+
+ Vector2 _gravity = Vector2(); // +20
+ float _fps = 60.0f; // +28
+ int _velocityIterations = 8; // +32
+ int _positionIterations = 3; // +36
+ int _drawShapes = 1; // +40
+ int _drawJoints = 1; // +44
+ int _drawAABBs = 0; // +48
+ int _drawPairs = 0; // +52
+ int _drawCentersOfMass = 0; // +72
+ int _warmStarting = 1; // +84
+ int _continuousPhysics = 1; // +88
+ int _subStepping = 0; // +92
+ bool _mouseEnabled = false; // +104
+ bool _paused = false; // +105
+ Vector4 _worldRegion = Vector4(); // +4
+ Scene *_scene; // +108
+ b2World *_world = nullptr; // +112
+ b2Body *_ground = nullptr; // +116
+ b2AABB _worldAABB = b2AABB(); // +120
+ DestructionListener _destructionListener; // +136
+ b2MouseJoint *_mouseJoint = nullptr; // +144
+ b2Vec2 _mouseTarget = b2Vec2(0.0f, 0.0f); // +148
+ PhysDebugDraw *_debugDraw = nullptr; // +156
+ Common::Array<ContactPoint> _contacts; // +160
+ uint _maxContacts = 2048; // +172
+ float _accumulator = 0.0f; // +184
+ bool _field188 = false; // +188
+ Vector2 _scale = Vector2(); // +192
+ Common::Array<PhysicalObject *> _objects; // +200
+ JointBuilder *_jointBuilder = nullptr; // +212
+};
+
/** Android CPhysMaterials (CSingleton): the material table (built in ones and XML MATERIALS) */
class PhysMaterials {
public:
@@ -478,31 +556,6 @@ public:
void *createJoint(Joint *arg2); // 10BFD4
};
-/** Android CPhysDebugDraw: b2Draw implementation (RenderDbg of the world) */
-class PhysDebugDraw {
-public:
- PhysDebugDraw();
- virtual ~PhysDebugDraw() {}
- int setScale(int arg2, int arg3); // 1181F8
- int setScroll(int arg2, int arg3); // 118202
- void drawString(int arg2, int arg3, char *arg4, int arg5); // 11820C
- void drawPolygon(float *arg2, int arg3, int *arg4); // 1182D0
- void drawSolidPolygon(float *arg2, int arg3, int *arg4); // 1183E6
- void drawCircle(float *arg2, float arg3, int *arg4); // 1184F8
- void drawSolidCircle(float *arg2, float arg3, int arg4, int *arg5); // 118576
- void drawSegment(float *arg2, float *arg3, int *arg4); // 1185F4
- void drawTransform(float *arg2); // 118684
- void drawPoint(float *arg2, int arg3, int *arg4); // 1187B8
- void drawAABB(float *arg2, int *arg3); // 11881C
-};
-
-/** Android IPhysController: base of the scene physics logic */
-class PhysController {
-public:
- PhysController();
- virtual ~PhysController() {}
-};
-
/** Android CPhysRegistrator (CSingleton): category bits by name (1, 0xFFFF, 2, 4 ..) */
class PhysRegistrator {
public:
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 0c310269b65..0b5a0f0fe84 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -366,6 +366,8 @@ Scene::~Scene() {
// _faObjlist is not used
+ // CPhysListener::~CPhysListener: its objects and their pictures go first
+ _physListener.reset();
_destroying = true;
for (uint i = 0; i < _messageQueues.size(); i++)
delete _messageQueues[i];
@@ -390,8 +392,6 @@ Scene::~Scene() {
_aniObjects.clear();
- for (PhysicalObject *object : _physicalObjects)
- delete object;
for (Selection *selection : _selections)
delete selection;
@@ -627,6 +627,21 @@ void Scene::addAni(AniObject *obj, bool addList2) {
}
}
+// CScene::AddGameObject (123398): the copy id is the number of visible objects with the id
+void Scene::addPhysicalObject(PhysicalObject *object) {
+ int amount = 0;
+ while (findVisibleObject(object->_id, amount))
+ amount++;
+ object->_copyId = amount;
+ _physListener->addObject(object);
+}
+
+PhysicalObject *Scene::findPhysicalObject(uint id, int copyId) const {
+ if (!_physListener)
+ return nullptr;
+ return _physListener->findPhysicalObject(id | (static_cast<uint>(copyId) << 16));
+}
+
void Scene::setPictureObjectsFlag4() {
for (uint i = 0; i < _pictureObjects.size(); i++) {
_pictureObjects[i]->_flags |= 4;
@@ -1353,6 +1368,8 @@ uint Scene::unloadAdditional() {
// CScene::OnShow (the parts that are ported): the controller, the behaviors
void Scene::onShow() {
_shown = true;
+ if (_physListener)
+ _physListener->onShow();
if (_behaviorController)
_behaviorController->attachAnimations(*this);
if (_controller)
@@ -1365,7 +1382,9 @@ void Scene::onShow() {
void Scene::onHide() {
if (_controller)
_controller->onHide();
- // CBehaviorController::OnHide (stops the behavior sounds) and CPhysListener::OnHide are not ported
+ // CBehaviorController::OnHide (stops the behavior sounds) is not ported
+ if (_physListener)
+ _physListener->onHide();
if (_guiManager)
_guiManager->onHide();
}
@@ -1380,12 +1399,19 @@ bool Scene::onMouseLKeyDown(uint32 id, float x, float y) {
_controller->onMouseLKeyDown(id, sceneX, sceneY);
}
}
+ // CDialogController::OnMouseLKeyDown is not ported
+ if (_physListener) {
+ Vector2 pos;
+ pos.x = sceneX;
+ pos.y = sceneY;
+ _physListener->onMouseLDown(id, pos);
+ }
return false;
}
// CScene::OnMouseLKeyUp (120980): controller (Top), GUI, controller; if none handles it the
// interaction at the point starts (FindInteraction(x, y), TryStartInteract).
-// CDialogController::OnMouseLKeyUp and CPhysListener::OnMouseLUp are not ported
+// CDialogController::OnMouseLKeyUp is not ported
bool Scene::onMouseLKeyUp(uint32 id, float x, float y) {
const float sceneX = x + _x;
const float sceneY = y + _y;
@@ -1403,6 +1429,13 @@ bool Scene::onMouseLKeyUp(uint32 id, float x, float y) {
}
}
}
+ // the original also needs a non-empty render list
+ if (_physListener && !_renderables.empty()) {
+ Vector2 pos;
+ pos.x = sceneX;
+ pos.y = sceneY;
+ _physListener->onMouseLUp(pos);
+ }
return false;
}
@@ -1439,6 +1472,8 @@ bool Scene::onMouseMove(uint32 id, float x, float y) {
}
if (_controller)
_controller->onMouseMove(id, sceneX, sceneY);
+ if (_physListener)
+ _physListener->onMouseMove(id, sceneX, sceneY);
return false;
}
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index ab3992f9fc0..c93e007402e 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -92,10 +92,8 @@ class Scene : public Background {
/** The widescreen flag of CRender::SetSrcRect (CRender +32): black bars over the margins */
bool hasWidescreenBars() const;
Common::ScopedPtr<GuiManager> _guiManager;
- /** XML PHYSICS (+56): the Box2D world, not implemented yet (physics.h) */
+ /** XML PHYSICS (+56): the Box2D world and the physical objects (physics.h) */
Common::ScopedPtr<PhysListener> _physListener;
- /** XML PHYSOBJ / PHYSGROUND, owned (stubs, physics.h) */
- Common::Array<PhysicalObject *> _physicalObjects;
/** XML SELECTION, owned (stubs, sceneobjects.h) */
Common::Array<Selection *> _selections;
/** XML MOTIONCONTROLLER (CScene+68, stub) */
@@ -246,6 +244,10 @@ class Scene : public Background {
void removeCopies();
/** takes ownership of the passed obj */
void addAni(AniObject *obj, bool addList2);
+ /** CScene::AddGameObject for a CPhysicalObject: the copy id, then the physics listener keeps it */
+ void addPhysicalObject(PhysicalObject *object);
+ /** CScene::FindPhysicalObject (11F896) */
+ PhysicalObject *findPhysicalObject(uint id, int copyId) const;
void setPictureObjectsFlag4();
PictureObject *findPictureObjectById(int objId, int flags);
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index d3c692d143b..8c81867aeb8 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -533,6 +533,10 @@ private:
/** inventory.xml: the INVENTORY node is kept as a tree for CInventory::Init */
Inventory *_inventory;
Common::Array<XmlNode *> _inventoryNodes;
+ /** PHYSICS, PHYSOBJ, PHYSGROUND: the subtree is kept as XmlNode for their Init */
+ Common::ScopedPtr<XmlNode> _physRoot;
+ Common::Array<XmlNode *> _physNodes;
+ int _physDepth = 0;
uint _objectOrder = 0;
bool _hasInitialStatics = false;
int16 _initialStaticsId = 0;
@@ -775,8 +779,6 @@ private:
KEY_END()
KEY_END()
XML_KEY(PHYSICS)
- XML_KEY(MATERIALS)
- KEY_END()
KEY_END()
XML_KEY(ADDANI)
XML_PROP(static, false)
@@ -1096,25 +1098,71 @@ private:
return true;
}
- // CPhysicalObject::Init / CPhysGround::Init: no Box2D world or geometries (physics.h)
+ // CScene::Init PHYSOBJ / PHYSGROUND of the scene itself: made by CScene::CreateObjects, which adds
+ // them to the physics listener; the original has none yet at this point and fails
bool parserCallback_PHYSOBJ(ParserNode *node) {
- return addPhysicalObject(new PhysicalObject(&_scene), node, "PHYSOBJ");
+ return startPhysics(node);
}
bool parserCallback_PHYSGROUND(ParserNode *node) {
- return addPhysicalObject(new PhysGround(&_scene), node, "PHYSGROUND");
+ return startPhysics(node);
}
- bool addPhysicalObject(PhysicalObject *object, ParserNode *node, const char *name) {
- Common::ScopedPtr<PhysicalObject> owned(object);
- if (!parseObject(*owned, *node))
+ // CScene::Init PHYSICS: the Box2D world of the scene and its objects, made when the node is closed
+ bool parserCallback_PHYSICS(ParserNode *node) {
+ if (!_scene._physListener)
+ _scene._physListener.reset(new PhysListener(&_scene));
+ return startPhysics(node);
+ }
+
+ bool startPhysics(ParserNode *node) {
+ if (node->name != "PHYSICS" && !_scene._physListener)
+ return parserError("<" + node->name + "> without <PHYSICS> before it");
+ _physRoot.reset(new XmlNode());
+ XmlNode *root = _physRoot->append(node->name);
+ copyAttributes(*root, *node);
+ _physNodes.clear();
+ _physNodes.push_back(root);
+ _physDepth = node->depth;
+ return true;
+ }
+
+ bool addPhysicsNode(ParserNode *node) {
+ if (!_physRoot || node->depth <= _physDepth || static_cast<uint>(node->depth - _physDepth) > _physNodes.size())
return false;
- _scene._physicalObjects.push_back(owned.release());
- warning("STUB: XML <%s>", name);
- node->ignore = true;
+ XmlNode *child = _physNodes[node->depth - _physDepth - 1]->append(node->name);
+ copyAttributes(*child, *node);
+ _physNodes.resize(node->depth - _physDepth);
+ _physNodes.push_back(child);
return true;
}
+ // IObjectBuilder::CreateBaseObjects for the physical objects, then CScene::AddGameObject
+ void createPhysicalObject(const XmlNode &node) {
+ PhysicalObject *object;
+ if (node.name() == "PHYSGROUND")
+ object = new PhysGround(&_scene);
+ else
+ object = new PhysicalObject(&_scene);
+ object->init(node);
+ _scene.addPhysicalObject(object);
+ }
+
+ void finishPhysics(const XmlNode &root) {
+ if (root.name() == "PHYSICS") {
+ // CPhysListener::Init: the materials and the settings, then CScene::CreateObjects
+ _scene._physListener->init(root);
+ for (uint i = 0; i < root.childCount(); i++) {
+ if (root[i].name() == "PHYSOBJ" || root[i].name() == "PHYSGROUND")
+ createPhysicalObject(root[i]);
+ else if (root[i].name() != "MATERIALS")
+ warning("STUB: XML <%s> inside <PHYSICS>", root[i].name().c_str());
+ }
+ } else {
+ createPhysicalObject(root);
+ }
+ }
+
bool parserCallback_ROAMING_PARAMS(ParserNode *node) {
warning("STUB: XML <ROAMING_PARAMS>");
node->ignore = true;
@@ -1146,14 +1194,6 @@ private:
return true;
}
- // CScene::Init PHYSICS: the Box2D world of the scene (physics.h, stub); its MATERIALS are skipped
- bool parserCallback_PHYSICS(ParserNode *node) {
- _scene._physListener.reset(new PhysListener(&_scene));
- warning("STUB: XML <PHYSICS>");
- node->ignore = true;
- return true;
- }
-
// ITEM of ZCONTROLLER (CZController::CZController); the ITEM of PRELOAD is skipped with its parent
bool parserCallback_ITEM(ParserNode *node) {
if (getParentNode(node)->name == "PRELOAD") {
@@ -1197,12 +1237,6 @@ private:
return true;
}
- bool parserCallback_MATERIALS(ParserNode *node) {
- warning("STUB: XML <MATERIALS>");
- node->ignore = true;
- return true;
- }
-
bool parserCallback_ADDANI(ParserNode *node) {
PicAniInfo ref;
if (!readId(node->values["id"], ref.objectId) || !readId(node->values["scene"], ref.sceneId))
@@ -1659,6 +1693,11 @@ private:
}
bool closedKeyCallback(ParserNode *node) override {
+ if (_physRoot && node->depth == _physDepth && (node->name == "PHYSICS" || node->name == "PHYSOBJ" || node->name == "PHYSGROUND")) {
+ finishPhysics(_physRoot->first());
+ _physRoot.reset();
+ _physNodes.clear();
+ }
if (node->name == "MCTL_GRAPH") {
// Links can precede their nodes. Only GRAPH_NODE defines the coordinates.
uint i = 0;
@@ -1696,6 +1735,10 @@ private:
const ParserNode *parent = getParentNode(node);
if (!parent)
return false;
+ if (addPhysicsNode(node)) {
+ node->layout = _XMLkeys;
+ return true;
+ }
addInventoryNode(node);
if (parent->name == "PICTURE" && node->name == "HITREGION" && node->values.getValOrDefault("type") == "rect") {
int16 id;
Commit: 705a7c22f0e70804de15363643cea9c670c92535
https://github.com/scummvm/scummvm/commit/705a7c22f0e70804de15363643cea9c670c92535
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Physics joints (IJoint, the joint definitions, CJointBuilder)
Changed paths:
A engines/ngi/physjoint.cpp
engines/ngi/module.mk
engines/ngi/physics.cpp
engines/ngi/physics.h
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 657b77fcd43..572e77f7ff5 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -26,6 +26,7 @@ MODULE_OBJS = \
physdraw.o \
physgeom.o \
physics.o \
+ physjoint.o \
preloadmanager.o \
region.o \
scene.o \
diff --git a/engines/ngi/physics.cpp b/engines/ngi/physics.cpp
index 3f698f11bd7..881cbe89145 100644
--- a/engines/ngi/physics.cpp
+++ b/engines/ngi/physics.cpp
@@ -20,7 +20,6 @@
*/
#include "common/debug.h"
-#include "common/hashmap.h"
#include "ngi/ngi.h"
#include "ngi/objects.h"
@@ -31,14 +30,6 @@
namespace NGI {
-static void stub(const char *name) {
- static Common::HashMap<Common::String, bool> reported;
- if (reported.contains(name))
- return;
- reported[name] = true;
- warning("STUB/untested: %s", name);
-}
-
// CBoundBox (117140 ... 117354)
void BoundBox::setWorldRect(const Vector4 &rect) {
_worldRect = rect;
@@ -1002,112 +993,4 @@ void PhysListener::findObjectsInRegion(const Vector4 ®ion, Common::Array<Phys
}
}
-JointBuilder::JointBuilder() {
- stub("JointBuilder::JointBuilder");
-}
-
-JointBuilder::JointBuilder(PhysListener *arg2) {
- stub("JointBuilder::JointBuilder");
-}
-
-void *JointBuilder::buildJoint(void *arg2) {
- stub("JointBuilder::buildJoint");
- return nullptr;
-}
-
-Joint::Joint() {
- stub("Joint::Joint");
-}
-
-Joint::Joint(int arg2) {
- stub("Joint::Joint");
-}
-
-int Joint::getWorld() {
- stub("Joint::getWorld");
- return 0;
-}
-
-void Joint::init() {
- stub("Joint::init");
-}
-
-int Joint::createJoint() {
- stub("Joint::createJoint");
- return 0;
-}
-
-int Joint::destroyJoint() {
- stub("Joint::destroyJoint");
- return 0;
-}
-
-void Joint::removeThis() {
- stub("Joint::removeThis");
-}
-
-int Joint::setBodies(int arg2, int arg3) {
- stub("Joint::setBodies");
- return 0;
-}
-
-int Joint::getBody1Id() {
- stub("Joint::getBody1Id");
- return 0;
-}
-
-int Joint::getBody2Id() {
- stub("Joint::getBody2Id");
- return 0;
-}
-
-JointDef::JointDef() {
- stub("JointDef::JointDef");
-}
-
-JointDistanceDef::JointDistanceDef() {
- stub("JointDistanceDef::JointDistanceDef");
-}
-
-void *JointDistanceDef::createJoint(Joint *arg2) {
- stub("JointDistanceDef::createJoint");
- return nullptr;
-}
-
-JointRevoluteDef::JointRevoluteDef() {
- stub("JointRevoluteDef::JointRevoluteDef");
-}
-
-void *JointRevoluteDef::createJoint(Joint *arg2) {
- stub("JointRevoluteDef::createJoint");
- return nullptr;
-}
-
-JointRopeDef::JointRopeDef() {
- stub("JointRopeDef::JointRopeDef");
-}
-
-void *JointRopeDef::createJoint(Joint *arg2) {
- stub("JointRopeDef::createJoint");
- return nullptr;
-}
-
-JointWeldDef::JointWeldDef() {
- stub("JointWeldDef::JointWeldDef");
-}
-
-void *JointWeldDef::createJoint(Joint *arg2) {
- stub("JointWeldDef::createJoint");
- return nullptr;
-}
-
-JointWheelDef::JointWheelDef() {
- stub("JointWheelDef::JointWheelDef");
-}
-
-void *JointWheelDef::createJoint(Joint *arg2) {
- stub("JointWheelDef::createJoint");
- return nullptr;
-}
-
} // End of namespace NGI
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index ab53eec0cae..7dee57df842 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -387,15 +387,6 @@ private:
void removeVisObj();
};
-/** Android CJointBuilder: builds the joints of a PHYSOBJ */
-class JointBuilder {
-public:
- JointBuilder();
- JointBuilder(PhysListener *arg2);
- virtual ~JointBuilder() {}
- void *buildJoint(void *arg2); // 116284
-};
-
/** Android IGeom: a shape of a physical object (a fixture of its body) */
class Geom {
public:
@@ -493,67 +484,107 @@ public:
int _vertexCount = 3; // +140
};
-/** Android IJoint */
-class Joint {
-public:
- Joint();
- Joint(int arg2);
- virtual ~Joint() {}
- int getWorld(); // 115D68
- void init(); // 115D74
- int createJoint(); // 115E68
- int destroyJoint(); // 115E90
- void removeThis(); // 115ECC
- int setBodies(int arg2, int arg3); // 115EE6
- int getBody1Id(); // 115EEC
- int getBody2Id(); // 115EF0
-};
-
-/** Android IJointDef */
+/** Android IJoint::JOINT_TYPE (the ids that CJointBuilder and IJoint::Init use) */
+enum JointType {
+ kJointNone = 0,
+ kJointDistance = 1,
+ kJointWheel = 2,
+ kJointRevolute = 3,
+ kJointPrismatic = 4,
+ kJointRope = 5,
+ kJointWeld = 6
+};
+
+/** The parameters of a joint: the first 80 bytes of Android IJoint (pixels) */
+struct JointParams {
+ bool _collideConnected = false; // +0
+ float _frequency = 0.0f; // +4
+ float _damping = 0.0f; // +8
+ b2Body *_bodyA = nullptr; // +12
+ b2Body *_bodyB = nullptr; // +16
+ Vector2 _anchorA = Vector2(); // +20
+ Vector2 _anchorB = Vector2(); // +28
+ int _type = kJointNone; // +36
+ float _length = 0.0f; // +40
+ Vector2 _axis = Vector2(); // +44
+ bool _enableMotor = false; // +52
+ float _maxMotorTorque = 0.0f; // +56
+ float _motorSpeed = 0.0f; // +60
+ bool _enableLimit = false; // +64
+ float _referenceAngle = 0.0f; // +68
+ float _lowerAngle = 0.0f; // +72
+ float _upperAngle = 0.0f; // +76
+};
+
+/** Android IJointDef: makes the Box2D joint of one type from the parameters of a Joint */
class JointDef {
public:
- JointDef();
virtual ~JointDef() {}
+ virtual b2Joint *createJoint(Joint *joint) = 0;
};
/** Android CJointDistanceDef */
class JointDistanceDef : public JointDef {
public:
- JointDistanceDef();
- ~JointDistanceDef() override {}
- void *createJoint(Joint *arg2); // 10C05C
+ b2Joint *createJoint(Joint *joint) override; // 10C05C
};
/** Android CJointRevoluteDef */
class JointRevoluteDef : public JointDef {
public:
- JointRevoluteDef();
- ~JointRevoluteDef() override {}
- void *createJoint(Joint *arg2); // 10BF48
+ b2Joint *createJoint(Joint *joint) override; // 10BF48
};
/** Android CJointRopeDef */
class JointRopeDef : public JointDef {
public:
- JointRopeDef();
- ~JointRopeDef() override {}
- void *createJoint(Joint *arg2); // 10C160
+ b2Joint *createJoint(Joint *joint) override; // 10C160
};
/** Android CJointWeldDef */
class JointWeldDef : public JointDef {
public:
- JointWeldDef();
- ~JointWeldDef() override {}
- void *createJoint(Joint *arg2); // 10C0E8
+ b2Joint *createJoint(Joint *joint) override; // 10C0E8
};
/** Android CJointWheelDef */
class JointWheelDef : public JointDef {
public:
- JointWheelDef();
- ~JointWheelDef() override {}
- void *createJoint(Joint *arg2); // 10BFD4
+ b2Joint *createJoint(Joint *joint) override; // 10BFD4
+};
+
+/** Android IJoint: a joint of the world of a physics listener */
+class Joint {
+public:
+ explicit Joint(PhysListener *listener); // 115D1C
+ virtual ~Joint(); // 115D54
+ b2World *getWorld() const; // 115D68
+ void init(const JointParams ¶ms); // 115D74
+ void createJoint(); // 115E68
+ void createJoint(const JointParams ¶ms); // 115E7E
+ void destroyJoint(); // 115E90
+ void removeThis(); // 115ECC
+ void setBodies(b2Body *bodyA, b2Body *bodyB); // 115EE6
+ int getBody1Id() const; // 115EEC
+ int getBody2Id() const; // 115EF0
+
+ JointParams _params; // +0
+ int _body1Id = 0; // +80
+ int _body2Id = 0; // +84
+ JointDef *_def = nullptr; // +88
+ PhysListener *_listener; // +92
+ b2Joint *_joint = nullptr; // +96
+};
+
+/** Android CJointBuilder: builds the joints of an XML node (JOINT, with BODY1 and BODY2) */
+class JointBuilder {
+public:
+ explicit JointBuilder(PhysListener *listener); // 116188
+ virtual ~JointBuilder() {}
+ Joint *buildJoint(const XmlNode &node); // 116284
+
+ PhysListener *_listener; // +0
+ Common::HashMap<Common::String, int> _types; // +4
};
/** Android CPhysRegistrator (CSingleton): category bits by name (1, 0xFFFF, 2, 4 ..) */
diff --git a/engines/ngi/physjoint.cpp b/engines/ngi/physjoint.cpp
new file mode 100644
index 00000000000..d52cc1194cb
--- /dev/null
+++ b/engines/ngi/physjoint.cpp
@@ -0,0 +1,233 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// The joints of the Android physics (IJoint, the joint definitions of the types and CJointBuilder)
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/physics.h"
+#include "ngi/xmlnode.h"
+
+namespace NGI {
+
+static const float kScale = 30.0f;
+
+static b2Vec2 scaled(const Vector2 &point) {
+ return b2Vec2(point.x / kScale, point.y / kScale);
+}
+
+// the joint definitions of the types
+
+b2Joint *JointDistanceDef::createJoint(Joint *joint) {
+ const JointParams ¶ms = joint->_params;
+ b2DistanceJointDef def;
+ def.bodyA = params._bodyA;
+ def.bodyB = params._bodyB;
+ def.collideConnected = params._collideConnected;
+ def.localAnchorA = scaled(params._anchorA);
+ def.localAnchorB = scaled(params._anchorB);
+ def.length = params._length / kScale;
+ def.frequencyHz = params._frequency;
+ def.dampingRatio = params._damping;
+ return joint->getWorld()->CreateJoint(&def);
+}
+
+b2Joint *JointRevoluteDef::createJoint(Joint *joint) {
+ const JointParams ¶ms = joint->_params;
+ b2RevoluteJointDef def;
+ def.bodyA = params._bodyA;
+ def.bodyB = params._bodyB;
+ def.collideConnected = params._collideConnected;
+ def.localAnchorA = scaled(params._anchorA);
+ def.localAnchorB = scaled(params._anchorB);
+ def.referenceAngle = params._referenceAngle;
+ def.enableLimit = params._enableLimit;
+ def.lowerAngle = params._lowerAngle;
+ def.upperAngle = params._upperAngle;
+ def.enableMotor = params._enableMotor;
+ def.motorSpeed = params._motorSpeed;
+ def.maxMotorTorque = params._maxMotorTorque;
+ return joint->getWorld()->CreateJoint(&def);
+}
+
+b2Joint *JointRopeDef::createJoint(Joint *joint) {
+ const JointParams ¶ms = joint->_params;
+ b2RopeJointDef def;
+ def.bodyA = params._bodyA;
+ def.bodyB = params._bodyB;
+ def.collideConnected = false;
+ def.localAnchorA = scaled(params._anchorA);
+ def.localAnchorB = scaled(params._anchorB);
+ def.maxLength = params._length / kScale;
+ return joint->getWorld()->CreateJoint(&def);
+}
+
+b2Joint *JointWeldDef::createJoint(Joint *joint) {
+ const JointParams ¶ms = joint->_params;
+ b2WeldJointDef def;
+ def.bodyA = params._bodyA;
+ def.bodyB = params._bodyB;
+ def.collideConnected = params._collideConnected;
+ def.localAnchorA = scaled(params._anchorA);
+ def.localAnchorB = scaled(params._anchorB);
+ def.referenceAngle = 0.0f;
+ def.frequencyHz = params._frequency;
+ def.dampingRatio = params._damping;
+ return joint->getWorld()->CreateJoint(&def);
+}
+
+b2Joint *JointWheelDef::createJoint(Joint *joint) {
+ const JointParams ¶ms = joint->_params;
+ b2WheelJointDef def;
+ def.bodyA = params._bodyA;
+ def.bodyB = params._bodyB;
+ def.collideConnected = params._collideConnected;
+ def.localAnchorA = scaled(params._anchorA);
+ def.localAnchorB = scaled(params._anchorB);
+ def.localAxisA.Set(params._axis.x, params._axis.y);
+ def.enableMotor = params._enableMotor;
+ def.maxMotorTorque = params._maxMotorTorque;
+ def.motorSpeed = params._motorSpeed;
+ def.frequencyHz = params._frequency;
+ def.dampingRatio = params._damping;
+ return joint->getWorld()->CreateJoint(&def);
+}
+
+// IJoint
+
+Joint::Joint(PhysListener *listener) : _listener(listener) {
+}
+
+Joint::~Joint() {
+ delete _def;
+}
+
+b2World *Joint::getWorld() const {
+ return _listener->getWorld();
+}
+
+// the parameters are taken when the type is set, then the definition of the type is made
+void Joint::init(const JointParams ¶ms) {
+ if (params._type == kJointNone)
+ return;
+
+ _params = params;
+ delete _def;
+ _def = nullptr;
+ switch (_params._type) {
+ case kJointDistance:
+ _def = new JointDistanceDef();
+ break;
+ case kJointWheel:
+ _def = new JointWheelDef();
+ break;
+ case kJointRevolute:
+ _def = new JointRevoluteDef();
+ break;
+ case kJointRope:
+ _def = new JointRopeDef();
+ break;
+ case kJointWeld:
+ _def = new JointWeldDef();
+ break;
+ default:
+ break;
+ }
+}
+
+void Joint::createJoint() {
+ if (_def)
+ _joint = _def->createJoint(this);
+}
+
+void Joint::createJoint(const JointParams ¶ms) {
+ init(params);
+ createJoint();
+}
+
+void Joint::destroyJoint() {
+ if (!_joint)
+ return;
+
+ for (b2Joint *joint = getWorld()->GetJointList(); joint; joint = joint->GetNext()) {
+ if (joint == _joint) {
+ getWorld()->DestroyJoint(_joint);
+ _joint = nullptr;
+ return;
+ }
+ }
+}
+
+void Joint::removeThis() {
+ destroyJoint();
+ delete this;
+}
+
+void Joint::setBodies(b2Body *bodyA, b2Body *bodyB) {
+ _params._bodyA = bodyA;
+ _params._bodyB = bodyB;
+}
+
+int Joint::getBody1Id() const {
+ return _body1Id;
+}
+
+int Joint::getBody2Id() const {
+ return _body2Id;
+}
+
+// CJointBuilder
+
+JointBuilder::JointBuilder(PhysListener *listener) : _listener(listener) {
+ _types["distance"] = kJointDistance;
+ _types["wheel"] = kJointWheel;
+ _types["revolute"] = kJointRevolute;
+ _types["prismatic"] = kJointPrismatic;
+}
+
+Joint *JointBuilder::buildJoint(const XmlNode &node) {
+ const Common::String type = node.attrStr("type", "");
+ if (!_types.contains(type))
+ return nullptr;
+
+ Joint *joint = new Joint(_listener);
+ JointParams params;
+ params._type = _types[type];
+ params._frequency = node.attrFloat("freq", 0.0f);
+ params._damping = node.attrFloat("damp", 0.0f);
+ params._length = node.attrFloat("length", 0.0f);
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (node[i].name() == "BODY1") {
+ joint->_body1Id = node[i].attrInt("id", 0);
+ params._anchorA.x = node[i].attrFloat("x", 0.0f);
+ params._anchorA.y = node[i].attrFloat("y", 0.0f);
+ } else if (node[i].name() == "BODY2") {
+ joint->_body2Id = node[i].attrInt("id", 0);
+ params._anchorB.x = node[i].attrFloat("x", 0.0f);
+ params._anchorB.y = node[i].attrFloat("y", 0.0f);
+ }
+ }
+ joint->init(params);
+ return joint;
+}
+
+} // End of namespace NGI
Commit: 000a3976ea6dc4b56fa3fe48e0aa043abe7024b5
https://github.com/scummvm/scummvm/commit/000a3976ea6dc4b56fa3fe48e0aa043abe7024b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Physics XML loading and the physics test
Changed paths:
A engines/ngi/debugger/physicstest.cpp
engines/ngi/debugger/testmode.cpp
engines/ngi/debugger/testmode.h
engines/ngi/module.mk
engines/ngi/physics.cpp
engines/ngi/physics.h
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/debugger/physicstest.cpp b/engines/ngi/debugger/physicstest.cpp
new file mode 100644
index 00000000000..41fbef1dff8
--- /dev/null
+++ b/engines/ngi/debugger/physicstest.cpp
@@ -0,0 +1,406 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+// The Android physics test (docs/android-physics.md): no game data has PHYSICS, so the world
+// is made from XmlNode trees or an XML scene file (--start-movie=physics=prog or physics=xml:PATH).
+
+#include "common/debug.h"
+
+#include "ngi/ngi.h"
+#include "ngi/objects.h"
+#include "ngi/physics.h"
+#include "ngi/scene.h"
+#include "ngi/xmlnode.h"
+#include "ngi/debugger/testmode.h"
+
+namespace NGI {
+
+namespace {
+
+int g_failures = 0;
+
+void check(bool ok, const Common::String &what) {
+ if (!ok)
+ g_failures++;
+ warning("PHYSTEST %s: %s", ok ? "PASS" : "FAIL", what.c_str());
+}
+
+Common::String objectName(int id) {
+ return g_ngi->_gameProject->_objectIds.findName(static_cast<uint16>(id));
+}
+
+XmlNode *add(XmlNode *parent, const char *name) {
+ return parent->append(name);
+}
+
+void attr(XmlNode *node, const char *name, const Common::String &value) {
+ node->appendAttr(name, value);
+}
+
+void attr(XmlNode *node, const char *name, int value) {
+ node->appendAttr(name, Common::String::format("%d", value));
+}
+
+// one frame of the scene: CScene::Update gives the physics the milliseconds of the frame
+void run(Scene &scene, int frames) {
+ for (int i = 0; i < frames; i++)
+ scene._physListener->update(42);
+}
+
+// the scene has pictures with these ids, so the objects get a copy id: find them by id only
+PhysicalObject *find(Scene &scene, const Common::String &name) {
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId(name, id);
+ for (PhysicalObject *object : scene._physListener->_objects) {
+ if (object->_id == static_cast<int16>(id))
+ return object;
+ }
+ return nullptr;
+}
+
+// the ball falls on the ground, a box and a triangle too: where they rest, and that they sleep
+void checkResting(Scene &scene, PhysicalObject *ball, PhysicalObject *box, PhysicalObject *triangle, PhysicalObject *polygon) {
+ Vector2 ballPos = ball->getPos();
+ Vector2 boxPos = box->getPos();
+ Vector2 trianglePos = triangle->getPos();
+ Vector2 polygonPos = polygon->getPos();
+ warning("PHYSTEST positions ball %.1f,%.1f box %.1f,%.1f triangle %.1f,%.1f polygon %.1f,%.1f", ballPos.x, ballPos.y, boxPos.x, boxPos.y,
+ trianglePos.x, trianglePos.y, polygonPos.x, polygonPos.y);
+ // ground y 600 (20 m), radius 30 px, half height of the box 20 px, of the polygon 25 px
+ check(ballPos.y > 568.0f && ballPos.y < 572.0f, Common::String::format("ball rests at y %.1f (570 expected)", ballPos.y));
+ check(boxPos.y > 577.5f && boxPos.y < 581.5f, Common::String::format("box rests at y %.1f (579.5 expected)", boxPos.y));
+ check(polygonPos.y > 572.0f && polygonPos.y < 576.0f, Common::String::format("polygon rests at y %.1f (574.5 expected)", polygonPos.y));
+ check(ballPos.x > 399.0f && ballPos.x < 401.0f, Common::String::format("ball fell straight, x %.1f", ballPos.x));
+ check(!ball->_body->IsAwake() && !box->_body->IsAwake(), "ball and box sleep");
+ check(triangle->_body != nullptr, "triangle has a body");
+}
+
+void checkQueries(Scene &scene, PhysicalObject *ball) {
+ PhysListener &listener = *scene._physListener;
+ Vector4 region;
+ region.x = 0.0f;
+ region.y = 0.0f;
+ region.z = 1200.0f;
+ region.w = 700.0f;
+ const Common::Array<Geom *> geoms = listener.findGeomsInRegion(region);
+ check(geoms.size() == 5, Common::String::format("region query finds %u dynamic geometries (5 expected)", geoms.size()));
+ Common::Array<PhysicalObject *> objects;
+ listener.findObjectsInRegion(region, objects);
+ check(objects.size() == 5, Common::String::format("region query finds %u objects (5 expected)", objects.size()));
+ Vector2 pos = ball->getPos();
+ check(listener.findPhysicalObject(pos.x, pos.y) == ball, "the point at the ball finds the ball");
+ check(listener.findPhysicalObject(2000.0f, 100.0f) == nullptr, "an empty point finds nothing");
+ check(listener.findPhysicalObject(static_cast<uint32>(static_cast<uint16>(ball->_id)) | (static_cast<uint32>(ball->_copyId) << 16)) == ball,
+ "found by id and copy id");
+ check(scene.findPhysicalObject(static_cast<uint16>(ball->_id), ball->_copyId) == ball, "CScene::FindPhysicalObject");
+}
+
+// a mouse joint drags the ball to the right
+void checkMouse(Scene &scene, PhysicalObject *ball) {
+ PhysListener &listener = *scene._physListener;
+ listener._mouseEnabled = true;
+ listener.createGround(-1000.0f, 700.0f, 3000.0f, 700.0f);
+ Vector2 start = ball->getPos();
+ listener.onMouseLDown(0, start);
+ check(listener._mouseJoint != nullptr, "mouse down on the ball makes the mouse joint");
+ listener.onMouseMove(0, start.x + 250.0f, start.y);
+ run(scene, 120);
+ Vector2 end = ball->getPos();
+ warning("PHYSTEST mouse: ball from %.1f,%.1f to %.1f,%.1f", start.x, start.y, end.x, end.y);
+ check(end.x > start.x + 100.0f, "the ball follows the mouse joint");
+ listener.onMouseLUp(start);
+ check(listener._mouseJoint == nullptr, "mouse up destroys the joint");
+}
+
+// a distance joint from the static anchor holds the other ball at the same distance
+void checkJoint(Scene &scene, PhysicalObject *anchor, PhysicalObject *swing) {
+ PhysListener &listener = *scene._physListener;
+ XmlNode doc;
+ XmlNode *joint = add(&doc, "JOINT");
+ attr(joint, "type", "distance");
+ attr(joint, "freq", "0");
+ attr(joint, "damp", "0");
+ attr(joint, "length", "100");
+ XmlNode *body1 = add(joint, "BODY1");
+ attr(body1, "id", anchor->_id);
+ attr(body1, "x", "0");
+ attr(body1, "y", "0");
+ XmlNode *body2 = add(joint, "BODY2");
+ attr(body2, "id", swing->_id);
+ attr(body2, "x", "0");
+ attr(body2, "y", "0");
+
+ Joint *built = listener._jointBuilder->buildJoint(doc.first());
+ check(built != nullptr, "the joint builder makes a distance joint");
+ if (!built)
+ return;
+ check(built->getBody1Id() == anchor->_id && built->getBody2Id() == swing->_id, "body ids of the joint");
+ // the swinging ball has fallen to the ground by now: back to its place, 100 px from the anchor
+ swing->setPos(1200.0f, 200.0f);
+ built->setBodies(anchor->_body, swing->_body);
+ built->createJoint();
+ check(built->_joint != nullptr, "the Box2D joint exists");
+ swing->setVel(0.0f, 0.0f);
+ swing->_body->SetAwake(true);
+ float minimum = 1000.0f;
+ float maximum = 0.0f;
+ for (int i = 0; i < 300; i++) {
+ run(scene, 1);
+ Vector2 a = anchor->getPos();
+ Vector2 b = swing->getPos();
+ const float distance = sqrtf((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
+ minimum = MIN(minimum, distance);
+ maximum = MAX(maximum, distance);
+ }
+ warning("PHYSTEST joint distance %.2f .. %.2f", minimum, maximum);
+ check(minimum > 98.0f && maximum < 102.0f, "the joined balls stay 100 px apart");
+ built->removeThis();
+}
+
+// the objects of a PHYSICS node: a ground, a ball, a box, a triangle, an anchor and a swinging ball
+void buildPhysics(XmlNode *physics, bool visible, const Common::String &visibleId) {
+ XmlNode *materials = add(physics, "MATERIALS");
+ XmlNode *material = add(materials, "MATERIAL");
+ attr(material, "name", "BALL");
+ attr(material, "description", "a rubber ball");
+ attr(material, "density", "1.0");
+ attr(material, "friction", "0.3");
+ attr(material, "restitution", "0.1");
+ attr(material, "ignitability", "0");
+
+ XmlNode *ground = add(physics, "PHYSGROUND");
+ attr(ground, "id", "PIC_SC1_UTRUBA");
+ attr(ground, "x", "0");
+ attr(ground, "y", "0");
+ XmlNode *point = add(ground, "POINT");
+ attr(point, "x", "-200");
+ attr(point, "y", "600");
+ point = add(ground, "POINT");
+ attr(point, "x", "600");
+ attr(point, "y", "600");
+ point = add(ground, "POINT");
+ attr(point, "x", "1400");
+ attr(point, "y", "600");
+
+ XmlNode *ball = add(physics, "PHYSOBJ");
+ attr(ball, "id", "PIC_SC1_UTRUBA2");
+ attr(ball, "x", "400");
+ attr(ball, "y", "100");
+ attr(ball, "physflags", "5");
+ attr(ball, "material", "BALL");
+ XmlNode *circle = add(ball, "GEOMCIRCLE");
+ attr(circle, "x", "0");
+ attr(circle, "y", "0");
+ attr(circle, "radius", "30");
+ if (visible) {
+ XmlNode *vis = add(circle, "VISOBJ");
+ attr(vis, "id", visibleId);
+ attr(vis, "dx", "0");
+ attr(vis, "dy", "0");
+ }
+
+ XmlNode *box = add(physics, "PHYSOBJ");
+ attr(box, "id", "PIC_SC1_PRIMUS");
+ attr(box, "x", "700");
+ attr(box, "y", "200");
+ attr(box, "physflags", "5");
+ attr(box, "material", "WOOD");
+ XmlNode *boxGeom = add(box, "GEOMBOX");
+ attr(boxGeom, "left", "-20");
+ attr(boxGeom, "right", "20");
+ attr(boxGeom, "top", "-20");
+ attr(boxGeom, "bottom", "20");
+
+ XmlNode *triangle = add(physics, "PHYSOBJ");
+ attr(triangle, "id", "PIC_SC1_KUCHKA");
+ attr(triangle, "x", "900");
+ attr(triangle, "y", "300");
+ attr(triangle, "physflags", "5");
+ XmlNode *triangleGeom = add(triangle, "GEOMTRIANGLE");
+ attr(triangleGeom, "left", "-25");
+ attr(triangleGeom, "right", "25");
+ attr(triangleGeom, "top", "-25");
+ attr(triangleGeom, "bottom", "25");
+
+ XmlNode *anchor = add(physics, "PHYSOBJ");
+ attr(anchor, "id", "PIC_SC1_OSK");
+ attr(anchor, "x", "1100");
+ attr(anchor, "y", "200");
+ attr(anchor, "physflags", "2");
+ XmlNode *anchorGeom = add(anchor, "GEOMCIRCLE");
+ attr(anchorGeom, "radius", "10");
+
+ XmlNode *swing = add(physics, "PHYSOBJ");
+ attr(swing, "id", "PIC_SC1_OSK2");
+ attr(swing, "x", "1200");
+ attr(swing, "y", "200");
+ attr(swing, "physflags", "5");
+ XmlNode *swingGeom = add(swing, "GEOMCIRCLE");
+ attr(swingGeom, "radius", "10");
+}
+
+// the polygon has no XML tag in the original, it is made from the parameters
+PhysicalObject *addPolygon(Scene &scene) {
+ PhysicalObject *polygon = new PhysicalObject(&scene);
+ PhysObjParams params;
+ uint32 id = 0;
+ g_ngi->_gameProject->_objectIds.findId("PIC_SC1_LADDER", id);
+ params._id = id;
+ params._x = 300.0f;
+ params._y = 100.0f;
+ params._physFlags = 5;
+ polygon->init(params);
+ polygon->_title = "polygon";
+ GeomPolygon *geom = new GeomPolygon(polygon);
+ GeomParams geomParams;
+ Vector2 hexagon[6] = { { 25.0f, 0.0f }, { 12.0f, 25.0f }, { -12.0f, 25.0f }, { -25.0f, 0.0f }, { -12.0f, -25.0f }, { 12.0f, -25.0f } };
+ for (int i = 0; i < 6; i++)
+ geomParams._points.push_back(hexagon[i]);
+ geom->init(geomParams);
+ polygon->addGeom(geom);
+ scene.addPhysicalObject(polygon);
+ return polygon;
+}
+
+void runProgrammatic() {
+ Scene &scene = *g_ngi->_currentScene;
+ check(scene._physListener == nullptr, Common::String::format("scene %d has no physics of its own", scene._sceneId));
+ const uint pictures = scene._pictureObjects.size();
+ const Common::String visibleId = scene._pictureObjects.empty() ? Common::String() : objectName(scene._pictureObjects[0]->_id);
+
+ scene._physListener.reset(new PhysListener(&scene));
+ XmlNode doc;
+ XmlNode *physics = add(&doc, "PHYSICS");
+ buildPhysics(physics, !visibleId.empty(), visibleId);
+ PhysListener &listener = *scene._physListener;
+ listener.init(*physics);
+ listener.createObjects(*physics);
+ check(listener.getMaterial("BALL")._density == 1.0f && listener.getMaterial("BALL")._friction == 0.3f, "the XML material BALL is known");
+ check(listener.getMaterial("WOOD")._friction == 0.7f, "the built in material WOOD is known");
+ PhysicalObject *polygon = addPolygon(scene);
+ check(listener._objects.size() == 7, Common::String::format("PHYSICS made %u objects (7 with the polygon)", listener._objects.size()));
+ check(listener.getWorld() == nullptr, "no world before OnShow");
+
+ scene.onShow();
+ check(listener.getWorld() != nullptr, "OnShow makes the world");
+
+ PhysicalObject *ball = find(scene, "PIC_SC1_UTRUBA2");
+ PhysicalObject *box = find(scene, "PIC_SC1_PRIMUS");
+ PhysicalObject *triangle = find(scene, "PIC_SC1_KUCHKA");
+ PhysicalObject *anchor = find(scene, "PIC_SC1_OSK");
+ PhysicalObject *swing = find(scene, "PIC_SC1_OSK2");
+ check(ball && box && triangle && anchor && swing, "the objects are found by id");
+ if (!(ball && box && triangle && anchor && swing)) {
+ scene._physListener.reset();
+ return;
+ }
+ check(ball->_body && ball->_body->GetType() == b2_dynamicBody, "ball is a dynamic body");
+ check(anchor->_body && anchor->_body->GetType() == b2_staticBody, "anchor is a static body");
+ check(ball->_geoms.size() == 1 && ball->_geoms[0]->_fixture != nullptr, "ball has a circle fixture");
+
+ run(scene, 600);
+ checkResting(scene, ball, box, triangle, polygon);
+ checkQueries(scene, ball);
+
+ if (!visibleId.empty()) {
+ check(scene._pictureObjects.size() == pictures + 1, "VISOBJ made a copy of the picture in the scene");
+ GameObject *copy = ball->_geoms[0]->getVisObj() ? ball->_geoms[0]->getVisObj()->_visObj : nullptr;
+ if (copy) {
+ Common::Point center = copy->getCenter();
+ Vector2 pos = ball->getPos();
+ warning("PHYSTEST visible copy at %d,%d, ball at %.1f,%.1f", center.x, center.y, pos.x, pos.y);
+ check(abs(center.x - static_cast<int>(pos.x)) <= 2 && abs(center.y - static_cast<int>(pos.y)) <= 2, "the copy follows the ball");
+ }
+ }
+
+ // the rest of the checks changes the bodies
+ ball->setVel(0.0f, 0.0f);
+ checkMouse(scene, ball);
+ checkJoint(scene, anchor, swing);
+
+ // the other calls of the object
+ box->setGravityMode(false);
+ box->setVel(0.0f, 0.0f);
+ run(scene, 30);
+ const float lifted = box->getPos().y;
+ box->setGravityMode(true);
+ run(scene, 30);
+ check(box->getPos().y > lifted - 0.5f, "gravity mode off and on");
+ box->setPos(700.0f, 300.0f);
+ check(box->getPos().y > 299.0f && box->getPos().y < 301.0f, "SetPos moves the body");
+ box->physicalStop();
+ box->setRotation(0.5f);
+ check(box->getRotation() > 0.49f && box->getRotation() < 0.51f, "SetRotation");
+ check(box->getBoundBox().getWorldRect().z > box->getBoundBox().getWorldRect().x, "the bound box has a width");
+
+ scene.onHide();
+ check(listener.getWorld() == nullptr && ball->_body == nullptr, "OnHide clears the world and the bodies");
+ scene.onShow();
+ check(listener.getWorld() != nullptr && ball->_body != nullptr, "OnShow makes the world again");
+ scene.onHide();
+
+ scene._physListener.reset();
+ check(scene._pictureObjects.size() == pictures, "deleting the listener removes the picture copy again");
+}
+
+void runXml(const Common::String &path) {
+ Scene scene;
+ uint32 sceneId = 0;
+ g_ngi->_gameProject->_objectIds.findId("SC_1", sceneId);
+ scene._sceneId = static_cast<int16>(sceneId);
+ const bool loaded = loadSceneXmlFile(*g_ngi->_gameProject, scene, path);
+ check(loaded, "the scene XML file " + path + " loads");
+ check(scene._physListener != nullptr, "the PHYSICS node made the listener");
+ if (!scene._physListener)
+ return;
+
+ PhysListener &listener = *scene._physListener;
+ check(listener._objects.size() == 3, Common::String::format("the XML made %u objects (3 expected)", listener._objects.size()));
+ check(listener.getMaterial("BALL")._restitution == 0.2f, "the MATERIALS of the XML are read");
+ scene.onShow();
+ PhysicalObject *ball = find(scene, "PIC_SC1_UTRUBA2");
+ PhysicalObject *box = find(scene, "PIC_SC1_PRIMUS");
+ check(ball && box, "ball and box are found");
+ if (ball && box) {
+ run(scene, 600);
+ warning("PHYSTEST xml positions ball %.1f,%.1f box %.1f,%.1f", ball->getPos().x, ball->getPos().y, box->getPos().x, box->getPos().y);
+ check(ball->getPos().y > 568.0f && ball->getPos().y < 572.0f, "the XML ball rests on the XML ground");
+ check(box->getPos().y > 577.5f && box->getPos().y < 581.5f, "the XML box rests on the XML ground");
+ }
+ scene.onHide();
+}
+
+} // End of anonymous namespace
+
+void runPhysicsTest(const Common::String &what) {
+ g_failures = 0;
+ if (what == "prog") {
+ runProgrammatic();
+ } else if (what.hasPrefix("xml:")) {
+ runXml(what.substr(4));
+ } else {
+ warning("PHYSTEST unknown test %s", what.c_str());
+ return;
+ }
+ warning("PHYSTEST %s: %s", g_failures ? "FAILED" : "ALL PASSED", what.c_str());
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index ee9595d30e4..bb0e3585d27 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -163,6 +163,8 @@ void runSetup() {
const int at = value.findFirstOf('@');
ladder.delay = at == (int)Common::String::npos ? 0 : atoi(value.substr(at + 1).c_str());
ladderSteps().push_back(ladder);
+ } else if (key == "physics") {
+ runPhysicsTest(value);
} else if (key == "plankjump") {
g_plankJump = atoi(value.c_str());
} else if (key == "shootx") {
diff --git a/engines/ngi/debugger/testmode.h b/engines/ngi/debugger/testmode.h
index 8d650ecb3c1..de3c950b97d 100644
--- a/engines/ngi/debugger/testmode.h
+++ b/engines/ngi/debugger/testmode.h
@@ -73,6 +73,9 @@ void testmode_update(uint32 elapsed);
/** the state for the Info window */
void testmode_getInfo(TestInfo &info);
+/** --start-movie=physics=prog|xml:PATH: the Android physics test (physicstest.cpp) */
+void runPhysicsTest(const Common::String &what);
+
} // End of namespace NGI
#endif
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 572e77f7ff5..7a688ec05ac 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -85,6 +85,7 @@ MODULE_OBJS = \
box2d/Dynamics/b2World.o \
box2d/Dynamics/b2WorldCallbacks.o \
box2d/Rope/b2Rope.o \
+ debugger/physicstest.o \
debugger/testmode.o \
fullpipe/floaters.o \
fullpipe/lift.o \
diff --git a/engines/ngi/physics.cpp b/engines/ngi/physics.cpp
index 881cbe89145..e07b89398f0 100644
--- a/engines/ngi/physics.cpp
+++ b/engines/ngi/physics.cpp
@@ -731,7 +731,7 @@ void PhysListener::PreSolve(b2Contact *contact, const b2Manifold *oldManifold) {
_scene->_controller->preSolve(contact, oldManifold);
}
-// The XML objects of the node are made by the loader (CScene::CreateObjects), after this
+// The caller makes the objects of the node (createObjects) after this, as CScene::CreateObjects
void PhysListener::init(const XmlNode &node) {
for (uint i = 0; i < node.childCount(); i++) {
if (node[i].name() == "MATERIALS")
@@ -757,6 +757,27 @@ void PhysListener::init(const XmlNode &node) {
setScale(scale);
}
+// IObjectBuilder::CreateBaseObjects: a tag that is not a physical object makes none
+PhysicalObject *PhysListener::createObject(const XmlNode &node) {
+ PhysicalObject *object;
+ if (node.name() == "PHYSOBJ")
+ object = new PhysicalObject(_scene);
+ else if (node.name() == "PHYSGROUND")
+ object = new PhysGround(_scene);
+ else
+ return nullptr;
+ object->init(node);
+ _scene->addPhysicalObject(object);
+ return object;
+}
+
+void PhysListener::createObjects(const XmlNode &node) {
+ for (uint i = 0; i < node.childCount(); i++) {
+ if (!createObject(node[i]) && node[i].name() != "MATERIALS")
+ warning("STUB: XML <%s> inside <PHYSICS>", node[i].name().c_str());
+ }
+}
+
void PhysListener::initWorld() {
_accumulator = 0.0f;
delete _world;
diff --git a/engines/ngi/physics.h b/engines/ngi/physics.h
index 7dee57df842..fd24d690f27 100644
--- a/engines/ngi/physics.h
+++ b/engines/ngi/physics.h
@@ -34,8 +34,7 @@
namespace NGI {
-// Android physics (Box2D): the glue around the imported Box2D 2.2.1 (docs/android-physics.md).
-// Classes not ported yet are stubs from scripts/ngi_gen_stubs.py (each warns "STUB/untested").
+// Android physics (Box2D): the glue around the imported Box2D 2.2.1 (docs/android-physics.md)
class XmlNode;
@@ -274,6 +273,9 @@ public:
void PostSolve(b2Contact *contact, const b2ContactImpulse *impulse) override; // 1189C4
void init(const XmlNode &node); // 119118
+ /** CScene::CreateObjects for the PHYSOBJ and PHYSGROUND children of the node */
+ void createObjects(const XmlNode &node);
+ PhysicalObject *createObject(const XmlNode &node);
void initWorld(); // 118BA4
b2World *getWorld() const; // 118C28
void onShow(); // 118C2C
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index c93e007402e..14224467371 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -278,6 +278,9 @@ class Scene : public Background {
void sortRenderables(Common::Array<T*> &list, uint startIndex = 0);
};
+/** The test mode (physics): the XML scene file at this path of the file system into the scene */
+bool loadSceneXmlFile(const GameProject &project, Scene &scene, const Common::String &path);
+
class SceneTag : public CObject {
public:
Common::String _tag;
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 8c81867aeb8..f95e555cee4 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -25,6 +25,7 @@
#include "common/debug-channels.h"
#include "common/file.h"
#include "common/formats/xmlparser.h"
+#include "common/fs.h"
#include "common/tokenizer.h"
#include "ngi/ngi.h"
@@ -1137,29 +1138,13 @@ private:
return true;
}
- // IObjectBuilder::CreateBaseObjects for the physical objects, then CScene::AddGameObject
- void createPhysicalObject(const XmlNode &node) {
- PhysicalObject *object;
- if (node.name() == "PHYSGROUND")
- object = new PhysGround(&_scene);
- else
- object = new PhysicalObject(&_scene);
- object->init(node);
- _scene.addPhysicalObject(object);
- }
-
void finishPhysics(const XmlNode &root) {
if (root.name() == "PHYSICS") {
// CPhysListener::Init: the materials and the settings, then CScene::CreateObjects
_scene._physListener->init(root);
- for (uint i = 0; i < root.childCount(); i++) {
- if (root[i].name() == "PHYSOBJ" || root[i].name() == "PHYSGROUND")
- createPhysicalObject(root[i]);
- else if (root[i].name() != "MATERIALS")
- warning("STUB: XML <%s> inside <PHYSICS>", root[i].name().c_str());
- }
+ _scene._physListener->createObjects(root);
} else {
- createPhysicalObject(root);
+ _scene._physListener->createObject(root);
}
}
@@ -1843,6 +1828,12 @@ const char *NGIEngine::getResourceLocale() const {
}
}
+bool loadSceneXmlFile(const GameProject &project, Scene &scene, const Common::String &path) {
+ Common::FSNode file(Common::Path(path, '/'));
+ XMLSceneParser parser(project, scene, g_ngi->getResourceLocale());
+ return parser.loadStream(file.createReadStream(), path) && parser.parse();
+}
+
void SceneTag::loadSceneXML(const GameProject &project) {
Common::ScopedPtr<Scene> scene(new Scene());
scene->_sceneId = _sceneId;
Commit: 34eb7b19f0c40949268e90a888afc24779efbd90
https://github.com/scummvm/scummvm/commit/34eb7b19f0c40949268e90a888afc24779efbd90
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Send ENABLE_CHARACTER from old animations (COldAniObject::Update)
Changed paths:
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 54092275f3d..6e144494178 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -886,6 +886,8 @@ Common::Point AniObject::getSomeXY() const {
// CAniObject::Update (F2D7C): afterwards the object lets go of a stopped queue
bool AniObject::update(int counterdiff) {
+ if (g_ngi->_gameVersion >= 201509 && _oldAni)
+ updateEnableCharacter();
if (g_ngi->_gameVersion >= 201509)
updateMoveTo(counterdiff);
const bool changed = updateAnimation(counterdiff);
@@ -894,6 +896,23 @@ bool AniObject::update(int counterdiff) {
return changed;
}
+// COldAniObject::Update (161DF0): a character that shows up on the screen is unlocked once
+void AniObject::updateEnableCharacter() {
+ if (!(_flags & 4) || _characterSent || !isOnScreen(g_ngi->getCurrentScene()))
+ return;
+ const Common::Point size = getSize();
+ if (size.x <= 2 && size.y <= 2)
+ return;
+
+ _characterSent = true;
+ Command command(0, kCmdUser, 0, 0, 0, 0, 0, 0, 0, 0);
+ command._messageName = "ENABLE_CHARACTER";
+ command._args["type"] = "ENABLE_CHARACTER";
+ command._args["persId"] = g_ngi->_gameProject->_objectIds.findName(_id);
+ debugC(1, kDebugInfo, "INFO ENABLE_CHARACTER %s (%d)", command._args["persId"].c_str(), _id);
+ g_ngi->getCurrentScene()->execCmd(&command, 1);
+}
+
bool AniObject::updateAnimation(int counterdiff) {
int mqid;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index e33bcfe7709..1910be0d180 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -229,6 +229,7 @@ class AniObject : public GameObject {
public:
int16 _sceneId;
bool _oldAni = false; // COldAniObject (XML OLDANI)
+ bool _characterSent = false; // COldAniObject +176: ENABLE_CHARACTER was sent
public:
AniObject();
@@ -310,6 +311,7 @@ public:
void playIdle();
/** CAniObject::Update (F2D7C) */
bool update(int counterdiff);
+ void updateEnableCharacter();
/** The movement of the object (update without the queue pointer) */
bool updateAnimation(int counterdiff);
Commit: 3557b47f778ac443ccfa256f0d3a76d0f3fd8eb8
https://github.com/scummvm/scummvm/commit/3557b47f778ac443ccfa256f0d3a76d0f3fd8eb8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Float model stage 3: AniObject stores the top left on 201509
Changed paths:
engines/ngi/debugger/testmode.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/fullpipe/scene18and19.cpp
engines/ngi/fullpipe/sceneDbg.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/interaction.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/motion.cpp
engines/ngi/scene.cpp
engines/ngi/statics.cpp
engines/ngi/statics.h
engines/ngi/xmlproject.cpp
engines/ngi/zcontroller.cpp
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index bb0e3585d27..e79de10480a 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -63,6 +63,193 @@ const Spot kSpots[] = {
{ SC_4, 3, 1150, 476, 800, "scene 4: with the coin for the horn", ANI_INV_COIN },
};
+Common::String name(int id);
+
+// movetest: movements, frames, stops, setStatic, setPosition of every animation, one MT line each
+// (docs/float-model-plan.md, stage 3; compare two builds with scripts/ngi_movetest_compare.py)
+Common::String moveTestState(const AniObject *ani) {
+ const Common::Point topLeft = ani->getPosition();
+ const Common::Point center = ani->getCenter();
+ const Common::Rect bounds = ani->getBounds();
+ const int staticsId = ani->_statics ? ani->_statics->_staticsId : 0;
+ return Common::String::format("tl %d,%d pv %d,%d c %d,%d b %d,%d,%d,%d st %d m %d fl %02x", topLeft.x, topLeft.y, ani->pivotX(), ani->pivotY(), center.x, center.y,
+ bounds.left, bounds.top, bounds.right, bounds.bottom, staticsId, ani->_movement ? ani->_movement->_id : 0, ani->_flags);
+}
+
+Common::String moveTestFrame(const AniObject *ani) {
+ const Common::Point topLeft = ani->getPosition();
+ return Common::String::format("%d:%d,%d/%d,%d", ani->_movement ? ani->_movement->_curFrame : -1, topLeft.x, topLeft.y, ani->pivotX(), ani->pivotY());
+}
+
+// raw state changes (as the Windows code makes them), then the pivot is written
+void moveTestReset(AniObject *ani, Statics *statics, bool mirror) {
+ ani->_movement = nullptr;
+ ani->_statics = statics;
+ ani->_flags = (ani->_flags & ~(1 | 8 | 0x20)) | (mirror ? 8 : 0);
+ ani->_stepArray.clear();
+ ani->setTargetFrame(-1);
+ ani->setPos(101, 203);
+}
+
+void moveTestRun(AniObject *ani, const Common::String &prefix, int variant, int movementId, bool mirror, bool reverse, int startFrame) {
+ Common::String line = prefix + " " + moveTestState(ani) + " ->";
+ const bool started = ani->startMovement(movementId, 0, -1, mirror, false, reverse, startFrame, true);
+ line += Common::String::format(" %s | %s |", started ? "started" : "no", moveTestState(ani).c_str());
+ int frames = 0;
+ if (variant == 1) {
+ while (ani->_movement && frames < 400) {
+ if (!ani->setNextFrame(true)) {
+ ani->stopMovement(true);
+ break;
+ }
+ line += " " + moveTestFrame(ani);
+ frames++;
+ }
+ } else if (variant == 2) {
+ for (; ani->_movement && frames < 2 && ani->setNextFrame(true); frames++)
+ line += " " + moveTestFrame(ani);
+ ani->stopMovementToPrev(true);
+ } else if (variant == 3) {
+ for (; ani->_movement && frames < 3 && ani->setNextFrame(true); frames++)
+ line += " " + moveTestFrame(ani);
+ if (ani->_movement) {
+ ani->setCurFrame(1, true, true);
+ line += " back " + moveTestFrame(ani);
+ ani->stopMovement(true);
+ }
+ }
+ line += " | " + moveTestState(ani);
+ debugC(1, kDebugInfo, "MT %s", line.c_str());
+}
+
+void moveTestObject(AniObject *ani) {
+ const Common::String title = name(ani->_id);
+ const bool oldAni = ani->_oldAni;
+ for (Movement *mov : ani->_movements) {
+ Statics *first = mov->_prevStatic ? mov->_prevStatic : mov->_nextStatic;
+ Statics *last = mov->_nextStatic ? mov->_nextStatic : mov->_prevStatic;
+ if (!first || !last)
+ continue;
+ const int movementId = mov->_id;
+ for (int reverse = 0; reverse < 2; reverse++) {
+ for (int initMirror = 0; initMirror < 2; initMirror++) {
+ for (int mirror = 0; mirror < 2; mirror++) {
+ for (int variant = 1; variant <= 3; variant++) {
+ moveTestReset(ani, reverse ? last : first, initMirror != 0);
+ moveTestRun(ani, Common::String::format("%s mov %d rev %d init %d mir %d v%d", title.c_str(), movementId, reverse, initMirror, mirror, variant), variant,
+ movementId, mirror != 0, reverse != 0, -1);
+ }
+ }
+ }
+ }
+ // a start frame, and the slide of three steps
+ if (mov->_phases.size() > 4) {
+ moveTestReset(ani, first, false);
+ moveTestRun(ani, Common::String::format("%s mov %d startframe", title.c_str(), movementId), 1, movementId, false, false, 2);
+ moveTestReset(ani, first, true);
+ moveTestRun(ani, Common::String::format("%s mov %d startframe mir", title.c_str(), movementId), 1, movementId, true, false, 2);
+ }
+ for (int mirror = 0; mirror < 2; mirror++) {
+ moveTestReset(ani, first, false);
+ PointList points;
+ points.push_back(Common::Point(5, 1));
+ points.push_back(Common::Point(7, -2));
+ points.push_back(Common::Point(-3, 4));
+ points.push_back(Common::Point(2, 2));
+ Common::String line = Common::String::format("%s mov %d slide mir %d %s ->", title.c_str(), movementId, mirror, moveTestState(ani).c_str());
+ ani->startSliding(movementId, 0, 0, 0, points, -1, mirror != 0);
+ line += " | " + moveTestState(ani) + " |";
+ for (int frames = 0; ani->_movement && frames < 400; frames++) {
+ if (!ani->setNextFrame(true)) {
+ ani->stopMovement(true);
+ break;
+ }
+ line += " " + moveTestFrame(ani);
+ }
+ line += " | " + moveTestState(ani);
+ debugC(1, kDebugInfo, "MT %s", line.c_str());
+ }
+ // a position written while the movement runs
+ for (int oldAniFlag = 0; oldAniFlag < 2; oldAniFlag++) {
+ moveTestReset(ani, first, false);
+ ani->_oldAni = oldAniFlag != 0;
+ ani->startMovement(movementId, 0, -1, false, false, false, -1, true);
+ if (ani->_movement)
+ ani->setNextFrame(true);
+ ani->setPosition(Common::Point(57, 61));
+ debugC(1, kDebugInfo, "MT %s mov %d setposition running oldani %d %s", title.c_str(), movementId, oldAniFlag, moveTestState(ani).c_str());
+ ani->stopMovement(true);
+ ani->_oldAni = oldAni;
+ }
+ }
+
+ // SetStatic between statics (the first ten and the last), standing, SetPos of a standing object
+ Common::Array<Statics *> statics;
+ for (Statics *st : ani->_staticsList) {
+ if (statics.size() < 10 || st == ani->_staticsList.back())
+ statics.push_back(st);
+ }
+ for (Statics *from : statics) {
+ for (int initMirror = 0; initMirror < 2; initMirror++) {
+ moveTestReset(ani, from, initMirror != 0);
+ debugC(1, kDebugInfo, "MT %s standing %d init %d %s", title.c_str(), from->_staticsId, initMirror, moveTestState(ani).c_str());
+ for (int oldAniFlag = 0; oldAniFlag < 2; oldAniFlag++) {
+ moveTestReset(ani, from, initMirror != 0);
+ ani->_oldAni = oldAniFlag != 0;
+ ani->setPosition(Common::Point(57, 61));
+ debugC(1, kDebugInfo, "MT %s setposition standing %d init %d oldani %d %s", title.c_str(), from->_staticsId, initMirror, oldAniFlag, moveTestState(ani).c_str());
+ ani->_oldAni = oldAni;
+ }
+ for (Statics *to : statics) {
+ for (int mirror = 0; mirror < 3; mirror++) {
+ moveTestReset(ani, from, initMirror != 0);
+ if (mirror == 2)
+ ani->setStatic(to->_staticsId);
+ else
+ ani->setStatic(to->_staticsId, mirror != 0);
+ debugC(1, kDebugInfo, "MT %s setstatic %d -> %d init %d mir %d %s", title.c_str(), from->_staticsId, to->_staticsId, initMirror, mirror, moveTestState(ani).c_str());
+ }
+ }
+ }
+ }
+}
+
+void runMoveTest(const Common::String &what) {
+ Scene *scene = g_ngi->_currentScene;
+ if (!scene)
+ return;
+ // movetest=1: the animations of the scene, once per id; movetest=hero: Dude only
+ Common::Array<AniObject *> objects;
+ if (what == "hero") {
+ if (g_ngi->_aniMan)
+ objects.push_back(g_ngi->_aniMan);
+ } else {
+ for (AniObject *ani : scene->_aniObjects) {
+ bool seen = false;
+ for (const AniObject *other : objects)
+ seen = seen || other->_id == ani->_id;
+ if (!seen && ani != g_ngi->_aniMan && ani->_id != ANI_MAN)
+ objects.push_back(ani);
+ }
+ }
+ debugC(1, kDebugInfo, "MT begin scene %d, %u animations", scene->_sceneId, objects.size());
+ for (AniObject *ani : objects) {
+ if (!ani->_statics && ani->_staticsList.empty())
+ continue;
+ if (what == "anchors") {
+ // the anchor (someXY) and size of every statics
+ for (const Statics *st : ani->_staticsList) {
+ const Dims size = st->getDimensions();
+ debugC(1, kDebugInfo, "MT anchors %s statics %s anchor %d,%d size %d,%d", name(ani->_id).c_str(), name(st->_staticsId).c_str(), st->_someX, st->_someY, size.x, size.y);
+ }
+ continue;
+ }
+ moveTestObject(ani);
+ }
+ debugC(1, kDebugInfo, "MT done");
+ g_ngi->quitGame();
+}
+
// --start-movie=<actions> (NGI_TEST_SETUP): ';' separated, done once after the entrance queue:
// state=Object:Value, item=ANI_INV_COIN, scroll=x,y, visit=1,2,1,3 (scenes in turn, 7 s each)
bool g_setupDone = false;
@@ -136,6 +323,8 @@ void runSetup() {
const Common::String state = toGameEncoding(value.substr(colon + 1));
warning("TESTMODE: state %s = %s", value.substr(0, colon).c_str(), value.substr(colon + 1).c_str());
g_ngi->setState(object, g_ngi->getStateValue(object, state.c_str()));
+ } else if (key == "movetest") {
+ runMoveTest(value);
} else if (key == "watchpos") {
watchPositions() = value != "0";
} else if (key == "watch") {
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index a275936a5cd..031e0a79916 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -985,8 +985,12 @@ void sceneHandler04_shootKozyawka() {
}
g_vars->scene04_walkingKozyawka->setQueue(nullptr);
+ const int pivotX = g_vars->scene04_walkingKozyawka->pivotX();
+ const int pivotY = g_vars->scene04_walkingKozyawka->pivotY();
g_vars->scene04_walkingKozyawka->_movement = nullptr;
g_vars->scene04_walkingKozyawka->_statics = g_vars->scene04_walkingKozyawka->getStatic(ST_KZW_RIGHT);
+ if (g_ngi->_gameVersion >= 201509)
+ g_vars->scene04_walkingKozyawka->setPos(pivotX, pivotY);
MessageQueue *mq;
@@ -1082,7 +1086,7 @@ void sceneHandler04_bottleUpdateObjects(int off) {
} else {
GameObject *obj = *it;
- obj->setPos(obj->_x, off + obj->_y);
+ obj->setPos(obj->pivotX(), off + obj->pivotY());
}
}
}
diff --git a/engines/ngi/fullpipe/scene18and19.cpp b/engines/ngi/fullpipe/scene18and19.cpp
index f779a31c654..a5ae981e09c 100644
--- a/engines/ngi/fullpipe/scene18and19.cpp
+++ b/engines/ngi/fullpipe/scene18and19.cpp
@@ -231,7 +231,7 @@ void scene18_initScene1(Scene *sc) {
else
go = g_vars->scene18_swingers[i]->ani;
- go->setPos(newx + go->_x, newy + go->_y);
+ go->setPos(newx + go->pivotX(), newy + go->pivotY());
}
if (g_vars->scene18_bridgeIsConvoluted && g_vars->scene18_whirlgigMovMum != -1) {
diff --git a/engines/ngi/fullpipe/sceneDbg.cpp b/engines/ngi/fullpipe/sceneDbg.cpp
index 83f06aa149f..1eacd2b1592 100644
--- a/engines/ngi/fullpipe/sceneDbg.cpp
+++ b/engines/ngi/fullpipe/sceneDbg.cpp
@@ -91,7 +91,7 @@ int sceneHandlerDbgMenu(Command *ex) {
obj = sceneHandlerDbgMenu_getObjectAtXY(mx, my);
if (obj && canInteractAny(nullptr, obj, -3) ) {
g_vars->selector->_flags |= 4;
- g_vars->selector->setPos(obj->_x, obj->_y);
+ g_vars->selector->setPos(obj->pivotX(), obj->pivotY());
g_ngi->_cursorId = PIC_CSR_DEFAULT;
g_ngi->setCursor(PIC_CSR_DEFAULT);
return 0;
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index a70ff2698cb..d83b41ab0dc 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -641,9 +641,10 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
scene->_renderableAnis.push_back(actor);
scene->_roamingAnis.push_back(actor);
}
+ const int pivotX = ref.ox == -1 ? actor->pivotX() : ref.ox;
+ const int pivotY = ref.oy == -1 ? actor->pivotY() : ref.oy;
if (ref.staticsId)
actor->_statics = actor->getStatic(ref.staticsId);
- actor->setPos(ref.ox == -1 ? actor->pivotX() : ref.ox, ref.oy == -1 ? actor->pivotY() : ref.oy);
if (ref.priority != -1)
actor->_z = ref.priority;
if (ref.objectFlags != -1) {
@@ -652,6 +653,7 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
}
if (ref.flags != -1)
actor->_flags = (actor->_flags & ~8) | (ref.flags ? 8 : 0);
+ actor->setPos(pivotX, pivotY);
}
_aniMan = scene->findAniObjectById(scene->_heroId, 0);
_aniMan2 = _aniMan;
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 784d59099e2..324cc70a4bb 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -357,10 +357,8 @@ static bool textureQuad(const GameObject *object, Common::Point &topLeft, Dims &
if (!phase)
return false;
size = phase->getDimensions();
- anchor = ani->getSomeXY();
- if (ani->_flags & 8)
- anchor.x = size.x - anchor.x;
- topLeft = Common::Point(ani->pivotX(), ani->pivotY()) - anchor;
+ anchor = ani->pivotAnchor();
+ topLeft = ani->topLeft();
return true;
}
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index 20adc6d4e9b..c027960d0da 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -212,6 +212,9 @@ class GameObject : public CObject {
virtual Common::String toXML();
bool load(MfcArchive &file) override;
virtual void setPos(int x, int y); // CVisibleObject::SetPos (vtable slot 80)
+ /** the position as the Windows code reads it (an AniObject answers with its pivot) */
+ virtual int pivotX() const { return static_cast<int>(_x); }
+ virtual int pivotY() const { return static_cast<int>(_y); }
void assignCopyId(Common::Array<AniObject *> *lst);
void assignCopyId(Common::Array<PictureObject *> *lst);
void setFlags(int16 flags) { _flags = flags; }
@@ -221,7 +224,7 @@ class GameObject : public CObject {
RenderParams getRenderParams(bool mirror = false) const;
/** the texture's top left, +40/+44 of CVisibleObject (_x, _y are a pivot) */
Common::Point getPosition() const;
- void setTopLeft(Common::Point topLeft);
+ virtual void setTopLeft(Common::Point topLeft);
/** CVisibleObject::SetPos (11F648): the virtual SetPos (slot 20), the z stays */
virtual void setPosition(Common::Point pos);
/** CVisibleObject::MoveTo (127BC0) owns the info, Update (127AFE) runs it, StopMoveTo (126D0E) */
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index be308cb7397..83d5681b2d6 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -224,8 +224,8 @@ bool InteractionController::handleInteraction(AniObject *subj, GameObject *obj,
ani->_messageQueueId = 0;
ani->setStatic(cinter->_objectStaticId);
}
- int xpos = cinter->_heroOffsetX + obj->_x;
- int ypos = cinter->_heroOffsetY + obj->_y;
+ int xpos = cinter->_heroOffsetX + obj->pivotX();
+ int ypos = cinter->_heroOffsetY + obj->pivotY();
obj->setPicAniInfo(aniInfo);
@@ -341,7 +341,7 @@ bool InteractionController::handleInteraction(AniObject *subj, GameObject *obj,
if (!inter->_messageQueue)
return false;
- subj->setPos(inter->_heroOffsetX + obj->_x, inter->_heroOffsetY + obj->_y);
+ subj->setPos(inter->_heroOffsetX + obj->pivotX(), inter->_heroOffsetY + obj->pivotY());
mq = new MessageQueue(inter->_messageQueue, 0, 1);
mq->setObjectCopyForId(obj->_id, -1, obj->_copyId);
@@ -396,8 +396,8 @@ bool InteractionController::handleInteraction(AniObject *subj, GameObject *obj,
ani->setStatic(inter->_objectStaticId);
}
- int xpos = inter->_heroOffsetX + obj->_x;
- int ypos = inter->_heroOffsetY + obj->_y;
+ int xpos = inter->_heroOffsetX + obj->pivotX();
+ int ypos = inter->_heroOffsetY + obj->pivotY();
obj->setPicAniInfo(aniInfo);
@@ -617,8 +617,8 @@ bool Interact::canRun(GameObject *obj1, GameObject *obj2, int invId) {
}
bool Interact::isOverlapping(AniObject *subj, GameObject *obj) {
- if (abs(_heroOffsetX + obj->_x - subj->pivotX()) <= 1
- && abs(obj->_y + _heroOffsetY - subj->pivotY()) <= 1) {
+ if (abs(_heroOffsetX + obj->pivotX() - subj->pivotX()) <= 1
+ && abs(obj->pivotY() + _heroOffsetY - subj->pivotY()) <= 1) {
if (!_heroStaticId || (subj->_statics != nullptr && subj->_statics->_staticsId == _heroStaticId)) {
if (!_objectStaticId || !(_flags & 1))
return true;
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 272693397ed..7e049652979 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -749,8 +749,11 @@ int global_messageHandler4(Command *cmd) {
if (g_ngi->_gameVersion >= 201509) {
const bool mirror = cmd->_auxParam < 0 ? (ani->_flags & 8) != 0 : cmd->_auxParam != 0;
- ani->show1(cmd->_x == -1 ? ani->pivotX() : cmd->_x, cmd->_y == -1 ? ani->pivotY() : cmd->_y, cmd->_messageNum, (cmd->_excFlags & 1) ? 0 : cmd->_parId);
+ const int x = cmd->_x == -1 ? ani->pivotX() : cmd->_x;
+ const int y = cmd->_y == -1 ? ani->pivotY() : cmd->_y;
+ ani->show1(x, y, cmd->_messageNum, (cmd->_excFlags & 1) ? 0 : cmd->_parId);
ani->_flags = (ani->_flags & ~8) | (mirror ? 8 : 0);
+ ani->setPos(x, y);
} else {
ani->show1(cmd->_x, cmd->_y, cmd->_messageNum, cmd->_parId);
}
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index 75e3fe95ccf..b4f0f9f755c 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -1239,6 +1239,9 @@ bool MovGraph::resetPosition(AniObject *ani, int flag) {
}
ani->_statics = st;
+ // the pivot stays where it was set, the top left of the 2015 build follows the new statics
+ if (g_ngi->_gameVersion >= 201509)
+ ani->setPos(point.x, point.y);
}
return true;
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 0b5a0f0fe84..03ca2b5d622 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -1201,7 +1201,7 @@ void Scene::renderDebug() {
if (object->_objtype == kObjTypePictureObject) {
Common::Rect region = static_cast<PictureObject *>(object)->_hitRegion;
if (!region.isEmpty()) {
- region.translate(object->_x - scroll.x, object->_y - scroll.y);
+ region.translate(object->pivotX() - scroll.x, object->pivotY() - scroll.y);
target.frameRect(region, green);
}
}
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 6e144494178..6e8d0704325 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -216,7 +216,71 @@ bool AniObject::load(MfcArchive &file) {
return true;
}
+Common::Point AniObject::pivotAnchor() const {
+ const Phase *phase = _movement ? _movement->_curPhase : _statics;
+ if (!phase)
+ return Common::Point();
+ Common::Point anchor = getSomeXY();
+ if (_flags & 8)
+ anchor.x = phase->getDimensions().x - anchor.x;
+ return anchor;
+}
+
+Common::Point AniObject::topLeft() const {
+ if (g_ngi->_gameVersion >= 201509)
+ return Common::Point(static_cast<int>(_x), static_cast<int>(_y));
+ return Common::Point(static_cast<int>(_x), static_cast<int>(_y)) - pivotAnchor();
+}
+
+int AniObject::pivotX() const {
+ if (g_ngi->_gameVersion >= 201509)
+ return static_cast<int>(_x + pivotAnchor().x);
+ return static_cast<int>(_x);
+}
+
+int AniObject::pivotY() const {
+ if (g_ngi->_gameVersion >= 201509)
+ return static_cast<int>(_y + pivotAnchor().y);
+ return static_cast<int>(_y);
+}
+
+void AniObject::setPivotX(int x) {
+ if (g_ngi->_gameVersion >= 201509)
+ _x = x - pivotAnchor().x;
+ else
+ _x = x;
+}
+
+void AniObject::setPivotY(int y) {
+ if (g_ngi->_gameVersion >= 201509)
+ _y = y - pivotAnchor().y;
+ else
+ _y = y;
+}
+
+// the Movement keeps a copy of the pivot for the Windows code (CMovement has no position)
+void AniObject::storeTopLeft(float x, float y) {
+ _x = x;
+ _y = y;
+
+ if (_movement)
+ _movement->setPos(pivotX(), pivotY());
+}
+
+void AniObject::setTopLeft(Common::Point topLeft) {
+ if (g_ngi->_gameVersion >= 201509)
+ storeTopLeft(topLeft.x, topLeft.y);
+ else
+ GameObject::setTopLeft(topLeft);
+}
+
void AniObject::setPos(int x, int y) {
+ if (g_ngi->_gameVersion >= 201509) {
+ const Common::Point anchor = pivotAnchor();
+ storeTopLeft(x - anchor.x, y - anchor.y);
+ return;
+ }
+
_x = x;
_y = y;
@@ -224,16 +288,26 @@ void AniObject::setPos(int x, int y) {
_movement->setPos(x, y);
}
-// COldAniObject::SetPos (161924): x, y is the pivot of a standing object, its static is set again
+// COldAniObject::SetPos (161924): a standing object is set into its statics again
void AniObject::setOldAniPos(int x, int y, int z) {
const Common::Point topLeft = getPosition();
_z = z;
if (topLeft.x == x && topLeft.y == y)
return;
- if (_movement)
- setTopLeft(Common::Point(x, y));
- else
- setPos(x, y);
+ if (g_ngi->_gameVersion < 201509) {
+ if (_movement)
+ setTopLeft(Common::Point(x, y));
+ else
+ setPos(x, y);
+ return;
+ }
+
+ storeTopLeft(x, y);
+ if (!_movement && _statics) {
+ const int staticsId = _statics->_staticsId;
+ _statics = nullptr;
+ setStatic(staticsId, (_flags & 8) != 0);
+ }
}
// slot 20 of an OLDANI is COldAniObject::SetPos, of an ANI CVisibleObject::SetPos
@@ -541,8 +615,8 @@ bool AniObject::getPixelAtPos(int x, int y, uint32 *pixel, bool hitOnly) {
const Common::Point point = _statics->getSomeXY();
xani = point.x;
yani = point.y;
- oxani = _x;
- oyani = _y;
+ oxani = pivotX();
+ oyani = pivotY();
}
int xtarget = x - (oxani - xani);
@@ -705,11 +779,7 @@ void AniObject::render(Common::Point scroll) {
if (g_ngi->_gameVersion >= 201509) {
const Phase *phase = _movement ? _movement->_curPhase : _statics;
if (phase && (_flags & 4)) {
- Common::Point anchor = getSomeXY();
- const bool mirror = (_flags & 8) != 0;
- if (mirror)
- anchor.x = phase->getDimensions().x - anchor.x;
- phase->blitTo(g_ngi->_backgroundSurface, Common::Point(_x, _y) - scroll - anchor, getRenderParams(mirror));
+ phase->blitTo(g_ngi->_backgroundSurface, topLeft() - scroll, getRenderParams((_flags & 8) != 0));
}
return;
}
@@ -1025,8 +1095,8 @@ bool AniObject::updateAnimation(int counterdiff) {
const Common::Point point = _movement->getCurrDynamicPhaseXY();
const Common::Point pointS = _statics->getSomeXY();
- _movement->setPos(_x + point.x + _movement->_prevStepX - pointS.x,
- _y + point.y + _movement->_prevStepY - pointS.y);
+ _movement->setPos(pivotX() + point.x + _movement->_prevStepX - pointS.x,
+ pivotY() + point.y + _movement->_prevStepY - pointS.y);
}
return true;
}
@@ -1231,19 +1301,20 @@ void AniObject::setMovementFrame(Movement *mov, int frame, bool silent) {
else if (old < (int)mov->_phases.size() - 1)
mov->_phases[old]->setCurrent(_id, load, silent);
- const Common::Point before(_x, _y);
- mov->setFrame(frame, (_flags & 8) != 0);
- setPos(mov->_x, mov->_y);
- if ((_x != before.x || _y != before.y) && (_scaleX != 1.0f || _scaleY != 1.0f || _rotation != 0.0f))
+ float x = _x;
+ float y = _y;
+ mov->setFrame(frame, x, y, (_flags & 8) != 0);
+ if ((_x != x || _y != y) && (_scaleX != 1.0f || _scaleY != 1.0f || _rotation != 0.0f))
warning("STUB/untested: CMovement::SetFrame of ani %d with scale %f, %f, rotation %f: the step is not scaled or rotated", _id, _scaleX, _scaleY, _rotation);
+ storeTopLeft(x, y);
// the slide of the frames (+80, +84 of the movement): added going forward, taken back going back
if (forward) {
const Common::Point step = _stepArray.getCurrPoint();
- setPos(_x + step.x, _y + step.y);
+ storeTopLeft(_x + step.x, _y + step.y);
_stepArray.gotoNextPoint();
} else if (frame < _stepArray.getPointsCount()) {
const Common::Point step = _stepArray.getPoint(frame, 1);
- setPos(_x - step.x, _y - step.y);
+ storeTopLeft(_x - step.x, _y - step.y);
}
if (!silent)
@@ -1333,6 +1404,17 @@ void AniObject::adjustSomeXY() {
point = _movement->getMovementSize(1, -1);
+ if (g_ngi->_gameVersion >= 201509) {
+ // the pivot moves, then the object stands in the next statics
+ const int pivotX = this->pivotX() + (diff > 0 ? point.x : 0);
+ const int pivotY = this->pivotY() + (diff > 0 ? 0 : point.y);
+ _statics = _movement->_nextStatic;
+ _movement = nullptr;
+ _targetFrame = -1;
+ setPos(pivotX, pivotY);
+ return;
+ }
+
if (diff > 0)
_x += point.x;
else
@@ -1694,8 +1776,6 @@ void AniObject::show1(int x, int y, int movId, int mqId) {
_statics->_countdown = _statics->_delay;
_flags |= 4;
- _x = x;
- _y = y;
_movement = nullptr;
if (mov->_currMovement)
@@ -1706,6 +1786,8 @@ void AniObject::show1(int x, int y, int movId, int mqId) {
if (_flags & 1)
_flags ^= 1;
+ setPos(x, y);
+
// ExecuteCmdShow does not tie the object to a queue
if (g_ngi->_gameVersion < 201509)
_messageQueueId = mqId;
@@ -1735,8 +1817,12 @@ void AniObject::show2(int x, int y, int movementId, int mqId) {
point = _statics->getSomeXY();
_flags |= 4;
- _x = _statics->_x + point.x;
- _y = _statics->_y + point.y;
+ const float posX = _statics->_x + point.x;
+ const float posY = _statics->_y + point.y;
+ if (g_ngi->_gameVersion < 201509) {
+ _x = posX;
+ _y = posY;
+ }
if (mov->_currMovement) {
_flags |= 8;
@@ -1749,6 +1835,8 @@ void AniObject::show2(int x, int y, int movementId, int mqId) {
_flags ^= 1;
_flags |= 0x20;
+ if (g_ngi->_gameVersion >= 201509)
+ setPos(posX, posY);
}
}
}
@@ -1766,7 +1854,7 @@ void AniObject::startSliding(int movementId, int messageQueueId, int x, int y, c
if (startMovement(movementId, messageQueueId, someDynamicPhaseIndex, mirror, cycled, false, -1, true)) {
_stepArray.insertPoints(points);
const Common::Point offset = _stepArray.getCurrPoint();
- setPos(_x + offset.x, _y + offset.y);
+ storeTopLeft(_x + offset.x, _y + offset.y);
_stepArray.gotoNextPoint();
// CMovement::SetFrame (EF8B8): the sound and the command of the first frame, after the slide
Phase *phase = _movement->_curPhase;
@@ -1898,6 +1986,68 @@ void AniObject::startMovementWithoutPhases(Movement *movement, bool mirror, bool
setTopLeft(Common::Point(topLeft.x + (int)(dx * c - dy * sn), topLeft.y + (int)(dx * sn + dy * c)));
}
+// CAniObject::StartMovement (F0D46) from 201509, then CMovement::Start (EFC96)
+bool AniObject::startMovementTimed(Movement *mov, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame, bool silent) {
+ const int movementId = mov->_id;
+
+ Statics *start = reverse ? mov->_nextStatic : mov->_prevStatic;
+ const bool startMirror = (reverse ? mov->_mirrorNext : mov->_mirrorPrev) != mirror;
+ if (startFrame == -1 && (_statics != start || ((_flags & 8) != 0) != startMirror))
+ setStatic(start->_staticsId, startMirror);
+ _flags = (_flags & ~8) | (mirror ? 8 : 0);
+
+ // CVisibleObject::GetSize of the statics, before the first phase is set
+ const Common::Point oldSize = getSize();
+
+ _movement = mov;
+ _stepArray.clear();
+
+ // a reverse movement starts one phase before its end statics (CMovement::SetNext)
+ if (reverse) {
+ _movement->_curFrame = (int)_movement->_phases.size() - 2;
+ _movement->updateCurrDynamicPhase();
+ } else {
+ _movement->gotoFirstFrame();
+ }
+
+ float x = _x;
+ float y = _y;
+ _movement->start(x, y, oldSize.x, oldSize.y, _scaleX, _scaleY, _rotation, mirror, reverse);
+ storeTopLeft(x, y);
+
+ _flags |= 1;
+ _movement->_cycled = cycled;
+ _movement->_reverse = reverse;
+ _movement->_timerRuns = true;
+
+ _movement->_curPhase->_countdown = _movement->_curPhase->_delay;
+ _movement->_counter = 0;
+
+ _counter = _initialCounter;
+ _targetFrame = dynPhaseIdx;
+
+ debugC(1, kDebugAnimation, "movement start: t %u ani %d copy %d movement %d pos %d,%d topleft %d,%d flags %x mirror %d frame %d", g_system->getMillis(), _id, _copyId, movementId,
+ pivotX(), pivotY(), topLeft().x, topLeft().y, _flags, mirror, _movement->_curFrame);
+
+ Command *newex = new Command(_id, kCmdMessage, kMsgAniMovementStarted, 0, 0, movementId, 1, 0, 0, 0);
+
+ newex->_param = _copyId;
+ newex->_excFlags = 2;
+
+ newex->postMessage();
+
+ // CMovement::SetFrame (EF8B8) of the first frame: a reverse start leaves no phase, so no sound
+ if (!reverse)
+ mov->_curPhase->setCurrent(_id, !g_ngi->_preloadManager->isPreloaded(movementId), silent);
+ if (!silent)
+ mov->_curPhase->execCmd();
+ // CAniObject::SetCurFrame (F0C76) of the start frame
+ if (startFrame != -1)
+ setCurFrame(startFrame, true, false);
+
+ return true;
+}
+
bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame, bool silent) {
if (_flags & 0x80)
return false;
@@ -1939,22 +2089,15 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
return true;
}
+ if (timedMovement)
+ return startMovementTimed(mov, messageQueueId, dynPhaseIdx, mirror, cycled, reverse, startFrame, silent);
+
int newx = _x;
int newy = _y;
Common::Point point;
// a reverse movement starts from its next statics
- if (!timedMovement)
- reverse = (_flags & 0x40) != 0;
- if (timedMovement && !_movement) {
- const bool startMirror = reverse ? mov->_mirrorNext : mov->_mirrorPrev;
- const bool prevMirror = mirror != startMirror;
- if (_statics && prevMirror != ((_flags & 8) != 0)) {
- const int shift = _statics->getDimensions().x - 2 * _statics->_someX;
- newx += prevMirror ? shift : -shift;
- }
- _statics = reverse ? mov->_nextStatic : mov->_prevStatic;
- }
+ reverse = (_flags & 0x40) != 0;
if (mirror)
newx = -newx;
@@ -1977,11 +2120,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
_stepArray.clear();
- if (timedMovement && reverse) {
- // the object stands in its next statics (last frame); the first one shown is the one before
- _movement->_curFrame = (int)_movement->_phases.size() - 1;
- _movement->updateCurrDynamicPhase();
- } else if (reverse) {
+ if (reverse) {
_movement->setLast();
} else {
_movement->gotoFirstFrame();
@@ -1996,7 +2135,7 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
_stepArray.gotoNextPoint();
Command *ex = _movement->_curPhase->getCommand();
- if (ex && !timedMovement) {
+ if (ex) {
if (ex->_cmd == kCmdSound) {
Command *newex = ex->createClone();
newex->_excFlags |= 2;
@@ -2010,24 +2149,14 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
newx += point.x;
setPos(mirror ? -newx : newx, point.y + newy);
- if (mirror || (!timedMovement && (_movement->_nextStatic->_staticsId & 0x4000)))
+ if (mirror || (_movement->_nextStatic->_staticsId & 0x4000))
_flags |= 8;
else
_flags &= 0xFFF7;
_flags |= 1;
- if (timedMovement) {
- _movement->_cycled = cycled;
- _movement->_reverse = reverse;
- _movement->_timerRuns = true;
- if (reverse) {
- _movement->gotoPrevFrame(mirror);
- setPos(_movement->_x, _movement->_y);
- }
- }
- if (!timedMovement) // no queue started the movement (CAniObject::StartMovement has none)
- _messageQueueId = messageQueueId;
+ _messageQueueId = messageQueueId;
_movement->_curPhase->_countdown = _movement->_curPhase->_delay;
_movement->_counter = 0;
@@ -2046,17 +2175,6 @@ bool AniObject::startMovement(int movementId, int messageQueueId, int dynPhaseId
newex->postMessage();
- if (timedMovement) {
- // CMovement::SetFrame (EF8B8) of the first frame: a reverse start leaves no phase, so no sound
- if (!reverse)
- mov->_curPhase->setCurrent(_id, !g_ngi->_preloadManager->isPreloaded(movementId), silent);
- if (!silent)
- mov->_curPhase->execCmd();
- // CAniObject::SetCurFrame (F0C76) of the start frame
- if (startFrame != -1)
- setCurFrame(startFrame, true, false);
- }
-
return true;
}
@@ -2863,30 +2981,65 @@ bool Movement::gotoPrevFrame(bool mirror) {
return true;
}
-void Movement::setFrame(int frame, bool mirror) {
- const int oldX = _x;
- Common::Point point = getCurrDynamicPhaseXY();
- _x -= point.x;
- _y -= point.y;
+// CMovement::SetFrame (EF8B8): the center is kept against the change of size, mirrored x is negated
+void Movement::setFrame(int frame, float &x, float &y, bool mirror) {
+ const Dims oldSize = _curPhase ? _curPhase->getDimensions() : Dims();
+ const float oldCenterX = x + oldSize.x * 0.5f;
+ const float oldCenterY = y + oldSize.y * 0.5f;
+ float stepX = 0.0f;
+ float stepY = 0.0f;
if (_curFrame >= frame) {
if (_curFrame >= 0 && (uint)_curFrame < _framePosOffsets.size()) {
- _x -= _framePosOffsets[_curFrame].x;
- _y -= _framePosOffsets[_curFrame].y;
+ stepX = -_framePosOffsets[_curFrame].x;
+ stepY = -_framePosOffsets[_curFrame].y;
}
} else if ((uint)frame < _framePosOffsets.size()) {
- _x += _framePosOffsets[frame].x;
- _y += _framePosOffsets[frame].y;
+ stepX = _framePosOffsets[frame].x;
+ stepY = _framePosOffsets[frame].y;
}
_curFrame = frame;
updateCurrDynamicPhase();
- point = getCurrDynamicPhaseXY();
- _x += point.x;
- _y += point.y;
+ const Dims newSize = _curPhase->getDimensions();
+ const float halfWidth = newSize.x * 0.5f;
+ const float halfHeight = newSize.y * 0.5f;
+ float dx = ((x + stepX) + halfWidth) - oldCenterX;
+ const float dy = ((y + stepY) + halfHeight) - oldCenterY;
if (mirror)
- _x = oldX - (_x - oldX);
+ dx = -dx;
+ x = (oldCenterX + dx) - halfWidth;
+ y = (oldCenterY + dy) - halfHeight;
+}
+
+// CMovement::Start (EFC96): the center is kept against the change of size, mirrored x is negated
+void Movement::start(float &x, float &y, float oldWidth, float oldHeight, float scaleX, float scaleY, float rotation, bool mirror, bool reverse) {
+ float stepX;
+ float stepY;
+ if (reverse) {
+ stepX = 0.0f - scaleX * _nextStepX;
+ stepY = 0.0f - scaleY * _nextStepY;
+ } else {
+ stepX = scaleX * _prevStepX;
+ stepY = scaleY * _prevStepY;
+ }
+
+ const float oldCenterX = x + oldWidth * 0.5f;
+ const float oldCenterY = y + oldHeight * 0.5f;
+
+ const Dims texture = _curPhase->getDimensions();
+ const float halfWidth = texture.x * 0.5f * scaleX;
+ const float halfHeight = texture.y * 0.5f * scaleX;
+ float dx = ((x + stepX) + halfWidth) - oldCenterX;
+ const float dy = ((y + stepY) + halfHeight) - oldCenterY;
+ if (mirror)
+ dx = -dx;
+
+ const float c = cosf(rotation);
+ const float sn = sinf(rotation);
+ x = ((oldCenterX + (dx * c)) - (dy * sn)) - halfWidth;
+ y = ((oldCenterY + (dx * sn)) + (dy * c)) - halfHeight;
}
void Movement::gotoFirstFrame() {
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 1910be0d180..cd154356e44 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -182,8 +182,10 @@ class Movement : public GameObject {
void removeFirstPhase();
bool setNext(void (*_callback1)(int, Common::Point *point, int, int), void (*callback2)(int *), bool mirror = false);
bool gotoPrevFrame(bool mirror = false);
- /** CMovement::SetFrame (EF8B8) */
- void setFrame(int frame, bool mirror);
+ /** CMovement::SetFrame (EF8B8): moves the top left x, y by the offset of the frame */
+ void setFrame(int frame, float &x, float &y, bool mirror);
+ /** CMovement::Start (EFC96): moves the top left by the previous step (reverse: the next, back) */
+ void start(float &x, float &y, float oldWidth, float oldHeight, float scaleX, float scaleY, float rotation, bool mirror, bool reverse);
void gotoFirstFrame();
void setLast();
/** CMovement::Stop (EEE70); width and height: the size of the end statics */
@@ -236,11 +238,17 @@ public:
~AniObject() override;
AniObject(AniObject *src);
- /** the Windows view of the position (the pivot), docs/float-model-plan.md */
- int pivotX() const { return static_cast<int>(_x); }
- int pivotY() const { return static_cast<int>(_y); }
- void setPivotX(int x) { _x = x; }
- void setPivotY(int y) { _y = y; }
+ /** the Windows view of the position, the pivot (_x/_y hold the top left from 201509) */
+ int pivotX() const override;
+ int pivotY() const override;
+ void setPivotX(int x);
+ void setPivotY(int y);
+ /** the pivot minus the top left: someXY of the current phase, mirrored with the flag 8 */
+ Common::Point pivotAnchor() const;
+ /** the top left of the texture as drawn */
+ Common::Point topLeft() const;
+ /** CVisibleObject::SetPos (EEACC) for 201509: the stored top left */
+ void setTopLeft(Common::Point topLeft) override;
bool load(MfcArchive &file) override;
@@ -302,6 +310,7 @@ public:
bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false, bool cycled = false, bool reverse = false, int startFrame = -1,
bool silent = false);
void startMovementWithoutPhases(Movement *movement, bool mirror, bool reverse, int startFrame);
+ bool startMovementTimed(Movement *mov, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame, bool silent);
bool startAnimEx(int movid, int parId, int flag1, int flag2);
void startSliding(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex, bool mirror, bool cycled = false);
@@ -367,6 +376,9 @@ public:
bool hit(int x, int y);
private:
+ /** the stored position, see pivotX; the Movement keeps a copy of the pivot for the Windows code */
+ void storeTopLeft(float x, float y);
+
using GameObject::_x;
using GameObject::_y;
};
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index f95e555cee4..b31f4005bbd 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1700,6 +1700,12 @@ private:
_scene._aniObjects.back()->_movements.back()->updateCurrDynamicPhase();
if (node->name == "OLDANI" && !_scene._aniObjects.back()->_statics)
return parserError("Missing initial statics for animation");
+ if ((node->name == "OLDANI" || node->name == "ANI") && g_ngi->_gameVersion >= 201509 && _scene._aniObjects.back()->_statics) {
+ // CAniObject::Init (F29FC): the XML x, y is the pivot, SetStatic adds the offset of the statics
+ AniObject &animation = *_scene._aniObjects.back();
+ const GameObject &stored = animation;
+ animation.setPos(stored._x, stored._y);
+ }
return true;
}
diff --git a/engines/ngi/zcontroller.cpp b/engines/ngi/zcontroller.cpp
index 0325d0d3cd5..242c4f72d7b 100644
--- a/engines/ngi/zcontroller.cpp
+++ b/engines/ngi/zcontroller.cpp
@@ -43,7 +43,7 @@ void ZController::addItem(GameObject *object, int startY, bool changeZ, bool cha
void ZController::update() {
for (Item &item : _items) {
if (item.changeY || item.pending) {
- item.startY = item.object->_y + item.object->getSize().y;
+ item.startY = item.object->pivotY() + item.object->getSize().y;
item.pending = false;
}
}
@@ -76,7 +76,7 @@ void ZController::renderDebug() const {
Graphics::ManagedSurface &target = g_ngi->_backgroundSurface;
const uint32 white = target.format.RGBToColor(255, 255, 255);
for (const Item &item : _items) {
- const int x = item.object->_x;
+ const int x = item.object->pivotX();
target.fillRect(Common::Rect(x, item.startY, x + item.object->getSize().x, item.startY + 5), white);
}
}
Commit: 374dc10c834318577079ad886a04765903efcbed
https://github.com/scummvm/scummvm/commit/374dc10c834318577079ad886a04765903efcbed
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: CFlyPack::AddFly sets the static and the center like the original
Changed paths:
engines/ngi/fullpipe/floaters.cpp
diff --git a/engines/ngi/fullpipe/floaters.cpp b/engines/ngi/fullpipe/floaters.cpp
index 94910c7b08e..c92b20ce291 100644
--- a/engines/ngi/fullpipe/floaters.cpp
+++ b/engines/ngi/fullpipe/floaters.cpp
@@ -84,9 +84,14 @@ void FlyPack::addFly(Scene *sc, int x, int y, int priority, int flags) {
if (android)
ani->_copyId = ++_flyCounter;
- ani->_statics = ani->getStatic(ST_FLY_FLY);
- ani->_movement = nullptr;
- ani->setPos(x, y);
+ if (android) {
+ ani->setStatic(ST_FLY_FLY);
+ ani->setCenter(Common::Point(x, y));
+ } else {
+ ani->_statics = ani->getStatic(ST_FLY_FLY);
+ ani->_movement = nullptr;
+ ani->setPos(x, y);
+ }
ani->_flags |= 4;
ani->_z = priority;
@@ -101,7 +106,10 @@ void FlyPack::addFly(Scene *sc, int x, int y, int priority, int flags) {
else
nummoves = ani->_movement->_phases.size();
- ani->_movement->setCurFrame(g_ngi->_rnd.getRandomNumber(nummoves - 1));
+ if (android)
+ ani->setCurFrame(g_ngi->_rnd.getRandomNumber(nummoves - 1), true, false); // CAniObject::SetCurFrame (F0C76)
+ else
+ ani->_movement->setCurFrame(g_ngi->_rnd.getRandomNumber(nummoves - 1));
_flies.push_back(GutlFly());
GutlFly &arr2 = _flies.back();
Commit: 743acfe0e32d7c8ca4f82b436f188e128588c22b
https://github.com/scummvm/scummvm/commit/743acfe0e32d7c8ca4f82b436f188e128588c22b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Saves by target name, footer version 4, extension block, Android load and autosave on quit
Changed paths:
A engines/ngi/fullpipe/mobile/savesections.cpp
A engines/ngi/saveext.cpp
A engines/ngi/saveext.h
engines/ngi/fullpipe/mobile/achievements.cpp
engines/ngi/fullpipe/mobile/achievements.h
engines/ngi/fullpipe/mobile/controllerhelpers.cpp
engines/ngi/fullpipe/mobile/settings.h
engines/ngi/gameloader.h
engines/ngi/metaengine.cpp
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/stateloader.cpp
engines/ngi/statesaver.cpp
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/mobile/achievements.cpp b/engines/ngi/fullpipe/mobile/achievements.cpp
index c5c5d866343..5307f9de40e 100644
--- a/engines/ngi/fullpipe/mobile/achievements.cpp
+++ b/engines/ngi/fullpipe/mobile/achievements.cpp
@@ -350,6 +350,18 @@ void AchievementsManager::cleanXml() {
achievement->cleanXml();
}
+// stands in for achievements.sav: the achievements that ScummVM keeps
+void AchievementsManager::loadFromAchMan() {
+ if (!AchMan.isReady())
+ return;
+ for (Achievement *achievement : _achievements) {
+ if (AchMan.isAchieved(achievement->_id)) {
+ achievement->_state = Achievement::kReached;
+ achievement->_curActivatingCounter = 100;
+ }
+ }
+}
+
// CAchievementsManager::OnUpdate (145500)
void AchievementsManager::onUpdate(uint32 elapsed) {
for (Achievement *achievement : _achievements)
diff --git a/engines/ngi/fullpipe/mobile/achievements.h b/engines/ngi/fullpipe/mobile/achievements.h
index 65babd7e76e..04c244aaada 100644
--- a/engines/ngi/fullpipe/mobile/achievements.h
+++ b/engines/ngi/fullpipe/mobile/achievements.h
@@ -136,6 +136,8 @@ public:
void setXmlData(const XmlNode &node);
/** CAchievementsManager::CleanXml (14620E, slot 5) */
void cleanXml();
+ /** achievements.sav is the achievements of the ScummVM: the reached ones are reached, no banner */
+ void loadFromAchMan();
void onUpdate(uint32 elapsed); // 145500
void onRender(float x, float y); // 145524
diff --git a/engines/ngi/fullpipe/mobile/controllerhelpers.cpp b/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
index 194af6209e0..70549bc962b 100644
--- a/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
+++ b/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
@@ -31,6 +31,7 @@
#include "ngi/fullpipe/mobile/catalog.h"
#include "ngi/fullpipe/mobile/controllerhelpers.h"
#include "ngi/fullpipe/mobile/fpcontroller.h"
+#include "ngi/fullpipe/mobile/settings.h"
namespace NGI {
@@ -155,8 +156,11 @@ void warnOnce(const char *what) {
}
}
-void setSaving(bool) {
- warnOnce("CBaseSettings::SetSaving (the saves are not blocked while the arcade runs)");
+// CBaseSettings::SetSaving (ED21E): the save comes first when the saving goes off
+void setSaving(bool allowed) {
+ if (!allowed)
+ g_ngi->saveSettings();
+ g_ngi->settings().setSavingFlag(allowed);
}
// CCatalogManager::UnlockItem
diff --git a/engines/ngi/fullpipe/mobile/savesections.cpp b/engines/ngi/fullpipe/mobile/savesections.cpp
new file mode 100644
index 00000000000..c4ff40febaf
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/savesections.cpp
@@ -0,0 +1,207 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/serializer.h"
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/saveext.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/mobile/achievements.h"
+#include "ngi/fullpipe/mobile/arcadeinterface.h"
+#include "ngi/fullpipe/mobile/catalog.h"
+#include "ngi/fullpipe/mobile/chaptermanager.h"
+#include "ngi/fullpipe/mobile/controllerhelpers.h"
+#include "ngi/fullpipe/mobile/exitmanager.h"
+#include "ngi/fullpipe/mobile/help.h"
+#include "ngi/fullpipe/mobile/hintmanager.h"
+#include "ngi/fullpipe/mobile/map.h"
+#include "ngi/fullpipe/mobile/settings.h"
+#include "ngi/fullpipe/mobile/statemanager.h"
+#include "ngi/fullpipe/mobile/taskmanager.h"
+#include "ngi/fullpipe/mobile/tutorialmanager.h"
+
+namespace NGI {
+
+// The sections of the extension block, in the order of CSettings::Save (19F138)
+enum {
+ kSectionGame = MKTAG('G', 'A', 'M', 'E'),
+ kSectionSettings = MKTAG('S', 'E', 'T', 'T'),
+ kSectionChapter = MKTAG('C', 'H', 'A', 'P'),
+ kSectionTask = MKTAG('T', 'A', 'S', 'K'),
+ kSectionCatalog = MKTAG('C', 'A', 'T', 'A'),
+ kSectionHelp = MKTAG('H', 'E', 'L', 'P'),
+ kSectionHint = MKTAG('H', 'I', 'N', 'T'),
+ kSectionArcade = MKTAG('A', 'R', 'C', 'D')
+};
+
+// The managers whose state is a section: one function syncs a section for saving and loading
+static const uint32 kManagerSections[] = {
+ kSectionChapter, kSectionTask, kSectionCatalog, kSectionHelp, kSectionHint, kSectionArcade
+};
+
+void NGIEngine::syncSaveSection(uint32 tag, Common::Serializer &serializer) {
+ switch (tag) {
+ case kSectionChapter:
+ _chapterManager->syncGame(serializer);
+ break;
+ case kSectionTask:
+ _taskManager->syncGame(serializer);
+ break;
+ case kSectionCatalog:
+ _catalogManager->syncGame(serializer);
+ break;
+ case kSectionHelp:
+ _help->syncGame(serializer);
+ break;
+ case kSectionHint:
+ _hintManager->syncGame(serializer);
+ break;
+ case kSectionArcade:
+ arcadeInterface().syncProgress(serializer);
+ break;
+ default:
+ break;
+ }
+}
+
+// CGame::GetXmlData (FCEB0, the scene of the load list) and CSettings::GetXmlData (19E14C)
+void NGIEngine::writeSaveSections(SaveExtension &extension) {
+ // a scene that waits to be entered replaces the current one (the first scene after a restart)
+ int32 sceneId = _currentScene ? _currentScene->_sceneId : 0;
+
+ if (_gameLoader && _gameLoader->_preloadSceneId)
+ sceneId = _gameLoader->_preloadSceneId;
+
+ {
+ Common::MemoryWriteStreamDynamic stream(DisposeAfterUse::YES);
+ stream.writeSint32LE(sceneId);
+ extension.add(kSectionGame, stream);
+ }
+ {
+ Common::MemoryWriteStreamDynamic stream(DisposeAfterUse::YES);
+ stream.writeByte(settings().getIsCompleted());
+ extension.add(kSectionSettings, stream);
+ }
+
+ // the order of CSettings::Save; the achievements are the ones of the ScummVM (AchMan)
+ for (uint i = 0; i < ARRAYSIZE(kManagerSections); i++) {
+ Common::MemoryWriteStreamDynamic stream(DisposeAfterUse::YES);
+ Common::Serializer serializer(nullptr, &stream);
+
+ syncSaveSection(kManagerSections[i], serializer);
+ extension.add(kManagerSections[i], stream);
+ }
+}
+
+// CSettings::Load (19F210), CBaseSettings::Load (ED27A), CGame::SetXmlData (FC400); a save without
+// the extension block gives the defaults of every manager
+bool NGIEngine::readSaveSections(const SaveExtension *extension, GameVar *objectStates) {
+ warnOnce("CGame::CleanXml(0) (load list, CInventory, CInteractionController, scenes) is not ported");
+ warnOnce("CStateManager::CleanXml is not ported (SetStartStates)");
+ warnOnce("CTremble::CleanXml and CFlurryEventManager::CleanXml are not ported");
+ if (_map)
+ _map->cleanXml();
+ if (_exitManager)
+ _exitManager->cleanXml();
+ if (_taskManager)
+ _taskManager->cleanXml();
+ if (_tutorialManager)
+ _tutorialManager->cleanXml();
+ if (_achievementsManager)
+ _achievementsManager->cleanXml();
+ if (_chapterManager)
+ _chapterManager->cleanXml();
+ if (_catalogManager)
+ _catalogManager->cleanXml();
+ arcadeInterface().cleanProgress();
+
+ if (_sceneStack.size() > 1) {
+ Scene *scene = getSceneInStack(0);
+ if (scene) {
+ scene->removeCopies();
+ scene->stopAllQueues();
+ }
+ removeSceneInStack(0);
+ }
+
+ // CGame::LoadXml(0) enters the saved scene by its entrance 0
+ int32 sceneId = 0;
+ if (objectStates) {
+ GameVar *saved = objectStates->getSubVarByName("SAVEGAME");
+ if (saved)
+ sceneId = saved->getSubVarAsInt("Scene");
+ }
+
+ const SaveExtension::Section *game = extension ? extension->find(kSectionGame) : nullptr;
+ if (game && game->data.size() == 4)
+ sceneId = (int32)READ_LE_UINT32(game->data.data());
+ const SaveExtension::Section *settingsSection = extension ? extension->find(kSectionSettings) : nullptr;
+ if (settingsSection && settingsSection->data.size() == 1)
+ settings().setIsCompleted(settingsSection->data[0] != 0);
+
+ if (_stateManager && objectStates)
+ _stateManager->syncFromGameVar(objectStates);
+
+ // the achievements of the ScummVM stand in for achievements.sav
+ if (_achievementsManager)
+ _achievementsManager->loadFromAchMan();
+
+ for (uint i = 0; extension && i < ARRAYSIZE(kManagerSections); i++) {
+ const SaveExtension::Section *section = extension->find(kManagerSections[i]);
+ if (!section)
+ continue;
+
+ Common::MemoryReadStream stream(section->data.data(), section->data.size());
+ Common::Serializer serializer(&stream, nullptr);
+
+ syncSaveSection(kManagerSections[i], serializer);
+ if (stream.eos() || stream.pos() != stream.size())
+ warning("The save section %08x does not match the game data (%d of %d bytes read)",
+ kManagerSections[i], (int)stream.pos(), (int)stream.size());
+ }
+
+ if (sceneId)
+ _gameLoader->preloadScene(sceneId, 0);
+ else
+ warning("The savegame has no scene to enter");
+
+ return sceneId != 0;
+}
+
+// CBaseSettings::Save (ED264): the original writes the files of the managers, here the autosave
+void NGIEngine::saveSettings() {
+ if (settings().getSaving())
+ saveAutosaveIfEnabled();
+}
+
+void NGIEngine::autosaveOnQuit() {
+ if (usesXMLProject() && _gameLoader && _currentScene)
+ saveAutosaveIfEnabled();
+}
+
+bool NGIEngine::canSaveGameStateCurrently(Common::U32String *) {
+ if (usesXMLProject())
+ return _gameLoader && _currentScene && settings().getSaving();
+ return _isSaveAllowed;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mobile/settings.h b/engines/ngi/fullpipe/mobile/settings.h
index 3f7c97e80f5..8f14e20c06e 100644
--- a/engines/ngi/fullpipe/mobile/settings.h
+++ b/engines/ngi/fullpipe/mobile/settings.h
@@ -27,7 +27,7 @@ namespace NGI {
// CSettings (19EB48), CGame +112: flag bytes only, no settings file and no purchases
class Settings {
public:
- Settings() : _sendNotif(true), _reviewState(false), _isFull(true), _isCompleted(false), _debugPurchase(false) {}
+ Settings() : _saving(true), _sendNotif(true), _reviewState(false), _isFull(true), _isCompleted(false), _debugPurchase(false) {}
// CSettings::GetReviewState (19DEA4)
bool getReviewState() const {
@@ -70,12 +70,22 @@ public:
_isFull = full;
}
+ // CBaseSettings +28: saving is on (CBaseSettings::SetSaving saves first when it goes off)
+ bool getSaving() const {
+ return _saving;
+ }
+
+ void setSavingFlag(bool saving) {
+ _saving = saving;
+ }
+
// CSettings::SetSendNotif (19DF16), PP_cancelAllNotifications is not ported
void setSendNotif(bool send) {
_sendNotif = send;
}
private:
+ bool _saving; // +28
bool _sendNotif; // +36
bool _reviewState; // +37
bool _isFull; // +38
diff --git a/engines/ngi/gameloader.h b/engines/ngi/gameloader.h
index 7a31a162547..669c2f235d3 100644
--- a/engines/ngi/gameloader.h
+++ b/engines/ngi/gameloader.h
@@ -31,7 +31,7 @@
namespace NGI {
-#define NGI_SAVEGAME_VERSION 2
+#define NGI_SAVEGAME_VERSION 4
class SceneTag;
class MctlCompound;
@@ -106,7 +106,7 @@ class GameLoader : public CObject {
PicAniInfoList savePicAniInfos(Scene *sc, int flag1, int flag2);
bool readSavegame(const char *fname);
- bool writeSavegame(Scene *sc, const char *fname, const Common::String &description);
+ bool writeSavegame(Scene *sc, const char *fname, const Common::String &description, bool isAutosave = false);
void addVar(GameVar *var, GameVar *subvar);
diff --git a/engines/ngi/metaengine.cpp b/engines/ngi/metaengine.cpp
index 6d33bf8386e..c76a308d683 100644
--- a/engines/ngi/metaengine.cpp
+++ b/engines/ngi/metaengine.cpp
@@ -112,19 +112,26 @@ public:
Common::KeymapArray initKeymaps(const char *target) const override;
- Common::String getSavegameFile(int saveGameIdx, const char *target) const override {
- if (saveGameIdx == kSavegameFilePattern) {
- // Pattern requested
- const char *pattern = "%s.s##";
- return Common::String::format(pattern, "fullpipe");
- } else {
- // Specific filename requested
- const char *pattern = "%s.s%02d";
- return Common::String::format(pattern, "fullpipe", saveGameIdx);
- }
- }
+ Common::String getSavegameFile(int saveGameIdx, const char *target) const override;
};
+// Only the Windows Full Pipe keeps the save names of the original game (fullpipe.sNN, the format of
+// the old engine); a target without a platform is a Windows one, as it was before the Android build
+static bool usesWindowsSaveNames(const char *target) {
+ if (!target || !ConfMan.hasKey("gameid", target) || ConfMan.get("gameid", target) != "fullpipe")
+ return false;
+ return !ConfMan.hasKey("platform", target) || Common::parsePlatform(ConfMan.get("platform", target)) != Common::kPlatformAndroid;
+}
+
+Common::String NGIMetaEngine::getSavegameFile(int saveGameIdx, const char *target) const {
+ if (usesWindowsSaveNames(target)) {
+ if (saveGameIdx == kSavegameFilePattern)
+ return "fullpipe.s##";
+ return Common::String::format("fullpipe.s%02d", saveGameIdx);
+ }
+ return AdvancedMetaEngine<NGI::NGIGameDescription>::getSavegameFile(saveGameIdx, target);
+}
+
bool NGIMetaEngine::hasFeature(MetaEngineFeature f) const {
return checkExtendedSaves(f) || (f == kSupportsLoadingDuringStartup);
}
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 7a688ec05ac..d447c481d33 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -29,6 +29,7 @@ MODULE_OBJS = \
physjoint.o \
preloadmanager.o \
region.o \
+ saveext.o \
scene.o \
scenecontroller.o \
sceneobjects.o \
@@ -110,6 +111,7 @@ MODULE_OBJS = \
fullpipe/mobile/noactionlogger.o \
fullpipe/mobile/notebook.o \
fullpipe/mobile/objhelper.o \
+ fullpipe/mobile/savesections.o \
fullpipe/mobile/sc01controller.o \
fullpipe/mobile/sc02controller.o \
fullpipe/mobile/sc03controller.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index d4a5ec795b3..e621f92e25b 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -276,21 +276,21 @@ bool NGIEngine::shouldQuit() {
Common::Error NGIEngine::loadGameState(int slot) {
deleteModalObject();
- if (_gameLoader->readSavegame(g_ngi->getMetaEngine()->getSavegameFile(slot,"fullpipe").c_str()))
+ if (_gameLoader->readSavegame(getMetaEngine()->getSavegameFile(slot, _targetName.c_str()).c_str()))
return Common::kNoError;
else
- return Common::kUnknownError;
+ return Common::kReadingFailed;
}
Common::Error NGIEngine::saveGameState(int slot, const Common::String &description, bool isAutosave) {
- if (_gameLoader->writeSavegame(_currentScene, g_ngi->getMetaEngine()->getSavegameFile(slot,"fullpipe").c_str(), description))
+ if (_gameLoader->writeSavegame(_currentScene, getMetaEngine()->getSavegameFile(slot, _targetName.c_str()).c_str(), description, isAutosave))
return Common::kNoError;
else
- return Common::kUnknownError;
+ return Common::kWritingFailed;
}
Common::String NGIEngine::getSaveStateName(int slot) const {
- return Common::String::format("%s.s%02d", getGameId(), slot);
+ return getMetaEngine()->getSavegameFile(slot, _targetName.c_str());
}
Common::Error NGIEngine::initGame() {
@@ -525,6 +525,12 @@ Common::Error NGIEngine::run() {
_system->copyRectToScreen(_backgroundSurface.getPixels(), _backgroundSurface.pitch, 0, 0, _backgroundSurface.w, height);
_system->updateScreen();
debugC(1, kDebugDrawing, "Presented first Full Pipe frame for %s", start->_tag.c_str());
+ // the launcher (or -x) loads a save when the game stands: the main screen is shown first
+ if (ConfMan.hasKey("save_slot") && canLoadGameStateCurrently()) {
+ const Common::Error loaded = loadGameState(ConfMan.getInt("save_slot"));
+ if (loaded.getCode() != Common::kNoError)
+ warning("Could not load the save slot %d: %s", ConfMan.getInt("save_slot"), loaded.getDesc().c_str());
+ }
}
#ifdef USE_IMGUI
@@ -629,6 +635,9 @@ bool NGIEngine::updateEvents() {
bool redraw = false;
while (eventMan->pollEvent(event)) {
+ // the quit and the return to the launcher save the game when the autosave is on (period not 0)
+ if (event.type == Common::EVENT_QUIT || event.type == Common::EVENT_RETURN_TO_LAUNCHER)
+ autosaveOnQuit();
// the game works in the coordinates of its 800x600 area, not of the widescreen
event.mouse.x -= _wideOfs;
if (_gameVersion >= 201509) {
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 7d7c6bdfb85..04c97fbf775 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -41,6 +41,10 @@ namespace Audio {
class SoundHandle;
}
+namespace Common {
+class Serializer;
+}
+
namespace NGI {
enum {
@@ -106,6 +110,7 @@ class ExitManager;
class Tremble;
class Map;
class Settings;
+class SaveExtension;
class PhysMaterials;
class PhysRegistrator;
class ArcadeInterface;
@@ -541,8 +546,18 @@ public:
Common::Error saveGameState(int slot, const Common::String &description, bool isAutosave = false) override;
Common::String getSaveStateName(int slot) const override;
- bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return !usesXMLProject(); }
- bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
+ bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return !usesXMLProject() || _gameVersion >= 201509; }
+ bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
+
+ // the extension block of a savegame of an XML project (fullpipe/mobile/savesections.cpp)
+ void writeSaveSections(SaveExtension &extension);
+ void syncSaveSection(uint32 tag, Common::Serializer &serializer);
+ // CSettings::Load (19F210); false when the save has no scene to enter
+ bool readSaveSections(const SaveExtension *extension, GameVar *objectStates);
+ /** CBaseSettings::Save (ED264): the autosave of the ScummVM when the saving is on */
+ void saveSettings();
+ /** the engine asked to quit or to return to the launcher: the autosave of the period (not at 0) */
+ void autosaveOnQuit();
bool hasFeature(EngineFeature f) const override;
};
diff --git a/engines/ngi/saveext.cpp b/engines/ngi/saveext.cpp
new file mode 100644
index 00000000000..3e9d115bdc9
--- /dev/null
+++ b/engines/ngi/saveext.cpp
@@ -0,0 +1,96 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/saveext.h"
+
+namespace NGI {
+
+void SaveExtension::add(uint32 tag, Common::MemoryWriteStreamDynamic &stream) {
+ Section section;
+
+ section.tag = tag;
+ section.data.resize(stream.size());
+ if (stream.size())
+ memcpy(section.data.data(), stream.getData(), stream.size());
+ _sections.push_back(section);
+}
+
+const SaveExtension::Section *SaveExtension::find(uint32 tag, uint index) const {
+ for (uint i = 0; i < _sections.size(); i++) {
+ if (_sections[i].tag == tag && index-- == 0)
+ return &_sections[i];
+ }
+ return nullptr;
+}
+
+void SaveExtension::write(Common::WriteStream &out) const {
+ uint32 length = 0;
+
+ for (uint i = 0; i < _sections.size(); i++)
+ length += 8 + _sections[i].data.size();
+
+ out.writeUint32BE(MKTAG('N', 'G', 'I', 'X'));
+ out.writeByte(kVersion);
+ out.writeUint32LE(_gameVersion);
+ out.writeUint32LE(length);
+
+ for (uint i = 0; i < _sections.size(); i++) {
+ out.writeUint32LE(_sections[i].tag);
+ out.writeUint32LE(_sections[i].data.size());
+ if (!_sections[i].data.empty())
+ out.write(_sections[i].data.data(), _sections[i].data.size());
+ }
+}
+
+bool SaveExtension::read(Common::SeekableReadStream &in, uint32 available) {
+ _sections.clear();
+
+ if (available < kHeaderSize || in.readUint32BE() != MKTAG('N', 'G', 'I', 'X'))
+ return false;
+
+ const byte version = in.readByte();
+ _gameVersion = in.readUint32LE();
+ uint32 length = in.readUint32LE();
+
+ // a newer block version may add fields to the header, the sections stay readable
+ if (version < kVersion || length > available - kHeaderSize)
+ return false;
+
+ while (length >= 8) {
+ Section section;
+
+ section.tag = in.readUint32LE();
+ const uint32 size = in.readUint32LE();
+ length -= 8;
+ if (size > length)
+ return false;
+
+ section.data.resize(size);
+ if (size && in.read(section.data.data(), size) != size)
+ return false;
+ length -= size;
+ _sections.push_back(section);
+ }
+
+ return true;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/saveext.h b/engines/ngi/saveext.h
new file mode 100644
index 00000000000..9b7962eb6a3
--- /dev/null
+++ b/engines/ngi/saveext.h
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_SAVEEXT_H
+#define NGI_SAVEEXT_H
+
+#include "common/array.h"
+#include "common/stream.h"
+#include "common/memstream.h"
+
+namespace NGI {
+
+// The extension block of a savegame of an XML project, before the ScummVM footer. Readers of the
+// original format find the footer by the last four bytes and never see it. A section is
+// {u32 tag, u32 length, bytes}, unknown sections are skipped.
+class SaveExtension {
+public:
+ enum {
+ kVersion = 1,
+ kHeaderSize = 13 // "NGIX", u8 version, u32 game version, u32 length of the sections
+ };
+
+ struct Section {
+ uint32 tag;
+ Common::Array<byte> data;
+ };
+
+ SaveExtension() : _gameVersion(0) {}
+
+ void add(uint32 tag, Common::MemoryWriteStreamDynamic &stream);
+ /** the index-th section of the tag, or null */
+ const Section *find(uint32 tag, uint index = 0) const;
+ void write(Common::WriteStream &out) const;
+ /** reads the block at the position of the stream when there is one; false when there is none */
+ bool read(Common::SeekableReadStream &in, uint32 available);
+
+ uint32 _gameVersion;
+ Common::Array<Section> _sections;
+};
+
+} // End of namespace NGI
+
+#endif
diff --git a/engines/ngi/stateloader.cpp b/engines/ngi/stateloader.cpp
index 1628b8b7f03..0b3e8aba0b8 100644
--- a/engines/ngi/stateloader.cpp
+++ b/engines/ngi/stateloader.cpp
@@ -27,6 +27,7 @@
#include "ngi/gameloader.h"
#include "ngi/interaction.h"
#include "ngi/objects.h"
+#include "ngi/saveext.h"
#include "ngi/scene.h"
#include "ngi/statics.h"
@@ -83,15 +84,37 @@ bool GameLoader::readSavegame(const char *fname) {
Common::Array<byte> data(header.encSize);
saveFile->read(data.data(), header.encSize);
+ // the XML projects write no map table, but an extension block (see SaveExtension)
+ const bool xmlProject = g_ngi->usesXMLProject();
Common::Array<byte> map(800);
- saveFile->read(map.data(), 800);
+ if (!xmlProject)
+ saveFile->read(map.data(), 800);
+
+ SaveExtension extension;
+ bool hasExtension = false;
+ {
+ // the footer is found by the pointer in the last four bytes
+ const uint32 extensionPos = saveFile->pos();
+ saveFile->seek(-4, SEEK_END);
+ const uint32 footerPos = saveFile->readUint32LE();
+ saveFile->seek(extensionPos, SEEK_SET);
+ if (footerPos > extensionPos)
+ hasExtension = extension.read(*saveFile, footerPos - extensionPos);
+ saveFile->seek(extensionPos, SEEK_SET);
+ }
+
+ // a save of another engine version is refused, the save names cannot clash
+ if (hasExtension && extension._gameVersion != (uint32)g_ngi->_gameVersion) {
+ warning("The save was made by the engine version %u, this one is %d", extension._gameVersion, g_ngi->_gameVersion);
+ return false;
+ }
ExtendedSavegameHeader header2;
if (MetaEngine::readSavegameHeader(saveFile.get(), &header2)) {
g_ngi->setTotalPlayTime(header2.playtime * 1000);
}
- {
+ if (!xmlProject) {
Common::MemoryReadStream tempStream(map.data(), 800, DisposeAfterUse::NO);
MfcArchive temp(&tempStream);
@@ -125,9 +148,6 @@ bool GameLoader::readSavegame(const char *fname) {
if (var)
deleteLoadedVars(var);
- // the 2015 build keeps the object states in CStateManager, the savegame has them in the GameVar
- if (g_ngi->_stateManager)
- g_ngi->_stateManager->syncFromGameVar(v);
getGameLoaderInventory()->loadPartial(archive);
@@ -151,6 +171,10 @@ bool GameLoader::readSavegame(const char *fname) {
_sc2array[i]._isLoaded = false;
}
+ // XML projects: the objects are in CStateManager (the GameVar is its mirror), the rest in sections
+ if (xmlProject)
+ return g_ngi->readSaveSections(hasExtension ? &extension : nullptr, v);
+
getGameLoaderInventory()->recalcItemPos();
PreloadItem preloadItem;
diff --git a/engines/ngi/statesaver.cpp b/engines/ngi/statesaver.cpp
index d887e268d5e..afb3ffed7bb 100644
--- a/engines/ngi/statesaver.cpp
+++ b/engines/ngi/statesaver.cpp
@@ -28,10 +28,11 @@
#include "ngi/gameloader.h"
#include "ngi/objects.h"
+#include "ngi/saveext.h"
namespace NGI {
-bool GameLoader::writeSavegame(Scene *sc, const char *fname, const Common::String &description) {
+bool GameLoader::writeSavegame(Scene *sc, const char *fname, const Common::String &description, bool isAutosave) {
GameVar *v = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME");
if (!v) {
@@ -126,6 +127,15 @@ bool GameLoader::writeSavegame(Scene *sc, const char *fname, const Common::Strin
saveFile->write(stream.getData(), stream.size());
+ // the XML projects keep the state of their managers in the extension block, before the footer
+ if (g_ngi->usesXMLProject()) {
+ SaveExtension extension;
+
+ extension._gameVersion = g_ngi->_gameVersion;
+ g_ngi->writeSaveSections(extension);
+ extension.write(*saveFile);
+ }
+
uint headerPos = saveFile->pos();
ExtendedSavegameHeader header2;
@@ -151,7 +161,12 @@ bool GameLoader::writeSavegame(Scene *sc, const char *fname, const Common::Strin
saveFile->writeByte(desc.size());
saveFile->writeString(desc);
- g_ngi->_currentScene->render();
+ // Added in save version 4
+ saveFile->writeByte(isAutosave);
+
+ // the XML projects show the frame presented last (the autosave runs inside the event loop)
+ if (!g_ngi->usesXMLProject())
+ g_ngi->_currentScene->render();
Graphics::saveThumbnail(*saveFile); // FIXME. Render proper screen
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index b31f4005bbd..1ca43bf595d 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -2033,7 +2033,6 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_help.reset(new Help);
g_ngi->_help->init("data/help.xml");
g_ngi->_noActionLogger.reset(new NoActionLogger);
- warning("STUB: the task and catalog state are not saved yet (their syncGame is not hooked into the savegames)");
}
width = parser.width();
height = parser.height();
Commit: 3a882592f1274518de2bcec2b50d511c9e4ce2d8
https://github.com/scummvm/scummvm/commit/3a882592f1274518de2bcec2b50d511c9e4ce2d8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Sound volume curve and ConfMan settings, save sections of the managers, saving flag
Changed paths:
engines/ngi/fullpipe/mobile/controllerhelpers.cpp
engines/ngi/fullpipe/mobile/controllerhelpers.h
engines/ngi/fullpipe/mobile/exitmanager.cpp
engines/ngi/fullpipe/mobile/exitmanager.h
engines/ngi/fullpipe/mobile/inventorycontroller.cpp
engines/ngi/fullpipe/mobile/inventorycontroller.h
engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
engines/ngi/fullpipe/mobile/map.cpp
engines/ngi/fullpipe/mobile/map.h
engines/ngi/fullpipe/mobile/objhelper.cpp
engines/ngi/fullpipe/mobile/objhelper.h
engines/ngi/fullpipe/mobile/savesections.cpp
engines/ngi/fullpipe/mobile/sc22controller.cpp
engines/ngi/fullpipe/mobile/sc23controller.cpp
engines/ngi/fullpipe/mobile/tutorialmanager.cpp
engines/ngi/fullpipe/mobile/tutorialmanager.h
engines/ngi/inventory.cpp
engines/ngi/inventory.h
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/sound.cpp
engines/ngi/sound.h
engines/ngi/soundmanager.h
diff --git a/engines/ngi/fullpipe/mobile/controllerhelpers.cpp b/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
index 70549bc962b..b1782de9eca 100644
--- a/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
+++ b/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
@@ -106,6 +106,13 @@ bool isSoundPlayed(int soundId) {
return sound && sound->isPlaying();
}
+// CSoundManager::GetSound and CSound::Attenuate (124D40)
+void attenuateSound(int soundId, float volume, float pan) {
+ Sound *sound = g_ngi->findSound(soundId);
+ if (sound)
+ sound->attenuate(volume, pan);
+}
+
MessageQueue *copyQueue(Scene *scene, int queueId) {
MessageQueue *queue = scene->findMessageQueue(queueId);
if (!queue)
diff --git a/engines/ngi/fullpipe/mobile/controllerhelpers.h b/engines/ngi/fullpipe/mobile/controllerhelpers.h
index 9343ce66150..34f58fb2c7d 100644
--- a/engines/ngi/fullpipe/mobile/controllerhelpers.h
+++ b/engines/ngi/fullpipe/mobile/controllerhelpers.h
@@ -48,6 +48,7 @@ Command *setSceneCommand(int sceneId, int entranceId, const char *scene, const c
bool isState(const char *object, const char *state);
/** CSoundManager::IsPlayed */
bool isSoundPlayed(int soundId);
+void attenuateSound(int soundId, float volume, float pan);
/** FindQueue + CMessageQueue::CMessageQueue(CMessageQueue *): the copy of the queue of the scene */
MessageQueue *copyQueue(Scene *scene, int queueId);
diff --git a/engines/ngi/fullpipe/mobile/exitmanager.cpp b/engines/ngi/fullpipe/mobile/exitmanager.cpp
index cb3886fccb8..1ec658dcb59 100644
--- a/engines/ngi/fullpipe/mobile/exitmanager.cpp
+++ b/engines/ngi/fullpipe/mobile/exitmanager.cpp
@@ -21,6 +21,8 @@
#include "math/utils.h"
+#include "common/serializer.h"
+
#include "ngi/ngi.h"
#include "ngi/utils.h"
#include "ngi/font.h"
@@ -395,10 +397,16 @@ void ExitManager::init(const char *path, Scene *scene) {
exit->loadParam(root[i], *owner);
} else if (owner) {
exit = new Exit();
- if (exit->init(root[i], *owner))
+ if (exit->init(root[i], *owner)) {
_exits.push_back(exit);
- else
+ // the state of a loaded game (CExitManager::SetXmlData) is applied when the exit exists
+ if (_saved.contains(pictureId)) {
+ applySaved(pictureId, _saved[pictureId]);
+ _saved.erase(pictureId);
+ }
+ } else {
delete exit;
+ }
}
}
}
@@ -573,8 +581,73 @@ void ExitManager::setXmlData(const XmlNode &node) {
}
}
+void ExitManager::applySaved(uint pictureId, const SavedExit &saved) {
+ setExitState(pictureId, saved.state);
+ setExitAngle(pictureId, saved.angle);
+ resetExitIntersect(pictureId, saved.intersect);
+ setExitOffset(pictureId, saved.offsetX, saved.offsetY);
+}
+
+// CExit::GetXmlData (144940), CExitManager::GetXmlData (144A68): the exits in their order
+void ExitManager::syncGame(Common::Serializer &s) {
+ uint32 count = _exits.size();
+ if (s.isSaving()) {
+ // the exits of the scenes that did not load yet keep their saved state
+ count += _saved.size();
+ }
+ s.syncAsUint32LE(count);
+
+ if (s.isSaving()) {
+ for (uint i = 0; i < _exits.size(); i++) {
+ int32 id = _exits[i]->getVisId();
+ int32 state = _exits[i]->getState();
+ float angle = _exits[i]->getAngle();
+ bool intersect = _exits[i]->getIntersect();
+ float offsetX = _exits[i]->getOffsetX();
+ float offsetY = _exits[i]->getOffsetY();
+ s.syncAsSint32LE(id);
+ s.syncAsSint32LE(state);
+ s.syncAsFloatLE(angle);
+ s.syncAsByte(intersect);
+ s.syncAsFloatLE(offsetX);
+ s.syncAsFloatLE(offsetY);
+ }
+ for (Common::HashMap<int, SavedExit>::iterator it = _saved.begin(); it != _saved.end(); ++it) {
+ int32 id = it->_key;
+ int32 state = it->_value.state;
+ float angle = it->_value.angle;
+ bool intersect = it->_value.intersect;
+ float offsetX = it->_value.offsetX;
+ float offsetY = it->_value.offsetY;
+ s.syncAsSint32LE(id);
+ s.syncAsSint32LE(state);
+ s.syncAsFloatLE(angle);
+ s.syncAsByte(intersect);
+ s.syncAsFloatLE(offsetX);
+ s.syncAsFloatLE(offsetY);
+ }
+ return;
+ }
+
+ for (uint32 i = 0; i < count; i++) {
+ int32 id = 0;
+ SavedExit saved;
+ s.syncAsSint32LE(id);
+ s.syncAsSint32LE(saved.state);
+ s.syncAsFloatLE(saved.angle);
+ s.syncAsByte(saved.intersect);
+ s.syncAsFloatLE(saved.offsetX);
+ s.syncAsFloatLE(saved.offsetY);
+ if (find(id))
+ applySaved(id, saved);
+ else
+ _saved[id] = saved;
+ }
+}
+
// CExitManager::CleanXml (144F64): the exits are read again
void ExitManager::cleanXml() {
+ _saved.clear();
_sceneExits.clear();
init("data/exits.xml", nullptr);
}
diff --git a/engines/ngi/fullpipe/mobile/exitmanager.h b/engines/ngi/fullpipe/mobile/exitmanager.h
index 1e47f0e35d3..da875d17845 100644
--- a/engines/ngi/fullpipe/mobile/exitmanager.h
+++ b/engines/ngi/fullpipe/mobile/exitmanager.h
@@ -23,12 +23,17 @@
#define NGI_FULLPIPE_EXITMANAGER_H
#include "common/array.h"
+#include "common/hashmap.h"
#include "common/ptr.h"
#include "common/rect.h"
#include "common/str.h"
#include "ngi/xmlnode.h"
+namespace Common {
+class Serializer;
+}
+
namespace NGI {
class AniObject;
@@ -67,6 +72,9 @@ public:
void initPicPressed();
void stopRotate();
void setOffset(float x, float y);
+ bool getIntersect() const { return _intersect; }
+ float getOffsetX() const { return _offsetX; }
+ float getOffsetY() const { return _offsetY; }
void setFixedZ(bool fixedZ) { _fixedZ = fixedZ; }
/** CVisibleObject::Hit of the picture of the exit */
bool hitPicture(float x, float y) const;
@@ -130,8 +138,21 @@ public:
/** CExitManager::SetXmlData and CleanXml: the saved state */
void setXmlData(const XmlNode &node);
void cleanXml();
+ /** CExitManager::GetXmlData and SetXmlData for the savegames (_saved: scenes not loaded yet) */
+ void syncGame(Common::Serializer &s);
private:
+ struct SavedExit {
+ int state = 0;
+ float angle = 0;
+ bool intersect = false;
+ float offsetX = 0;
+ float offsetY = 0;
+ };
+
+ void applySaved(uint pictureId, const SavedExit &saved);
+
+ Common::HashMap<int, SavedExit> _saved;
Common::Array<Exit *> _exits; // +8
Common::Array<Exit *> _sceneExits; // +20
bool _pressed = false; // +32
diff --git a/engines/ngi/fullpipe/mobile/inventorycontroller.cpp b/engines/ngi/fullpipe/mobile/inventorycontroller.cpp
index 7da7a2321f0..be386bd514b 100644
--- a/engines/ngi/fullpipe/mobile/inventorycontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/inventorycontroller.cpp
@@ -21,6 +21,8 @@
#include "common/debug.h"
+#include "common/serializer.h"
+
#include "ngi/ngi.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/mobile/arcadeinterface.h"
@@ -47,6 +49,12 @@ void InventoryController::setXmlData(const XmlNode &node) {
_stateHintNotebook = node.attrInt("stateHintNotebook", 0);
}
+// CInventoryController::GetXmlData: stateHintMap, stateHintNotebook
+void InventoryController::syncGame(Common::Serializer &s) {
+ s.syncAsSint32LE(_stateHintMap);
+ s.syncAsSint32LE(_stateHintNotebook);
+}
+
void InventoryController::cleanXml() {
_stateHintMap = 0;
_stateHintNotebook = 0;
diff --git a/engines/ngi/fullpipe/mobile/inventorycontroller.h b/engines/ngi/fullpipe/mobile/inventorycontroller.h
index 246986d7d93..2b0b1f226ae 100644
--- a/engines/ngi/fullpipe/mobile/inventorycontroller.h
+++ b/engines/ngi/fullpipe/mobile/inventorycontroller.h
@@ -26,6 +26,10 @@
#include "ngi/scenecontroller.h"
+namespace Common {
+class Serializer;
+}
+
namespace NGI {
class GuiElement;
@@ -48,6 +52,8 @@ public:
/** CInventoryController::SetXmlData and CleanXml: the saved state of the hints */
void setXmlData(const XmlNode &node);
void cleanXml();
+ /** CInventoryController::GetXmlData and SetXmlData for the savegames: the two hint states */
+ void syncGame(Common::Serializer &s);
/** CInventoryController::ScrollIn / ScrollOut: the bar comes back / leaves the screen */
void scrollIn() { _scrollState = 2; }
diff --git a/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp b/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
index ebcdd6128b7..c830e9f6a1a 100644
--- a/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
@@ -35,6 +35,7 @@
#include "ngi/fullpipe/mobile/controllerhelpers.h"
#include "ngi/fullpipe/mobile/exitmanager.h"
#include "ngi/fullpipe/mobile/mainmenucontroller.h"
+#include "ngi/fullpipe/mobile/settings.h"
#include "ngi/fullpipe/mobile/map.h"
#include "ngi/fullpipe/mobile/taskmanager.h"
#include "ngi/fullpipe/mobile/tutorialmanager.h"
@@ -166,12 +167,14 @@ void MainMenuController::restartGame() {
// CFlurryEventManager::CleanXml: the analytics are not ported
g_ngi->arcadeInterface().cleanProgress();
- warnOnce("CGame::AddScenesInLoadList, CSettings::Save, CGame::ClearLoadList: the load list of the scenes and the settings are not ported");
+ warnOnce("CGame::AddScenesInLoadList and ClearLoadList: the load list of the scenes is not ported");
setScene(SC_INTRO1, 0);
+ // the two CSettings::Save calls of the original (all scenes, none) are one autosave here
+ g_ngi->saveSettings();
warnOnce("CObjHelperManager::SetObjHelperCount(0): not hooked here (ported separately)");
if (g_ngi->_inventory && g_ngi->_inventory->_guiManager)
g_ngi->_inventory->_guiManager->deselectAll();
- warnOnce("CSettings::SetIsCompleted(0): the settings are not ported");
+ g_ngi->settings().setIsCompleted(false);
}
// CMainMenu::EnableDebugMenu (19BCC4)
diff --git a/engines/ngi/fullpipe/mobile/map.cpp b/engines/ngi/fullpipe/mobile/map.cpp
index 6dde0529b3a..9d44e4b0c97 100644
--- a/engines/ngi/fullpipe/mobile/map.cpp
+++ b/engines/ngi/fullpipe/mobile/map.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/serializer.h"
+
#include "ngi/ngi.h"
#include "ngi/scene.h"
#include "ngi/fullpipe/constants.h"
@@ -75,6 +77,31 @@ void Map::setXmlData(const XmlNode &node) {
}
}
+// CMap::GetXmlData (156040), SetXmlData (157B60): the items and the tutorial of the scene SC_MAP
+void Map::syncGame(Common::Serializer &s) {
+ MapWindowController *controller = nullptr;
+ Scene *scene = g_ngi->findScene(SC_MAP);
+ if (scene && scene->_controller)
+ controller = static_cast<MapWindowController *>(scene->_controller.get());
+
+ s.syncAsSint32LE(_firstEnterToSc13);
+
+ uint32 count = _items.size();
+ s.syncAsUint32LE(count);
+ if (s.isLoading())
+ _items.resize(count);
+ for (uint32 i = 0; i < count; i++) {
+ s.syncAsSint32LE(_items[i].id);
+ s.syncAsSint32LE(_items[i].state);
+ s.syncAsByte(_items[i].dontEnter);
+ }
+
+ Common::String tutorial = controller ? controller->tutorial() : "TUTORIAL_USE_MAP";
+ s.syncString(tutorial);
+ if (s.isLoading() && controller)
+ controller->setTutorial(tutorial);
+}
+
// CMap::Reset (157CB4)
void Map::reset() {
_items.clear();
diff --git a/engines/ngi/fullpipe/mobile/map.h b/engines/ngi/fullpipe/mobile/map.h
index 8b4c54adb80..8865d009652 100644
--- a/engines/ngi/fullpipe/mobile/map.h
+++ b/engines/ngi/fullpipe/mobile/map.h
@@ -27,6 +27,10 @@
#include "ngi/xmlnode.h"
+namespace Common {
+class Serializer;
+}
+
namespace NGI {
/** CMap: the state of the map pictures (visited scenes, pipes, forbidden scenes) */
@@ -49,6 +53,8 @@ public:
void getXmlData();
/** CMap::SetXmlData (157B60) */
void setXmlData(const XmlNode &node);
+ /** CMap::GetXmlData (156040) and SetXmlData for the savegames: items and the map tutorial */
+ void syncGame(Common::Serializer &s);
/** CMap::Reset (157CB4): the map of a new game, the first scene and its pipe are shown */
void reset();
/** CMap::Update (157CD8): the shown scene and its entrance */
diff --git a/engines/ngi/fullpipe/mobile/objhelper.cpp b/engines/ngi/fullpipe/mobile/objhelper.cpp
index 3b8ccba9109..6c7dbb0e3d2 100644
--- a/engines/ngi/fullpipe/mobile/objhelper.cpp
+++ b/engines/ngi/fullpipe/mobile/objhelper.cpp
@@ -22,6 +22,8 @@
#include "common/debug.h"
#include "common/ptr.h"
+#include "common/serializer.h"
+
#include "ngi/ngi.h"
#include "ngi/gameloader.h"
#include "ngi/gfx.h"
@@ -296,6 +298,17 @@ void ObjHelperManager::setXmlData(const XmlNode &node) {
showPipeZone();
}
+// CObjHelperManager::GetXmlData (1609F0), SetXmlData (160E20)
+void ObjHelperManager::syncGame(Common::Serializer &s) {
+ s.syncAsUint16LE(_count);
+ if (s.isLoading()) {
+ hidePipeAction();
+ hidePipeZone();
+ showPipeAction();
+ showPipeZone();
+ }
+}
+
// CObjHelperManager::IsHitObjHelper (160C0A): circle of the glow width sitting on its bottom edge
bool ObjHelperManager::isHitObjHelper(Scene *scene, float x, float y) const {
if (!_helperAni)
diff --git a/engines/ngi/fullpipe/mobile/objhelper.h b/engines/ngi/fullpipe/mobile/objhelper.h
index c6b5f91a2c8..5d88eb1b88d 100644
--- a/engines/ngi/fullpipe/mobile/objhelper.h
+++ b/engines/ngi/fullpipe/mobile/objhelper.h
@@ -28,6 +28,10 @@
#include "ngi/xmlnode.h"
+namespace Common {
+class Serializer;
+}
+
namespace NGI {
class AniObject;
@@ -96,6 +100,8 @@ public:
void getXmlData();
/** CObjHelperManager::SetXmlData (160E20, slot 8): "objHelperCount" */
void setXmlData(const XmlNode &node);
+ /** GetXmlData and SetXmlData for the savegames */
+ void syncGame(Common::Serializer &s);
/** CObjHelperManager::SetObjHelperCount */
void setObjHelperCount(uint16 count) { _count = count; }
diff --git a/engines/ngi/fullpipe/mobile/savesections.cpp b/engines/ngi/fullpipe/mobile/savesections.cpp
index c4ff40febaf..9affbb2f85c 100644
--- a/engines/ngi/fullpipe/mobile/savesections.cpp
+++ b/engines/ngi/fullpipe/mobile/savesections.cpp
@@ -23,6 +23,7 @@
#include "ngi/ngi.h"
#include "ngi/gameloader.h"
+#include "ngi/inventory.h"
#include "ngi/saveext.h"
#include "ngi/scene.h"
#include "ngi/fullpipe/mobile/achievements.h"
@@ -32,8 +33,10 @@
#include "ngi/fullpipe/mobile/controllerhelpers.h"
#include "ngi/fullpipe/mobile/exitmanager.h"
#include "ngi/fullpipe/mobile/help.h"
+#include "ngi/fullpipe/mobile/inventorycontroller.h"
#include "ngi/fullpipe/mobile/hintmanager.h"
#include "ngi/fullpipe/mobile/map.h"
+#include "ngi/fullpipe/mobile/objhelper.h"
#include "ngi/fullpipe/mobile/settings.h"
#include "ngi/fullpipe/mobile/statemanager.h"
#include "ngi/fullpipe/mobile/taskmanager.h"
@@ -45,6 +48,12 @@ namespace NGI {
enum {
kSectionGame = MKTAG('G', 'A', 'M', 'E'),
kSectionSettings = MKTAG('S', 'E', 'T', 'T'),
+ kSectionInventory = MKTAG('I', 'N', 'V', 'T'),
+ kSectionInventoryController = MKTAG('I', 'C', 'T', 'L'),
+ kSectionMap = MKTAG('M', 'A', 'P', '_'),
+ kSectionExit = MKTAG('E', 'X', 'I', 'T'),
+ kSectionTutorial = MKTAG('T', 'U', 'T', 'O'),
+ kSectionObjHelper = MKTAG('O', 'B', 'J', 'H'),
kSectionChapter = MKTAG('C', 'H', 'A', 'P'),
kSectionTask = MKTAG('T', 'A', 'S', 'K'),
kSectionCatalog = MKTAG('C', 'A', 'T', 'A'),
@@ -55,11 +64,30 @@ enum {
// The managers whose state is a section: one function syncs a section for saving and loading
static const uint32 kManagerSections[] = {
- kSectionChapter, kSectionTask, kSectionCatalog, kSectionHelp, kSectionHint, kSectionArcade
+ kSectionInventory, kSectionInventoryController, kSectionMap, kSectionExit, kSectionChapter, kSectionTask,
+ kSectionTutorial, kSectionCatalog, kSectionHelp, kSectionObjHelper, kSectionHint, kSectionArcade
};
void NGIEngine::syncSaveSection(uint32 tag, Common::Serializer &serializer) {
switch (tag) {
+ case kSectionInventory:
+ _inventory->syncGame(serializer);
+ break;
+ case kSectionInventoryController:
+ static_cast<InventoryController *>(_inventory->_controller.get())->syncGame(serializer);
+ break;
+ case kSectionMap:
+ _map->syncGame(serializer);
+ break;
+ case kSectionExit:
+ _exitManager->syncGame(serializer);
+ break;
+ case kSectionTutorial:
+ _tutorialManager->syncGame(serializer);
+ break;
+ case kSectionObjHelper:
+ _objHelperManager->syncGame(serializer);
+ break;
case kSectionChapter:
_chapterManager->syncGame(serializer);
break;
@@ -115,7 +143,11 @@ void NGIEngine::writeSaveSections(SaveExtension &extension) {
// CSettings::Load (19F210), CBaseSettings::Load (ED27A), CGame::SetXmlData (FC400); a save without
// the extension block gives the defaults of every manager
bool NGIEngine::readSaveSections(const SaveExtension *extension, GameVar *objectStates) {
- warnOnce("CGame::CleanXml(0) (load list, CInventory, CInteractionController, scenes) is not ported");
+ warnOnce("CGame::CleanXml(0) (load list, CInteractionController, scenes) is not ported");
+ if (_inventory)
+ _inventory->cleanXml();
+ if (_inventory && _inventory->_controller)
+ static_cast<InventoryController *>(_inventory->_controller.get())->cleanXml();
warnOnce("CStateManager::CleanXml is not ported (SetStartStates)");
warnOnce("CTremble::CleanXml and CFlurryEventManager::CleanXml are not ported");
if (_map)
diff --git a/engines/ngi/fullpipe/mobile/sc22controller.cpp b/engines/ngi/fullpipe/mobile/sc22controller.cpp
index 52a16d462d0..ced0f310f4a 100644
--- a/engines/ngi/fullpipe/mobile/sc22controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc22controller.cpp
@@ -289,12 +289,10 @@ void Sc22Controller::onShow() {
_musicPlaying = false;
} else if (isState(sO_CoinSlot_22, sO_IsFull)) {
_scene->_behaviorController->disableAllMusic();
- if (isSoundPlayed(SND_MUS_SC04_LOOP)) {
- warnOnce("CSound::Attenuate with the music volume and pan 50 is not ported");
- } else {
- warnOnce("CSoundManager::Play with the music volume and pan 50 is not ported (plays at full volume)");
- g_ngi->playSound(SND_MUS_SC04_START, 0);
- }
+ if (isSoundPlayed(SND_MUS_SC04_LOOP))
+ attenuateSound(SND_MUS_SC04_LOOP, (float)g_ngi->getMusicSetting() * 0.5f, 50.0f);
+ else
+ g_ngi->playSound(SND_MUS_SC04_START, 0, 0, (float)g_ngi->getMusicSetting() * 0.5f, 50.0f);
_musicPlaying = true;
} else {
_scene->_behaviorController->enableAllMusic();
@@ -411,8 +409,7 @@ void Sc22Controller::onMessage(const Common::String &message, const Common::Stri
g_ngi->findScene(SC_21)->message(message, param, queue);
} else if (message == "MSG_SC22_PLAY_MUSIC") {
_scene->_behaviorController->disableAllMusic();
- warnOnce("CSoundManager::Play with the music volume and pan 50 is not ported (plays at full volume)");
- g_ngi->playSound(SND_MUS_SC04_START, 0);
+ g_ngi->playSound(SND_MUS_SC04_START, 0, 0, (float)g_ngi->getMusicSetting() * 0.5f, 50.0f);
_musicPlaying = true;
} else if (message == "MSG_SC22_OPEN_LUK") {
enableSound(SND_MUS_19, true);
@@ -421,7 +418,11 @@ void Sc22Controller::onMessage(const Common::String &message, const Common::Stri
g_ngi->stopAllSoundInstances(SND_MUS_SC04_START);
g_ngi->stopAllSoundInstances(SND_MUS_SC04_LOOP);
} else if (message == "MSG_MUSIC_VOL_CHANGED") {
- warnOnce("CSc22Controller::OnMessage MSG_MUSIC_VOL_CHANGED: CSound::Attenuate with the music volume is not ported");
+ const int sounds[] = { SND_MUS_SC04_START, SND_MUS_SC04_LOOP, SND_MUS_SC04_STOP2 };
+ for (uint i = 0; i < ARRAYSIZE(sounds); i++) {
+ if (isSoundPlayed(sounds[i]))
+ attenuateSound(sounds[i], (float)g_ngi->getMusicSetting() * 0.5f, 50.0f);
+ }
} else if (message == "MSG_DISABLESAVES") {
setSaving(false);
} else if (message == "MSG_ENABLESAVES") {
diff --git a/engines/ngi/fullpipe/mobile/sc23controller.cpp b/engines/ngi/fullpipe/mobile/sc23controller.cpp
index 273fb838da9..b2078414eae 100644
--- a/engines/ngi/fullpipe/mobile/sc23controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc23controller.cpp
@@ -457,7 +457,7 @@ void Sc23Controller::onShow() {
} else {
behavior->disableAllMusic();
if (isSoundPlayed(SND_MUS_SC04_LOOP))
- warning("STUB/untested: CSc23Controller::OnShow: CSound::Attenuate with the music volume and pan 50");
+ attenuateSound(SND_MUS_SC04_LOOP, (float)g_ngi->getMusicSetting(), 50.0f);
else
g_ngi->playSound(SND_MUS_SC04_LOOP, 0);
}
diff --git a/engines/ngi/fullpipe/mobile/tutorialmanager.cpp b/engines/ngi/fullpipe/mobile/tutorialmanager.cpp
index c17cccbd2c6..ec029125b7c 100644
--- a/engines/ngi/fullpipe/mobile/tutorialmanager.cpp
+++ b/engines/ngi/fullpipe/mobile/tutorialmanager.cpp
@@ -19,6 +19,8 @@
*
*/
+#include "common/serializer.h"
+
#include "ngi/ngi.h"
#include "ngi/font.h"
#include "ngi/objects.h"
@@ -250,4 +252,18 @@ void TutorialManager::setXmlData(const XmlNode &node) {
}
}
+// CTutorialManager::GetXmlData, CTutorial::GetXmlData; a loaded state 3 is 2
+void TutorialManager::syncGame(Common::Serializer &s) {
+ s.syncAsByte(_active);
+
+ uint32 count = _tutorials.size();
+ s.syncAsUint32LE(count);
+ for (uint32 i = 0; i < count; i++) {
+ int32 state = i < _tutorials.size() ? _tutorials[i]->_state : 0;
+ s.syncAsSint32LE(state);
+ if (s.isLoading() && i < _tutorials.size())
+ _tutorials[i]->_state = state == 3 ? 2 : state;
+ }
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mobile/tutorialmanager.h b/engines/ngi/fullpipe/mobile/tutorialmanager.h
index 2b8637a9bdc..3cc7a08574c 100644
--- a/engines/ngi/fullpipe/mobile/tutorialmanager.h
+++ b/engines/ngi/fullpipe/mobile/tutorialmanager.h
@@ -27,6 +27,10 @@
#include "ngi/xmlnode.h"
+namespace Common {
+class Serializer;
+}
+
namespace NGI {
/** CArrowData (36 bytes): the arrow of a tutorial, points at a place or an object */
@@ -100,6 +104,8 @@ public:
/** CTutorialManager::SetXmlData and CleanXml: the saved state */
void setXmlData(const XmlNode &node);
void cleanXml();
+ /** CTutorialManager::GetXmlData and SetXmlData for the savegames: isActive, the tutorial states */
+ void syncGame(Common::Serializer &s);
private:
Common::Array<Tutorial *> _tutorials; // +8
diff --git a/engines/ngi/inventory.cpp b/engines/ngi/inventory.cpp
index 5db15e101ff..67f3caf593f 100644
--- a/engines/ngi/inventory.cpp
+++ b/engines/ngi/inventory.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "common/serializer.h"
#include "common/tokenizer.h"
#include "ngi/ngi.h"
@@ -1119,10 +1120,80 @@ void Inventory::setXmlData(const XmlNode &node) {
// CInventory::CleanXml (10BC40): CScene::CleanXml (reread the document) is not ported
void Inventory::cleanXml() {
warning("STUB/untested: CScene::CleanXml of the inventory (the pictures and the GUI are not read again)");
+ // the items of the document that is read again have no counter; stands in for it
for (uint i = 0; i < _items.size(); i++) {
- // CGObject::CleanXml of an item: nothing in the original
+ _items[i]->_counter = 0;
+ _items[i]->_presentDelay = 0;
+ _items[i]->_state = 0;
}
_visibleItems.clear();
+ _assemblies.clear();
+ _assemblyShown = false;
+ _assemblyFlashTime = -1;
+}
+
+// CInventory::GetXmlData (108304), SetXmlData, CInventoryItem::GetXmlData: id, counter, delay
+void Inventory::syncGame(Common::Serializer &s) {
+ for (int pass = 0; pass < 2; pass++) {
+ const bool assemblies = pass == 1;
+ uint32 count = 0;
+ if (s.isSaving()) {
+ if (assemblies) {
+ count = _assemblies.size();
+ } else {
+ for (uint i = 0; i < _items.size(); i++) {
+ if (_items[i]->_counter != 0)
+ count++;
+ }
+ }
+ }
+ s.syncAsUint32LE(count);
+
+ uint next = 0;
+ for (uint32 i = 0; i < count; i++) {
+ InventoryItem *item = nullptr;
+ if (s.isSaving()) {
+ if (assemblies) {
+ item = _assemblies[i];
+ } else {
+ while (_items[next]->_counter == 0)
+ next++;
+ item = _items[next++];
+ }
+ }
+ Common::String id = item ? item->_id : "";
+ int32 counter = item ? item->_counter : 0;
+ int32 presentDelay = item ? item->_presentDelay : 0;
+ s.syncString(id);
+ s.syncAsSint32LE(counter);
+ s.syncAsSint32LE(presentDelay);
+ if (s.isSaving())
+ continue;
+
+ item = getItemByName(id);
+ if (!item)
+ continue;
+ item->_counter = counter;
+ item->_presentDelay = presentDelay;
+ item->_state = 0;
+ if (!assemblies) {
+ if (item->_counter > 0)
+ addVisibleItem(item);
+ } else {
+ _assemblyShown = true;
+ _assemblies.push_back(item);
+ _assemblyFlashTime = 0;
+ _assemblyFlashOn = true;
+ }
+ }
+ }
+
+ if (s.isLoading()) {
+ for (uint i = 0; i < _visibleItems.size(); i++) {
+ if (_visibleItems[i]->_autoCombine)
+ _visibleItems[i]->checkCombines(true, true);
+ }
+ }
}
// CGObject::SaveXml(bool) (FE8D8): saves the XML state to GetSavePath (inventory.sav)
diff --git a/engines/ngi/inventory.h b/engines/ngi/inventory.h
index 719587675c7..dc4d24d4ecf 100644
--- a/engines/ngi/inventory.h
+++ b/engines/ngi/inventory.h
@@ -29,6 +29,10 @@
#include "ngi/utils.h"
#include "ngi/xmlnode.h"
+namespace Common {
+class Serializer;
+}
+
namespace NGI {
class Scene;
@@ -225,6 +229,8 @@ public:
void init();
/** CInventory::SetXmlData: the saved state of the items ("counter", "presentDelay") */
void setXmlData(const XmlNode &node);
+ /** CInventory::GetXmlData (108304) and SetXmlData for the savegames: the items, the assemblies */
+ void syncGame(Common::Serializer &s);
/** CInventory::CleanXml */
void cleanXml();
/** CInventory::SaveXml (CGObject::SaveXml: the object saves itself to GetSavePath) */
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index e621f92e25b..f13f01c7334 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -468,8 +468,16 @@ Common::Error NGIEngine::run() {
return result;
_gameProject = _gameLoader->_gameProject.get();
// the achievements of ScummVM stand in for Google Play (CAchievement::AddActivatingCounter)
- if (_gameVersion >= 201509)
+ if (_gameVersion >= 201509) {
AchMan.setActiveDomain(getMetaEngine()->getAchievementsInfo(ConfMan.getActiveDomainName()));
+ // CBaseSettings::CBaseSettings (ED41C): sound 60 and music 30 until they are set
+ const Common::String domain = ConfMan.getActiveDomainName();
+ if (!ConfMan.hasKey("sfx_volume", domain))
+ setSoundSetting(60);
+ if (!ConfMan.hasKey("music_volume", domain))
+ setMusicSetting(30);
+ syncSoundSettings();
+ }
}
// The Android revision shows a wide screen: the 800x600 area stays in the middle, the margins
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 04c97fbf775..7dd2193d7be 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -283,7 +283,13 @@ public:
void stopAllSounds(int flags = -1);
void toggleMute();
Sound *findSound(int id) const;
- void playSound(int id, int flag, int creator = 0);
+ void playSound(int id, int flag, int creator = 0, float volume = -1, float pan = -1);
+ // CSettings::GetSound/GetMusic/SetSound/SetMusic: 0..100 (CGame +20, +24 in the original)
+ int getSoundSetting();
+ int getMusicSetting();
+ void setSoundSetting(int volume);
+ void setMusicSetting(int volume);
+ void syncSoundSettings() override;
void playTrack(GameVar *sceneVar, const char *name, bool delayed);
int getSceneTrack();
void updateTrackDelay();
diff --git a/engines/ngi/sound.cpp b/engines/ngi/sound.cpp
index 8a9c9a13fec..c336478ae83 100644
--- a/engines/ngi/sound.cpp
+++ b/engines/ngi/sound.cpp
@@ -171,6 +171,20 @@ void SoundManager::stopAll() {
sound->stop();
}
+// CSoundManager::Attenuate (12513C)
+void SoundManager::attenuate() {
+ for (Sound *sound : _sounds) {
+ if (sound->isPlaying())
+ sound->attenuate();
+ }
+}
+
+// CSoundManager::AttenuateByFlag (125116)
+void SoundManager::attenuateByFlag(int flags) {
+ for (Sound *sound : _sounds)
+ sound->attenuateByFlag(flags);
+}
+
// CSoundManager::StopAllSoundsByFlag (124EEA)
void SoundManager::stopAllSoundsByFlag(int flags) {
for (Sound *sound : _sounds) {
@@ -285,7 +299,42 @@ void Sound::attenuate(int vol, int pan) {
g_ngi->_mixer->setChannelBalance(*_handle, CLIP(pan / 78, -127, 127)); // -10000..10000
}
-void Sound::play(int loop, int creator) {
+// The gain is (1 - exp(-4.605 * volume / 100)) in percent (PP_Source_SetVolume), the pan is
+// (pan - 50) / 100 as the x of the source (PP_Source_SetPan)
+void Sound::mixerValues(float volume, float pan, byte &channelVolume, int8 &balance) {
+ volume = CLIP(volume, 0.0f, 100.0f);
+ pan = CLIP(pan, 0.0f, 100.0f);
+
+ const float gain = (1.0f - expf(volume / 100.0f * -4.605f)) * 100.0f;
+ const int percent = (int)(gain + 0.5f);
+
+ channelVolume = (byte)((percent * Audio::Mixer::kMaxChannelVolume + 50) / 100);
+ balance = (int8)CLIP(((int)(pan + 0.5f) - 50) * 127 / 50, -127, 127);
+}
+
+// CSound::Attenuate (124D40)
+void Sound::attenuate(float volume, float pan) {
+ byte channelVolume;
+ int8 balance;
+
+ mixerValues(volume, pan, channelVolume, balance);
+ debugC(2, kDebugEvents, "Sound %d: volume %.1f pan %.1f -> channel %d balance %d", _id, volume, pan, channelVolume, balance);
+ g_ngi->_mixer->setChannelVolume(*_handle, channelVolume);
+ g_ngi->_mixer->setChannelBalance(*_handle, balance);
+}
+
+// CSound::Attenuate (1250DC): the music (flags 2) has its own volume
+void Sound::attenuate() {
+ attenuate((float)(_flags == kMusic ? g_ngi->getMusicSetting() : g_ngi->getSoundSetting()), 50.0f);
+}
+
+// CSound::AttenuateByFlag (125108)
+void Sound::attenuateByFlag(int flags) {
+ if (_flags == flags)
+ attenuate();
+}
+
+void Sound::play(int loop, int creator, float volume, float pan) {
Audio::SoundHandle *handle = getHandle();
Audio::RewindableAudioStream *stream = nullptr;
@@ -320,7 +369,18 @@ void Sound::play(int loop, int creator) {
g_ngi->_mixer->stopHandle(*handle);
}
const Audio::Mixer::SoundType type = streamedSound && _flags == kMusic ? Audio::Mixer::kMusicSoundType : Audio::Mixer::kSFXSoundType;
- g_ngi->_mixer->playStream(type, handle, audioStream);
+ // the 2015 build sets the volume and the pan of the source before it starts
+ byte channelVolume = Audio::Mixer::kMaxChannelVolume;
+ int8 balance = 0;
+ if (streamedSound) {
+ if (volume < 0 || pan < 0) {
+ volume = (float)(_flags == kMusic ? g_ngi->getMusicSetting() : g_ngi->getSoundSetting());
+ pan = 50.0f;
+ }
+ mixerValues(volume, pan, channelVolume, balance);
+ }
+ debugC(2, kDebugEvents, "Sound %d starts: channel %d balance %d", _id, channelVolume, balance);
+ g_ngi->_mixer->playStream(type, handle, audioStream, -1, channelVolume, balance);
// CSound::Play (125338): +64 the loop flag, +68 the current scene
_looped = loop != 0;
_sceneId = g_ngi->getCurrentScene() ? g_ngi->getCurrentScene()->_sceneId : 0;
@@ -520,14 +580,43 @@ Sound *NGIEngine::findSound(int id) const {
return nullptr;
}
-void NGIEngine::playSound(int id, int flag, int creator) {
+void NGIEngine::playSound(int id, int flag, int creator, float volume, float pan) {
Sound *sound = findSound(id);
if (!sound) {
warning("playSound: Can't find sound with ID %d", id);
return;
}
- sound->play(flag, creator);
+ sound->play(flag, creator, volume, pan);
+}
+
+// CSettings::GetSound (19E11E) and GetMusic (19E114): 0..100, kept as the ScummVM volumes (0..255)
+int NGIEngine::getSoundSetting() {
+ return (ConfMan.getInt("sfx_volume") * 100 + 127) / 255;
+}
+
+int NGIEngine::getMusicSetting() {
+ return (ConfMan.getInt("music_volume") * 100 + 127) / 255;
+}
+
+// CSettings::SetSound (19E134) and SetMusic (19E128)
+void NGIEngine::setSoundSetting(int volume) {
+ ConfMan.setInt("sfx_volume", (CLIP(volume, 0, 100) * 255 + 50) / 100);
+}
+
+void NGIEngine::setMusicSetting(int volume) {
+ ConfMan.setInt("music_volume", (CLIP(volume, 0, 100) * 255 + 50) / 100);
+}
+
+void NGIEngine::syncSoundSettings() {
+ Engine::syncSoundSettings();
+
+ if (_gameVersion >= 201509) {
+ // the gain of every sound carries the volume (CSound::Attenuate), the mixer takes it at full
+ _mixer->setVolumeForSoundType(Audio::Mixer::kSFXSoundType, Audio::Mixer::kMaxMixerVolume);
+ _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, Audio::Mixer::kMaxMixerVolume);
+ _soundManager.attenuate();
+ }
}
void NGIEngine::playTrack(GameVar *sceneVar, const char *name, bool delayed) {
diff --git a/engines/ngi/sound.h b/engines/ngi/sound.h
index 716c850f2eb..64dc13d1951 100644
--- a/engines/ngi/sound.h
+++ b/engines/ngi/sound.h
@@ -51,7 +51,8 @@ public:
Audio::SoundHandle *getHandle() const { return _handle; }
bool isPlaying() const;
- void play(int loop, int creator = 0);
+ // CSound::Play (125338): the volume and pan are 0..100 for 201509, below 0 means the settings
+ void play(int loop, int creator = 0, float volume = -1, float pan = -1);
void unload();
int getVolume();
void stop();
@@ -59,6 +60,11 @@ public:
void setPanAndVolumeByStaticAni();
void attenuate(int vol, int pan);
+ // 201509: CSound::Attenuate (124D40) with volume and pan 0..100, the one without them (1250DC)
+ // takes the volume of the settings, CSound::AttenuateByFlag (125108)
+ void attenuate(float volume, float pan);
+ void attenuate();
+ void attenuateByFlag(int flags);
/** CSound::isLooped (+64): the sound was started with a loop */
bool isLooped() const { return _looped; }
@@ -66,6 +72,9 @@ public:
int getSceneId() const { return _sceneId; }
private:
+ // the gain curve of the original and the pan as the mixer takes them
+ static void mixerValues(float volume, float pan, byte &channelVolume, int8 &balance);
+
bool _looped = false;
int _sceneId = 0;
};
diff --git a/engines/ngi/soundmanager.h b/engines/ngi/soundmanager.h
index 479bdaaf395..d18ec0012e0 100644
--- a/engines/ngi/soundmanager.h
+++ b/engines/ngi/soundmanager.h
@@ -45,6 +45,10 @@ public:
void stopAll();
/** CSoundManager::StopAllSoundsByFlag: the sounds whose flags equal `flags` */
void stopAllSoundsByFlag(int flags);
+ /** CSoundManager::Attenuate (12513C): the sounds that play get the volume of the settings again */
+ void attenuate();
+ /** CSoundManager::AttenuateByFlag (125116) */
+ void attenuateByFlag(int flags);
private:
Common::Array<Sound *> _sounds;
Commit: b543fcdf52d6522beec5708cfbcd53fe2fdd8c62
https://github.com/scummvm/scummvm/commit/b543fcdf52d6522beec5708cfbcd53fe2fdd8c62
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Not implemented box for the platform buttons of the Android menu and the notebook
Changed paths:
A engines/ngi/fullpipe/mobile/platformservices.cpp
A engines/ngi/fullpipe/mobile/platformservices.h
engines/ngi/POTFILES
engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
engines/ngi/fullpipe/mobile/notebook.cpp
engines/ngi/module.mk
diff --git a/engines/ngi/POTFILES b/engines/ngi/POTFILES
index 5856c3b48f6..7addce617dc 100644
--- a/engines/ngi/POTFILES
+++ b/engines/ngi/POTFILES
@@ -1 +1,2 @@
+engines/ngi/fullpipe/mobile/platformservices.cpp
engines/ngi/metaengine.cpp
diff --git a/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp b/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
index c830e9f6a1a..b58324bc856 100644
--- a/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
@@ -35,6 +35,7 @@
#include "ngi/fullpipe/mobile/controllerhelpers.h"
#include "ngi/fullpipe/mobile/exitmanager.h"
#include "ngi/fullpipe/mobile/mainmenucontroller.h"
+#include "ngi/fullpipe/mobile/platformservices.h"
#include "ngi/fullpipe/mobile/settings.h"
#include "ngi/fullpipe/mobile/map.h"
#include "ngi/fullpipe/mobile/taskmanager.h"
@@ -62,12 +63,6 @@ bool debuggerIsCheater() {
return false;
}
-// the platform services (PP_FB_isConnected, PP_GC_IsAuthorized ...): none, nothing is connected
-bool platformService(const char *name) {
- warnOnce(Common::String::format("%s: the platform services of the Android application are not ported", name).c_str());
- return false;
-}
-
// CGame::SetScene(sceneId, entranceId)
void setScene(int sceneId, int entranceId) {
g_ngi->_gameLoader->preloadScene(sceneId, entranceId);
@@ -223,7 +218,7 @@ void MainMenuController::initButtons() {
button->showAndActivate();
}
- const bool connected = platformService("PP_FB_isConnected");
+ const bool connected = platformQuery("PP_FB_isConnected");
if ((button = guiElement(_scene, "BTN_MNU_FACEBOOK"))) {
if (connected)
button->deactivate();
@@ -251,7 +246,7 @@ void MainMenuController::onUpdate(uint32 elapsed) {
_facebookTimer += elapsed;
if (_facebookTimer > 499) {
_facebookTimer = 0;
- const bool connected = platformService("PP_FB_isConnected");
+ const bool connected = platformQuery("PP_FB_isConnected");
if (GuiElement *button = guiElement(_scene, "BTN_MNU_FACEBOOK")) {
if (connected)
button->deactivate();
@@ -287,7 +282,7 @@ void MainMenuController::onMessage(const Common::String &message, const Common::
}
}
-// CMainMenu::OnGuiEvent (19B9E4); the platform services are not ported
+// CMainMenu::OnGuiEvent (19B9E4); the platform buttons say "Not implemented"
void MainMenuController::onGuiEvent(const Common::String &id, const Common::String &event) {
if (event == "unpress") {
if (id == "BTN_MNU_DEBUG") {
@@ -304,43 +299,37 @@ void MainMenuController::onGuiEvent(const Common::String &id, const Common::Stri
} else if (id == "BTN_MNU_RESTART") {
pushDialog(SC_CONFIRMATION, 2);
} else if (id == "BTN_MNU_ACHIEVE" || id == "BTN_MNU_GC") {
- // PP_CheckInternetConnection, PP_GC_IsAuthorized, PP_GC_ShowAchievements / PP_GC_Authenticate
- if (platformService("PP_CheckInternetConnection")) {
- if (platformService("PP_GC_IsAuthorized"))
- platformService("PP_GC_ShowAchievements");
- else
- platformService("PP_GC_Authenticate");
- }
+ // PP_CheckInternetConnection, PP_GC_IsAuthorized, PP_GC_ShowAchievements / PP_GC_Authenticate
+ showNotImplemented("Game Center / achievements");
} else if (id == "BTN_MNU_OPTIONS") {
pushDialog(SC_OPTIONS, 0);
} else if (id == "BTN_MNU_REVIEW") {
- platformService("PP_OpenLink (CSettings::GetReviewLink)");
+ showNotImplemented("Review link (PP_OpenLink)");
} else if (id == "BTN_MNU_MAIL") {
- platformService("PP_OpenLink (CSettings::GetMailLink)");
+ showNotImplemented("Mail link (PP_OpenLink)");
} else if (id == "BTN_MNU_FACEBOOK") {
- if (!platformService("PP_FB_isConnected")) {
- platformService("PP_FB_Login");
+ if (!platformQuery("PP_FB_isConnected")) {
+ showNotImplemented("Facebook login (PP_FB_Login)");
} else if (GuiElement *button = guiElement(_scene, "BTN_MNU_FACEBOOK")) {
button->deactivate();
}
} else if (id == "BTN_MNU_MORE_GAMES") {
- if (platformService("PP_CheckInternetConnection"))
- platformService("PP_UpsightContent");
+ showNotImplemented("More games (PP_UpsightContent)");
} else if (id == "BTN_MNU_GET_FULL") {
- pushDialog(SC_UPSELL, 0);
+ showNotImplemented("Get the full version (the upsell scene)");
}
}
if (event == "unpress_unactive") {
if (id == "BTN_MNU_FACEBOOK") {
- if (platformService("PP_FB_isConnected")) {
- platformService("PP_FB_Logout");
+ if (platformQuery("PP_FB_isConnected")) {
+ platformQuery("PP_FB_Logout");
} else if (GuiElement *button = guiElement(_scene, "BTN_MNU_FACEBOOK")) {
button->activate();
}
} else if (id == "BTN_MNU_GC") {
- if (platformService("PP_GC_IsAuthorized")) {
- platformService("PP_GC_SignOut");
+ if (platformQuery("PP_GC_IsAuthorized")) {
+ platformQuery("PP_GC_SignOut");
} else if (GuiElement *button = guiElement(_scene, "BTN_MNU_GC")) {
button->activate();
}
diff --git a/engines/ngi/fullpipe/mobile/notebook.cpp b/engines/ngi/fullpipe/mobile/notebook.cpp
index 1dc03913a96..b7a7f6dd79d 100644
--- a/engines/ngi/fullpipe/mobile/notebook.cpp
+++ b/engines/ngi/fullpipe/mobile/notebook.cpp
@@ -40,6 +40,7 @@
#include "ngi/scene.h"
#include "ngi/fullpipe/scenes.h"
#include "ngi/sound.h"
+#include "ngi/fullpipe/mobile/platformservices.h"
#include "ngi/fullpipe/mobile/taskmanager.h"
#include "ngi/fullpipe/mobile/tutorialmanager.h"
@@ -874,7 +875,7 @@ void Notebook::onGuiEvent(const Common::String &id, const Common::String &event)
setCatalogMark(ST_MARK_CATALOG);
}
} else if (id == "BTN_MENU_BAY_1" || id == "BTN_MENU_BAY_2" || id == "BTN_MENU_BAY_3") {
- warnOnce("CNotebookController::OnBuyButtonPressed: purchases of hints are not ported");
+ showNotImplemented("Purchases of hints (CNotebookController::OnBuyButtonPressed)");
} else if (id == "BTN_MARK_CATALOG") {
catalog->hidePage();
if (_page == kPageCatalog) {
diff --git a/engines/ngi/fullpipe/mobile/platformservices.cpp b/engines/ngi/fullpipe/mobile/platformservices.cpp
new file mode 100644
index 00000000000..bae835b0ae2
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/platformservices.cpp
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/str.h"
+#include "common/translation.h"
+#include "engines/engine.h"
+#include "gui/message.h"
+
+#include "ngi/ngi.h"
+#include "ngi/guimanager.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/mobile/controllerhelpers.h"
+#include "ngi/fullpipe/mobile/platformservices.h"
+
+namespace NGI {
+
+bool platformQuery(const char *name) {
+ warnOnce(Common::String::format("%s: the platform services of the Android application are not ported", name).c_str());
+ return false;
+}
+
+void showNotImplemented(const char *feature) {
+ warning("STUB: %s is not implemented (platform service of the Android application)", feature);
+
+ {
+ PauseToken pause = g_ngi->pauseEngine();
+ GUI::MessageDialog dialog(_("Not implemented"));
+ dialog.runModal();
+ }
+
+ // the dialog loop took the button-up of the tap
+ g_ngi->_touchDown = false;
+ Scene *scene = g_ngi->getCurrentScene();
+ if (scene && scene->_guiManager) {
+ scene->_guiManager->unpressAll();
+ scene->_guiManager->deselectAll();
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mobile/platformservices.h b/engines/ngi/fullpipe/mobile/platformservices.h
new file mode 100644
index 00000000000..5be862c9e45
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/platformservices.h
@@ -0,0 +1,34 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_PLATFORMSERVICES_H
+#define NGI_FULLPIPE_PLATFORMSERVICES_H
+
+namespace NGI {
+
+/** A polled platform service (PP_FB_isConnected ...): none exists, the answer is false */
+bool platformQuery(const char *name);
+/** A platform feature behind a button (achievements, links, store): "Not implemented" */
+void showNotImplemented(const char *feature);
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_PLATFORMSERVICES_H
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index d447c481d33..c78c270330d 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -111,6 +111,7 @@ MODULE_OBJS = \
fullpipe/mobile/noactionlogger.o \
fullpipe/mobile/notebook.o \
fullpipe/mobile/objhelper.o \
+ fullpipe/mobile/platformservices.o \
fullpipe/mobile/savesections.o \
fullpipe/mobile/sc01controller.o \
fullpipe/mobile/sc02controller.o \
Commit: 62398f3ee7f334e65152836fea0fd3db67088d87
https://github.com/scummvm/scummvm/commit/62398f3ee7f334e65152836fea0fd3db67088d87
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: CConfirmationDlg, the confirmation dialog of the main menu
Changed paths:
A engines/ngi/fullpipe/mobile/confirmationdlg.cpp
A engines/ngi/fullpipe/mobile/confirmationdlg.h
engines/ngi/fullpipe/mobile/controllerhelpers.cpp
engines/ngi/fullpipe/mobile/controllerhelpers.h
engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
engines/ngi/fullpipe/mobile/scenecontrollers.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/module.mk
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/mobile/confirmationdlg.cpp b/engines/ngi/fullpipe/mobile/confirmationdlg.cpp
new file mode 100644
index 00000000000..a5ff9ed6abf
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/confirmationdlg.cpp
@@ -0,0 +1,110 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/font.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/mobile/confirmationdlg.h"
+#include "ngi/fullpipe/mobile/controllerhelpers.h"
+
+namespace NGI {
+
+// CConfirmationDlg::CConfirmationDlg (19AA2C)
+ConfirmationDlg::ConfirmationDlg(int sceneId) : FPGuiController(sceneId) {
+}
+
+// CConfirmationDlg::OnUpdate (19A6EC): empty
+void ConfirmationDlg::onUpdate(uint32 elapsed) {
+}
+
+// CConfirmationDlg::OnShow (19B1E8)
+void ConfirmationDlg::onShow() {
+ if (_mode == 2) {
+ _text = g_ngi->getText("STR_NEWGAME_CONFIRMATION");
+ } else if (_mode == 1) {
+ _text = g_ngi->getText("STR_EXIT_CONFIRMATION");
+ } else {
+ g_ngi->popScene();
+ }
+ _left = 305.0f;
+ _top = 250.0f;
+ _right = 515.0f;
+ _bottom = 300.0f;
+ _font = g_ngi->getFont("impact_24_grey.fnt");
+}
+
+// CConfirmationDlg::OnHide (19A6E6)
+void ConfirmationDlg::onHide() {
+ _mode = 0;
+}
+
+// CConfirmationDlg::OnRender (19A840): CFont::Print, white, centered
+void ConfirmationDlg::onRender(Common::Point scroll) {
+ if (_font)
+ _font->print(g_ngi->_backgroundSurface, _text, _left, _top, _right - _left, _bottom - _top, BitmapFont::kAlignCenter, BitmapFont::kVerticalCenter);
+}
+
+// CConfirmationDlg::OnRenderBottom (19B3DC): a black quad of opacity 0.4 over the whole screen
+void ConfirmationDlg::onRenderBottom(Common::Point scroll) {
+ dimScreen(0.4f);
+}
+
+// CConfirmationDlg::OnGuiEvent (19B2D4)
+void ConfirmationDlg::onGuiEvent(const Common::String &id, const Common::String &event) {
+ if (event != "unpress")
+ return;
+ if (id == "BTN_SC_CONFIRMATION_YES") {
+ if (_mode == 2) {
+ Scene *menu = g_ngi->findScene(SC_MAINMENU);
+ if (menu)
+ menu->message("MSG_RESTART_GAME", "", nullptr);
+ } else if (_mode == 1) {
+ Scene *menu = g_ngi->findScene(SC_MAINMENU);
+ if (menu)
+ menu->message("MSG_EXIT", "", nullptr);
+ }
+ } else if (id == "BTN_SC_CONFIRMATION_NO" || id == "BTN_SC_CONFIRMATION_CLOSE") {
+ g_ngi->popScene();
+ }
+}
+
+// CConfirmationDlg::OnMouseLKeyDown (19A6CA): the click stays in the dialog
+bool ConfirmationDlg::onMouseLKeyDown(uint32 id, float x, float y) {
+ return true;
+}
+
+// CConfirmationDlg::OnMouseLKeyUp (19A6CE)
+bool ConfirmationDlg::onMouseLKeyUp(uint32 id, float x, float y) {
+ return true;
+}
+
+// CConfirmationDlg::OnMouseRKeyDown (19A6D2)
+bool ConfirmationDlg::onMouseRKeyDown(uint32 id, float x, float y) {
+ return true;
+}
+
+// CConfirmationDlg::OnMouseRKeyUp (19A6D6)
+bool ConfirmationDlg::onMouseRKeyUp(uint32 id, float x, float y) {
+ return true;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mobile/confirmationdlg.h b/engines/ngi/fullpipe/mobile/confirmationdlg.h
new file mode 100644
index 00000000000..8d68d85ff0c
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/confirmationdlg.h
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_CONFIRMATIONDLG_H
+#define NGI_FULLPIPE_CONFIRMATIONDLG_H
+
+#include "common/rect.h"
+#include "common/str.h"
+
+#include "ngi/fullpipe/mobile/fpguicontroller.h"
+
+namespace NGI {
+
+class BitmapFont;
+
+/** CConfirmationDlg (0x2C bytes): SC_CONFIRMATION, the yes/no question of the main menu */
+class ConfirmationDlg : public FPGuiController {
+public:
+ /** CConfirmationDlg::CConfirmationDlg (19AA2C) */
+ explicit ConfirmationDlg(int sceneId);
+
+ /** The caller writes +40 before CGame::PushScene: 1 = quit, 2 = new game */
+ void setMode(int mode) {
+ _mode = mode;
+ }
+
+ void onUpdate(uint32 elapsed) override;
+ void onShow() override;
+ void onHide() override;
+ void onRender(Common::Point scroll) override;
+ void onRenderBottom(Common::Point scroll) override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseRKeyDown(uint32 id, float x, float y) override;
+ bool onMouseRKeyUp(uint32 id, float x, float y) override;
+
+private:
+ Common::String _text; // +16
+ float _left = 0; // +20
+ float _top = 0; // +24
+ float _right = 0; // +28
+ float _bottom = 0; // +32
+ const BitmapFont *_font = nullptr; // +36
+ int _mode = 0; // +40
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_CONFIRMATIONDLG_H
diff --git a/engines/ngi/fullpipe/mobile/controllerhelpers.cpp b/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
index b1782de9eca..dd32aef9336 100644
--- a/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
+++ b/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
@@ -163,6 +163,12 @@ void warnOnce(const char *what) {
}
}
+void dimScreen(float opacity) {
+ // drawAlphaRectangle takes the brightness that is left: the opposite of the opacity
+ const Graphics::ManagedSurface &screen = g_ngi->_backgroundSurface;
+ g_ngi->drawAlphaRectangle(0, 0, screen.w, screen.h, (int)(255.0f * (1.0f - opacity) + 0.5f));
+}
+
// CBaseSettings::SetSaving (ED21E): the save comes first when the saving goes off
void setSaving(bool allowed) {
if (!allowed)
diff --git a/engines/ngi/fullpipe/mobile/controllerhelpers.h b/engines/ngi/fullpipe/mobile/controllerhelpers.h
index 34f58fb2c7d..79aaab38306 100644
--- a/engines/ngi/fullpipe/mobile/controllerhelpers.h
+++ b/engines/ngi/fullpipe/mobile/controllerhelpers.h
@@ -59,6 +59,9 @@ Command *createMouseCommand(Scene *scene, float x, float y, int objectId);
/** the object id in the game project (Android obj.h differs from constants.h, e.g. ST_LBN_*) */
int projectId(const char *name);
+/** CRender::DrawQuad: a black quad over the whole screen, the wide margins too */
+void dimScreen(float opacity);
+
// placeholders of subsystems that are not ported
void warnOnce(const char *what);
void setSaving(bool allowed); // CBaseSettings::SetSaving
diff --git a/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp b/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
index b58324bc856..bced6ba6ccc 100644
--- a/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
@@ -30,6 +30,7 @@
#include "ngi/fullpipe/mobile/arcadeinterface.h"
#include "ngi/fullpipe/mobile/catalog.h"
#include "ngi/fullpipe/mobile/chaptermanager.h"
+#include "ngi/fullpipe/mobile/confirmationdlg.h"
#include "ngi/fullpipe/mobile/achievements.h"
#include "ngi/fullpipe/constants.h"
#include "ngi/fullpipe/mobile/controllerhelpers.h"
@@ -91,9 +92,15 @@ GameObject *findVisibleObjectAt(Scene *scene, float x, float y) {
return found;
}
-// SC_CONFIRMATION (CConfirmationDlg, +40: 1 exits, 2 restarts), options and upsell scenes
+// CGame::PushScene of a dialog; the caller sets the mode first (+40 of CConfirmationDlg)
void pushDialog(int sceneId, int mode) {
- warnOnce(Common::String::format("CGame::PushScene(%d) (mode %d): the controller of the scene (CConfirmationDlg, CScOptionsController, CUpsellController) is not ported, the scene is not pushed", sceneId, mode).c_str());
+ if (sceneId == SC_CONFIRMATION) {
+ Scene *dialog = g_ngi->findScene(sceneId);
+ static_cast<ConfirmationDlg *>(dialog->_controller.get())->setMode(mode);
+ g_ngi->pushScene(sceneId);
+ return;
+ }
+ warnOnce(Common::String::format("CGame::PushScene(%d) (mode %d): the controller of the scene (CScOptionsController) is not ported, the scene is not pushed", sceneId, mode).c_str());
}
} // End of anonymous namespace
diff --git a/engines/ngi/fullpipe/mobile/scenecontrollers.cpp b/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
index 4666646486f..a113f193d8a 100644
--- a/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
@@ -61,6 +61,7 @@
#include "ngi/fullpipe/mobile/sc03controller.h"
#include "ngi/fullpipe/mobile/sc04controller.h"
#include "ngi/fullpipe/mobile/chaptercontroller.h"
+#include "ngi/fullpipe/mobile/confirmationdlg.h"
#include "ngi/fullpipe/mobile/help.h"
#include "ngi/fullpipe/mobile/notebook.h"
#include "ngi/fullpipe/mobile/introcontroller.h"
@@ -213,6 +214,9 @@ void createSceneController(int sceneId) {
case SC_MAINMENU:
new MainMenuController(sceneId);
break;
+ case SC_CONFIRMATION:
+ new ConfirmationDlg(sceneId);
+ break;
case SC_MAP:
new MapWindowController(sceneId);
break;
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index d83b41ab0dc..f4770935453 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -600,19 +600,9 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (!source)
return false;
if (ref.type & 2) {
- // ADDPIC: the picture of this scene, else the source scene's, else a copy it owns
- PictureObject *picture = scene->findPictureObjectById(ref.objectId, ref.copyId);
- if (!picture) {
- picture = source->findPictureObjectById(ref.objectId, ref.copyId);
- if (!picture) {
- PictureObject *original = source->findPictureObjectById(ref.objectId, 0);
- if (!original)
- return false;
- picture = new PictureObject(original);
- source->addPicture(picture);
- }
- scene->_roamingPictures.push_back(picture);
- }
+ PictureObject *picture = scene->addRoamingPicture(ref);
+ if (!picture)
+ return false;
picture->setPos(ref.ox == -1 ? picture->_x : ref.ox, ref.oy == -1 ? picture->_y : ref.oy);
if (ref.priority != -1)
picture->_z = ref.priority;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index c78c270330d..db4b934b785 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -95,6 +95,7 @@ MODULE_OBJS = \
fullpipe/mobile/catalog.o \
fullpipe/mobile/chaptercontroller.o \
fullpipe/mobile/chaptermanager.o \
+ fullpipe/mobile/confirmationdlg.o \
fullpipe/mobile/controllerhelpers.o \
fullpipe/mobile/exitmanager.o \
fullpipe/mobile/fpcontroller.o \
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 03ca2b5d622..d272ba9b136 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -114,6 +114,8 @@ void NGIEngine::pushScene(int sceneId) {
return;
}
debugC(1, kDebugInfo, "INFO t %u scene %d is pushed", g_system->getMillis(), sceneId);
+ if (usesXMLProject())
+ scene->addRoamingPictures();
if (_sceneStack.empty() && _currentScene)
_sceneStack.push_back(_currentScene);
if (_preloadManager) {
@@ -1323,6 +1325,35 @@ uint Scene::unloadRoamings(bool all) {
return size;
}
+// CScene::AddRoamingObjects (12300C), ADDPIC: this scene's picture, else the source's, else a copy
+PictureObject *Scene::addRoamingPicture(const PicAniInfo &ref) {
+ Scene *source = g_ngi->findScene(ref.sceneId);
+ if (!source)
+ return nullptr;
+ PictureObject *picture = findPictureObjectById(ref.objectId, ref.copyId);
+ if (!picture) {
+ picture = source->findPictureObjectById(ref.objectId, ref.copyId);
+ if (!picture) {
+ PictureObject *original = source->findPictureObjectById(ref.objectId, 0);
+ if (!original)
+ return nullptr;
+ picture = new PictureObject(original);
+ source->addPicture(picture);
+ }
+ _roamingPictures.push_back(picture);
+ }
+ return picture;
+}
+
+// A pushed dialog gets its ADDPIC pictures here (CGame::PushScene has no SetupRoamingObjects)
+void Scene::addRoamingPictures() {
+ for (const PicAniInfo &ref : _roamingObjects) {
+ if ((ref.type & 2) && !addRoamingPicture(ref))
+ warning("Scene::addRoamingPictures: a picture of the scene %d is not found", _sceneId);
+ }
+ repopulateRenderables();
+}
+
// CScene::AddRoamingObject (123DF0): the roaming pictures load with the scene here, so only the
// new one loads (the original calls CPreloadManager::LoadRoamings)
void Scene::addRoamingObject(PictureObject *picture, bool load) {
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 14224467371..267ff3a8b13 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -78,6 +78,8 @@ class Scene : public Background {
uint unloadRoamings(bool all);
/** CScene::AddRoamingObject / RemoveRoamingObject: a picture of another scene (CCatalogManager) */
void addRoamingObject(PictureObject *picture, bool load);
+ PictureObject *addRoamingPicture(const PicAniInfo &ref);
+ void addRoamingPictures();
void removeRoamingObject(int id);
uint loadMovement(int aniId, int movementId);
uint unloadMovement(int aniId, int movementId);
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 1ca43bf595d..ca0c1a55a18 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -2021,6 +2021,7 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_achievementsManager->init("data/achievements.xml");
createSceneController(SC_TUTORIAL); // CTutorialController
createSceneController(SC_MAINMENU); // CMainMenu
+ createSceneController(SC_CONFIRMATION); // CConfirmationDlg
createSceneController(SC_MAP); // CMapWindow
g_ngi->_map.reset(new Map); // CMap, CMap::Reset
g_ngi->_map->reset();
Commit: 81cbb94b2946bcd9dbfe9295febff555680e2931
https://github.com/scummvm/scummvm/commit/81cbb94b2946bcd9dbfe9295febff555680e2931
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: CScFinalController, the ending scenes
Changed paths:
A engines/ngi/fullpipe/mobile/scfinalcontroller.cpp
A engines/ngi/fullpipe/mobile/scfinalcontroller.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/mobile/controllerhelpers.cpp
engines/ngi/fullpipe/mobile/controllerhelpers.h
engines/ngi/fullpipe/mobile/scenecontrollers.cpp
engines/ngi/fullpipe/scenes.cpp
engines/ngi/module.mk
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 113924c9c25..5b71af54398 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -1728,17 +1728,22 @@ namespace NGI {
// Final scene
#define ANI_FIN_COIN 5014
+#define ANI_FN3_HAND3 5036
#define MSG_FIN_ENDFINAL 5109
#define MSG_FIN_GOTO2 5024
#define MSG_FIN_GOTO3 5071
#define MSG_FIN_GOTO4 5075
#define MSG_FIN_STARTFINAL 5025
#define MSG_FN4_STARTMUSIC 5356
+#define MV_FNHND3_SHOWHMR 5040
#define QU_FIN1_FALLCOIN 5018
#define QU_FIN1_TAKECOIN 5023
#define QU_FN2_DOFINAL 5066
#define QU_FN3_DOFINAL 5072
#define QU_FN4_DOFINAL 5108
+#define SND_FIN_032 5107
+#define SND_MUS_16 63293
+#define SND_MUS_17 63294
#define ST_FCN_NORM 5017
// Debug scene
diff --git a/engines/ngi/fullpipe/mobile/controllerhelpers.cpp b/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
index dd32aef9336..ffbbe0f2bcf 100644
--- a/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
+++ b/engines/ngi/fullpipe/mobile/controllerhelpers.cpp
@@ -163,6 +163,15 @@ void warnOnce(const char *what) {
}
}
+void doSetScene() {
+ GameLoader *loader = g_ngi->_gameLoader.get();
+ if (!loader->_preloadSceneId)
+ return;
+ if (!loader->setScene(loader->_preloadSceneId, loader->_preloadEntranceId))
+ warning("doSetScene: could not enter the scene %d", loader->_preloadSceneId);
+ loader->_preloadSceneId = loader->_preloadEntranceId = 0;
+}
+
void dimScreen(float opacity) {
// drawAlphaRectangle takes the brightness that is left: the opposite of the opacity
const Graphics::ManagedSurface &screen = g_ngi->_backgroundSurface;
diff --git a/engines/ngi/fullpipe/mobile/controllerhelpers.h b/engines/ngi/fullpipe/mobile/controllerhelpers.h
index 79aaab38306..9d4fd128aaa 100644
--- a/engines/ngi/fullpipe/mobile/controllerhelpers.h
+++ b/engines/ngi/fullpipe/mobile/controllerhelpers.h
@@ -59,6 +59,8 @@ Command *createMouseCommand(Scene *scene, float x, float y, int objectId);
/** the object id in the game project (Android obj.h differs from constants.h, e.g. ST_LBN_*) */
int projectId(const char *name);
+/** CGame::DoSetScene: the scene that SetScene asked for is entered now, not at the frame end */
+void doSetScene();
/** CRender::DrawQuad: a black quad over the whole screen, the wide margins too */
void dimScreen(float opacity);
diff --git a/engines/ngi/fullpipe/mobile/scenecontrollers.cpp b/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
index a113f193d8a..c8369b36207 100644
--- a/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
@@ -58,6 +58,7 @@
#include "ngi/fullpipe/mobile/sc25controller.h"
#include "ngi/fullpipe/mobile/sc23controller.h"
#include "ngi/fullpipe/mobile/scenecontrollers.h"
+#include "ngi/fullpipe/mobile/scfinalcontroller.h"
#include "ngi/fullpipe/mobile/sc03controller.h"
#include "ngi/fullpipe/mobile/sc04controller.h"
#include "ngi/fullpipe/mobile/chaptercontroller.h"
@@ -214,6 +215,12 @@ void createSceneController(int sceneId) {
case SC_MAINMENU:
new MainMenuController(sceneId);
break;
+ case SC_FINAL1:
+ case SC_FINAL2:
+ case SC_FINAL3:
+ case SC_FINAL4:
+ new ScFinalController(sceneId);
+ break;
case SC_CONFIRMATION:
new ConfirmationDlg(sceneId);
break;
diff --git a/engines/ngi/fullpipe/mobile/scfinalcontroller.cpp b/engines/ngi/fullpipe/mobile/scfinalcontroller.cpp
new file mode 100644
index 00000000000..a9050b66c7f
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/scfinalcontroller.cpp
@@ -0,0 +1,223 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/behavior.h"
+#include "ngi/fader.h"
+#include "ngi/gameloader.h"
+#include "ngi/interaction.h"
+#include "ngi/motion.h"
+#include "ngi/preloadmanager.h"
+#include "ngi/scene.h"
+#include "ngi/statics.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/mobile/achievements.h"
+#include "ngi/fullpipe/mobile/chaptermanager.h"
+#include "ngi/fullpipe/mobile/controllerhelpers.h"
+#include "ngi/fullpipe/mobile/scfinalcontroller.h"
+#include "ngi/fullpipe/mobile/settings.h"
+#include "ngi/fullpipe/mobile/taskmanager.h"
+
+namespace NGI {
+
+// CScFinalController::CScFinalController (1982EC)
+ScFinalController::ScFinalController(int sceneId) : FPController(sceneId) {
+}
+
+// CScFinalController::DoFallCoin (198324)
+void ScFinalController::doFallCoin() {
+ AniObject *coin = _scene->findAniObjectById(ANI_FIN_COIN, 0);
+ if (!coin->_movement && coin->getStaticsId() != ST_FCN_NORM)
+ _scene->runQueue(QU_FIN1_FALLCOIN, 2);
+}
+
+// CScFinalController::DoEndFinal (198360)
+void ScFinalController::doEndFinal() {
+ _state = 1;
+}
+
+// CScFinalController::DoSwitchTo2 (1983CC)
+void ScFinalController::doSwitchTo2() {
+ g_ngi->_gameLoader->preloadScene(SC_FINAL2, 0); // CGame::SetScene
+}
+
+// CScFinalController::DoSwitchTo3 (1983E0)
+void ScFinalController::doSwitchTo3() {
+ g_ngi->_gameLoader->preloadScene(SC_FINAL3, 0);
+}
+
+// CScFinalController::DoSwitchTo4 (1983F4)
+void ScFinalController::doSwitchTo4() {
+ g_ngi->_gameLoader->preloadScene(SC_FINAL4, 0);
+}
+
+// CScFinalController::DoStartFinal (19844C)
+void ScFinalController::doStartFinal() {
+ _scene->_motionController->deactivate();
+ getGameLoaderInteractionController()->_enabled = false;
+ _follow = nullptr;
+ hero()->_flags &= ~4;
+ _scene->runQueueWithAni(QU_FIN1_TAKECOIN, hero(), 2);
+ _scene->_behaviorController->disableAllMusic();
+ enableSound(SND_MUS_17, true);
+ _state = 0;
+}
+
+// CScFinalController::OnShow (19849C)
+void ScFinalController::onShow() {
+ FPController::onShow();
+ getGameLoaderInteractionController()->_enabled = false;
+ _scene->_motionController->deactivate();
+ g_ngi->_chapterManager->setActiveChapter(12);
+ g_ngi->_taskManager->visitScene(_scene->_sceneId);
+ _lastCoinX = 0;
+ _coinX = 0;
+
+ switch (_scene->_sceneId) {
+ case SC_FINAL1:
+ _state = -1;
+ g_ngi->_preloadManager->unloadScene(SC_INV);
+ break;
+ case SC_FINAL2:
+ _state = 0;
+ if (!_scene->_currentEntranceId)
+ _scene->runQueue(QU_FN2_DOFINAL, 2);
+ break;
+ case SC_FINAL3:
+ _state = 0;
+ if (!_scene->_currentEntranceId)
+ _scene->runQueue(QU_FN3_DOFINAL, 2);
+ break;
+ case SC_FINAL4:
+ _state = 0;
+ if (!_scene->_currentEntranceId) {
+ if (g_ngi->settings().getIsCompleted()) {
+ warnOnce("CScFinalController::OnShow: the replay of a finished game (SetScene and DoSetScene inside OnShow) is not played");
+ _state = -1;
+ g_ngi->_preloadManager->loadScene(SC_INV);
+ g_ngi->_gameLoader->preloadScene(SC_MAINMENU, 0);
+ doSetScene();
+ Chapter *chapter = g_ngi->_chapterManager->findChapter("CHAPTER_FINAL");
+ chapter->_countShow = 0;
+ chapter->_isStart = false;
+ g_ngi->_chapterManager->showChapterDialog("CHAPTER_FINAL", true);
+ return;
+ }
+ _scene->runQueue(QU_FN4_DOFINAL, 2);
+ if (_scene->_behaviorController)
+ _scene->_behaviorController->disableAllMusic();
+ g_ngi->_soundManager.stopAllSoundsByFlag(2);
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_HELPLESS_FINISH", 100, "UNDEF");
+ g_ngi->_achievementsManager->addActivatingCounter("ACHIEVEMENT_FINISH", 100, "UNDEF");
+ }
+ break;
+ default:
+ break;
+ }
+ g_ngi->_fader.setFadeParams(0, 0.0f, 0, 0, 0);
+}
+
+// CScFinalController::OnUpdate (19872C)
+void ScFinalController::onUpdate(uint32 elapsed) {
+ FPController::onUpdate(elapsed);
+ if (_follow) {
+ _coinX = _follow->getCenter().x;
+ if (_coinX <= 449 && _lastCoinX > 449)
+ doFallCoin();
+ _lastCoinX = _coinX;
+ }
+
+ Fader &fader = g_ngi->_fader;
+ fader.onUpdate(elapsed);
+ if (fader.getState() != Fader::kIdle)
+ return;
+ if (_state == 1) {
+ fader.startFade(0, 0, 1000);
+ fader.setAlpha(0.0f);
+ fader.setState(Fader::kFadeIn);
+ _state = 2;
+ } else if (_state == 2) {
+ _state = -1;
+ g_ngi->settings().setIsCompleted(true);
+ g_ngi->_preloadManager->loadScene(SC_INV);
+ g_ngi->_gameLoader->preloadScene(SC_MAINMENU, 0);
+ doSetScene();
+ g_ngi->_chapterManager->showChapterDialog("CHAPTER_FINAL", true);
+ }
+}
+
+// CScFinalController::OnMouseLKeyUp (19882C)
+bool ScFinalController::onMouseLKeyUp(uint32 id, float x, float y) {
+ if (_scene->_sceneId == SC_FINAL1)
+ return FPController::onMouseLKeyUp(id, x, y);
+ return false;
+}
+
+// CScFinalController::OnMouseLKeyDown (198848)
+bool ScFinalController::onMouseLKeyDown(uint32 id, float x, float y) {
+ if (_scene->_sceneId == SC_FINAL1)
+ return FPController::onMouseLKeyDown(id, x, y);
+ return false;
+}
+
+// CScFinalController::OnRender (198864)
+void ScFinalController::onRender(Common::Point scroll) {
+ FPController::onRender(scroll);
+ g_ngi->_fader.onRender();
+}
+
+// CScFinalController::OnMessage (19887C)
+void ScFinalController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message == "MSG_FIN_ACTIVATE") {
+ _scene->_motionController->activate();
+ getGameLoaderInteractionController()->_enabled = true;
+ } else if (message == "MSG_FIN_GOTO2") {
+ doSwitchTo2();
+ } else if (message == "MSG_FIN_GOTO3") {
+ doSwitchTo3();
+ } else if (message == "MSG_FIN_GOTO4") {
+ doSwitchTo4();
+ if (_scene->_behaviorController)
+ _scene->_behaviorController->disableAllMusic();
+ g_ngi->_soundManager.stopAllSoundsByFlag(2);
+ } else if (message == "MSG_FIN_STARTFINAL") {
+ doStartFinal();
+ } else if (message == "MSG_FIN_ENDFINAL") {
+ doEndFinal();
+ } else if (message == "MSG_SOUND_FIN_032") {
+ g_ngi->playSound(SND_FIN_032, 1);
+ } else if (message == "MSG_FN4_STARTMUSIC") {
+ g_ngi->playSound(SND_MUS_16, 1);
+ } else if (message == "MSG_FN3_SHOWHMR") {
+ _scene->findAniObjectById(ANI_FN3_HAND3, 0)->startMovement(MV_FNHND3_SHOWHMR, 0, -1);
+ } else {
+ FPController::onMessage(message, param, queue);
+ }
+}
+
+// CScFinalController::GetCursorType (198A18)
+int ScFinalController::getCursorType(float x, float y) {
+ if (_state < 0)
+ return FPController::getCursorType(x, y);
+ return 6;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mobile/scfinalcontroller.h b/engines/ngi/fullpipe/mobile/scfinalcontroller.h
new file mode 100644
index 00000000000..8c12711e1d9
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/scfinalcontroller.h
@@ -0,0 +1,61 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SCFINALCONTROLLER_H
+#define NGI_FULLPIPE_SCFINALCONTROLLER_H
+
+#include "ngi/fullpipe/mobile/fpcontroller.h"
+
+namespace NGI {
+
+/** CScFinalController (0xE4 bytes): the four scenes of the ending, SC_FINAL1 to SC_FINAL4 */
+class ScFinalController : public FPController {
+public:
+ /** CScFinalController::CScFinalController (1982EC) */
+ explicit ScFinalController(int sceneId);
+
+ void onShow() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ int getCursorType(float x, float y) override;
+ bool isInventoryEnabled() override { return false; }
+ bool isInventoryRendered() override { return false; }
+
+private:
+ // DoFallCoin (198324), DoEndFinal (198360), DoSwitchTo2..4 (1983CC..1983F4), DoStartFinal (19844C)
+ void doFallCoin();
+ void doEndFinal();
+ void doSwitchTo2();
+ void doSwitchTo3();
+ void doSwitchTo4();
+ void doStartFinal();
+
+ int _lastCoinX = 0; // +216
+ int _coinX = 0; // +220
+ int _state = -1; // +224: -1 idle, 0 plays, 1 ended, 2 fades out
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SCFINALCONTROLLER_H
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index f4770935453..a1d4d139d59 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -646,6 +646,9 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
actor->setPos(pivotX, pivotY);
}
_aniMan = scene->findAniObjectById(scene->_heroId, 0);
+ // CFPController::OnSceneInit (14F9C8): the hero is the ANI_MAN of SC_COMMON, a "hero" is optional
+ if (!_aniMan && !scene->_heroId && usesXMLProject() && common)
+ _aniMan = common->findAniObjectById(ANI_MAN, 0);
_aniMan2 = _aniMan;
if (scene->_heroId && !_aniMan)
return false;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index db4b934b785..5b3fdbf9cbd 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -153,6 +153,7 @@ MODULE_OBJS = \
fullpipe/mobile/sc37controller.o \
fullpipe/mobile/sc38controller.o \
fullpipe/mobile/scenecontrollers.o \
+ fullpipe/mobile/scfinalcontroller.o \
fullpipe/mobile/statemanager.o \
fullpipe/mobile/taskmanager.o \
fullpipe/mobile/tremble.o \
Commit: 3606d197544adbe4eb7b949cf6c45368c1bf58c9
https://github.com/scummvm/scummvm/commit/3606d197544adbe4eb7b949cf6c45368c1bf58c9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: CGuiSlider and CGuiCheckbox, hitAlpha of the GUI elements
Changed paths:
engines/ngi/guimanager.cpp
engines/ngi/guimanager.h
diff --git a/engines/ngi/guimanager.cpp b/engines/ngi/guimanager.cpp
index 7db0f7f3d8a..0c4be0add37 100644
--- a/engines/ngi/guimanager.cpp
+++ b/engines/ngi/guimanager.cpp
@@ -63,6 +63,7 @@ GuiElement::GuiElement(Scene &scene, const Common::StringMap &attrs, const Objec
_pos.x += _fitShift.x;
if (_hasY)
_pos.y += _fitShift.y;
+ _hitAlpha = atoi(attrs.getValOrDefault("hitAlpha", "128").c_str());
_cursor = atoi(attrs.getValOrDefault("cursor", "1").c_str());
_z = atoi(attrs.getValOrDefault("z").c_str());
_active = guiFlag(attrs, "active", true);
@@ -102,13 +103,6 @@ Common::Point GuiElement::screenPos() const {
return _scrolling ? _pos - Common::Point(_scene._x, _scene._y) : _pos;
}
-class GuiElementStub : public GuiElement {
-public:
- GuiElementStub(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) : GuiElement(scene, attrs, ids) {}
- void load(GameProject &project) override {}
- void render(Graphics::ManagedSurface &target) const override {}
-};
-
class GuiPicture : public GuiElement {
public:
GuiPicture(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) : GuiElement(scene, attrs, ids) {}
@@ -195,30 +189,6 @@ void GuiProgressBar::render(Graphics::ManagedSurface &target) const {
}
}
-class GuiButton : public GuiElement {
-public:
- GuiButton(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
- GuiButton(Scene &scene, const GuiButtonInit &init);
- void load(GameProject &project) override;
- void unload() override;
- uint loadTexture() override;
- uint unloadTexture() override;
- void activate() override;
- void render(Graphics::ManagedSurface &target) const override;
- bool hit(Common::Point pos) const override;
- bool onMouseMove(Common::Point pos) override;
- bool onMouseLKeyDown(Common::Point pos) override;
- bool onMouseLKeyUp(Common::Point pos) override;
-
-protected:
- enum State { kDisabled, kPressed, kSelected, kNumStates };
- int _pictureIds[kNumStates];
- PictureObject *_pictures[kNumStates] = {};
- Common::Point _offsets[kNumStates];
- bool _useOffsets;
- int _pressSound, _inactiveSound, _selectSound;
-};
-
GuiButton::GuiButton(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) :
GuiElement(scene, attrs, ids) {
_pictureIds[kDisabled] = resourceId(attrs, "tex_disable", ids);
@@ -452,6 +422,217 @@ bool GuiButton::onMouseLKeyUp(Common::Point pos) {
return handled;
}
+// CGuiSlider::CGuiSlider (101EC4)
+GuiSlider::GuiSlider(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) :
+ GuiElement(scene, attrs, ids) {
+ _x = (float)atof(attrs.getValOrDefault("x").c_str()) + _fitShift.x;
+ _y = (float)atof(attrs.getValOrDefault("y").c_str()) + _fitShift.y;
+ _pressSound = resourceId(attrs, "press", ids);
+ _selectSound = resourceId(attrs, "select", ids);
+ _startX = (float)atof(attrs.getValOrDefault("startX").c_str());
+ _startY = (float)atof(attrs.getValOrDefault("startY").c_str());
+ _endX = (float)atof(attrs.getValOrDefault("endX").c_str());
+ _endY = (float)atof(attrs.getValOrDefault("endY").c_str());
+}
+
+// CGuiSlider::Load (10149E) and Unload (1014C4): the size is the one of the texture
+uint GuiSlider::loadTexture() {
+ const uint size = _picture ? _picture->load() : 0;
+ if (_picture)
+ _size = _picture->getFullSize();
+ return size;
+}
+
+uint GuiSlider::unloadTexture() {
+ return _picture ? _picture->unload() : 0;
+}
+
+// CGuiSlider::Render (101512)
+void GuiSlider::render(Graphics::ManagedSurface &target) const {
+ if (!_visible || !_picture)
+ return;
+ float x = _x;
+ float y = _y;
+ if (_scrolling) {
+ x -= _scene._x;
+ y -= _scene._y;
+ }
+ _picture->_picture->blitTo(target, Common::Point((int)floorf(x + 0.5f), (int)floorf(y + 0.5f)));
+}
+
+// CGuiSlider::Hit (FFDC4): a scene point; the knob is hit where its texture is opaque enough
+bool GuiSlider::hitScene(float x, float y) const {
+ if (!_scrolling) {
+ x -= _scene._x;
+ y -= _scene._y;
+ }
+ if (!_visible)
+ return false;
+ const float localX = x - _x;
+ if (!(localX > 0.0f))
+ return false;
+ const float localY = y - _y;
+ if (!(localY > 0.0f))
+ return false;
+ if (!_picture)
+ return false;
+ Texture *texture = _picture->_picture;
+ const int oldX = texture->_x;
+ const int oldY = texture->_y;
+ texture->_x = 0;
+ texture->_y = 0;
+ const bool result = texture->hit((int)localX, (int)localY, _hitAlpha);
+ texture->_x = oldX;
+ texture->_y = oldY;
+ return result;
+}
+
+bool GuiSlider::hit(Common::Point pos) const {
+ return hitScene((float)(pos.x + _scene._x), (float)(pos.y + _scene._y));
+}
+
+// CGuiSlider::Move (100988)
+void GuiSlider::move(float x, float y) {
+ if (!_selected)
+ return;
+ _x = x - _pressOffsetX;
+ _y = y - _pressOffsetY;
+ if (_x < _startX)
+ _x = _startX;
+ else if (_x > _endX)
+ _x = _endX;
+ if (_y < _startY)
+ _y = _startY;
+ else if (_y > _endY)
+ _y = _endY;
+ _scene.onGuiEvent(_id, "slider_move");
+}
+
+// CGuiSlider::OnMouseMove (1030A0)
+bool GuiSlider::onMouseMove(Common::Point pos) {
+ if (!_active)
+ return false;
+ const float x = (float)(pos.x + _scene._x);
+ const float y = (float)(pos.y + _scene._y);
+ if (_pressed)
+ move(x, y);
+ const bool inside = hitScene(x, y);
+ if (inside) {
+ if (!_selected && _selectSound)
+ g_ngi->playSound(_selectSound, 0);
+ _selected = true;
+ } else if (!_pressed) {
+ _selected = false;
+ }
+ return inside;
+}
+
+// CGuiSlider::OnMouseLKeyDown (103004)
+bool GuiSlider::onMouseLKeyDown(Common::Point pos) {
+ if (!_selected)
+ return false;
+ if (_pressSound)
+ g_ngi->playSound(_pressSound, 0);
+ _scene.onGuiEvent(_id, "press");
+ _pressOffsetX = (float)(pos.x + _scene._x) - _x;
+ _pressOffsetY = (float)(pos.y + _scene._y) - _y;
+ _pressed = true;
+ return true;
+}
+
+// CGuiSlider::OnMouseLKeyUp (FFD58)
+bool GuiSlider::onMouseLKeyUp(Common::Point pos) {
+ if (!_pressed)
+ return false;
+ _scene.onGuiEvent(_id, "unpress");
+ _pressOffsetX = 0;
+ _pressOffsetY = 0;
+ _pressed = false;
+ return true;
+}
+
+// CGuiSlider::SetY (FF940)
+void GuiSlider::setY(float y) {
+ _y = y;
+ _startY = y;
+ _endY = y;
+}
+
+// CGuiSlider::SetPos (100A38)
+void GuiSlider::setPos(float pos) {
+ _x = _startX + pos * (_endX - _startX);
+ _y = _startY + pos * (_endY - _startY);
+}
+
+// CGuiSlider::GetPos (100A78)
+float GuiSlider::getPos() const {
+ const float lineX = _endX - _startX;
+ const float lineY = _endY - _startY;
+ const float length = (float)sqrt((double)(lineX * lineX + lineY * lineY));
+ const float knobX = _startX - _x;
+ const float knobY = _startY - _y;
+ const float distance = (float)sqrt((double)(knobX * knobX + knobY * knobY));
+ return distance / length;
+}
+
+// CGuiSlider::GetLogPos (100B30)
+float GuiSlider::getLogPos() const {
+ return (float)(log((double)getPos() + 0.000001) / 13.815510557964274 + 1.0);
+}
+
+// CGuiSlider::GetExpPos (100B78)
+float GuiSlider::getExpPos() const {
+ return (expf(getPos()) - 1.0f) / 1.7182817f;
+}
+
+// CGuiSlider::GetPowPos (100B98)
+float GuiSlider::getPowPos(float a) const {
+ return (powf(a, getPos()) - 1.0f) / (a - 1.0f);
+}
+
+// CGuiSlider::SetPowPos (100BC6)
+float GuiSlider::setPowPos(float a, float value) {
+ setPos(logf(value * (a - 1.0f) + 1.0f) / logf(a));
+ return getPowPos(a);
+}
+
+// CGuiCheckbox::CGuiCheckbox (102AD8)
+GuiCheckbox::GuiCheckbox(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids) :
+ GuiButton(scene, attrs, ids) {
+ _checked = guiFlag(attrs, "checked", false);
+ _checkSound = resourceId(attrs, "check", ids);
+ _uncheckSound = _checkSound;
+ if (attrs.contains("uncheck"))
+ _uncheckSound = resourceId(attrs, "uncheck", ids);
+}
+
+// CGuiCheckbox::Render (1016E0): the disabled picture, then the checked or the empty one
+void GuiCheckbox::render(Graphics::ManagedSurface &target) const {
+ if (!_visible)
+ return;
+ const Common::Point pos = screenPos();
+ if (_pictures[kDisabled])
+ _pictures[kDisabled]->_picture->blitTo(target, pos);
+ PictureObject *state = _checked ? _pictures[kPressed] : _picture;
+ if (state)
+ state->_picture->blitTo(target, pos);
+}
+
+// CGuiCheckbox::OnMouseLKeyUp (103110)
+bool GuiCheckbox::onMouseLKeyUp(Common::Point pos) {
+ if (!_selected || !_visible || !_active)
+ return false;
+ const bool wasChecked = _checked;
+ _checked = !_checked;
+ if (!wasChecked && _checkSound)
+ g_ngi->playSound(_checkSound, 0);
+ // the original plays the check sound again, not the uncheck one
+ if (!_checked && _uncheckSound)
+ g_ngi->playSound(_checkSound, 0);
+ _scene.onGuiEvent(_id, "unpress");
+ return true;
+}
+
GuiElement *GuiManager::createButton(const GuiButtonInit &init) {
GuiButton *button = new GuiButton(_scene, init);
button->load(*g_ngi->_gameProject);
@@ -480,10 +661,11 @@ void GuiManager::createElement(const Common::String &type, const Common::StringM
addGuiElement(new GuiText(_scene, attrs, ids));
else if (type == "TEXTBUTTON")
addGuiElement(new GuiTextButton(_scene, attrs, ids));
- else if (type == "SLIDER" || type == "CHECKBOX") {
- warning("STUB: %s", type.c_str());
- addGuiElement(new GuiElementStub(_scene, attrs, ids));
- } else
+ else if (type == "SLIDER")
+ addGuiElement(new GuiSlider(_scene, attrs, ids));
+ else if (type == "CHECKBOX")
+ addGuiElement(new GuiCheckbox(_scene, attrs, ids));
+ else
debugC(2, kDebugXML, "GUI element %s (%s) not implemented", type.c_str(), attrs.getValOrDefault("id").c_str());
}
diff --git a/engines/ngi/guimanager.h b/engines/ngi/guimanager.h
index adc3c8d50ee..6b5b56f4f5b 100644
--- a/engines/ngi/guimanager.h
+++ b/engines/ngi/guimanager.h
@@ -85,6 +85,7 @@ public:
Common::String _id;
Common::Point _pos, _size;
int _z, _cursor;
+ int _hitAlpha = 128; // +40: the alpha from which a pixel counts as hit (hitAlpha)
bool _active, _visible, _selected = false, _pressed = false;
protected:
@@ -117,6 +118,89 @@ private:
bool _lowBegin;
};
+// CGuiButton: the pictures of the states and the sounds of a button
+class GuiButton : public GuiElement {
+public:
+ GuiButton(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
+ GuiButton(Scene &scene, const GuiButtonInit &init);
+ void load(GameProject &project) override;
+ void unload() override;
+ uint loadTexture() override;
+ uint unloadTexture() override;
+ void activate() override;
+ void render(Graphics::ManagedSurface &target) const override;
+ bool hit(Common::Point pos) const override;
+ bool onMouseMove(Common::Point pos) override;
+ bool onMouseLKeyDown(Common::Point pos) override;
+ bool onMouseLKeyUp(Common::Point pos) override;
+
+protected:
+ enum State { kDisabled, kPressed, kSelected, kNumStates };
+ int _pictureIds[kNumStates];
+ PictureObject *_pictures[kNumStates] = {};
+ Common::Point _offsets[kNumStates];
+ bool _useOffsets;
+ int _pressSound;
+ int _inactiveSound;
+ int _selectSound;
+};
+
+
+// CGuiSlider (0x58 bytes): a knob on the line (startX, startY) to (endX, endY), float position
+class GuiSlider : public GuiElement {
+public:
+ GuiSlider(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
+ uint loadTexture() override;
+ uint unloadTexture() override;
+ void render(Graphics::ManagedSurface &target) const override;
+ bool hit(Common::Point pos) const override;
+ bool onMouseMove(Common::Point pos) override;
+ bool onMouseLKeyDown(Common::Point pos) override;
+ bool onMouseLKeyUp(Common::Point pos) override;
+
+ /** CGuiSlider::SetY (FF940): the knob and both ends of the line are at this y */
+ void setY(float y);
+ /** The place on the line, 0 at the start and 1 at the end (SetPos 100A38, GetPos 100A78) */
+ void setPos(float pos);
+ float getPos() const;
+ float getLogPos() const;
+ float getExpPos() const;
+ /** (a ^ pos - 1) / (a - 1) and its inverse (GetPowPos 100B98, SetPowPos 100BC6) */
+ float getPowPos(float a) const;
+ float setPowPos(float a, float value);
+
+private:
+ void move(float x, float y);
+ bool hitScene(float x, float y) const;
+
+ float _x; // +20
+ float _y; // +24
+ int _selectSound; // +56
+ int _pressSound; // +60
+ float _pressOffsetX = 0; // +64
+ float _pressOffsetY = 0; // +68
+ float _startX; // +72
+ float _startY; // +76
+ float _endX; // +80
+ float _endY; // +84
+};
+
+// CGuiCheckbox (0x88 bytes): a button that is checked or not
+class GuiCheckbox : public GuiButton {
+public:
+ GuiCheckbox(Scene &scene, const Common::StringMap &attrs, const ObjectIdList &ids);
+ void render(Graphics::ManagedSurface &target) const override;
+ bool onMouseLKeyUp(Common::Point pos) override;
+
+ void setChecked(bool checked) { _checked = checked; }
+ bool getChecked() const { return _checked; }
+
+private:
+ bool _checked; // +128
+ int _checkSound; // +132
+ int _uncheckSound; // +136
+};
+
class BitmapFont;
// CGuiText: a line (aligned to x) or, with "separate", text wrapped into the box w x h
Commit: 8447e48cd7395bc94f44efaac1b56577dc097b06
https://github.com/scummvm/scummvm/commit/8447e48cd7395bc94f44efaac1b56577dc097b06
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: CScOptionsController, the options scene of the main menu
Changed paths:
A engines/ngi/fullpipe/mobile/scoptionscontroller.cpp
A engines/ngi/fullpipe/mobile/scoptionscontroller.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
engines/ngi/fullpipe/mobile/scenecontrollers.cpp
engines/ngi/fullpipe/mobile/settings.h
engines/ngi/module.mk
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 5b71af54398..12bbffd7e76 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -1917,6 +1917,8 @@ namespace NGI {
#define TrubaLeft_fin 23274
#define SC_CONFIRMATION 23496
#define SC_OPTIONS 10009
+#define PIC_OPT_BGR 23514
+#define PIC_OPT_BGR_IOS 28116
// Android: names of obj.h that the ported controllers use
#define QU_EGTR_FATASK 5334
diff --git a/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp b/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
index bced6ba6ccc..0b2786d5515 100644
--- a/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/mainmenucontroller.cpp
@@ -100,7 +100,11 @@ void pushDialog(int sceneId, int mode) {
g_ngi->pushScene(sceneId);
return;
}
- warnOnce(Common::String::format("CGame::PushScene(%d) (mode %d): the controller of the scene (CScOptionsController) is not ported, the scene is not pushed", sceneId, mode).c_str());
+ if (sceneId == SC_OPTIONS) {
+ g_ngi->pushScene(sceneId);
+ return;
+ }
+ warnOnce(Common::String::format("CGame::PushScene(%d) (mode %d): the scene has no controller here, it is not pushed", sceneId, mode).c_str());
}
} // End of anonymous namespace
diff --git a/engines/ngi/fullpipe/mobile/scenecontrollers.cpp b/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
index c8369b36207..ea504fb2ac3 100644
--- a/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
@@ -59,6 +59,7 @@
#include "ngi/fullpipe/mobile/sc23controller.h"
#include "ngi/fullpipe/mobile/scenecontrollers.h"
#include "ngi/fullpipe/mobile/scfinalcontroller.h"
+#include "ngi/fullpipe/mobile/scoptionscontroller.h"
#include "ngi/fullpipe/mobile/sc03controller.h"
#include "ngi/fullpipe/mobile/sc04controller.h"
#include "ngi/fullpipe/mobile/chaptercontroller.h"
@@ -224,6 +225,9 @@ void createSceneController(int sceneId) {
case SC_CONFIRMATION:
new ConfirmationDlg(sceneId);
break;
+ case SC_OPTIONS:
+ new ScOptionsController(sceneId);
+ break;
case SC_MAP:
new MapWindowController(sceneId);
break;
diff --git a/engines/ngi/fullpipe/mobile/scoptionscontroller.cpp b/engines/ngi/fullpipe/mobile/scoptionscontroller.cpp
new file mode 100644
index 00000000000..126602bbaeb
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/scoptionscontroller.cpp
@@ -0,0 +1,148 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ngi/ngi.h"
+#include "ngi/guimanager.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/mobile/controllerhelpers.h"
+#include "ngi/fullpipe/mobile/scoptionscontroller.h"
+#include "ngi/fullpipe/mobile/settings.h"
+
+namespace NGI {
+
+// CScOptionsController::CScOptionsController (19C954)
+ScOptionsController::ScOptionsController(int sceneId) : FPGuiController(sceneId) {
+}
+
+// CScOptionsController::OnShow (19CDBC)
+void ScOptionsController::onShow() {
+ FPGuiController::onShow();
+ _timer = -1;
+ GuiManager *gui = _scene->_guiManager.get();
+ _soundSlider = static_cast<GuiSlider *>(gui->getElement("SLIDER_OPT_SOUND"));
+ _musicSlider = static_cast<GuiSlider *>(gui->getElement("SLIDER_OPT_MUSIC"));
+ _checkbox = static_cast<GuiCheckbox *>(gui->getElement("CHECK_OPT_CHECK"));
+ _soundSlider->setPowPos(10.0f, (float)g_ngi->getSoundSetting() / 100.0f);
+ _musicSlider->setPowPos(10.0f, (float)g_ngi->getMusicSetting() / 100.0f);
+ _checkbox->setChecked(g_ngi->settings().getSendNotif());
+ _scene->findPictureObjectById(PIC_OPT_BGR, 0)->_flags |= 4;
+ _scene->findPictureObjectById(PIC_OPT_BGR_IOS, 0)->_flags &= ~4;
+ gui->getElement("BTN_SC_OPT_RESTORE")->hideAndDeactivate();
+ debugC(1, kDebugInfo, "INFO t %u OPTIONS shown: sound %d music %d notifications %d", g_system->getMillis(), g_ngi->getSoundSetting(), g_ngi->getMusicSetting(),
+ g_ngi->settings().getSendNotif());
+}
+
+// CScOptionsController::OnHide (19C8EC)
+void ScOptionsController::onHide() {
+ _timer = -1;
+}
+
+// CScOptionsController::OnUpdate (19CF0C): the volume follows a pressed slider every half second
+void ScOptionsController::onUpdate(uint32 elapsed) {
+ FPGuiController::onUpdate(elapsed);
+ if (_timer != -1) {
+ _timer += elapsed;
+ if (_timer > 499) {
+ _timer = 0;
+ g_ngi->_soundManager.attenuate();
+ }
+ }
+}
+
+// CScOptionsController::OnRenderBottom (19CD14)
+void ScOptionsController::onRenderBottom(Common::Point scroll) {
+ dimScreen(0.4f);
+}
+
+// CScOptionsController::OnMessage (19C984)
+void ScOptionsController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message != "PURCHASE_COMPLETED")
+ return;
+ warnOnce("STUB/untested: CScOptionsController::OnMessage PURCHASE_COMPLETED is never sent (no store)");
+ const Common::String unlockId; // CSettings::GetUnlockId: not ported
+ if (param == unlockId) {
+ g_ngi->settings().setIsFull(true);
+ g_ngi->findScene(SC_MAINMENU)->message(message, param, nullptr);
+ g_ngi->getSceneInStack(0)->message("MSG_COMPLTEUPSELL", "", nullptr);
+ g_ngi->popScene();
+ } else {
+ warnOnce("CNotebookController::OnPurchaseCompleted: not ported");
+ }
+}
+
+// CScOptionsController::OnGuiEvent (19CA9C)
+void ScOptionsController::onGuiEvent(const Common::String &id, const Common::String &event) {
+ if (event == "unpress") {
+ if (id == "BTN_OPT_CLOSE") {
+ g_ngi->popScene();
+ } else if (id == "BTN_OPT_CREDITS") {
+ g_ngi->pushScene(SC_TITLES);
+ } else if (id == "SLIDER_OPT_SOUND") {
+ _timer = -1;
+ g_ngi->setSoundSetting((int)(float)((double)_soundSlider->getPowPos(10.0f) * 100.0));
+ g_ngi->_soundManager.attenuate();
+ debugC(1, kDebugInfo, "INFO t %u OPTIONS sound %d music %d", g_system->getMillis(), g_ngi->getSoundSetting(), g_ngi->getMusicSetting());
+ } else if (id == "SLIDER_OPT_MUSIC") {
+ _timer = -1;
+ g_ngi->setMusicSetting((int)(float)((double)_musicSlider->getPowPos(10.0f) * 100.0));
+ g_ngi->_soundManager.attenuate();
+ if (g_ngi->_sceneStack.size() >= 2)
+ g_ngi->getSceneInStack(0)->message("MSG_MUSIC_VOL_CHANGED", "", nullptr);
+ debugC(1, kDebugInfo, "INFO t %u OPTIONS sound %d music %d", g_system->getMillis(), g_ngi->getSoundSetting(), g_ngi->getMusicSetting());
+ } else if (id == "CHECK_OPT_CHECK") {
+ g_ngi->settings().setSendNotif(!g_ngi->settings().getSendNotif());
+ debugC(1, kDebugInfo, "INFO t %u OPTIONS notifications %d", g_system->getMillis(), g_ngi->settings().getSendNotif());
+ } else if (id == "BTN_SC_OPT_RESTORE") {
+ warnOnce("PP_storeRestorePurchases: the store of the Android application is not ported");
+ }
+ } else if (event == "press") {
+ if (id == "SLIDER_OPT_SOUND" || id == "SLIDER_OPT_MUSIC")
+ _timer = 0;
+ } else if (event == "slider_move") {
+ if (id == "SLIDER_OPT_SOUND")
+ g_ngi->setSoundSetting((int)(float)((double)_soundSlider->getPowPos(10.0f) * 100.0));
+ else if (id == "SLIDER_OPT_MUSIC")
+ g_ngi->setMusicSetting((int)(float)((double)_musicSlider->getPowPos(10.0f) * 100.0));
+ }
+}
+
+// CScOptionsController::OnMouseLKeyDown (19C8D8): the click stays in the dialog
+bool ScOptionsController::onMouseLKeyDown(uint32 id, float x, float y) {
+ return true;
+}
+
+// CScOptionsController::OnMouseLKeyUp (19C8DC)
+bool ScOptionsController::onMouseLKeyUp(uint32 id, float x, float y) {
+ return true;
+}
+
+// CScOptionsController::OnMouseRKeyDown (19C8E0)
+bool ScOptionsController::onMouseRKeyDown(uint32 id, float x, float y) {
+ return true;
+}
+
+// CScOptionsController::OnMouseRKeyUp (19C8E4)
+bool ScOptionsController::onMouseRKeyUp(uint32 id, float x, float y) {
+ return true;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mobile/scoptionscontroller.h b/engines/ngi/fullpipe/mobile/scoptionscontroller.h
new file mode 100644
index 00000000000..e44ca856c09
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/scoptionscontroller.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SCOPTIONSCONTROLLER_H
+#define NGI_FULLPIPE_SCOPTIONSCONTROLLER_H
+
+#include "ngi/fullpipe/mobile/fpguicontroller.h"
+
+namespace NGI {
+
+class GuiCheckbox;
+class GuiSlider;
+
+/** CScOptionsController (0x20 bytes): SC_OPTIONS, the volumes and the notifications */
+class ScOptionsController : public FPGuiController {
+public:
+ /** CScOptionsController::CScOptionsController (19C954) */
+ explicit ScOptionsController(int sceneId);
+
+ void onShow() override;
+ void onHide() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRenderBottom(Common::Point scroll) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onGuiEvent(const Common::String &id, const Common::String &event) override;
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseRKeyDown(uint32 id, float x, float y) override;
+ bool onMouseRKeyUp(uint32 id, float x, float y) override;
+ bool isInventoryEnabled() override { return false; }
+
+private:
+ GuiSlider *_soundSlider = nullptr; // +16
+ GuiSlider *_musicSlider = nullptr; // +20
+ GuiCheckbox *_checkbox = nullptr; // +24
+ int _timer = -1; // +28: ms since the slider was pressed, -1 when none is
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SCOPTIONSCONTROLLER_H
diff --git a/engines/ngi/fullpipe/mobile/settings.h b/engines/ngi/fullpipe/mobile/settings.h
index 8f14e20c06e..0cf17072427 100644
--- a/engines/ngi/fullpipe/mobile/settings.h
+++ b/engines/ngi/fullpipe/mobile/settings.h
@@ -79,6 +79,11 @@ public:
_saving = saving;
}
+ // CSettings +36
+ bool getSendNotif() const {
+ return _sendNotif;
+ }
+
// CSettings::SetSendNotif (19DF16), PP_cancelAllNotifications is not ported
void setSendNotif(bool send) {
_sendNotif = send;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 5b3fdbf9cbd..144818a0c29 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -154,6 +154,7 @@ MODULE_OBJS = \
fullpipe/mobile/sc38controller.o \
fullpipe/mobile/scenecontrollers.o \
fullpipe/mobile/scfinalcontroller.o \
+ fullpipe/mobile/scoptionscontroller.o \
fullpipe/mobile/statemanager.o \
fullpipe/mobile/taskmanager.o \
fullpipe/mobile/tremble.o \
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index ca0c1a55a18..11fc7fd93c6 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -2022,6 +2022,7 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
createSceneController(SC_TUTORIAL); // CTutorialController
createSceneController(SC_MAINMENU); // CMainMenu
createSceneController(SC_CONFIRMATION); // CConfirmationDlg
+ createSceneController(SC_OPTIONS); // CScOptionsController
createSceneController(SC_MAP); // CMapWindow
g_ngi->_map.reset(new Map); // CMap, CMap::Reset
g_ngi->_map->reset();
Commit: 5658cc9abcef99d3e732632c5669f5becd96159c
https://github.com/scummvm/scummvm/commit/5658cc9abcef99d3e732632c5669f5becd96159c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Rename CreditsController to ModalCredits
Changed paths:
engines/ngi/modal.cpp
engines/ngi/modal.h
diff --git a/engines/ngi/modal.cpp b/engines/ngi/modal.cpp
index 37a7aa13662..7d02ad99720 100644
--- a/engines/ngi/modal.cpp
+++ b/engines/ngi/modal.cpp
@@ -1122,7 +1122,7 @@ bool ModalFinal::init(int counterdiff) {
unloadScenes();
- g_ngi->_modalObject = new CreditsController();
+ g_ngi->_modalObject = new ModalCredits();
return true;
}
@@ -1180,7 +1180,7 @@ void ModalFinal::update() {
}
}
-CreditsController::CreditsController() {
+ModalCredits::ModalCredits() {
_sceneTitles = g_ngi->findScene(SC_TITLES);
_creditsPic = _sceneTitles->findPictureObjectById(PIC_TTL_CREDITS, 0);
@@ -1206,7 +1206,7 @@ CreditsController::CreditsController() {
keymapper->getKeymap("credits")->setEnabled(true);
}
-CreditsController::~CreditsController() {
+ModalCredits::~ModalCredits() {
g_ngi->_gameLoader->unloadScene(SC_TITLES);
g_ngi->_sfxVolume = _sfxVolume;
@@ -1216,7 +1216,7 @@ CreditsController::~CreditsController() {
keymapper->getKeymap("ngi-default")->setEnabled(true);
}
-bool CreditsController::handleMessage(Command *cmd) {
+bool ModalCredits::handleMessage(Command *cmd) {
if (cmd->_cmd == kCmdMessage && cmd->_messageNum == kMsgKeyDown && cmd->_param == kActionSkipCredits) {
_fadeIn = false;
@@ -1226,7 +1226,7 @@ bool CreditsController::handleMessage(Command *cmd) {
return false;
}
-bool CreditsController::init(int counterdiff) {
+bool ModalCredits::init(int counterdiff) {
if (_fadeIn || _fadeOut) {
_countdown--;
@@ -1251,7 +1251,7 @@ bool CreditsController::init(int counterdiff) {
return true;
}
-void CreditsController::update() {
+void ModalCredits::update() {
if (_fadeOut) {
if (_fadeIn) {
_sceneTitles->render();
@@ -1493,7 +1493,7 @@ bool MainMenu::init(int counterdiff) {
break;
case PIC_MNU_AUTHORS_L:
- g_ngi->_modalObject = new CreditsController();
+ g_ngi->_modalObject = new ModalCredits();
g_ngi->_modalObject->_parentObj = this;
_hoverAreaId = 0;
diff --git a/engines/ngi/modal.h b/engines/ngi/modal.h
index 9b323b68ede..d012a9fe86d 100644
--- a/engines/ngi/modal.h
+++ b/engines/ngi/modal.h
@@ -177,7 +177,7 @@ class ModalFinal : public BaseModalObject {
void unloadScenes();
};
-class CreditsController : public BaseModalObject {
+class ModalCredits : public BaseModalObject {
Scene *_sceneTitles;
PictureObject *_creditsPic;
bool _fadeIn;
@@ -189,8 +189,8 @@ class CreditsController : public BaseModalObject {
int _maxY;
public:
- CreditsController();
- ~CreditsController() override;
+ ModalCredits();
+ ~ModalCredits() override;
bool pollEvent() override { return true; }
bool handleMessage(Command *message) override;
Commit: bc1043693dc69e97b4e783a0969f1a3aea8fcfa4
https://github.com/scummvm/scummvm/commit/bc1043693dc69e97b4e783a0969f1a3aea8fcfa4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: CCreditsController, the credits of the options scene
Changed paths:
A engines/ngi/fullpipe/mobile/creditscontroller.cpp
A engines/ngi/fullpipe/mobile/creditscontroller.h
engines/ngi/fullpipe/constants.h
engines/ngi/fullpipe/mobile/scenecontrollers.cpp
engines/ngi/module.mk
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 12bbffd7e76..5ed72db25b5 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -243,6 +243,14 @@ namespace NGI {
#define PIC_MAP_H37 5391
#define PIC_MAP_H38 5392
#define PIC_TTL_CREDITS 5172
+#define PIC_TTL_CREDITS_1 23005
+#define PIC_TTL_CREDITS_2 23006
+#define PIC_TTL_CREDITS_3 23510
+#define PIC_SC_TITLES_BGR_DN 63274
+#define PIC_SC_TITLES_BGR_DN_IOS 28113
+#define PIC_SC_TITLES_BGR_UP 23527
+#define PIC_SC_TITLES_BGR_UPFB 23528
+#define QU_TTL_EXIT 28071
#define QU_INTR_STARTINTRO 5133
#define SC_1 301
#define SC_2 302
diff --git a/engines/ngi/fullpipe/mobile/creditscontroller.cpp b/engines/ngi/fullpipe/mobile/creditscontroller.cpp
new file mode 100644
index 00000000000..a45d87acb54
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/creditscontroller.cpp
@@ -0,0 +1,217 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/util.h"
+
+#include "ngi/ngi.h"
+#include "ngi/gameloader.h"
+#include "ngi/messages.h"
+#include "ngi/scene.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/mobile/controllerhelpers.h"
+#include "ngi/fullpipe/mobile/creditscontroller.h"
+#include "ngi/fullpipe/mobile/platformservices.h"
+
+namespace NGI {
+
+namespace {
+
+int wholePixel(float value) {
+ return (int)floorf(value + 0.5f);
+}
+
+// the ids of the objects are int16 here, those over 32767 wrap around
+PictureObject *findPicture(Scene *scene, int id) {
+ return scene->findPictureObjectById(static_cast<int16>(id), 0);
+}
+
+} // End of anonymous namespace
+
+// The pictures one under the other, the first at (_x, _y), z -1001 (a part of OnShow and OnUpdate)
+void CreditsController::layoutPictures() {
+ for (uint i = 0; i < _pictures.size(); i++) {
+ float x;
+ float y;
+ if (i != 0) {
+ const PictureObject *previous = _pictures[i - 1];
+ x = (float)previous->getPosition().x;
+ y = (float)previous->getPosition().y + (float)previous->getSize().y;
+ } else {
+ x = _x;
+ y = _y;
+ }
+ _pictures[i]->setPosition(Common::Point(wholePixel(x), wholePixel(y)));
+ _pictures[i]->_z = -1001;
+ }
+}
+
+// CCreditsController::CCreditsController (198BFC)
+CreditsController::CreditsController(int sceneId) : FPGuiController(sceneId) {
+}
+
+// CCreditsController::OnShow (199898)
+void CreditsController::onShow() {
+ FPGuiController::onShow();
+ for (PictureObject *picture : _hidden)
+ picture->_flags &= ~4;
+ if (_pictures.empty()) {
+ _pictures.push_back(findPicture(_scene, PIC_TTL_CREDITS));
+ _pictures.push_back(findPicture(_scene, PIC_TTL_CREDITS_1));
+ _pictures.push_back(findPicture(_scene, PIC_TTL_CREDITS_2));
+ _pictures.push_back(findPicture(_scene, PIC_TTL_CREDITS_3));
+ }
+ for (PictureObject *picture : _pictures)
+ picture->_flags |= 4;
+ _onScreen = true;
+ _flag45 = false;
+
+ float height = 0.0f;
+ for (PictureObject *picture : _pictures)
+ height += (float)picture->getSize().y;
+ _y = 459.0f;
+ _target = 600.0f - height;
+ _speed = -0.1f;
+ _x = 416.0f - (float)_pictures[0]->getSize().x * 0.5f;
+ layoutPictures();
+
+ findPicture(_scene, PIC_SC_TITLES_BGR_DN)->_flags |= 4;
+ findPicture(_scene, PIC_SC_TITLES_BGR_DN_IOS)->_flags &= ~4;
+ const bool connected = platformQuery("PP_FB_isConnected");
+ PictureObject *up = findPicture(_scene, PIC_SC_TITLES_BGR_UP);
+ PictureObject *upFacebook = findPicture(_scene, PIC_SC_TITLES_BGR_UPFB);
+ if (connected) {
+ up->_flags &= ~4;
+ upFacebook->_flags |= 4;
+ } else {
+ up->_flags |= 4;
+ upFacebook->_flags &= ~4;
+ }
+}
+
+// CCreditsController::OnHide (198A4E)
+void CreditsController::onHide() {
+ for (PictureObject *picture : _hidden)
+ picture->_flags |= 4;
+}
+
+// CCreditsController::OnUpdate (199A90)
+void CreditsController::onUpdate(uint32 elapsed) {
+ FPGuiController::onUpdate(elapsed);
+ if (_queue)
+ _queue->update(elapsed);
+ if (!_onScreen && !_flag45) {
+ exitToMainMenu(_flag45);
+ return;
+ }
+ _onScreen = false;
+ layoutPictures();
+ for (PictureObject *picture : _pictures) {
+ if (picture->isOnScreen(_scene))
+ _onScreen = true;
+ }
+ _y += (float)elapsed * _speed;
+ const PictureObject *last = _pictures.back();
+ if ((float)last->getPosition().y + (float)last->getSize().y < 459.0f)
+ queueMainMenu();
+}
+
+// CCreditsController::OnRender (198A70)
+void CreditsController::onRender(Common::Point scroll) {
+ for (PictureObject *picture : _hidden)
+ picture->render(scroll);
+}
+
+// CCreditsController::OnKeyUp (199150)
+void CreditsController::onKeyUp(uint32 key) {
+ if (key == 4)
+ exitToMainMenu(true);
+}
+
+// CCreditsController::OnMouseLKeyUp (199144)
+bool CreditsController::onMouseLKeyUp(uint32 id, float x, float y) {
+ exitToMainMenu(true);
+ return true;
+}
+
+// CCreditsController::ExecuteUserCmd (199160)
+void CreditsController::executeUserCmd(Command *cmd, MessageQueue *queue) {
+ if (cmd->_messageName != "MOVE" && cmd->_messageName == "GOOUT")
+ exitToMainMenu(true);
+}
+
+// CCreditsController::UpdateUserCmd (198AD4): MOVE waits while a picture is on the screen
+bool CreditsController::updateUserCmd(Command *cmd, uint32 elapsed) {
+ bool waiting = false;
+ if (cmd->_messageName == "MOVE") {
+ for (PictureObject *picture : _pictures) {
+ if (picture->isOnScreen(_scene))
+ waiting = true;
+ }
+ }
+ return waiting;
+}
+
+// CCreditsController::QueueMainMenu (198F14)
+void CreditsController::queueMainMenu() {
+ if (!_queue)
+ return;
+ if (_queue->_deleteAfter) {
+ _queue->getCommandByIndex(0)->_args["fast"] = fabsf(_speed) == 1.0f ? "1" : "0";
+ return;
+ }
+ _queue->stop(_queue->_deleteAfter);
+ Scene *scene = _queue->_scene;
+ _queue = new MessageQueue(scene, true, 1);
+ Command *command = new Command(0, kCmdUser, 0, 0, 0, 0, 1, 0, 0, 0);
+ command->_excFlags |= 2;
+ if (_speed <= 0.0f) {
+ command->_messageName = "MOVE_FR_DN";
+ command->_args["type"] = "MOVE_FR_DN";
+ const PictureObject *last = _pictures.back();
+ command->_args["anchor"] = Common::String::format("%f", (float)last->getPosition().y + (float)last->getSize().y);
+ command->_args["fast"] = fabsf(_speed) == 1.0f ? "1" : "0";
+ } else {
+ command->_messageName = "MOVE_FR_UP";
+ command->_args["type"] = "MOVE_FR_UP";
+ command->_args["anchor"] = Common::String::format("%f", (float)_pictures[0]->getPosition().y - 459.0f);
+ }
+ _queue->addCommandToEnd(command);
+ _queue->_scene->runQueueObject(_queue, nullptr, 4);
+}
+
+// CCreditsController::ExitToMainMenu (1990B0)
+void CreditsController::exitToMainMenu(bool leave) {
+ debugC(1, kDebugInfo, "INFO t %u CREDITS exit %d: y %g speed %g, scenes %u", g_system->getMillis(), leave, _y, _speed, g_ngi->_sceneStack.size());
+ if (leave) {
+ if (g_ngi->_sceneStack.size() < 2) {
+ g_ngi->_gameLoader->preloadScene(SC_MAINMENU, 0); // CGame::SetScene
+ doSetScene();
+ } else {
+ g_ngi->popScene();
+ }
+ } else if (fabsf(_speed) == 0.1f) {
+ _speed = _y >= (_target - 459.0f) * 0.5f ? 1.0f : -1.0f;
+ queueMainMenu();
+ _scene->runQueue(QU_TTL_EXIT, 4);
+ }
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mobile/creditscontroller.h b/engines/ngi/fullpipe/mobile/creditscontroller.h
new file mode 100644
index 00000000000..c3b50a9ef9f
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/creditscontroller.h
@@ -0,0 +1,68 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_CREDITSCONTROLLER_H
+#define NGI_FULLPIPE_CREDITSCONTROLLER_H
+
+#include "common/array.h"
+
+#include "ngi/fullpipe/mobile/fpguicontroller.h"
+
+namespace NGI {
+
+class MessageQueue;
+class PictureObject;
+
+/** CCreditsController (0x40 bytes): SC_TITLES, the pictures of the credits move up the screen */
+class CreditsController : public FPGuiController {
+public:
+ /** CCreditsController::CCreditsController (198BFC) */
+ explicit CreditsController(int sceneId);
+
+ void onShow() override;
+ void onHide() override;
+ void onUpdate(uint32 elapsed) override;
+ void onRender(Common::Point scroll) override;
+ void onKeyUp(uint32 key) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ void executeUserCmd(Command *cmd, MessageQueue *queue) override;
+ bool updateUserCmd(Command *cmd, uint32 elapsed) override;
+
+private:
+ /** QueueMainMenu (198F14), ExitToMainMenu (1990B0) */
+ void layoutPictures();
+ void queueMainMenu();
+ void exitToMainMenu(bool leave);
+
+ Common::Array<PictureObject *> _pictures; // +16: the four pictures of the credits, one under the other
+ Common::Array<PictureObject *> _hidden; // +28: shown by OnHide and OnRender, nothing fills it
+ MessageQueue *_queue = nullptr; // +40
+ bool _onScreen = true; // +44: a picture is on the screen
+ bool _flag45 = false; // +45
+ float _y = 459.0f; // +48: the top of the first picture
+ float _target = 0; // +52: _y when the last picture has left
+ float _speed = 0; // +56: ms to pixels, negative goes up
+ float _x = 0; // +60
+};
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_CREDITSCONTROLLER_H
diff --git a/engines/ngi/fullpipe/mobile/scenecontrollers.cpp b/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
index ea504fb2ac3..94f7daf4969 100644
--- a/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
+++ b/engines/ngi/fullpipe/mobile/scenecontrollers.cpp
@@ -64,6 +64,7 @@
#include "ngi/fullpipe/mobile/sc04controller.h"
#include "ngi/fullpipe/mobile/chaptercontroller.h"
#include "ngi/fullpipe/mobile/confirmationdlg.h"
+#include "ngi/fullpipe/mobile/creditscontroller.h"
#include "ngi/fullpipe/mobile/help.h"
#include "ngi/fullpipe/mobile/notebook.h"
#include "ngi/fullpipe/mobile/introcontroller.h"
@@ -228,6 +229,9 @@ void createSceneController(int sceneId) {
case SC_OPTIONS:
new ScOptionsController(sceneId);
break;
+ case SC_TITLES:
+ new CreditsController(sceneId);
+ break;
case SC_MAP:
new MapWindowController(sceneId);
break;
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index 144818a0c29..b4f46ddfbf6 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -97,6 +97,7 @@ MODULE_OBJS = \
fullpipe/mobile/chaptermanager.o \
fullpipe/mobile/confirmationdlg.o \
fullpipe/mobile/controllerhelpers.o \
+ fullpipe/mobile/creditscontroller.o \
fullpipe/mobile/exitmanager.o \
fullpipe/mobile/fpcontroller.o \
fullpipe/mobile/fpguicontroller.o \
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 11fc7fd93c6..12f86b92744 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -2023,6 +2023,7 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
createSceneController(SC_MAINMENU); // CMainMenu
createSceneController(SC_CONFIRMATION); // CConfirmationDlg
createSceneController(SC_OPTIONS); // CScOptionsController
+ createSceneController(SC_TITLES); // CCreditsController
createSceneController(SC_MAP); // CMapWindow
g_ngi->_map.reset(new Map); // CMap, CMap::Reset
g_ngi->_map->reset();
Commit: e4f04d29a3b5f471dfa2c57a8f651d3c22599403
https://github.com/scummvm/scummvm/commit/e4f04d29a3b5f471dfa2c57a8f651d3c22599403
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: CSplashScreen and CSplashScreenController, the start sequence
Changed paths:
A engines/ngi/fullpipe/mobile/splashscreen.cpp
A engines/ngi/fullpipe/mobile/splashscreen.h
engines/ngi/detection.cpp
engines/ngi/font.cpp
engines/ngi/fullpipe/constants.h
engines/ngi/gameloader.h
engines/ngi/module.mk
engines/ngi/ngi.cpp
engines/ngi/ngi.h
engines/ngi/preloadmanager.cpp
engines/ngi/scene.cpp
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/detection.cpp b/engines/ngi/detection.cpp
index cfc5932ae5e..ad3b165381b 100644
--- a/engines/ngi/detection.cpp
+++ b/engines/ngi/detection.cpp
@@ -44,6 +44,7 @@ static const DebugChannelDef debugFlagList[] = {
{NGI::kDebugFast, "fast", "Six times faster game, for test runs"},
{NGI::kDebugSkipIntro, "skipIntro", "Starts without the initial tutorial (the Skip button of it is pressed at the start)"},
{NGI::kDebugNoRandom, "noRandom", "Repeatable runs for tests: fixed random seed, fixed update steps, no cursor in the Windows games, --start-movie=freeze=N stops the updates"},
+ {NGI::kDebugSplash, "splash", "Shows the start screen (logos, progress bar) with --boot-param too"},
DEBUG_CHANNEL_END
};
diff --git a/engines/ngi/font.cpp b/engines/ngi/font.cpp
index aa281ee58ce..68f9af8e3c4 100644
--- a/engines/ngi/font.cpp
+++ b/engines/ngi/font.cpp
@@ -199,6 +199,7 @@ private:
if (page->getDimensions().x == 0)
return parserError("Missing bitmap font page");
_font._pages.push_back(page);
+ g_ngi->incrementLoadingPercent(1); // CFont::Load (FAA08): a unit per texture page
return true;
}
@@ -220,6 +221,7 @@ private:
g.advance = w;
_font._lineHeight = MAX(_font._lineHeight, h);
_font._maxWidth = MAX(_font._maxWidth, _font.getCharWidth(id));
+ g_ngi->incrementLoadingPercent(1); // a unit per glyph
return true;
}
bool parserCallback_pages(ParserNode *) { return true; }
@@ -249,6 +251,7 @@ private:
if (page->getDimensions().x == 0)
return parserError("Missing bitmap font page");
_font._pages.push_back(page);
+ g_ngi->incrementLoadingPercent(1);
return true;
}
@@ -272,6 +275,7 @@ private:
if (!g.advance)
g.advance = w;
_font._maxWidth = MAX(_font._maxWidth, _font.getCharWidth(id));
+ g_ngi->incrementLoadingPercent(1);
return true;
}
@@ -290,6 +294,9 @@ bool BitmapFont::load(const Common::Path &path) {
warning("Could not load bitmap font %s", path.toString().c_str());
return false;
}
+ // CFont::Load unloads every page again after the glyphs: a unit each
+ for (uint i = 0; i < font._pages.size(); i++)
+ g_ngi->incrementLoadingPercent(1);
*this = Common::move(font);
return true;
}
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index 5ed72db25b5..b9c0eeae3a8 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -308,6 +308,7 @@ namespace NGI {
#define SC_LDR 635
#define SC_MAINMENU 4620
#define SC_MAP 5222
+#define SC_SPLASH 2
#define SC_TITLES 5166
#define SND_CMN_015 3139
#define SND_CMN_031 3516
diff --git a/engines/ngi/fullpipe/mobile/splashscreen.cpp b/engines/ngi/fullpipe/mobile/splashscreen.cpp
new file mode 100644
index 00000000000..ba6fa6e2bec
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/splashscreen.cpp
@@ -0,0 +1,382 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "backends/keymapper/keymapper.h"
+
+#include "common/archive.h"
+#include "common/debug.h"
+#include "common/events.h"
+#include "common/system.h"
+
+#include "ngi/ngi.h"
+#include "ngi/determinism.h"
+#include "ngi/gameloader.h"
+#include "ngi/gfx.h"
+#include "ngi/inventory.h"
+#include "ngi/fullpipe/constants.h"
+#include "ngi/fullpipe/mobile/splashscreen.h"
+#include "ngi/debugger/testmode.h"
+
+namespace NGI {
+
+// Progress units of the loading: the original has 3407 (en, de) and 4835 (others), this loader
+// sends 3387 and 4829 (counted from the fonts and the call sites, checked in runs): D63
+static const int kTotalEnDe = 3387;
+static const int kTotalOther = 4829;
+
+// CSplashScreen::CSplashScreen (128534)
+SplashScreen::SplashScreen() {
+ _waitscreen = false; // waitscreen="false" in splash.xml
+}
+
+// CSplashScreen::OnShow (1284EC)
+void SplashScreen::onShow() {
+ Scene::onShow();
+ _showing = true;
+}
+
+// CSplashScreen::OnHide (1284FE)
+void SplashScreen::onHide() {
+ Scene::onHide();
+ _showing = false;
+}
+
+// CSplashScreen::RenderFromUpdate (1285D0): Clear, Render, Present (CGame +101 unused)
+void SplashScreen::renderFromUpdate() {
+ render(true);
+ g_ngi->_system->copyRectToScreen(g_ngi->_backgroundSurface.getPixels(), g_ngi->_backgroundSurface.pitch, 0, 0, g_ngi->_backgroundSurface.w, g_ngi->_backgroundSurface.h);
+ g_ngi->_system->updateScreen();
+ // services the event queue, or macOS shows the wait cursor and does not paint
+ Common::Event event;
+ while (g_ngi->getEventManager()->pollEvent(event)) {
+ }
+}
+
+// CSplashScreenController::CSplashScreenController (1A6810); +12 is set and never read
+SplashScreenController::SplashScreenController(int sceneId) : ISceneController(sceneId) {
+ for (PictureObject *&picture : _pictures)
+ picture = nullptr;
+ const Common::String locale = g_ngi->getResourceLocale();
+ _total = locale == "en" || locale == "de" ? kTotalEnDe : kTotalOther;
+}
+
+// CSplashScreenController::OnMouseLKeyDown (1A6730) ... OnMouseRKeyUp (1A673C)
+bool SplashScreenController::onMouseLKeyDown(uint32 id, float x, float y) {
+ return true;
+}
+
+bool SplashScreenController::onMouseLKeyUp(uint32 id, float x, float y) {
+ return true;
+}
+
+bool SplashScreenController::onMouseRKeyDown(uint32 id, float x, float y) {
+ return true;
+}
+
+bool SplashScreenController::onMouseRKeyUp(uint32 id, float x, float y) {
+ return true;
+}
+
+// CSplashScreenController::IncPercent (1A68C0): the message goes through the virtual OnMessage
+void SplashScreenController::incPercent(int count) {
+ for (int i = 0; i < count; i++)
+ onMessage("MSG_INC_LOAD_PERCENT", Common::String(), nullptr);
+}
+
+// CSplashScreenController::OnMessage (1A69B0)
+void SplashScreenController::onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) {
+ if (message != "MSG_INC_LOAD_PERCENT")
+ return;
+ _units++;
+ _percent++;
+ if (_percent >= _total)
+ _percent = _total;
+ PictureObject *bar = _pictures[2];
+ if (!bar)
+ return;
+ bar->_windowLeft = 0;
+ bar->_windowTop = 0;
+ bar->_windowRight = (float)_percent / (float)_total;
+ bar->_windowBottom = 1.0f;
+ if (_percent % 10 == 0 && g_ngi->_splashScreen)
+ g_ngi->_splashScreen->renderFromUpdate();
+}
+
+// CSplashScreenController::SetInvItemsOffset (1A6A14): phones double the y offsets of the items
+void SplashScreenController::setInvItemsOffset(float offsetX, float offsetY) {
+ if (!g_ngi->_inventory)
+ return;
+ for (InventoryItem *item : g_ngi->_inventory->_items) {
+ const float y = offsetY * item->_cursorOfsY;
+ item->_cursorOfsX = item->_cursorOfsX * offsetX;
+ item->_cursorOfsY = y;
+ }
+}
+
+void SplashScreenController::showPicture(int index, bool show) {
+ if (show)
+ _pictures[index]->_flags |= 4;
+ else
+ _pictures[index]->_flags &= ~4;
+}
+
+// CSplashScreenController::OnShow (1A6A5E): the four pictures are the first of the scene
+void SplashScreenController::onShow() {
+ for (int i = 0; i < 4; i++) {
+ _pictures[i] = _scene->_pictureObjects[i];
+ showPicture(i, false);
+ }
+ _pictures[2]->_windowLeft = 0;
+ _pictures[2]->_windowTop = 0;
+ _pictures[2]->_windowRight = 0;
+ _pictures[2]->_windowBottom = 1.0f;
+ if (_phase == 1)
+ showPicture(1, true);
+ else if (_phase == 0)
+ showPicture(0, true);
+ g_ngi->_fader.startFade(1000, 1000, 1000);
+ debugC(1, kDebugInfo, "INFO t %u SPLASH phase %d percent %d/%d", g_system->getMillis(), _phase, _percent, _total);
+}
+
+// CSplashScreenController::OnRender (1A6AE4): the fader covers the logos and the fade out
+void SplashScreenController::onRender(Common::Point scroll) {
+ if (_phase <= 2 || _phase == 4)
+ g_ngi->_fader.onRender();
+}
+
+// CSplashScreenController::TrySkipSplash (1A6B04)
+void SplashScreenController::trySkipSplash() {
+ if (_phase == 0) {
+ g_ngi->_fader.startFade(1000, 0, 0);
+ showPicture(0, false);
+ showPicture(3, true);
+ showPicture(2, true);
+ _phase = 2;
+ } else if (_phase == 1) {
+ g_ngi->_fader.startFade(1000, 1000, 1000);
+ showPicture(1, false);
+ showPicture(0, true);
+ _phase = 0;
+ } else {
+ return;
+ }
+ debugC(1, kDebugInfo, "INFO t %u SPLASH phase %d percent %d/%d skipped", g_system->getMillis(), _phase, _percent, _total);
+}
+
+// CSplashScreenController::OnMouseLKeyUpTop (1A6B66)
+bool SplashScreenController::onMouseLKeyUpTop(uint32 id, float x, float y) {
+ if (_phase <= 1) {
+ trySkipSplash();
+ return true;
+ }
+ return false;
+}
+
+// CSplashScreenController::OnKeyUp (1A6B7A): the back key, 4 or 0x84
+void SplashScreenController::onKeyUp(uint32 key) {
+ if ((key & 0xFFFFFF7F) == 4)
+ trySkipSplash();
+}
+
+// CSplashScreenController::CreateControllers (1A6B8C): the loader sends its progress units
+void SplashScreenController::createControllers() {
+ _error = g_ngi->_gameLoader->createControllers(_start, this);
+ if (_error.getCode() == Common::kNoError)
+ g_ngi->initXmlSettings();
+}
+
+// CSplashScreenController::StartGame (1A7588): SetScene of the start scene, cursors, preloads
+void SplashScreenController::startGame() {
+ // Dropped: Game Center, notifications, store restore, InitSplit. The CSettings +13 branch (resume)
+ // is not used: a save is loaded from the launcher. SetInvItemsOffset(1.0, 2.0) is for screens of
+ // at most 7 inches, never called. CTaskManager::OnShow runs in createControllers (D64).
+ _error = g_ngi->startXmlGame(_start);
+ _done = true;
+ debugC(1, kDebugInfo, "INFO t %u SPLASH done, %d units of %d", g_system->getMillis(), _units, _total);
+}
+
+// CSplashScreenController::OnUpdate (1A7738): the Flurry event "1st_run_loadscreen" is dropped
+void SplashScreenController::onUpdate(uint32 elapsed) {
+ Fader &fader = g_ngi->_fader;
+ fader.onUpdate(elapsed);
+ if (fader.getState() != Fader::kIdle)
+ return;
+ const int phase = _phase;
+ switch (_phase) {
+ case 0:
+ fader.startFade(1000, 0, 0);
+ showPicture(0, false);
+ showPicture(3, true);
+ showPicture(2, true);
+ _phase = 2;
+ break;
+ case 1:
+ fader.startFade(1000, 1000, 1000);
+ showPicture(1, false);
+ showPicture(0, true);
+ _phase = 0;
+ break;
+ case 2:
+ _phase = 3;
+ break;
+ case 3:
+ onMessage("MSG_INC_LOAD_PERCENT", Common::String(), nullptr);
+ g_ngi->_gameLoader->createContent();
+ createControllers();
+ _phase = 4;
+ fader.startFade(0, 0, 1000);
+ fader.setAlpha(0.0f);
+ fader.setState(Fader::kFadeIn);
+ break;
+ case 4:
+ startGame();
+ break;
+ default:
+ break;
+ }
+ if (phase != _phase)
+ debugC(1, kDebugInfo, "INFO t %u SPLASH phase %d percent %d/%d", g_system->getMillis(), _phase, _percent, _total);
+}
+
+static Common::String attribute(const Common::String &tag, const char *name, const char *defaultValue) {
+ const Common::String key = Common::String::format(" %s=\"", name);
+ const uint pos = tag.find(key);
+ if (pos == Common::String::npos)
+ return defaultValue;
+ const uint begin = pos + key.size();
+ const uint end = tag.find('"', begin);
+ if (end == Common::String::npos)
+ return defaultValue;
+ return Common::String(tag.c_str() + begin, tag.c_str() + end);
+}
+
+// CGame::CreateSplashScreen (FD580): splash.xml has the four pictures (found by order, ids not in
+// obj.h) and a SPLASH node with the texture files
+bool createSplashScreen() {
+ Common::ScopedPtr<Common::SeekableReadStream> stream(SearchMan.createReadStreamForMember("data/splash.xml"));
+ if (!stream)
+ return false;
+ Common::String xml;
+ while (!stream->eos()) {
+ char buffer[512];
+ const uint32 count = stream->read(buffer, sizeof(buffer));
+ xml += Common::String(buffer, count);
+ if (!count)
+ break;
+ }
+
+ Common::ScopedPtr<SplashScreen> scene(new SplashScreen());
+ scene->_sceneId = SC_SPLASH;
+ int index = 0;
+ for (uint pos = xml.find("<PICTURE "); pos != Common::String::npos; pos = xml.find("<PICTURE ", pos + 1)) {
+ const uint end = xml.find("/>", pos);
+ if (end == Common::String::npos)
+ break;
+ const Common::String tag(xml.c_str() + pos, xml.c_str() + end);
+ Common::ScopedPtr<PictureObject> picture(new PictureObject());
+ picture->_id = ++index;
+ picture->_x = atof(attribute(tag, "x", "0").c_str());
+ picture->_y = atof(attribute(tag, "y", "0").c_str());
+ picture->_z = atof(attribute(tag, "z", "0").c_str());
+ picture->_objectFlags = atoi(attribute(tag, "flags", "0").c_str());
+ picture->_flags = (picture->_objectFlags & 1) ? 4 : 0;
+ picture->_cnum = index - 1;
+ picture->_picture = new Texture();
+ scene->addPicture(picture.release());
+ }
+ if (index < 4)
+ return false;
+
+ // the SPLASH node: CRender::CreateTexture of each file, set in the order of the pictures
+ const uint node = xml.find("<SPLASH ");
+ const Common::String splash = node == Common::String::npos ? Common::String() : Common::String(xml.c_str() + node);
+ const Common::Path data("data");
+ const Common::Path resources = Common::Path("data/res_").appendInPlace(g_ngi->getResourceLocale());
+ const Common::Path paths[4] = {
+ data.join(attribute(splash, "pathDevLogo", "logo.png")),
+ data.join(attribute(splash, "pathPublishLogo", "logoPublish.png")),
+ data.join(attribute(splash, "pathProgress", "progress.png")),
+ resources.join(attribute(splash, "pathProgressBGR", "logoGame.png"))
+ };
+ for (int i = 0; i < 4; i++) {
+ scene->_pictureObjects[i]->_picture->loadPNG(paths[i], Dims());
+ scene->_pictureObjects[i]->setOXY2();
+ }
+ scene->repopulateRenderables(); // CScene::Init
+ g_ngi->_splashScreen.reset(scene.release());
+ new SplashScreenController(SC_SPLASH);
+ return true;
+}
+
+// CGame::Run for the splash scene: events, the update steps of the main loop, the scene
+Common::Error runSplash(const SceneTag *start) {
+ if (!createSplashScreen()) {
+ // no splash.xml: CGame::Create goes to CreateContent at once
+ g_ngi->_gameLoader->createContent();
+ Common::Error result = g_ngi->_gameLoader->createControllers(start, nullptr);
+ if (result.getCode() == Common::kNoError) {
+ g_ngi->initXmlSettings();
+ result = g_ngi->startXmlGame(start);
+ }
+ return result;
+ }
+
+ SplashScreen *scene = g_ngi->_splashScreen.get();
+ SplashScreenController &controller = *static_cast<SplashScreenController *>(scene->_controller.get());
+ controller.setStart(start);
+ // the back key is kActionCloseDialog with the dialog keymap (as in pushScene)
+ Common::Keymapper *mapper = g_ngi->_system->getEventManager()->getKeymapper();
+ mapper->setGameKeymapState("ngi-default", false);
+ mapper->setGameKeymapState("dialog", true);
+ scene->onShow();
+ uint32 lastUpdate = g_system->getMillis();
+ while (!g_ngi->shouldQuit() && !controller.isDone() && controller.error().getCode() == Common::kNoError) {
+ Common::Event event;
+ while (g_ngi->getEventManager()->pollEvent(event)) {
+ if (event.type == Common::EVENT_LBUTTONUP)
+ controller.onMouseLKeyUpTop(0, event.mouse.x - g_ngi->_wideOfs, event.mouse.y);
+ else if ((event.type == Common::EVENT_KEYUP && (event.kbd.keycode == Common::KEYCODE_ESCAPE || event.kbd.keycode == Common::KEYCODE_AC_BACK)) ||
+ (event.type == Common::EVENT_CUSTOM_ENGINE_ACTION_END && event.customType == kActionCloseDialog))
+ controller.onKeyUp(4);
+ }
+ // CGame::Update discounts long stalls (the loading is one update); fast mode steps six times
+ const uint32 now = g_system->getMillis();
+ const uint32 elapsed = now - lastUpdate;
+ lastUpdate = now;
+ const int updates = testmode_updatesPerFrame();
+ for (int i = 0; i < updates && !controller.isDone(); i++)
+ controller.onUpdate(i ? 42 : (elapsed > 350 ? 15 : elapsed));
+ if (controller.isDone() || controller.error().getCode() != Common::kNoError)
+ break;
+ scene->render(true);
+ g_system->copyRectToScreen(g_ngi->_backgroundSurface.getPixels(), g_ngi->_backgroundSurface.pitch, 0, 0, g_ngi->_backgroundSurface.w, g_ngi->_backgroundSurface.h);
+ g_system->updateScreen();
+ g_system->delayMillis(updates > 1 ? 1 : 10);
+ }
+ const Common::Error result = controller.error();
+ mapper->setGameKeymapState("ngi-default", true);
+ mapper->setGameKeymapState("dialog", false);
+ scene->onHide();
+ g_ngi->_splashScreen.reset();
+ return result;
+}
+
+} // End of namespace NGI
diff --git a/engines/ngi/fullpipe/mobile/splashscreen.h b/engines/ngi/fullpipe/mobile/splashscreen.h
new file mode 100644
index 00000000000..0a884a3e428
--- /dev/null
+++ b/engines/ngi/fullpipe/mobile/splashscreen.h
@@ -0,0 +1,98 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef NGI_FULLPIPE_SPLASHSCREEN_H
+#define NGI_FULLPIPE_SPLASHSCREEN_H
+
+#include "ngi/scene.h"
+#include "ngi/scenecontroller.h"
+
+namespace NGI {
+
+class PictureObject;
+class SceneTag;
+
+/** CSplashScreen (scene 2, size 0x194): the logos and the progress bar of the start */
+class SplashScreen : public Scene {
+public:
+ SplashScreen();
+
+ void onShow() override;
+ void onHide() override;
+ /** CSplashScreen::RenderFromUpdate: draws the scene at once while the game loads */
+ void renderFromUpdate();
+ /** CSplashScreen +400 */
+ bool isShowing() const { return _showing; }
+
+private:
+ bool _showing = false;
+};
+
+/** CSplashScreenController: the start sequence, ISceneController +16..+40 as in the original */
+class SplashScreenController : public ISceneController {
+public:
+ explicit SplashScreenController(int sceneId);
+
+ bool onMouseLKeyDown(uint32 id, float x, float y) override;
+ bool onMouseLKeyUp(uint32 id, float x, float y) override;
+ bool onMouseRKeyDown(uint32 id, float x, float y) override;
+ bool onMouseRKeyUp(uint32 id, float x, float y) override;
+ void onMessage(const Common::String &message, const Common::String ¶m, MessageQueue *queue) override;
+ void onShow() override;
+ void onRender(Common::Point scroll) override;
+ bool onMouseLKeyUpTop(uint32 id, float x, float y) override;
+ void onKeyUp(uint32 key) override;
+ void onUpdate(uint32 elapsed) override;
+
+ void incPercent(int count);
+ void setInvItemsOffset(float offsetX, float offsetY);
+ void trySkipSplash();
+ void createControllers();
+ void startGame();
+
+ /** The project start scene (CGame +84), the game starts in it */
+ void setStart(const SceneTag *start) { _start = start; }
+ bool isDone() const { return _done; }
+ const Common::Error &error() const { return _error; }
+
+private:
+ void showPicture(int index, bool show);
+
+ PictureObject *_pictures[4]; // +16: the dev logo, the publisher logo, the progress bar, the background of the progress
+ int _phase = 1; // +32: 1 publisher, 0 dev, 2 progress faded in, 3 loading, 4 faded out
+ int _percent = 0; // +36
+ int _total; // +40
+ // not in the original: end of the sequence, start scene, loading error, units received (log)
+ bool _done = false;
+ const SceneTag *_start = nullptr;
+ Common::Error _error = Common::kNoError;
+ int _units = 0;
+};
+
+/** CGame::CreateSplashScreen (FD580): the scene from splash.xml, false when the file is missing */
+bool createSplashScreen();
+
+/** CGame::Run for the splash: the start sequence, until the game starts (or the engine quits) */
+Common::Error runSplash(const SceneTag *start);
+
+} // End of namespace NGI
+
+#endif // NGI_FULLPIPE_SPLASHSCREEN_H
diff --git a/engines/ngi/gameloader.h b/engines/ngi/gameloader.h
index 669c2f235d3..c89798e50f4 100644
--- a/engines/ngi/gameloader.h
+++ b/engines/ngi/gameloader.h
@@ -34,6 +34,7 @@ namespace NGI {
#define NGI_SAVEGAME_VERSION 4
class SceneTag;
+class SplashScreenController;
class MctlCompound;
class CursorController;
class InteractionController;
@@ -91,6 +92,10 @@ class GameLoader : public CObject {
bool load(MfcArchive &file) override;
bool loadScene(int sceneId);
+ /** The steps of CGame::Create and of the splash controller; loadXML runs them in a row */
+ Common::Error openProject(const Common::Path &projectPath, const SceneTag *&start, int &width, int &height);
+ void createContent();
+ Common::Error createControllers(const SceneTag *start, SplashScreenController *splash);
Common::Error loadXML(const Common::Path &projectPath, const SceneTag *&start, int &width, int &height);
bool setScene(int sceneId, int entranceId);
bool preloadScene(int sceneId, int entranceId);
diff --git a/engines/ngi/module.mk b/engines/ngi/module.mk
index b4f46ddfbf6..f0d6f837f87 100644
--- a/engines/ngi/module.mk
+++ b/engines/ngi/module.mk
@@ -156,6 +156,7 @@ MODULE_OBJS = \
fullpipe/mobile/scenecontrollers.o \
fullpipe/mobile/scfinalcontroller.o \
fullpipe/mobile/scoptionscontroller.o \
+ fullpipe/mobile/splashscreen.o \
fullpipe/mobile/statemanager.o \
fullpipe/mobile/taskmanager.o \
fullpipe/mobile/tremble.o \
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index f13f01c7334..af2a78c7053 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -47,6 +47,7 @@
#include "ngi/fullpipe/mobile/taskmanager.h"
#include "ngi/fullpipe/mobile/exitmanager.h"
#include "ngi/fullpipe/mobile/settings.h"
+#include "ngi/fullpipe/mobile/splashscreen.h"
#include "ngi/preloadmanager.h"
#include "ngi/fullpipe/mobile/achievements.h"
#include "ngi/fullpipe/mobile/objhelper.h"
@@ -448,14 +449,91 @@ bool NGIEngine::handleSceneEvent(const Common::Event &event, GuiManager *manager
return false;
}
+// CGame::IncrementLoadingPercent (FC288)
+void NGIEngine::incrementLoadingPercent(int count) {
+ if (!_splashScreen)
+ return;
+ for (int i = 0; i < count; i++)
+ _splashScreen->message("MSG_INC_LOAD_PERCENT", Common::String(), nullptr);
+}
+
+// recordings and tests use --boot-param and skip the splash; --debugflags=splash shows it too
+bool NGIEngine::splashWanted() const {
+ return usesXMLProject() && _gameVersion >= 201509 && (!ConfMan.getInt("boot_param") || debugChannelSet(-1, kDebugSplash));
+}
+
+// The 800x600 area stays in the middle, the margins show more scenery (up to 159 pixels beyond it)
+Common::Error NGIEngine::initScreen(int width, int height) {
+ _wideOfs = 0;
+ if (usesXMLProject() && _gameVersion >= 201509 && (!ConfMan.hasKey("widescreen") || ConfMan.getBool("widescreen")))
+ _wideOfs = kWideMargin;
+ initGraphics(width + 2 * _wideOfs, height, nullptr);
+ const Graphics::PixelFormat format = _system->getScreenFormat();
+ if (format.isCLUT8())
+ return Common::kUnsupportedColorMode;
+ _backgroundSurface.create(width + 2 * _wideOfs, height, format);
+ _isSaveAllowed = false;
+ return Common::kNoError;
+}
+
+void NGIEngine::initXmlSettings() {
+ // the achievements of ScummVM stand in for Google Play (CAchievement::AddActivatingCounter)
+ if (_gameVersion >= 201509) {
+ AchMan.setActiveDomain(getMetaEngine()->getAchievementsInfo(ConfMan.getActiveDomainName()));
+ // CBaseSettings::CBaseSettings (ED41C): sound 60 and music 30 until they are set
+ const Common::String domain = ConfMan.getActiveDomainName();
+ if (!ConfMan.hasKey("sfx_volume", domain))
+ setSoundSetting(60);
+ if (!ConfMan.hasKey("music_volume", domain))
+ setMusicSetting(30);
+ syncSoundSettings();
+ }
+}
+
+void NGIEngine::setupXmlKeymaps() {
+ Common::Keymapper *mapper = _system->getEventManager()->getKeymapper();
+ mapper->disableAllGameKeymaps();
+ mapper->setGameKeymapState("ngi-default", true);
+}
+
+// CSplashScreenController::StartGame (1A7588): the start scene, the cursors and the preloads
+Common::Error NGIEngine::startXmlGame(const SceneTag *start) {
+ // Debugging aid: --boot-param=N starts in scene N (1 to 38) through its first entrance
+ int startEntranceId = 0;
+ int startSceneId = start->_sceneId;
+ if (ConfMan.getInt("boot_param")) {
+ // scene + 100 * spot: testmode.h
+ testmode_setSpot(ConfMan.getInt("boot_param") / 100);
+ startSceneId = convertScene(ConfMan.getInt("boot_param") % 100);
+ const Scene *bootScene = _gameProject->findScene(startSceneId);
+ if (bootScene && !bootScene->_entrances.empty())
+ startEntranceId = bootScene->_entrances.front()._id;
+ }
+ if (DebugMan.isDebugChannelEnabled(kDebugSkipIntro) && _tutorialManager && _taskManager) {
+ // --debugflags=skipIntro: what BTN_SKIP does (CTutorialController::OnGuiEvent), no tutorial
+ _tutorialManager->deactivate(false);
+ if (!_taskManager->isTaskClosed("FIND_DOMINO_SC3"))
+ _taskManager->activateTask("FIND_DOMINO_SC3");
+ if (!_taskManager->isTaskClosed("FIND_APPLE_SC4"))
+ _taskManager->activateTask("FIND_APPLE_SC4");
+ }
+ // CGame::OnShow: the cursors are initialised, then the inventory (cursors, buttons) is loaded
+ _inputController->initPointers();
+ if (_preloadManager)
+ _preloadManager->startGame();
+ if (!_gameLoader->setScene(startSceneId, startEntranceId))
+ return Common::Error(Common::kNoGameDataFoundError, "Could not load the Full Pipe start scene");
+ return Common::kNoError;
+}
+
Common::Error NGIEngine::run() {
_globalMessageQueueList.reset(new GlobalMessageQueueList);
_aniHandler.reset(new AniHandler);
const bool timedUpdates = _gameVersion >= 201509;
const SceneTag *start = nullptr;
- int startSceneId = 0;
int width = 800, height = 600;
Common::Error result = Common::kNoError;
+ bool splash = false;
if (usesXMLProject()) {
if (getGameGID() != GID_FULLPIPE)
return Common::kUnsupportedGameidError;
@@ -463,72 +541,47 @@ Common::Error NGIEngine::run() {
_floaters.reset(new FlyPack);
// the wide screen margin is needed while the data loads (CInventory::Init, GUI elements)
_wideOfs = _gameVersion >= 201509 && (!ConfMan.hasKey("widescreen") || ConfMan.getBool("widescreen")) ? kWideMargin : 0;
- result = _gameLoader->loadXML("data/FullPipe.xml", start, width, height);
- if (result.getCode() != Common::kNoError)
- return result;
- _gameProject = _gameLoader->_gameProject.get();
- // the achievements of ScummVM stand in for Google Play (CAchievement::AddActivatingCounter)
- if (_gameVersion >= 201509) {
- AchMan.setActiveDomain(getMetaEngine()->getAchievementsInfo(ConfMan.getActiveDomainName()));
- // CBaseSettings::CBaseSettings (ED41C): sound 60 and music 30 until they are set
- const Common::String domain = ConfMan.getActiveDomainName();
- if (!ConfMan.hasKey("sfx_volume", domain))
- setSoundSetting(60);
- if (!ConfMan.hasKey("music_volume", domain))
- setMusicSetting(30);
- syncSoundSettings();
+ splash = splashWanted();
+ if (splash) {
+ // CGame::Create: the graphics, then the splash that loads and starts the game
+ result = _gameLoader->openProject("data/FullPipe.xml", start, width, height);
+ if (result.getCode() == Common::kNoError)
+ result = initScreen(width, height);
+ if (result.getCode() != Common::kNoError)
+ return result;
+ _gameProject = _gameLoader->_gameProject.get();
+ setupXmlKeymaps();
+ result = runSplash(start);
+ if (result.getCode() != Common::kNoError)
+ return result;
+ } else {
+ result = _gameLoader->loadXML("data/FullPipe.xml", start, width, height);
+ if (result.getCode() != Common::kNoError)
+ return result;
+ _gameProject = _gameLoader->_gameProject.get();
+ initXmlSettings();
}
}
- // The Android revision shows a wide screen: the 800x600 area stays in the middle, the margins
- // show more scenery (backgrounds go up to 159 pixels beyond it); 1066 x 600 is 16:9
- _wideOfs = 0;
- if (usesXMLProject() && _gameVersion >= 201509 && (!ConfMan.hasKey("widescreen") || ConfMan.getBool("widescreen")))
- _wideOfs = kWideMargin;
- initGraphics(width + 2 * _wideOfs, height, nullptr);
- const Graphics::PixelFormat format = _system->getScreenFormat();
- if (format.isCLUT8())
- return Common::kUnsupportedColorMode;
- _backgroundSurface.create(width + 2 * _wideOfs, height, format);
- _isSaveAllowed = false;
-
- if (usesXMLProject()) {
- Common::Keymapper *mapper = _system->getEventManager()->getKeymapper();
- mapper->disableAllGameKeymaps();
- mapper->setGameKeymapState("ngi-default", true);
- // Debugging aid: --boot-param=N starts in scene N (1 to 38) through its first entrance
- int startEntranceId = 0;
- startSceneId = start->_sceneId;
- if (ConfMan.getInt("boot_param")) {
- // scene + 100 * spot: testmode.h
- testmode_setSpot(ConfMan.getInt("boot_param") / 100);
- startSceneId = convertScene(ConfMan.getInt("boot_param") % 100);
- const Scene *bootScene = _gameProject->findScene(startSceneId);
- if (bootScene && !bootScene->_entrances.empty())
- startEntranceId = bootScene->_entrances.front()._id;
- }
- if (DebugMan.isDebugChannelEnabled(kDebugSkipIntro) && _tutorialManager && _taskManager) {
- // --debugflags=skipIntro: what BTN_SKIP does (CTutorialController::OnGuiEvent), no tutorial
- _tutorialManager->deactivate(false);
- if (!_taskManager->isTaskClosed("FIND_DOMINO_SC3"))
- _taskManager->activateTask("FIND_DOMINO_SC3");
- if (!_taskManager->isTaskClosed("FIND_APPLE_SC4"))
- _taskManager->activateTask("FIND_APPLE_SC4");
- }
- // CGame::OnShow: the cursors are initialised, then the inventory (cursors, buttons) is loaded
- _inputController->initPointers();
- if (_preloadManager)
- _preloadManager->startGame();
- if (!_gameLoader->setScene(startSceneId, startEntranceId))
- return Common::Error(Common::kNoGameDataFoundError, "Could not load the Full Pipe start scene");
- } else {
- result = initGame();
+ if (!splash) {
+ result = initScreen(width, height);
if (result.getCode() != Common::kNoError)
return result;
+
+ if (usesXMLProject()) {
+ setupXmlKeymaps();
+ result = startXmlGame(start);
+ if (result.getCode() != Common::kNoError)
+ return result;
+ } else {
+ result = initGame();
+ if (result.getCode() != Common::kNoError)
+ return result;
+ }
}
byte brightness = 255;
- if (usesXMLProject()) {
+ if (usesXMLProject() && !shouldQuit()) {
_currentScene->render();
_system->copyRectToScreen(_backgroundSurface.getPixels(), _backgroundSurface.pitch, 0, 0, _backgroundSurface.w, height);
_system->updateScreen();
diff --git a/engines/ngi/ngi.h b/engines/ngi/ngi.h
index 7dd2193d7be..795ac2f4f49 100644
--- a/engines/ngi/ngi.h
+++ b/engines/ngi/ngi.h
@@ -64,6 +64,7 @@ enum {
kDebugFast,
kDebugSkipIntro,
kDebugNoRandom,
+ kDebugSplash,
};
enum NGIActions {
@@ -129,6 +130,8 @@ class MessageQueue;
class AniHandler;
class NGIArchive;
class PictureObject;
+class SceneTag;
+class SplashScreen;
struct PreloadItem;
class Scene;
class Sound;
@@ -175,6 +178,10 @@ protected:
Common::Error run() override;
Common::Error initGame();
+ /** The start of the XML project, in the order of CGame::Create (see run) */
+ bool splashWanted() const;
+ Common::Error initScreen(int width, int height);
+ void setupXmlKeymaps();
bool handleGuiEvent(const Common::Event &event);
public:
@@ -403,6 +410,13 @@ public:
Inventory *_inventory = nullptr;
/** CGame +120: the scene of the wait screen (SC_LDR), owned by the scene list under the id 1 */
Scene *_waitScreen = nullptr;
+ /** CGame +124: the splash scene (CGame::CreateSplashScreen) while the game starts, 0 afterwards */
+ Common::ScopedPtr<SplashScreen> _splashScreen;
+ /** CGame::IncrementLoadingPercent (FC288): MSG_INC_LOAD_PERCENT to the splash, if any */
+ void incrementLoadingPercent(int count);
+ /** The settings and the start of the XML project (CSplashScreenController::StartGame) */
+ void initXmlSettings();
+ Common::Error startXmlGame(const SceneTag *start);
int _currSelectedInventoryItemId;
int32 _updateTicks;
diff --git a/engines/ngi/preloadmanager.cpp b/engines/ngi/preloadmanager.cpp
index 35ec98e0890..129f9fcdc0f 100644
--- a/engines/ngi/preloadmanager.cpp
+++ b/engines/ngi/preloadmanager.cpp
@@ -256,8 +256,17 @@ void PreloadManager::unloadInventory() {
}
// CPreloadManager::LoadFonts (11A590) and UnloadFonts (11A5AC)
+// CFontController::Load: every font of the language, kept; BitmapFont::load sends the progress
void PreloadManager::loadFonts() {
- warning("STUB/untested: CFontController::Load: the fonts are loaded when they are first used and kept");
+ const Common::Path directory = Common::Path("data/res_").appendInPlace(g_ngi->getResourceLocale()).join("Fonts");
+ Common::ArchiveMemberList members;
+ SearchMan.listMatchingMembers(members, directory.join("*.fnt"));
+ Common::StringArray names;
+ for (const Common::ArchiveMemberPtr &member : members)
+ names.push_back(member->getFileName());
+ Common::sort(names.begin(), names.end());
+ for (const Common::String &name : names)
+ g_ngi->getFont(name);
}
void PreloadManager::unloadFonts() {
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index d272ba9b136..425a218721c 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -22,6 +22,7 @@
#include "math/utils.h"
#include "ngi/ngi.h"
+#include "ngi/fullpipe/mobile/splashscreen.h"
#include "ngi/fullpipe/mobile/waitscreen.h"
#include "ngi/preloadmanager.h"
#include "ngi/scenecontroller.h"
@@ -55,6 +56,9 @@ namespace NGI {
Scene *NGIEngine::findScene(int sceneId) {
if (sceneId == 0 && _inventory)
return _inventory;
+ // the splash scene is the scene 2 of the original's scene map, but the project does not list it
+ if (sceneId == SC_SPLASH && _splashScreen)
+ return _splashScreen.get();
return _gameProject->findScene(sceneId);
}
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index 12f86b92744..fd8b3716b78 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -58,6 +58,7 @@
#include "ngi/fullpipe/mobile/achievements.h"
#include "ngi/fullpipe/mobile/objhelper.h"
#include "ngi/fullpipe/mobile/tutorialmanager.h"
+#include "ngi/fullpipe/mobile/splashscreen.h"
#include "ngi/fullpipe/mobile/waitscreen.h"
#include "ngi/preloadmanager.h"
#include "ngi/fullpipe/mobile/hintmanager.h"
@@ -1922,7 +1923,8 @@ static void setManSpeed(GameVar *gameVar, float speed) {
}
}
-Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTag *&start, int &width, int &height) {
+// CGame::Create: the archives and the project file, what CGame::CreateContent reads of it later
+Common::Error GameLoader::openProject(const Common::Path &projectPath, const SceneTag *&start, int &width, int &height) {
// XML projects may ship in zip containers (APK and OBB), later entries win: added in reverse order
const auto &files = g_ngi->_gameDescription->desc.filesDescriptions;
const Common::FSNode gameDirectory(ConfMan.getPath("path"));
@@ -1960,6 +1962,28 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
return Common::Error(Common::kNoGameDataFoundError, "Could not find the Full Pipe start scene");
debugC(1, kDebugXML, "Loaded Full Pipe project, start scene %s (%hu)",
start->_tag.c_str(), static_cast<uint16>(start->_sceneId));
+ width = parser.width();
+ height = parser.height();
+ return Common::kNoError;
+}
+
+// CGame::CreateContent (FD88C): only its progress units (debug font, obj.h, 2 per scene) are sent;
+// the scenes load on demand, the inventory and the wait screen come with createControllers
+void GameLoader::createContent() {
+ g_ngi->incrementLoadingPercent(1);
+ g_ngi->incrementLoadingPercent(1);
+ for (uint i = 0; i < _gameProject->_sceneTagList->size(); i++)
+ g_ngi->incrementLoadingPercent(2);
+}
+
+// CSplashScreenController::CreateControllers (1A6B8C): the rest, in this loader's order; its 61
+// progress units (16 of 1, 9 of 5) go at the closest steps
+Common::Error GameLoader::createControllers(const SceneTag *start, SplashScreenController *splash) {
+ GameProject &project = *_gameProject;
+ for (int i = 0; splash && i < 16; i++)
+ splash->incPercent(1);
+ if (splash)
+ splash->incPercent(5);
if (start->_sceneId == SC_INTRO1) {
XMLWalkParser walkParser(project._walkData);
if (!walkParser.loadFile("data/data.xml") || !walkParser.parse())
@@ -1978,6 +2002,10 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
return Common::Error(Common::kNoGameDataFoundError, "Could not read the object states");
g_ngi->_stateManager->setStartStates();
g_ngi->_stateManager->setActivity();
+ if (splash) {
+ splash->incPercent(5); // CStateManager::Init
+ splash->incPercent(5); // SetStartStates, SetActivity
+ }
} else {
g_ngi->setState(sO_EggCracker, g_ngi->getStateValue(sO_EggCracker, sO_DidNotCrackEgg));
}
@@ -1991,8 +2019,19 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
}
if (g_ngi->_gameVersion < 201509)
g_ngi->lift_resetButtons(); // CStateManager::SetStartStates does it from 201509 on
- if (g_ngi->_gameVersion >= 201509)
+ if (g_ngi->_gameVersion >= 201509) {
+ // CGame::OnShow (FCE28): 3 units per scene, then 1, 1, 1, 1 and 5; the scenes load on demand here
+ for (uint i = 0; i < project._sceneTagList->size(); i++)
+ g_ngi->incrementLoadingPercent(3);
+ for (int i = 0; i < 4; i++)
+ g_ngi->incrementLoadingPercent(1);
+ g_ngi->incrementLoadingPercent(5);
+ if (splash) {
+ splash->incPercent(5); // CStateManager::InitData, CGame::OnShow
+ splash->incPercent(5); // CGame::LoadInteractions
+ }
setManSpeed(_gameVar, 4.0f); // CSplashScreenController::CreateControllers
+ }
if (project._createInventory && !createInventory(project))
return Common::Error(Common::kNoGameDataFoundError, "Could not read the inventory");
if (g_ngi->_gameVersion >= 201509 && project._createWaitScreen && !createWaitScreen(project))
@@ -2007,6 +2046,8 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_objHelperManager->init("data/objhelpers.xml");
g_ngi->_objHelperHint.reset(new ObjHelperHint);
g_ngi->_objHelperHint->init("data/objhints.xml");
+ if (splash)
+ splash->incPercent(5); // hints, help, objhelpers, objhints, exits
g_ngi->_taskManager.reset(new TaskManager);
createSceneController(SC_NOTEBOOK); // CNotebookController
if (!g_ngi->_taskManager->init("data/tasks.xml", project._objectIds))
@@ -2016,9 +2057,13 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_tutorialManager->init("data/tutorials.xml");
g_ngi->_catalogManager.reset(new CatalogManager);
g_ngi->_catalogManager->init("data/catalog.xml");
+ if (splash)
+ splash->incPercent(5); // tasks, tutorials, chapter, catalog, map
// CAchievementsManager::Init (after CCatalogManager::Init): achievements.xml
g_ngi->_achievementsManager.reset(new AchievementsManager);
g_ngi->_achievementsManager->init("data/achievements.xml");
+ if (splash)
+ splash->incPercent(5); // achievements
createSceneController(SC_TUTORIAL); // CTutorialController
createSceneController(SC_MAINMENU); // CMainMenu
createSceneController(SC_CONFIRMATION); // CConfirmationDlg
@@ -2036,10 +2081,19 @@ Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTa
g_ngi->_help.reset(new Help);
g_ngi->_help->init("data/help.xml");
g_ngi->_noActionLogger.reset(new NoActionLogger);
+ g_ngi->_preloadManager->loadFonts(); // CPreloadManager::LoadFonts
+ if (splash)
+ splash->incPercent(5);
}
- width = parser.width();
- height = parser.height();
return Common::kNoError;
}
+Common::Error GameLoader::loadXML(const Common::Path &projectPath, const SceneTag *&start, int &width, int &height) {
+ Common::Error result = openProject(projectPath, start, width, height);
+ if (result.getCode() != Common::kNoError)
+ return result;
+ createContent();
+ return createControllers(start, nullptr);
+}
+
} // End of namespace NGI
Commit: 5e77f695a5daa4955635dfae2875e579dd794200
https://github.com/scummvm/scummvm/commit/5e77f695a5daa4955635dfae2875e579dd794200
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Float center API (CVisibleObject::GetCenter, SetCenter)
Changed paths:
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index 324cc70a4bb..d4ac0be65b4 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -499,6 +499,40 @@ void GameObject::setCenter(Common::Point center) {
setPos(center.x - offset.x + anchor.x, center.y - offset.y + anchor.y);
}
+// CVisibleObject::GetCenter (126D3C)
+Vector2 GameObject::getCenterF() const {
+ Vector2 center;
+ Common::Point topLeft;
+ Common::Point anchor;
+ Dims size;
+ if (g_ngi->_gameVersion < 201509 || !textureQuad(this, topLeft, size, anchor)) {
+ const Common::Point point = getCenter();
+ center.x = point.x;
+ center.y = point.y;
+ return center;
+ }
+ center.x = _x + size.x * _scaleX * (_windowLeft + (_windowRight - _windowLeft) * 0.5f);
+ center.y = _y + size.y * _scaleY * (_windowTop + (_windowBottom - _windowTop) * 0.5f);
+ return center;
+}
+
+// CVisibleObject::SetCenter (126DBC)
+void GameObject::setCenterF(float x, float y) {
+ Common::Point topLeft;
+ Common::Point anchor;
+ Dims size;
+ if (g_ngi->_gameVersion < 201509 || !textureQuad(this, topLeft, size, anchor)) {
+ setCenter(Common::Point(static_cast<int>(x), static_cast<int>(y)));
+ return;
+ }
+ setTopLeftF(x - size.x * _scaleX * (_windowLeft + (_windowRight - _windowLeft) * 0.5f), y - size.y * _scaleY * (_windowTop + (_windowBottom - _windowTop) * 0.5f));
+}
+
+void GameObject::setTopLeftF(float x, float y) {
+ _x = x;
+ _y = y;
+}
+
RenderParams GameObject::getRenderParams(bool mirror) const {
RenderParams params;
params.mirror = mirror;
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index c027960d0da..c8a4fb408b7 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -24,6 +24,8 @@
#include "common/ptr.h"
+#include "ngi/vector2.h"
+
namespace Graphics {
struct Surface;
class ManagedSurface;
@@ -236,6 +238,11 @@ class GameObject : public CObject {
/** CVisibleObject::GetCenter / SetCenter: the center of the texture window */
Common::Point getCenter() const;
void setCenter(Common::Point center);
+ /** CVisibleObject::GetCenter (126D3C), SetCenter (126DBC) in floats (>= 201509) */
+ Vector2 getCenterF() const;
+ void setCenterF(float x, float y);
+ /** writes +40, +44 as they are */
+ virtual void setTopLeftF(float x, float y);
/** CVisibleObject::IsOnScreenEntirely (127682) / IsOnScreen (12755E) */
bool isOnScreenEntirely(const Scene *scene) const;
bool isOnScreen(const Scene *scene) const;
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 6e8d0704325..812ac5e9ed5 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -274,6 +274,13 @@ void AniObject::setTopLeft(Common::Point topLeft) {
GameObject::setTopLeft(topLeft);
}
+void AniObject::setTopLeftF(float x, float y) {
+ if (g_ngi->_gameVersion >= 201509)
+ storeTopLeft(x, y);
+ else
+ GameObject::setTopLeftF(x, y);
+}
+
void AniObject::setPos(int x, int y) {
if (g_ngi->_gameVersion >= 201509) {
const Common::Point anchor = pivotAnchor();
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index cd154356e44..502d7697fb7 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -256,6 +256,7 @@ public:
void setOldAniPos(int x, int y, int z);
void setPosition(Common::Point pos) override;
Statics *getStatic(int id);
+ void setTopLeftF(float x, float y) override;
Statics *getStaticsByName(const Common::String &name);
Movement *getMovement(int id);
int getMovementIdById(int itemId) const;
Commit: 0523b5115f11142816dddcdccdc18393cbb70a96
https://github.com/scummvm/scummvm/commit/0523b5115f11142816dddcdccdc18393cbb70a96
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Float stage 4: the slide as one float vector (D49)
Changed paths:
engines/ngi/anihandler.cpp
engines/ngi/anihandler.h
engines/ngi/debugger/testmode.cpp
engines/ngi/messagehandlers.cpp
engines/ngi/messagequeuebuilder.cpp
engines/ngi/motion.cpp
engines/ngi/motion.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/anihandler.cpp b/engines/ngi/anihandler.cpp
index aedf6d55d9e..1194ec92ef0 100644
--- a/engines/ngi/anihandler.cpp
+++ b/engines/ngi/anihandler.cpp
@@ -30,10 +30,15 @@
namespace NGI {
-// CMovement::GetMovementSize of 2015 measures center to center (Movement::getCenterMovementSize);
-// a walk plan (cycles, seekWay transitions, makeRunQueue offsets) must use one unit
-static Common::Point moveSize(Movement *mov, int idx, int dynidx) {
- return g_ngi->_gameVersion >= 201509 ? mov->getCenterMovementSize(idx, dynidx) : mov->getMovementSize(idx, dynidx);
+// CMovement::GetMovementSize (2015): center to center, floats
+static Vector2 moveSize(Movement *mov, int idx, int dynidx) {
+ if (g_ngi->_gameVersion >= 201509)
+ return mov->getCenterMovementSizeF(idx, dynidx);
+ const Common::Point point = mov->getMovementSize(idx, dynidx);
+ Vector2 size;
+ size.x = point.x;
+ size.y = point.y;
+ return size;
}
void AniHandler::detachAllObjects() {
@@ -223,6 +228,9 @@ MessageQueue *AniHandler::makeRunQueue(MakeQueueStruct *mkQueue) {
if (!mkQueue->ani)
return nullptr;
+ if (g_ngi->_gameVersion >= 201509)
+ return makeRunQueueAndroid(mkQueue);
+
Movement *mov = mkQueue->ani->_movement;
if (!mov && !mkQueue->ani->_statics)
@@ -290,7 +298,7 @@ MessageQueue *AniHandler::makeRunQueue(MakeQueueStruct *mkQueue) {
int n1x = mkQueue->x1 - mkQueue->x2 - sub1.x - sub2.x;
int n1y = mkQueue->y1 - mkQueue->y2 - sub1.y - sub2.y;
- const Common::Point point1 = moveSize(mov, 0, -1);
+ const Common::Point point1 = mov->getMovementSize(0, -1);
int n2x = point1.x;
int n2y = point1.y;
@@ -469,29 +477,35 @@ void AniHandler::putObjectToStatic(AniObject *ani, int staticsId) {
}
if (ani->_statics) {
- const Common::Point point = getTransitionSize(ani->_id, ani->_statics->_staticsId, staticsId);
+ const Vector2 size = getTransitionSize(ani->_id, ani->_statics->_staticsId, staticsId);
- ani->setPos(ani->pivotX() + point.x, ani->pivotY() + point.y);
+ ani->setPos(ani->pivotX() + static_cast<int>(size.x), ani->pivotY() + static_cast<int>(size.y));
ani->_statics = ani->getStatic(staticsId);
}
}
-Common::Point AniHandler::getTransitionSize(int objectId, int staticsId1, int staticsId2) {
+// CAniHandler::GetTransitionSize (1A7FA4)
+Vector2 AniHandler::getTransitionSize(int objectId, int staticsId1, int staticsId2) {
debugC(4, kDebugPathfinding, "AniHandler::getTransitionSize(%d, %d, %d)", objectId, staticsId1, staticsId2);
+ Vector2 size;
+ size.x = 0.0f;
+ size.y = 0.0f;
+
int idx = getIndex(objectId);
if (idx == -1) {
- return Common::Point(-1, -1);
+ size.x = -1.0f;
+ size.y = -1.0f;
+ return size;
}
int st1idx = getStaticIndex(idx, staticsId1);
int st2idx = getStaticIndex(idx, staticsId2);
- if (st1idx == st2idx) {
- return Common::Point(0, 0);
- }
+ if (st1idx == st2idx)
+ return size;
int subidx = st1idx + st2idx * _items[idx].statics.size();
@@ -507,11 +521,12 @@ Common::Point AniHandler::getTransitionSize(int objectId, int staticsId1, int st
const MGMSubItem &sub = _items[idx].transitions[subidx];
- if (!sub.movement) {
- return Common::Point(0, 0);
- }
+ if (!sub.movement)
+ return size;
- return Common::Point(sub.x, sub.y);
+ size.x = sub.x;
+ size.y = sub.y;
+ return size;
}
int AniHandler::getStaticIndex(int idx, int16 id) {
@@ -561,7 +576,7 @@ int AniHandler::seekWay(int idx, int st1idx, int st2idx, bool allowReverse, bool
if (item.transitions[subIdx].movement)
return item.transitions[subIdx].movementCount;
- Common::Point point;
+ Vector2 point;
debugC(3, kDebugPathfinding, "AniHandler::seekWay. movements sz: %d visitedMovements sz: %d", item.movements.size(), item.visitedMovements.size());
@@ -658,10 +673,8 @@ int AniHandler::getNumMovements(int objectId, int idx1, int idx2) {
}
Common::Point AniHandler::getNumCycles(Movement *mov, int x, int y, int *mult, int *len, int flag) {
- // CAniHandler::GetNumCycles measures with CMovement::GetMovementSize (center displacement, 2015)
- const bool centered = g_ngi->_gameVersion >= 201509;
auto size = [&](int idx, int dynidx) {
- return moveSize(mov, idx, dynidx);
+ return mov->getMovementSize(idx, dynidx);
};
Common::Point point = size(0, -1);
@@ -677,9 +690,7 @@ Common::Point AniHandler::getNumCycles(Movement *mov, int x, int y, int *mult, i
newmult = (int)((double)x / size(0, -1).x);
}
- if (centered)
- newmult = abs(newmult); // fabs(size / step), then truncated (CAniHandler::GetNumCycles)
- else if (newmult < 0)
+ if (newmult < 0)
newmult = 0;
*mult = newmult;
@@ -687,21 +698,7 @@ Common::Point AniHandler::getNumCycles(Movement *mov, int x, int y, int *mult, i
int phase = 1;
int sz;
- if (flag && centered) {
- // CAniHandler::GetNumCycles (1A816E): stops at the first frame where the center displacement plus
- // that of the whole cycles (absolute values) reaches the distance; stop = frame before
- // without the end statics that this engine's movement holds
- const int phases = (int)(mov->_currMovement ? mov->_currMovement->_phases.size() : mov->_phases.size()) - 1;
- const bool vertical = abs(p1y) > abs(p1x);
- int frame = 0;
- for (;; frame++) {
- const Common::Point step = size(0, frame);
- const int part = vertical ? abs(step.y) + abs(p1y * newmult) : abs(step.x) + abs(p1x * newmult);
- if (part >= (vertical ? abs(y) : abs(x)) || frame >= phases)
- break;
- }
- *len = frame - 1;
- } else if (flag) {
+ if (flag) {
if (abs(p1y) > abs(p1x)) {
while (abs(p1y * newmult + size(0, phase).y) < abs(y)) {
sz = mov->_currMovement ? mov->_currMovement->_phases.size() : mov->_phases.size();
@@ -749,6 +746,76 @@ Common::Point AniHandler::getNumCycles(Movement *mov, int x, int y, int *mult, i
return Common::Point(p2x + p1x * newmult, p2y + p1y * newmult);
}
+// CAniHandler::GetNumCycles (1A816E)
+Vector2 AniHandler::getNumCyclesF(Movement *mov, float x, float y, int *mult, int *len, bool flag, bool mirror) {
+ const Vector2 size = mov->getCenterMovementSizeF(0, -1);
+ const bool vertical = fabsf(size.y) > fabsf(size.x);
+ // the phases of the original have no end statics
+ const int phases = (int)(mov->_currMovement ? mov->_currMovement->_phases.size() : mov->_phases.size()) - 1;
+
+ int cycles = 0;
+ if (vertical) {
+ if (size.y != 0.0f)
+ cycles = MAX((int)fabsf(y / size.y), 0);
+ } else if (size.x != 0.0f) {
+ cycles = MAX((int)fabsf(x / size.x), 0);
+ }
+
+ *mult = cycles;
+ *len = -1;
+
+ if (flag) {
+ int i = 0;
+ for (;; ++i) {
+ const Vector2 part = mov->getCenterMovementSizeF(0, i);
+ const float reached = vertical ? fabsf(part.y) + fabsf((float)cycles * size.y) : fabsf(part.x) + fabsf((float)cycles * size.x);
+ if (reached >= (vertical ? fabsf(y) : fabsf(x)) || i >= phases)
+ break;
+ }
+ *len = i - 1;
+ }
+
+ float restX = 0.0f;
+ float restY = 0.0f;
+ if (*len > 0) {
+ ++*mult;
+ const Vector2 part = mov->getCenterMovementSizeF(0, *len);
+ restX = part.x;
+ restY = part.y;
+ if (vertical)
+ restX = size.x;
+ else
+ restY = size.y;
+ }
+
+ Vector2 result;
+ result.x = size.x * (float)cycles + restX;
+ result.y = size.y * (float)cycles + restY;
+ if (mirror)
+ result.x = -result.x;
+ return result;
+}
+
+// CAniHandler::CreateCommand (1A8410)
+Command *AniHandler::createCommand(Movement *mov, bool mirror, int aniId, float stepX, float stepY, int stopFrame) {
+ Command *command = new Command();
+ command->_cmd = kCmdStartSliding;
+ command->_wait = 1;
+ command->_excFlags = 2;
+ command->setParamInt("aniId", aniId);
+ command->setParamInt("moveId", mov->_id);
+ command->_args["cycled"] = "0";
+ command->_args["mirror"] = mirror ? "1" : "0";
+ command->setParamFloat("stepX", stepX);
+ command->setParamFloat("stepY", stepY);
+ command->setParamInt("stopFrame", stopFrame);
+ command->_parentId = aniId;
+ command->_messageNum = mov->_id;
+ command->_mirror = mirror;
+ command->_z = stopFrame;
+ return command;
+}
+
ExCommand2 *AniHandler::createCommand(Movement *mov, int objId, int x1, int y1, Common::Point &x2, Common::Point &y2, int len) {
debugC(2, kDebugPathfinding, "AniHandler::createCommand(mov, %d, %d, %d, [%d, %d], [%d, %d], %d)", objId, x1, y1, x2.x, x2.y, y2.x, y2.y, len);
@@ -796,4 +863,169 @@ ExCommand2 *AniHandler::createCommand(Movement *mov, int objId, int x1, int y1,
return ex;
}
+// CAniHandler::MakeRunQueue (1A8874)
+MessageQueue *AniHandler::makeRunQueueAndroid(MakeQueueStruct *mkQueue) {
+ AniObject *ani = mkQueue->ani;
+
+ debugC(4, kDebugPathfinding, "CAniHandler::MakeRunQueue-: Src=(%d,%d),Dest=(%d,%d)", (int)mkQueue->x2, (int)mkQueue->y2, (int)mkQueue->x1, (int)mkQueue->y1);
+
+ if (!ani->_movement && !ani->_statics)
+ return nullptr;
+
+ if (!(mkQueue->flags & 1))
+ mkQueue->staticsId1 = ani->_movement ? ani->_movement->_nextStatic->_staticsId : ani->getStaticsId();
+
+ if ((mkQueue->flags & 0x30) != 0x30) {
+ Vector2 center = ani->getCenterF();
+ if (ani->_movement) {
+ const Vector2 left = ani->getMovementSizeLeft();
+ center.x += left.x;
+ center.y += left.y;
+ }
+ if (!(mkQueue->flags & 0x10))
+ mkQueue->x2 = center.x;
+ if (!(mkQueue->flags & 0x20))
+ mkQueue->y2 = center.y;
+ }
+
+ debugC(4, kDebugPathfinding, "CAniHandler::MakeRunQueue--: Src=(%d,%d),Dest=(%d,%d)", (int)mkQueue->x2, (int)mkQueue->y2, (int)mkQueue->x1, (int)mkQueue->y1);
+
+ Movement *mov = ani->getMovement(mkQueue->movementId);
+ if (!mov)
+ return nullptr;
+
+ const int itemIdx = getIndex(ani->_id);
+ if (itemIdx == -1) {
+ warning("STUB/untested: CAniHandler::MakeRunQueue: object %d is not attached to the handler (the original reads garbage)!", ani->_id);
+ return nullptr;
+ }
+ int startIdx = getStaticIndex(itemIdx, mkQueue->staticsId1);
+ const int movePrevIdx = getStaticIndex(itemIdx, mov->_prevStatic->_staticsId);
+ int moveNextIdx = getStaticIndex(itemIdx, mov->_nextStatic->_staticsId);
+ const int endIdx = getStaticIndex(itemIdx, mkQueue->staticsId2);
+
+ clearVisitsList(itemIdx);
+ seekWay(itemIdx, startIdx, movePrevIdx, false, true);
+ clearVisitsList(itemIdx);
+ seekWay(itemIdx, moveNextIdx, endIdx, false, true);
+
+ const uint staticsCount = _items[itemIdx].statics.size();
+ const MGMSubItem &sub1 = _items[itemIdx].transitions[startIdx + movePrevIdx * staticsCount];
+ const MGMSubItem &sub2 = _items[itemIdx].transitions[moveNextIdx + endIdx * staticsCount];
+
+ if (startIdx != movePrevIdx && !sub1.movement)
+ return nullptr;
+ if (moveNextIdx != endIdx && !sub2.movement)
+ return nullptr;
+
+ float distX = (mkQueue->x1 - mkQueue->x2 - sub1.x) - sub2.x;
+ float distY = (mkQueue->y1 - mkQueue->y2 - sub1.y) - sub2.y;
+
+ const Vector2 size = mov->getCenterMovementSizeF(0, -1);
+ int cycles;
+ int stopFrame;
+ float cyclesX;
+ float cyclesY;
+ if (mkQueue->flags & 0x40) {
+ cycles = mkQueue->cycleCount;
+ stopFrame = -1;
+ cyclesX = size.x * (float)cycles;
+ cyclesY = size.y * (float)cycles;
+ } else {
+ const Vector2 cycled = getNumCyclesF(mov, distX, distY, &cycles, &stopFrame, true, false);
+ cyclesX = cycled.x;
+ cyclesY = cycled.y;
+ }
+
+ if (!(mkQueue->flags & 2)) {
+ stopFrame = -1;
+ cyclesX = size.x * (float)cycles;
+ mkQueue->x1 = ((sub1.x + mkQueue->x2) + cyclesX) + sub2.x;
+ distX = cyclesX;
+ }
+ if (!(mkQueue->flags & 4)) {
+ stopFrame = -1;
+ cyclesY = size.y * (float)cycles;
+ mkQueue->y1 = ((sub1.y + mkQueue->y2) + cyclesY) + sub2.y;
+ distY = cyclesY;
+ }
+
+ int framesX = 0;
+ int framesY = 0;
+ if (sub1.movement) {
+ framesX = getFramesCount(itemIdx, startIdx, movePrevIdx, 1);
+ framesY = getFramesCount(itemIdx, startIdx, movePrevIdx, 2);
+ }
+ if (cycles > 1) {
+ framesX += mov->countPhasesWithFlag(-1, 1) * (cycles - 1);
+ framesY += mov->countPhasesWithFlag(-1, 2) * (cycles - 1);
+ }
+ if (cycles > 0) {
+ framesX += mov->countPhasesWithFlag(stopFrame, 1);
+ framesY += mov->countPhasesWithFlag(stopFrame, 2);
+ }
+ if (sub2.movement) {
+ framesX += getFramesCount(itemIdx, moveNextIdx, endIdx, 1);
+ framesY += getFramesCount(itemIdx, moveNextIdx, endIdx, 2);
+ }
+
+ const float restX = distX - cyclesX;
+ const float restY = distY - cyclesY;
+ const float stepX = framesX != 0 ? restX / (float)framesX : 0.0f;
+ const float stepY = framesY != 0 ? restY / (float)framesY : 0.0f;
+
+ debugC(4, kDebugPathfinding, "CAniHandler::MakeRunQueue---: nYOfs=%d,nSteps=%d,nStopPhase=%d,csOfs=(%d,%d),csOfsPerFrame=(%d,%d)", framesY, cycles, stopFrame, (int)restX, (int)restY, (int)stepX, (int)stepY);
+
+ MessageQueue *mq = newQueue();
+ const int copy = ani->_copyId;
+
+ while (startIdx != movePrevIdx) {
+ const MGMSubItem &sub = _items[itemIdx].transitions[startIdx + movePrevIdx * staticsCount];
+ Command *command = createCommand(sub.movement, false, ani->_id, stepX, stepY, -1);
+ command->setParamInt("copy", copy);
+ command->_parId = mq->_id;
+ mq->addCommandToEnd(command);
+ startIdx = sub.staticsIndex;
+ }
+
+ for (int i = 0; i < cycles; i++) {
+ Command *command = createCommand(mov, false, ani->_id, stepX, stepY, i == cycles - 1 ? stopFrame : -1);
+ command->setParamInt("copy", copy);
+ command->_parId = mq->_id;
+ mq->addCommandToEnd(command);
+ }
+
+ while (moveNextIdx != endIdx) {
+ const MGMSubItem &sub = _items[itemIdx].transitions[moveNextIdx + endIdx * staticsCount];
+ Command *command = createCommand(sub.movement, false, ani->_id, stepX, stepY, -1);
+ command->setParamInt("copy", copy);
+ command->_parId = mq->_id;
+ mq->addCommandToEnd(command);
+ moveNextIdx = sub.staticsIndex;
+ }
+
+ // the final SHOW: x, y, z only when set, the mirror stays
+ Command *show = new Command();
+ show->_cmd = kCmdShow;
+ show->_excFlags = 2;
+ show->setParamInt("aniId", ani->_id);
+ show->setParamInt("copy", copy);
+ show->_x = -1;
+ show->_y = -1;
+ show->_z = -1;
+ show->_auxParam = -1;
+ if (mkQueue->x1 != -1.0f)
+ show->setParamFloat("x", mkQueue->x1);
+ if (mkQueue->y1 != -1.0f)
+ show->setParamFloat("y", mkQueue->y1);
+ if ((float)mkQueue->destZ != -1.0f)
+ show->setParamFloat("z", (float)mkQueue->destZ);
+ show->_parentId = ani->_id;
+ show->_messageNum = -1;
+ show->_parId = mq->_id;
+ mq->addCommandToEnd(show);
+
+ return mq;
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/anihandler.h b/engines/ngi/anihandler.h
index b5e6d37d332..127cd49070d 100644
--- a/engines/ngi/anihandler.h
+++ b/engines/ngi/anihandler.h
@@ -22,8 +22,11 @@
#ifndef NGI_ANIHANDLER_H
#define NGI_ANIHANDLER_H
+#include "ngi/vector2.h"
+
namespace NGI {
+class Command;
class ExCommand2;
class Movement;
class Statics;
@@ -33,8 +36,9 @@ struct MGMSubItem {
int staticsIndex;
int movementCount;
int frameCount;
- int x;
- int y;
+ /** CAniHandler: +16, +20, the sum of the center displacements of the way (floats from 201509) */
+ float x;
+ float y;
MGMSubItem();
@@ -64,11 +68,11 @@ struct MakeQueueStruct {
int staticsId2;
int movementId;
int cycleCount;
- int x1;
- int y1;
+ float x1;
+ float y1;
int destZ;
- int x2;
- int y2;
+ float x2;
+ float y2;
int flags;
MakeQueueStruct() { reset(); }
@@ -104,13 +108,20 @@ public:
MessageQueue *makeRunQueue(MakeQueueStruct *mkQueue);
void putObjectToStatic(AniObject *ani, int staticsId);
- Common::Point getTransitionSize(int aniId, int staticsId1, int staticsId2);
+ /** CAniHandler::GetTransitionSize (1A7FA4); (-1, -1) for an unknown object */
+ Vector2 getTransitionSize(int aniId, int staticsId1, int staticsId2);
int getStaticIndex(int idx, int16 id);
int getStaticIndex(int idx, Statics *st);
void clearVisitsList(int idx);
int seekWay(int idx, int st1idx, int st2idx, bool allowReverse, bool linkedOnly);
Common::Point getNumCycles(Movement *mov, int x, int y, int *mult, int *len, int flag);
+ /** CAniHandler::GetNumCycles (1A816E) */
+ Vector2 getNumCyclesF(Movement *mov, float x, float y, int *mult, int *len, bool flag, bool mirror);
ExCommand2 *createCommand(Movement *mov, int objId, int x1, int y1, Common::Point &x2, Common::Point &y2, int len);
+ /** CAniHandler::CreateCommand (1A8410): START_SLIDING with one step vector (>= 201509) */
+ Command *createCommand(Movement *mov, bool mirror, int aniId, float stepX, float stepY, int stopFrame);
+ /** CAniHandler::MakeRunQueue (1A8874), run by makeRunQueue from 201509 on */
+ MessageQueue *makeRunQueueAndroid(MakeQueueStruct *mkQueue);
MessageQueue *newQueue();
MessageQueue *makeQueue(AniObject *ani, int staticsIndex, int staticsId, int *resStatId, Common::Point **pointArr);
int getFramesCount(int idx, int subIdx, int subOffset, int flag);
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index e79de10480a..09c92af66bb 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -151,13 +151,8 @@ void moveTestObject(AniObject *ani) {
}
for (int mirror = 0; mirror < 2; mirror++) {
moveTestReset(ani, first, false);
- PointList points;
- points.push_back(Common::Point(5, 1));
- points.push_back(Common::Point(7, -2));
- points.push_back(Common::Point(-3, 4));
- points.push_back(Common::Point(2, 2));
Common::String line = Common::String::format("%s mov %d slide mir %d %s ->", title.c_str(), movementId, mirror, moveTestState(ani).c_str());
- ani->startSliding(movementId, 0, 0, 0, points, -1, mirror != 0);
+ ani->startSliding(movementId, false, -1, mirror != 0, 3.5f, -1.25f);
line += " | " + moveTestState(ani) + " |";
for (int frames = 0; ani->_movement && frames < 400; frames++) {
if (!ani->setNextFrame(true)) {
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 7e049652979..3e42691a8e5 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -604,6 +604,22 @@ int global_messageHandler4(Command *cmd) {
if (!scene)
break;
+ if (g_ngi->_gameVersion >= 201509) {
+ // CMessageQueue::ExecuteCmdStartSliding (10D49C): the copy -1 is every copy
+ const int stopFrame = cmd->getParamInt("stopFrame", -1);
+ const Common::String cycled = cmd->_args.getValOrDefault("cycled");
+ const bool isCycled = cycled == "1" || cycled.equalsIgnoreCase("true");
+ const float stepX = cmd->getParamFloat("stepX", 0.0f);
+ const float stepY = cmd->getParamFloat("stepY", 0.0f);
+ if (cmd->_param == -1) {
+ for (int copy = 0; (ani = scene->findAniObjectById(cmd->_parentId, copy)) != nullptr; copy++)
+ ani->startSliding(cmd->_messageNum, isCycled, stopFrame, cmd->_mirror, stepX, stepY);
+ } else if ((ani = scene->findAniObjectById(cmd->_parentId, cmd->_param)) != nullptr) {
+ ani->startSliding(cmd->_messageNum, isCycled, stopFrame, cmd->_mirror, stepX, stepY);
+ }
+ break;
+ }
+
ani = scene->findAniObjectById(cmd->_parentId, cmd->_param);
if (!ani)
break;
diff --git a/engines/ngi/messagequeuebuilder.cpp b/engines/ngi/messagequeuebuilder.cpp
index 2f9215bed4c..61bdaf13600 100644
--- a/engines/ngi/messagequeuebuilder.cpp
+++ b/engines/ngi/messagequeuebuilder.cpp
@@ -162,7 +162,6 @@ void MessageQueueBuilder::addCmdStartMove(uint aniId, uint moveId, bool cycled,
void MessageQueueBuilder::addCmdStartSliding(uint aniId, uint moveId, Vector2 step, bool cycled, bool mirror, int stopFrame, int position, bool wait, int copy) {
if (!_queue)
return;
- warning("STUB/untested: CMessageQueueBuilder::AddCmdStartSliding (the queue cannot run START_SLIDING without the points)");
Command *command = newCommand(kCmdStartSliding, wait);
command->setParamInt("aniId", aniId);
command->setParamInt("copy", copy);
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index b4f0f9f755c..e833e30f6a0 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -693,10 +693,10 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
int nx = ani->pivotX();
int ny = ani->pivotY();
- point = _aniHandler.getTransitionSize(ani->_id, ani->_statics->_staticsId, _ladmovements[pos]->staticIds[0]);
+ const Vector2 size = _aniHandler.getTransitionSize(ani->_id, ani->_statics->_staticsId, _ladmovements[pos]->staticIds[0]);
- nx += point.x;
- ny += point.y;
+ nx += static_cast<int>(size.x);
+ ny += static_cast<int>(size.y);
ani->getPicAniInfo(picinfo);
@@ -2619,7 +2619,10 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
mctlMQ1.destZ = nod->_z + (int)(dst1 * (double)dst / linkInfoDest.link->_length);
- putToLink(&mctlMQ1.destPos, linkInfoDest.link, 1);
+ Common::Point linked(static_cast<int>(mctlMQ1.destPos.x), static_cast<int>(mctlMQ1.destPos.y));
+ putToLink(&linked, linkInfoDest.link, 1);
+ mctlMQ1.destPos.x = linked.x;
+ mctlMQ1.destPos.y = linked.y;
dx1 = mctlMQ1.sourcePos.x;
dy1 = mctlMQ1.sourcePos.y;
@@ -2776,6 +2779,9 @@ int MctlGraph::getLinkDir(MovGraphLinkList *linkList, int idx, Common::Rect *rec
MessageQueue *MctlGraph::makeLineQueue(GmctlMqStruct *info) {
debugC(4, kDebugPathfinding, "MctlGraph::makeLineQueue(...)");
+ if (g_ngi->_gameVersion >= 201509)
+ return makeLineQueueAndroid(info);
+
int mx1 = 0;
int my1 = 0;
@@ -2895,11 +2901,8 @@ MessageQueue *MctlGraph::makeLineQueue(GmctlMqStruct *info) {
ex->_z = info->sourceZ;
ex->_param = _aniData[info->objectIndex]._ani->_copyId;
- ex->_wait = g_ngi->_gameVersion >= 201509 ? 0 : 1; // CCommand(1) has no wait
+ ex->_wait = 1;
ex->_excFlags |= 2;
- // CMctlGraph::MakeLineQueue: Show carries the mirror of its movement
- if (g_ngi->_gameVersion >= 201509)
- ex->_auxParam = walk[1]._mirror;
} else {
ex = new Command(
_aniData[info->objectIndex]._objectId,
@@ -2916,10 +2919,8 @@ MessageQueue *MctlGraph::makeLineQueue(GmctlMqStruct *info) {
ex->_z = info->sourceZ;
ex->_param = _aniData[info->objectIndex]._ani->_copyId;
- ex->_wait = g_ngi->_gameVersion >= 201509 ? 0 : 1; // CCommand(1) has no wait
+ ex->_wait = 1;
ex->_excFlags |= 2;
- if (g_ngi->_gameVersion >= 201509)
- ex->_auxParam = walk[0]._mirror;
mq->addCommandToEnd(ex);
ex = _aniHandler.createCommand(
@@ -2975,21 +2976,146 @@ MessageQueue *MctlGraph::makeLineQueue(GmctlMqStruct *info) {
mq->addCommandToEnd(ex);
}
- // The final Show puts the object on the exact destination; the 2015 build only for an exact
- // one (flags & 1), with the stop movement's mirror, else it faces right after walking left
- if (g_ngi->_gameVersion < 201509 || (info->flags & 1)) {
- ex = new Command(_aniData[info->objectIndex]._objectId, kCmdShow, -1, info->destPos.x, info->destPos.y, 0, 1, 0, 0, 0);
- ex->_z = info->destZ;
+ ex = new Command(_aniData[info->objectIndex]._objectId, kCmdShow, -1, info->destPos.x, info->destPos.y, 0, 1, 0, 0, 0);
+ ex->_z = info->destZ;
- ex->_param = _aniData[info->objectIndex]._ani->_copyId;
- ex->_wait = 0;
- ex->_excFlags |= 2;
- if (g_ngi->_gameVersion >= 201509)
- ex->_auxParam = walk[2]._mirror;
+ ex->_param = _aniData[info->objectIndex]._ani->_copyId;
+ ex->_wait = 0;
+ ex->_excFlags |= 2;
- mq->addCommandToEnd(ex);
+ mq->addCommandToEnd(ex);
+
+ return mq;
+}
+
+// the SHOW of CMctlGraph::MakeLineQueue: x, y, z only when set, the facing of the movement
+static Command *newLineShow(int aniId, int copy, int movementId, bool mirror, float x, float y, int z) {
+ Command *show = new Command();
+ show->_cmd = kCmdShow;
+ show->_excFlags = 2;
+ show->setParamInt("aniId", aniId);
+ if (movementId != -1)
+ show->setParamInt("moveId", movementId);
+ show->_args["mirror"] = mirror ? "1" : "0";
+ show->_x = -1;
+ show->_y = -1;
+ show->_z = -1;
+ if (x != -1.0f)
+ show->setParamFloat("x", x);
+ if (y != -1.0f)
+ show->setParamFloat("y", y);
+ if (z != -1)
+ show->setParamFloat("z", (float)z);
+ show->setParamInt("copy", copy);
+ show->_parentId = aniId;
+ show->_messageNum = movementId;
+ show->_auxParam = mirror;
+ return show;
+}
+
+// CMctlGraph::MakeLineQueue (1AB174)
+MessageQueue *MctlGraph::makeLineQueueAndroid(GmctlMqStruct *info) {
+ GmctlAni &data = _aniData[info->objectIndex];
+ const MG2I *walk = data._directions[info->sourceDir]._walk;
+ const int flags = info->flags;
+ const int aniId = data._objectId;
+ const int copy = data._ani->_copyId;
+
+ debugC(4, kDebugPathfinding, "CMctlGraph::MakeLineQueue-: Src=(%d,%d),Dest=(%d,%d)", (int)info->sourcePos.x, (int)info->sourcePos.y, (int)info->destPos.x, (int)info->destPos.y);
+
+ float startX = 0.0f;
+ float startY = 0.0f;
+ if (!(flags & 2)) {
+ startX = walk[0]._deltaX;
+ startY = walk[0]._deltaY;
+ }
+ float endX = 0.0f;
+ float endY = 0.0f;
+ if (!(flags & 4)) {
+ endX = walk[2]._deltaX;
+ endY = walk[2]._deltaY;
+ }
+
+ float distX = ((info->destPos.x - info->sourcePos.x) - startX) - endX;
+ float distY = ((info->destPos.y - info->sourcePos.y) - startY) - endY;
+
+ int cycles;
+ int stopFrame;
+ const Vector2 cycled = _aniHandler.getNumCyclesF(walk[1]._movement, distX, distY, &cycles, &stopFrame, flags & 1, walk[1]._mirror);
+ float cyclesX = cycled.x;
+ float cyclesY = cycled.y;
+
+ if (!(flags & 1)) {
+ if (info->sourceDir <= 1) {
+ stopFrame = -1;
+ cyclesX = (float)cycles * walk[1]._deltaX;
+ info->destPos.x = ((cyclesX + info->sourcePos.x) + startX) + endX;
+ distX = cyclesX;
+ }
+ if (info->sourceDir == 2 || info->sourceDir == 3) {
+ stopFrame = -1;
+ cyclesY = (float)cycles * walk[1]._deltaY;
+ info->destPos.y = ((cyclesY + info->sourcePos.y) + startY) + endY;
+ distY = cyclesY;
+ }
}
+ int framesX = 0;
+ int framesY = 0;
+ if (!(flags & 2)) {
+ framesX = walk[0]._movement->countPhasesWithFlag(-1, 1);
+ framesY = walk[0]._movement->countPhasesWithFlag(-1, 2);
+ }
+ if (cycles > 1) {
+ framesX += walk[1]._movement->countPhasesWithFlag(-1, 1) * (cycles - 1);
+ framesY += walk[1]._movement->countPhasesWithFlag(-1, 2) * (cycles - 1);
+ }
+ if (cycles > 0) {
+ framesX += walk[1]._movement->countPhasesWithFlag(stopFrame, 1);
+ framesY += walk[1]._movement->countPhasesWithFlag(stopFrame, 2);
+ }
+ if (!(flags & 4)) {
+ framesX += walk[2]._movement->countPhasesWithFlag(-1, 1);
+ framesY += walk[2]._movement->countPhasesWithFlag(-1, 2);
+ }
+
+ const float restX = distX - cyclesX;
+ const float restY = distY - cyclesY;
+ const float stepX = framesX != 0 ? restX / (float)framesX : 0.0f;
+ const float stepY = framesY != 0 ? restY / (float)framesY : 0.0f;
+
+ debugC(4, kDebugPathfinding, "CMctlGraph::MakeLineQueue--: nYOfs=%d,nSteps=%d,nStopPhase=%d,csOfs=(%d,%d),csOfsPerFrame=(%d,%d)", framesY, cycles, stopFrame, (int)restX, (int)restY, (int)stepX, (int)stepY);
+
+ MessageQueue *mq = newWalkQueue();
+
+ if (flags & 2) {
+ mq->addCommandToEnd(newLineShow(aniId, copy, walk[1]._movementId, walk[1]._mirror, info->sourcePos.x, info->sourcePos.y, info->sourceZ));
+ } else {
+ mq->addCommandToEnd(newLineShow(aniId, copy, walk[0]._movementId, walk[0]._mirror, info->sourcePos.x, info->sourcePos.y, info->sourceZ));
+
+ Command *command = _aniHandler.createCommand(walk[0]._movement, walk[0]._mirror, aniId, stepX, stepY, -1);
+ command->setParamInt("copy", copy);
+ command->_parId = mq->_id;
+ mq->addCommandToEnd(command);
+ }
+
+ for (int i = 0; i < cycles; i++) {
+ Command *command = _aniHandler.createCommand(walk[1]._movement, walk[1]._mirror, aniId, stepX, stepY, i == cycles - 1 ? stopFrame : -1);
+ command->setParamInt("copy", copy);
+ command->_parId = mq->_id;
+ mq->addCommandToEnd(command);
+ }
+
+ if (!(flags & 4)) {
+ Command *command = _aniHandler.createCommand(walk[2]._movement, walk[2]._mirror, aniId, stepX, stepY, -1);
+ command->setParamInt("copy", copy);
+ command->_parId = mq->_id;
+ mq->addCommandToEnd(command);
+ }
+
+ if (flags & 1)
+ mq->addCommandToEnd(newLineShow(aniId, copy, -1, walk[2]._mirror, info->destPos.x, info->destPos.y, info->destZ));
+
return mq;
}
diff --git a/engines/ngi/motion.h b/engines/ngi/motion.h
index e33f4f84de6..e1af17c6585 100644
--- a/engines/ngi/motion.h
+++ b/engines/ngi/motion.h
@@ -374,8 +374,9 @@ struct GmctlPathItem {
struct GmctlMqStruct {
int objectIndex;
- Common::Point sourcePos;
- Common::Point destPos;
+ /** floats in the original (CGmctlMqStruct +4 .. +16) */
+ Vector2 sourcePos;
+ Vector2 destPos;
int sourceZ;
int destZ;
int sourceDir;
@@ -426,6 +427,8 @@ public:
double iterate(LinkOrNode *linkInfoSource, LinkOrNode *linkInfoDest, MovGraphLinkList *listObj);
MessageQueue *makeLineQueue(GmctlMqStruct *movinfo);
+ /** CMctlGraph::MakeLineQueue (1AB174), run by makeLineQueue from 201509 on */
+ MessageQueue *makeLineQueueAndroid(GmctlMqStruct *info);
};
class MctlConnectionPoint : public CObject {
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 812ac5e9ed5..4811970fd0b 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -1177,6 +1177,16 @@ Common::Point *AniObject::calcNextStep(Common::Point *pRes) {
return pRes;
}
+// mqGetMovementSizeLeft (1A84A8)
+Vector2 AniObject::getMovementSizeLeft() {
+ Vector2 size;
+ size.x = 0.0f;
+ size.y = 0.0f;
+ if (_movement)
+ size = _movement->getCenterMovementSizeF(1, movementStopFrame());
+ return size;
+}
+
void AniObject::stopMovement(bool keepSounds) {
if (g_ngi->_gameVersion >= 201509) {
stopMovementAndroid(keepSounds);
@@ -1314,15 +1324,6 @@ void AniObject::setMovementFrame(Movement *mov, int frame, bool silent) {
if ((_x != x || _y != y) && (_scaleX != 1.0f || _scaleY != 1.0f || _rotation != 0.0f))
warning("STUB/untested: CMovement::SetFrame of ani %d with scale %f, %f, rotation %f: the step is not scaled or rotated", _id, _scaleX, _scaleY, _rotation);
storeTopLeft(x, y);
- // the slide of the frames (+80, +84 of the movement): added going forward, taken back going back
- if (forward) {
- const Common::Point step = _stepArray.getCurrPoint();
- storeTopLeft(_x + step.x, _y + step.y);
- _stepArray.gotoNextPoint();
- } else if (frame < _stepArray.getPointsCount()) {
- const Common::Point step = _stepArray.getPoint(frame, 1);
- storeTopLeft(_x - step.x, _y - step.y);
- }
if (!silent)
mov->_curPhase->execCmd();
@@ -1853,24 +1854,29 @@ void AniObject::playIdle() {
adjustSomeXY();
}
-void AniObject::startSliding(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex, bool mirror, bool cycled) {
- if (g_ngi->_gameVersion >= 201509) {
- // CAniObject::StartSliding (F0E3C): a running movement is finished, not rewound
- if (_movement && (_flags & 1))
- stopMovement(false);
- if (startMovement(movementId, messageQueueId, someDynamicPhaseIndex, mirror, cycled, false, -1, true)) {
- _stepArray.insertPoints(points);
- const Common::Point offset = _stepArray.getCurrPoint();
- storeTopLeft(_x + offset.x, _y + offset.y);
- _stepArray.gotoNextPoint();
- // CMovement::SetFrame (EF8B8): the sound and the command of the first frame, after the slide
- Phase *phase = _movement->_curPhase;
- phase->setCurrent(_id, !g_ngi->_preloadManager->isPreloaded(movementId), false);
- phase->execCmd();
- }
- return;
+// CAniObject::StartSliding (F0E3C)
+bool AniObject::startSliding(int movementId, bool cycled, int stopFrame, bool mirror, float stepX, float stepY) {
+ if (_movement && (_flags & 1))
+ stopMovement(false);
+ _animExFlag = 0;
+ _lastMovementId = movementId;
+
+ Movement *mov = getMovement(movementId);
+ if (!mov)
+ return false;
+ if (!mov->getPhase(1)) {
+ // a movement without phases stops at once, as in startMovement
+ startMovementWithoutPhases(mov, mirror, false, -1);
+ return false;
}
+ Vector2 slide;
+ slide.x = stepX;
+ slide.y = stepY;
+ return startMovementTimed(mov, 0, stopFrame, mirror, cycled, false, -1, false, &slide);
+}
+
+void AniObject::startSliding(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex, bool mirror, bool cycled) {
Movement *mov = nullptr;
if (!(_flags & 0x80)) {
@@ -1994,7 +2000,7 @@ void AniObject::startMovementWithoutPhases(Movement *movement, bool mirror, bool
}
// CAniObject::StartMovement (F0D46) from 201509, then CMovement::Start (EFC96)
-bool AniObject::startMovementTimed(Movement *mov, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame, bool silent) {
+bool AniObject::startMovementTimed(Movement *mov, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame, bool silent, const Vector2 *slide) {
const int movementId = mov->_id;
Statics *start = reverse ? mov->_nextStatic : mov->_prevStatic;
@@ -2007,7 +2013,6 @@ bool AniObject::startMovementTimed(Movement *mov, int messageQueueId, int dynPha
const Common::Point oldSize = getSize();
_movement = mov;
- _stepArray.clear();
// a reverse movement starts one phase before its end statics (CMovement::SetNext)
if (reverse) {
@@ -2019,7 +2024,10 @@ bool AniObject::startMovementTimed(Movement *mov, int messageQueueId, int dynPha
float x = _x;
float y = _y;
- _movement->start(x, y, oldSize.x, oldSize.y, _scaleX, _scaleY, _rotation, mirror, reverse);
+ if (slide)
+ _movement->slide(x, y, oldSize.x, oldSize.y, _scaleX, _scaleY, _rotation, mirror, slide->x, slide->y);
+ else
+ _movement->start(x, y, oldSize.x, oldSize.y, _scaleX, _scaleY, _rotation, mirror, reverse);
storeTopLeft(x, y);
_flags |= 1;
@@ -2530,30 +2538,55 @@ Common::Point Movement::getCurrDynamicPhaseXY() const {
}
Common::Point Movement::getCenterMovementSize(int idx, int dynidx) {
- // CMovement::GetMovementSize: displacement of the sprite center from the start (idx 0:
- // previous statics, idx 1: current phase) to the phase dynidx (-1: the end)
+ const Vector2 size = getCenterMovementSizeF(idx, dynidx);
+ return Common::Point((int)roundf(size.x), (int)roundf(size.y));
+}
+
+// CMovement::GetMovementSize (EFEC2); idx 0: from the previous statics, 1: from the current phase
+Vector2 Movement::getCenterMovementSizeF(int idx, int dynidx) {
+ // the original has no end statics in its phases: its last phase plus Stop is the end statics here
const int last = (int)_phases.size() - 1;
- const int target = dynidx < 0 || dynidx > last ? last : dynidx;
+ const int target = dynidx < 0 || dynidx >= last - 1 ? last : dynidx;
Dims startSize;
- float dx = 0, dy = 0;
- int first;
+ float dx = 0;
+ float dy = 0;
+ int frame;
if (!idx) {
startSize = _prevStatic->getDimensions();
dx = _prevStepX;
dy = _prevStepY;
- first = 1;
+ frame = 0;
} else {
startSize = getPhaseSize(_curFrame);
- first = _curFrame + 1;
+ frame = _curFrame;
}
const Dims endSize = getPhaseSize(target);
- for (int i = first; i <= target && i < (int)_framePosOffsets.size(); ++i) {
- dx += _framePosOffsets[i].x;
- dy += _framePosOffsets[i].y;
+ while (frame != target) {
+ const int next = frame < target ? frame + 1 : frame - 1;
+ float slideX = 0.0f;
+ float slideY = 0.0f;
+ const Phase *phase = getPhase(next);
+ if (idx && phase && (phase->_flags & 1))
+ slideX = _slideX;
+ if (idx && phase && (phase->_flags & 2))
+ slideY = _slideY;
+ if (next > frame) {
+ if ((uint)next < _framePosOffsets.size()) {
+ dx += slideX + _framePosOffsets[next].x;
+ dy += slideY + _framePosOffsets[next].y;
+ }
+ } else if ((uint)frame < _framePosOffsets.size()) {
+ dx -= slideX + _framePosOffsets[frame].x;
+ dy -= slideY + _framePosOffsets[frame].y;
+ }
+ frame = next;
}
dx += (endSize.x - startSize.x) * 0.5f;
dy += (endSize.y - startSize.y) * 0.5f;
- return Common::Point((int)roundf(dx), (int)roundf(dy));
+ Vector2 size;
+ size.x = dx;
+ size.y = dy;
+ return size;
}
// CMovement::GetStepToFrame (EF05E)
@@ -2994,16 +3027,22 @@ void Movement::setFrame(int frame, float &x, float &y, bool mirror) {
const float oldCenterX = x + oldSize.x * 0.5f;
const float oldCenterY = y + oldSize.y * 0.5f;
+ // the slide of the phase entered; going back it is negated with the offset of the phase left
float stepX = 0.0f;
float stepY = 0.0f;
+ const Phase *target = getPhase(frame);
+ if (target && (target->_flags & 1))
+ stepX = _slideX;
+ if (target && (target->_flags & 2))
+ stepY = _slideY;
if (_curFrame >= frame) {
if (_curFrame >= 0 && (uint)_curFrame < _framePosOffsets.size()) {
- stepX = -_framePosOffsets[_curFrame].x;
- stepY = -_framePosOffsets[_curFrame].y;
+ stepX = -(stepX + _framePosOffsets[_curFrame].x);
+ stepY = -(stepY + _framePosOffsets[_curFrame].y);
}
} else if ((uint)frame < _framePosOffsets.size()) {
- stepX = _framePosOffsets[frame].x;
- stepY = _framePosOffsets[frame].y;
+ stepX += _framePosOffsets[frame].x;
+ stepY += _framePosOffsets[frame].y;
}
_curFrame = frame;
@@ -3022,6 +3061,9 @@ void Movement::setFrame(int frame, float &x, float &y, bool mirror) {
// CMovement::Start (EFC96): the center is kept against the change of size, mirrored x is negated
void Movement::start(float &x, float &y, float oldWidth, float oldHeight, float scaleX, float scaleY, float rotation, bool mirror, bool reverse) {
+ _slideX = 0.0f;
+ _slideY = 0.0f;
+
float stepX;
float stepY;
if (reverse) {
@@ -3049,6 +3091,13 @@ void Movement::start(float &x, float &y, float oldWidth, float oldHeight, float
y = ((oldCenterY + (dx * sn)) + (dy * c)) - halfHeight;
}
+// CMovement::Slide (F00B2): the position of Start (its SetNext writes one that is thrown away)
+void Movement::slide(float &x, float &y, float oldWidth, float oldHeight, float scaleX, float scaleY, float rotation, bool mirror, float stepX, float stepY) {
+ start(x, y, oldWidth, oldHeight, scaleX, scaleY, rotation, mirror, false);
+ _slideX = mirror ? -stepX : stepX;
+ _slideY = stepY;
+}
+
void Movement::gotoFirstFrame() {
while (_curFrame)
gotoPrevFrame();
@@ -3090,6 +3139,8 @@ void Movement::stop(Common::Point &topLeft, float width, float height, float sca
_cycled = false;
_reverse = false;
_timerRuns = true;
+ _slideX = 0.0f;
+ _slideY = 0.0f;
const float halfWidth = width * 0.5f;
const float halfHeight = height * 0.5f;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 502d7697fb7..8707ffdf1a8 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -129,6 +129,9 @@ class Movement : public GameObject {
bool _reverse = false;
/** CMovement +63: false holds the frame, the phase timer stands (SetCurFrame) */
bool _timerRuns = true;
+ /** CMovement +80, +84 (>= 201509): the slide, for the phases with the flag 1 (x) or 2 (y) */
+ float _slideX = 0.0f;
+ float _slideY = 0.0f;
int _prevStepX;
int _prevStepY;
int _nextStepX;
@@ -164,6 +167,8 @@ class Movement : public GameObject {
Common::Point getMovementSize(int idx, int dynidx);
// 2015 (CMovement::GetMovementSize): displacement of the sprite center, used to plan walks
Common::Point getCenterMovementSize(int idx, int dynidx);
+ /** CMovement::GetMovementSize (EFEC2) in floats */
+ Vector2 getCenterMovementSizeF(int idx, int dynidx);
void getCenterDisplacement(float &dx, float &dy) const;
/** CMovement::GetStepToFrame (EF05E) */
void getStepToFrame(int frame, float &dx, float &dy) const;
@@ -186,6 +191,8 @@ class Movement : public GameObject {
void setFrame(int frame, float &x, float &y, bool mirror);
/** CMovement::Start (EFC96): moves the top left by the previous step (reverse: the next, back) */
void start(float &x, float &y, float oldWidth, float oldHeight, float scaleX, float scaleY, float rotation, bool mirror, bool reverse);
+ /** CMovement::Slide (F00B2): Start with the slide vector */
+ void slide(float &x, float &y, float oldWidth, float oldHeight, float scaleX, float scaleY, float rotation, bool mirror, float stepX, float stepY);
void gotoFirstFrame();
void setLast();
/** CMovement::Stop (EEE70); width and height: the size of the end statics */
@@ -249,6 +256,7 @@ public:
Common::Point topLeft() const;
/** CVisibleObject::SetPos (EEACC) for 201509: the stored top left */
void setTopLeft(Common::Point topLeft) override;
+ void setTopLeftF(float x, float y) override;
bool load(MfcArchive &file) override;
@@ -256,7 +264,6 @@ public:
void setOldAniPos(int x, int y, int z);
void setPosition(Common::Point pos) override;
Statics *getStatic(int id);
- void setTopLeftF(float x, float y) override;
Statics *getStaticsByName(const Common::String &name);
Movement *getMovement(int id);
int getMovementIdById(int itemId) const;
@@ -311,9 +318,11 @@ public:
bool startMovement(int movementId, int messageQueueId, int dynPhaseIdx, bool mirror = false, bool cycled = false, bool reverse = false, int startFrame = -1,
bool silent = false);
void startMovementWithoutPhases(Movement *movement, bool mirror, bool reverse, int startFrame);
- bool startMovementTimed(Movement *mov, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame, bool silent);
+ bool startMovementTimed(Movement *mov, int messageQueueId, int dynPhaseIdx, bool mirror, bool cycled, bool reverse, int startFrame, bool silent, const Vector2 *slide = nullptr);
bool startAnimEx(int movid, int parId, int flag1, int flag2);
void startSliding(int movementId, int messageQueueId, int x, int y, const PointList &points, int someDynamicPhaseIndex, bool mirror, bool cycled = false);
+ /** CAniObject::StartSliding (F0E3C), >= 201509: one slide vector for the whole movement */
+ bool startSliding(int movementId, bool cycled, int stopFrame, bool mirror, float stepX, float stepY);
void hide();
void show1(int x, int y, int movementId, int mqId);
@@ -344,6 +353,8 @@ public:
/** CAniObject::IsSlidingEnd (F0EEE); the end point test for cycled movements is not ported */
bool isSlidingEnd(float endX, float endY) const;
Common::Point *calcNextStep(Common::Point *point);
+ /** mqGetMovementSizeLeft (1A84A8): what the running movement still moves the center */
+ Vector2 getMovementSizeLeft();
MessageQueue *moveToStatic(int msgNum);
void setStatic(int objId);
Commit: 0ecf43697cc56041269fb60d241ae19bb81b6783
https://github.com/scummvm/scummvm/commit/0ecf43697cc56041269fb60d241ae19bb81b6783
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:21+01:00
Commit Message:
NGI: Scene 29 uses the float center, scene 19 gets the controller of scene 18
Changed paths:
engines/ngi/fullpipe/mobile/sc18controller.cpp
engines/ngi/fullpipe/mobile/sc29controller.cpp
diff --git a/engines/ngi/fullpipe/mobile/sc18controller.cpp b/engines/ngi/fullpipe/mobile/sc18controller.cpp
index a76167dae85..e3729bb78dd 100644
--- a/engines/ngi/fullpipe/mobile/sc18controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc18controller.cpp
@@ -593,7 +593,8 @@ void Sc18Controller::initSwitch1819() {
const int sceneId = _scene->_sceneId;
if (sceneId == SC_19 || sceneId == SC_18) {
if (_keepCells) {
- Sc18Controller *other = static_cast<Sc18Controller *>(g_ngi->findScene(sceneId == SC_19 ? SC_18 : SC_19)->_controller.get());
+ // the original has made every controller at the start
+ Sc18Controller *other = static_cast<Sc18Controller *>(&sceneController(*g_ngi->findScene(sceneId == SC_19 ? SC_18 : SC_19)));
_cells = other->_cells;
other->_cells.clear();
_state = other->_state;
diff --git a/engines/ngi/fullpipe/mobile/sc29controller.cpp b/engines/ngi/fullpipe/mobile/sc29controller.cpp
index 25d91d5b4e8..f0e08973814 100644
--- a/engines/ngi/fullpipe/mobile/sc29controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc29controller.cpp
@@ -98,7 +98,7 @@ bool Sc29Controller::doJump() {
} else {
result = false;
}
- const Common::Point center = man->getCenter();
+ const Vector2 center = man->getCenterF();
_manX = center.x;
_manY = center.y;
return result;
@@ -119,7 +119,7 @@ bool Sc29Controller::doBend() {
} else {
result = false;
}
- const Common::Point center = man->getCenter();
+ const Vector2 center = man->getCenterF();
_manX = center.x;
_manY = center.y;
return result;
@@ -128,7 +128,7 @@ bool Sc29Controller::doBend() {
// CSc29Controller::UpdateManRideback (18CB3C): the hero runs back to the left
void Sc29Controller::updateManRideback(uint32 elapsed) {
_manX = _manX - (float)elapsed * _manSpeed;
- hero()->setCenter(Common::Point((int)_manX, (int)_manY));
+ hero()->setCenterF(_manX, _manY);
}
// CSc29Controller::TryShoot (18CB74)
@@ -170,7 +170,7 @@ void Sc29Controller::hitAssRed() {
bool Sc29Controller::hitsManRed(AniObject *ani, int maxX) {
if (!_arcadeIsOn || _manIsHit)
return false;
- const float x = (float)ani->getCenter().x;
+ const float x = ani->getCenterF().x;
if ((x >= _manX + 42.0f || x <= _manX + 8.0f) && (x < _manX + 8.0f || (float)maxX > (_manX + 25.0f) + _manSpeed))
return false;
AniObject *man = hero();
@@ -185,7 +185,7 @@ bool Sc29Controller::hitsManRed(AniObject *ani, int maxX) {
bool Sc29Controller::hitsManGreen(AniObject *ani, int maxX) {
if (!_arcadeIsOn || _manIsHit)
return false;
- const float x = (float)ani->getCenter().x;
+ const float x = ani->getCenterF().x;
if ((x >= _manX + 40.0f || x <= _manX + 10.0f) && (x < _manX + 40.0f || (float)maxX > (_manX + 25.0f) + _manSpeed))
return false;
AniObject *man = hero();
@@ -292,15 +292,15 @@ void Sc29Controller::updateManRideRight() {
if (_manX <= 1436.0f) {
_shootDelay = (int)(_shootDelayMin + ((_shootDelayMax - _shootDelayMin) * (1310.0f - _manX)) / 959.0f);
if (!_manIsHit && !man->getMessageQueue()) {
- const Common::Point center = man->getCenter();
- man->setCenter(Common::Point(center.x, 427));
+ const Vector2 center = man->getCenterF();
+ man->setCenterF(center.x, 427.0f);
man->startMovement(MV_MAN29_RUN, 0, -1);
}
} else {
doJumpfromR();
}
}
- const Common::Point center = man->getCenter();
+ const Vector2 center = man->getCenterF();
_manX = center.x;
_manY = center.y;
}
@@ -345,7 +345,7 @@ void Sc29Controller::countLoopBeardeds(uint32 elapsed) {
}
AniObject *ani = _bearders[i]._ani;
- const Common::Point center = ani->getCenter();
+ const Vector2 center = ani->getCenterF();
float x = center.x;
const float y = center.y;
if (!ani->_movement && ani->_statics->_staticsId == ST_BRDCMN_RIGHT) {
@@ -375,7 +375,7 @@ void Sc29Controller::countLoopBeardeds(uint32 elapsed) {
_bearders[i]._counter = 0;
}
}
- _bearders[i]._ani->setCenter(Common::Point((int)x, (int)y));
+ _bearders[i]._ani->setCenterF(x, y);
}
}
@@ -431,23 +431,23 @@ void Sc29Controller::tryEscapeShooters() {
void Sc29Controller::updateManPosition(uint32 elapsed) {
if (_arcadeIsOn) {
_manX = _manX + (float)elapsed * _manSpeed;
- hero()->setCenter(Common::Point((int)_manX, (int)_manY));
+ hero()->setCenterF(_manX, _manY);
if (_manX > 1310.0f)
tryEscapeShooters();
calcScore();
} else if (_manIsRiding) {
_manX = _manX - (float)elapsed * 0.092f;
- hero()->setCenter(Common::Point((int)_manX, (int)_manY));
+ hero()->setCenterF(_manX, _manY);
}
}
// CSc29Controller::OnClickPorter (18DC78): MSG_SC29_PORTER_CLICK comes back here
void Sc29Controller::onClickPorter() {
const float heroX = _manX;
- const Common::Point porterCenter = _porter->getCenter();
+ const Vector2 porterCenter = _porter->getCenterF();
AniObject *man = hero();
if (heroX <= (float)porterCenter.x) {
- Common::Point center = man->getCenter();
+ Vector2 center = man->getCenterF();
_manX = center.x;
_manY = center.y;
if (fabsf(351.0f - _manX) <= 3.0f && fabsf(443.0f - _manY) <= 3.0f) {
@@ -462,7 +462,7 @@ void Sc29Controller::onClickPorter() {
queue->addCommandToEnd(messageCommand("MSG_SC29_PORTER_CLICK"));
}
} else {
- Common::Point center = man->getCenter();
+ Vector2 center = man->getCenterF();
_manX = center.x;
_manY = center.y;
if (fabsf(1582.0f - _manX) <= 3.0f && fabsf(445.0f - _manY) <= 3.0f) {
@@ -485,7 +485,7 @@ void Sc29Controller::doHitMan() {
debugC(1, kDebugInfo, "INFO t %u SC29 the hero is hit at %d", g_system->getMillis(), (int)_manX);
_manIsHit = true;
man->moveToStaticChain(ST_MAN29_RUNR);
- man->setCenter(Common::Point((int)_manX, (int)_manY));
+ man->setCenterF(_manX, _manY);
MakeQueueStruct make;
make.ani = man;
@@ -591,7 +591,7 @@ void Sc29Controller::skipArcade() {
void Sc29Controller::updateShellFlight(uint32 elapsed) {
for (int i = 0; i < (int)_flyingGreenBalls.size(); i++) {
AniObject *ball = _flyingGreenBalls[i];
- const Common::Point center = ball->getCenter();
+ const Vector2 center = ball->getCenterF();
float x = (float)center.x - (float)elapsed * _greenSpeed;
const float y = center.y;
if (x < 186.0f) {
@@ -614,11 +614,11 @@ void Sc29Controller::updateShellFlight(uint32 elapsed) {
// CFlurryEventManager (total_moves, first_move, failcount_ANI_PORTER) is not ported
continue;
}
- ball->setCenter(Common::Point((int)x, (int)y));
+ ball->setCenterF(x, y);
}
for (int j = 0; j < (int)_flyingRedBalls.size(); j++) {
AniObject *ball = _flyingRedBalls[j];
- const Common::Point center = ball->getCenter();
+ const Vector2 center = ball->getCenterF();
float x = (float)center.x - (float)elapsed * _redSpeed;
const float y = center.y;
if (x < 147.0f) {
@@ -641,14 +641,14 @@ void Sc29Controller::updateShellFlight(uint32 elapsed) {
--j;
continue;
}
- ball->setCenter(Common::Point((int)x, (int)y));
+ ball->setCenterF(x, y);
}
}
// CSc29Controller::DoShootGreen (18EB64): the first free green shell flies from the first shooter
void Sc29Controller::doShootGreen() {
if (!_greenBalls.empty()) {
- const Common::Point center = _shooter1->getCenter();
+ const Vector2 center = _shooter1->getCenterF();
const float x = center.x - 113.0f;
const float y = center.y - 48.0f;
debugC(1, kDebugInfo, "INFO t %u SC29 green shell flies, hits in %d ms", g_system->getMillis(), (int)((x - _manX - 25.0f) / (_greenSpeed + _manSpeed)));
@@ -656,7 +656,7 @@ void Sc29Controller::doShootGreen() {
_greenBalls.pop_front();
ball->setStatic(ST_SHG_NORM, false);
ball->_flags |= 4;
- ball->setCenter(Common::Point((int)x, (int)y));
+ ball->setCenterF(x, y);
_flyingGreenBalls.push_back(ball);
}
}
@@ -664,7 +664,7 @@ void Sc29Controller::doShootGreen() {
// CSc29Controller::DoShootRed (18EBF0): the first free red shell flies from the second shooter
void Sc29Controller::doShootRed() {
if (!_redBalls.empty()) {
- const Common::Point center = _shooter2->getCenter();
+ const Vector2 center = _shooter2->getCenterF();
const float x = center.x - 101.0f;
const float y = center.y - 14.0f;
debugC(1, kDebugInfo, "INFO t %u SC29 red shell flies, hits in %d ms", g_system->getMillis(), (int)((x - _manX - 25.0f) / (_redSpeed + _manSpeed)));
@@ -672,7 +672,7 @@ void Sc29Controller::doShootRed() {
_redBalls.pop_front();
ball->setStatic(ST_SHR_NORM, false);
ball->_flags |= 4;
- ball->setCenter(Common::Point((int)x, (int)y));
+ ball->setCenterF(x, y);
_flyingRedBalls.push_back(ball);
}
}
@@ -809,7 +809,7 @@ void Sc29Controller::onUpdate(uint32 elapsed) {
// with a dialog over the scene and the hit queue running, the hero gives the position
if (g_ngi->_sceneStack.size() > 1) {
if (_hitQueue && isQueueRunning(_scene, _hitQueue)) {
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
_manX = center.x;
_manY = center.y;
}
@@ -958,7 +958,7 @@ void Sc29Controller::updateScroll() {
FPController::updateScroll();
}
}
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
_manX = center.x;
_manY = center.y;
}
Commit: 25e67199c125e85d8baaee183d8207bc72a564dd
https://github.com/scummvm/scummvm/commit/25e67199c125e85d8baaee183d8207bc72a564dd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: Float stage 4 leftovers: the walk starts at the center, Stop and Show keep the fraction
Changed paths:
engines/ngi/messagehandlers.cpp
engines/ngi/messages.cpp
engines/ngi/messages.h
engines/ngi/motion.cpp
engines/ngi/motion.h
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/messagehandlers.cpp b/engines/ngi/messagehandlers.cpp
index 3e42691a8e5..1a186c9017a 100644
--- a/engines/ngi/messagehandlers.cpp
+++ b/engines/ngi/messagehandlers.cpp
@@ -760,17 +760,24 @@ int global_messageHandler4(Command *cmd) {
if (!ani)
break;
- if (cmd->_z >= 0)
- ani->_z = cmd->_z;
-
if (g_ngi->_gameVersion >= 201509) {
+ // CMessageQueue::ExecuteCmdShow (10CE00): x, y and z are floats
+ const float z = cmd->getPositionParam("z", cmd->_z);
+ if (z >= 0)
+ ani->_z = z;
+
const bool mirror = cmd->_auxParam < 0 ? (ani->_flags & 8) != 0 : cmd->_auxParam != 0;
- const int x = cmd->_x == -1 ? ani->pivotX() : cmd->_x;
- const int y = cmd->_y == -1 ? ani->pivotY() : cmd->_y;
+ const float cx = cmd->getPositionParam("x", cmd->_x);
+ const float cy = cmd->getPositionParam("y", cmd->_y);
+ const float x = cx == -1.0f ? ani->pivotXF() : cx;
+ const float y = cy == -1.0f ? ani->pivotYF() : cy;
ani->show1(x, y, cmd->_messageNum, (cmd->_excFlags & 1) ? 0 : cmd->_parId);
ani->_flags = (ani->_flags & ~8) | (mirror ? 8 : 0);
- ani->setPos(x, y);
+ ani->setPosF(x, y);
} else {
+ if (cmd->_z >= 0)
+ ani->_z = cmd->_z;
+
ani->show1(cmd->_x, cmd->_y, cmd->_messageNum, cmd->_parId);
}
break;
diff --git a/engines/ngi/messages.cpp b/engines/ngi/messages.cpp
index 8dd4f5eaaa6..433d0750baf 100644
--- a/engines/ngi/messages.cpp
+++ b/engines/ngi/messages.cpp
@@ -169,6 +169,10 @@ void Command::setParamFloat(const char *name, float value) {
_z = (int)value;
}
+float Command::getPositionParam(const char *name, int field) const {
+ return getParamFloat(name, static_cast<float>(field));
+}
+
int Command::getParamInt(const char *name, int defaultValue) const {
return _args.contains(name) ? atoi(_args.getVal(name).c_str()) : defaultValue;
}
diff --git a/engines/ngi/messages.h b/engines/ngi/messages.h
index 854a313b291..41428ce3733 100644
--- a/engines/ngi/messages.h
+++ b/engines/ngi/messages.h
@@ -146,6 +146,8 @@ class Command : public Message {
float getParamFloat(const char *name, float defaultValue) const;
/** CCommand::SetParamFloat (10F494): sets the attribute and keeps the x, y, z fields in step */
void setParamFloat(const char *name, float value);
+ /** x, y or z as a float of the parameters (as the original keeps them), else the field */
+ float getPositionParam(const char *name, int field) const;
/** CCommand::GetParamInt (10CBF0): the attribute, the default when it has none */
int getParamInt(const char *name, int defaultValue) const;
/** CCommand::SetParamInt (10F384): sets the attribute and the matching fields */
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index e833e30f6a0..f166739d60d 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -2376,15 +2376,15 @@ static MessageQueue *newWalkQueue() {
// CMctlGraph::ResetObjMove (1AA3C2): after a failed MakeQueue the stopped movement restarts
// at its frame and center; nothing when no movement ran (id 0)
-void MctlGraph::resetObjMove(AniObject *ani, int movementId, Common::Point center, int frame) {
+void MctlGraph::resetObjMove(AniObject *ani, int movementId, Vector2 center, int frame) {
if (movementId == 0)
return;
- debugC(1, kDebugInfo, "INFO t %u WALK reset: the movement %d of %d goes back to frame %d at the center %d,%d", g_system->getMillis(), movementId, ani->_id, frame, center.x, center.y);
+ debugC(1, kDebugInfo, "INFO t %u WALK reset: the movement %d of %d goes back to frame %d at the center %g,%g", g_system->getMillis(), movementId, ani->_id, frame, center.x, center.y);
ani->startMovement(movementId, 0, -1, false, false, false, -1);
ani->setCurFrame(frame, true, false);
- ani->setCenter(center);
+ ani->setCenterF(center.x, center.y);
}
MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror) {
@@ -2454,16 +2454,18 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
// CMctlGraph::MakeQueue keeps id (+168), center and frame for ResetObjMove
int resetMovementId = 0;
int resetFrame = 0;
- Common::Point resetCenter(-1, -1);
+ Vector2 resetCenter;
+ resetCenter.x = -1.0f;
+ resetCenter.y = -1.0f;
if (obj->_movement && revised) {
resetMovementId = obj->_movement->_id; // +168 is the running movement while one runs
- resetCenter = obj->getCenter();
+ resetCenter = obj->getCenterF();
resetFrame = obj->getCurFrame();
// CAniObject::StopMovementToPrev, then SetCenter(x before, y now)
obj->stopMovementToPrev(true);
- obj->setCenter(Common::Point(resetCenter.x, obj->getCenter().y));
+ obj->setCenterF(resetCenter.x, obj->getCenterF().y);
} else if (obj->_movement) {
int newx, newy;
@@ -2489,8 +2491,17 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
obj->setPos(newx, newy);
}
- // CMctlGraph::MakeQueue: already there within one pixel (of the sprite center)
- const bool near = revised ? (abs(obj->pivotX() - xpos) <= 1 && abs(obj->pivotY() - ypos) <= 1) : (obj->pivotX() == xpos && obj->pivotY() == ypos);
+ // CMctlGraph::MakeQueue: the walk starts at the center of the texture, cut to whole numbers
+ int startX = obj->pivotX();
+ int startY = obj->pivotY();
+ if (revised) {
+ const Vector2 center = obj->getCenterF();
+ startX = static_cast<int>(center.x);
+ startY = static_cast<int>(center.y);
+ }
+
+ // CMctlGraph::MakeQueue: already there within one pixel
+ const bool near = revised ? (abs(startX - xpos) <= 1 && abs(startY - ypos) <= 1) : (startX == xpos && startY == ypos);
if (near) {
MessageQueue *mq = newWalkQueue();
@@ -2538,16 +2549,16 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
return mq;
}
- linkInfoSource.node = getHitNode(obj->pivotX(), obj->pivotY(), 0);
+ linkInfoSource.node = getHitNode(startX, startY, 0);
if (!linkInfoSource.node) {
- linkInfoSource.link = getHitLink(obj->pivotX(), obj->pivotY(), idxsub, 0);
+ linkInfoSource.link = getHitLink(startX, startY, idxsub, 0);
if (!linkInfoSource.link) {
- linkInfoSource.link = getNearestLink(obj->pivotX(), obj->pivotY());
+ linkInfoSource.link = getNearestLink(startX, startY);
if (!linkInfoSource.link) {
- debugC(1, kDebugInfo, "INFO t %u WALK refused: no link near the start %d,%d", g_system->getMillis(), obj->pivotX(), obj->pivotY());
+ debugC(1, kDebugInfo, "INFO t %u WALK refused: no link near the start %d,%d", g_system->getMillis(), startX, startY);
if (revised)
resetObjMove(obj, resetMovementId, resetCenter, resetFrame);
else
@@ -2589,11 +2600,11 @@ MessageQueue *MctlGraph::makeQueue(AniObject *obj, int xpos, int ypos, int fuzzy
mctlMQ1.clear();
mctlMQ1.sourceDir = idxsub;
- mctlMQ1.sourcePos.x = obj->pivotX();
- mctlMQ1.sourcePos.y = obj->pivotY();
+ mctlMQ1.sourcePos.x = startX;
+ mctlMQ1.sourcePos.y = startY;
- int dx1 = obj->pivotX();
- int dy1 = obj->pivotY();
+ int dx1 = startX;
+ int dy1 = startY;
int dx2, dy2;
if (linkInfoSource.node)
diff --git a/engines/ngi/motion.h b/engines/ngi/motion.h
index e1af17c6585..858f4c600e5 100644
--- a/engines/ngi/motion.h
+++ b/engines/ngi/motion.h
@@ -406,7 +406,7 @@ public:
using MovGraph::startMove;
MessageQueue *startMove(AniObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror = false) override;
MessageQueue *makeQueue(AniObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId, bool mirror = false) override;
- void resetObjMove(AniObject *ani, int movementId, Common::Point center, int frame);
+ void resetObjMove(AniObject *ani, int movementId, Vector2 center, int frame);
int getObjIndex(int objectId);
int getDirByStatics(int index, int staticsId, bool mirror = false);
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 4811970fd0b..c86c8b24a8d 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -244,6 +244,18 @@ int AniObject::pivotY() const {
return static_cast<int>(_y);
}
+float AniObject::pivotXF() const {
+ if (g_ngi->_gameVersion >= 201509)
+ return _x + pivotAnchor().x;
+ return _x;
+}
+
+float AniObject::pivotYF() const {
+ if (g_ngi->_gameVersion >= 201509)
+ return _y + pivotAnchor().y;
+ return _y;
+}
+
void AniObject::setPivotX(int x) {
if (g_ngi->_gameVersion >= 201509)
_x = x - pivotAnchor().x;
@@ -295,17 +307,27 @@ void AniObject::setPos(int x, int y) {
_movement->setPos(x, y);
}
+void AniObject::setPosF(float x, float y) {
+ if (g_ngi->_gameVersion >= 201509) {
+ const Common::Point anchor = pivotAnchor();
+ storeTopLeft(x - anchor.x, y - anchor.y);
+ return;
+ }
+
+ setPos(static_cast<int>(x), static_cast<int>(y));
+}
+
// COldAniObject::SetPos (161924): a standing object is set into its statics again
-void AniObject::setOldAniPos(int x, int y, int z) {
+void AniObject::setOldAniPos(float x, float y, float z) {
const Common::Point topLeft = getPosition();
_z = z;
- if (topLeft.x == x && topLeft.y == y)
+ if (g_ngi->_gameVersion >= 201509 ? (_x == x && _y == y) : (topLeft.x == x && topLeft.y == y))
return;
if (g_ngi->_gameVersion < 201509) {
if (_movement)
- setTopLeft(Common::Point(x, y));
+ setTopLeft(Common::Point(static_cast<int>(x), static_cast<int>(y)));
else
- setPos(x, y);
+ setPos(static_cast<int>(x), static_cast<int>(y));
return;
}
@@ -1351,18 +1373,19 @@ void AniObject::stopMovementAndroid(bool keepSounds) {
const bool endMirror = (reverse ? mov->_mirrorPrev : mov->_mirrorNext) != mirror;
// CMovement::Stop with the size of the end statics (CVisibleObject::GetSize)
- Common::Point topLeft = getPosition();
+ float x = _x;
+ float y = _y;
const Dims endSize = end->getDimensions();
- mov->stop(topLeft, endSize.x * _scaleX * (_windowRight - _windowLeft), endSize.y * _scaleY * (_windowBottom - _windowTop), _scaleX, _scaleY, _rotation, mirror);
+ mov->stop(x, y, endSize.x * _scaleX * (_windowRight - _windowLeft), endSize.y * _scaleY * (_windowBottom - _windowTop), _scaleX, _scaleY, _rotation, mirror);
const int oid = mov->_id;
_statics = end;
_movement = nullptr;
_targetFrame = -1;
_flags = (_flags & ~8) | (endMirror ? 8 : 0);
- setTopLeft(topLeft);
+ setTopLeftF(x, y);
- debugC(1, kDebugAnimation, "movement stop: t %u ani %d copy %d movement %d pos %g,%g topleft %d,%d flags %x statics %d", g_system->getMillis(), _id, _copyId, oid, _x, _y, topLeft.x, topLeft.y,
+ debugC(1, kDebugAnimation, "movement stop: t %u ani %d copy %d movement %d pos %g,%g topleft %g,%g flags %x statics %d", g_system->getMillis(), _id, _copyId, oid, _x, _y, x, y,
_flags, _statics->_staticsId);
if (keepSounds)
@@ -1748,8 +1771,8 @@ void AniObject::hide() {
}
}
-void AniObject::show1(int x, int y, int movId, int mqId) {
- debugC(6, kDebugAnimation, "AniObject::show1(%d, %d, %d, %d)", x, y, movId, mqId);
+void AniObject::show1(float x, float y, int movId, int mqId) {
+ debugC(6, kDebugAnimation, "AniObject::show1(%g, %g, %d, %d)", x, y, movId, mqId);
// CMessageQueue::ExecuteCmdShow (10CE00): the object is shown whatever its queue does
if (_messageQueueId && g_ngi->_gameVersion < 201509)
@@ -1758,7 +1781,7 @@ void AniObject::show1(int x, int y, int movId, int mqId) {
if (movId == -1) {
_flags |= 4u;
if (x != -1 && y != -1) {
- setPos(x, y);
+ setPosF(x, y);
}
return;
@@ -1769,7 +1792,7 @@ void AniObject::show1(int x, int y, int movId, int mqId) {
return;
if (x != -1 && y != -1) {
- setPos(x, y);
+ setPosF(x, y);
}
_statics = mov->_prevStatic;
@@ -1777,8 +1800,8 @@ void AniObject::show1(int x, int y, int movId, int mqId) {
// the Android SetStatic reads Statics::_x/_y as offsets: ExecuteCmdShow does not write them
if (g_ngi->_gameVersion < 201509) {
const Common::Point point = mov->_prevStatic->getSomeXY();
- _statics->_x = x - point.x;
- _statics->_y = y - point.y;
+ _statics->_x = static_cast<int>(x) - point.x;
+ _statics->_y = static_cast<int>(y) - point.y;
}
_statics->_countdown = _statics->_delay;
@@ -1794,7 +1817,7 @@ void AniObject::show1(int x, int y, int movId, int mqId) {
if (_flags & 1)
_flags ^= 1;
- setPos(x, y);
+ setPosF(x, y);
// ExecuteCmdShow does not tie the object to a queue
if (g_ngi->_gameVersion < 201509)
@@ -1986,7 +2009,8 @@ void AniObject::startMovementWithoutPhases(Movement *movement, bool mirror, bool
dx = -dx;
const float c = cosf(_rotation);
const float sn = sinf(_rotation);
- const Common::Point topLeft = getPosition();
+ const float x = _x;
+ const float y = _y;
// CAniObject::StopMovement: the end statics and the facing
_movement = nullptr;
@@ -1996,7 +2020,7 @@ void AniObject::startMovementWithoutPhases(Movement *movement, bool mirror, bool
if (_flags & 8)
endMirror = !endMirror;
_flags = (_flags & ~8) | (endMirror ? 8 : 0);
- setTopLeft(Common::Point(topLeft.x + (int)(dx * c - dy * sn), topLeft.y + (int)(dx * sn + dy * c)));
+ setTopLeftF(x + (dx * c - dy * sn), y + (dx * sn + dy * c));
}
// CAniObject::StartMovement (F0D46) from 201509, then CMovement::Start (EFC96)
@@ -3121,7 +3145,7 @@ void Movement::setLast() {
// CMovement::Stop (EEE70): the top left moves by the next step (reverse: back by the previous one)
// and the object keeps its center against the change of size to the end statics
-void Movement::stop(Common::Point &topLeft, float width, float height, float scaleX, float scaleY, float rotation, bool mirror) {
+void Movement::stop(float &x, float &y, float width, float height, float scaleX, float scaleY, float rotation, bool mirror) {
float stepX;
float stepY;
if (_reverse) {
@@ -3133,8 +3157,8 @@ void Movement::stop(Common::Point &topLeft, float width, float height, float sca
}
const Dims texture = _curPhase->getDimensions();
- const float oldCenterX = topLeft.x + texture.x * 0.5f * scaleX;
- const float oldCenterY = topLeft.y + texture.y * 0.5f * scaleX;
+ const float oldCenterX = x + texture.x * 0.5f * scaleX;
+ const float oldCenterY = y + texture.y * 0.5f * scaleX;
_cycled = false;
_reverse = false;
@@ -3144,15 +3168,15 @@ void Movement::stop(Common::Point &topLeft, float width, float height, float sca
const float halfWidth = width * 0.5f;
const float halfHeight = height * 0.5f;
- float dx = (topLeft.x + stepX + halfWidth * scaleX) - oldCenterX;
- const float dy = (topLeft.y + stepY + halfHeight * scaleX) - oldCenterY;
+ float dx = (x + stepX + halfWidth * scaleX) - oldCenterX;
+ const float dy = (y + stepY + halfHeight * scaleX) - oldCenterY;
if (mirror)
dx = -dx;
const float c = cosf(rotation);
const float sn = sinf(rotation);
- topLeft.x = static_cast<int>(roundf((oldCenterX + (dx * c - dy * sn)) - halfWidth));
- topLeft.y = static_cast<int>(roundf((oldCenterY + (dx * sn + dy * c)) - halfHeight));
+ x = (oldCenterX + (dx * c - dy * sn)) - halfWidth;
+ y = (oldCenterY + (dx * sn + dy * c)) - halfHeight;
}
Common::Point Movement::getCenter() const {
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 8707ffdf1a8..b2e7ac7cf66 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -196,7 +196,7 @@ class Movement : public GameObject {
void gotoFirstFrame();
void setLast();
/** CMovement::Stop (EEE70); width and height: the size of the end statics */
- void stop(Common::Point &topLeft, float width, float height, float scaleX, float scaleY, float rotation, bool mirror);
+ void stop(float &x, float &y, float width, float height, float scaleX, float scaleY, float rotation, bool mirror);
/** CMovement::Load and Unload (Android): returns the size loaded / freed (a quarter for "dxt") */
uint load();
@@ -248,6 +248,9 @@ public:
/** the Windows view of the position, the pivot (_x/_y hold the top left from 201509) */
int pivotX() const override;
int pivotY() const override;
+ /** the pivot with the fraction of the stored top left */
+ float pivotXF() const;
+ float pivotYF() const;
void setPivotX(int x);
void setPivotY(int y);
/** the pivot minus the top left: someXY of the current phase, mirrored with the flag 8 */
@@ -261,7 +264,9 @@ public:
bool load(MfcArchive &file) override;
void setPos(int x, int y) override;
- void setOldAniPos(int x, int y, int z);
+ /** setPos with the fraction kept from 201509 */
+ void setPosF(float x, float y);
+ void setOldAniPos(float x, float y, float z);
void setPosition(Common::Point pos) override;
Statics *getStatic(int id);
Statics *getStaticsByName(const Common::String &name);
@@ -325,7 +330,7 @@ public:
bool startSliding(int movementId, bool cycled, int stopFrame, bool mirror, float stepX, float stepY);
void hide();
- void show1(int x, int y, int movementId, int mqId);
+ void show1(float x, float y, int movementId, int mqId);
void show2(int x, int y, int movementId, int mqId);
void playIdle();
/** CAniObject::Update (F2D7C) */
Commit: 3d371ae12aeadb54d3cc8c147067ad12eb4053ec
https://github.com/scummvm/scummvm/commit/3d371ae12aeadb54d3cc8c147067ad12eb4053ec
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: CFPController::TestScroll and TouchScroll recalculate the cursor position after the camera moved
Changed paths:
engines/ngi/fullpipe/mobile/fpcontroller.cpp
diff --git a/engines/ngi/fullpipe/mobile/fpcontroller.cpp b/engines/ngi/fullpipe/mobile/fpcontroller.cpp
index 557beffbccf..a10f32cbd9e 100644
--- a/engines/ngi/fullpipe/mobile/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/fpcontroller.cpp
@@ -515,6 +515,7 @@ bool FPController::touchScroll() {
}
_targetX = 0;
_targetY = 0;
+ g_ngi->_inputController->recalcCursorPos();
return true;
}
@@ -599,6 +600,8 @@ void FPController::testScroll() {
_scene->_x += static_cast<int>(dx);
_scene->_y += static_cast<int>(dy);
+ if (dx != 0.0f || dy != 0.0f)
+ g_ngi->_inputController->recalcCursorPos();
}
// CFPController::OnUpdate, the camera part: every 10 ms UpdateScroll, TestScroll unless touching
Commit: 5cd3751e8c24a7d58d26da1feaec683159447acb
https://github.com/scummvm/scummvm/commit/5cd3751e8c24a7d58d26da1feaec683159447acb
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: Float stage 5: scale and rotation in CMovement::SetFrame and CAniObject::GetFullSize (D50)
Changed paths:
engines/ngi/debugger/testmode.cpp
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/debugger/testmode.cpp b/engines/ngi/debugger/testmode.cpp
index 09c92af66bb..dd96f004ec6 100644
--- a/engines/ngi/debugger/testmode.cpp
+++ b/engines/ngi/debugger/testmode.cpp
@@ -67,7 +67,15 @@ Common::String name(int id);
// movetest: movements, frames, stops, setStatic, setPosition of every animation, one MT line each
// (docs/float-model-plan.md, stage 3; compare two builds with scripts/ngi_movetest_compare.py)
+// movetest=scale:SX,SY,ROT: a scale and a rotation on every object, logs the float top left
+bool g_moveTestScaled = false;
+float g_moveTestScaleX = 1.0f;
+float g_moveTestScaleY = 1.0f;
+float g_moveTestRotation = 0.0f;
+
Common::String moveTestState(const AniObject *ani) {
+ if (g_moveTestScaled)
+ return Common::String::format("tlf %g,%g st %d m %d fl %02x", ani->topLeftXF(), ani->topLeftYF(), ani->_statics ? ani->_statics->_staticsId : 0, ani->_movement ? ani->_movement->_id : 0, ani->_flags);
const Common::Point topLeft = ani->getPosition();
const Common::Point center = ani->getCenter();
const Common::Rect bounds = ani->getBounds();
@@ -77,6 +85,10 @@ Common::String moveTestState(const AniObject *ani) {
}
Common::String moveTestFrame(const AniObject *ani) {
+ if (g_moveTestScaled) {
+ const Dims size = ani->_movement && ani->_movement->_curPhase ? ani->_movement->_curPhase->getDimensions() : Dims();
+ return Common::String::format("%d:%g,%g,%d,%d", ani->_movement ? ani->_movement->_curFrame : -1, ani->topLeftXF(), ani->topLeftYF(), size.x, size.y);
+ }
const Common::Point topLeft = ani->getPosition();
return Common::String::format("%d:%d,%d/%d,%d", ani->_movement ? ani->_movement->_curFrame : -1, topLeft.x, topLeft.y, ani->pivotX(), ani->pivotY());
}
@@ -88,6 +100,11 @@ void moveTestReset(AniObject *ani, Statics *statics, bool mirror) {
ani->_flags = (ani->_flags & ~(1 | 8 | 0x20)) | (mirror ? 8 : 0);
ani->_stepArray.clear();
ani->setTargetFrame(-1);
+ if (g_moveTestScaled) {
+ ani->_scaleX = g_moveTestScaleX;
+ ani->_scaleY = g_moveTestScaleY;
+ ani->_rotation = g_moveTestRotation;
+ }
ani->setPos(101, 203);
}
@@ -213,6 +230,17 @@ void runMoveTest(const Common::String &what) {
Scene *scene = g_ngi->_currentScene;
if (!scene)
return;
+ if (what.hasPrefix("scale:")) {
+ float scaleX = 1.0f;
+ float scaleY = 1.0f;
+ float rotation = 0.0f;
+ if (sscanf(what.c_str() + 6, "%f,%f,%f", &scaleX, &scaleY, &rotation) == 3) {
+ g_moveTestScaled = true;
+ g_moveTestScaleX = scaleX;
+ g_moveTestScaleY = scaleY;
+ g_moveTestRotation = rotation;
+ }
+ }
// movetest=1: the animations of the scene, once per id; movetest=hero: Dude only
Common::Array<AniObject *> objects;
if (what == "hero") {
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index c86c8b24a8d..6fce5e5ea83 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -957,6 +957,7 @@ void AniObject::preloadMovements(MovTable *mt) {
}
}
+// CAniObject::GetFullSize (EEB00): the texture size times the scale
Dims AniObject::getFullSize() const {
Texture *pic;
@@ -966,7 +967,8 @@ Dims AniObject::getFullSize() const {
pic = _statics;
if (pic) {
- return pic->getDimensions();
+ const Dims size = pic->getDimensions();
+ return Dims(static_cast<int>(size.x * _scaleX), static_cast<int>(size.y * _scaleY));
}
return Dims();
@@ -1342,9 +1344,7 @@ void AniObject::setMovementFrame(Movement *mov, int frame, bool silent) {
float x = _x;
float y = _y;
- mov->setFrame(frame, x, y, (_flags & 8) != 0);
- if ((_x != x || _y != y) && (_scaleX != 1.0f || _scaleY != 1.0f || _rotation != 0.0f))
- warning("STUB/untested: CMovement::SetFrame of ani %d with scale %f, %f, rotation %f: the step is not scaled or rotated", _id, _scaleX, _scaleY, _rotation);
+ mov->setFrame(frame, x, y, _scaleX, _scaleY, _rotation, (_flags & 8) != 0);
storeTopLeft(x, y);
if (!silent)
@@ -3045,11 +3045,12 @@ bool Movement::gotoPrevFrame(bool mirror) {
return true;
}
-// CMovement::SetFrame (EF8B8): the center is kept against the change of size, mirrored x is negated
-void Movement::setFrame(int frame, float &x, float &y, bool mirror) {
+// CMovement::SetFrame (EF8B8): the center is kept against the change of size, mirrored x negated;
+// offsets scaled, the step rotated (the original takes scaleX for both half sizes)
+void Movement::setFrame(int frame, float &x, float &y, float scaleX, float scaleY, float rotation, bool mirror) {
const Dims oldSize = _curPhase ? _curPhase->getDimensions() : Dims();
- const float oldCenterX = x + oldSize.x * 0.5f;
- const float oldCenterY = y + oldSize.y * 0.5f;
+ const float oldCenterX = x + oldSize.x * 0.5f * scaleX;
+ const float oldCenterY = y + oldSize.y * 0.5f * scaleX;
// the slide of the phase entered; going back it is negated with the offset of the phase left
float stepX = 0.0f;
@@ -3061,26 +3062,29 @@ void Movement::setFrame(int frame, float &x, float &y, bool mirror) {
stepY = _slideY;
if (_curFrame >= frame) {
if (_curFrame >= 0 && (uint)_curFrame < _framePosOffsets.size()) {
- stepX = -(stepX + _framePosOffsets[_curFrame].x);
- stepY = -(stepY + _framePosOffsets[_curFrame].y);
+ stepX = -(stepX + _framePosOffsets[_curFrame].x * scaleX);
+ stepY = -(stepY + scaleY * _framePosOffsets[_curFrame].y);
}
} else if ((uint)frame < _framePosOffsets.size()) {
- stepX += _framePosOffsets[frame].x;
- stepY += _framePosOffsets[frame].y;
+ stepX += _framePosOffsets[frame].x * scaleX;
+ stepY += scaleY * _framePosOffsets[frame].y;
}
_curFrame = frame;
updateCurrDynamicPhase();
const Dims newSize = _curPhase->getDimensions();
- const float halfWidth = newSize.x * 0.5f;
- const float halfHeight = newSize.y * 0.5f;
+ const float halfWidth = newSize.x * 0.5f * scaleX;
+ const float halfHeight = newSize.y * 0.5f * scaleX;
float dx = ((x + stepX) + halfWidth) - oldCenterX;
const float dy = ((y + stepY) + halfHeight) - oldCenterY;
if (mirror)
dx = -dx;
- x = (oldCenterX + dx) - halfWidth;
- y = (oldCenterY + dy) - halfHeight;
+
+ const float c = cosf(rotation);
+ const float sn = sinf(rotation);
+ x = ((oldCenterX + (dx * c)) - (dy * sn)) - halfWidth;
+ y = ((oldCenterY + (dx * sn)) + (dy * c)) - halfHeight;
}
// CMovement::Start (EFC96): the center is kept against the change of size, mirrored x is negated
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index b2e7ac7cf66..1fde7269585 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -188,7 +188,7 @@ class Movement : public GameObject {
bool setNext(void (*_callback1)(int, Common::Point *point, int, int), void (*callback2)(int *), bool mirror = false);
bool gotoPrevFrame(bool mirror = false);
/** CMovement::SetFrame (EF8B8): moves the top left x, y by the offset of the frame */
- void setFrame(int frame, float &x, float &y, bool mirror);
+ void setFrame(int frame, float &x, float &y, float scaleX, float scaleY, float rotation, bool mirror);
/** CMovement::Start (EFC96): moves the top left by the previous step (reverse: the next, back) */
void start(float &x, float &y, float oldWidth, float oldHeight, float scaleX, float scaleY, float rotation, bool mirror, bool reverse);
/** CMovement::Slide (F00B2): Start with the slide vector */
@@ -257,6 +257,9 @@ public:
Common::Point pivotAnchor() const;
/** the top left of the texture as drawn */
Common::Point topLeft() const;
+ /** the stored top left with its fraction (201509) */
+ float topLeftXF() const { return _x; }
+ float topLeftYF() const { return _y; }
/** CVisibleObject::SetPos (EEACC) for 201509: the stored top left */
void setTopLeft(Common::Point topLeft) override;
void setTopLeftF(float x, float y) override;
Commit: 0b6bcc5072bc4719465b6baf0059ebb87e85bcd1
https://github.com/scummvm/scummvm/commit/0b6bcc5072bc4719465b6baf0059ebb87e85bcd1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: Test mode screenshots by the engine (shot=, shotms=, shotquit)
Changed paths:
engines/ngi/determinism.cpp
engines/ngi/determinism.h
engines/ngi/ngi.cpp
diff --git a/engines/ngi/determinism.cpp b/engines/ngi/determinism.cpp
index 0276b977522..263dda11b53 100644
--- a/engines/ngi/determinism.cpp
+++ b/engines/ngi/determinism.cpp
@@ -19,10 +19,12 @@
*
*/
+#include "common/array.h"
#include "common/config-manager.h"
#include "common/debug.h"
#include "common/debug-channels.h"
#include "common/str.h"
+#include "common/system.h"
#include "common/tokenizer.h"
#include "ngi/ngi.h"
@@ -32,6 +34,25 @@ namespace NGI {
static uint32 g_updates = 0;
static uint32 g_freezeAfter = 0;
+// shot=N,M: screenshots after the N-th update (noRandom); shotms=N,M: N ms after the loop starts
+static Common::Array<uint32> &shotUpdates() {
+ static Common::Array<uint32> list;
+ return list;
+}
+static Common::Array<uint32> &shotTimes() {
+ static Common::Array<uint32> list;
+ return list;
+}
+static uint32 g_nextShotUpdate = 0;
+static uint32 g_nextShotTime = 0;
+static uint32 g_shotStart = 0;
+static bool g_shotQuit = false;
+
+static void parseList(const Common::String &list, Common::Array<uint32> &out) {
+ Common::StringTokenizer tokens(list, ",");
+ while (!tokens.empty())
+ out.push_back(atoi(tokens.nextToken().c_str()));
+}
bool determinismActive() {
return DebugMan.isDebugChannelEnabled(kDebugNoRandom);
@@ -61,4 +82,41 @@ bool determinismAllowUpdate() {
return true;
}
+void testShotsStart() {
+ shotUpdates().clear();
+ shotTimes().clear();
+ g_nextShotUpdate = g_nextShotTime = 0;
+ g_shotQuit = false;
+ g_shotStart = g_system->getMillis();
+ if (!ConfMan.hasKey("start_movie"))
+ return;
+ Common::StringTokenizer actions(ConfMan.get("start_movie"), ";");
+ while (!actions.empty()) {
+ const Common::String action = actions.nextToken();
+ if (action.hasPrefix("shot="))
+ parseList(action.substr(5), shotUpdates());
+ else if (action.hasPrefix("shotms="))
+ parseList(action.substr(7), shotTimes());
+ else if (action == "shotquit")
+ g_shotQuit = true;
+ }
+}
+
+void testShotsCheck() {
+ bool taken = false;
+ if (g_nextShotUpdate < shotUpdates().size() && g_updates >= shotUpdates()[g_nextShotUpdate]) {
+ ++g_nextShotUpdate;
+ taken = true;
+ }
+ if (g_nextShotTime < shotTimes().size() && g_system->getMillis() - g_shotStart >= shotTimes()[g_nextShotTime]) {
+ ++g_nextShotTime;
+ taken = true;
+ }
+ if (!taken)
+ return;
+ g_system->saveScreenshot();
+ if (g_shotQuit && g_nextShotUpdate >= shotUpdates().size() && g_nextShotTime >= shotTimes().size())
+ g_ngi->quitGame();
+}
+
} // End of namespace NGI
diff --git a/engines/ngi/determinism.h b/engines/ngi/determinism.h
index af9f3c70927..2219983a3a3 100644
--- a/engines/ngi/determinism.h
+++ b/engines/ngi/determinism.h
@@ -35,6 +35,12 @@ void determinismStart();
/** True when the game may be updated now; counts the updates for freeze=N. */
bool determinismAllowUpdate();
+/** Test screenshots: --start-movie=shot=, shotms=, shotquit (docs/test-mode.md). */
+void testShotsStart();
+
+/** Takes the screenshots that are due (after the frame was presented). */
+void testShotsCheck();
+
} // End of namespace NGI
#endif
diff --git a/engines/ngi/ngi.cpp b/engines/ngi/ngi.cpp
index af2a78c7053..6dcf3ea0aaf 100644
--- a/engines/ngi/ngi.cpp
+++ b/engines/ngi/ngi.cpp
@@ -607,6 +607,7 @@ Common::Error NGIEngine::run() {
const bool deterministic = determinismActive();
if (deterministic)
determinismStart();
+ testShotsStart();
while (!shouldQuit()) {
#ifdef USE_IMGUI
// For performance reasons, disable the renderer callback if the ImGui debug flag isn't set
@@ -630,6 +631,7 @@ Common::Error NGIEngine::run() {
// --debugflags=noRandom: a fixed step, and freeze=N stops the updates
if (deterministic && !determinismAllowUpdate()) {
_system->updateScreen();
+ testShotsCheck();
_system->delayMillis(5);
continue;
}
@@ -659,6 +661,7 @@ Common::Error NGIEngine::run() {
}
_system->updateScreen();
+ testShotsCheck();
_system->delayMillis(testmode_updatesPerFrame() > 1 ? 1 : timedUpdates ? 10 : 5);
}
Commit: af06fd480190a1a94d8356dc2b5c1107d1cd4a55
https://github.com/scummvm/scummvm/commit/af06fd480190a1a94d8356dc2b5c1107d1cd4a55
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: Mark the Android-only constants added with the UI work
Changed paths:
engines/ngi/fullpipe/constants.h
diff --git a/engines/ngi/fullpipe/constants.h b/engines/ngi/fullpipe/constants.h
index b9c0eeae3a8..f1c0580eaa6 100644
--- a/engines/ngi/fullpipe/constants.h
+++ b/engines/ngi/fullpipe/constants.h
@@ -243,14 +243,14 @@ namespace NGI {
#define PIC_MAP_H37 5391
#define PIC_MAP_H38 5392
#define PIC_TTL_CREDITS 5172
-#define PIC_TTL_CREDITS_1 23005
-#define PIC_TTL_CREDITS_2 23006
-#define PIC_TTL_CREDITS_3 23510
-#define PIC_SC_TITLES_BGR_DN 63274
-#define PIC_SC_TITLES_BGR_DN_IOS 28113
-#define PIC_SC_TITLES_BGR_UP 23527
-#define PIC_SC_TITLES_BGR_UPFB 23528
-#define QU_TTL_EXIT 28071
+#define PIC_TTL_CREDITS_1 23005 // Android
+#define PIC_TTL_CREDITS_2 23006 // Android
+#define PIC_TTL_CREDITS_3 23510 // Android
+#define PIC_SC_TITLES_BGR_DN 63274 // Android
+#define PIC_SC_TITLES_BGR_DN_IOS 28113 // Android
+#define PIC_SC_TITLES_BGR_UP 23527 // Android
+#define PIC_SC_TITLES_BGR_UPFB 23528 // Android
+#define QU_TTL_EXIT 28071 // Android
#define QU_INTR_STARTINTRO 5133
#define SC_1 301
#define SC_2 302
@@ -308,7 +308,7 @@ namespace NGI {
#define SC_LDR 635
#define SC_MAINMENU 4620
#define SC_MAP 5222
-#define SC_SPLASH 2
+#define SC_SPLASH 2 // Android
#define SC_TITLES 5166
#define SND_CMN_015 3139
#define SND_CMN_031 3516
@@ -1737,22 +1737,22 @@ namespace NGI {
// Final scene
#define ANI_FIN_COIN 5014
-#define ANI_FN3_HAND3 5036
+#define ANI_FN3_HAND3 5036 // Android
#define MSG_FIN_ENDFINAL 5109
#define MSG_FIN_GOTO2 5024
#define MSG_FIN_GOTO3 5071
#define MSG_FIN_GOTO4 5075
#define MSG_FIN_STARTFINAL 5025
#define MSG_FN4_STARTMUSIC 5356
-#define MV_FNHND3_SHOWHMR 5040
+#define MV_FNHND3_SHOWHMR 5040 // Android
#define QU_FIN1_FALLCOIN 5018
#define QU_FIN1_TAKECOIN 5023
#define QU_FN2_DOFINAL 5066
#define QU_FN3_DOFINAL 5072
#define QU_FN4_DOFINAL 5108
-#define SND_FIN_032 5107
-#define SND_MUS_16 63293
-#define SND_MUS_17 63294
+#define SND_FIN_032 5107 // Android
+#define SND_MUS_16 63293 // Android
+#define SND_MUS_17 63294 // Android
#define ST_FCN_NORM 5017
// Debug scene
@@ -1926,8 +1926,8 @@ namespace NGI {
#define TrubaLeft_fin 23274
#define SC_CONFIRMATION 23496
#define SC_OPTIONS 10009
-#define PIC_OPT_BGR 23514
-#define PIC_OPT_BGR_IOS 28116
+#define PIC_OPT_BGR 23514 // Android
+#define PIC_OPT_BGR_IOS 28116 // Android
// Android: names of obj.h that the ported controllers use
#define QU_EGTR_FATASK 5334
Commit: 87ce9989c4fb06ff3b852ad51d062aa4270e8610
https://github.com/scummvm/scummvm/commit/87ce9989c4fb06ff3b852ad51d062aa4270e8610
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: Resolve the ADDPIC pictures when the scene is created, as CScene::Init (D62)
Changed paths:
engines/ngi/fullpipe/scenes.cpp
engines/ngi/scene.cpp
engines/ngi/scene.h
engines/ngi/xmlproject.cpp
diff --git a/engines/ngi/fullpipe/scenes.cpp b/engines/ngi/fullpipe/scenes.cpp
index a1d4d139d59..e27cd5b3189 100644
--- a/engines/ngi/fullpipe/scenes.cpp
+++ b/engines/ngi/fullpipe/scenes.cpp
@@ -600,7 +600,7 @@ bool NGIEngine::doSetScene(const Entrance &entrance) {
if (!source)
return false;
if (ref.type & 2) {
- PictureObject *picture = scene->addRoamingPicture(ref);
+ PictureObject *picture = scene->findPictureObjectById(ref.objectId, ref.copyId);
if (!picture)
return false;
picture->setPos(ref.ox == -1 ? picture->_x : ref.ox, ref.oy == -1 ? picture->_y : ref.oy);
diff --git a/engines/ngi/scene.cpp b/engines/ngi/scene.cpp
index 425a218721c..12e07d0c867 100644
--- a/engines/ngi/scene.cpp
+++ b/engines/ngi/scene.cpp
@@ -118,8 +118,6 @@ void NGIEngine::pushScene(int sceneId) {
return;
}
debugC(1, kDebugInfo, "INFO t %u scene %d is pushed", g_system->getMillis(), sceneId);
- if (usesXMLProject())
- scene->addRoamingPictures();
if (_sceneStack.empty() && _currentScene)
_sceneStack.push_back(_currentScene);
if (_preloadManager) {
@@ -1329,33 +1327,37 @@ uint Scene::unloadRoamings(bool all) {
return size;
}
-// CScene::AddRoamingObjects (12300C), ADDPIC: this scene's picture, else the source's, else a copy
-PictureObject *Scene::addRoamingPicture(const PicAniInfo &ref) {
- Scene *source = g_ngi->findScene(ref.sceneId);
- if (!source)
- return nullptr;
- PictureObject *picture = findPictureObjectById(ref.objectId, ref.copyId);
- if (!picture) {
- picture = source->findPictureObjectById(ref.objectId, ref.copyId);
- if (!picture) {
- PictureObject *original = source->findPictureObjectById(ref.objectId, 0);
- if (!original)
- return nullptr;
- picture = new PictureObject(original);
- source->addPicture(picture);
- }
- _roamingPictures.push_back(picture);
- }
- return picture;
-}
-
-// A pushed dialog gets its ADDPIC pictures here (CGame::PushScene has no SetupRoamingObjects)
+// CScene::AddRoamingObjects (12300C), ADDPIC part: CScene::Init runs it, the map is sorted by key
void Scene::addRoamingPictures() {
for (const PicAniInfo &ref : _roamingObjects) {
- if ((ref.type & 2) && !addRoamingPicture(ref))
+ if (!(ref.type & 2))
+ continue;
+ Scene *source = g_ngi->findScene(ref.sceneId);
+ PictureObject *picture = source ? source->findPictureObjectById(ref.objectId, ref.copyId) : nullptr;
+ if (source && !picture) {
+ PictureObject *original = source->findPictureObjectById(ref.objectId, 0);
+ if (original) {
+ warning("STUB/untested: CScene::AddRoamingObjects copy %d of the picture %d of the scene %d", ref.copyId, ref.objectId, ref.sceneId);
+ picture = new PictureObject(original);
+ source->addPicture(picture);
+ }
+ }
+ if (!picture) {
warning("Scene::addRoamingPictures: a picture of the scene %d is not found", _sceneId);
+ continue;
+ }
+ const uint key = ((uint)(uint16)picture->_copyId << 16) | (uint16)picture->_id;
+ uint pos = 0;
+ uint found = 0;
+ for (; pos < _roamingPictures.size(); pos++) {
+ found = ((uint)(uint16)_roamingPictures[pos]->_copyId << 16) | (uint16)_roamingPictures[pos]->_id;
+ if (found >= key)
+ break;
+ }
+ if (pos < _roamingPictures.size() && found == key)
+ continue;
+ _roamingPictures.insert_at(pos, picture);
}
- repopulateRenderables();
}
// CScene::AddRoamingObject (123DF0): the roaming pictures load with the scene here, so only the
diff --git a/engines/ngi/scene.h b/engines/ngi/scene.h
index 267ff3a8b13..f5ddc122c30 100644
--- a/engines/ngi/scene.h
+++ b/engines/ngi/scene.h
@@ -78,7 +78,6 @@ class Scene : public Background {
uint unloadRoamings(bool all);
/** CScene::AddRoamingObject / RemoveRoamingObject: a picture of another scene (CCatalogManager) */
void addRoamingObject(PictureObject *picture, bool load);
- PictureObject *addRoamingPicture(const PicAniInfo &ref);
void addRoamingPictures();
void removeRoamingObject(int id);
uint loadMovement(int aniId, int movementId);
diff --git a/engines/ngi/xmlproject.cpp b/engines/ngi/xmlproject.cpp
index fd8b3716b78..95223d41289 100644
--- a/engines/ngi/xmlproject.cpp
+++ b/engines/ngi/xmlproject.cpp
@@ -1862,6 +1862,7 @@ void SceneTag::loadSceneXML(const GameProject &project) {
debugC(1, kDebugXML, "Loaded Full Pipe scene %s with %u pictures and %u animations",
_tag.c_str(), scene->_pictureObjects.size(), scene->_aniObjects.size());
+ scene->addRoamingPictures(); // CScene::Init: CScene::AddRoamingObjects
scene->updateLoadingTotal();
scene->repopulateRenderables(); // CScene::Init
delete _scene;
Commit: 3d18fe345b4e9e4be5aa31205b429f88e67d5157
https://github.com/scummvm/scummvm/commit/3d18fe345b4e9e4be5aa31205b429f88e67d5157
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: CAniObject::GetFullSize returns floats, the camera of TouchScroll and TestScroll adds the float steps
Changed paths:
engines/ngi/fullpipe/mobile/fpcontroller.cpp
engines/ngi/fullpipe/scene04.cpp
engines/ngi/physgeom.cpp
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/fullpipe/mobile/fpcontroller.cpp b/engines/ngi/fullpipe/mobile/fpcontroller.cpp
index a10f32cbd9e..703c8188a7c 100644
--- a/engines/ngi/fullpipe/mobile/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/fpcontroller.cpp
@@ -499,15 +499,15 @@ bool FPController::touchScroll() {
if (fabsf(_scene->_x - _targetX) > 0.0f)
_dragged = true;
if (_targetX >= 0.0f && !(_scene->_dims.x < _targetX + g_ngi->gameWidth())) {
- _scene->_x = (int)_targetX;
- _scene->_y = (int)_targetY;
+ _scene->_x = _targetX;
+ _scene->_y = _targetY;
} else {
const float dx = _targetX - _scene->_x;
const float dy = _targetY - _scene->_y;
_targetX = _scene->_x + dx / (g_ngi->gameWidth() / 102.0f);
_targetY = dy + _scene->_y;
- _scene->_x = (int)_targetX;
- _scene->_y = (int)_targetY;
+ _scene->_x = _targetX;
+ _scene->_y = _targetY;
_touchOffsetX = screenX;
_touchOffsetY = screenY;
_touchCameraX = _scene->_x;
@@ -529,20 +529,20 @@ bool FPController::touchScroll() {
float step = (fabsf(_scene->_x - limit + g_ngi->gameWidth()) * 5.0f) / 102.0f;
if (step < 0.5f)
step = 0.5f;
- _scene->_x = (int)(_scene->_x - step);
+ _scene->_x = _scene->_x - step;
_targetX = 0;
if (_scene->_x < limit - g_ngi->gameWidth())
- _scene->_x = (int)(limit - g_ngi->gameWidth());
+ _scene->_x = limit - g_ngi->gameWidth();
return true;
}
if (_scene->_x < lowest) {
float step = (fabsf(_scene->_x - lowest) * 5.0f) / 102.0f;
if (step < 0.5f)
step = 0.5f;
- _scene->_x = (int)(_scene->_x + step);
+ _scene->_x = _scene->_x + step;
_targetX = 0;
if (_scene->_x > lowest)
- _scene->_x = (int)lowest;
+ _scene->_x = lowest;
return true;
}
return false;
@@ -598,8 +598,8 @@ void FPController::testScroll() {
}
}
- _scene->_x += static_cast<int>(dx);
- _scene->_y += static_cast<int>(dy);
+ _scene->_x += dx;
+ _scene->_y += dy;
if (dx != 0.0f || dy != 0.0f)
g_ngi->_inputController->recalcCursorPos();
}
diff --git a/engines/ngi/fullpipe/scene04.cpp b/engines/ngi/fullpipe/scene04.cpp
index 031e0a79916..9a261b8d946 100644
--- a/engines/ngi/fullpipe/scene04.cpp
+++ b/engines/ngi/fullpipe/scene04.cpp
@@ -1125,7 +1125,7 @@ void sceneHandler04_springWobble() {
}
}
- int oldpos = g_vars->scene04_spring->getFullSize().y - oldDynIndex;
+ int oldpos = static_cast<int>(g_vars->scene04_spring->getFullSize().y) - oldDynIndex;
if (g_vars->scene04_dynamicPhaseIndex) {
if (!g_vars->scene04_spring->_movement)
@@ -1137,7 +1137,7 @@ void sceneHandler04_springWobble() {
}
if (g_vars->scene04_dynamicPhaseIndex != oldDynIndex) {
- sceneHandler04_bottleUpdateObjects(oldpos - (g_vars->scene04_spring->getFullSize().y - g_vars->scene04_dynamicPhaseIndex));
+ sceneHandler04_bottleUpdateObjects(oldpos - (static_cast<int>(g_vars->scene04_spring->getFullSize().y) - g_vars->scene04_dynamicPhaseIndex));
}
}
diff --git a/engines/ngi/physgeom.cpp b/engines/ngi/physgeom.cpp
index 80e37b3e013..6177d694cb8 100644
--- a/engines/ngi/physgeom.cpp
+++ b/engines/ngi/physgeom.cpp
@@ -172,9 +172,7 @@ void VisForPhys::recalcVisible() {
Vector2 fullSize;
if (_visObj->_objtype == kObjTypeStaticANIObject) {
- const Common::Point size = static_cast<AniObject *>(_visObj)->getFullSize();
- fullSize.x = size.x;
- fullSize.y = size.y;
+ fullSize = static_cast<AniObject *>(_visObj)->getFullSize();
} else {
const Dims size = static_cast<PictureObject *>(_visObj)->getFullSize();
fullSize.x = size.x;
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index 6fce5e5ea83..a3f5a80bbb9 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -819,7 +819,7 @@ void AniObject::render(Common::Point scroll) {
debugC(6, kDebugDrawing, "AniObject::render() (%s) [%d] [%g, %g]", transCyrillic(_title), _id, _x, _y);
if (_shadowsOn && g_ngi->_currentScene && g_ngi->_currentScene->_shadows
- && (getFullSize().x != 1 || getFullSize().y != 1)) {
+ && (getFullSize().x != 1.0f || getFullSize().y != 1.0f)) {
Phase *dyn;
@@ -957,8 +957,8 @@ void AniObject::preloadMovements(MovTable *mt) {
}
}
-// CAniObject::GetFullSize (EEB00): the texture size times the scale
-Dims AniObject::getFullSize() const {
+// CAniObject::GetFullSize (EEB00): the texture size times the scale, as floats
+Vector2 AniObject::getFullSize() const {
Texture *pic;
if (_movement)
@@ -966,12 +966,16 @@ Dims AniObject::getFullSize() const {
else
pic = _statics;
+ Vector2 size;
+ size.x = 0.0f;
+ size.y = 0.0f;
if (pic) {
- const Dims size = pic->getDimensions();
- return Dims(static_cast<int>(size.x * _scaleX), static_cast<int>(size.y * _scaleY));
+ const Dims dims = pic->getDimensions();
+ size.x = dims.x * _scaleX;
+ size.y = dims.y * _scaleY;
}
- return Dims();
+ return size;
}
Common::Point AniObject::getSomeXY() const {
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 1fde7269585..11b831a06a2 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -276,7 +276,7 @@ public:
Movement *getMovement(int id);
int getMovementIdById(int itemId) const;
Movement *getMovementByName(const Common::String &name);
- Common::Point getFullSize() const;
+ Vector2 getFullSize() const;
Common::Point getSomeXY() const;
Commit: 5c3c98931d7b11ca0b94e05adeb9f6eaca81e007
https://github.com/scummvm/scummvm/commit/5c3c98931d7b11ca0b94e05adeb9f6eaca81e007
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: Use the float centre (CVisibleObject::GetCenter, SetCenter) in the Android code
Changed paths:
engines/ngi/debugger/physicstest.cpp
engines/ngi/fullpipe/floaters.cpp
engines/ngi/fullpipe/lift.cpp
engines/ngi/fullpipe/mobile/catalog.cpp
engines/ngi/fullpipe/mobile/exitmanager.cpp
engines/ngi/fullpipe/mobile/exitmanager.h
engines/ngi/fullpipe/mobile/fpcontroller.cpp
engines/ngi/fullpipe/mobile/help.cpp
engines/ngi/fullpipe/mobile/liftcontroller.cpp
engines/ngi/fullpipe/mobile/mapwindowcontroller.cpp
engines/ngi/fullpipe/mobile/objhelper.cpp
engines/ngi/fullpipe/mobile/sc04controller.cpp
engines/ngi/fullpipe/mobile/sc06controller.cpp
engines/ngi/fullpipe/mobile/sc08controller.cpp
engines/ngi/fullpipe/mobile/sc09controller.cpp
engines/ngi/fullpipe/mobile/sc10controller.cpp
engines/ngi/fullpipe/mobile/sc11controller.cpp
engines/ngi/fullpipe/mobile/sc13controller.cpp
engines/ngi/fullpipe/mobile/sc14controller.cpp
engines/ngi/fullpipe/mobile/sc16controller.cpp
engines/ngi/fullpipe/mobile/sc17controller.cpp
engines/ngi/fullpipe/mobile/sc18controller.cpp
engines/ngi/fullpipe/mobile/sc21controller.cpp
engines/ngi/fullpipe/mobile/sc22controller.cpp
engines/ngi/fullpipe/mobile/sc23controller.cpp
engines/ngi/fullpipe/mobile/sc25controller.cpp
engines/ngi/fullpipe/mobile/sc26controller.cpp
engines/ngi/fullpipe/mobile/sc27controller.cpp
engines/ngi/fullpipe/mobile/sc28controller.cpp
engines/ngi/fullpipe/mobile/sc32controller.cpp
engines/ngi/fullpipe/mobile/sc33controller.cpp
engines/ngi/fullpipe/mobile/sc34controller.cpp
engines/ngi/fullpipe/mobile/sc37controller.cpp
engines/ngi/fullpipe/mobile/sc38controller.cpp
engines/ngi/fullpipe/mobile/scfinalcontroller.cpp
engines/ngi/fullpipe/mobile/tremble.cpp
engines/ngi/gfx.cpp
engines/ngi/gfx.h
engines/ngi/interaction.cpp
engines/ngi/inventory.cpp
engines/ngi/inventory.h
engines/ngi/motion.cpp
engines/ngi/physgeom.cpp
engines/ngi/statics.cpp
engines/ngi/statics.h
diff --git a/engines/ngi/debugger/physicstest.cpp b/engines/ngi/debugger/physicstest.cpp
index 41fbef1dff8..4b8b86792f9 100644
--- a/engines/ngi/debugger/physicstest.cpp
+++ b/engines/ngi/debugger/physicstest.cpp
@@ -324,10 +324,10 @@ void runProgrammatic() {
check(scene._pictureObjects.size() == pictures + 1, "VISOBJ made a copy of the picture in the scene");
GameObject *copy = ball->_geoms[0]->getVisObj() ? ball->_geoms[0]->getVisObj()->_visObj : nullptr;
if (copy) {
- Common::Point center = copy->getCenter();
+ const Vector2 center = copy->getCenterF();
Vector2 pos = ball->getPos();
- warning("PHYSTEST visible copy at %d,%d, ball at %.1f,%.1f", center.x, center.y, pos.x, pos.y);
- check(abs(center.x - static_cast<int>(pos.x)) <= 2 && abs(center.y - static_cast<int>(pos.y)) <= 2, "the copy follows the ball");
+ warning("PHYSTEST visible copy at %.1f,%.1f, ball at %.1f,%.1f", center.x, center.y, pos.x, pos.y);
+ check(fabsf(center.x - pos.x) <= 2.0f && fabsf(center.y - pos.y) <= 2.0f, "the copy follows the ball");
}
}
diff --git a/engines/ngi/fullpipe/floaters.cpp b/engines/ngi/fullpipe/floaters.cpp
index c92b20ce291..55a725b0fdf 100644
--- a/engines/ngi/fullpipe/floaters.cpp
+++ b/engines/ngi/fullpipe/floaters.cpp
@@ -86,7 +86,7 @@ void FlyPack::addFly(Scene *sc, int x, int y, int priority, int flags) {
if (android) {
ani->setStatic(ST_FLY_FLY);
- ani->setCenter(Common::Point(x, y));
+ ani->setCenterF((float)x, (float)y);
} else {
ani->_statics = ani->getStatic(ST_FLY_FLY);
ani->_movement = nullptr;
diff --git a/engines/ngi/fullpipe/lift.cpp b/engines/ngi/fullpipe/lift.cpp
index d3af945507d..e00bf43fcaa 100644
--- a/engines/ngi/fullpipe/lift.cpp
+++ b/engines/ngi/fullpipe/lift.cpp
@@ -870,7 +870,7 @@ bool Lift::onButtonUpBig(AniObject *button) {
// CLift::EnterLift: the hero walks to the lift and the door opens, or it stands there already
void Lift::enterLift() {
warnOnce("CBaseSettings::SetSaving (the saves are not blocked while the lift moves)");
- const Common::Point center = _hero->getCenter();
+ const Vector2 center = _hero->getCenterF();
if (fabsf(_x - center.x) > 3.0f || fabsf(_y - center.y) > 3.0f || _hero->_movement || _hero->_statics->_staticsId != ST_MAN_UP) {
MessageQueue *queue = sceneController(*_scene).mctlStartMove(_x, _y, true, ST_MAN_UP, false);
if (queue) {
diff --git a/engines/ngi/fullpipe/mobile/catalog.cpp b/engines/ngi/fullpipe/mobile/catalog.cpp
index a5a317ba452..52e85385f7b 100644
--- a/engines/ngi/fullpipe/mobile/catalog.cpp
+++ b/engines/ngi/fullpipe/mobile/catalog.cpp
@@ -205,7 +205,7 @@ void CatalogManager::addPicture(int id) {
if (!picture)
return;
_scene->addRoamingObject(picture, true);
- picture->setCenter(Common::Point(255, 304));
+ picture->setCenterF(255.0f, 304.0f);
picture->_flags |= 4;
}
diff --git a/engines/ngi/fullpipe/mobile/exitmanager.cpp b/engines/ngi/fullpipe/mobile/exitmanager.cpp
index 1ec658dcb59..a2f1f2d8679 100644
--- a/engines/ngi/fullpipe/mobile/exitmanager.cpp
+++ b/engines/ngi/fullpipe/mobile/exitmanager.cpp
@@ -81,10 +81,14 @@ int Exit::getVisId() const {
}
// center of the hit region, else of the picture (CHitregionObject / CVisibleObject::GetCenter)
-Common::Point Exit::pictureCenter() const {
- if (!_picture->_hitRegion.isEmpty())
- return _picture->_hitRegion.center() + Common::Point(_picture->_x, _picture->_y);
- return _picture->getCenter();
+Vector2 Exit::pictureCenter() const {
+ if (!_picture->_hitRegion.isEmpty()) {
+ Vector2 center;
+ center.x = _picture->_x + _picture->_hitRegion.left + _picture->_hitRegion.width() * 0.5f;
+ center.y = _picture->_y + _picture->_hitRegion.top + _picture->_hitRegion.height() * 0.5f;
+ return center;
+ }
+ return _picture->getCenterF();
}
// CExit::CreateAndAddInScene (144258): copies of the SC_COMMON arrow and its pressed picture go in
@@ -134,10 +138,10 @@ bool Exit::init(const XmlNode &node, Scene &scene) {
} else {
_arrow->_z = _picture->_z - 1;
}
- const Common::Point center = pictureCenter();
+ const Vector2 center = pictureCenter();
_centerX = center.x;
_centerY = center.y;
- _arrow->setCenter(Common::Point(_centerX + _offsetX, _centerY + _offsetY));
+ _arrow->setCenterF(_centerX + _offsetX, _centerY + _offsetY);
setState(state);
return true;
}
@@ -151,7 +155,7 @@ void Exit::loadParam(const XmlNode &node, Scene &scene) {
_offsetY = node.attrFloat("offsetY", 0.0f);
_type = node.attrInt("type", 0);
_intersect = node.attrBool("intersect", false);
- const Common::Point center = pictureCenter();
+ const Vector2 center = pictureCenter();
_centerX = center.x;
_centerY = center.y;
if (!_scene->findAniObjectById(_type != 0 ? ANI_ARROW_CHAPTER : ANI_ARROW, _arrowCopyId))
@@ -162,7 +166,7 @@ void Exit::loadParam(const XmlNode &node, Scene &scene) {
} else {
_arrow->_z = _picture->_z - 1;
}
- _arrow->setCenter(Common::Point(_centerX + _offsetX, _centerY + _offsetY));
+ _arrow->setCenterF(_centerX + _offsetX, _centerY + _offsetY);
setAngle(_angle);
setState(state);
}
@@ -218,7 +222,8 @@ void Exit::setNewAngle(float angle) {
// CExit::InitPicPressed (143EE0): the pressed arrow is where the arrow is
void Exit::initPicPressed() {
- _pressed->setCenter(_arrow->getCenter());
+ const Vector2 center = _arrow->getCenterF();
+ _pressed->setCenterF(center.x, center.y);
_pressed->_rotation = Math::deg2rad(_angle);
_pressed->_z = _arrow->_z;
_pressed->_flags |= 4;
@@ -237,11 +242,11 @@ void Exit::setOffset(float x, float y) {
_offsetX = x;
_offsetY = y;
if (_arrow) {
- const Common::Point center = pictureCenter();
+ const Vector2 center = pictureCenter();
_centerX = center.x;
_centerY = center.y;
- _arrow->setCenter(Common::Point(_centerX, _centerY));
- _arrow->setCenter(Common::Point(_centerX + _offsetX, _centerY + _offsetY));
+ _arrow->setCenterF(_centerX, _centerY);
+ _arrow->setCenterF(_centerX + _offsetX, _centerY + _offsetY);
}
}
diff --git a/engines/ngi/fullpipe/mobile/exitmanager.h b/engines/ngi/fullpipe/mobile/exitmanager.h
index da875d17845..df8a069c085 100644
--- a/engines/ngi/fullpipe/mobile/exitmanager.h
+++ b/engines/ngi/fullpipe/mobile/exitmanager.h
@@ -101,7 +101,7 @@ private:
int _hintTime = -1; // +68
void createAndAddInScene();
- Common::Point pictureCenter() const;
+ Vector2 pictureCenter() const;
};
/** CExitManager (CSingleton, NGIEngine::_exitManager): the exits of all scenes */
diff --git a/engines/ngi/fullpipe/mobile/fpcontroller.cpp b/engines/ngi/fullpipe/mobile/fpcontroller.cpp
index 703c8188a7c..fc97bac422d 100644
--- a/engines/ngi/fullpipe/mobile/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/fpcontroller.cpp
@@ -431,7 +431,7 @@ void FPController::defaultScroll() {
}
const float margin = marginX();
- const Common::Point center = _follow->getCenter();
+ const Vector2 center = _follow->getCenterF();
_heroCenterX = center.x;
_heroCenterY = center.y;
const float cx = cursorX();
@@ -741,7 +741,7 @@ MessageQueue *FPController::mctlStartMove(int x, int y, bool fuzzy, int staticsI
// CFPController::TrySwipeMan: when the point is not reachable, goes to the nearest one on the graph
bool FPController::trySwipeMan(float x, float y, bool nearest) {
if ((x != _lastTargetX || y != _lastTargetY) && checkTry()) {
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
if (_scene->_motionController->checkPoint(center.x, center.y)) {
if (mctlStartMove((int)x, (int)y, false, 0, false))
return true;
@@ -808,7 +808,7 @@ void FPController::calcFinPoint(float &outX, float &outY) {
bool FPController::moveBorders(float x, float y) {
if (!_follow)
return false;
- const Common::Point center = _follow->getCenter();
+ const Vector2 center = _follow->getCenterF();
_heroCenterX = center.x;
_heroCenterY = center.y;
MotionController *controller = _scene->_motionController.get();
@@ -841,10 +841,10 @@ bool FPController::tryStartInteractMan() {
} else {
return false;
}
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
const float x = _swipeDirection == -1 ? 2.0f : _scene->_dims.x - 2.0f;
// runs unless its object is the one of the interaction that runs
- Interact *interact = getGameLoaderInteractionController()->findInteraction(x, (float)center.y);
+ Interact *interact = getGameLoaderInteractionController()->findInteraction(x, center.y);
if (!interact)
return false;
GameObject *object = interact->getObject();
@@ -864,10 +864,10 @@ void FPController::testSwipe() {
if (!hero())
return;
if (_swipeDirection >= -1 && _swipeDirection <= 1) {
- const Common::Point center = hero()->getCenter();
- if (_swipeThreshold > fabsf(static_cast<float>(center.x)))
+ const Vector2 center = hero()->getCenterF();
+ if (_swipeThreshold > fabsf(center.x))
_swipeDirection = -1;
- else if (_swipeThreshold > fabsf(static_cast<float>(_scene->_dims.x - center.x)))
+ else if (_swipeThreshold > fabsf(static_cast<float>(_scene->_dims.x) - center.x))
_swipeDirection = 1;
else
_swipeDirection = 0;
@@ -1106,11 +1106,11 @@ void FPController::execCmdMctl(Command *cmd, MessageQueue *queue) {
if (started->getCurCommandNum() + 1 != 0)
return;
} else {
- if (fabsf(x - man->getCenter().x) > 1.0f) {
+ if (fabsf(x - man->getCenterF().x) > 1.0f) {
queue->stop(false);
return;
}
- if (fabsf(y - man->getCenter().y) > 1.0f) {
+ if (fabsf(y - man->getCenterF().y) > 1.0f) {
queue->stop(false);
return;
}
@@ -1325,7 +1325,7 @@ bool FPController::onMouseLKeyUpTop(uint32 id, float x, float y) {
if (_react->_movement)
_react->stopMovementToPrev(true);
_react->setStatic(ST_REACT);
- _react->setCenter(Common::Point((int)x, (int)y));
+ _react->setCenterF(x, y);
_react->_flags |= 4;
_react->startMovement(MV_REACT, 0, -1);
}
diff --git a/engines/ngi/fullpipe/mobile/help.cpp b/engines/ngi/fullpipe/mobile/help.cpp
index e57b86d2f32..09eb29c9d21 100644
--- a/engines/ngi/fullpipe/mobile/help.cpp
+++ b/engines/ngi/fullpipe/mobile/help.cpp
@@ -184,7 +184,7 @@ void HelpController::onShow() {
_sceneInitDone = true;
onSceneInit();
}
- const Common::Point center = _hero->getCenter();
+ const Vector2 center = _hero->getCenterF();
const Common::Point size = _hero->getSize();
Scene *below = g_ngi->getSceneInStack(0);
float x;
diff --git a/engines/ngi/fullpipe/mobile/liftcontroller.cpp b/engines/ngi/fullpipe/mobile/liftcontroller.cpp
index b1c4d3e9824..62e047d3add 100644
--- a/engines/ngi/fullpipe/mobile/liftcontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/liftcontroller.cpp
@@ -86,10 +86,10 @@ void LiftController::sortButtons(const Common::Array<AniObject *> &buttons) {
big->_flags |= 4; // CVisibleObject +8 |= 1: visible
const float x = background->_x + 52.0f + (i & 1) * 65.0f;
const float y = background->_y + 64.0f + (i >> 1) * 85.0f;
- big->setCenter(Common::Point(x, y));
+ big->setCenterF(x, y);
big->setStatic(buttons[i]->_statics->_staticsId - 30);
if (i + 1 == buttons.size() && buttons[i]->pivotX() > buttons[0]->pivotX())
- big->setCenter(Common::Point(background->_x + 52 + 65, y));
+ big->setCenterF((background->_x + 52.0f) + 65.0f, y);
Button button;
button.big = big;
diff --git a/engines/ngi/fullpipe/mobile/mapwindowcontroller.cpp b/engines/ngi/fullpipe/mobile/mapwindowcontroller.cpp
index 2fa3989aca2..20e23718ae1 100644
--- a/engines/ngi/fullpipe/mobile/mapwindowcontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/mapwindowcontroller.cpp
@@ -572,7 +572,8 @@ bool MapWindowController::onTouchesDown(uint32 id, float x, float y) {
bool stop = false;
if (_hitObject && getSceneId(_hitObject->_id) != 0) {
if (g_ngi->_map->isDontEnter(_hitObject->_id)) {
- _stopSign->setCenter(_hitObject->getCenter());
+ const Vector2 center = _hitObject->getCenterF();
+ _stopSign->setCenterF(center.x, center.y);
stop = true;
}
}
diff --git a/engines/ngi/fullpipe/mobile/objhelper.cpp b/engines/ngi/fullpipe/mobile/objhelper.cpp
index 6c7dbb0e3d2..49041448144 100644
--- a/engines/ngi/fullpipe/mobile/objhelper.cpp
+++ b/engines/ngi/fullpipe/mobile/objhelper.cpp
@@ -550,7 +550,8 @@ void ObjHelperHint::initAniObjs(Scene *scene) {
return;
}
AniObject *ani = new AniObject(_template);
- ani->setCenter(target->getCenter());
+ const Vector2 center = target->getCenterF();
+ ani->setCenterF(center.x, center.y);
HintAni entry;
entry.object = target;
entry.ani = ani;
diff --git a/engines/ngi/fullpipe/mobile/sc04controller.cpp b/engines/ngi/fullpipe/mobile/sc04controller.cpp
index b6a1c4d4387..e3b28efe033 100644
--- a/engines/ngi/fullpipe/mobile/sc04controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc04controller.cpp
@@ -320,8 +320,8 @@ void Sc04Controller::setJumpSteps(Movement *movement, int from, int to, const Ve
void Sc04Controller::moveSpringAttachments(int delta) {
for (uint i = 0; i < _bottleObjects.size(); i++) {
GameObject *object = _bottleObjects[i];
- const Common::Point center = object->getCenter();
- object->setCenter(Common::Point(center.x, (int)((float)center.y + (float)delta)));
+ const Vector2 center = object->getCenterF();
+ object->setCenterF(center.x, center.y + (float)delta);
}
}
@@ -389,13 +389,13 @@ void Sc04Controller::onClickBottle() {
// CSc04Controller::DoUpdateBottlePosition (164D4C): spring center is 108 px under the hand frame
void Sc04Controller::doUpdateBottlePosition() {
- const Common::Point spring = _spring->getCenter();
+ const Vector2 spring = _spring->getCenterF();
const float springY = spring.y;
- const Common::Point hand = _hand->getCenter();
+ const Vector2 hand = _hand->getCenterF();
const Common::Point size = _hand->getSize();
- const float y = ((float)hand.y + (float)(size.y * 0.5)) + 108.0f;
+ const float y = (hand.y + (float)(size.y * 0.5)) + 108.0f;
moveSpringAttachments((int)(float)(y - springY));
- _spring->setCenter(Common::Point(spring.x, (int)y));
+ _spring->setCenterF(spring.x, y);
}
// CSc04Controller::OnClickButton (164DC4): not while the arcade runs or the hand is busy
@@ -594,13 +594,13 @@ void Sc04Controller::afterLadder() {
// CSc04Controller::DoUpdateBottlePositionDown (1658A8): jar falls (speed +5 per step)
void Sc04Controller::doUpdateBottlePositionDown() {
- const Common::Point spring = _spring->getCenter();
+ const Vector2 spring = _spring->getCenterF();
const float springY = spring.y;
const int speed = _bottleFallSpeed;
const float newY = springY + (float)speed;
_bottleFallSpeed = speed + 5;
moveSpringAttachments((int)(float)(newY - springY));
- _spring->setCenter(Common::Point(spring.x, (int)newY));
+ _spring->setCenterF(spring.x, newY);
if (_springState == 0) {
_springState = 1;
@@ -614,12 +614,12 @@ void Sc04Controller::doUpdateBottlePositionDown() {
recalcSpring(1);
}
- if ((float)_bottle->getCenter().y >= 226.0f) {
+ if (_bottle->getCenterF().y >= 226.0f) {
const int bottleY = _bottle->getPosition().y;
moveSpringAttachments(226 - bottleY);
_spring->stopMovementToPrev(true);
- const Common::Point center = _spring->getCenter();
- _spring->setPosition(Common::Point(center.x, 437));
+ const Vector2 center = _spring->getCenterF();
+ _spring->setPositionF(center.x, 437.0f);
_bottleDropped = false;
_handIsDown = false;
_objectIsTaken = true;
@@ -892,7 +892,7 @@ void Sc04Controller::doShootKozawka() {
return;
if (kozaw->_movement && kozaw->_movement->_id == MV_KZW_WALKPLANK && kozaw->_movement->_curFrame <= 40) {
- const int x = _testShootX >= 0 ? _testShootX : kozaw->getCenter().x;
+ const int x = _testShootX >= 0 ? _testShootX : (int)kozaw->getCenterF().x;
int result = 7;
if ((uint)(x - 615) > 0x27) {
result = 6;
@@ -1060,7 +1060,7 @@ void Sc04Controller::onClickLadder() {
_clickY = (float)((float)((float)((float)(_ladder->_stepY * 6.0) + _ladder->_y) - _ladder->_entryOffsetY) + (float)(_ladder->_stepY * 0.5)) + 1.0f;
doWalkLadder(_clickX, _clickY);
} else {
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
_clickHeroX = center.x;
_clickHeroY = center.y;
if (getGameLoaderInteractionController()->_enabled) {
@@ -1198,7 +1198,7 @@ void Sc04Controller::doAttachMan() {
// CSc04Controller::PutKozawToBottle (167E30): kozawka sits in the jar, counter grows, 3rd: hand
void Sc04Controller::putKozawToBottle(AniObject *kozaw, PictureObject *bottle) {
g_ngi->arcadeInterface().incCounter();
- bottle->getCenter();
+ bottle->getCenterF();
random31();
_bottleObjects.push_back(kozaw);
_bottleKozaws.push_back(kozaw);
@@ -1270,8 +1270,8 @@ void Sc04Controller::onShowSceneState() {
if (isState(sO_Jar_4, sO_OnTheSpring)) {
_spring->stopMovementToPrev(true);
- const Common::Point center = _spring->getCenter();
- _spring->setPosition(Common::Point(center.x, 437));
+ const Vector2 center = _spring->getCenterF();
+ _spring->setPositionF(center.x, 437.0f);
_bottleObjects.clear();
PictureObject *bottle = _scene->findPictureObjectById(PIC_SC4_BOTTLE, 0);
bottle->setPosition(Common::Point(bottle->getPosition().x, 226));
@@ -1315,7 +1315,7 @@ void Sc04Controller::onShowSceneState() {
_spring->startMovement(MV_SPR_LOWER, 0, -1);
if (_spring->_movement)
_spring->setCurFrame(8);
- _spring->setCenter(Common::Point(433, 238));
+ _spring->setCenterF(433.0f, 238.0f);
}
_bottleTaken = false;
diff --git a/engines/ngi/fullpipe/mobile/sc06controller.cpp b/engines/ngi/fullpipe/mobile/sc06controller.cpp
index 8940decb5ee..ae264190be5 100644
--- a/engines/ngi/fullpipe/mobile/sc06controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc06controller.cpp
@@ -411,8 +411,8 @@ void Sc06Controller::onBallClick() {
if (!_currentBall || _currentBall->_movement || _currentBall->getStaticsId() != ST_NBL_NORM)
return;
- const Common::Point center = hero()->getCenter();
- if ((fabsf(1158.0f - (float)center.x) <= 2.0f && fabsf(452.0f - (float)center.y) <= 2.0f && !hero()->_movement && hero()->getStaticsId() == ST_MAN_RIGHT &&
+ const Vector2 center = hero()->getCenterF();
+ if ((fabsf(1158.0f - center.x) <= 2.0f && fabsf(452.0f - center.y) <= 2.0f && !hero()->_movement && hero()->getStaticsId() == ST_MAN_RIGHT &&
(hero()->_flags & 8)) || _holdingBall) {
doTakeBall();
return;
@@ -622,7 +622,7 @@ void Sc06Controller::doTakeLastDrop() {
// CSc06Controller::DoFallBall (16CB38): the missed ball falls to y 475 and returns to the pool
void Sc06Controller::doFallBall() {
_ballY = 475.0f;
- _flyingBall->setCenter(Common::Point((int)_ballX, (int)475.0f));
+ _flyingBall->setCenterF(_ballX, 475.0f);
runQueueForCopy(_scene, QU_SC6_FALLBALL, _flyingBall->_copyId);
_balls.push_back(_flyingBall);
_flyingBall = nullptr;
@@ -647,29 +647,29 @@ void Sc06Controller::putBallToBag() {
bool done = false;
if (_mumsy->_movement->_id == MV_MOM_JUMPFW) {
if (_mumsy->getCurFrame() > 5) {
- const Common::Point size = _mumsy->_movement->getCenterMovementSize(1, -1);
- moveX = (float)size.x;
- moveY = (float)size.y;
+ const Vector2 size = _mumsy->_movement->getCenterMovementSizeF(1, -1);
+ moveX = size.x;
+ moveY = size.y;
++_momPos;
done = true;
}
} else if (_mumsy->getCurFrame() > 4) {
- const Common::Point size = _mumsy->_movement->getCenterMovementSize(1, -1);
- moveX = (float)size.x;
- moveY = (float)size.y;
+ const Vector2 size = _mumsy->_movement->getCenterMovementSizeF(1, -1);
+ moveX = size.x;
+ moveY = size.y;
--_momPos;
done = true;
}
if (!done) {
- const Common::Point size = _mumsy->_movement->getCenterMovementSize(0, _mumsy->getCurFrame());
- moveX = -(float)size.x;
- moveY = -(float)size.y;
+ const Vector2 size = _mumsy->_movement->getCenterMovementSizeF(0, _mumsy->getCurFrame());
+ moveX = -size.x;
+ moveY = -size.y;
}
- const Common::Point center = _mumsy->getCenter();
- const float x = (float)center.x + moveX;
- const float y = (float)center.y + moveY;
+ const Vector2 center = _mumsy->getCenterF();
+ const float x = center.x + moveX;
+ const float y = center.y + moveY;
_mumsy->setStatic(ST_MOM_STANDS);
- _mumsy->setCenter(Common::Point((int)x, (int)y));
+ _mumsy->setCenterF(x, y);
}
_scene->runQueue(QU_MOM_PUTBALL, 2);
_ballInBag = true;
@@ -680,8 +680,8 @@ void Sc06Controller::putBallToBag() {
// CSc06Controller::TestBallFlight (16CD14): caught in the region at Mumsy, lost below the floor
void Sc06Controller::testBallFlight() {
if (_ballY <= 475.0f) {
- const Common::Point center = _mumsy->getCenter();
- _region.moveRegionTo((float)center.x + 20.0f, (float)center.y + 0.0f);
+ const Vector2 center = _mumsy->getCenterF();
+ _region.moveRegionTo(center.x + 20.0f, center.y + 0.0f);
if (_region.ptInRegion(_ballX, _ballY)) {
// CFlurryEventManager first_move/total_moves: analytics not ported
putBallToBag();
@@ -796,9 +796,9 @@ void Sc06Controller::onShow() {
_powerArrow->_scaleX = _aimScale;
_powerArrow->_scaleY = 1.0f;
_powerArrow->setPosition(Common::Point(980, 390));
- const Common::Point arrowCenter = _powerArrow->getCenter();
- _arrowX = (float)arrowCenter.x;
- _arrowY = (float)arrowCenter.y;
+ const Vector2 arrowCenter = _powerArrow->getCenterF();
+ _arrowX = arrowCenter.x;
+ _arrowY = arrowCenter.y;
if (!_liquidCopy) {
_liquidCopy = new PictureObject(_liquid);
_scene->addPicture(_liquidCopy);
@@ -963,13 +963,13 @@ void Sc06Controller::onUpdate(uint32 elapsed) {
_jumpBkQueue->_percent = 0;
}
if (_flyingBall) {
- const Common::Point center = _flyingBall->getCenter();
- _ballX = (float)center.x;
- _ballY = (float)center.y;
+ const Vector2 center = _flyingBall->getCenterF();
+ _ballX = center.x;
+ _ballY = center.y;
const float time = (float)elapsed;
_ballX = _ballX - (time * _ballSpeedX);
_ballY = _ballY - (time * _ballSpeedY);
- _flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
+ _flyingBall->setCenterF(_ballX, _ballY);
const float slowdown = time * 0.001f;
if (_ballSpeedX >= slowdown)
_ballSpeedX = _ballSpeedX - slowdown;
@@ -994,7 +994,7 @@ void Sc06Controller::onRender(Common::Point scroll) {
_powerArrow->_rotation = (float)((double)_aimAngle * 3.14159265358979 / 180.0);
_powerArrow->_scaleX = _aimScale;
_powerArrow->_scaleY = 1.0f;
- _powerArrow->setCenter(Common::Point((int)_arrowX, (int)_arrowY));
+ _powerArrow->setCenterF(_arrowX, _arrowY);
}
}
@@ -1006,9 +1006,9 @@ void Sc06Controller::updateScroll() {
}
if (!_follow)
return;
- const Common::Point center = _follow->getCenter();
- _heroCenterX = (float)center.x;
- _heroCenterY = (float)center.y;
+ const Vector2 center = _follow->getCenterF();
+ _heroCenterX = center.x;
+ _heroCenterY = center.y;
if (!_arcadeRunning || _heroCenterY > 470.0f || _heroCenterX < 1088.0f) {
FPController::updateScroll();
return;
diff --git a/engines/ngi/fullpipe/mobile/sc08controller.cpp b/engines/ngi/fullpipe/mobile/sc08controller.cpp
index 2dd4ef0e767..698b31bbb8a 100644
--- a/engines/ngi/fullpipe/mobile/sc08controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc08controller.cpp
@@ -133,7 +133,7 @@ void Sc08Controller::resumeFlight() {
// CSc08Controller::DoManDryg (16EA94): button up in the air: kick up or down, near the ground jump
void Sc08Controller::doManDryg() {
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
float centerY = center.y;
const Common::Point size = hero()->getSize();
if (!((697.0f - (centerY + (float)size.y * 0.5f)) < 150.0f)) {
@@ -145,10 +145,10 @@ void Sc08Controller::doManDryg() {
} else {
if (hero()->getStaticsId() == ST_MAN8_FLYDOWN) {
centerY = centerY - 25.0f;
- hero()->setCenter(Common::Point(center.x, (int)centerY));
+ hero()->setCenterF(center.x, centerY);
}
hero()->setStatic(ST_MAN8_STAND);
- hero()->setCenter(Common::Point(380, (int)centerY));
+ hero()->setCenterF(380.0f, centerY);
hero()->startMovement(MV_MAN8_JUMP, 0, -1);
}
}
@@ -231,9 +231,9 @@ void Sc08Controller::updateButtons(uint32 elapsed) {
// CSc08Controller::DoSitdown (16EF8C): the man lands on his belly; nothing calls it
void Sc08Controller::doSitdown() {
g_ngi->arcadeInterface().setCounter(0);
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
hero()->setStatic(ST_MAN8_FLYDOWN);
- hero()->setCenter(Common::Point(380, center.y));
+ hero()->setCenterF(380.0f, center.y);
hero()->startMovement(MV_MAN8_SITDOWN, 0, -1);
_vmyats->setStatic(ST_VMT_MIN);
_vmyats->_flags &= ~4;
@@ -306,9 +306,9 @@ void Sc08Controller::countManRaising(uint32 elapsed) {
if (!_flyingUp)
return;
- const Common::Point center = hero()->getCenter();
- const float y = (float)((double)(float)center.y + (double)elapsed * -0.5);
- hero()->setCenter(Common::Point(center.x, (int)y));
+ const Vector2 center = hero()->getCenterF();
+ const float y = (float)((double)center.y + (double)elapsed * -0.5);
+ hero()->setCenterF(center.x, y);
if (y < 80.0f) {
g_ngi->_taskManager->deactivateTask("FIND_EXIT_BATUTA_SC8");
endBatut();
@@ -334,7 +334,7 @@ void Sc08Controller::startBatut() {
_scene->_motionController->deactivate();
_batuta->stopMovement();
_vmyats->setStatic(ST_VMT_MIN);
- _vmyats->setCenter(Common::Point(382, 697));
+ _vmyats->setCenterF(382.0f, 697.0f);
_vmyats->_z = 29;
_manSpeed = stepSpeed(1);
_targetY = 0;
@@ -386,7 +386,7 @@ void Sc08Controller::doStep1() {
// CSc08Controller::CountManFlight (16F6E8): the physics of the flight in steps of 25 ms
void Sc08Controller::countManFlight(uint32 elapsed) {
_flightTimer += elapsed;
- Common::Point center = hero()->getCenter();
+ Vector2 center = hero()->getCenterF();
float centerX = center.x;
float centerY = center.y;
if ((double)fabsf(_manSpeed) <= 0.08) {
@@ -413,9 +413,9 @@ void Sc08Controller::countManFlight(uint32 elapsed) {
const float limit = stepSpeed(_step);
if (_manSpeed < limit)
_manSpeed = limit;
- hero()->setCenter(Common::Point((int)centerX, (int)newY));
+ hero()->setCenterF(centerX, newY);
// CVisibleObject::GetSize(hero): the result is not used
- center = hero()->getCenter();
+ center = hero()->getCenterF();
centerX = center.x;
centerY = center.y;
@@ -518,7 +518,7 @@ void Sc08Controller::onShow() {
lock->_flags |= 0x20000000;
_snoringTimer = 1;
if (_scene->_currentEntranceId == 0) {
- hero()->setCenter(Common::Point(663, 436));
+ hero()->setCenterF(663.0f, 436.0f);
hero()->_z = 20;
hero()->setStatic(ST_MAN_RIGHT);
hero()->_flags |= 8; // CVisibleObject +64: the man looks to the left (mirrored)
@@ -584,13 +584,13 @@ void Sc08Controller::updateScroll() {
return;
}
const int renderHeight = g_ngi->_backgroundSurface.h; // CRender +40
- if ((float)_follow->getCenter().y < (float)_scene->_y + 300.0f) {
- _scene->_y = (float)_follow->getCenter().y - 300.0f;
+ if (_follow->getCenterF().y < (float)_scene->_y + 300.0f) {
+ _scene->_y = _follow->getCenterF().y - 300.0f;
if ((float)_scene->_y < 0.0f)
_scene->_y = 0;
}
- if ((float)_follow->getCenter().y > ((float)renderHeight + (float)_scene->_y) - 350.0f)
- _scene->_y = ((float)_follow->getCenter().y + 350.0f) - (float)renderHeight;
+ if (_follow->getCenterF().y > ((float)renderHeight + (float)_scene->_y) - 350.0f)
+ _scene->_y = (_follow->getCenterF().y + 350.0f) - (float)renderHeight;
}
limitScroll();
testScroll();
@@ -626,7 +626,7 @@ void Sc08Controller::onUpdate(uint32 elapsed) {
if (man->_movement && man->_movement->_id == MV_MAN_FROMLADDERUP && man->getCurFrame() == 13)
man->_z = 20;
}
- switchLadder(_follow->getCenter().y > 520.0f);
+ switchLadder(_follow->getCenterF().y > 520.0f);
}
if (_flyingUp)
countManRaising(elapsed);
@@ -696,7 +696,7 @@ void Sc08Controller::onMessage(const Common::String &message, const Common::Stri
_scene->_y = 352;
hero()->setStatic(ST_MAN_RIGHT);
hero()->_flags |= 8; // SetStatic(ST_MAN_RIGHT, mirror 1)
- hero()->setCenter(Common::Point(663, 436));
+ hero()->setCenterF(663.0f, 436.0f);
PictureObject *ladder = _scene->findPictureObjectById(PIC_SC8_LADDER_D, 0);
ladder->setPosition(Common::Point(327, 110));
ladder->_flags |= 4;
@@ -724,7 +724,7 @@ void Sc08Controller::onMessage(const Common::String &message, const Common::Stri
} else if (message == "MSG_SC8_STANDUP") {
_manSpeed = -0.1f;
_vmyats->setStatic(ST_VMT_MIN);
- _vmyats->setCenter(Common::Point(382, 697));
+ _vmyats->setCenterF(382.0f, 697.0f);
_vmyats->_z = 29;
_inAir = true;
} else if (message == "MSG_SC8_ENTERUP") {
@@ -770,8 +770,8 @@ void Sc08Controller::onGuiEvent(const Common::String &id, const Common::String &
else if (_onBelly)
doStandup();
// the analytics counter total_moves_ANI_BATUTA (CFlurryEventManager) is not ported
- const Common::Point center = hero()->getCenter();
- if (_region->ptInRegion((float)center.x, (float)center.y) && (_manSpeed > 0.0f || _step == 1)) {
+ const Vector2 center = hero()->getCenterF();
+ if (_region->ptInRegion(center.x, center.y) && (_manSpeed > 0.0f || _step == 1)) {
const int steps = (int)_stepSpeeds.size();
if (_step < steps)
_step++;
@@ -794,9 +794,9 @@ int Sc08Controller::getCursorType(float x, float y) {
if (!_arcadeRunning) {
if (!g_ngi->_inputController->isObjectHit(PIC_SC8_LADDERD))
return FPController::getCursorType(x, y);
- if ((float)_follow->getCenter().y < 520.0f)
+ if (_follow->getCenterF().y < 520.0f)
return 2;
- return (_follow->getCenter().y > 750.0f) ? 4 : 0;
+ return (_follow->getCenterF().y > 750.0f) ? 4 : 0;
}
if (!_onBelly)
return 6;
diff --git a/engines/ngi/fullpipe/mobile/sc09controller.cpp b/engines/ngi/fullpipe/mobile/sc09controller.cpp
index b4a930800df..3d7904f03bd 100644
--- a/engines/ngi/fullpipe/mobile/sc09controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc09controller.cpp
@@ -267,10 +267,10 @@ void Sc09Controller::doUpdatePath() {
if (_gulperPresent) {
if (link)
link->_flags |= 0x20000000;
- const Common::Point center = hero()->getCenter();
- if ((float)center.y <= 450.0f) {
+ const Vector2 center = hero()->getCenterF();
+ if (center.y <= 450.0f) {
hero()->setStatic(ST_MAN_UP);
- hero()->setCenter(Common::Point(1552, 493));
+ hero()->setCenterF(1552.0f, 493.0f);
onMessage("MSG_FROMLADDER", "", nullptr);
}
} else {
@@ -342,10 +342,10 @@ void Sc09Controller::doShowBall() {
_sceneBalls.pop_front();
_flyingBalls.push_back(ball);
ball->_flags |= 4;
- const Common::Point center = hero()->getCenter();
- const float x = (float)center.x + 94.0f;
- const float y = (float)hero()->getCenter().y - 162.0f;
- ball->setCenter(Common::Point((int)x, (int)y));
+ const Vector2 center = hero()->getCenterF();
+ const float x = center.x + 94.0f;
+ const float y = hero()->getCenterF().y - 162.0f;
+ ball->setCenterF(x, y);
ball->setStatic(ST_BALL9_NORM);
}
}
@@ -509,10 +509,10 @@ void Sc09Controller::countBallFlight(uint32 elapsed) {
AniObject *ball = _flyingBalls.front();
_flyingBalls.pop_front();
_flyingBalls.push_back(ball);
- const Common::Point center = ball->getCenter();
- const float x = (float)center.x + (float)((float)elapsed * _ballSpeed);
- const float y = (float)center.y;
- ball->setCenter(Common::Point((int)x, (int)y));
+ const Vector2 center = ball->getCenterF();
+ const float x = center.x + (float)((float)elapsed * _ballSpeed);
+ const float y = center.y;
+ ball->setCenterF(x, y);
if (x <= 1398.0f || _eatingBall || !_gulperPresent) {
bool explode = false;
if (_gulperPresent || x <= 1600.0f) {
@@ -541,10 +541,10 @@ void Sc09Controller::countBallFlight(uint32 elapsed) {
// CSc09Controller::DoStartShoot (172040)
void Sc09Controller::doStartShoot() {
_spitter->stopMovement();
- const float targetX = (float)_spitter->getCenter().x - 10.0f;
- const float targetY = (float)_spitter->getCenter().y + 145.0f;
+ const float targetX = _spitter->getCenterF().x - 10.0f;
+ const float targetY = _spitter->getCenterF().y + 145.0f;
_shootIdle = 0;
- if (fabsf(targetX - (float)hero()->getCenter().x) > 3.0f || fabsf(targetY - (float)hero()->getCenter().y) > 3.0f) {
+ if (fabsf(targetX - hero()->getCenterF().x) > 3.0f || fabsf(targetY - hero()->getCenterF().y) > 3.0f) {
MessageQueue *queue = mctlStartMove((int)targetX, (int)targetY, true, ST_MAN_UP, false);
if (queue)
queue->addCommandToEnd(messageCommand("MSG_SC9_PLVCLICK"));
@@ -593,9 +593,9 @@ void Sc09Controller::onShow() {
}
g_ngi->_taskManager->visitScene(_scene->_sceneId);
if (_scene->_currentEntranceId == 0 && !(_spitter->_flags & 4)) {
- const float x = (float)_spitter->getCenter().x - 10.0f;
- const float y = (float)_spitter->getCenter().y + 145.0f;
- hero()->setCenter(Common::Point((int)x, (int)y));
+ const float x = _spitter->getCenterF().x - 10.0f;
+ const float y = _spitter->getCenterF().y + 145.0f;
+ hero()->setCenterF(x, y);
hero()->setStatic(ST_MAN_UP);
}
_spitter->_flags |= 4;
@@ -651,9 +651,9 @@ void Sc09Controller::onShow() {
for (int i = 1; i < _hangerCount; i++) {
AniObject *copy = new AniObject(original);
copy->_flags |= 4;
- const float x = (float)(_hangerStep * i) + (float)original->getCenter().x;
- const float y = (float)original->getCenter().y;
- copy->setCenter(Common::Point((int)x, (int)y));
+ const float x = (float)(_hangerStep * i) + original->getCenterF().x;
+ const float y = original->getCenterF().y;
+ copy->setCenterF(x, y);
// CScene::AddAni(copy, 0): the copy number is the amount of objects with this id
copy->assignCopyId(&_scene->_aniObjects);
_scene->addAni(copy, true);
@@ -723,7 +723,7 @@ int Sc09Controller::getCursorType(float x, float y) {
return 116;
CursorController *cursor = g_ngi->_inputController;
if (cursor->getInteractHitObjectId() == PIC_SC9_LADDER_R) {
- if ((float)hero()->getCenter().y < 350.0f)
+ if (hero()->getCenterF().y < 350.0f)
return 2;
return 4;
}
@@ -740,9 +740,9 @@ void Sc09Controller::updateScroll() {
FPController::updateScroll();
return;
}
- const float targetX = (float)_spitter->getCenter().x - 10.0f;
- const float targetY = (float)_spitter->getCenter().y;
- if (fabsf(targetX - (float)hero()->getCenter().x) > 20.0f || fabsf((float)(targetY + 145.0f) - (float)hero()->getCenter().y) > 20.0f) {
+ const float targetX = _spitter->getCenterF().x - 10.0f;
+ const float targetY = _spitter->getCenterF().y;
+ if (fabsf(targetX - hero()->getCenterF().x) > 20.0f || fabsf((float)(targetY + 145.0f) - hero()->getCenterF().y) > 20.0f) {
if (_follow != nullptr) {
FPController::updateScroll();
return;
diff --git a/engines/ngi/fullpipe/mobile/sc10controller.cpp b/engines/ngi/fullpipe/mobile/sc10controller.cpp
index 6445664fec0..1729d44d81e 100644
--- a/engines/ngi/fullpipe/mobile/sc10controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc10controller.cpp
@@ -68,9 +68,9 @@ void Sc10Controller::doShowGum() {
void Sc10Controller::doTakeGum() {
if (!_gumEnabled)
return;
- const float targetX = (float)_gum->getCenter().x - 139.0f;
- const float targetY = (float)_gum->getCenter().y - 48.0f;
- if (fabsf(targetX - (float)hero()->getCenter().x) > 3.0f || fabsf(targetY - (float)hero()->getCenter().y) > 3.0f ||
+ const float targetX = _gum->getCenterF().x - 139.0f;
+ const float targetY = _gum->getCenterF().y - 48.0f;
+ if (fabsf(targetX - hero()->getCenterF().x) > 3.0f || fabsf(targetY - hero()->getCenterF().y) > 3.0f ||
hero()->_movement) {
MessageQueue *queue = mctlStartMove((int)targetX, (int)targetY, true, ST_MAN_RIGHT, false);
if (queue) {
diff --git a/engines/ngi/fullpipe/mobile/sc11controller.cpp b/engines/ngi/fullpipe/mobile/sc11controller.cpp
index 5fa8be26335..35eb25a3e99 100644
--- a/engines/ngi/fullpipe/mobile/sc11controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc11controller.cpp
@@ -224,7 +224,7 @@ void Sc11Controller::leaveSwing() {
_swingMan->_flags &= ~4;
_swing->_flags |= 4;
_swing->setStatic(ST_KCH_STATIC);
- _swing->setCenter(Common::Point(691, 218));
+ _swing->setCenterF(691.0f, 218.0f);
_swing->_z = 20;
_swing->_rotation = _swingMan->_rotation;
_swingInertia = 0.03;
@@ -232,8 +232,8 @@ void Sc11Controller::leaveSwing() {
// CSc11Controller::TryHitMan (174618): the man is hit by the swing when he stands at x 345 .. 355
void Sc11Controller::tryHitMan() {
- if ((float)hero()->getCenter().x > 345.0f) {
- if ((float)hero()->getCenter().x < 355.0f) {
+ if (hero()->getCenterF().x > 345.0f) {
+ if (hero()->getCenterF().x < 355.0f) {
hero()->setStatic(ST_MAN_RIGHT);
MessageQueue *queue = _scene->findMessageQueue(QU_SC11_MANFALL);
if (queue) {
@@ -247,7 +247,7 @@ void Sc11Controller::tryHitMan() {
// CSc11Controller::DoShowSwing (174698)
void Sc11Controller::doShowSwing() {
_swing->setStatic(ST_KCH_STATIC);
- _swing->setCenter(Common::Point(691, 218));
+ _swing->setCenterF(691.0f, 218.0f);
_swing->_z = 20;
_swing->_flags |= 4;
_swing->_rotation = kRotationDown;
@@ -262,7 +262,7 @@ void Sc11Controller::doMoveSwinger() {
_swingerSwinging = false;
_swingerStands = false;
_swinger->setStatic(ST_SWR_SIT);
- _swinger->setCenter(Common::Point(144, 389));
+ _swinger->setCenterF(144.0f, 389.0f);
g_ngi->setState(sO_Swingie, g_ngi->getStateValue(sO_Swingie, sO_IsSitting));
}
}
@@ -460,7 +460,7 @@ void Sc11Controller::doRetire() {
_swingAngle = 0.0;
_swingMan->_flags &= ~4;
_swing->setStatic(ST_KCH_STATIC);
- _swing->setCenter(Common::Point(691, 218));
+ _swing->setCenterF(691.0f, 218.0f);
_swing->_z = 20;
_swing->_flags |= 4;
hero()->_flags |= 4;
@@ -505,7 +505,7 @@ void Sc11Controller::startArcade() {
_swingMan->_flags |= 4;
_swingMan->_z = 20;
_swingMan->setStatic(ST_MAN11_SWING_0);
- _swingMan->setCenter(Common::Point(691, 218));
+ _swingMan->setCenterF(691.0f, 218.0f);
_swingMan->_rotation = kRotationDown;
_targetX = (1150.0f - ((float)_scene->_x + (float)g_ngi->gameWidth())) + renderMargin();
g_ngi->_aniHandler->detachAllObjects();
@@ -698,8 +698,8 @@ void Sc11Controller::onRButtonDown() {
// CSc11Controller::TryPutBoot (1760A0): the hero walks to (348, 498) and puts the boot on
void Sc11Controller::tryPutBoot() {
- if (fabsf(348.0f - (float)hero()->getCenter().x) <= 3.0f) {
- if (fabsf(498.0f - (float)hero()->getCenter().y) <= 3.0f) {
+ if (fabsf(348.0f - hero()->getCenterF().x) <= 3.0f) {
+ if (fabsf(498.0f - hero()->getCenterF().y) <= 3.0f) {
if (!hero()->_movement && hero()->_statics->_staticsId == ST_MAN_RIGHT) {
doPutBoot();
return;
@@ -714,9 +714,9 @@ void Sc11Controller::tryPutBoot() {
// CSc11Controller::DoManToPipe (176190): the hero walks to (158, 524), then INT_070
void Sc11Controller::doManToPipe() {
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
if (getGameLoaderInteractionController()->_enabled) {
- if (fabsf(158.0f - (float)center.x) > 3.0f || fabsf(524.0f - (float)center.y) > 3.0f) {
+ if (fabsf(158.0f - center.x) > 3.0f || fabsf(524.0f - center.y) > 3.0f) {
MessageQueue *started = mctlStartMove(158, 524, true, ST_MAN_RIGHT, true);
if (started) {
started->addCommandToEnd(messageCommand("MSG_SC11_MAN_TO_PIPE"));
@@ -828,13 +828,13 @@ void Sc11Controller::onShow() {
_swingerStands = false;
_swinger->stopMovement();
_swinger->setStatic(ST_SWR_SIT);
- _swinger->setCenter(Common::Point(144, 389));
+ _swinger->setCenterF(144.0f, 389.0f);
} else {
_swingerSwinging = false;
_swingerStands = false;
_swinger->stopMovement();
_swinger->setStatic(ST_SWR_SITBALD);
- _swinger->setCenter(Common::Point(144, 415));
+ _swinger->setCenterF(144.0f, 415.0f);
}
}
_boots->_flags &= ~4;
@@ -842,7 +842,7 @@ void Sc11Controller::onShow() {
if (!_swingerSwinging) {
_swing->setStatic(ST_KCH_STATIC);
- _swing->setCenter(Common::Point(691, 218));
+ _swing->setCenterF(691.0f, 218.0f);
_swing->_z = 20;
_swing->_rotation = kRotationDown;
_swingMan->_flags &= ~4;
@@ -860,7 +860,7 @@ void Sc11Controller::onShow() {
if (hero()->_statics->_staticsId == ST_MAN11_SWING) {
hero()->setStatic(ST_MAN_RIGHT);
}
- hero()->setCenter(Common::Point(493, 522));
+ hero()->setCenterF(493.0f, 522.0f);
hero()->_z = 10;
}
}
@@ -963,7 +963,7 @@ void Sc11Controller::onUpdate(uint32 elapsed) {
swingNextFunc2(_swingMan);
swingNextFunc2(_swing);
if ((_swing->_flags & 4) && !_swing->_movement) {
- _swing->setCenter(Common::Point(691, 218));
+ _swing->setCenterF(691.0f, 218.0f);
}
}
@@ -1053,9 +1053,9 @@ void Sc11Controller::onMessage(const Common::String &message, const Common::Stri
_swingerStands = false;
_swinger->stopMovement();
_swinger->setStatic(ST_SWR_SITBALD);
- _swinger->setCenter(Common::Point(144, 415));
+ _swinger->setCenterF(144.0f, 415.0f);
_swing->setStatic(ST_KCH_STATIC);
- _swing->setCenter(Common::Point(691, 218));
+ _swing->setCenterF(691.0f, 218.0f);
_swing->_z = 20;
_swingMan->_flags &= ~4;
_swing->_flags |= 4;
@@ -1092,9 +1092,9 @@ void Sc11Controller::updateScroll() {
// INT_071 (the man jumps to the swing) runs while the current command of its queue is not -1
_smooth = _arcadeRunning || interactionCommandNum("INT_071") != -1;
if (_follow) {
- const Common::Point center = _follow->getCenter();
- _heroCenterX = (float)center.x;
- _heroCenterY = (float)center.y;
+ const Vector2 center = _follow->getCenterF();
+ _heroCenterX = center.x;
+ _heroCenterY = center.y;
const float sceneX = (float)_scene->_x;
const int width = g_ngi->gameWidth();
if (_scrollToTube) {
diff --git a/engines/ngi/fullpipe/mobile/sc13controller.cpp b/engines/ngi/fullpipe/mobile/sc13controller.cpp
index f20167625c8..0ad3b972399 100644
--- a/engines/ngi/fullpipe/mobile/sc13controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc13controller.cpp
@@ -316,12 +316,12 @@ void Sc13Controller::updateScroll() {
FPController::updateScroll();
if (!controllerRunsSceneLogic())
return;
- if (_heroLeft && hero()->getCenter().x < 1022.0f) {
+ if (_heroLeft && hero()->getCenterF().x < 1022.0f) {
_scene->runQueue(QU_STR_RTOL);
_heroLeft = false;
return;
}
- if (!_heroLeft && hero()->getCenter().x > 1022.0f) {
+ if (!_heroLeft && hero()->getCenterF().x > 1022.0f) {
_scene->runQueue(QU_STR_LTOR);
_heroLeft = true;
}
@@ -334,7 +334,7 @@ void Sc13Controller::onUpdate(uint32 elapsed) {
return;
bool heroRight = false;
if (isState(sO_Bridge, sO_Convoluted))
- heroRight = hero()->getCenter().x >= 1022.0f;
+ heroRight = hero()->getCenterF().x >= 1022.0f;
getGameLoaderInteractionController()->setActive("INT_095", 0, 0, heroRight ? 0.0f : 1.0f, 0.0f);
}
diff --git a/engines/ngi/fullpipe/mobile/sc14controller.cpp b/engines/ngi/fullpipe/mobile/sc14controller.cpp
index 1fbf14c0610..16221fe7b5a 100644
--- a/engines/ngi/fullpipe/mobile/sc14controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc14controller.cpp
@@ -176,7 +176,7 @@ void Sc14Controller::doShowBallKickman() {
divisor = 1.0f;
_ballDeltaY = (float)((float)(targetY - y) - (float)((float)((float)((float)distance * 0.0f) * (float)distance) * 0.5f)) / divisor;
_flyingBall->_flags |= 4;
- _flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
+ _flyingBall->setCenterF(_ballX, _ballY);
_flyingBall->startMovement(MV_BAL14_SPIN, 0, -1);
_flyingBall->_z = 5;
_ballFlying = true;
@@ -189,7 +189,7 @@ void Sc14Controller::doShowBallFly() {
_balls.pop_front();
}
if (_grandma->_movement) {
- const Common::Point center = _grandma->getCenter();
+ const Vector2 center = _grandma->getCenterF();
_ballX = center.x;
_ballY = center.y;
} else {
@@ -212,7 +212,7 @@ void Sc14Controller::doShowBallFly() {
_ballY = y + deltaY;
_flyingBall->_flags |= 4;
_flyingBall->setStatic(ST_BAL14_MAIN, false);
- _flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
+ _flyingBall->setCenterF(_ballX, _ballY);
_flyingBall->_z = 5;
_flyingBall->startMovement(MV_BAL14_SPIN, 0, -1);
_ballFlying = true;
@@ -225,7 +225,7 @@ void Sc14Controller::doShowBallFallgrandma2() {
const float x = _grandmaX + 223.0f;
const float y = _grandmaY + 35.0f;
_flyingBall->_flags |= 4;
- _flyingBall->setCenter(Common::Point((int)x, (int)y));
+ _flyingBall->setCenterF(x, y);
_flyingBall->setStatic(ST_BAL14_MAIN, false);
_flyingBall->_z = 27;
_pink = _flyingBall;
@@ -238,7 +238,7 @@ void Sc14Controller::doShowBallLast() {
if (_pink) {
_pink->_flags |= 4;
_pink->setStatic(ST_BAL14_MAIN, false);
- _pink->setCenter(Common::Point(693, 491));
+ _pink->setCenterF(693.0f, 491.0f);
_pink->_z = 27;
}
}
@@ -259,7 +259,7 @@ void Sc14Controller::doShowBallDivegrandma() {
const float x = _grandmaX + 506.0f;
const float y = _grandmaY - 29.0f;
_flyingBall->_flags |= 4;
- _flyingBall->setCenter(Common::Point((int)x, (int)y));
+ _flyingBall->setCenterF(x, y);
_balls.push_back(_flyingBall);
_flyingBall = nullptr;
}
@@ -353,7 +353,7 @@ void Sc14Controller::startArcade() {
_manCanKick = true;
if (!hero()->_movement) {
hero()->setStatic(ST_MAN_RIGHT, true);
- hero()->setCenter(Common::Point(1237, 451));
+ hero()->setCenterF(1237.0f, 451.0f);
hero()->_z = 19;
}
_scene->_motionController->deactivate();
@@ -543,7 +543,7 @@ void Sc14Controller::countBallFlight(uint32 elapsed) {
}
}
if (_flyingBall)
- _flyingBall->setCenter(Common::Point((int)_ballX, (int)_ballY));
+ _flyingBall->setCenterF(_ballX, _ballY);
}
// CSc14Controller::DoShowBallFallman (179B70): ball that passed the hero lands behind him
@@ -555,7 +555,7 @@ void Sc14Controller::doShowBallFallman() {
const float y = _manY + 40.0f;
_flyingBall->_flags |= 4;
_flyingBall->setStatic(ST_BAL14_TOGMA, false);
- _flyingBall->setCenter(Common::Point((int)x, (int)y));
+ _flyingBall->setCenterF(x, y);
_flyingBall->_z = 27;
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(movementCommand(ANI_BALL14, MV_BAL14_TOGMA, _flyingBall->_copyId));
@@ -577,7 +577,7 @@ void Sc14Controller::doShowBallFallgrandma() {
const float y = _grandmaY + 56.0f;
_flyingBall->_flags |= 4;
_flyingBall->setStatic(ST_BAL14_TOGMA, false);
- _flyingBall->setCenter(Common::Point((int)x, (int)y));
+ _flyingBall->setCenterF(x, y);
_flyingBall->_z = 27;
MessageQueue *queue = new MessageQueue(_scene, true, 1);
queue->addCommandToEnd(movementCommand(ANI_BALL14, MV_BAL14_TOGMA, _flyingBall->_copyId));
@@ -692,7 +692,7 @@ void Sc14Controller::onShow() {
if (_scene->_currentEntranceId == 0) {
hero()->setStatic(ST_MAN_RIGHT, false);
hero()->_flags |= 8;
- hero()->setCenter(Common::Point(1448, 462));
+ hero()->setCenterF(1448.0f, 462.0f);
hero()->_z = 10;
_scene->_x = 800;
_scene->_y = 0;
@@ -744,16 +744,16 @@ void Sc14Controller::onUpdate(uint32 elapsed) {
manNextFunc(elapsed);
AniObject *man = hero();
if (man->_movement && man->_lastMovementId == MV_MAN14_KICK) {
- const Common::Point center = man->getCenter();
+ const Vector2 center = man->getCenterF();
_manX = center.x;
_manY = center.y;
_manX = _manX + (float)(2 * man->getCurFrame());
} else {
- const Common::Point center = man->getCenter();
+ const Vector2 center = man->getCenterF();
_manX = center.x;
_manY = center.y;
}
- const Common::Point grandmaCenter = _grandma->getCenter();
+ const Vector2 grandmaCenter = _grandma->getCenterF();
_grandmaX = grandmaCenter.x;
_grandmaY = grandmaCenter.y;
if (_ballFlying)
@@ -781,8 +781,8 @@ bool Sc14Controller::onMouseLKeyDown(uint32 id, float x, float y) {
}
} else if (!g_ngi->_inputController->getObject()) {
if (_pink && (_pink->_flags & 4)) {
- const Common::Point center = _pink->getCenter();
- if (x < (float)center.x + 40.0f)
+ const Vector2 center = _pink->getCenterF();
+ if (x < center.x + 40.0f)
return true;
}
}
@@ -817,13 +817,13 @@ bool Sc14Controller::onMouseLKeyUp(uint32 id, float x, float y) {
}
} else if (!g_ngi->_inputController->getObject()) {
if (_pink && (_pink->_flags & 4)) {
- Common::Point center = _pink->getCenter();
- if (x < (float)center.x + 40.0f) {
+ Vector2 center = _pink->getCenterF();
+ if (x < center.x + 40.0f) {
AniObject *ball = _scene->findAniObjectById(_pink->_id, 0);
if (ball->_statics)
ball->setStatic(ball->_statics->_staticsId, false);
- center = _pink->getCenter();
- ball->setCenter(center);
+ center = _pink->getCenterF();
+ ball->setCenterF(center.x, center.y);
if (runInteraction(_scene, _pink->_id))
return canInterrupt;
return true;
diff --git a/engines/ngi/fullpipe/mobile/sc16controller.cpp b/engines/ngi/fullpipe/mobile/sc16controller.cpp
index f003e6b9ac3..fc5493c5f4c 100644
--- a/engines/ngi/fullpipe/mobile/sc16controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc16controller.cpp
@@ -217,8 +217,8 @@ void Sc16Controller::onMugFall() {
void Sc16Controller::onMugClick() {
if (!canInterruptManQueue())
return;
- const Common::Point center = hero()->getCenter();
- if (fabsf(310.0f - (float)center.x) < 3.0f && fabsf(449.0f - (float)center.y) < 3.0f && !hero()->_movement &&
+ const Vector2 center = hero()->getCenterF();
+ if (fabsf(310.0f - center.x) < 3.0f && fabsf(449.0f - center.y) < 3.0f && !hero()->_movement &&
hero()->_statics->_staticsId == ST_MAN_RIGHT) {
doMug();
return;
@@ -315,7 +315,7 @@ void Sc16Controller::onShow() {
if (isState(sO_Girl, sO_IsLaughing)) {
girl->_flags |= 4;
girl->setStatic(ST_GRL_POPA, false);
- girl->setCenter(Common::Point(554, 432));
+ girl->setCenterF(554.0f, 432.0f);
girl->_z = 20;
} else {
girl->stopMovement();
diff --git a/engines/ngi/fullpipe/mobile/sc17controller.cpp b/engines/ngi/fullpipe/mobile/sc17controller.cpp
index b0660ddbaa2..77c0dc2efc1 100644
--- a/engines/ngi/fullpipe/mobile/sc17controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc17controller.cpp
@@ -213,12 +213,12 @@ void Sc17Controller::onUpdate(uint32 elapsed) {
FPController::onUpdate(elapsed);
return;
}
- _heroX = hero()->getCenter().x;
+ _heroX = (int)hero()->getCenterF().x;
FPController::onUpdate(elapsed);
if (_sugarShown)
doTakeSugar();
if (_handAsks) {
- const bool left = hero()->getCenter().x < 410;
+ const bool left = hero()->getCenterF().x < 410;
BehaviorController *behavior = _scene->_behaviorController.get();
behavior->getAniQueue(_hand->_id, QU_HND17_TOCYCLE)->setEnabled(left);
behavior->getAniQueue(_hand->_id, QU_HND17_ATTRACT)->setEnabled(left);
diff --git a/engines/ngi/fullpipe/mobile/sc18controller.cpp b/engines/ngi/fullpipe/mobile/sc18controller.cpp
index e3729bb78dd..b92f12ed4f8 100644
--- a/engines/ngi/fullpipe/mobile/sc18controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc18controller.cpp
@@ -144,7 +144,7 @@ void Sc18Controller::prepareGirlTo() {
// CSc18Controller::PrepareManTo (17D978)
void Sc18Controller::prepareManTo() {
debugC(1, kDebugInfo, "INFO t %u SC18 hero boards the swing", g_system->getMillis());
- hero()->setCenter(Common::Point(967, 379));
+ hero()->setCenterF(967.0f, 379.0f);
hero()->setStatic(ST_MAN_RIGHT, false);
hero()->_z = 35;
hero()->startMovement(MV_MAN18_STANDKRESLO, 0, -1);
@@ -171,10 +171,10 @@ void Sc18Controller::tickCellsNoswing() {
// CSc18Controller::DoShowBoyJump (17DA88)
void Sc18Controller::doShowBoyJump() {
debugC(1, kDebugInfo, "INFO t %u SC18 boy jumps off", g_system->getMillis());
- const Common::Point center = _cells[_boyCell].ani->getCenter();
+ const Vector2 center = _cells[_boyCell].ani->getCenterF();
_boy->_flags |= 4;
_boy->setStatic(ST_BOY18_FLYFROM, false);
- _boy->setCenter(Common::Point((int)((float)center.x - 48.0f), (int)((float)center.y + 8.0f)));
+ _boy->setCenterF(center.x - 48.0f, center.y + 8.0f);
_boy->_z = 50;
_boy->startMovement(MV_BOY18_JUMPFROM, 0, -1);
_cells[_boyCell].kind = 1;
@@ -186,13 +186,13 @@ void Sc18Controller::doShowBoyJump() {
// CSc18Controller::DoShowGirlJump (17DB6C)
void Sc18Controller::doShowGirlJump() {
debugC(1, kDebugInfo, "INFO t %u SC18 girl jumps off", g_system->getMillis());
- const Common::Point center = _cells[_boyCell].ani->getCenter();
- float x = (float)center.x - 62.0f;
- float y = (float)center.y - 10.0f;
+ const Vector2 center = _cells[_boyCell].ani->getCenterF();
+ float x = center.x - 62.0f;
+ float y = center.y - 10.0f;
if (_scene->_sceneId == SC_18)
y -= 40.0f;
_girl->_flags |= 4;
- _girl->setCenter(Common::Point((int)x, (int)y));
+ _girl->setCenterF(x, y);
_girl->setStatic(ST_GRL18_FLYFROM, false);
_girl->_z = 50;
_girl->startMovement(MV_GRL18_JUMPFROM, 0, -1);
@@ -229,9 +229,9 @@ void Sc18Controller::doShowGirlJumpto() {
// CSc18Controller::GetManDist (17DD50)
float Sc18Controller::getManDist() {
- const Common::Point center = hero()->getCenter();
- const float dx = 967.0f - (float)center.x;
- const float dy = 379.0f - (float)center.y;
+ const Vector2 center = hero()->getCenterF();
+ const float dx = 967.0f - center.x;
+ const float dy = 379.0f - center.y;
return sqrt((double)(dx * dx + dy * dy));
}
@@ -288,7 +288,7 @@ void Sc18Controller::onCloseUpsell() {
setSaving(true);
hero()->_flags |= 4;
hero()->setStatic(ST_MAN_RIGHT, false);
- hero()->setCenter(Common::Point(967, 379));
+ hero()->setCenterF(967.0f, 379.0f);
_closeUpsell = false;
} else {
g_ngi->_gameLoader->preloadScene(SC_18, 0); // CGame::SetScene
@@ -344,7 +344,7 @@ void Sc18Controller::tickCells() {
x -= 60.0f;
}
}
- ani->setCenter(Common::Point((int)x, (int)y));
+ ani->setCenterF(x, y);
if (_wheelActive) {
const int kind = cell.kind;
if ((kind & 2) && cell.angle >= 2.7925268031909245 && prev < 2.7925268031909245) {
@@ -417,9 +417,9 @@ void Sc18Controller::tickCells() {
// CSc18Controller::DoShowManJump (17E620)
void Sc18Controller::doShowManJump() {
debugC(1, kDebugInfo, "INFO t %u SC18 hero jumps off", g_system->getMillis());
- const Common::Point center = _cells[_manJumpCell].ani->getCenter();
+ const Vector2 center = _cells[_manJumpCell].ani->getCenterF();
hero()->_flags |= 4;
- hero()->setCenter(Common::Point((int)((float)center.x + 62.0f), (int)((float)center.y + 5.0f)));
+ hero()->setCenterF(center.x + 62.0f, center.y + 5.0f);
hero()->setStatic(ST_MAN18_JUMP, false);
hero()->_z = 35;
MessageQueue *queue = nullptr;
@@ -483,8 +483,8 @@ void Sc18Controller::updateNumRides() {
// CSc18Controller::OnBoardClick (17E978)
void Sc18Controller::onBoardClick() {
- const Common::Point center = hero()->getCenter();
- if (fabsf(967.0f - (float)center.x) <= 2.0f && fabsf(379.0f - (float)center.y) <= 2.0f && hero()->getStaticsId() == ST_MAN_RIGHT) {
+ const Vector2 center = hero()->getCenterF();
+ if (fabsf(967.0f - center.x) <= 2.0f && fabsf(379.0f - center.y) <= 2.0f && hero()->getStaticsId() == ST_MAN_RIGHT) {
_manReady = true;
return;
}
@@ -532,7 +532,7 @@ void Sc18Controller::createCells(AniObject *chair) {
cell.ani->_flags |= 4;
else
cell.ani->_flags &= ~4;
- cell.ani->setCenter(Common::Point((int)cell.homeX, (int)cell.homeY));
+ cell.ani->setCenterF(cell.homeX, cell.homeY);
cell.ani->_z = 30;
int movementId;
if (_keepCells) {
@@ -708,8 +708,8 @@ void Sc18Controller::onShow() {
initSwitch1819();
if (_closeUpsell)
onCloseUpsell();
- const Common::Point center = hero()->getCenter();
- if (fabsf(967.0f - (float)center.x) < 2.0f && fabsf(379.0f - (float)center.y) < 2.0f && hero()->getStaticsId() == ST_MAN_RIGHT)
+ const Vector2 center = hero()->getCenterF();
+ if (fabsf(967.0f - center.x) < 2.0f && fabsf(379.0f - center.y) < 2.0f && hero()->getStaticsId() == ST_MAN_RIGHT)
_manReady = true;
}
@@ -761,8 +761,8 @@ int Sc18Controller::getCursorType(float x, float y) {
return FPController::getCursorType(x, y);
if (g_ngi->_inputController->isObjectHit(PIC_SC18_LADDER1)) {
- const Common::Point center = hero()->getCenter();
- if ((float)center.y <= 250.0f)
+ const Vector2 center = hero()->getCenterF();
+ if (center.y <= 250.0f)
return 2;
return 4;
}
@@ -926,7 +926,7 @@ void Sc18Controller::defaultScroll() {
}
if (_follow) {
- const Common::Point center = _follow->getCenter();
+ const Vector2 center = _follow->getCenterF();
_heroCenterX = center.x;
_heroCenterY = center.y;
}
diff --git a/engines/ngi/fullpipe/mobile/sc21controller.cpp b/engines/ngi/fullpipe/mobile/sc21controller.cpp
index a1eb895a48e..8d708913b93 100644
--- a/engines/ngi/fullpipe/mobile/sc21controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc21controller.cpp
@@ -48,7 +48,7 @@ Sc21Controller::~Sc21Controller() {
// CSc21Controller::MoveTheAss (180D88): the hanging giraffe swings sideways
void Sc21Controller::moveTheAss(uint32 elapsed) {
const int offset = (int)(cos(_angle) * 10.0);
- _giraffe->setCenter(Common::Point((int)(_giraffeX + (float)offset), (int)_giraffeY));
+ _giraffe->setCenterF(_giraffeX + (float)offset, _giraffeY);
const double angle = (double)elapsed * 0.19635 / 40.0 + _angle;
if (angle > 6.28318530717958)
_angle = angle - 6.28318530717958;
@@ -100,7 +100,7 @@ void Sc21Controller::onShow() {
_giraffe->moveToStaticChain(ST_GRFB_HANG);
_swinging = true;
_angle = 0.0;
- const Common::Point center = _giraffe->getCenter();
+ const Vector2 center = _giraffe->getCenterF();
_giraffeX = center.x;
_giraffeY = center.y;
if (pipe->_hitRegion.left != 50) {
@@ -146,7 +146,7 @@ void Sc21Controller::onMessage(const Common::String &message, const Common::Stri
if (!isState(sO_LowerPipe_21, sO_IsOpened))
return;
_giraffe->setStatic(ST_GRFB_HANG, false);
- _giraffe->setCenter(Common::Point((int)_giraffeX, (int)_giraffeY));
+ _giraffe->setCenterF(_giraffeX, _giraffeY);
_giraffe->moveToStaticChain(ST_GRFB_SIT);
_swinging = false;
g_ngi->setState(sO_LowerPipe_21, g_ngi->getStateValue(sO_LowerPipe_21, sO_IsClosed));
diff --git a/engines/ngi/fullpipe/mobile/sc22controller.cpp b/engines/ngi/fullpipe/mobile/sc22controller.cpp
index ced0f310f4a..737a5830607 100644
--- a/engines/ngi/fullpipe/mobile/sc22controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc22controller.cpp
@@ -159,8 +159,8 @@ void Sc22Controller::onClickHandle(bool fromQueue) {
CursorController *cursor = g_ngi->_inputController;
if (cursor->getObjectId() == PIC_INV_STOOL) {
- const Common::Point center = hero()->getCenter();
- if (fabsf(841.0f - (float)center.x) <= 3.0f && fabsf(449.0f - (float)hero()->getCenter().y) <= 3.0f &&
+ const Vector2 center = hero()->getCenterF();
+ if (fabsf(841.0f - center.x) <= 3.0f && fabsf(449.0f - hero()->getCenterF().y) <= 3.0f &&
hero()->_statics->_staticsId == ST_MAN_RIGHT) {
setSaving(false);
g_ngi->_inventory->removeItem("ANI_INV_STOOL", -1);
@@ -184,8 +184,8 @@ void Sc22Controller::onClickHandle(bool fromQueue) {
AniObject *stool = _scene->findAniObjectById(ANI_TABURETTE, 0);
if (stool && (stool->_flags & 4))
return;
- const Common::Point center = hero()->getCenter();
- if (fabsf(841.0f - (float)center.x) <= 3.0f && fabsf(449.0f - (float)hero()->getCenter().y) <= 3.0f &&
+ const Vector2 center = hero()->getCenterF();
+ if (fabsf(841.0f - center.x) <= 3.0f && fabsf(449.0f - hero()->getCenterF().y) <= 3.0f &&
hero()->_statics->_staticsId == ST_MAN_UP) {
_scene->runQueueWithAni(QU_SC22_TRYBOX, hero(), 2);
cursor->setObject(nullptr, 0, 0);
@@ -212,8 +212,8 @@ void Sc22Controller::onClickHandle(bool fromQueue) {
return;
}
if (_stool && (_stool->_flags & 4)) {
- const Common::Point center = hero()->getCenter();
- if (fabsf(841.0f - (float)center.x) > 15.0f || fabsf(449.0f - (float)hero()->getCenter().y) > 15.0f ||
+ const Vector2 center = hero()->getCenterF();
+ if (fabsf(841.0f - center.x) > 15.0f || fabsf(449.0f - hero()->getCenterF().y) > 15.0f ||
hero()->_statics->_staticsId != ST_MAN_RIGHT) {
MessageQueue *queue = mctlStartMove(841, 449, true, ST_MAN_RIGHT, false);
if (!queue)
@@ -228,8 +228,8 @@ void Sc22Controller::onClickHandle(bool fromQueue) {
_busy = true;
return;
}
- const Common::Point center = hero()->getCenter();
- if (fabsf(1010.0f - (float)center.x) > 15.0f || fabsf(443.0f - (float)hero()->getCenter().y) > 15.0f ||
+ const Vector2 center = hero()->getCenterF();
+ if (fabsf(1010.0f - center.x) > 15.0f || fabsf(443.0f - hero()->getCenterF().y) > 15.0f ||
hero()->_statics->_staticsId != ST_MAN_UP) {
MessageQueue *queue = mctlStartMove(1010, 443, true, ST_MAN_UP, false);
if (!queue)
diff --git a/engines/ngi/fullpipe/mobile/sc23controller.cpp b/engines/ngi/fullpipe/mobile/sc23controller.cpp
index b2078414eae..2f516ad6697 100644
--- a/engines/ngi/fullpipe/mobile/sc23controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc23controller.cpp
@@ -70,8 +70,8 @@ Sc23Controller::~Sc23Controller() {
void Sc23Controller::checkOnCalendar() {
bool onCalendar = false;
if (!hero()->_movement && hero()->getStaticsId() == ST_MAN_STANDLADDER) {
- if (hero()->getCenter().x == 405) {
- if (hero()->getCenter().y == 220)
+ if (hero()->getCenterF().x == 405.0f) {
+ if (hero()->getCenterF().y == 220.0f)
onCalendar = true;
}
}
@@ -299,18 +299,18 @@ void Sc23Controller::onBtnClick() {
return;
}
- Common::Point center = hero()->getCenter();
+ Vector2 center = hero()->getCenterF();
if (isNear(center.x, 405)) {
- center = hero()->getCenter();
+ center = hero()->getCenterF();
if (isNear(center.y, 220)) {
_onCalendar = true;
return;
}
}
- center = hero()->getCenter();
+ center = hero()->getCenterF();
bool mirror = isNear(center.x, 276);
if (mirror) {
- center = hero()->getCenter();
+ center = hero()->getCenterF();
mirror = isNear(center.y, 438);
if (mirror) {
if (hero()->_movement) {
@@ -433,14 +433,14 @@ void Sc23Controller::onShow() {
if (g_ngi->getState(sO_UpperHatch_23) == sO_Opened)
giraffeeShown = (_giraffee->_flags & 4) != 0;
if (giraffeeShown)
- _kiss->setCenter(Common::Point(614, 362));
+ _kiss->setCenterF(614.0f, 362.0f);
else
- _kiss->setCenter(Common::Point(618, 350));
+ _kiss->setCenterF(618.0f, 350.0f);
if (canStartKiss())
_wheels[1]->setStatic(ST_CND_5, false);
}
_scene->findAniObjectById(ANI_LUK23_D, 0)->moveToStaticChain(ST_LUK23_OPEN);
- _scene->findAniObjectById(ANI_TABURETTE, 0)->setCenter(Common::Point(700, 535));
+ _scene->findAniObjectById(ANI_TABURETTE, 0)->setCenterF(700.0f, 535.0f);
} else {
_kiss->_flags &= ~4;
_scene->findAniObjectById(ANI_LUK23_D, 0)->moveToStaticChain(ST_LUK23_CLOSED);
@@ -626,7 +626,7 @@ void Sc23MiniController::onShow() {
button->_flags |= 4;
buttonX += _buttonOffsets[i * 2];
buttonY += _buttonOffsets[i * 2 + 1];
- button->setCenter(Common::Point((int)buttonX, (int)buttonY));
+ button->setCenterF(buttonX, buttonY);
wheel = new AniObject(wheel);
wheel->assignCopyId(&_scene->_aniObjects);
@@ -634,7 +634,7 @@ void Sc23MiniController::onShow() {
wheel->_flags |= 4;
wheelX += _wheelOffsets[i * 2];
wheelY += _wheelOffsets[i * 2 + 1];
- wheel->setCenter(Common::Point((int)wheelX, (int)wheelY));
+ wheel->setCenterF(wheelX, wheelY);
_buttons.push_back(button);
_wheels.push_back(wheel);
diff --git a/engines/ngi/fullpipe/mobile/sc25controller.cpp b/engines/ngi/fullpipe/mobile/sc25controller.cpp
index fd14b340a26..a86f3237fde 100644
--- a/engines/ngi/fullpipe/mobile/sc25controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc25controller.cpp
@@ -50,13 +50,13 @@ bool isNear(float value, float target) {
// CUtils::ResetManLadderQueue (14FADC)
void resetManLadderQueue(AniObject *man, float x, float y, MessageQueue *queue) {
- const Common::Point center = man->getCenter();
+ const Vector2 center = man->getCenterF();
float centerY = center.y;
if (!man->_movement) {
// CAniObject::GetMovement() is 0 while the hero has no movement
Movement *current = nullptr;
if (current) {
- const Common::Point size = current->getCenterMovementSize(0, -1);
+ const Vector2 size = current->getCenterMovementSizeF(0, -1);
centerY -= size.y;
}
}
@@ -77,7 +77,7 @@ void resetManLadderQueue(AniObject *man, float x, float y, MessageQueue *queue)
bestDistance = (int)ABS(nextY - centerY);
bestIndex = cur;
}
- const Common::Point size = movement->getCenterMovementSize(0, -1);
+ const Vector2 size = movement->getCenterMovementSizeF(0, -1);
nextX += size.x;
nextY += size.y;
}
@@ -88,13 +88,13 @@ void resetManLadderQueue(AniObject *man, float x, float y, MessageQueue *queue)
Command *first = queue->getCommandByIndex(0);
if (man->_movement || !first || man->_lastMovementId != first->_cmd) {
- man->setCenter(Common::Point((int)bestX, (int)bestY));
+ man->setCenterF(bestX, bestY);
man->setQueue(nullptr);
} else {
queue->removeCommand(0, true);
const int num = queue->getCurCommandNum();
man->setStatic(man->_lastMovementId, false);
- man->setCenter(Common::Point((int)bestX, (int)bestY));
+ man->setCenterF(bestX, bestY);
man->_lastMovementId = num;
}
}
@@ -133,7 +133,7 @@ void Sc25Controller::tryPutBoard() {
void Sc25Controller::tryRowHand() {
hero()->stopMovement(false);
hero()->setStatic(hero()->getStaticsId(), (hero()->_flags & 8) != 0);
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
if (hero()->getStaticsId() != ST_MAN25_ONBOARD)
return;
@@ -163,7 +163,7 @@ void Sc25Controller::tryWater() {
void Sc25Controller::showBoardL() {
_board->_flags |= 4;
_board->setStatic(ST_BRD25_RIGHT2, false);
- _board->setCenter(Common::Point(453, 557));
+ _board->setCenterF(453.0f, 557.0f);
_board->_z = 28;
}
@@ -171,7 +171,7 @@ void Sc25Controller::showBoardL() {
void Sc25Controller::showBoardLClose() {
_board->_flags |= 4;
_board->setStatic(ST_BRD25_RIGHT2, true);
- _board->setCenter(Common::Point(632, 557));
+ _board->setCenterF(632.0f, 557.0f);
_board->_z = 28;
}
@@ -236,7 +236,7 @@ bool Sc25Controller::trySwitchUp() {
void Sc25Controller::tryRow() {
hero()->stopMovement(false);
hero()->setStatic(hero()->getStaticsId(), (hero()->_flags & 8) != 0);
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
if (hero()->getStaticsId() != ST_MAN25_ONBOARD)
return;
@@ -260,7 +260,7 @@ void Sc25Controller::tryRow() {
void Sc25Controller::tryBoardToTruba() {
hero()->stopMovement(false);
hero()->setStatic(hero()->getStaticsId(), (hero()->_flags & 8) != 0);
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
if (hero()->getStaticsId() != ST_MAN25_ONBOARD)
return;
@@ -273,7 +273,7 @@ void Sc25Controller::tryBoardToTruba() {
return;
if (!isNear(center.x, 633))
return;
- if ((float)center.y - 502.0f > 3.0f)
+ if (center.y - 502.0f > 3.0f)
return;
hero()->setStatic(ST_MAN25_ONBOARD, true);
if (!_scene->runQueueWithAni(QU_SC25_MANTOTRUBA_R, hero(), 2))
@@ -285,7 +285,7 @@ void Sc25Controller::tryBoardToTruba() {
// CSc25Controller::TryGetBoard (1856FC)
void Sc25Controller::tryGetBoard(int itemId) {
hero()->stopMovement(false);
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
if (!isNear(center.x, 788) || !isNear(center.y, 468))
return;
@@ -366,11 +366,11 @@ void Sc25Controller::tryBearded() {
void Sc25Controller::tryBoardToLadder() {
hero()->stopMovement(false);
hero()->setStatic(hero()->getStaticsId(), (hero()->_flags & 8) != 0);
- const Common::Point center = hero()->getCenter();
+ const Vector2 center = hero()->getCenterF();
if (hero()->getStaticsId() != ST_MAN25_ONBOARD)
return;
- if ((hero()->_flags & 8) && isNear(center.x, 191) && (float)center.y - 502.0f <= 3.0f) {
+ if ((hero()->_flags & 8) && isNear(center.x, 191) && center.y - 502.0f <= 3.0f) {
hero()->setStatic(ST_MAN25_ONBOARD, true);
if (!_scene->runQueueWithAni(QU_SC25_BOARDTOLADDER, hero(), 2))
warning("sc25::TryBoardToLadder: m_scene->RunQueue() returned false!");
diff --git a/engines/ngi/fullpipe/mobile/sc26controller.cpp b/engines/ngi/fullpipe/mobile/sc26controller.cpp
index f1d6b8f4364..49be26c2f1f 100644
--- a/engines/ngi/fullpipe/mobile/sc26controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc26controller.cpp
@@ -209,11 +209,11 @@ bool Sc26Controller::onClickVent(AniObject *vent) {
if (hero()->getMessageQueue())
return false;
_activeVent = vent;
- const Common::Point ventCenter = vent->getCenter();
- const float x = (float)ventCenter.x - 19.0f;
- const float y = (float)ventCenter.y + 61.0f;
- const Common::Point heroCenter = hero()->getCenter();
- if (fabsf(x - (float)heroCenter.x) > 3.0f || fabsf(y - (float)heroCenter.y) > 3.0f || hero()->_movement) {
+ const Vector2 ventCenter = vent->getCenterF();
+ const float x = ventCenter.x - 19.0f;
+ const float y = ventCenter.y + 61.0f;
+ const Vector2 heroCenter = hero()->getCenterF();
+ if (fabsf(x - heroCenter.x) > 3.0f || fabsf(y - heroCenter.y) > 3.0f || hero()->_movement) {
MessageQueue *queue = mctlStartMove((int)x, (int)y, true, ST_MAN_UP, false);
if (queue) {
queue->addCommandToEnd(messageCommand("MSG_SC26_CLICKVENT", 0, 2,
diff --git a/engines/ngi/fullpipe/mobile/sc27controller.cpp b/engines/ngi/fullpipe/mobile/sc27controller.cpp
index 9abecc1224a..15cbc41f918 100644
--- a/engines/ngi/fullpipe/mobile/sc27controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc27controller.cpp
@@ -384,7 +384,7 @@ void Sc27Controller::stopDrag() {
void Sc27Controller::showNextBet() {
if (_nextBet) {
_nextBet->setStatic(ST_BTA_NORM);
- _nextBet->setCenter(Common::Point(186, 527));
+ _nextBet->setCenterF(186.0f, 527.0f);
_nextBet->_z = 5;
_nextBet->_flags |= 4;
} else {
@@ -563,8 +563,8 @@ void Sc27Controller::onStopAll() {
// CSc27Controller::OnBetClick (189B88): MSG_SC27_CLICKBET: the hero walks to (181, 456), takes it
void Sc27Controller::onBetClick(MessageQueue *queue) {
- const Common::Point betCenter = _nextBet->getCenter();
- if (betCenter.x != 186 || betCenter.y != 527)
+ const Vector2 betCenter = _nextBet->getCenterF();
+ if (betCenter.x != 186.0f || betCenter.y != 527.0f)
return;
if (g_ngi->arcadeInterface().getState() == ArcadeInterface::kHidden) {
@@ -573,11 +573,11 @@ void Sc27Controller::onBetClick(MessageQueue *queue) {
}
bool mirror;
- Common::Point heroCenter = hero()->getCenter();
+ Vector2 heroCenter = hero()->getCenterF();
if (ABS(181.0f - heroCenter.x) > 3.0f) {
mirror = false;
} else {
- heroCenter = hero()->getCenter();
+ heroCenter = hero()->getCenterF();
if (ABS(456.0f - heroCenter.y) > 3.0f) {
mirror = false;
} else if (hero()->_movement) {
@@ -633,16 +633,16 @@ void Sc27Controller::doShootBet(AniObject *ani) {
bet._power = (float)((float)_launchPhase * _shootParamMult + _shootParamAdd);
bet._powerCos = bet._power;
bet._powerSin = bet._power * 0.0;
- Common::Point center = hero()->getCenter();
+ Vector2 center = hero()->getCenterF();
bet._x = center.x;
- center = hero()->getCenter();
+ center = hero()->getCenterF();
const double angle = bet._angle;
const double centerY = center.y;
const double power = bet._power;
const double x = power * cos(angle) + 42.0 + bet._x;
bet._x = x;
bet._y = power * sin(angle) + 63.0 + centerY;
- ani->setCenter(Common::Point((int)x, (int)bet._y));
+ ani->setCenterF((float)(int)x, (float)(int)bet._y);
ani->_flags |= 4;
_bets.push_back(bet);
debugC(1, kDebugInfo, "INFO t %u SC27 bet thrown, power %d", g_system->getMillis(), (int)bet._power);
@@ -676,7 +676,7 @@ void Sc27Controller::recalcBets() {
for (int i = 0; i < (int)_bets.size(); ++i) {
_bets[i]._x = _bets[i]._x + cos(_bets[i]._angle) * _bets[i]._power;
_bets[i]._y = _bets[i]._y + sin(_bets[i]._angle) * _bets[i]._power;
- _bets[i]._ani->setCenter(Common::Point((int)_bets[i]._x, (int)_bets[i]._y));
+ _bets[i]._ani->setCenterF((float)(int)_bets[i]._x, (float)(int)_bets[i]._y);
_bets[i]._ani->_z = (int)(600.0 - _bets[i]._y);
float friction;
@@ -712,7 +712,7 @@ void Sc27Controller::recalcBets() {
} else {
_fallenBets[j]._x = _fallenBets[j]._x + _fallenBets[j]._powerCos;
_fallenBets[j]._y = _fallenBets[j]._y + _fallenBets[j]._powerSin;
- _fallenBets[j]._ani->setCenter(Common::Point((int)_fallenBets[j]._x, (int)_fallenBets[j]._y));
+ _fallenBets[j]._ani->setCenterF((float)(int)_fallenBets[j]._x, (float)(int)_fallenBets[j]._y);
_fallenBets[j]._powerSin = _fallenBets[j]._powerSin + 1.0;
}
}
@@ -733,7 +733,7 @@ void Sc27Controller::generateTest() {
first._y = doubleFromWords(0x40731000, 0);
first._powerCos = doubleFromWords(0x402E0000, 0);
first._powerSin = 0.0;
- first._ani->setCenter(Common::Point(100, 305));
+ first._ani->setCenterF(100.0f, 305.0f);
first._ani->_flags |= 4;
_bets.push_back(first);
@@ -745,7 +745,7 @@ void Sc27Controller::generateTest() {
second._y = doubleFromWords(0x40727000, 0);
second._powerCos = doubleFromWords(0xC02E0000, 0);
second._powerSin = doubleFromWords(0x3DE50ACF, 0x743C301D);
- second._ani->setCenter(Common::Point(700, 295));
+ second._ani->setCenterF(700.0f, 295.0f);
second._ani->_flags |= 4;
_bets.push_back(second);
}
@@ -793,13 +793,13 @@ void Sc27Controller::onShow() {
_powerArrow->_scaleX = _arrowScale;
_powerArrow->_scaleY = 1.0f;
_powerArrow->setPosition(Common::Point(220, 450)); // SetPos(220, 450, z): the z stays
- const Common::Point arrowCenter = _powerArrow->getCenter();
+ const Vector2 arrowCenter = _powerArrow->getCenterF();
_arrowCenterX = arrowCenter.x;
_arrowCenterY = arrowCenter.y;
_batHandler = _scene->findAniObjectById(ANI_BITAHANDLER, 0);
_batHandler->setStatic(ST_BTH_4);
- _batHandler->setCenter(Common::Point(58, 513));
+ _batHandler->setCenterF(58.0f, 513.0f);
_arcadeRunning = false;
AniObject *bet = _scene->findAniObjectById(ANI_BITA, 0);
@@ -922,7 +922,7 @@ void Sc27Controller::onRender(Common::Point scroll) {
if (_powerArrow && _aiming && _manAnimating) {
_powerArrow->_scaleX = _arrowScale;
_powerArrow->_scaleY = 1.0f;
- _powerArrow->setCenter(Common::Point((int)_arrowCenterX, (int)_arrowCenterY));
+ _powerArrow->setCenterF(_arrowCenterX, _arrowCenterY);
}
}
diff --git a/engines/ngi/fullpipe/mobile/sc28controller.cpp b/engines/ngi/fullpipe/mobile/sc28controller.cpp
index ad2b2a47e2e..429fc0ae2b8 100644
--- a/engines/ngi/fullpipe/mobile/sc28controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc28controller.cpp
@@ -213,8 +213,8 @@ void Sc28Controller::onClickLift(uint lift) {
if (lift == 0)
staticsId = ST_MAN_RIGHT;
}
- const Common::Point center = hero()->getCenter();
- if (fabsf(x - (float)center.x) > 20.0f || fabsf(y - (float)hero()->getCenter().y) > 20.0f ||
+ const Vector2 center = hero()->getCenterF();
+ if (fabsf(x - center.x) > 20.0f || fabsf(y - hero()->getCenterF().y) > 20.0f ||
hero()->_movement || staticsId != hero()->_statics->_staticsId) {
if (!_scene->isQueueStarted(QU_SC28_WMN_START) && !_scene->isQueueStarted(QU_WMN_SHOWBEFORE) &&
!_scene->isQueueStarted(QU_SC28_ENTERWMN) && !_scene->isQueueStarted(QU_SC28_WORKINSIDE) &&
diff --git a/engines/ngi/fullpipe/mobile/sc32controller.cpp b/engines/ngi/fullpipe/mobile/sc32controller.cpp
index dbafa487309..2cd5c5e50b8 100644
--- a/engines/ngi/fullpipe/mobile/sc32controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc32controller.cpp
@@ -154,7 +154,7 @@ void Sc32Controller::onCloseUpsell() {
g_ngi->_inventory->addItem("ANI_INV_MUGFULL", 1);
}
hero()->setStatic(ST_MAN_RIGHT, true);
- hero()->setCenter(Common::Point(645, 466));
+ hero()->setCenterF(645.0f, 466.0f);
_sitting = false;
_cactusCounter = -1;
_cactusStarted = false;
@@ -235,7 +235,7 @@ void Sc32Controller::onShow() {
if (_sitting || _cactusStarted) {
hero()->setStatic(ST_MAN_RIGHT, true);
- hero()->setCenter(Common::Point(645, 466));
+ hero()->setCenterF(645.0f, 466.0f);
}
_sitting = false;
_cactusCounter = -1;
diff --git a/engines/ngi/fullpipe/mobile/sc33controller.cpp b/engines/ngi/fullpipe/mobile/sc33controller.cpp
index c79c051d6c4..3b695d31ff3 100644
--- a/engines/ngi/fullpipe/mobile/sc33controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc33controller.cpp
@@ -181,11 +181,11 @@ void Sc33Controller::onShow() {
if (!(_mug->_flags & 4)) {
if (isState(sO_Mug, sO_In_33_OnTap)) {
_mug->setStatic(ST_MUG33_EMPTY, false);
- _mug->setCenter(Common::Point(652, 65));
+ _mug->setCenterF(652.0f, 65.0f);
_mug->_flags |= 4;
} else if (isState(sO_Mug, sO_In_33_OnFloor)) {
_mug->setStatic(ST_MUG33_FALL, false);
- _mug->setCenter(Common::Point(653, 531));
+ _mug->setCenterF(653.0f, 531.0f);
_mug->_flags |= 4;
}
}
diff --git a/engines/ngi/fullpipe/mobile/sc34controller.cpp b/engines/ngi/fullpipe/mobile/sc34controller.cpp
index 3a615600e26..f90b563db84 100644
--- a/engines/ngi/fullpipe/mobile/sc34controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc34controller.cpp
@@ -195,9 +195,9 @@ void Sc34Controller::onTestVent() {
bool Sc34Controller::onMouseDown(float x, float y) {
if (hero()->_movement)
return false;
- const Common::Point center = hero()->getCenter();
- const float heroX = (float)center.x;
- const float heroY = (float)center.y;
+ const Vector2 center = hero()->getCenterF();
+ const float heroX = center.x;
+ const float heroY = center.y;
GameObject *under = _scene->findAniObjectAt(x, y);
MessageQueue *queue;
if (under && under->_id == ANI_VENT_34) {
diff --git a/engines/ngi/fullpipe/mobile/sc37controller.cpp b/engines/ngi/fullpipe/mobile/sc37controller.cpp
index c9ed1f8c57c..f0b3f097ea2 100644
--- a/engines/ngi/fullpipe/mobile/sc37controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc37controller.cpp
@@ -123,7 +123,7 @@ void Sc37Controller::onShow() {
for (int i = 0; i <= 12; i++) {
_scene->findAniObjectById(ANI_RING, i)->setStatic(ST_RNG_OPEN, false);
- _scene->findAniObjectById(ANI_RING, i)->setCenter(Common::Point(299 - 20 * i, 444));
+ _scene->findAniObjectById(ANI_RING, i)->setCenterF((float)(299 - 20 * i), 444.0f);
}
_guards.clear();
_lastHeroX = -1;
@@ -242,7 +242,7 @@ void Sc37Controller::updateScroll() {
}
if (!_follow)
return;
- const Common::Point center = _follow->getCenter();
+ const Vector2 center = _follow->getCenterF();
_heroCenterY = center.y;
_heroCenterX = center.x;
if (_heroCenterX < 500.0f) {
diff --git a/engines/ngi/fullpipe/mobile/sc38controller.cpp b/engines/ngi/fullpipe/mobile/sc38controller.cpp
index 42dcf22fcbd..a0b8a65d6d2 100644
--- a/engines/ngi/fullpipe/mobile/sc38controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc38controller.cpp
@@ -182,8 +182,8 @@ void Sc38Controller::onHmrKick() {
_shortyChatter._counter = 0;
}
}
- const Common::Point center = _domino1->getCenter();
- _domino1->setCenter(Common::Point(center.x, center.y - 2));
+ const Vector2 center = _domino1->getCenterF();
+ _domino1->setCenterF(center.x, center.y - 2.0f);
const int state = _dominos->_statics->_staticsId;
if (state == ST_DMS_3)
_dominos->startMovement(MV_DMS_THREE, 0, -1);
@@ -193,8 +193,8 @@ void Sc38Controller::onHmrKick() {
// CSc38Controller::OnPostHmrKick (195EC4)
void Sc38Controller::onPostHmrKick() {
- const Common::Point center = _domino1->getCenter();
- _domino1->setCenter(Common::Point(center.x, center.y + 2));
+ const Vector2 center = _domino1->getCenterF();
+ _domino1->setCenterF(center.x, center.y + 2.0f);
}
// CSc38Controller::OnDrink (195F00)
diff --git a/engines/ngi/fullpipe/mobile/scfinalcontroller.cpp b/engines/ngi/fullpipe/mobile/scfinalcontroller.cpp
index a9050b66c7f..7a7b6c95d26 100644
--- a/engines/ngi/fullpipe/mobile/scfinalcontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/scfinalcontroller.cpp
@@ -139,7 +139,7 @@ void ScFinalController::onShow() {
void ScFinalController::onUpdate(uint32 elapsed) {
FPController::onUpdate(elapsed);
if (_follow) {
- _coinX = _follow->getCenter().x;
+ _coinX = (int)_follow->getCenterF().x;
if (_coinX <= 449 && _lastCoinX > 449)
doFallCoin();
_lastCoinX = _coinX;
diff --git a/engines/ngi/fullpipe/mobile/tremble.cpp b/engines/ngi/fullpipe/mobile/tremble.cpp
index 65fccce2c57..40207b26192 100644
--- a/engines/ngi/fullpipe/mobile/tremble.cpp
+++ b/engines/ngi/fullpipe/mobile/tremble.cpp
@@ -136,7 +136,8 @@ void TrembleItem::update(uint32 elapsed, int itemCount) {
void TrembleItem::preRender() {
if (!_effect)
return;
- _effect->setCenter(_object->getCenter() + Common::Point(_offsetX, _offsetY));
+ const Vector2 center = _object->getCenterF();
+ _effect->setCenterF(center.x + (float)_offsetX, center.y + (float)_offsetY);
_effect->_z = _object->_z - 1;
}
diff --git a/engines/ngi/gfx.cpp b/engines/ngi/gfx.cpp
index d4ac0be65b4..4b8c8df5935 100644
--- a/engines/ngi/gfx.cpp
+++ b/engines/ngi/gfx.cpp
@@ -436,6 +436,11 @@ void GameObject::setPosition(Common::Point pos) {
setTopLeft(pos);
}
+// the float form of CVisibleObject::SetPos(vector3) (EEACC)
+void GameObject::setPositionF(float x, float y) {
+ setTopLeftF(x, y);
+}
+
Common::Point GameObject::getCenter() const {
Common::Point topLeft;
Common::Point anchor;
diff --git a/engines/ngi/gfx.h b/engines/ngi/gfx.h
index c8a4fb408b7..b36a7ab094e 100644
--- a/engines/ngi/gfx.h
+++ b/engines/ngi/gfx.h
@@ -229,6 +229,7 @@ class GameObject : public CObject {
virtual void setTopLeft(Common::Point topLeft);
/** CVisibleObject::SetPos (11F648): the virtual SetPos (slot 20), the z stays */
virtual void setPosition(Common::Point pos);
+ virtual void setPositionF(float x, float y);
/** CVisibleObject::MoveTo (127BC0) owns the info, Update (127AFE) runs it, StopMoveTo (126D0E) */
void moveTo(MoveToInfo *info);
void updateMoveTo(uint elapsed);
diff --git a/engines/ngi/interaction.cpp b/engines/ngi/interaction.cpp
index 83d5681b2d6..c7c3e26500e 100644
--- a/engines/ngi/interaction.cpp
+++ b/engines/ngi/interaction.cpp
@@ -781,39 +781,43 @@ Common::Point Interact::getHeroPos() {
return Common::Point(0, 0);
hero->stopMovement();
- const Common::Point heroCenter = hero->getCenter();
+ const Vector2 heroCenter = hero->getCenterF();
const int heroStatics = hero->getStaticsId();
const bool heroMirror = (hero->_flags & 8) != 0;
GameObject *object = getObject();
- Common::Point base;
+ Vector2 base;
+ base.x = 0.0f;
+ base.y = 0.0f;
if (object && object->_objtype == kObjTypeStaticANIObject) {
// the object goes into the statics of the interaction to take its center, then back
AniObject *ani = static_cast<AniObject *>(object);
ani->stopMovement();
const int oldStatics = ani->getStaticsId();
const bool oldMirror = (ani->_flags & 8) != 0;
- const Common::Point oldCenter = ani->getCenter();
+ const Vector2 oldCenter = ani->getCenterF();
if (_objectStaticId && oldStatics != _objectStaticId)
ani->moveToStaticChain(_objectStaticId);
- base = ani->getCenter();
+ base = ani->getCenterF();
ani->setStatic(oldStatics, oldMirror);
- ani->setCenter(oldCenter);
+ ani->setCenterF(oldCenter.x, oldCenter.y);
} else if (object) {
- base = object->getPosition();
+ base.x = object->_x;
+ base.y = object->_y;
}
hero->setStatic(_heroStaticId ? _heroStaticId : hero->getStaticsId(), _heroMirror);
// DEVIATION D39: the decompile uses SetPos and GetCenter (half a hero too far); the data say the
// point is the hero's center (scripts/ngi_interact_target_check.py), so SetCenter
- hero->setCenter(Common::Point(base.x + _heroOffsetX, base.y + _heroOffsetY));
- const Common::Point result = hero->getCenter();
- debugC(2, kDebugInfo, "INFO t %u GetHeroPos %s: the object %d at %d,%d (statics %d), the hero at %d,%d size %d,%d, offset %d,%d, hero center %d,%d", g_system->getMillis(),
+ hero->setCenterF(base.x + _heroOffsetX, base.y + _heroOffsetY);
+ const Vector2 result = hero->getCenterF();
+ debugC(2, kDebugInfo, "INFO t %u GetHeroPos %s: the object %d at %g,%g (statics %d), the hero at %d,%d size %d,%d, offset %d,%d, hero center %g,%g", g_system->getMillis(),
_actionName.c_str(), _objectId, base.x, base.y, _objectStaticId, hero->getPosition().x, hero->getPosition().y, hero->getSize().x, hero->getSize().y, _heroOffsetX, _heroOffsetY,
result.x, result.y);
hero->setStatic(heroStatics, heroMirror);
- hero->setCenter(heroCenter);
- return result;
+ hero->setCenterF(heroCenter.x, heroCenter.y);
+ // the original returns the float vector; the locked callers take an int point
+ return Common::Point(static_cast<int>(result.x), static_cast<int>(result.y));
}
static Command *interactMessage(const char *message, const Common::String ¶m) {
@@ -842,8 +846,8 @@ void Interact::run(Scene *scene) {
// a running movement is stopped and restarted at its frame as the first command
const int curFrame = ani->getCurFrame();
Movement *movement = ani->_movement;
- debugC(1, kDebugInfo, "INFO t %u INTERACTION %s: the movement %d of %d runs (frame %d of %d) at %d,%d, center %d,%d", g_system->getMillis(), _actionName.c_str(), movement->_id, ani->_id,
- curFrame, (int)movement->_phases.size(), ani->pivotX(), ani->pivotY(), ani->getCenter().x, ani->getCenter().y);
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION %s: the movement %d of %d runs (frame %d of %d) at %d,%d, center %g,%g", g_system->getMillis(), _actionName.c_str(), movement->_id, ani->_id,
+ curFrame, (int)movement->_phases.size(), ani->pivotX(), ani->pivotY(), ani->getCenterF().x, ani->getCenterF().y);
fromStatics = movement->_nextStatic->_staticsId;
const bool mirror = (ani->_flags & 8) != 0;
ani->stopMovementToPrev(false);
@@ -857,8 +861,8 @@ void Interact::run(Scene *scene) {
}
MessageQueue *linked = ani->getLinkedMovements(fromStatics, _objectStaticId);
- debugC(1, kDebugInfo, "INFO t %u INTERACTION %s runs: the object %d stands at %d,%d (center %d,%d) in the statics %d, wants %d, restart %d, %d linked movements", g_system->getMillis(),
- _actionName.c_str(), ani->_id, ani->pivotX(), ani->pivotY(), ani->getCenter().x, ani->getCenter().y, ani->getStaticsId(), _objectStaticId, restart != nullptr, (int)linked->getCount());
+ debugC(1, kDebugInfo, "INFO t %u INTERACTION %s runs: the object %d stands at %d,%d (center %g,%g) in the statics %d, wants %d, restart %d, %d linked movements", g_system->getMillis(),
+ _actionName.c_str(), ani->_id, ani->pivotX(), ani->pivotY(), ani->getCenterF().x, ani->getCenterF().y, ani->getStaticsId(), _objectStaticId, restart != nullptr, (int)linked->getCount());
if (linked->getCount() != 0 || restart) {
MessageQueue *queue = scene->addInteractionQueue(linked, this);
if (restart)
diff --git a/engines/ngi/inventory.cpp b/engines/ngi/inventory.cpp
index 67f3caf593f..db977f3e9fc 100644
--- a/engines/ngi/inventory.cpp
+++ b/engines/ngi/inventory.cpp
@@ -704,20 +704,23 @@ Common::Point InventoryItem::getPos() const {
}
// CInventoryItem::SetCenter (1088CE)
-void InventoryItem::setCenter(Common::Point center) {
+void InventoryItem::setCenter(float x, float y) {
if (_picturePlate)
- _picturePlate->setCenter(center);
+ _picturePlate->setCenterF(x, y);
else if (_picture)
- _picture->setCenter(center);
+ _picture->setCenterF(x, y);
}
// CInventoryItem::GetCenter (1088F0)
-Common::Point InventoryItem::getCenter() const {
+Vector2 InventoryItem::getCenter() const {
if (_picturePlate)
- return _picturePlate->getCenter();
+ return _picturePlate->getCenterF();
if (_picture)
- return _picture->getCenter();
- return Common::Point();
+ return _picture->getCenterF();
+ Vector2 zero;
+ zero.x = 0.0f;
+ zero.y = 0.0f;
+ return zero;
}
// CInventoryItem::GetSize (108A3E): the picture size includes the scale of the item
@@ -784,17 +787,17 @@ void InventoryItem::render(float scrollX, float scrollY, bool printCounter) {
drawn = _picture;
if (drawn) {
if (_picturePlate) {
- const Common::Point center = _picturePlate->getCenter();
+ const Vector2 center = _picturePlate->getCenterF();
_picturePlate->_scaleX = _scaleX;
_picturePlate->_scaleY = _scaleY;
- _picturePlate->setCenter(center);
+ _picturePlate->setCenterF(center.x, center.y);
const Common::Point pos = getPos();
_picturePlate->renderAtPos(pos.x - scrollX, pos.y - scrollY);
}
- const Common::Point center = _picture->getCenter();
+ const Vector2 center = _picture->getCenterF();
drawn->_scaleX = _scaleX;
drawn->_scaleY = _scaleY;
- drawn->setCenter(center);
+ drawn->setCenterF(center.x, center.y);
const Common::Point pos = getPos();
drawn->renderAtPos((pos.x + _offsetX) - scrollX, (pos.y + _offsetY) - scrollY);
}
@@ -1454,7 +1457,7 @@ void Inventory::recalcItemPos() {
_visibleItems[i]->getSize(width, height);
const float centerX = (_areaX + width * 0.5f) + (float)(i - _firstVisible) * (width + _interval);
_visibleItems[i]->getSize(width, height);
- _visibleItems[i]->setCenter(Common::Point(centerX, _areaY + height * 0.5f));
+ _visibleItems[i]->setCenter(centerX, _areaY + height * 0.5f);
}
}
diff --git a/engines/ngi/inventory.h b/engines/ngi/inventory.h
index dc4d24d4ecf..2531820d809 100644
--- a/engines/ngi/inventory.h
+++ b/engines/ngi/inventory.h
@@ -162,8 +162,8 @@ public:
void setPos(int x, int y);
Common::Point getPos() const;
- void setCenter(Common::Point center);
- Common::Point getCenter() const;
+ void setCenter(float x, float y);
+ Vector2 getCenter() const;
/** CInventoryItem::GetSize: the size of the picture without the scale of the item */
void getSize(float &width, float &height) const;
bool hit(float x, float y) const;
diff --git a/engines/ngi/motion.cpp b/engines/ngi/motion.cpp
index f166739d60d..a737251c030 100644
--- a/engines/ngi/motion.cpp
+++ b/engines/ngi/motion.cpp
@@ -405,14 +405,14 @@ int MctlLadder::getCurrentStep(AniObject *man) {
double delta;
// CMctlLadder::GetCurrentStep (1AD008): the height is the y of the center
- const int manY = g_ngi->_gameVersion >= 201509 ? man->getCenter().y : man->pivotY();
+ const float manY = g_ngi->_gameVersion >= 201509 ? man->getCenterF().y : (float)man->pivotY();
- if ((double)(manY - _y) / (double)_stepY < 0.0)
+ if ((double)(float)(manY - (float)_y) / (double)_stepY < 0.0)
delta = -0.5;
else
delta = 0.5;
- int res = (int)((double)(manY - _y) / (double)_stepY + delta);
+ int res = (int)((double)(float)(manY - (float)_y) / (double)_stepY + delta);
if (res < 0)
return 0;
@@ -549,9 +549,9 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
warning("STUB/untested: CMctlLadder::MakeQueue / StartMove (the ladder of scene 4): played up and down from the foot, from ST_MAN_STANDLADDER and from the idle ST_MAN_LADDERDOWN with the scene 4 controller running the scene (not the shipped state, D02); not played: the cases of the idle statics ST_MAN_GOLADDER / ST_MAN_GOLADDERD and a call while a movement runs");
}
// CMctlLadder::MakeQueue (1AD110): every height is the y of the center of the object
- const int aniY = revised ? ani->getCenter().y : ani->pivotY();
+ const float aniY = revised ? ani->getCenterF().y : (float)ani->pivotY();
double dh = _stepY;
- double corr = (double)(aniY - _y) / dh;
+ double corr = (double)(float)(aniY - (float)_y) / dh;
int dl = (int)(corr + (corr < 0.0 ? -0.5 : 0.5));
corr = (double)(ypos - _y) / dh;
@@ -563,7 +563,7 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
if (dl == dl2 || dl2 < 0)
return nullptr;
- int direction = (normy - aniY) < 0 ? 0 : 1;
+ int direction = ((float)normy - aniY) < 0.0f ? 0 : 1;
MakeQueueStruct mkQueue;
PicAniInfo picinfo;
@@ -677,7 +677,7 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
if (revised) {
// ladder statics: StopMovement(false), SetStatic(statics, 0), step queue, MergeQueue, restore
ani->stopMovement(false);
- const Common::Point center = ani->getCenter();
+ const Vector2 center = ani->getCenterF();
const int oldStatics = ani->getStaticsId();
ani->setStatic(_ladmovements[pos]->staticIds[0], false);
MessageQueue *next = makeQueue(ani, normx, normy, fuzzyMatch, staticsId, mirror);
@@ -686,7 +686,7 @@ MessageQueue *MctlLadder::makeQueue(AniObject *ani, int xpos, int ypos, int fuzz
delete next;
}
ani->setStatic(oldStatics, false);
- ani->setCenter(center);
+ ani->setCenterF(center.x, center.y);
return mq;
}
diff --git a/engines/ngi/physgeom.cpp b/engines/ngi/physgeom.cpp
index 6177d694cb8..062dc4319a8 100644
--- a/engines/ngi/physgeom.cpp
+++ b/engines/ngi/physgeom.cpp
@@ -137,7 +137,7 @@ void VisForPhys::removeVisObj() {
void VisForPhys::setPos(float x, float y) {
if (_visObj)
- _visObj->setCenter(Common::Point(static_cast<int>(x + static_cast<float>(_dx)), static_cast<int>(static_cast<float>(_dy) + y)));
+ _visObj->setCenterF(x + static_cast<float>(_dx), static_cast<float>(_dy) + y);
}
void VisForPhys::setZ(float z) {
diff --git a/engines/ngi/statics.cpp b/engines/ngi/statics.cpp
index a3f5a80bbb9..16a30614d3b 100644
--- a/engines/ngi/statics.cpp
+++ b/engines/ngi/statics.cpp
@@ -347,6 +347,13 @@ void AniObject::setPosition(Common::Point pos) {
setTopLeft(pos);
}
+void AniObject::setPositionF(float x, float y) {
+ if (_oldAni)
+ setOldAniPos(x, y, _z);
+ else
+ setTopLeftF(x, y);
+}
+
void AniObject::clearFlags() {
_flags = 0;
diff --git a/engines/ngi/statics.h b/engines/ngi/statics.h
index 11b831a06a2..60e4694d8a0 100644
--- a/engines/ngi/statics.h
+++ b/engines/ngi/statics.h
@@ -271,6 +271,7 @@ public:
void setPosF(float x, float y);
void setOldAniPos(float x, float y, float z);
void setPosition(Common::Point pos) override;
+ void setPositionF(float x, float y) override;
Statics *getStatic(int id);
Statics *getStaticsByName(const Common::String &name);
Movement *getMovement(int id);
Commit: 8ac95a76882a423aeb65ba229247a9f99d379c83
https://github.com/scummvm/scummvm/commit/8ac95a76882a423aeb65ba229247a9f99d379c83
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: Guard the cells of scene 18 at a cold boot of scene 19
Changed paths:
engines/ngi/fullpipe/mobile/sc18controller.cpp
diff --git a/engines/ngi/fullpipe/mobile/sc18controller.cpp b/engines/ngi/fullpipe/mobile/sc18controller.cpp
index b92f12ed4f8..a1ff9f54326 100644
--- a/engines/ngi/fullpipe/mobile/sc18controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc18controller.cpp
@@ -495,6 +495,9 @@ void Sc18Controller::onBoardClick() {
// CSc18Controller::CreateCells (17EB48)
void Sc18Controller::createCells(AniObject *chair) {
+ // D67: no cells of scene 18 to keep at a cold boot of scene 19
+ if (_keepCells && _cells.size() < 8)
+ _keepCells = false;
Common::Array<WheelCell> cells;
for (int i = 0; i < 8; i++) {
WheelCell cell;
Commit: 1a598e05468dbf09c0013bca67445b0ef4dd7e82
https://github.com/scummvm/scummvm/commit/1a598e05468dbf09c0013bca67445b0ef4dd7e82
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2026-12-06T00:16:22+01:00
Commit Message:
NGI: CFPController::MctlStartMove takes the target as floats
Changed paths:
engines/ngi/fullpipe/mobile/fpcontroller.cpp
engines/ngi/fullpipe/mobile/fpcontroller.h
engines/ngi/fullpipe/mobile/sc09controller.cpp
engines/ngi/fullpipe/mobile/sc10controller.cpp
engines/ngi/fullpipe/mobile/sc26controller.cpp
engines/ngi/fullpipe/mobile/sc28controller.cpp
diff --git a/engines/ngi/fullpipe/mobile/fpcontroller.cpp b/engines/ngi/fullpipe/mobile/fpcontroller.cpp
index fc97bac422d..7c7d6f46c5f 100644
--- a/engines/ngi/fullpipe/mobile/fpcontroller.cpp
+++ b/engines/ngi/fullpipe/mobile/fpcontroller.cpp
@@ -704,13 +704,13 @@ bool FPController::checkTry() const {
}
// CFPController::MctlStartMove
-MessageQueue *FPController::mctlStartMove(int x, int y, bool fuzzy, int staticsId, bool mirror) {
+MessageQueue *FPController::mctlStartMove(float x, float y, bool fuzzy, int staticsId, bool mirror) {
checkQueues();
MotionController *controller = _scene->_motionController.get();
if (controller && (fuzzy || controller->_isEnabled) && canInterruptManQueue()) {
if (g_ngi->_gameVersion >= 201509) {
// MakeQueue (slot 72), the hero's queue stops, the walk runs with the hero as owner (state 0)
- MessageQueue *queue = controller->makeQueue(hero(), x, y, fuzzy, staticsId, mirror);
+ MessageQueue *queue = controller->makeQueue(hero(), (int)x, (int)y, fuzzy, staticsId, mirror);
if (queue) {
if (queue->getCount()) {
interruptManQueue();
@@ -726,7 +726,7 @@ MessageQueue *FPController::mctlStartMove(int x, int y, bool fuzzy, int staticsI
_failedTargetY = y;
return nullptr;
}
- MessageQueue *queue = controller->startMove(hero(), x, y, fuzzy, staticsId, mirror);
+ MessageQueue *queue = controller->startMove(hero(), (int)x, (int)y, fuzzy, staticsId, mirror);
if (queue) {
_lastTargetX = x;
_lastTargetY = y;
@@ -743,7 +743,7 @@ bool FPController::trySwipeMan(float x, float y, bool nearest) {
if ((x != _lastTargetX || y != _lastTargetY) && checkTry()) {
const Vector2 center = hero()->getCenterF();
if (_scene->_motionController->checkPoint(center.x, center.y)) {
- if (mctlStartMove((int)x, (int)y, false, 0, false))
+ if (mctlStartMove(x, y, false, 0, false))
return true;
if (nearest) {
const Common::Point point = _scene->_motionController->getNearestWalkPoint((int)x, (int)y);
@@ -816,7 +816,7 @@ bool FPController::moveBorders(float x, float y) {
if (x <= _heroCenterX) {
if (_leftBorderX < x || _leftBorderX < _heroCenterX) {
if (y > 60.0f && active)
- return mctlStartMove((int)_leftBorderX, (int)_leftBorderY, false, 0, false) != nullptr;
+ return mctlStartMove(_leftBorderX, _leftBorderY, false, 0, false) != nullptr;
}
return false;
}
@@ -824,7 +824,7 @@ bool FPController::moveBorders(float x, float y) {
return false;
if (!active)
return false;
- return mctlStartMove((int)_rightBorderX, (int)_rightBorderY, false, 0, false) != nullptr;
+ return mctlStartMove(_rightBorderX, _rightBorderY, false, 0, false) != nullptr;
}
// CFPController::TryStartInteractMan (SwipeState)
diff --git a/engines/ngi/fullpipe/mobile/fpcontroller.h b/engines/ngi/fullpipe/mobile/fpcontroller.h
index 352b767fdda..4bee228325e 100644
--- a/engines/ngi/fullpipe/mobile/fpcontroller.h
+++ b/engines/ngi/fullpipe/mobile/fpcontroller.h
@@ -138,7 +138,7 @@ public:
void calcFinPoint(float &x, float &y);
void initBorders();
/** CFPController::MctlStartMove */
- MessageQueue *mctlStartMove(int x, int y, bool fuzzy, int staticsId, bool mirror);
+ MessageQueue *mctlStartMove(float x, float y, bool fuzzy, int staticsId, bool mirror);
/** CFPController::InterruptManQueue (148DFE) */
void interruptManQueue();
void forgetQueue(MessageQueue *queue) override;
diff --git a/engines/ngi/fullpipe/mobile/sc09controller.cpp b/engines/ngi/fullpipe/mobile/sc09controller.cpp
index 3d7904f03bd..a310c11ee41 100644
--- a/engines/ngi/fullpipe/mobile/sc09controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc09controller.cpp
@@ -545,7 +545,7 @@ void Sc09Controller::doStartShoot() {
const float targetY = _spitter->getCenterF().y + 145.0f;
_shootIdle = 0;
if (fabsf(targetX - hero()->getCenterF().x) > 3.0f || fabsf(targetY - hero()->getCenterF().y) > 3.0f) {
- MessageQueue *queue = mctlStartMove((int)targetX, (int)targetY, true, ST_MAN_UP, false);
+ MessageQueue *queue = mctlStartMove(targetX, targetY, true, ST_MAN_UP, false);
if (queue)
queue->addCommandToEnd(messageCommand("MSG_SC9_PLVCLICK"));
} else {
diff --git a/engines/ngi/fullpipe/mobile/sc10controller.cpp b/engines/ngi/fullpipe/mobile/sc10controller.cpp
index 1729d44d81e..f2e74250c0f 100644
--- a/engines/ngi/fullpipe/mobile/sc10controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc10controller.cpp
@@ -72,7 +72,7 @@ void Sc10Controller::doTakeGum() {
const float targetY = _gum->getCenterF().y - 48.0f;
if (fabsf(targetX - hero()->getCenterF().x) > 3.0f || fabsf(targetY - hero()->getCenterF().y) > 3.0f ||
hero()->_movement) {
- MessageQueue *queue = mctlStartMove((int)targetX, (int)targetY, true, ST_MAN_RIGHT, false);
+ MessageQueue *queue = mctlStartMove(targetX, targetY, true, ST_MAN_RIGHT, false);
if (queue) {
queue->addCommandToEnd(messageCommand("MSG_SC10_CLICKGUM"));
queue->setIntState(2);
diff --git a/engines/ngi/fullpipe/mobile/sc26controller.cpp b/engines/ngi/fullpipe/mobile/sc26controller.cpp
index 49be26c2f1f..aeec7fd962c 100644
--- a/engines/ngi/fullpipe/mobile/sc26controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc26controller.cpp
@@ -214,7 +214,7 @@ bool Sc26Controller::onClickVent(AniObject *vent) {
const float y = ventCenter.y + 61.0f;
const Vector2 heroCenter = hero()->getCenterF();
if (fabsf(x - heroCenter.x) > 3.0f || fabsf(y - heroCenter.y) > 3.0f || hero()->_movement) {
- MessageQueue *queue = mctlStartMove((int)x, (int)y, true, ST_MAN_UP, false);
+ MessageQueue *queue = mctlStartMove(x, y, true, ST_MAN_UP, false);
if (queue) {
queue->addCommandToEnd(messageCommand("MSG_SC26_CLICKVENT", 0, 2,
Common::String::format("%d", (vent->_copyId << 16) | (uint16)vent->_id).c_str()));
diff --git a/engines/ngi/fullpipe/mobile/sc28controller.cpp b/engines/ngi/fullpipe/mobile/sc28controller.cpp
index 429fc0ae2b8..6bc134dd753 100644
--- a/engines/ngi/fullpipe/mobile/sc28controller.cpp
+++ b/engines/ngi/fullpipe/mobile/sc28controller.cpp
@@ -221,7 +221,7 @@ void Sc28Controller::onClickLift(uint lift) {
!_scene->isQueueStarted(QU_SC28_WMN_END) && !_scene->isQueueStarted(QU_SC28_LIFT1_END) &&
!_scene->isQueueStarted(QU_SC28_LIFT0_FINISH) && !_scene->isQueueStarted(QU_SC28_LIFT0_START)) {
if (!_walkQueue || (_lastTargetX - x) > 10.0f || (_lastTargetY - y) > 10.0f) {
- MessageQueue *queue = mctlStartMove((int)x, (int)y, true, staticsId, false);
+ MessageQueue *queue = mctlStartMove(x, y, true, staticsId, false);
if (queue)
queue->addCommandToEnd(messageCommand("MSG_SC28_CLICKLIFT", 0, 2, Common::String::format("%d", lift).c_str()));
}
More information about the Scummvm-git-logs
mailing list