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.
This commit is contained in:
2026-07-06 21:28:57 +02:00
parent 1133feb0ba
commit e71a2ef3fd
32 changed files with 646 additions and 650 deletions

View File

@@ -9,19 +9,19 @@ const dragonShot = 5
func (g *RogueGame) runners(int) {
list := append([]*Monster(nil), g.Level.Monsters...)
for _, tp := range list {
if !tp.On(IsHeld) && tp.On(IsRun) {
if !tp.On(Held) && tp.On(Awake) {
origPos := tp.Pos
wastarget := tp.On(IsTarget)
wastarget := tp.On(Targeted)
if g.moveMonst(tp) == -1 {
continue
}
if tp.On(IsFly) && distCp(g.Player.Pos, tp.Pos) >= 3 {
if tp.On(Flying) && distCp(g.Player.Pos, tp.Pos) >= 3 {
if g.moveMonst(tp) == -1 {
continue
}
}
if wastarget && origPos != tp.Pos {
tp.Flags.Clear(IsTarget)
tp.Flags.Clear(Targeted)
g.ToDeath = false
}
}
@@ -35,12 +35,12 @@ func (g *RogueGame) runners(int) {
// moveMonst executes a single turn of running for a monster (chase.c
// move_monst). Returns -1 if the monster died or left the level.
func (g *RogueGame) moveMonst(tp *Monster) int {
if !tp.On(IsSlow) || tp.Turn {
if !tp.On(Slowed) || tp.Turn {
if g.doChase(tp) == -1 {
return -1
}
}
if tp.On(IsHaste) {
if tp.On(Hasted) {
if g.doChase(tp) == -1 {
return -1
}
@@ -68,7 +68,7 @@ func (g *RogueGame) relocate(th *Monster, newLoc Coord) {
g.move(newLoc.Y, newLoc.X)
if g.seeMonst(th) {
g.addch(th.Disguise)
} else if g.Player.On(SeeMonst) {
} else if g.Player.On(SenseMonsters) {
g.standout()
g.addch(th.Type)
g.standend()
@@ -83,7 +83,7 @@ func (g *RogueGame) doChase(th *Monster) int {
mindist := 32767
rer := th.Room // find room of chaser
if th.On(IsGreed) && rer.GoldVal == 0 {
if th.On(Greedy) && rer.GoldVal == 0 {
th.Dest = &p.Pos // if gold has been taken, run after hero
}
var ree *Room // find room of chasee
@@ -108,7 +108,7 @@ over:
}
}
if door {
rer = &g.Level.Passages[*g.Level.FlagsAt(th.Pos.Y, th.Pos.X)&FPNum]
rer = &g.Level.Passages[*g.Level.FlagsAt(th.Pos.Y, th.Pos.X)&FPassNum]
door = false
goto over
}
@@ -120,7 +120,7 @@ over:
if th.Type == 'D' && (th.Pos.Y == p.Pos.Y || th.Pos.X == p.Pos.X ||
abs(th.Pos.Y-p.Pos.Y) == abs(th.Pos.X-p.Pos.X)) &&
distCp(th.Pos, p.Pos) <= BoltLength*BoltLength &&
!th.On(IsCanc) && g.rnd(dragonShot) == 0 {
!th.On(Cancelled) && g.rnd(dragonShot) == 0 {
g.Delta.Y = sign(p.Pos.Y - th.Pos.Y)
g.Delta.X = sign(p.Pos.X - th.Pos.X)
if g.HasHit {
@@ -130,7 +130,7 @@ over:
g.Running = false
g.Count = 0
g.Quiet = 0
if g.ToDeath && !th.On(IsTarget) {
if g.ToDeath && !th.On(Targeted) {
g.ToDeath = false
g.Kamikaze = false
}
@@ -147,7 +147,7 @@ over:
if th.Dest == &obj.Pos {
detachObj(&g.Level.Objects, obj)
attachObj(&th.Pack, obj)
if th.Room.Flags.Has(IsGone) {
if th.Room.Flags.Has(Gone) {
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, Passage)
} else {
g.Level.SetChar(obj.Pos.Y, obj.Pos.X, Floor)
@@ -168,7 +168,7 @@ over:
g.relocate(th, g.chRet)
// And stop running if need be
if stoprun && th.Pos == *th.Dest {
th.Flags.Clear(IsRun)
th.Flags.Clear(Awake)
}
return 0
}
@@ -185,14 +185,14 @@ func (g *RogueGame) chase(tp *Monster, ee Coord) bool {
// If the thing is confused, let it move randomly. Invisible Stalkers
// are slightly confused all of the time, and bats are quite confused
// all the time
if (tp.On(IsHuh) && g.rnd(5) != 0) || (tp.Type == 'P' && g.rnd(5) == 0) ||
if (tp.On(Confused) && g.rnd(5) != 0) || (tp.Type == 'P' && g.rnd(5) == 0) ||
(tp.Type == 'B' && g.rnd(2) == 0) {
// get a valid random move
g.chRet = g.rndmove(&tp.Creature)
curdist = distCp(g.chRet, ee)
// Small chance that it will become un-confused
if g.rnd(20) == 0 {
tp.Flags.Clear(IsHuh)
tp.Flags.Clear(Confused)
}
} else {
// Otherwise, find the empty spot next to the chaser that is
@@ -233,7 +233,7 @@ func (g *RogueGame) chase(tp *Monster, ee Coord) bool {
break
}
}
if found != nil && found.Which == SScare {
if found != nil && found.Which == ScrollScareMonster {
continue
}
}
@@ -268,8 +268,8 @@ func (g *RogueGame) setOldch(tp *Monster, cp Coord) {
}
sch := tp.OldCh
tp.OldCh = g.mvinch(cp.Y, cp.X)
if !g.Player.On(IsBlind) {
if (sch == Floor || tp.OldCh == Floor) && tp.Room.Flags.Has(IsDark) {
if !g.Player.On(Blind) {
if (sch == Floor || tp.OldCh == Floor) && tp.Room.Flags.Has(Dark) {
tp.OldCh = ' '
} else if distCp(cp, g.Player.Pos) <= LampDist && g.Options.SeeFloor {
tp.OldCh = g.Level.Char(cp.Y, cp.X)
@@ -281,10 +281,10 @@ func (g *RogueGame) setOldch(tp *Monster, cp Coord) {
// see_monst).
func (g *RogueGame) seeMonst(mp *Monster) bool {
p := &g.Player
if p.On(IsBlind) {
if p.On(Blind) {
return false
}
if mp.On(IsInvis) && !p.On(CanSee) {
if mp.On(Invisible) && !p.On(CanSeeInvisible) {
return false
}
y, x := mp.Pos.Y, mp.Pos.X
@@ -298,7 +298,7 @@ func (g *RogueGame) seeMonst(mp *Monster) bool {
if mp.Room != p.Room {
return false
}
return !mp.Room.Flags.Has(IsDark)
return !mp.Room.Flags.Has(Dark)
}
// runto sets a monster running after the hero (chase.c runto).
@@ -308,8 +308,8 @@ func (g *RogueGame) runto(runner Coord) {
return
}
// Start the beastie running
tp.Flags.Set(IsRun)
tp.Flags.Clear(IsHeld)
tp.Flags.Set(Awake)
tp.Flags.Clear(Held)
tp.Dest = g.findDest(tp)
}
@@ -317,8 +317,8 @@ func (g *RogueGame) runto(runner Coord) {
// any room (chase.c roomin).
func (g *RogueGame) roomin(cp Coord) *Room {
fp := *g.Level.FlagsAt(cp.Y, cp.X)
if fp.Has(FPass) {
return &g.Level.Passages[fp&FPNum]
if fp.Has(FPassage) {
return &g.Level.Passages[fp&FPassNum]
}
for i := range g.Level.Rooms {
@@ -348,11 +348,11 @@ func (g *RogueGame) diagOk(sp, ep Coord) bool {
// cansee).
func (g *RogueGame) cansee(y, x int) bool {
p := &g.Player
if p.On(IsBlind) {
if p.On(Blind) {
return false
}
if distance(y, x, p.Pos.Y, p.Pos.X) < LampDist {
if g.Level.FlagsAt(y, x).Has(FPass) {
if g.Level.FlagsAt(y, x).Has(FPassage) {
if y != p.Pos.Y && x != p.Pos.X &&
!stepOk(g.Level.Char(y, p.Pos.X)) &&
!stepOk(g.Level.Char(p.Pos.Y, x)) {
@@ -364,7 +364,7 @@ func (g *RogueGame) cansee(y, x int) bool {
// We can only see if the hero is in the same room as the coordinate
// and the room is lit, or if it is close.
rer := g.roomin(Coord{X: x, Y: y})
return rer == p.Room && !rer.Flags.Has(IsDark)
return rer == p.Room && !rer.Flags.Has(Dark)
}
// findDest finds the proper destination for the monster (chase.c
@@ -375,7 +375,7 @@ func (g *RogueGame) findDest(tp *Monster) *Coord {
return &g.Player.Pos
}
for _, obj := range g.Level.Objects {
if obj.Type == Scroll && obj.Which == SScare {
if obj.Type == Scroll && obj.Which == ScrollScareMonster {
continue
}
if g.roomin(obj.Pos) == tp.Room && g.rnd(100) < prob {