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