Added lots of security using asserts.
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "ChoiceQueue.hpp"
|
||||
#include <Arbutils/Assert.hpp>
|
||||
|
||||
bool CreatureLib::Battling::ChoiceQueue::MoveCreatureChoiceNext(CreatureLib::Battling::Creature* creature) {
|
||||
AssertNotNull(creature)
|
||||
// Find which index the creature choice is at.
|
||||
size_t choiceIndex = SIZE_MAX;
|
||||
for (size_t index = _current; index < _queue.size(); index++) {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#include "TurnHandler.hpp"
|
||||
#include <Arbutils/Assert.hpp>
|
||||
#include "../../Library/Exceptions/NotImplementedException.hpp"
|
||||
#include "../Models/Battle.hpp"
|
||||
#include "../ScriptHandling/ScriptMacros.hpp"
|
||||
|
||||
using namespace CreatureLib::Battling;
|
||||
|
||||
void TurnHandler::RunTurn(Battle* battle, ChoiceQueue* queue) {
|
||||
void TurnHandler::RunTurn(ChoiceQueue* queue) {
|
||||
AssertNotNull(queue)
|
||||
for (auto choice : queue->GetInnerQueue()) {
|
||||
HOOK(OnBeforeTurn, choice, choice);
|
||||
}
|
||||
@@ -31,6 +32,7 @@ void TurnHandler::ExecuteChoice(BaseTurnChoice* choice) {
|
||||
return;
|
||||
}
|
||||
auto battle = user->GetBattle();
|
||||
AssertNotNull(battle)
|
||||
// If the user is not in the field, we don't want to execute its choice.
|
||||
if (!battle->CreatureInField(user)) {
|
||||
return;
|
||||
@@ -51,6 +53,7 @@ void TurnHandler::ExecuteChoice(BaseTurnChoice* choice) {
|
||||
}
|
||||
|
||||
void TurnHandler::ExecuteAttackChoice(AttackTurnChoice* choice) {
|
||||
AssertNotNull(choice)
|
||||
auto attackName = choice->GetAttack()->GetAttack()->GetName();
|
||||
HOOK(ChangeAttack, choice, choice, &attackName);
|
||||
if (attackName != choice->GetAttack()->GetAttack()->GetName()) {
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace CreatureLib::Battling {
|
||||
static void ExecuteFleeChoice(FleeTurnChoice* choice);
|
||||
|
||||
public:
|
||||
static void RunTurn(Battle* battle, ChoiceQueue* queue);
|
||||
static void RunTurn(ChoiceQueue* queue);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user