Aug 11, 2009 at 12:29 AM
I don't see how a selective undo could work. Since edits happening after the "undone" edit may be contingent on the undone edit.
If you think about it, each tile takes up only 1 byte of space so storing the entire map in memory only takes width * height bytes to store. While storing a single specific tile takes 5 bytes (1 for the tile and 2 for the x coord and 2 for the y coord) which means that if more than 1/5 the map is changed by a command it would actually take more space to store the undo. Plus, it would take a lot longer to reset a set of tiles than it would to just replace them all whole sale.
The other option is keeping the original map and a list of all commands used on it and reprocess of the commands-1 for an undo but that would really take some time on a large map that you've done a lot to.
Entities are a little different since they're a bit more complicated.
Right now the simplest way to do this is also the best way to do it too: simply take a snapshot of the map before every edit.Celtic Minstrel said:Wistil, were you going to use an actual stack for undo? Or were you considering anyone else's suggestions for how to do it? I (obviously) think my (doubly-linked) list version is the best one, because it allows for effectively infinite undo and redo (unless arbitrary limits are imposed, which is probably advisable).
If you think about it, each tile takes up only 1 byte of space so storing the entire map in memory only takes width * height bytes to store. While storing a single specific tile takes 5 bytes (1 for the tile and 2 for the x coord and 2 for the y coord) which means that if more than 1/5 the map is changed by a command it would actually take more space to store the undo. Plus, it would take a lot longer to reset a set of tiles than it would to just replace them all whole sale.
The other option is keeping the original map and a list of all commands used on it and reprocess of the commands-1 for an undo but that would really take some time on a large map that you've done a lot to.
Entities are a little different since they're a bit more complicated.
I was thinking more along the lines of a Mac version of the editor. With all the offsets and save commands are in the general.cpp I think it would be a case of changing anything specific that needs to be changed for the MAc version to read it correctly but that may be naive since I really don't know anything about the Mac executable format.Celtic Minstrel said:I have my doubts about whether it would be possible to port this code at all. Even if it is, it would be very difficult, because anything that changes the executable would almost have to be rewritten.