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

adding non-standard server option 'fix_chest_missing_inventory_window' to fix chest bug #3134

Merged
merged 1 commit into from
Aug 22, 2022

Conversation

gmriggs
Copy link
Collaborator

@gmriggs gmriggs commented Aug 18, 2020

This is a relatively simple server modification to fix a bug in acclient / odd network protocol. It does some very non-standard things with ObjectDescriptionFlags.Openable for Chests though.

Repro steps:

  • Find any locked chest, ie. /teleloc 0xC6A90024 [104.717110 89.921745 42.005001] -0.839618 0.000000 0.000000 -0.543177
  • Open network lag simulator https://jagt.github.io/clumsy/, and simulate 500ms of UDP lag
  • Appraise chest, confirm it takes ~1s for appraisal window to come up
  • Type /crack, press enter, and then immediately press R to open chest (before unlock sound plays)

Expected:
Chest opens, and chest inventory window is displayed

Actual:
Chest opens, but no chest inventory window is displayed. Effectively wastes a key for the player

acclient:

ClientUISystem::OnViewContents:

  if ( obj == v9->requestedGroundObject
    && (obj != ACCWeenieObject::prevRequestObjectID || ACCWeenieObject::prevRequest != 4) )
  {
    CM_Item::SendNotice_SetGroundObject(v9->requestedGroundObject);
    ACCWeenieObject::RecordResponse(obj);
  }

When R is pressed before the unlock sound is heard, requestGroundObject == 0. Normally, this should be the id of the chest, ie. when R is pressed after the unlock sound

Tracing backwards, in ItemHolder::AttemptSetGroundObject:

    if ( v2->pwd._bitfield & 1 )
    {
      v5 = ClientUISystem::GetUISystem();
      ClientUISystem::SetGroundObject(v5, _objectID, 1);
      v1 = (ClientUISystem *)1;
    }
    else
    {
      if ( !((int (__thiscall *)(ACCWeenieObject *))v2->vfptr[11].__vecDelDtor)(v2) )
      {
        v4 = ACCWeenieObject::GetObjectNameWide(v2, &result, NAME_APPROPRIATE, 0);
        PStringBase<unsigned short>::PStringBase<unsigned short>(&errorText, 0, L"The %s is locked", v4->m_charbuffer);
        PStringBase<char>::~PStringBase<char>((CaseInsensitiveStringBase<PStringBase<char> > *)&result);
        StringInfo::StringInfo(&siError);
        StringInfo::SetLiteralValue(&siError, &errorText, 1);
        ECM_UI::SendNotice_DisplayStringInfo(0x1Au, &siError);
        StringInfo::~StringInfo(&siError);
        PStringBase<char>::~PStringBase<char>((CaseInsensitiveStringBase<PStringBase<char> > *)&errorText);
      }
      v1 = 0;
    }

pwd._bitfield & 1 is ObjectDescriptionFlags.Openable. If the chest is locked, the client automatically displays the message "The chest is locked", but then continues to send the request to the server to open the chest (presumably so the server can play the 'locked' sound)

This bug happens in the small window of time when there is a state difference for PropertyBool.IsLocked for the chest, between the client and the server. After the server has sent PropertyBool.IsLocked=false, but before the client has received it. If the client still thinks the chest is locked, but then the request to open it on the server succeeds (server state is unlocked, unlock state not yet received by client), it results in this bug.

Tracing the usage of ObjectDescriptionFlags.Openable in acclient, I haven't seen it used for much directly, aside from displaying this message automatically on the client. The client automatically updates its version of ObjectDescriptionFlags.Openable when it receives a PropertyBool.IsLocked update from the server, so that has been suppressed. However, when appraising the chest, it still correctly shows the 'Locked' status message, as PropertyBool.IsLocked can still be sent in the Appraisal properties, without the client updating the ObjectDescriptionFlags.

I have seen no anomalies from this patch yet. The only issue is that it goes off course for ObjectDescriptionFlags.Openable for chests. Other than that, I have seen no side effects in-game yet.

This is a non-standard server option, and not recommended generally.

@Gordian3
Copy link
Contributor

If this generally works.. and is by default a disabled server, option, why hasn't this been merged?
As a player, this is the most annoying bug to me.

@LtRipley36706 LtRipley36706 merged commit 3fd3bed into ACEmulator:master Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants