Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Beatrix can cause the game to crash #3

Closed
Albeoris opened this issue Apr 30, 2016 · 4 comments
Closed

Using Beatrix can cause the game to crash #3

Albeoris opened this issue Apr 30, 2016 · 4 comments
Assignees

Comments

@Albeoris
Copy link
Owner

Albeoris commented Apr 30, 2016

There is no suitable animation or dialog and Beatrix does not participate in the scene, which leads to a crash of the game.
It happened at the end of Memoria. It is possible that meet the problem elsewhere. Be careful.

NullReferenceException: Object reference not set to an instance of an object
at EBin.getvobj (.Obj obj, Int32 type) [0x00000] in :0
at EBin.getvi () [0x00000] in :0
at EBin.expr_jumpToSubCommand (Int32 arg0) [0x00000] in :0
at EBin.expr () [0x00000] in :0
at EBin.jumpToCommand (Int32 arg0) [0x00000] in :0
at EBin.next (Int32 arg0) [0x00000] in :0
at EBin.ad3 (Int32 arg0) [0x00000] in :0
at EBin.ProcessCode (.ObjList objList) [0x00000] in :0
at EventEngine.ProcessEvents () [0x00000] in :0
at EventEngine.ServiceEvents () [0x00000] in :0
at HonoluluFieldMain.FF9FieldMapMain (Int32 MapNo) [0x00000] in :0
at HonoluluFieldMain.FF9FieldLocationMain (Int32 LocNo) [0x00000] in :0
at HonoluluFieldMain.HonoUpdate () [0x00000] in :0
at HonoBehaviorSystem.Update () [0x00000] in :0

@wrongstuff
Copy link

Also occurs in Kuja's castle when selecting a party for Oeilvert.

Occurs at Oeilvert at the door at the beginning

@Tirlititi
Copy link
Collaborator

Tirlititi commented Feb 22, 2017

It occurs everytime the script asks for a field object based on the party members.

In EventEngine.cs:

    public Obj GetObjUID(Int32 uid)
    {
        if (uid == Byte.MaxValue)
            return this.gCur;
        if (uid == 250)
            uid = this._context.controlUID;
        else if (uid >= 251 && uid < Byte.MaxValue)
            uid = this._context.partyUID[uid - 251];
        ObjList objList = this._context.activeObj;
        while (objList != null && objList.obj.uid != uid)
            objList = objList.next;

        return objList?.obj;
    }

If Beatrix is in the party, the related "partyUID" object is an empty object without any functions/model related to it.

A possible temporary fix can be made in SetupPartyUID:

    private void SetupPartyUID()
    {
        Byte[] numArray1 = new Byte[9] {0, 6, 3, 1, 4, 5, 7, 2, 8};
        Byte[] numArray2 = new Byte[9] {0, 3, 7, 2, 4, 5, 1, 6, 8};
        Int32 num = 0;
        for (Int32 index = 0; index < 4; ++index)
            this._context.partyUID[index] = Byte.MaxValue;
        for (Int32 index = 0; index < 4; ++index)
        {
            Int32 partyMember = this.eTb.GetPartyMember(index);
            if (partyMember >= 0) {
                // If Beatrix is in the team, we make it so the engine thinks it's another member instead
                if (partyMember == 8) {
                    if (!partychk(1))
                        partyMember = 1;
                    else if (!partychk(2))
                        partyMember = 2;
                    else if (!partychk(3))
                        partyMember = 3;
                    else 
                        partyMember = 0;
                }
                num |= 1 << numArray2[partyMember];
            }
        }
        Int32 index1 = 0;
        Int32 index2 = 0;
        while (num != 0)
        {
            if ((num & 1) != 0)
            {
                this._context.partyUID[index1] = (Byte)((UInt32)(this.sSourceObjN - 9) + numArray1[index2]);
                ++index1;
            }
            ++index2;
            num >>= 1;
        }
    }

EDIT: I'm not sure if it will fix the crash in Memoria (right before Necron's fight) because it's a bit more complicated there. It should fix the bugs in Kuja's castle, Oeilvert, Ipsen Castle...

@Albeoris
Copy link
Owner Author

I add this fix to the Memoria but need to check CD3 where Steiner and Beatrix fighting together.

Albeoris pushed a commit that referenced this issue Jun 14, 2020
* Update FieldMap.cs

* Update NarrowMapList.cs
@iamelsun
Copy link

iamelsun commented Dec 9, 2020

Hi where can I apply the fix Tirlititi provided?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants