plugins/cheat: fix XML cheat loading when emulation is launched with an image option specified (e.g. mame nes -cart smb) or by loading directly one part of the software (e.g. mame a600 amigaocs_flop:lslarry2:flop1)

This commit is contained in:
Priuli 2021-04-01 15:33:39 +02:00
parent 1bc0dcbf46
commit bcfd7c64b0

View File

@ -95,18 +95,15 @@ function cheat.startplugin()
local filename = emu.romname()
local newcheats = {}
local file = emu.file(manager.machine.options.entries.cheatpath:value():gsub("([^;]+)", "%1;%1/cheat") , 1)
if emu.softname() ~= "" then
if emu.softname():find(":") then
filename = emu.softname():gsub(":", "/")
else
for name, image in pairs(manager.machine.images) do
if image.exists and image.software_list_name ~= "" then
filename = image.software_list_name .. "/" .. emu.softname()
end
end
for name, image in pairs(manager.machine.images) do
if image.exists and image.software_list_name ~= "" then
filename = image.software_list_name .. "/" .. image.filename
end
end
cheatname = filename
print(cheatname)
local function add(addcheats)
if not next(newcheats) then
newcheats = addcheats