Eranziel / foundryvtt-lancer

A Foundry VTT game system for LANCER RPG.
GNU General Public License v3.0
107 stars 64 forks source link

[BUG] NPC Class swap code runs on all clients #700

Closed Eranziel closed 4 months ago

Eranziel commented 5 months ago

Describe the bug Adding an NPC class to an NPC while player clients are logged in produces errors.

To Reproduce Steps to reproduce the behavior:

  1. Log in with a GM user and a player user.
  2. Create an NPC actor.
  3. Add an NPC class to the new actor.
  4. Player client throws errors about not having permission to add items to the actor.

Expected behavior The class swap code should only run on one GM client, and therefore not cause any errors.

Eranziel commented 5 months ago

Likely also happens on pilot imports, for example when the frame is added to a mech and triggers an image change.

BoltsJ commented 4 months ago

I haven't looked into this yet, but I suspect some of it is stuff for activeEffects in an _onUpdate method triggering further updates, it should probably be moved elsewhere. Ideally, it would be in _preUpdate to modify the update data and get it done in one db operation and also only on one client, but if it's not feasible, then it should probably be guarded by ownership rather than specifically gm permission.