Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

[Bug] Player clients trying to update GM tokens after combat #263

Closed
adotor opened this issue Mar 18, 2022 · 3 comments
Closed

[Bug] Player clients trying to update GM tokens after combat #263

adotor opened this issue Mar 18, 2022 · 3 comments
Assignees

Comments

@adotor
Copy link

adotor commented Mar 18, 2022

Foundry: 9.255
DnD5e: 1.5.7
DnD5e Helpers: 4.0.0

When ending a combat players receive an error message, e.g "Error: User Alex lacks permission to update Token [L0FAc8SE9WPJbauL] in parent Scene [fs02Kuyzx4xScGbi]".

The token is a dead hostile NPC owned by the GM (player permissions: none).

Debugging, I found the cause of this message: a websocket request from dnd5e-helpers to update this token.

"4397[
{
  "userId":"tlu0qAChAoAIvEDF",
  "request":{
    "action":"update",
    "type":"Token",
    "parentType":"Scene",
    "parentId":"fs02Kuyzx4xScGbi",
    "updates":[
      {
        "flags":{
          "dnd5e-helpers":{
            "-=ActionManagement":null
          }
        },
        "_id":"L0FAc8SE9WPJbauL"
      }
    ],
    "options":{
      "diff":true,
      "render":true
    },
    "pack":null
  },
  "error":{
    "class":"ServerError",
    "message":"User Alex lacks permission to update Token [L0FAc8SE9WPJbauL] in parent Scene [fs02Kuyzx4xScGbi]",
    "stack":"Error: User Alex lacks permission to update Token [L0FAc8SE9WPJbauL] in parent Scene [fs02Kuyzx4xScGbi]\n    at ServerDatabaseBackend._updateEmbeddedDocuments (file:///<foundryDir>/resources/app/dist/database/backend/server-backend.mjs:1:3611)\n    at async Semaphore._try (file:///<foundryDir>/resources/app/common/utils/semaphore.mjs:99:17)"
  }
}
]"
@trioderegion
Copy link
Owner

Good catch and great debugging, this will make it easy to pin down. I'm sure we simply missed a "isGM" checkpoint in that logic. Thanks!

@trioderegion trioderegion added this to the next milestone Mar 18, 2022
@adotor
Copy link
Author

adotor commented Mar 18, 2022

Some more hints. The last call is Deleted Combat with id [AlI2mVkX0BnVY0JD].

Looking into the code in the _deleteCombat hook it seems to me each client might iterate over every combatant and execute _deleteCombatant which in turn does token.removeActionFlag() (which looks at a first glance like the message that is sent to the server).

Is it necessary that each user requests this or is it enough if the owner of a token does this cleanup?

@trioderegion
Copy link
Owner

The primary owner (player for characters, GM for NPCs) should be handling this logic rather than everyone trying to do it for all combatants.

@trioderegion trioderegion self-assigned this Mar 18, 2022
trioderegion added a commit that referenced this issue Mar 18, 2022
Flag updates on ending combat will only be done by an owner. Note, as currently implemented, multiple extraneous updates will be performed by each owning client. This is needed to also update their action container display, which is undesirable. Closes #263

Beginning combat will now (hopefully) clear out any helpers action markers left from previous error states.

Used actions should now update on all clients regardless of which client initiated the action.
@trioderegion trioderegion removed this from the next milestone Apr 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants