Another rework for scripthooks, for better performance.
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:
2019-11-10 17:08:42 +01:00
parent e1a8d80863
commit d8332f9e40
19 changed files with 118 additions and 72 deletions

View File

@@ -33,10 +33,10 @@ void Battle::CheckChoicesSetAndRun() {
return;
}
}
auto choices = std::vector<const BaseTurnChoice*>(_numberOfSides * _creaturesPerSide);
auto choices = std::vector<BaseTurnChoice*>(_numberOfSides * _creaturesPerSide);
auto i = 0;
for (auto side: _sides){
for (const BaseTurnChoice* choice: side->GetChoices()){
for (BaseTurnChoice* choice: side->GetChoices()){
if (choice->GetKind() == TurnChoiceKind::Attack){
auto attack = dynamic_cast<const AttackTurnChoice*>(choice)->GetAttack();
uint8_t uses = 1;
@@ -93,6 +93,6 @@ void Battle::FillRecall(uint8_t side, uint8_t, Creature *c) {
}
}
void Battle::GetActiveScripts(ScriptAggregator &aggr) const {
aggr.Add(&_volatile);
void Battle::GetActiveScripts(std::vector<ScriptWrapper> &scripts) {
scripts.emplace_back(&_volatile);
}