mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-17 11:11:10 +02:00
fix(switch): centralize the NX asset fallback in a boot-time loader overlay
The scattered per-call-site prefix rewrites were a parallel track that any
future newImage("assets/generated/...") would silently bypass. Replace
them with NxAssetOverlay: installed once from love.load on NX only, it
wraps newImage / newImageData / newSource / filesystem.read / getInfo so a
missing assets/generated path falls back to the active version's
blue|yellow copy. Call sites return to plain love loader calls, and
Assets.resolve goes back to being the platform-free mod-override point.
Two deliberate exceptions remain: the chip-audio worker (separate Lua
state) keeps receiving the prefix explicitly via audio.programPrefix, and
data/generated module loads keep using CacheFs.readActive.
A new guard test (tests/engine/nx_generated_guard_test.lua) fails CI on
any direct love loader call with a literal assets/generated path, so the
class of bug cannot regress by accident. scripts/test.sh --quick is
green across all tiers.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -136,7 +136,7 @@ local FIGHT_SCRIPT = {
|
||||
|
||||
local function tryImage(path)
|
||||
if not path then return nil end
|
||||
local ok, img = pcall(love.graphics.newImage, require("src.render.Assets").resolve(path))
|
||||
local ok, img = pcall(love.graphics.newImage, path)
|
||||
return ok and img or nil
|
||||
end
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ function SurfingMinigame.new(game, onDone)
|
||||
self.banner = nil -- {quad, frames}: GOOD!/YEAH-/Oh no..
|
||||
|
||||
local function sheet(path)
|
||||
local ok, img = pcall(love.graphics.newImage, require("src.render.Assets").resolve(path))
|
||||
local ok, img = pcall(love.graphics.newImage, path)
|
||||
return ok and img or nil
|
||||
end
|
||||
self.bg = sheet("assets/generated/minigame/surf_1a.png")
|
||||
|
||||
@@ -100,7 +100,7 @@ local CYCLE_FRAMES = 240 -- the original waits ~4s between picks
|
||||
|
||||
local function tryImage(path)
|
||||
if not path then return nil end
|
||||
local ok, img = pcall(love.graphics.newImage, require("src.render.Assets").resolve(path))
|
||||
local ok, img = pcall(love.graphics.newImage, path)
|
||||
return ok and img or nil
|
||||
end
|
||||
|
||||
|
||||
+4
-5
@@ -104,7 +104,7 @@ local function loadBackground(game)
|
||||
local tm = (game.data.field or {}).townMap or {}
|
||||
local bg = tm.background
|
||||
if not (bg and bg.map and bg.tiles) then return nil end
|
||||
local ok, img = pcall(love.graphics.newImage, require("src.render.Assets").resolve(bg.tiles.path))
|
||||
local ok, img = pcall(love.graphics.newImage, bg.tiles.path)
|
||||
if not ok then return nil end
|
||||
local quads = {}
|
||||
local iw, ih = img:getDimensions()
|
||||
@@ -115,7 +115,7 @@ local function loadBackground(game)
|
||||
end
|
||||
local cursor
|
||||
if bg.cursor then
|
||||
local okc, c = pcall(love.graphics.newImage, require("src.render.Assets").resolve(bg.cursor.path))
|
||||
local okc, c = pcall(love.graphics.newImage, bg.cursor.path)
|
||||
cursor = okc and c or nil
|
||||
end
|
||||
return { img = img, quads = quads, map = bg.map, cursor = cursor }
|
||||
@@ -192,9 +192,8 @@ function TownMap.new(game, opts)
|
||||
-- field.townMap.nest lifts the icon path out of the engine
|
||||
local nest = ((game.data.field or {}).townMap or {}).nest
|
||||
local ok, img = pcall(love.graphics.newImage,
|
||||
require("src.render.Assets").resolve(
|
||||
(nest and nest.path)
|
||||
or "assets/generated/townmap/nest.png"))
|
||||
(nest and nest.path)
|
||||
or "assets/generated/townmap/nest.png")
|
||||
self.nestIcon = ok and img or nil
|
||||
end
|
||||
if opts.fly then
|
||||
|
||||
@@ -29,7 +29,7 @@ local DEFAULT_ART = {
|
||||
|
||||
local function tryImage(path)
|
||||
if not path then return nil end
|
||||
local ok, img = pcall(love.graphics.newImage, require("src.render.Assets").resolve(path))
|
||||
local ok, img = pcall(love.graphics.newImage, path)
|
||||
return ok and img or nil
|
||||
end
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ local function bobOffset(phase)
|
||||
end
|
||||
|
||||
local function tryImage(path)
|
||||
local ok, img = pcall(love.graphics.newImage, require("src.render.Assets").resolve(path))
|
||||
local ok, img = pcall(love.graphics.newImage, path)
|
||||
return ok and img or nil
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user