CPASDatabase: Resolve sign-conversion warnings

We can leverage size_t here to resolve sign-conversion warnings.

While we're in the same area, we can remove a use of at() for
std::vector, given a bounds check already precedes it.
This commit is contained in:
Lioncash 2020-04-06 13:21:04 -04:00
parent 8dcd6b3109
commit f96ea81d69
2 changed files with 6 additions and 5 deletions

View File

@ -8,7 +8,7 @@ namespace urde {
CBodyStateInfo::CBodyStateInfo(CActor& actor, EBodyType type) {
x34_24_changeLocoAtEndOfAnimOnly = false;
const CPASDatabase& pasDatabase = actor.GetModelData()->GetAnimationData()->GetCharacterInfo().GetPASDatabase();
for (int i = 0; i < pasDatabase.GetNumAnimStates(); ++i) {
for (size_t i = 0; i < pasDatabase.GetNumAnimStates(); ++i) {
const CPASAnimState* state = pasDatabase.GetAnimStateByIndex(i);
std::unique_ptr<CBodyState> bs;

View File

@ -23,7 +23,7 @@ public:
std::pair<float, s32> FindBestAnimation(const CPASAnimParmData& data, s32 ignoreAnim) const;
std::pair<float, s32> FindBestAnimation(const CPASAnimParmData& data, CRandom16& rand, s32 ignoreAnim) const;
s32 GetDefaultState() const { return x10_defaultState; }
s32 GetNumAnimStates() const { return x0_states.size(); }
size_t GetNumAnimStates() const { return x0_states.size(); }
const CPASAnimState* GetAnimState(s32 id) const {
for (const CPASAnimState& state : x0_states)
if (id == state.GetStateId())
@ -31,11 +31,12 @@ public:
return nullptr;
}
const CPASAnimState* GetAnimStateByIndex(s32 index) const {
if (index < 0 || index >= x0_states.size())
const CPASAnimState* GetAnimStateByIndex(size_t index) const {
if (index >= x0_states.size()) {
return nullptr;
}
return &x0_states.at(index);
return &x0_states[index];
}
bool HasState(s32 id) const {