otland / forgottenserver

A free and open-source MMORPG server emulator written in C++
https://otland.net
GNU General Public License v2.0
1.56k stars 1.04k forks source link

Use single shared lua interface for all npc #4666

Closed MillhioreBT closed 2 months ago

MillhioreBT commented 2 months ago

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

function talkAction.onSay(player, words, param, type) local pos = player:getPosition() local npcs = {} for i = 1, 1000 do Game.createNpc("Deruno", Position(pos.x + math.random(-5, 5), pos.y + math.random(-5, 5), pos.z)):remove() end

return false

end

talkAction:register()



and reloads...

**Issues addressed:** Nothing!
EvilHero90 commented 2 months ago

I'll close this, since this is already included in #4671