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

@@ -16,11 +16,11 @@ void BattleSide::ResetChoices() {
}
}
const std::vector<const BaseTurnChoice *>& BattleSide::GetChoices() const{
const std::vector<BaseTurnChoice *>& BattleSide::GetChoices() const{
return _choices;
}
void BattleSide::SetChoice(const BaseTurnChoice *choice) {
void BattleSide::SetChoice(BaseTurnChoice *choice) {
auto find = std::find(_creatures.begin(), _creatures.end(), choice->GetUser());
if (find ==_creatures.end())
throw CreatureException("User not found");
@@ -41,7 +41,7 @@ Creature *BattleSide::GetCreature(uint8_t index) const {
return _creatures[index];
}
void BattleSide::GetActiveScripts(ScriptAggregator &aggr) const {
aggr.Add(&_volatile);
_battle->GetActiveScripts(aggr);
void BattleSide::GetActiveScripts(std::vector<ScriptWrapper> &scripts) {
scripts.emplace_back(&_volatile);
_battle->GetActiveScripts(scripts);
}