Update to new THROW macro.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-11-21 12:39:07 +01:00
parent 54eddba913
commit f1d706b356
13 changed files with 30 additions and 37 deletions

View File

@@ -95,7 +95,7 @@ TargetList TargetResolver::ResolveTargets(const CreatureIndex& index, AttackTarg
return arr;
}
}
THROW("Unknown attack target kind: '" << AttackTargetHelper::ToString(target) << "'.")
THROW("Unknown attack target kind: '", AttackTargetHelper::ToString(target), "'.")
}
bool TargetResolver::IsValidTarget(const CreatureIndex& index, CreatureLib::Library::AttackTarget target,
@@ -149,5 +149,5 @@ bool TargetResolver::IsValidTarget(const CreatureIndex& index, CreatureLib::Libr
return index == userIndex;
}
}
THROW("Unknown attack target kind: '" << AttackTargetHelper::ToString(target) << "'.")
THROW("Unknown attack target kind: '", AttackTargetHelper::ToString(target), "'.")
}

View File

@@ -15,14 +15,7 @@ void TurnHandler::RunTurn(const ArbUt::BorrowedPtr<ChoiceQueue>& queue, const Ar
EnsureNotNull(item)
Ensure(item->GetUser()->GetBattle().HasValue())
Ensure(item->GetUser()->GetBattleSide().HasValue())
auto index = (uint32_t)item->GetUser()->GetBattleSide().GetValue()->GetCreatureIndex(item->GetUser());
try_creature(ExecuteChoice(item.get()),
"Executing choice failed for choice by mon on side "
<< ((uint32_t)item->GetUser()->GetBattleSide().GetValue()->GetSideIndex()) << " and index "
<< index << ". Choice had choice kind "
<< CreatureLib::Battling::TurnChoiceKindHelper::ToString(item->GetKind()) << " "
<< " with message");
ExecuteChoice(item.get());
}
if (!battle->HasEnded()) {
ArbUt::List<ScriptWrapper> scripts;
@@ -250,7 +243,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
THROW("Exception during status attack effect handling: " << e.what() << ".");
THROW("Exception during status attack effect handling: ", e.what(), ".");
}
}
} else {
@@ -282,7 +275,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
THROW("Exception during offensive attack secondary effect handling: " << e.what() << ".");
THROW("Exception during offensive attack secondary effect handling: ", e.what(), ".");
}
}
}

View File

@@ -50,7 +50,7 @@ void Battle::CheckChoicesSetAndRun() {
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
THROW("Exception during choices set validation: '" << e.what() << "'.")
THROW("Exception during choices set validation: '", e.what(), "'.")
}
auto begin = std::chrono::steady_clock::now();
@@ -77,13 +77,13 @@ void Battle::CheckChoicesSetAndRun() {
side->ResetChoices();
}
} catch (const std::exception& e) {
THROW("Exception during turn initialization: '" << e.what() << "'.")
THROW("Exception during turn initialization: '", e.what(), "'.")
}
_currentTurn++;
try {
TurnOrdering::OrderChoices(choices);
} catch (const std::exception& e) {
THROW("Exception during turn ordering: '" << e.what() << "'.")
THROW("Exception during turn ordering: '", e.what(), "'.")
}
this->_currentTurnQueue = std::make_unique<ChoiceQueue>(choices);
TriggerEventListener<TurnStartEvent>();
@@ -92,7 +92,7 @@ void Battle::CheckChoicesSetAndRun() {
} catch (const ArbUt::Exception& e) {
throw e;
} catch (const std::exception& e) {
THROW("Error during running a turn: '" << e.what() << "'.");
THROW("Error during running a turn: '", e.what(), "'.");
}
if (this->_currentTurnQueue->HasCompletedQueue) {
this->_currentTurnQueue = nullptr;
@@ -169,7 +169,7 @@ BattleScript* Battle::AddVolatileScript(const ArbUt::StringView& key) {
}
script = _library->LoadScript(this, ScriptCategory::Battle, key);
if (!script.HasValue()) {
THROW("Invalid volatile script requested for battle: '" << key.c_str() << "'.");
THROW("Invalid volatile script requested for battle: '", key.c_str(), "'.");
}
return _volatile.Add(script.GetValue());
}

View File

@@ -18,7 +18,7 @@ bool BattleSide::AllPossibleSlotsFilled() const {
}
}
} catch (const std::exception& e) {
THROW("Exception during AllPossibleSlotsFilled check: '" << e.what() << "'.");
THROW("Exception during AllPossibleSlotsFilled check: '", e.what(), "'.");
}
return true;
}
@@ -45,7 +45,7 @@ void BattleSide::SetChoice(BaseTurnChoice* choice) {
}
}
} catch (const std::exception& e) {
THROW("Error during setting choice: '" << e.what() << "'.");
THROW("Error during setting choice: '", e.what(), "'.");
}
THROW("User not found");
}
@@ -147,7 +147,7 @@ BattleScript* BattleSide::AddVolatileScript(const ArbUt::StringView& key) {
}
script = _battle->GetLibrary()->LoadScript(this, ScriptCategory::Side, key);
if (!script.HasValue()) {
THROW("Invalid volatile script requested for battleside: '" << key.c_str() << "'.");
THROW("Invalid volatile script requested for battleside: '", key.c_str(), "'.");
}
return _volatile.Add(script.GetValue());
}

View File

@@ -50,7 +50,7 @@ Creature* CreateCreature::Create() {
if (!this->_heldItem.IsEmpty()) {
auto val = _library->GetItemLibrary()->TryGet(this->_heldItem.GetHash());
if (!val.has_value()) {
THROW("Invalid held item '" << this->_heldItem.c_str() << "'.");
THROW("Invalid held item '", this->_heldItem.c_str(), "'.");
}
heldItem = val.value();
}

View File

@@ -302,7 +302,7 @@ namespace CreatureLib::Battling {
void Creature::SetHeldItem(const ArbUt::BasicStringView& itemName) {
auto v = _library->GetItemLibrary()->TryGet(itemName.GetHash());
if (!v.has_value()) {
THROW("Item not found '" << itemName.c_str() << "'.");
THROW("Item not found '", itemName.c_str(), "'.");
}
_heldItem = v.value();
}
@@ -322,7 +322,7 @@ namespace CreatureLib::Battling {
}
script = this->_library->LoadScript(this, ScriptCategory::Creature, name);
if (!script.HasValue()) {
THROW("Invalid volatile script requested for creature: '" << name.c_str() << "'.");
THROW("Invalid volatile script requested for creature: '", name.c_str(), "'.");
}
return _volatile.Add(script.GetValue());
}
@@ -360,7 +360,7 @@ namespace CreatureLib::Battling {
if (_attacks.Count() < _library->GetStaticLib()->GetSettings()->GetMaximalAttacks()) {
_attacks.Append(attack);
}
THROW("Can't replace attack at index " << index << ". Number of attacks is " << _attacks.Count() << ".");
THROW("Can't replace attack at index ", index, ". Number of attacks is ", _attacks.Count(), ".");
}
_attacks.Set(index, attack);
}

View File

@@ -10,13 +10,13 @@
try { \
next->hookName(__VA_ARGS__); \
} catch (const std::exception& e) { \
THROW("Exception running script hook '" #hookName "': " << e.what()) \
THROW("Exception running script hook '" #hookName "': ", e.what()) \
} \
} \
} catch (const ArbUt::Exception& e) { \
throw e; \
} catch (const std::exception& e) { \
THROW("Exception setting up script hook '" #hookName "': " << e.what()) \
THROW("Exception setting up script hook '" #hookName "': ", e.what()) \
} \
}
@@ -41,6 +41,6 @@
} catch (const ArbUt::Exception& e) { \
throw e; \
} catch (const std::exception& e) { \
THROW("Exception setting up script hook '" #hookName "': " << e.what()) \
THROW("Exception setting up script hook '" #hookName "': ", e.what()) \
} \
}