diff --git a/CHANGELOG.md b/CHANGELOG.md index dd37780..a77e428 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 0.2.2 - 2020/02/20 + +### Fixed + +- Addressed an issue where NPC tokens could be leaked to players when the GM clicks on an NPC. +- Addressed an issue where the GM moving NPC tokens did not update shared vision of those tokens. + ## 0.2.1 - 2020/02/01 ### Fixed diff --git a/module.json b/module.json index 3162b12..85a62aa 100644 --- a/module.json +++ b/module.json @@ -1,6 +1,6 @@ { "name": "shared-token-visibility", - "version": "0.2.1", + "version": "0.2.2", "title": "Shared Token Visibility", "description": "Shares visibility of individual tokens between all players, regardless of dynamic lightning", "author": "Steven Fuqua", diff --git a/src/RevealedTokenLayer.ts b/src/RevealedTokenLayer.ts index 262f8ac..45b0d13 100644 --- a/src/RevealedTokenLayer.ts +++ b/src/RevealedTokenLayer.ts @@ -191,10 +191,24 @@ export class RevealedTokenLayer extends CanvasLayer { updateTokens(_userId: string, updates: Array<{ _id: string }>): void { let dirty = false; for (const { _id: tokenId } of updates) { + // This means we have shared vision of this token and aren't drawing it ourselves, + // so the token needs to move if (this.revealedTokens.has(tokenId) && !this.myVisibleTokens.has(tokenId)) { dirty = true; break; } + + // Whether this token is currently being drawn on this client + const tokenVisible = canvas.tokens.get(tokenId)?.visible; + + // This means something's out of sync and we need to rebuild our status + if ( + !!tokenVisible !== this.myVisibleTokens.has(tokenId) || + !tokenVisible !== this.myHiddenTokens.has(tokenId) + ) { + dirty = true; + break; + } } if (dirty) { @@ -206,6 +220,11 @@ export class RevealedTokenLayer extends CanvasLayer { * Fires off the current visibility status to other clients. */ emitVisibilityUpdate(): void { + // If we're a GM, we want to avoid leaking tokens to the players + if (game.user.isGM) { + return; + } + const update: TokenVisibilityUpdate = { type: "visibilityUpdate", userId: game.userId,