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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user