RPTools / maptool

Virtual Tabletop for playing roleplaying games with remote players or face to face.
http://rptools.net
GNU Affero General Public License v3.0
799 stars 261 forks source link

State edits results in unusable state grid on token #2902

Open dorpond opened 3 years ago

dorpond commented 3 years ago

Describe the bug Scenario: You have an existing campaign, with many maps and many states applied to tokens. For whatever reason, you need to edit an existing state in Campaign Properties, but when you do so, any existing token that had that state applied, will now be gone (good), but the grid slot it was taking cannot be used anymore by other states (bad).

To Reproduce Steps to reproduce the behavior:

  1. I would suggesting using your existing campaign because states are already created.
  2. Apply one of your states on a token (preferably one that is grid image with 3x3 grid size).
  3. After the state is applied, go into Campaign Properties and edit that state - rename it from like Slowed to Slow for example. Save it.
  4. You will notice:

A) The previously applied state vanishes (expected), however, B) Any new states applied to that token, avoids the slot the previously named state was taking, as if it was still there (bug). Even if I 'clear states' on the token, that slot in the 3x3 is no longer available for future states.

Expected behavior If a state property is renamed (edited), the state that existed on any tokens should be deleted AND the grid slot it was taken should be available for other states.

MapTool Info

Desktop (please complete the following information):

Phergus commented 3 years ago

The problem stems from the original state still being part of the token. So if you had a State called Old and renamed it New existing tokens will still have the Old state in their internal States collection even though it won't show up on the States tab nor can it be enabled via setState() function. If you save the token, edit the content.xml and remove the offending State, then load the edited token back in the grid states will function as expected. (Not suggesting you do this necessarily. Just making an observation.)

When the rename process scans the tokens and adds in the "new" state, it need to remove the old one from the token.

Azhrei commented 3 years ago

If an existing state is being modified, shouldn't the changes be reflected on every token that has that state? For example, if the state changed its positioning policy, wouldn't you expect to see that reflected on the map when the dialog was closed? Changing the name of the state doesn't need to be any different.

Phergus commented 3 years ago

I don't have any expectations but changing properties other than the name of a state happens as you say.

Changing the name adds a new state to the token but doesn't remove the old one. Whether it modifies the existing state on the token or adds a new one while removing the old doesn't really matter as long as old states that are no longer part of the campaign are removed from the list on the token.

aliasmask commented 3 years ago

What happens if you save token, delete it, then drop it back on to map? I would assume the drop process does some cleanup assuming tokens could have other attributes not found in current campaign. I would assume [h: setAllStates(0)] would clear all states, even ones not apart of campaign. If not, that should probably be the fix we're after.

dorpond commented 3 years ago

Tested: