Defensive programming for Party
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -24,6 +24,9 @@ namespace CreatureLib::Battling {
|
||||
void Switch(size_t a, size_t b) noexcept { _party.Swap(a, b); }
|
||||
|
||||
Creature* SwapInto(size_t index, Creature* creature) {
|
||||
if (index >= _party.Count()) {
|
||||
THROW("Index was out of bounds for party.")
|
||||
}
|
||||
auto p = _party.TakeOwnership(index);
|
||||
_party.Set(index, creature);
|
||||
return p;
|
||||
|
||||
Reference in New Issue
Block a user