[Scummvm-git-logs] scummvm master -> e869b314978e6908051e1203bece3f67faa32b4d
aquadran
noreply at scummvm.org
Tue Nov 24 15:11:45 UTC 2026
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
e869b31497 GRIM: Fix GetVisibleThings logic and add FOV
Commit: e869b314978e6908051e1203bece3f67faa32b4d
https://github.com/scummvm/scummvm/commit/e869b314978e6908051e1203bece3f67faa32b4d
Author: Joel Teichroeb (joel at teichroeb.net)
Date: 2026-11-24T16:11:40+01:00
Commit Message:
GRIM: Fix GetVisibleThings logic and add FOV
We previously hardcoded a FOV of 180 degrees, however the original
engine uses 165 degrees. The more correct approach would be to get the
FOV from the head, but it's always 165 so there's no point.
In EMI, the default FOV is 120. I've implemented SetFOV, however it only
ever calls it with 120. This reduces the number of objects he can see,
which is immediately evident on the first scene of the game
GetVisibleThings shouldn't include the actor in its output, and it
should check the actors set, not the current set.
Changed paths:
engines/grim/actor.cpp
engines/grim/actor.h
engines/grim/emi/lua_v2_actor.cpp
engines/grim/lua_v1_actor.cpp
engines/grim/savegame.cpp
diff --git a/engines/grim/actor.cpp b/engines/grim/actor.cpp
index 2e7b94f8f97..096ba67f74d 100644
--- a/engines/grim/actor.cpp
+++ b/engines/grim/actor.cpp
@@ -104,6 +104,8 @@ Actor::Actor() :
// so Chepito in su.set
_turnRate = 100.0f;
+ _fov = g_grim->getGameType() == GType_GRIM ? 165 : 120;
+
_activeShadowSlot = -1;
_shadowArray = new Shadow[MAX_SHADOWS];
}
@@ -268,6 +270,7 @@ void Actor::saveState(SaveGame *savedState) const {
savedState->writeBool(_drawnToClean);
savedState->writeBool(_fakeUnbound);
+ savedState->writeFloat(_fov.getDegrees());
}
bool Actor::restoreState(SaveGame *savedState) {
@@ -489,6 +492,9 @@ bool Actor::restoreState(SaveGame *savedState) {
// by game scripts.
_fakeUnbound = false;
}
+ if (savedState->saveMinorVersion() >= 31) {
+ _fov = savedState->readFloat();
+ }
return true;
}
diff --git a/engines/grim/actor.h b/engines/grim/actor.h
index a6d0715b36f..96a992cf27f 100644
--- a/engines/grim/actor.h
+++ b/engines/grim/actor.h
@@ -317,6 +317,9 @@ public:
*/
Math::Angle getYawTo(const Math::Vector3d &p) const;
+ const Math::Angle &getFOV() const { return _fov; }
+ void setFOV(const Math::Angle &a) { _fov = a; }
+
/**
* Sets the actor visibility.
*
@@ -377,6 +380,8 @@ public:
*/
bool isInSet(const Common::String &setName) const;
+ const Common::String &getCurrentSet() const { return _setName; }
+
/**
* Sets the rate of the turning.
*
@@ -607,6 +612,7 @@ private:
Color _talkColor;
Math::Vector3d _pos;
Math::Angle _pitch, _yaw, _roll;
+ Math::Angle _fov;
float _walkRate, _turnRate;
bool _followBoxes; // Constrain to walkboxes
diff --git a/engines/grim/emi/lua_v2_actor.cpp b/engines/grim/emi/lua_v2_actor.cpp
index 9f3cf1dea33..e3876dcdab5 100644
--- a/engines/grim/emi/lua_v2_actor.cpp
+++ b/engines/grim/emi/lua_v2_actor.cpp
@@ -927,9 +927,7 @@ void Lua_V2::SetActorFOV() {
if (lua_isnumber(fovObj)) {
float fov = lua_getnumber(fovObj);
- // FIXME: implement missing code
- //actor->func(fov); // cos(fov * some tuntime val * 0.5)
- warning("Lua_V2::SetActorFOV: implement opcode. actor: %s, param: %f", actor->getName().c_str(), fov);
+ actor->setFOV(fov);
}
}
diff --git a/engines/grim/lua_v1_actor.cpp b/engines/grim/lua_v1_actor.cpp
index e7a045ab678..62bed7ba138 100644
--- a/engines/grim/lua_v1_actor.cpp
+++ b/engines/grim/lua_v1_actor.cpp
@@ -1416,16 +1416,13 @@ void Lua_V1::GetVisibleThings() {
lua_Object result = lua_createtable();
- // TODO verify code below
- if (actor->isInSet(g_grim->getCurrSet()->getName())) {
- for (Actor *a : g_grim->getActiveActors()) {
- // Consider the active actor visible
- if (actor == a || actor->getYawTo(a) < 90) {
- lua_pushobject(result);
- lua_pushusertag(a->getId(), MKTAG('A','C','T','R'));
- lua_pushnumber(1);
- lua_settable();
- }
+ const Common::String ¤tSet = actor->getCurrentSet();
+ for (Actor *a : g_grim->getActiveActors()) {
+ if (actor != a && a->isInSet(currentSet) && actor->getYawTo(a) < actor->getFOV() / 2) {
+ lua_pushobject(result);
+ lua_pushusertag(a->getId(), MKTAG('A','C','T','R'));
+ lua_pushnumber(1);
+ lua_settable();
}
}
lua_pushobject(result);
diff --git a/engines/grim/savegame.cpp b/engines/grim/savegame.cpp
index 4ca9016ac0f..98594ddc4f7 100644
--- a/engines/grim/savegame.cpp
+++ b/engines/grim/savegame.cpp
@@ -34,7 +34,7 @@ namespace Grim {
#define SAVEGAME_FOOTERTAG 'ESAV'
uint SaveGame::SAVEGAME_MAJOR_VERSION = 22;
-uint SaveGame::SAVEGAME_MINOR_VERSION = 30;
+uint SaveGame::SAVEGAME_MINOR_VERSION = 31;
SaveGame *SaveGame::openForLoading(const Common::String &filename) {
Common::InSaveFile *inSaveFile = g_system->getSavefileManager()->openForLoading(filename);
More information about the Scummvm-git-logs
mailing list