So, back in, what was in, 2015, I proposed a couple of new Glulx opcodes to make UNDO handling just a little bit cleaner.
Forum thread: Adding a @discardundo opcode
The opcodes look like this:
@hasundo S1
Test whether a VM state is available in temporary storage. S1 is set to 0 if a state is available, 1 if not. If this returns 0, then
@restoreundo
is expected to succeed.
@discardundo
Discard a VM state (the most recently saved) from temporary storage. If none is available, this does nothing.
The simplest way to make use of this would be to add a @discardundo
opcode to the āI didnāt recognize that commandā parser error. Then muffed command inputs wouldnāt take up an UNDO slot.
(Youād do a @gestalt
feature test before calling the opcode, so it wouldnāt crash on older interpreters. They just wouldnāt get the benefit. Theyād behave the way all games do today, where unrecognized verbs do take an UNDO slot.)
You could do this for other parser errors as well. Although this might start to cause problems for games that convert parser errors into real game actions. (Some games certainly do this.)
You could go deeper with this ā make UNDO less of a hack in the whole parser loop. But Iād definitely want to start with a conservative change.
Anyhow, the first step is to get the opcodes into interpreters (and the I6 compiler). It turns out I did the implementation back in 2015, and thenā¦ umā¦ never got around to pushing it out? I really canāt remember what the stumbling block was.
If you remember ā too late! Iāve already merged the change into the Glulxe and Quixe interpreter source. And posted pull requests for Inform 6 and the Git interpreter.
Once those are in circulation, Iāll figure out an I7 parser patch (the ādidnāt recognize that commandā change).