openplanet-nl / issues

Issue tracker for Openplanet.
10 stars 0 forks source link

`MwFastArray<float>` is not mutable when non-const #523

Closed CodyNinja1 closed 2 months ago

CodyNinja1 commented 2 months ago

For example, CFuncKeysReal (in MP4) has MwFastArray<float> Ys. Trying to modify any of this array's items has the changes reverted next frame.

void Render()
{
    auto wagon = cast<CPlugTrainWagonModel>(GetWagonFromFileName("Loco.Wagon.gbx")); // GetWagonFromFileName gets CMwNod for wagon in Valley/Media/Trains
    CFuncKeysReal@ FuncKeys = wagon.AccelCurve;

    print(FuncKeys.Ys[0]); // Change is reverted next frame.
    FuncKeys.Ys[0] = 1000;
    print(FuncKeys.Ys[0]);
}
codecat commented 2 months ago

This sounds like a bug - I will investigate.

CodyNinja1 commented 2 months ago

Here is the GetWagonFromFileName() function:

CMwNod@ GetWagonFromFileName(const string&in filename)
{
    auto file = Fids::GetGame("GameData/Valley/Media/Trains/" + filename);
    auto nod = Fids::Preload(file);
    return nod;
}

Do note that only Loco.Wagon.gbx has a non-null AccelCurve.

CodyNinja1 commented 2 months ago

This issue appears to have been a programming mistake on my end, sorry for any inconvinence.

codecat commented 2 months ago

Good to know, thanks for the update. Can you let me know what the mistake was?

CodyNinja1 commented 1 month ago

My mistake was that I used ImGui's input fields incorrectly, so nothing really related to the MwFastArray itself.