Skip to content

Broken object state with piece ownership fix  #64

@jsza

Description

@jsza

(See #43)

If a client interacts with a Piece that they've newly created, like a chest, this can happen:

  • Client places container; client owns container.
  • Client interacts with container
    1. Container.Interact invokes "RequestOpen" RPC
    2. Because the client owns the container, "RequestOpen" RPC is not routed to the server and is instead called on the client immediately
    3. Container.RPC_RequestOpen is called
    4. Sets owner to the client (does nothing because already owned by client)
    5. Invokes "OpenRespons" RPC which is is not routed to the server and is instead called on the client immediately
    6. Container.RPC_OpenRespons is called
    7. Calls InventoryGui.instance.Show(this)

Meanwhile, InventoryGui.UpdateContainer runs this every frame:

if (this.m_currentContainer && this.m_currentContainer.IsOwner())
{
    this.m_currentContainer.SetInUse(true);
}

Which chains to Container.UpdateUseVisual which calls:

if (this.m_nview.IsOwner())
{
     flag = this.m_inUse;
     this.m_nview.GetZDO().Set("InUse", this.m_inUse ? 1 : 0);
};

So ultimately, the client is able to set the "InUse" value on the ZDO because as far as it's concerned it's the owner. Then when the ownership change arrives from the server, the client gets kicked out of the container but can't unset the "InUse" key because the client no longer owns the container. The chest is now broken until all players leave the area and return at which point the chest is recreated and now works correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions