Use std::optional for BaseLibrary TryGet.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
@@ -48,9 +48,11 @@ Creature* CreateCreature::Create() {
|
||||
}
|
||||
ArbUt::BorrowedPtr<const Library::Item> heldItem;
|
||||
if (!this->_heldItem.IsEmpty()) {
|
||||
if (!_library->GetItemLibrary()->TryGet(this->_heldItem.GetHash(), heldItem)) {
|
||||
auto val = _library->GetItemLibrary()->TryGet(this->_heldItem.GetHash());
|
||||
if (!val.has_value()) {
|
||||
THROW("Invalid held item '" << this->_heldItem.c_str() << "'.");
|
||||
}
|
||||
heldItem = val.value();
|
||||
}
|
||||
auto experience = _library->GetGrowthRateLibrary()->CalculateExperience(species->GetGrowthRate(), _level);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user