summaryrefslogtreecommitdiffstatshomepage
path: root/plugins/hiscore/init.lua
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-11-06 05:20:59 +1100
committer Vas Crabb <vas@vastheman.com>2021-11-06 05:20:59 +1100
commit07e55935cf49c94a94dcc75d8240d0733d1ed5d7 (patch)
treefa60ebf78fee04fd57d9c8b8665f02729ef48a43 /plugins/hiscore/init.lua
parent3bb8e3adc7dbd6a9e57771047011efc3c54378ac (diff)
plugins: Rewrote timer plugin fixing multiple issues.
Added emulated time recording as well as wall clock time. Fixed recording time for multiple software items per system. An incorrect constraint on the database table meant that time was only being recorded for a single software item per system. Detect the "empty" driver so the time spent at the selection menu isn't recorded (you'd get multiple entries for this due to the way options leak when returning to the system selection menu). Included schema migration code to update existing timer plugin databases. Also replaced some unnecessary floating point code with integer maths, added log messages, and made the plugin unload unload its database access code during emulation. Changed other plugins' use of paths with trailing slashes as this causes stat to fail on Windows.
Diffstat (limited to 'plugins/hiscore/init.lua')
-rw-r--r--plugins/hiscore/init.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/plugins/hiscore/init.lua b/plugins/hiscore/init.lua
index 4101dd48708..652061c92cf 100644
--- a/plugins/hiscore/init.lua
+++ b/plugins/hiscore/init.lua
@@ -23,7 +23,7 @@ end
function hiscore.startplugin()
local function get_data_path()
- return emu.subst_env(manager.machine.options.entries.homepath:value():match('([^;]+)')) .. '/hiscore/'
+ return emu.subst_env(manager.machine.options.entries.homepath:value():match('([^;]+)')) .. '/hiscore'
end
-- configuration
@@ -35,7 +35,7 @@ function hiscore.startplugin()
if config_read then
return true
end
- local filename = get_data_path() .. 'plugin.cfg'
+ local filename = get_data_path() .. '/plugin.cfg'
local file = io.open(filename, 'r')
if file then
local json = require('json')
@@ -67,7 +67,7 @@ function hiscore.startplugin()
end
local settings = { only_save_at_exit = not timed_save }
-- TODO: other settings?
- local filename = path .. 'plugin.cfg'
+ local filename = path .. '/plugin.cfg'
local json = require('json')
local data = json.stringify(settings, { indent = true })
local file = io.open(filename, 'w')
@@ -210,9 +210,9 @@ function hiscore.startplugin()
local r;
if emu.softname() ~= "" then
local soft = emu.softname():match("([^:]*)$")
- r = get_data_path() .. emu.romname() .. "_" .. soft .. ".hi";
+ r = get_data_path() .. '/' .. emu.romname() .. "_" .. soft .. ".hi";
else
- r = get_data_path() .. emu.romname() .. ".hi";
+ r = get_data_path() .. '/' .. emu.romname() .. ".hi";
end
return r;
end
@@ -223,7 +223,7 @@ function hiscore.startplugin()
local output = io.open(get_file_name(), "wb");
if not output then
-- attempt to create the directory, and try again
- lfs.mkdir( get_data_path() );
+ lfs.mkdir(get_data_path());
output = io.open(get_file_name(), "wb");
end
emu.print_verbose("hiscore: write_scores output")