Skip to content

Commit

Permalink
Merge pull request #177 from RagnarokResearchLab/decoder-sanity-checks
Browse files Browse the repository at this point in the history
Add a missing EOF sanity check to the SPR and GND decoders
  • Loading branch information
rdw-software authored Nov 12, 2023
2 parents 4d0db2d + 1ee2dd3 commit 106302f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Core/FileFormats/RagnarokGND.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ function RagnarokGND:DecodeFileContents(fileContents)
self:DecodeCubeGrid()
self:DecodeWaterPlanes()

local numBytesRemaining = self.reader.endOfFilePointer - self.reader.virtualFilePointer
local eofErrorMessage = format("Detected %s leftover bytes at the end of the structure!", numBytesRemaining)
assert(self.reader:HasReachedEOF(), eofErrorMessage)

local endTime = uv.hrtime()
local decodingTimeInMilliseconds = (endTime - startTime) / 10E5
printf("[RagnarokGND] Finished decoding file contents in %.2f ms", decodingTimeInMilliseconds)
Expand Down
4 changes: 4 additions & 0 deletions Core/FileFormats/RagnarokSPR.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ function RagnarokSPR:DecodeFileContents(fileContents)
self:DecodeTrueColorImages()
self:DecodeColorPalette()

local numBytesRemaining = self.reader.endOfFilePointer - self.reader.virtualFilePointer
local eofErrorMessage = format("Detected %s leftover bytes at the end of the structure!", numBytesRemaining)
assert(self.reader:HasReachedEOF(), eofErrorMessage)

local endTime = uv_hrtime()
local decodingTimeInMilliseconds = (endTime - startTime) / 10E5
printf("[RagnarokSPR] Finished decoding file contents in %.2f ms", decodingTimeInMilliseconds)
Expand Down

0 comments on commit 106302f

Please sign in to comment.