openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

[Game crash] Attempting to get a list of MapList_Names #85

Closed chipsTM closed 2 years ago

chipsTM commented 2 years ago

For some reason calling this code (which appears to be correct) causes the game to crash with no explanation of the root cause.

void Main() {
#if TMNEXT
    auto app = cast<CTrackMania>(GetApp());
    auto network = cast<CTrackManiaNetwork>(app.Network);

        if (network.PlaygroundInterfaceScriptHandler !is null && network.PlaygroundInterfaceScriptHandler.Playground !is null) {
            auto maps = network.PlaygroundInterfaceScriptHandler.Playground.MapList_Names;
        }
#endif
}

I assume the expected behavior would be either an empty array/buffer (if in game menus) or a array/buffer of wstrings with the map names.

codecat commented 2 years ago

I believe this is not valid code actually; perhaps MapList_Names can't be considered valid unless MapList_Request() is called. Then you also need to wait for MapList_IsInProgress. (You can find a reference implementation in Maniascript in PauseMenuOnline_Client.Script.txt)

Additionally, MapList_Names and MapList_MapUids share the same block of memory (despite both using a different string type), which seems wrong. The Maniascript that uses these properties also never use MapList_Names, and only use MapList_MapUids.