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

@@ -1,4 +1,5 @@
#include <algorithm>
#include <utility>
#include "Creature.hpp"
#include "../Models/Battle.hpp"
@@ -20,9 +21,9 @@ Battling::Creature::Creature(const Library::CreatureSpecies* species, const Libr
__Gender(gender),
__Coloring(coloring),
__HeldItem(heldItem),
_nickname(nickname),
_nickname(std::move(nickname)),
_talentIndex(talent),
_attacks(attacks)
_attacks(std::move(attacks))
{}
@@ -140,8 +141,8 @@ bool Battling::Creature::HasType(uint8_t type) const {
return std::find(t.begin(), t.end(), type) != t.end();
}
void Battling::Creature::GetActiveScripts(Battling::ScriptAggregator &aggr) const {
aggr.Add(_status);
aggr.Add(&_volatile);
_side->GetActiveScripts(aggr);
void Battling::Creature::GetActiveScripts(std::vector<ScriptWrapper> &scripts) {
scripts.emplace_back(&_status);
scripts.emplace_back(&_volatile);
_side->GetActiveScripts(scripts);
}