-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix offset placement for Place Marker & Replace with Other #13720
Fix offset placement for Place Marker & Replace with Other #13720
Conversation
…Place Marker's stack operations when an offset is specified.
This PR makes PlaceMarker comply to the documented behaviour "Any value other than zero will prevent the new piece from stacking with the original piece.". |
Is this going to cause a problem if the offset causes the new piece to overlap an existing stack? You now have a supposedly stack-able piece overlapping a stack without being added to the stack (I have no idea if that is actually a cause for concern or not).... |
A fair question, thanks. The documentation effectively advises that's exactly what will happen for the piece's current stack, so it would seem consistent for that same behaviour to apply to any stack. I do have a nagging question as to whether SnapToGrid negates that, however. Going deeper, another question might be, why can't PlaceMarker apply its Stack setting in combination with the Offset action. My novice conclusion is that for PlaceMarker to do that would require a lot of extra overhead (code) to handle remote placement. By which I mean, PlaceMarker knows about its piece's own stack but nothing about other locations. One solution for the module designer is to use a Movement trait to wobble the piece at its new location and also do any positioning with the stack. This seems a reasonable accommodation to me. |
This begs the question of whether we actually want to allow this behaviour, or whether the documentation is needs to be corrected. The title of the original issue is actually incorrect. Place Marker does not actually 'Ignore' an offset, it is just that a small offset that does not displace the counter far enough away to be out of range of counter or hex snapping gets over-ridden. In EXACTLY the same way that drag'n drop of a counter in that same location would. This PR is creating a special case to over-ride standard behaviour. What is the actual use case for having a slightly offset piece, which generates 2 very close stacks? This can be achieved using Game Piece Layers or Non-stacking pieces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Querying the need for this PR at all. Should it be a documentation fix? See extended comment above.
Not disputing that some small offsets maybe should behave like a drag and drop, but the issue in question manifests regardless of the offset, providing the piece is Stackable it WILL stack at the original location regardless. |
Ah, I had not quite realised the seriousness. So currently, if the marker and the source stack are all stackable (lines 240-284), then the calculated destination for the piece (p) is completely ignored and the marker is inserted into the same stack as the source, There is some special case code to handle top/bottom/up/down. The second else (lines 285-295) is activated when either the source piece is non-stacking, or the pieces cannot be merged. It does a placeOrMerge(), to the correct destination, which may find a valid Stack there, in which case it has some special case code to place the piece at the bottom of that stack if Bottom or Below was selected. The final Else (lines 296-298) is activated when we have a non-stacking marker. We just place it directly at the destination. In you solution, this path will be taken by all markers with an offset specified. I can see a couple of issues with your proposed solution.
|
Thanks @BrentEaston. With your guidance, I now wonder if step 1 is actually causing the problem. Would this simplified logic work better (assume rotation matching preserved)?
*I question if the Below option should have any meaning away from the source piece's stack but as this is doubtless now a backward compatibility requirement, it's enough to clarify in the documentation if need be. |
…pieces, whilst preserving the effect of other trait settings.
…pieces, whilst preserving the effect of other trait settings.
…pieces, whilst preserving the effect of other trait settings.
Not working yet for Above & Below within parent stack. |
…ditional on zero offset. However, placeOrMerge is always used in other cases, unless the new marker is non-stackable.
… Update to trait reference sections to clarify the effect of offset on Place Marker options.
… Update to trait reference sections to clarify the effect of offset on Place Marker options.
I am liking the direction you have taken. I was thinking it could be simplified. I am trying to think what the impact will be.
How many modules are likely to be effected do we think? We could add a compatibility preference, but I am not a huge fan of these as a) It's not an obvious fix if the module suddenly stops working and b) Each player has to do this in their own preferences. Another way to handle this is to add a version number to the trait, and add code so that the old behaviour continues until the module is next edited and re-saved. New traits will be always use the new behaviour. This doesn't stop the 'surprise' happening, but it means it happens when the developer next releases an update, not when Vassal updates. |
Trying to implement my proposed "simplification" was educational. Now that I can see that the Above/Below options rely on the new piece remaining in the stack with the parent piece, I understand why the code is structured as it is and that there's extra complexity to add back in if I continue down that path. So, I've reverted to my original solution but got rid of the offset check at the second else (lines 285-295), which I can see was an error on my part. The impact of this on trait outcomes is just the one change highlighted below:
I've also updated the Place Marker & Replace with Other help sections to clarify the impact of specifying an Offset and its effect on the Place Marker options. I stripped out and modified a module to test both traits in the various combinations under consideration: @BrentEaston - this still leaves the compatibility gap that you mention. How would I go about trait versioning? Is there an example I can look at? |
Have a look at ActionButton and ReturnToDeck. |
Continued via #13801. |
… This change explicitly bypasses Place Marker's stack operations when an offset is specified.