From e0fd7dd1461759096867e61a663846d633d3e8f0 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Tue, 9 Jan 2018 07:19:48 +0000 Subject: [PATCH] Confirm the *length* of imported .bin files (must be evenly divisble by avatar size) before copying to text/avatars. Use '-file=<filename>', rather than -f. Export/share an avatar library like this: jsexec avatars export=syncdata -file=../text/avatars/custom.bin Export user's avatars like this: jsexec avatars export=syncdata -users Import avatars (users and shared libraries), like this: jsexec avatars import=syncdata (replace syncdata with the correct code for the syncdata sub) --- exec/avatars.js | 13 +++++++------ exec/load/avatar_lib.js | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/exec/avatars.js b/exec/avatars.js index a09f591ca5..2b70f59fdf 100644 --- a/exec/avatars.js +++ b/exec/avatars.js @@ -133,12 +133,13 @@ function import_shared_file(hdr, body) return false; } if(sauce.datatype != SAUCE.defs.datatype.bin - || sauce.cols != lib.defs.width) { - alert(format("%s has invalid SAUCE! (%u %u)" - ,file.name, sauce.datatype, sauce.cols)); + || sauce.cols != lib.defs.width + || (sauce.filesize%lib.size) != 0) { + alert(format("%s has invalid SAUCE! (datatype=%u cols=%u size=%u)" + ,file.name, sauce.datatype, sauce.cols, sauce.filesize)); return false; } - var new_path = format("%savatars/%s", system.text_dir, filename); + var new_path = format("%s%s", lib.local_library(), filename); var result = file_copy(file.name, new_path); if(!result) alert("ERROR copying " + file.name + " to " + new_path); @@ -294,7 +295,7 @@ function main() optval[arg] = val; switch(arg) { - case '-f': + case '-file': filename = val; break; case '-offset': @@ -320,7 +321,7 @@ function main() break; } } - + mkdir(lib.local_library()); for(var c in cmds) { var cmd = cmds[c].toLowerCase(); switch(cmd) { diff --git a/exec/load/avatar_lib.js b/exec/load/avatar_lib.js index 24f94448c8..ee343eae97 100644 --- a/exec/load/avatar_lib.js +++ b/exec/load/avatar_lib.js @@ -7,6 +7,8 @@ const defs = { height: 6, }; +const size = defs.width * defs.height * 2; // 2 bytes per cell for char and attributes + function local_library() { return format("%savatars/", system.text_dir); -- GitLab