Skip to content

Commit f60710d

Browse files
Fix infinite leveling bug when race TNLScale is 0 (#409)
This can happen if a race for some reason is missing the tnlscale field. Add validation to ensure TNLScale defaults to 1.0 when not specified or set to 0. This prevents XPTL() from returning 0 experience required for next level, which was causing infinite leveling. Changes: - Add TNLScale validation in Race.Validate() to default to 1.0 if 0 - Add safety check in Character.RecalculateStats() as additional protection
1 parent 55240c5 commit f60710d

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

internal/characters/character.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,6 +1381,10 @@ func (c *Character) RecalculateStats() {
13811381

13821382
if raceInfo := races.GetRace(c.RaceId); raceInfo != nil {
13831383
c.TNLScale = raceInfo.TNLScale
1384+
// Safety check: ensure TNLScale is never 0
1385+
if c.TNLScale == 0 {
1386+
c.TNLScale = 1.0
1387+
}
13841388
c.Stats.Strength.Base = raceInfo.Stats.Strength.Base
13851389
c.Stats.Speed.Base = raceInfo.Stats.Speed.Base
13861390
c.Stats.Smarts.Base = raceInfo.Stats.Smarts.Base

internal/races/races.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ func (r *Race) Validate() error {
113113
r.Damage.FormatDiceRoll()
114114
}
115115

116+
// Ensure TNLScale is never 0, default to 1.0
117+
if r.TNLScale == 0 {
118+
r.TNLScale = 1.0
119+
}
120+
116121
return nil
117122
}
118123

0 commit comments

Comments
 (0)