Skip to content

Commit ce74f10

Browse files
committed
Add a VC clones table.
1 parent adbc55b commit ce74f10

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ build/
44
releases/
55
nativefiledialog-master/
66
*.psd
7+
nativefiledialog/

source/modules/games/vcclones.lua

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Format ["CLONED VC ID"] = "ORIGINAL VC ID",
2+
3+
return {
4+
["NZTE"] = "NACE", -- The Legend of Zelda - A Missing Link
5+
}

source/modules/memory/cloneloader.lua

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
local loader = {}
2+
3+
local log = require("log")
4+
5+
local notification = require("notification")
6+
local configdir = love.filesystem.getSaveDirectory()
7+
8+
function loader.loadFile(file, clonesTbl)
9+
if file and love.filesystem.getInfo(file, "file") then
10+
log.info("[CLONES] Load: %s/%s", configdir, file)
11+
12+
local status, chunk = pcall(love.filesystem.load, file)
13+
14+
if not status then
15+
-- Failed loading chunk, chunk is an error string
16+
log.error(chunk)
17+
notification.error(chunk)
18+
elseif chunk then
19+
-- Create a sandboxed lua environment
20+
local env = {}
21+
env._G = env
22+
23+
-- Set the loaded chunk inside the sandbox
24+
setfenv(chunk, env)
25+
26+
local status, custom_clones = pcall(chunk)
27+
if not status then
28+
-- Failed calling the chunk, custom_clones is an error string
29+
log.error(custom_clones)
30+
notification.error(custom_clones)
31+
else
32+
local num_clones = 0
33+
for clone_id, clones in pairs(custom_clones) do
34+
if type(clones) == "table" then
35+
clonesTbl[clone_id] = {}
36+
for version, info in pairs(clones) do
37+
if info.id and info.version then
38+
num_clones = num_clones + 1
39+
log.debug("[CLONES] %s[%d] = %s[%d]", clone_id, version, info.id, info.version)
40+
clonesTbl[clone_id][version] = info
41+
end
42+
end
43+
end
44+
end
45+
log.info("[CLONES] Loaded %d clones from %s", num_clones, file)
46+
notification.coloredMessage(("Loaded %d clones from %s"):format(num_clones, file))
47+
end
48+
end
49+
end
50+
end
51+
52+
return loader

source/modules/memory/init.lua

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ local VC_NONE = "\0\0\0\0"
2020

2121
local memory = {
2222
clones = require("games.clones"),
23+
vcclones = require("games.vcclones"),
2324

2425
gameid = GAME_NONE,
2526
vcid = VC_NONE,
@@ -430,6 +431,9 @@ function memory.findGame()
430431
memory.ingame = true
431432
memory.vcid = vcid
432433

434+
-- Check for VC clones
435+
vcid = memory.vcclones[vcid] or vcid
436+
433437
memory.loadGameScript(vcid)
434438
elseif (not memory.ingame or meleeMode) and gid ~= GAME_NONE then
435439
memory.reset()

0 commit comments

Comments
 (0)