Skip to content

Commit

Permalink
Fix app state subchunk prefixes in the map loader
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnovak committed Jun 30, 2024
1 parent 92a8074 commit a652122
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/persistence.nim
Original file line number Diff line number Diff line change
Expand Up @@ -466,70 +466,70 @@ proc readAppState_V4(rr; map: Map): AppState =
rr.cursor = dispCursor.get

let themeName = rr.readBStr()
checkStringLength(themeName, "stat.themeName", ThemeNameLimits)
checkStringLength(themeName, "disp.themeName", ThemeNameLimits)
app.themeName = themeName

let zoomLevel = rr.read(uint8)
checkValueRange(zoomLevel, "stat.zoomLevel", ZoomLevelLimits)
checkValueRange(zoomLevel, "disp.zoomLevel", ZoomLevelLimits)
app.zoomLevel = zoomLevel

let maxLevelIndex = NumLevelsLimits.maxInt-1
var currLevelIndex = rr.read(uint16).int
checkValueRange(currLevelIndex, "stat.currLevelIndex", max=maxLevelIndex)
checkValueRange(currLevelIndex, "disp.currLevelIndex", max=maxLevelIndex)
app.currLevelId = currLevelIndex

let l = map.levels[currLevelIndex]

let cursorRow = rr.read(uint16)
checkValueRange(cursorRow, "stat.cursorRow", max=l.rows.uint16-1)
checkValueRange(cursorRow, "disp.cursorRow", max=l.rows.uint16-1)
app.cursorRow = cursorRow

let cursorCol = rr.read(uint16)
checkValueRange(cursorCol, "stat.cursorCol", max=l.cols.uint16-1)
checkValueRange(cursorCol, "disp.cursorCol", max=l.cols.uint16-1)
app.cursorCol = cursorCol

let viewStartRow = rr.read(uint16)
checkValueRange(viewStartRow, "stat.viewStartRow", max=l.rows.uint16-1)
checkValueRange(viewStartRow, "disp.viewStartRow", max=l.rows.uint16-1)
app.viewStartRow = viewStartRow

let viewStartCol = rr.read(uint16)
checkValueRange(viewStartCol, "stat.viewStartCol", max=l.cols.uint16-1)
checkValueRange(viewStartCol, "disp.viewStartCol", max=l.cols.uint16-1)
app.viewStartCol = viewStartCol

# Options state
if optsCursor.isSome:
rr.cursor = optsCursor.get

let optShowCellCoords = rr.read(uint8)
checkBool(optShowCellCoords, "stat.optShowCellCoords")
checkBool(optShowCellCoords, "opts.optShowCellCoords")
app.optShowCellCoords = optShowCellCoords.bool

let optShowToolsPane = rr.read(uint8)
checkBool(optShowToolsPane, "stat.optShowToolsPane")
checkBool(optShowToolsPane, "opts.optShowToolsPane")
app.optShowToolsPane = optShowToolsPane.bool

let optShowCurrentNotePane = rr.read(uint8)
checkBool(optShowCurrentNotePane, "stat.optShowCurrentNotePane")
checkBool(optShowCurrentNotePane, "opts.optShowCurrentNotePane")
app.optShowCurrentNotePane = optShowCurrentNotePane.bool

let optWasdMode = rr.read(uint8)
checkBool(optWasdMode, "stat.optWasdMode")
checkBool(optWasdMode, "opts.optWasdMode")
app.optWasdMode = optWasdMode.bool

let optWalkMode = rr.read(uint8)
checkBool(optWalkMode, "stat.optWalkMode")
checkBool(optWalkMode, "opts.optWalkMode")
app.optWalkMode = optWalkMode.bool

# Tools pane state
if toolCursor.isSome:
rr.cursor = toolCursor.get

let currFloorColor = rr.read(uint8)
checkValueRange(currFloorColor, "stat.currFloorColor", CellFloorColorLimits)
checkValueRange(currFloorColor, "tool.currFloorColor", CellFloorColorLimits)
app.currFloorColor = currFloorColor

let currSpecialWall = rr.read(uint8)
checkValueRange(currSpecialWall, "stat.currSpecialWall", SpecialWallLimits)
checkValueRange(currSpecialWall, "tool.currSpecialWall", SpecialWallLimits)
app.currSpecialWall = currSpecialWall

# Note list pane state
Expand Down

0 comments on commit a652122

Please sign in to comment.