Eluna icon indicating copy to clipboard operation
Eluna copied to clipboard

Changed how data pushed to lua is validated to use weak_ptr

Open Shauren opened this issue 11 months ago • 0 comments

Makes use of https://github.com/TrinityCore/TrinityCore/commit/a79b42bf681e211997923dbc6c191aae187aded6

Also removed additional indirection when pushing 64 bit integers and ObjectGuids

This allows storing direct object references in scripts

local test_stashed_player = nil

local function OnTextEmote(event, player, textEmote, emoteNum, guid)
    if test_stashed_player ~= nil then
        xpcall(
            function() test_stashed_player:SendBroadcastMessage("reuse stored player") end,
            function(err) player:SendBroadcastMessage(err) end
        )
    else 
        test_stashed_player = player
        test_stashed_player:SendBroadcastMessage("store player ".. tostring(player:GetGUID()))
    end
end

RegisterPlayerEvent(24, OnTextEmote)

Player handles are intentionally invalidated on cross map teleports

  1. login
  2. /lol
  3. /lol
  4. .tele dalaran
  5. .rec
  6. /lol Result: obraz

~~PR is marked as draft because map create/destroy hooks currently don't work (fix needed in main TC repo that changes where they are called)~~

Other emus won't currently compile - I plan to submit a PR to CMangos with the same commit that was pushed to TC (in the worst case that nobody is interested in adopting that code it would have to be instead done by forks that maintain Eluna integration)

Shauren avatar Mar 14 '24 15:03 Shauren