.golangci.yml is the prompts-repo standard verbatim plus one approved
exception (paralleltest, sneak 2026-07-06). Roughly 1,500 findings
fixed:
- autofix sweep (wsl_v5/nlreturn/intrange/modernize formatting), with
the misspell autofix REVERTED where it rewrote authentic C game text
("missle vanishes" stays, with nolint and a comment)
- error handling: errcheck sites get real handling — saveFile now
closes explicitly and removes corrupt saves, scoreboard writes are
documented best-effort, err113 sentinel errors (ErrSaveOutOfDate,
ErrScreenTooSmall); panics allowed for unrecoverable states per
MEMORY.md policy
- gosec: real fixes (ParseInt for SEED, 0600 scorefile) and justified
per-line nolints for provably-bounded conversions (randomMonsterLetter
helper collapses eight rnd(26)+'A' sites)
- API tidying from linters: pointer receivers on flag types
(recvcheck), msg helpers renamed addmsgf/doaddf/Printwf/MvPrintwf
(goprintffuncname), myExit()/findFloor(monst)/mkGameInput(t) drop
always-constant params (unparam), gameEnd carries no status
- gocritic/staticcheck: if-else chains to switches, the pack.c
inventory filter untangled into matchesFilter, main.go split so
defers run before exit (exitAfterDefer, funlen)
- revive doc comments on all exported flag types/consts/methods
Remaining findings are confined to linters pending sneak's exception
decision (mnd, gochecknoglobals, cyclop, nestif, gocognit, exhaustive,
goconst, testpackage); TODO.md records the state. MEMORY.md added at
repo root as the project's agent working notes.
58 lines
2.0 KiB
Go
58 lines
2.0 KiB
Go
package game
|
|
|
|
// Place describes a spot on the level map (rogue.h PLACE).
|
|
type Place struct {
|
|
Ch byte // the base map character
|
|
Flags PlaceFlags
|
|
Monst *Monster
|
|
}
|
|
|
|
// Level is the current dungeon level: the map and everything on it. It is
|
|
// reset in place by NewLevel, matching the C reuse of the global arrays.
|
|
type Level struct {
|
|
Places [MaxLines * MaxCols]Place
|
|
Rooms [MaxRooms]Room
|
|
Passages [MaxPass]Room // one pseudo-room per passage network
|
|
Objects []*Object // lvl_obj: objects on this level
|
|
Monsters []*Monster // mlist: monsters on the level
|
|
Stairs Coord // location of the staircase
|
|
TrapCount int // number of traps on this level
|
|
}
|
|
|
|
// At returns the map cell at (y, x); the C INDEX(y,x) macro, including its
|
|
// column-major (x<<5)+y layout.
|
|
func (l *Level) At(y, x int) *Place {
|
|
return &l.Places[(x<<5)+y]
|
|
}
|
|
|
|
// Char is the chat(y,x) macro: the base map character at a spot.
|
|
func (l *Level) Char(y, x int) byte { return l.At(y, x).Ch }
|
|
|
|
// SetChar updates the base map character at a spot.
|
|
func (l *Level) SetChar(y, x int, ch byte) { l.At(y, x).Ch = ch }
|
|
|
|
// FlagsAt is the flat(y,x) macro, returned as a pointer so ported
|
|
// read-modify-write sites keep their shape.
|
|
func (l *Level) FlagsAt(y, x int) *PlaceFlags { return &l.At(y, x).Flags }
|
|
|
|
// MonsterAt is the moat(y,x) macro: the monster standing at a spot, if any.
|
|
func (l *Level) MonsterAt(y, x int) *Monster { return l.At(y, x).Monst }
|
|
|
|
// SetMonsterAt places (or clears, with nil) the monster at a spot.
|
|
func (l *Level) SetMonsterAt(y, x int, m *Monster) { l.At(y, x).Monst = m }
|
|
|
|
// VisibleChar is the winat(y,x) macro: what is apparently at a spot — a
|
|
// monster's disguise if one stands there, else the map character.
|
|
func (l *Level) VisibleChar(y, x int) byte {
|
|
if m := l.MonsterAt(y, x); m != nil {
|
|
return m.Disguise
|
|
}
|
|
|
|
return l.Char(y, x)
|
|
}
|
|
|
|
// goldCalc is the GOLDCALC macro: how much a gold pile is worth at depth.
|
|
func (g *RogueGame) goldCalc() int {
|
|
return g.rnd(50+10*g.Depth) + 2
|
|
}
|