perf: remove unnecessary event callbacks #3076
Merged
+168
−3,206
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Removed Lua callbacks from
MonsterType
of various monsters. These callbacks were empty, which meant the functions were still being "called" by the monsters without performing any action, creating a significant performance bottleneck.Removed the
onHear
event callback, which had a significant impact on the server and was not used anywhere. It executed theonHear
callback for each spectator, causing an unnecessary overload without any real benefit, especially as we have other methods to check for these events.Additionally, the
monsterOnSpawn
event callback was removed and replaced withMonsterType::onSpawn
, which is much more efficient since it only needs to be declared in the script for each monster that actually uses it.Finally, the way
setRewardBoss
was handled was improved. Previously, it was executed in anonSpawn
event callback, but now it is done directly during the parsing of each monster script, marking them as reward bosses at the time of script loading, improving efficiency.Behaviour
Actual
onHear
was executed for every spectator, generating unnecessary server overload.setRewardBoss
was done through theonSpawn
event callback, which was inefficient.Expected
onHear
event callback to reduce overload and improve server efficiency.MonsterType::onSpawn
to replacemonsterOnSpawn
.setRewardBoss
directly during the reading of the monster scripts to avoid overhead during spawn.Type of change
How Has This Been Tested
Tests were conducted to verify the effectiveness of the changes in terms of monster performance and behavior.
MonsterType::onSpawn
.Checklist