chris 1.1 hotfix

This commit is contained in:
bryanthaboi
2026-08-24 11:32:42 -04:00
parent 041051e154
commit bed1062a5f
14 changed files with 280 additions and 28 deletions
+12 -5
View File
@@ -136,8 +136,15 @@ function CacheContract.requiredFilesFor(version)
return CacheContract.REQUIRED_FILES, false
end
function CacheContract.markerFor(version)
return CacheContract.FORMAT .. GameVersion.info(version).sha1
function CacheContract.markerFor(version, sha1)
return CacheContract.FORMAT .. (sha1 or GameVersion.info(version).sha1)
end
function CacheContract.markerMatches(version, marker)
for _, revision in ipairs(GameVersion.revisions(version)) do
if marker == CacheContract.markerFor(version, revision.sha1) then return true end
end
return false
end
-- Keep the process-global CacheFs prefix isolated even when a filesystem
@@ -189,11 +196,11 @@ function CacheContract.isReady(version, fs)
fs = fs or require("src.import.CacheFs")
if CacheContract.sourceTreeHasData(version) then return true end
local marker, readError = CacheContract.readMarker(version, fs)
if readError or marker ~= CacheContract.markerFor(version) then return false end
if readError or not CacheContract.markerMatches(version, marker) then return false end
return CacheContract.allRequiredFilesExist(version, fs)
end
function CacheContract.publish(version, fs)
function CacheContract.publish(version, fs, sha1)
fs = fs or require("src.import.CacheFs")
local complete, missing = CacheContract.allRequiredFilesExist(version, fs)
if not complete then
@@ -212,7 +219,7 @@ function CacheContract.publish(version, fs)
return false, "cache is incomplete; missing " .. tostring(missing)
end
local changed, ok, err = withVersionPrefix(version, fs, function()
return fs.write(CacheContract.MARKER_PATH, CacheContract.markerFor(version))
return fs.write(CacheContract.MARKER_PATH, CacheContract.markerFor(version, sha1))
end)
if not changed then return false, tostring(ok) end
return ok, err
+2 -2
View File
@@ -13,7 +13,7 @@ require("love.math")
require("love.system")
require("love.timer")
local version, prefix, romData, progressName, resultName = ...
local version, prefix, romData, progressName, resultName, romSha1 = ...
local progressChannel = love.thread.getChannel(progressName)
local resultChannel = love.thread.getChannel(resultName)
@@ -44,7 +44,7 @@ local ok, err = pcall(function()
current = current, stageTotal = stageTotal,
})
end
end)
end, romSha1)
extractor:run()
end)
+11 -2
View File
@@ -201,14 +201,23 @@ local function copy(value)
return result
end
function RomExtractorGen2.new(romData, manifest, progress)
function RomExtractorGen2.new(romData, manifest, progress, romSha1)
-- _GOLD / _SILVER: the labels are shared, the data behind a handful of
-- them is not (gfx/misc.asm:9-20 vs :46-57).
local edition = GameVersion.forSha1(manifest.romSha1) or "gold"
local symbols = manifest.symbols
local revision = romSha1 and manifest.symbolRevisions
and manifest.symbolRevisions[romSha1]
if revision then
local merged = {}
for name, location in pairs(manifest.symbols) do merged[name] = location end
for name, location in pairs(revision) do merged[name] = location end
symbols = merged
end
return setmetatable({
rom = Rom.new(romData),
manifest = manifest,
symbols = manifest.symbols,
symbols = symbols,
progress = progress,
stage = 0,
edition = edition,
+5 -4
View File
@@ -1432,7 +1432,7 @@ function RomImporter.new(onComplete, opts)
-- "update required" (re-import) rather than a clean first-run choose
local marker = CacheContract.readMarker(version, CacheFs)
self.returning[version] =
(not ready) and marker ~= nil and marker ~= CacheContract.markerFor(version)
(not ready) and marker ~= nil and not CacheContract.markerMatches(version, marker)
self.romName[version] = "pokemon_" .. info.id
.. ((info.id == "yellow" or GameVersion.generation(version) == 2)
and ".gbc" or ".gb")
@@ -1721,6 +1721,7 @@ function RomImporter:startData(data, displayName)
.. "(tagged [b] or [BF]) never verify."):format(actualHash, cartsProse()))
return
end
self.romSha1 = actualHash
local info = GameVersion.info(version)
-- Bring the launcher to this version's tab so its progress bar is on screen
@@ -1775,7 +1776,7 @@ function RomImporter:_startExtractThread(version, prefix, data, displayName)
love.thread.getChannel(progressName):clear()
love.thread.getChannel(resultName):clear()
local started = pcall(thread.start, thread, version, prefix, data,
progressName, resultName)
progressName, resultName, self.romSha1)
if not started then return false end
self._extract = {
thread = thread, version = version, prefix = prefix,
@@ -1804,7 +1805,7 @@ function RomImporter:_startExtractCoroutine(version, info, prefix, displayName)
self.stageCurrent = current
self.stageTotal = stageTotal
coroutine.yield()
end)
end, self.romSha1)
extractor:run()
CacheFs.prefix = "" -- restore the default so later writes stay at the root
self.romData = nil
@@ -1822,7 +1823,7 @@ function RomImporter:_completeImport(version, prefix, displayName)
-- appear once every required file is in place.
local savedPrefix = CacheFs.prefix
CacheFs.prefix = prefix
local ok, writeError = CacheContract.publish(version, CacheFs)
local ok, writeError = CacheContract.publish(version, CacheFs, self.romSha1)
CacheFs.prefix = savedPrefix
if not ok then
error("could not finish the private cache: " .. tostring(writeError))
+2 -1
View File
@@ -18,7 +18,8 @@ function RomManifest.decode(version)
if not manifest then
error("ROM import metadata is invalid: " .. tostring(decodeError))
end
assert(manifest.romSha1 == info.sha1, "ROM import metadata version mismatch")
assert(GameVersion.acceptsSha1(version, manifest.romSha1),
"ROM import metadata version mismatch")
return manifest
end