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

@@ -9,7 +9,7 @@ namespace CreatureLib::Battling{
class BattleSide : public ScriptSource{
uint8_t _creaturesPerSide;
std::vector<Creature*> _creatures;
std::vector<const BaseTurnChoice*> _choices;
std::vector<BaseTurnChoice*> _choices;
uint8_t _choicesSet = 0;
ScriptSet _volatile;
Battle* _battle;
@@ -21,9 +21,9 @@ namespace CreatureLib::Battling{
}
[[nodiscard]] bool AllChoicesSet() const;
[[nodiscard]] const std::vector<const BaseTurnChoice*>& GetChoices() const;
[[nodiscard]] const std::vector<BaseTurnChoice*>& GetChoices() const;
void SetChoice(const BaseTurnChoice* choice);
void SetChoice(BaseTurnChoice* choice);
void ResetChoices();
void SetCreature(Creature* creature, uint8_t index);
@@ -31,7 +31,7 @@ namespace CreatureLib::Battling{
Creature* GetCreature(uint8_t index) const;
bool CreatureOnSide(const Creature* creature) const;
void GetActiveScripts(ScriptAggregator &aggr) const override;
void GetActiveScripts(std::vector<ScriptWrapper> &scripts) override;
};
}