CObjectList: Make IsQualified() a const member function

None of the implementations modify object instance state, so this can be
made const qualified.
This commit is contained in:
Lioncash 2020-03-06 04:36:24 -05:00
parent 2f9dd38bbe
commit 80e2e97dc4
4 changed files with 21 additions and 21 deletions

View File

@ -91,6 +91,6 @@ CEntity* CObjectList::GetValidObjectById(TUniqueId uid) {
return ent.entity; return ent.entity;
} }
bool CObjectList::IsQualified(const CEntity&) { return true; } bool CObjectList::IsQualified(const CEntity&) const { return true; }
} // namespace urde } // namespace urde

View File

@ -80,7 +80,7 @@ public:
CEntity* GetValidObjectById(TUniqueId uid); CEntity* GetValidObjectById(TUniqueId uid);
s16 GetFirstObjectIndex() const { return x2008_firstId; } s16 GetFirstObjectIndex() const { return x2008_firstId; }
s16 GetNextObjectIndex(s16 prev) const { return x0_list[prev].next; } s16 GetNextObjectIndex(s16 prev) const { return x0_list[prev].next; }
virtual bool IsQualified(const CEntity&); virtual bool IsQualified(const CEntity&) const;
u16 size() const { return x200a_count; } u16 size() const { return x200a_count; }
}; };

View File

@ -14,39 +14,39 @@ namespace urde {
CActorList::CActorList() : CObjectList(EGameObjectList::Actor) {} CActorList::CActorList() : CObjectList(EGameObjectList::Actor) {}
bool CActorList::IsQualified(const CEntity& ent) { return TCastToConstPtr<CActor>(ent); } bool CActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CActor>(ent); }
CPhysicsActorList::CPhysicsActorList() : CObjectList(EGameObjectList::PhysicsActor) {} CPhysicsActorList::CPhysicsActorList() : CObjectList(EGameObjectList::PhysicsActor) {}
bool CPhysicsActorList::IsQualified(const CEntity& ent) { return TCastToConstPtr<CPhysicsActor>(ent); } bool CPhysicsActorList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CPhysicsActor>(ent); }
CGameCameraList::CGameCameraList() : CObjectList(EGameObjectList::GameCamera) {} CGameCameraList::CGameCameraList() : CObjectList(EGameObjectList::GameCamera) {}
bool CGameCameraList::IsQualified(const CEntity& ent) { return TCastToConstPtr<CGameCamera>(ent); } bool CGameCameraList::IsQualified(const CEntity& ent) const { return TCastToConstPtr<CGameCamera>(ent); }
CListeningAiList::CListeningAiList() : CObjectList(EGameObjectList::ListeningAi) {} CListeningAiList::CListeningAiList() : CObjectList(EGameObjectList::ListeningAi) {}
bool CListeningAiList::IsQualified(const CEntity& ent) { bool CListeningAiList::IsQualified(const CEntity& ent) const {
TCastToConstPtr<CAi> ai(ent); const TCastToConstPtr<CAi> ai(ent);
return ai && ai->IsListening(); return ai && ai->IsListening();
} }
CAiWaypointList::CAiWaypointList() : CObjectList(EGameObjectList::AiWaypoint) {} CAiWaypointList::CAiWaypointList() : CObjectList(EGameObjectList::AiWaypoint) {}
bool CAiWaypointList::IsQualified(const CEntity& ent) { bool CAiWaypointList::IsQualified(const CEntity& ent) const {
return TCastToConstPtr<CScriptCoverPoint>(ent) || TCastToConstPtr<CScriptAiJumpPoint>(ent); return TCastToConstPtr<CScriptCoverPoint>(ent) || TCastToConstPtr<CScriptAiJumpPoint>(ent);
} }
CPlatformAndDoorList::CPlatformAndDoorList() : CObjectList(EGameObjectList::PlatformAndDoor) {} CPlatformAndDoorList::CPlatformAndDoorList() : CObjectList(EGameObjectList::PlatformAndDoor) {}
bool CPlatformAndDoorList::IsQualified(const CEntity& ent) { return IsDoor(ent) || IsPlatform(ent); } bool CPlatformAndDoorList::IsQualified(const CEntity& ent) const { return IsDoor(ent) || IsPlatform(ent); }
bool CPlatformAndDoorList::IsDoor(const CEntity& ent) { return TCastToConstPtr<CScriptDoor>(ent); } bool CPlatformAndDoorList::IsDoor(const CEntity& ent) const { return TCastToConstPtr<CScriptDoor>(ent); }
bool CPlatformAndDoorList::IsPlatform(const CEntity& ent) { return TCastToConstPtr<CScriptPlatform>(ent); } bool CPlatformAndDoorList::IsPlatform(const CEntity& ent) const { return TCastToConstPtr<CScriptPlatform>(ent); }
CGameLightList::CGameLightList() : CObjectList(EGameObjectList::GameLight) {} CGameLightList::CGameLightList() : CObjectList(EGameObjectList::GameLight) {}
bool CGameLightList::IsQualified(const CEntity& lt) { return TCastToConstPtr<CGameLight>(lt); } bool CGameLightList::IsQualified(const CEntity& lt) const { return TCastToConstPtr<CGameLight>(lt); }
} // namespace urde } // namespace urde

View File

@ -8,47 +8,47 @@ class CActorList : public CObjectList {
public: public:
CActorList(); CActorList();
bool IsQualified(const CEntity&) override; bool IsQualified(const CEntity&) const override;
}; };
class CPhysicsActorList : public CObjectList { class CPhysicsActorList : public CObjectList {
public: public:
CPhysicsActorList(); CPhysicsActorList();
bool IsQualified(const CEntity&) override; bool IsQualified(const CEntity&) const override;
}; };
class CGameCameraList : public CObjectList { class CGameCameraList : public CObjectList {
public: public:
CGameCameraList(); CGameCameraList();
bool IsQualified(const CEntity&) override; bool IsQualified(const CEntity&) const override;
}; };
class CListeningAiList : public CObjectList { class CListeningAiList : public CObjectList {
public: public:
CListeningAiList(); CListeningAiList();
bool IsQualified(const CEntity&) override; bool IsQualified(const CEntity&) const override;
}; };
class CAiWaypointList : public CObjectList { class CAiWaypointList : public CObjectList {
public: public:
CAiWaypointList(); CAiWaypointList();
bool IsQualified(const CEntity&) override; bool IsQualified(const CEntity&) const override;
}; };
class CPlatformAndDoorList : public CObjectList { class CPlatformAndDoorList : public CObjectList {
public: public:
CPlatformAndDoorList(); CPlatformAndDoorList();
bool IsQualified(const CEntity&) override; bool IsQualified(const CEntity&) const override;
bool IsDoor(const CEntity&); bool IsDoor(const CEntity&) const;
bool IsPlatform(const CEntity&); bool IsPlatform(const CEntity&) const;
}; };
class CGameLightList : public CObjectList { class CGameLightList : public CObjectList {
public: public:
CGameLightList(); CGameLightList();
bool IsQualified(const CEntity&) override; bool IsQualified(const CEntity&) const override;
}; };
} // namespace urde } // namespace urde