go: port command loop, save/restore, tcell terminal, and the binary
- command.c in full: the command dispatcher with repeat counts, run prefixes, ctrl-run door-stop mode, fight-to-death targeting, and all wizard debug commands; search, help, identify, d_level/u_level, call, current - main.c completed: Run()/playit() with the C double ROGUEOPTS parse; exit()-anywhere becomes a gameEnd panic recovered in Run - save.c + state.c: gob SaveState snapshot with explicit pointer-to- index fixups for equipment, monster rooms, and chase targets (the rs_fix_thing role); save file deleted on restore as in C; SIGHUP/ SIGTERM autosave hook - wizard.c completed (create_obj, show_map), passages.c add_pass - term/: tcell/v2 Terminal — the one third-party dependency — replacing curses and mdport's 900-line key decoder; shell escape via suspend - cmd/rogue: flags -s/-d, SEED (wizard), ROGUEOPTS, ROGUE_WIZARD Tests: full scripted sessions through Run (quit, descend stairs, 3200-move crash sweep, save-command round trip). Notable fixes found by tests: gob silently drops embedded fields of unexported types, and --More-- prompts swallow space-free input scripts.
This commit is contained in:
@@ -138,6 +138,35 @@ func (w *Window) CopyFrom(src *Window) {
|
||||
copy(w.cells, src.cells)
|
||||
}
|
||||
|
||||
// Size reports the window dimensions.
|
||||
func (w *Window) Size() (rows, cols int) { return w.rows, w.cols }
|
||||
|
||||
// CellAt reports the character and standout attribute at a position; used
|
||||
// by Terminal implementations to render the window.
|
||||
func (w *Window) CellAt(y, x int) (ch byte, standout bool) {
|
||||
c := w.at(y, x)
|
||||
return c.ch, c.standout
|
||||
}
|
||||
|
||||
// Contents dumps the window characters row-major (the save file keeps the
|
||||
// visible map, as the C game saved the curses screen).
|
||||
func (w *Window) Contents() []byte {
|
||||
out := make([]byte, len(w.cells))
|
||||
for i, c := range w.cells {
|
||||
out[i] = c.ch
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// SetContents restores a Contents dump.
|
||||
func (w *Window) SetContents(data []byte) {
|
||||
for i := range w.cells {
|
||||
if i < len(data) {
|
||||
w.cells[i] = cell{ch: data[i]}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Line returns row y as a trimmed string; used by tests and the death/
|
||||
// victory screens.
|
||||
func (w *Window) Line(y int) string {
|
||||
|
||||
Reference in New Issue
Block a user