topaz-next / topaz

💎 A server emulator for Final Fantasy XI.
GNU General Public License v3.0
55 stars 80 forks source link

[canary] Crash server when start black coffin in party #2655

Closed Chronos77 closed 3 years ago

Chronos77 commented 3 years ago

Additional Information (Steps to reproduce/Expected behavior) : Make a party Start instance for black coffin

The player who doesn't start the instance has an event that has to be cancelled (with the escape key) then we have the crash server

I tried to debug however I have some questions about how to proceed. This is the luautils.cpp L 1561 -> L 1577

        sol::function onRegionLeave;
        if (PChar->PInstance)
        {
            auto instance_name = (const char*)PChar->PInstance->GetName();
            onRegionLeave      = lua["tpz"]["zones"][name]["instance"][instance_name]["onRegionLeave"];
        }
        else
        {
            onRegionLeave = lua["tpz"]["zones"][name]["Zone"]["onRegionLeave"];
        }

        if (!onRegionLeave.valid())
        {
            return -1;
        }

It crash on : onRegionLeave = lua["tpz"]["zones"][name]["instance"][instance_name]["onRegionLeave"];

Because name = arrapago_reef and instance_name = black coffin but black coffin is in the Ashu Talif zone not in arrapago.

I think i can add condition as : if (PChar->PInstance && lua["tpz"]["zones"][name]["instance"])

but i'm not sure