Merge branch 'classheader' into 'master'

Some include cleanup

See merge request OpenMW/openmw!4815
This commit is contained in:
AnyOldName3 2025-07-28 22:35:24 +00:00
commit 7c3fa3c89f
8 changed files with 32 additions and 23 deletions

View File

@ -8,9 +8,6 @@
#include <string_view> #include <string_view>
#include <vector> #include <vector>
#include "../mwmechanics/greetingstate.hpp"
#include "../mwrender/animationpriority.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
namespace osg namespace osg
@ -27,6 +24,11 @@ namespace ESM
class ESMWriter; class ESMWriter;
} }
namespace MWMechanics
{
enum class GreetingState;
}
namespace MWWorld namespace MWWorld
{ {
class Ptr; class Ptr;

View File

@ -73,7 +73,7 @@ namespace MWMechanics
CharacterController mCharacterController; CharacterController mCharacterController;
int mGreetingTimer{ 0 }; int mGreetingTimer{ 0 };
float mTargetAngleRadians{ 0.f }; float mTargetAngleRadians{ 0.f };
GreetingState mGreetingState{ Greet_None }; GreetingState mGreetingState{ GreetingState::None };
Misc::DeviatingPeriodicTimer mEngageCombat{ 1.0f, 0.25f, Misc::DeviatingPeriodicTimer mEngageCombat{ 1.0f, 0.25f,
Misc::Rng::deviate(0, 0.25f, MWBase::Environment::get().getWorld()->getPrng()) }; Misc::Rng::deviate(0, 0.25f, MWBase::Environment::get().getWorld()->getPrng()) };
bool mIsTurningToPlayer{ false }; bool mIsTurningToPlayer{ false };

View File

@ -50,6 +50,7 @@
#include "attacktype.hpp" #include "attacktype.hpp"
#include "character.hpp" #include "character.hpp"
#include "creaturestats.hpp" #include "creaturestats.hpp"
#include "greetingstate.hpp"
#include "movement.hpp" #include "movement.hpp"
#include "npcstats.hpp" #include "npcstats.hpp"
#include "steering.hpp" #include "steering.hpp"
@ -487,7 +488,7 @@ namespace MWMechanics
{ {
actorState.setTurningToPlayer(false); actorState.setTurningToPlayer(false);
actorState.setGreetingTimer(0); actorState.setGreetingTimer(0);
actorState.setGreetingState(Greet_None); actorState.setGreetingState(GreetingState::None);
return; return;
} }
@ -525,7 +526,7 @@ namespace MWMechanics
int greetingTimer = actorState.getGreetingTimer(); int greetingTimer = actorState.getGreetingTimer();
GreetingState greetingState = actorState.getGreetingState(); GreetingState greetingState = actorState.getGreetingState();
if (greetingState == Greet_None) if (greetingState == GreetingState::None)
{ {
if ((playerPos - actorPos).length2() <= helloDistance * helloDistance && !playerStats.isDead() if ((playerPos - actorPos).length2() <= helloDistance * helloDistance && !playerStats.isDead()
&& !actorStats.isParalyzed() && !isTargetMagicallyHidden(player) && !actorStats.isParalyzed() && !isTargetMagicallyHidden(player)
@ -535,14 +536,14 @@ namespace MWMechanics
if (greetingTimer >= GREETING_SHOULD_START) if (greetingTimer >= GREETING_SHOULD_START)
{ {
greetingState = Greet_InProgress; greetingState = GreetingState::InProgress;
if (!MWBase::Environment::get().getDialogueManager()->say(actor, ESM::RefId::stringRefId("hello"))) if (!MWBase::Environment::get().getDialogueManager()->say(actor, ESM::RefId::stringRefId("hello")))
greetingState = Greet_Done; greetingState = GreetingState::Done;
greetingTimer = 0; greetingTimer = 0;
} }
} }
if (greetingState == Greet_InProgress) if (greetingState == GreetingState::InProgress)
{ {
greetingTimer++; greetingTimer++;
@ -554,16 +555,16 @@ namespace MWMechanics
if (greetingTimer >= GREETING_COOLDOWN) if (greetingTimer >= GREETING_COOLDOWN)
{ {
greetingState = Greet_Done; greetingState = GreetingState::Done;
greetingTimer = 0; greetingTimer = 0;
} }
} }
if (greetingState == Greet_Done) if (greetingState == GreetingState::Done)
{ {
float resetDist = 2 * helloDistance; float resetDist = 2 * helloDistance;
if ((playerPos - actorPos).length2() >= resetDist * resetDist) if ((playerPos - actorPos).length2() >= resetDist * resetDist)
greetingState = Greet_None; greetingState = GreetingState::None;
} }
actorState.setGreetingTimer(greetingTimer); actorState.setGreetingTimer(greetingTimer);
@ -2381,7 +2382,7 @@ namespace MWMechanics
{ {
const auto it = mIndex.find(ptr.mRef); const auto it = mIndex.find(ptr.mRef);
if (it == mIndex.end()) if (it == mIndex.end())
return Greet_None; return GreetingState::None;
return it->second->getGreetingState(); return it->second->getGreetingState();
} }

View File

@ -12,6 +12,7 @@
#include "character.hpp" #include "character.hpp"
#include "creaturestats.hpp" #include "creaturestats.hpp"
#include "greetingstate.hpp"
#include "movement.hpp" #include "movement.hpp"
namespace namespace
@ -77,7 +78,7 @@ namespace MWMechanics
if (!stats.getMovementFlag(CreatureStats::Flag_ForceJump) if (!stats.getMovementFlag(CreatureStats::Flag_ForceJump)
&& !stats.getMovementFlag(CreatureStats::Flag_ForceSneak) && !stats.getMovementFlag(CreatureStats::Flag_ForceSneak)
&& (mechMgr->isTurningToPlayer(actor) || mechMgr->getGreetingState(actor) == Greet_InProgress)) && (mechMgr->isTurningToPlayer(actor) || mechMgr->getGreetingState(actor) == GreetingState::InProgress))
return false; return false;
const osg::Vec3f actorPos(actor.getRefData().getPosition().asVec3()); const osg::Vec3f actorPos(actor.getRefData().getPosition().asVec3());

View File

@ -25,6 +25,7 @@
#include "actorutil.hpp" #include "actorutil.hpp"
#include "character.hpp" #include "character.hpp"
#include "creaturestats.hpp" #include "creaturestats.hpp"
#include "greetingstate.hpp"
#include "movement.hpp" #include "movement.hpp"
#include "pathgrid.hpp" #include "pathgrid.hpp"
@ -257,7 +258,7 @@ namespace MWMechanics
&& !cStats.getMovementFlag(CreatureStats::Flag_ForceSneak)) && !cStats.getMovementFlag(CreatureStats::Flag_ForceSneak))
{ {
GreetingState greetingState = MWBase::Environment::get().getMechanicsManager()->getGreetingState(actor); GreetingState greetingState = MWBase::Environment::get().getMechanicsManager()->getGreetingState(actor);
if (greetingState == Greet_InProgress) if (greetingState == GreetingState::InProgress)
{ {
if (storage.mState == AiWanderStorage::Wander_Walking) if (storage.mState == AiWanderStorage::Wander_Walking)
{ {
@ -526,7 +527,7 @@ namespace MWMechanics
// Check if idle animation finished // Check if idle animation finished
GreetingState greetingState = MWBase::Environment::get().getMechanicsManager()->getGreetingState(actor); GreetingState greetingState = MWBase::Environment::get().getMechanicsManager()->getGreetingState(actor);
if (!checkIdle(actor, storage.mIdleAnimation) && (greetingState == Greet_Done || greetingState == Greet_None)) if (!checkIdle(actor, storage.mIdleAnimation) && greetingState != GreetingState::InProgress)
{ {
if (mPathFinder.isPathConstructed()) if (mPathFinder.isPathConstructed())
storage.setState(AiWanderStorage::Wander_Walking, !mUsePathgrid); storage.setState(AiWanderStorage::Wander_Walking, !mUsePathgrid);

View File

@ -3,11 +3,11 @@
namespace MWMechanics namespace MWMechanics
{ {
enum GreetingState enum class GreetingState
{ {
Greet_None, None,
Greet_InProgress, InProgress,
Greet_Done Done
}; };
} }

View File

@ -22,6 +22,7 @@
#include "../mwmechanics/aitravel.hpp" #include "../mwmechanics/aitravel.hpp"
#include "../mwmechanics/aiwander.hpp" #include "../mwmechanics/aiwander.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/greetingstate.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
@ -487,7 +488,7 @@ namespace MWScript
else if (testedTargetId == "Player") // Currently the player ID is hardcoded else if (testedTargetId == "Player") // Currently the player ID is hardcoded
{ {
MWBase::MechanicsManager* mechMgr = MWBase::Environment::get().getMechanicsManager(); MWBase::MechanicsManager* mechMgr = MWBase::Environment::get().getMechanicsManager();
bool greeting = mechMgr->getGreetingState(actor) == MWMechanics::Greet_InProgress; bool greeting = mechMgr->getGreetingState(actor) == MWMechanics::GreetingState::InProgress;
bool sayActive = MWBase::Environment::get().getSoundManager()->sayActive(actor); bool sayActive = MWBase::Environment::get().getSoundManager()->sayActive(actor);
targetsAreEqual = (greeting && sayActive) || mechMgr->isTurningToPlayer(actor); targetsAreEqual = (greeting && sayActive) || mechMgr->isTurningToPlayer(actor);
} }

View File

@ -6,7 +6,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <osg/Quat>
#include <osg/Vec4f> #include <osg/Vec4f>
#include "doorstate.hpp" #include "doorstate.hpp"
@ -16,9 +15,13 @@
#include "../mwmechanics/damagesourcetype.hpp" #include "../mwmechanics/damagesourcetype.hpp"
#include <components/esm/refid.hpp> #include <components/esm/refid.hpp>
#include <components/esm3/loadskil.hpp>
#include <components/vfs/pathutil.hpp> #include <components/vfs/pathutil.hpp>
namespace osg
{
class Quat;
}
namespace ESM namespace ESM
{ {
struct ObjectState; struct ObjectState;