openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

Crash when handing `MwFastBuffer<wstring>` to proc #28

Closed Nsgr closed 2 years ago

Nsgr commented 2 years ago

I am trying to send a custom UI Layer event to a server that is running a game mode script that can receive it. So I try to run the proc void SendCustomEvent(wstring Type, MwFastBuffer<wstring>& Data) in CGameManialinkScriptHandler (https://next.openplanet.nl/Game/CGameManialinkScriptHandler) using this code:

void Main() {
    auto app = GetApp();
    auto playground = app.CurrentPlayground;
    if(playground is null)
        return;

    auto Interface = playground.Interface;
    if(Interface is null)
        return;

    CGameManialinkScriptHandler@ ManialinkScriptHandler = cast<CGameManialinkScriptHandler>(Interface.ManialinkScriptHandler);
    if (ManialinkScriptHandler is null)
        return;

    MwFastBuffer<wstring> eventData;
    ManialinkScriptHandler.SendCustomEvent("ChaosMode.NewEffect", eventData);
}

Running this code while being in a server by reloading the plugin crashes the game. (The cast might not be necessary)

codecat commented 2 years ago

This crash is not caused by Openplanet, the cause of this is that CGameManialinkScriptHandler::Page is null. Nadeo would have to fix this crash. Although, it probably doesn't make sense to send an event to a non-existing page?

if (ManialinkScriptHandler.Page is null) {
    warn("Page is null");
    return;
}