Port the '+' wizard-mode toggle-off (closes #11)
C's command.c 317-338 has a `when '+'` arm in the main command switch, under #ifdef MASTER, that toggles wizard mode. The port had no '+' at all, so the key fell through dispatchKey's default to illcom and answered "illegal command '+'". The password half of that arm was dropped deliberately (wizard mode is ROGUE_WIZARD configuration) and is recorded in ARCHITECTURE.md section 9. The leave half was lost silently, and it is a different decision: it does not touch the password machinery. The substantive part of it is turn_see(TRUE) rather than the flag -- wizard sight draws every monster the hero cannot see, so without the re-hide there is no way back to normal visibility, and clearing the flag alone would leave the screen lying. New wizardToggleCommand, registered in commandHandlers between '^' and Escape, which is C's own switch order. Because C's arm sits in the main switch rather than the `if (wizard) switch (ch)` sub-switch that wizardCommand ports, it is reachable whether or not wizard is set, so the non-wizard case was a divergence too. It resolves the way the dropped passwd() forces: a password check that no longer exists can never succeed, so the else arm is what C did on a wrong answer -- the message "sorry", with no prompt, since nothing typed into one could change the outcome, and none of the noscore/turn_see(FALSE) bookkeeping of C's unreachable success branch. The choice is stated in the doc comment and in section 9. Two tests drive '+' through g.dispatch. The wizard one spawns a phantom (ISINVIS straight from the monster table, so seeMonst is false and it is on screen only because wizard sight put it there), asserts the precondition, then asserts the flag cleared, SenseMonsters cleared, the cell restored to the map char under the monster with standout off, the exact message text, and After false. Deleting the turnSee(true) call fails it on all three visibility assertions. The other pins "sorry". No RNG call is added: the turn_off arm of turn_see never reaches rnd. TestSeedCompatItemTables is green against the untouched golden.
This commit is contained in:
@@ -1784,7 +1784,7 @@ exit. Those are the steps referenced above (e.g. "step 5", "step 7").
|
||||
| `md_readchar` escape decoding | tcell decodes keys | key-event translation table |
|
||||
| XOR save/score encryption | obscurity, not security | plain gob (file perms 0600) |
|
||||
| save-file symlink/hardlink checks | single-user era anti-cheat | none |
|
||||
| DES crypt wizard password | ditto | `ROGUE_WIZARD` env var |
|
||||
| DES crypt wizard password (`passwd()`, the `'+'` enter arm) | ditto | `ROGUE_WIZARD` env var |
|
||||
| load-average / user-count gating (`too_much`, `ucount`, CHECKTIME) | 1980s timesharing courtesy | none |
|
||||
| tty dsusp/ltc character juggling | tcell owns the tty | none |
|
||||
| shell escape (`!`) setuid dance | no privileges to drop | plain `os/exec` shell |
|
||||
@@ -1793,6 +1793,16 @@ exit. Those are the steps referenced above (e.g. "step 5", "step 7").
|
||||
| SIGINT → the interactive `quit()` prompt | see below | `Q`; SIGINT exits cleanly |
|
||||
| `auto_save` on SIGILL/TRAP/FPE/BUS/SEGV/SYS | see below | none |
|
||||
|
||||
Only half of C's `'+'` command (`command.c` 317-338) goes with the password row.
|
||||
The leave arm is ported in full as `wizardToggleCommand`: it clears the wizard
|
||||
flag, calls `turnSee(true)` — C's `turn_see(TRUE)`, without which there is no
|
||||
way back out of wizard sight once it is on — and prints "not wizard any more".
|
||||
What `passwd()` takes with it is the enter arm. A password check that no longer
|
||||
exists is a password check that can never succeed, so `'+'` outside wizard mode
|
||||
reduces to what C did when the answer was wrong: the message "sorry", with no
|
||||
prompt, since nothing typed into one could change the outcome, and none of the
|
||||
`noscore`/`turn_see(FALSE)` bookkeeping of C's success branch.
|
||||
|
||||
The three signal rows warrant more than a table cell.
|
||||
|
||||
**SIGTSTP / `tstp()`.** Not handled, deliberately. Ctrl-Z cannot reach the game
|
||||
|
||||
Reference in New Issue
Block a user