Another rework for scripthooks, for better performance.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This new version caches pointers to the pointers to scripts, so that we can build the data once and then simply iterate over it whenever we want to run a hook.
This commit is contained in:
@@ -11,12 +11,12 @@ using namespace CreatureLib::Battling;
|
||||
TEST_CASE( "Turn ordering: Attack before pass", "[Battling]" ) {
|
||||
auto choice1 = new PassTurnChoice(nullptr);
|
||||
auto choice2 = new AttackTurnChoice(nullptr, nullptr, Target(0,0));
|
||||
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
@@ -31,12 +31,12 @@ TEST_CASE( "Turn ordering: High priority goes before no priority", "[Battling]"
|
||||
auto a2 = new LearnedAttack(l->GetAttack("highPriority"), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0,0));
|
||||
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
@@ -53,12 +53,12 @@ TEST_CASE( "Turn ordering: Higher priority goes before high priority", "[Battlin
|
||||
auto a2 = new LearnedAttack(l->GetAttack("higherPriority"), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0,0));
|
||||
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
@@ -75,12 +75,12 @@ TEST_CASE( "Turn ordering: High priority goes before low priority", "[Battling]"
|
||||
auto a2 = new LearnedAttack(l->GetAttack("higherPriority"), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0,0));
|
||||
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
@@ -97,12 +97,12 @@ TEST_CASE( "Turn ordering: No priority goes before low priority", "[Battling]" )
|
||||
auto a2 = new LearnedAttack(l->GetAttack("standard"), AttackLearnMethod::Unknown);
|
||||
auto choice1 = new AttackTurnChoice(nullptr, a1, Target(0,0));
|
||||
auto choice2 = new AttackTurnChoice(nullptr, a2, Target(0,0));
|
||||
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
|
||||
auto vec = std::vector<BaseTurnChoice*>{choice1, choice2};
|
||||
auto rand = Core::Random();
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
|
||||
vec = std::vector<BaseTurnChoice*>{choice2, choice1};
|
||||
TurnOrdering::OrderChoices(vec,rand);
|
||||
CHECK(vec[0] == choice2);
|
||||
CHECK(vec[1] == choice1);
|
||||
|
||||
Reference in New Issue
Block a user