Warn about loading dead bodies, but handle safely.
parent
9795b9deea
commit
18b4d487e2
|
@ -350,6 +350,10 @@ Body *Space::GetBodyByIndex(Uint32 idx) const
|
|||
{
|
||||
assert(m_bodyIndexValid);
|
||||
assert(m_bodyIndex.size() > idx);
|
||||
if (idx == SDL_MAX_UINT32 || m_bodyIndex.size() <= idx) {
|
||||
Output("GetBodyByIndex passed bad index %u", idx);
|
||||
return nullptr;
|
||||
}
|
||||
return m_bodyIndex[idx];
|
||||
}
|
||||
|
||||
|
@ -365,8 +369,9 @@ Uint32 Space::GetIndexForBody(const Body *body) const
|
|||
assert(m_bodyIndexValid);
|
||||
for (Uint32 i = 0; i < m_bodyIndex.size(); i++)
|
||||
if (m_bodyIndex[i] == body) return i;
|
||||
assert(0);
|
||||
return Uint32(-1);
|
||||
assert(false);
|
||||
Output("GetIndexForBody passed unknown body");
|
||||
return SDL_MAX_UINT32;
|
||||
}
|
||||
|
||||
Uint32 Space::GetIndexForSystemBody(const SystemBody *sbody) const
|
||||
|
@ -375,7 +380,7 @@ Uint32 Space::GetIndexForSystemBody(const SystemBody *sbody) const
|
|||
for (Uint32 i = 0; i < m_sbodyIndex.size(); i++)
|
||||
if (m_sbodyIndex[i] == sbody) return i;
|
||||
assert(0);
|
||||
return Uint32(-1);
|
||||
return SDL_MAX_UINT32;
|
||||
}
|
||||
|
||||
void Space::AddSystemBodyToIndex(SystemBody *sbody)
|
||||
|
|
Loading…
Reference in New Issue