Skip to content

Commit 55107e0

Browse files
committed
Merge branch 'idle_select_to_group_name' into 'master'
Use string_view for sIdleSelectToGroupName See merge request OpenMW/openmw!4646
2 parents 011dfb3 + f487a63 commit 55107e0

File tree

7 files changed

+19
-17
lines changed

7 files changed

+19
-17
lines changed

apps/openmw/mwbase/mechanicsmanager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ namespace MWBase
200200
///< Skip the animation for the given MW-reference for one frame. Calls to this function for
201201
/// references that are currently not in the scene should be ignored.
202202

203-
virtual bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName) = 0;
203+
virtual bool checkAnimationPlaying(const MWWorld::Ptr& ptr, std::string_view groupName) = 0;
204204

205205
virtual bool checkScriptedAnimationPlaying(const MWWorld::Ptr& ptr) const = 0;
206206

apps/openmw/mwmechanics/actors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2028,7 +2028,7 @@ namespace MWMechanics
20282028
iter->second->getCharacterController().skipAnim();
20292029
}
20302030

2031-
bool Actors::checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName) const
2031+
bool Actors::checkAnimationPlaying(const MWWorld::Ptr& ptr, std::string_view groupName) const
20322032
{
20332033
const auto iter = mIndex.find(ptr.mRef);
20342034
if (iter != mIndex.end())

apps/openmw/mwmechanics/actors.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ namespace MWMechanics
119119
std::string_view startKey, std::string_view stopKey, bool forceLoop);
120120
void enableLuaAnimations(const MWWorld::Ptr& ptr, bool enable);
121121
void skipAnimation(const MWWorld::Ptr& ptr) const;
122-
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName) const;
122+
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, std::string_view groupName) const;
123123
bool checkScriptedAnimationPlaying(const MWWorld::Ptr& ptr) const;
124124
void persistAnimationStates() const;
125125
void clearAnimationQueue(const MWWorld::Ptr& ptr, bool clearScripted);

apps/openmw/mwmechanics/aiwander.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ namespace MWMechanics
4040

4141
static const std::size_t MAX_IDLE_SIZE = 8;
4242

43-
const std::string AiWander::sIdleSelectToGroupName[GroupIndex_MaxIdle - GroupIndex_MinIdle + 1] = {
44-
std::string("idle2"),
45-
std::string("idle3"),
46-
std::string("idle4"),
47-
std::string("idle5"),
48-
std::string("idle6"),
49-
std::string("idle7"),
50-
std::string("idle8"),
51-
std::string("idle9"),
43+
const std::string_view AiWander::sIdleSelectToGroupName[GroupIndex_MaxIdle - GroupIndex_MinIdle + 1] = {
44+
"idle2",
45+
"idle3",
46+
"idle4",
47+
"idle5",
48+
"idle6",
49+
"idle7",
50+
"idle8",
51+
"idle9",
5252
};
5353

5454
namespace
@@ -680,7 +680,7 @@ namespace MWMechanics
680680
{
681681
if ((GroupIndex_MinIdle <= idleSelect) && (idleSelect <= GroupIndex_MaxIdle))
682682
{
683-
const std::string& groupName = sIdleSelectToGroupName[idleSelect - GroupIndex_MinIdle];
683+
const std::string_view groupName = sIdleSelectToGroupName[idleSelect - GroupIndex_MinIdle];
684684
return MWBase::Environment::get().getMechanicsManager()->playAnimationGroup(actor, groupName, 0, 1);
685685
}
686686
else
@@ -695,7 +695,7 @@ namespace MWMechanics
695695
{
696696
if ((GroupIndex_MinIdle <= idleSelect) && (idleSelect <= GroupIndex_MaxIdle))
697697
{
698-
const std::string& groupName = sIdleSelectToGroupName[idleSelect - GroupIndex_MinIdle];
698+
const std::string_view groupName = sIdleSelectToGroupName[idleSelect - GroupIndex_MinIdle];
699699
return MWBase::Environment::get().getMechanicsManager()->checkAnimationPlaying(actor, groupName);
700700
}
701701
else

apps/openmw/mwmechanics/aiwander.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "typedaipackage.hpp"
55

6+
#include <string_view>
67
#include <vector>
78

89
#include "aitemporarybase.hpp"
@@ -181,7 +182,7 @@ namespace MWMechanics
181182
const ESM::Pathgrid::Point& start, const ESM::Pathgrid::Point& end, AiWanderStorage& storage);
182183

183184
/// lookup table for converting idleSelect value to groupName
184-
static const std::string sIdleSelectToGroupName[GroupIndex_MaxIdle - GroupIndex_MinIdle + 1];
185+
static const std::string_view sIdleSelectToGroupName[GroupIndex_MaxIdle - GroupIndex_MinIdle + 1];
185186
};
186187
}
187188

apps/openmw/mwmechanics/mechanicsmanagerimp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,8 @@ namespace MWMechanics
778778
else
779779
mObjects.skipAnimation(ptr);
780780
}
781-
bool MechanicsManager::checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName)
781+
782+
bool MechanicsManager::checkAnimationPlaying(const MWWorld::Ptr& ptr, std::string_view groupName)
782783
{
783784
if (ptr.getClass().isActor())
784785
return mActors.checkAnimationPlaying(ptr, groupName);

apps/openmw/mwmechanics/mechanicsmanagerimp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ namespace MWMechanics
146146
std::string_view startKey, std::string_view stopKey, bool forceLoop) override;
147147
void enableLuaAnimations(const MWWorld::Ptr& ptr, bool enable) override;
148148
void skipAnimation(const MWWorld::Ptr& ptr) override;
149-
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName) override;
149+
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, std::string_view groupName) override;
150150
bool checkScriptedAnimationPlaying(const MWWorld::Ptr& ptr) const override;
151151
void persistAnimationStates() override;
152152
void clearAnimationQueue(const MWWorld::Ptr& ptr, bool clearScripted) override;

0 commit comments

Comments
 (0)