Force-ending a turn?

I’m pretty much finished with a massive revision to my Basic Real Time extension, thanks largely to Erik Temple and Andrew Plotkin. Everything works like it should, with one minor issue: ending the game does not work, as this check is done at the end of the turn. So the player has to type an incongruous command before he/she can win/be killed.

I suppose I can cheat by tossing in a meta “[Type any command.]” in there, but I really don’t want to. Is there a way to force-end the turn so that ending the game can work properly once the rest of the action happens?

Have you looked into writing a “for reading a command” rule that applies only when you’ve set a custom “end game now” flag? I’ve used this trick before to “skip” turns.

Sarah, I suspect that the real problem is the need to escape from the input loop. In a typical game, the vast majority of real-time events are going to fire while a line event is pending, simply because a line event is pending most of the time. When the event fires, the game is still in the standard input loop, defined in the VM_ReadKeyboard() routine in Glulx.i6t. In most situations, this isn’t a problem–the player will still be able to enter commands after the event fires. When the game ends as a consequence of a real-time event, though, we do have a problem: The game is still waiting for input, but we don’t want the player to have to give any.

Off the top of my head, I think that the way out of this is probably to hack the parser to check for the deadflag from within the input loop in VM_ReadKeyboard, and use this to escape the loop. There are multiple levels in the library’s call to that routine though, and this method will probably also require handling the deadflag appropriately in these routines as well. But maybe someone else has a more elegant suggestion.

N.B. I don’t think that Inform waits until the end of the turn to end the game. I believe it checks the deadflag (the I6-level variable) whenever it processes a rulebook–or something like that. (Otherwise the every turn rules would fire, for example, even if the game was ended from within the action rules, which run earlier. This doesn’t happen.)

–Erik

Hm. I wonder if it’s possible to do this from I7? Not speaking from total experience here, but it doesn’t seem like it’d be that catastrophic to do. (Famous last words!)