Use single shared lua interface for all npc #4666
Closed
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.
Changes Proposed
A while ago this PR was merged: #4483 and it fixes the memory leak problem with NPCs very well, however that PR includes the creation of a separate instance of NpcLuaScriptInterface, when in reality we can use a single one that is shared with everyone the NPCs, so this PR adds this possibility
The
Npcs class
has been removed for anNpcs namespace
, I decided to make this change because it is not possible to have a static shared pointer and this class does not have any singletons to reuse.Added a destructor to the
NpcEventsHandler
class to remove loaded event ids from the npc lua interface reference table. (inspired by first attempt at clearing npc events(callbacks) from scriptinterface … #3553)Now when we do
/reload npc
, the libraries will also be reloaded. It was always annoying to have to restart the server to be able to test changes to the libraries when we are in development. I don't know if maybe we should move it to theglobal reload type
?Tested with the following simple script:
and reloads...
Issues addressed: Nothing!