Open
Conversation
Now placing a player won't erase what's on the wrong initial player coords. This problem came up in some worlds produced by my ZZT puzzle generator. (Not really related to #BIND functionality improvement.)
This should keep any breaking #BIND links from making ZZT behave unpredictably.
For later debugging purposes.
This will be used for determining if the destination of copy and paste has the source for bound objects.
The first part moves objects that would be overwritten and are bound to by other objects outside the pasting area, out of the pasting area.
Fix hash table bugs as well.
Now I just need to find out how to copy params and extend the param array without running afoul of KevEdit's internal malloc/free calculus.
Known bugs: - There are some double frees I need to track down. - It copies paramless tiles if the param would exceed the limit, instead of omitting them. The double frees don't happen if the user unloads and reloads the board between cuts and pastes. So there's something strange going on with tile.param, I suspect.
This fixes the double free that goes away on board reload. There's still one when copying multiple bound objects without their source to the same board they're from. In addition, copying multiple objects with the same source (but without the source) to another board makes them all unbound; only one of them should, and the rest should bind to it instead. The latter problem is with misc.c:544. Find out just what's going on later.
The bug was caused by not incrementing a counter properly. This has been moved to the beginning of the relevant loops so there's less special casing going on.
We might argue that the new pasting function is so complex that it shouldn't be used until the user has decided where to place the selection. But if that's a problem, a simple "|| preview_mode" on the "If there are no objects to add" if statement should do the job much more easily.
…ctions. This fixes a subtle bug where copying the player would overwrite adjacent tiles, and consistently using isselected_both makes the code easier to understand even when not strictly necessary. Add parentheses to a macro in keys.h as well.
Contributor
|
The PR is complex, so maybe that's already been done, but I'd like to note down to make sure that the object being bound to should ideally always come before the objects binding to it in the stat order. ZZT prefers it that way. |
These fix operations are done on board load and save, and on pasting something onto a board. Previously it would only normalize on a board being saved or loaded.
Contributor
Author
|
Done. |
This is more true to what ZZT itself does.
Contributor
Author
|
Some tests/demos of the patch's functionality: https://munsterhjelm.no/km/zzt/kevtest.zzt |
Contributor
Author
|
If the PR is too imposing, I could try to split it into different components or see if anything could be simplified. |
Contributor
Author
|
It's been a while, so I thought I'd comment. Any chance of getting this incorporated, or should I refactor or split it up into something less extensive? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Another Oktrollber-inspired bout of coding: while I was creating my game, I noticed that after editing, the game would sometimes cause weird behavior in ZZT (including reads from unallocated memory). I think this was due to dangling #bind indices and indices that didn't change as copied objects around, hence this.
The patch resolves bind index chains and cycles (A->B->C or A->B->C->A) on loading and saving a board. On pasting it uses the following reasoning:
It relinks bind indices when cutting stuff as well: if the original source object of bound objects is removed, then one of the bound objects becomes the new source and they all link to it. And finally it does a reasonable job of preserving follower/leader chains, though it won't turn segments into heads.