Commit Graph

31 Commits

Author SHA1 Message Date
3ed7931676 Merge refactor/object-fields (refactor step 3 + module rename) v0.0.1 2026-07-06 23:10:39 +02:00
43c59b7f82 Update module base path to git.eeqj.de/sneak/rgoue
go.mod, term/ and cmd/ imports, the ARCHITECTURE.md module references,
and the in-game version string. User request; the repo already lives
at this remote.
2026-07-06 23:10:39 +02:00
2eff377a73 Un-overload Object fields and pre-parse damage dice (refactor step 3)
Object.Arm carried four meanings in C (o_arm/o_charges/o_goldval plus
ring bonuses); it is now four fields: ArmorClass, Charges, GoldValue,
and Bonus. Stats.Arm becomes Stats.ArmorClass. The Charges()/GoldVal()
accessor pair is gone.

Damage dice strings ("1x4/1x2") are parsed once into DiceSpec — at
table definition for the bestiary and weapon tables, at creation for
items — instead of re-parsed with atoi on every swing as fight.c
roll_em did. ParseDice preserves the C parse semantics exactly,
including the junk-tolerant "%%%x0" bestiary placeholder and the
"000x0" flytrap reset (regression-tested in dice_test.go); the
flytrap's growing grip becomes DiceSpec{{VfHit, 1}}.

Save format bumps to 5.4.4-go3 (field renames and retypes would
silently zero under gob's match-by-name decoding).

No behavior change; full suite green.
2026-07-06 23:07:57 +02:00
c75af2ec22 Rotate TODO.md for completed refactor step 2
The rotation should have ridden the step-2 commit per the Workflow
section, but the file was edited concurrently and the update was lost;
recording it now. Step 3 (un-overload Object fields) is Next Step.
2026-07-06 22:01:33 +02:00
4b04ac08ea Merge refactor/typed-kinds (refactor step 2) 2026-07-06 22:00:43 +02:00
b940cfc41f Give item categories and subtypes real types (refactor step 2)
ObjectKind separates what an item is from how it draws: Object.Type
(a byte that doubled as the map character) becomes Kind ObjectKind,
with Glyph() producing the display character and objectKindForGlyph
converting back at the map boundary. KindWand covers the C 'stick'
category. The magic-missile bolt uses KindGold, matching C's literal
o_type='*' trick, with a comment.

PotionKind, ScrollKind, RingKind, WandKind, WeaponKind, ArmorKind and
TrapKind are now iota enums with Stringer (names come from the base
info tables); Object gains typed accessors (obj.RingKind(), ...) and
Launch is typed WeaponKind. beTrapped returns TrapKind. The
getItem/inventory/whatis prompt filters take ObjectKind, with
KindCallable/KindRingOrStick replacing the C CALLABLE/R_OR_S
sentinels; wizard.c's type_name table is subsumed by
ObjectKind.String(). IsRing/IsWearing/initWeapon/doPot signatures are
typed accordingly.

The save format version becomes 5.4.4-go2: the gob field rename would
otherwise silently zero Kind when reading old saves.

No behavior change; full suite green.
2026-07-06 22:00:43 +02:00
626f8c5a7d Merge refactor/descriptive-constants (refactor step 1) 2026-07-06 21:29:19 +02:00
e71a2ef3fd Rename constants to descriptive names (refactor step 1)
Pure rename, no behavior change; the full suite (RNG goldens,
generation invariants, scripted sessions, save round trip) is
unchanged and green.

- Creature flags: IsHuh→Confused, IsHalu→Hallucinating,
  CanHuh→CanConfuse, CanSee→CanSeeInvisible, IsRun→Awake,
  SeeMonst→SenseMonsters, IsCanc→Cancelled, IsLevit→Levitating,
  IsBlind/IsGreed/IsHaste/IsTarget/IsHeld/IsInvis/IsMean/IsRegen/
  IsFly/IsSlow → Blind/Greedy/Hasted/Targeted/Held/Invisible/Mean/
  Regenerates/Flying/Slowed, IsFound→Found
- Object flags: IsCursed→Cursed, IsKnow→Known, IsMissl→Missile,
  IsMany→Stackable, ObjIsFound→WasFound, IsProt→Protected
- Room flags: IsDark/IsGone/IsMaze → Dark/Gone/Maze; place flags:
  FPass→FPassage, FPNum→FPassNum, FTMask→FTrapMask
- Trap types: TDoor→TrapDoor ... TMyst→TrapMystery
- Item subtypes: P*→Potion* (PLSD→PotionLSD, PMFind→
  PotionDetectMonsters, ...), S*→Scroll* (SIDRorS→
  ScrollIdentifyRingOrStick, ...), R*→Ring* (RAddHit→RingDexterity,
  RNop→RingAdornment, ...), Ws*→Wand* (WsElect→WandLightning, ...),
  weapons (TwoSword→WeaponTwoHandedSword, Shiraken→WeaponShuriken,
  ...), armor (RingMail→ArmorRingMail, ...)
- Counts: Max{Potions,Scrolls,Rings,Sticks,Weapons,Armors} →
  Num{Potion,Scroll,Ring,Wand,Weapon,Armor}Types; NTraps→NumTrapTypes
- Level.NTraps field → TrapCount (also in the save snapshot)
- Original C constant names preserved as comment breadcrumbs in
  types.go so the lineage stays greppable

TODO.md: step 1 moved to Completed, step 2 (typed kinds) promoted to
Next Step.
2026-07-06 21:28:57 +02:00
aaf72cf894 Add standard Workflow section to TODO.md 2026-07-06 21:06:38 +02:00
1133feb0ba Plan the idiomatic-Go refactor in TODO.md
Itemize the refactor from transliterated port to idiomatic Go: eight
stepped feature branches (descriptive constant renames, typed kind
enums, un-overloaded Object fields, per-subsystem method renames,
god-object extraction, effects dispatch tables, constructor/style
pass, docs refresh), slotted ahead of the existing playtest/lint/
release steps. Also add the styleguide-required .gitignore (a stray
built binary was sitting untracked in the root).
2026-07-06 20:54:32 +02:00
2bcc3894e2 Add TODO.md 2026-07-06 20:46:57 +02:00
c0b533ed2f Make the rgoue branch Go-only
The port is complete, so the C sources and their build system
(autoconf/automake inputs, Makefiles, Visual Studio project, doc
templates, RPM spec, C build/modernization notes) leave this branch;
they live on in master/modern-rogue for reference.

Also ports the last missing wizard command (things.c pr_list/pr_spec,
the '*' item-probability listing), rewrites README.md for the Go port,
and updates ARCHITECTURE.md's layout notes (game/ has no third-party
imports; tcell lives in term/).

Kept: LICENSE.TXT, rogue.png, rogue.desktop, ARCHITECTURE.md.
2026-07-06 20:19:33 +02:00
41fc1042fc 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.
2026-07-06 20:15:47 +02:00
cdf9bf73a9 go: port item effects — potions, scrolls, options, call_it
- potions.c completed: quaff with all 14 potion effects, the PACT
  standard-fuse table (do_pot), raise_level; the see-invisible fruit-
  juice message is computed at quaff time as in C
- scrolls.c in full: read_scroll with all 18 scroll effects including
  the magic-mapping map rewrite and identify dispatch, uncurse
- options.c in full: the interactive options screen, get_bool/get_str/
  get_inv_t/get_sf editors, ROGUEOPTS parsing (prefix matching, no-
  prefixed booleans, ~ expansion), strucpy
- misc.c call_it via the get_str line editor
- turn_see gets a DaemonID (C casts it to a fuse callback for the
  monster-detection potion)

Tests: healing/confusion potions with fuse burn-down, enchant armor,
hold monster, slow-monster zap, ROGUEOPTS parsing, and a regression
test documenting the C wake_monster ISGREED/ISHELD quirk the port
keeps faithfully.
2026-07-06 19:34:36 +02:00
3c5add87cd go: port combat, chase driver, traps, zapping, death and scores
- fight.c in full: fight/attack with all eight special monster attacks
  (aquator rust, ice freeze, rattlesnake poison, wraith/vampire drains,
  flytrap hold, leprechaun/nymph theft), swing, roll_em dice parsing
  (with a C-semantics atoi — Go's strconv rejects '1x4/...'), hit/miss
  message variants, killed, remove_mon
- chase.c completed: runners, move_monst, relocate, do_chase with
  dragon breath, chase target selection (C's dead oroom comparison in
  relocate is preserved as-is)
- move.c in full: do_move with passgo turning, all eight traps,
  rndmove, rust_armor
- sticks.c completed: do_zap (all 14 sticks), drain, fire_bolt with
  wall bounces; weapons.c completed: missile/do_motion/fall/wield
- rip.c: death tombstone, total_winner, killname; C exit() becomes a
  gameEnd panic that Run will recover
- score.go: top-ten scoreboard as a gob file with lock-file protocol
  replacing the XOR-encrypted C format
- wizard.c: whatis/set_know/teleport; daemons.c stomach
- monster bestiary moved to per-game state (C mutates the flytrap
  damage string during play)

Tests: combat math, kill/removal bookkeeping, monster chase pursuit,
death unwinding, scripted-input headless terminal.
2026-07-06 19:23:45 +02:00
a69ef7dc04 go: port dungeon generation, items base, pack, and monster creation
rooms.c, passages.c, new_level.c ported in full: room/maze layout,
corridor spanning tree with extra connections, passage numbering flood
fill, trap/stairs/object placement, treasure rooms. Careful RNG-call
ordering throughout keeps generation seed-faithful to C.

Supporting subsystems this depends on, also ported:
- screen.go: curses replaced by in-memory Window cell buffers behind a
  Terminal interface (tcell arrives with the UI phase; tests run headless)
- io.go: msg/addmsg/endmsg message-line protocol, status line, step_ok
- pack.c in full (add_pack sorting/stacking walk, get_item, inventory)
- things.c in full (inv_name, new_thing, discovery lists, pagination)
- monsters.c in full; chase.c navigation half (roomin/cansee/see_monst/
  find_dest/runto/set_oldch); rings.c, armor.c in full
- weapons.c/sticks.c creation half (init_weapon, fix_stick, num)
- misc.c look() display update, eat, level-up, direction input
- daemons.c callbacks except stomach (needs death()) and the runners
  chase driver (combat phase)
- init.c init_player with the starting kit

Tests: level invariants across seeds, determinism, 30-depth sweep.
2026-07-06 19:05:46 +02:00
7fa2048402 go: port foundation — types, RNG, tables, daemon scheduler
Module sneak.berlin/go/rogue, package game:
- types.go: all rogue.h constants, flag types, Coord/Stats/Room/ObjInfo
- creature.go/object.go: the THING union split into Creature (Player/
  Monster) and Object; slices replace the C linked lists
- level.go: Place map with the C column-major layout and chat/flat/moat/
  winat access methods
- tables.go: extern.c + init.c data (bestiary, item tables, name pools)
- rng.go: the exact C LCG (seed*11109+13849), golden-tested against a
  compiled C reference for seed compatibility
- init.go: per-game item appearance randomization (init.c)
- daemon.go/daemons.go: scheduler with DaemonID replacing function
  pointers (ids match the C save format's mapping)
- game.go: RogueGame holds all former globals; NewGame constructor
2026-07-06 18:46:22 +02:00
45dba95678 Add ARCHITECTURE.md Part 2: Go OOP port design
Design for the Go port (module sneak.berlin/go/rogue):
- RogueGame instance type owns all former globals; no package globals
- THING union split into Creature (Player/Monster) and Object
- Slices replace THING linked lists; list.c is not ported
- Daemon function pointers become serializable DaemonID enum + dispatch
- tcell/v2 (sole third-party dep) replaces curses; Window cell buffers
  preserve the screen-as-data-structure idiom
- encoding/gob snapshot replaces the 2,134-line state.c serializer
- Exact-LCG RNG for seed-compatible dungeon generation, with golden tests
- Per-file porting map, naming conventions, porting order, drop list
2026-07-06 18:17:48 +02:00
91eeee09c5 Add ARCHITECTURE.md Part 1: complete map of the C program
Documents the entire Rogue 5.4.4 C codebase ahead of the Go port:
program flow, source file inventory, the full type system (THING
union, PLACE map, rooms, stats, obj_info, daemons), constants and
flag bits, the macro layer, a census of every global variable, and
a function-by-function catalog of all 36 source files.
2026-07-06 18:13:55 +02:00
David Silva
546829b745 Merge pull request #14 from ndrew222/modern-rogue
change CFLAGS to compile on Linux
2026-05-14 20:59:09 +01:00
ndrew222
3554e0192e change CFLAGS to compile on Linux 2026-01-26 11:46:29 +08:00
David Silva
4eb2e8ae8c Improve README installation instructions for newcomers
- Reorganize Prerequisites section with numbered items for clarity
- Emphasize that ncurses development package is required (not just runtime)
- Update package names: add libncurses-dev for modern Debian/Ubuntu
- Add Fedora-specific instructions using dnf
- Add 'Before you begin' note in Quick Start section
- Improve troubleshooting section with clearer explanations
- Enhance platform-specific notes for macOS Homebrew
2025-11-07 15:51:27 +00:00
David Silva
97aee89f9c Update date in second modernization iteration entry
- Change date from placeholder 2025-01-XX to 2025-11-07 for function prototype fixes
2025-11-07 15:37:05 +00:00
David Silva
f564a46c1c Update modernization log: add dates and cleanup whitespace
- Update date from placeholder to 2025-11-07 in MODERNIZATION_LOG.md
- Mark function prototype warnings as fixed in pending issues
- Remove trailing whitespace in daemon.c, rogue.h, state.c
- Clean up formatting in MODERNIZATION_LOG.md
2025-11-07 15:36:58 +00:00
David Silva
a0c66a6078 Fix function prototype warnings for C23 compatibility
- Add proper function prototypes: fatal(), my_exit(), set_order()
- Fix function pointer types to match call sites: void (*func)(int)
- Remove conflicting localtime() declaration in rip.c
- Fix incorrect new_item() call in state.c (remove unused argument)

Result: Zero compilation warnings, C23 compatible.

See MODERNIZATION_LOG.md for detailed analysis.
2025-11-07 15:33:46 +00:00
David Silva
b66c6659c9 Fix ncurses compatibility: remove internal structure access
- Remove direct access to curscr->_cury and curscr->_curx
- Replace with public API call move() for cursor positioning
- Fixes critical build failure on modern systems with ncurses 6.x
- Build now succeeds on macOS arm64

See MODERNIZATION_LOG.md for detailed reasoning and impact analysis.
2025-11-07 15:30:46 +00:00
David Silva
e13f5c948a Add references to BUILD_ISSUES.md in README
- Add note in Quick Start section about build issues
- Add reference at top of Troubleshooting section
- Add specific entry for ncurses compatibility error in Build Issues
2025-11-07 15:22:13 +00:00
David Silva
45c3e32976 Document build issues found during README testing
- Critical compilation error: direct access to internal ncurses structure members
- Code compatibility issue with modern ncurses (curscr->_cury, curscr->_curx)
- Affects both standard and manual build methods
- Documented on macOS (darwin 25.0.0, Apple Silicon)
2025-11-07 15:20:29 +00:00
David Silva
af5533b279 docs: Improve README with comprehensive tooling and build instructions
- Fix Project Structure section (remove incorrect directory structure)
- Add missing prerequisites (make, m4) with installation instructions
- Clarify when autoreconf is needed vs when configure exists
- Improve Windows build instructions with detailed PDCurses setup
- Add optional documentation tools section
- Enhance troubleshooting with additional common issues
- Add notes about documentation adaptation and executable name variations
- Improve macOS Homebrew instructions for both Intel and Apple Silicon
- Add platform-specific build notes and alternatives
2025-11-07 15:14:20 +00:00
David Silva
4737f1bb61 README.md 2025-11-07 15:09:01 +00:00
David Silva
cf9bd26d56 Rogue - version 5.4.4
I want to preserve the game.
2016-07-23 03:24:54 +01:00