From 599cc2e1a4b9c0f095d5f4e1aa22c55e44a4284b Mon Sep 17 00:00:00 2001 From: Cruor Date: Tue, 31 Oct 2023 10:45:39 +0100 Subject: [PATCH 1/3] Multi snapshot backwards now iterates in reverse Fixes potential issue where snapshots are changing the same data --- src/snapshot_utils.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/snapshot_utils.lua b/src/snapshot_utils.lua index e995775a..a45f19a9 100644 --- a/src/snapshot_utils.lua +++ b/src/snapshot_utils.lua @@ -225,7 +225,9 @@ function snapshotUtils.multiSnapshot(description, snapshots) end local function backward(data) - for _, snap in ipairs(snapshots) do + for i = #snapshots, 1, -1 do + local snap = snapshots[i] + snap.backward(snap.data) end end From 75cde13bb8272f1fec6ddceee786372bbac19c2e Mon Sep 17 00:00:00 2001 From: Cruor Date: Wed, 1 Nov 2023 16:43:23 +0100 Subject: [PATCH 2/3] Revert "Attempted to fix issues with creating config with non latin characters in username" Sadly this didn't help the issue and is causing other issues Revering it for now, might look more into it later Other changes have made --portable more reliable on systems that otherwise would have problems This reverts commit 93ca1c87d8b53f53907715036d1b1bca17aa6f5d. --- src/file_locations.lua | 2 +- src/utils/filesystem.lua | 67 ---------------------------------------- src/utils/utils.lua | 4 --- 3 files changed, 1 insertion(+), 72 deletions(-) diff --git a/src/file_locations.lua b/src/file_locations.lua index 0eef7a18..fbdb9379 100644 --- a/src/file_locations.lua +++ b/src/file_locations.lua @@ -21,7 +21,7 @@ function fileLocations.getStorageDir() local linuxFolderName = fileLocations.loennLinuxFolderName if userOS == "Windows" then - return filesystem.joinpath(utils.getenv("LocalAppData"), simpleFolderName) + return filesystem.joinpath(os.getenv("LocalAppData"), simpleFolderName) elseif userOS == "Linux" then local xdgConfig = os.getenv("XDG_CONFIG_HOME") diff --git a/src/utils/filesystem.lua b/src/utils/filesystem.lua index 92099536..7dad3e63 100644 --- a/src/utils/filesystem.lua +++ b/src/utils/filesystem.lua @@ -1,5 +1,4 @@ local lfs = require("lib.lfs_ffi") -local ffi = require("ffi") local nfd = require("nfd") local physfs = require("lib.physfs") local requireUtils = require("utils.require") @@ -479,70 +478,4 @@ function filesystem.unzip(zipPath, outputDir) love.filesystem.unmount("temp") end -if osUtils.getOS() ~= "Windows" then - local function identity(value) - return value - end - - filesystem.codepageUtf8ToSys = identity - filesystem.codepageSysToUtf8 = identity - -else - ffi.cdef[[ - int MultiByteToWideChar( - unsigned int CodePage, - int dwFlags, - char* lpMultiByteStr, - int cbMultiByte, - wchar_t* lpWideCharStr, - int cchWideChar - ); - int WideCharToMultiByte( - unsigned int CodePage, - int dwFlags, - wchar_t* lpWideCharStr, - int cchWideChar, - char* lpMultiByteStr, - int cbMultiByte, - char* lpDefaultChar, - bool* lpUsedDefaultChar - ); - ]] - - local codepageSys = 0 - local codepageUtf8 = 65001 - - local function convert(from, to, orig) - local length = #orig + 1 - local valueC = ffi.new("char[?]", length) - ffi.copy(valueC, orig) - valueC[#orig] = 0 - - -- char from -> wchar_t - local size = ffi.C.MultiByteToWideChar(from, 0, valueC, length, nil, 0) - assert(size ~= 0) - local valueW = ffi.new("wchar_t[?]", size) - length = ffi.C.MultiByteToWideChar(from, 0, valueC, length, valueW, size) - assert(size == length) - - -- wchar_t -> char to - length = ffi.C.WideCharToMultiByte(to, 0, valueW, size, nil, 0, nil, nil) - assert(length ~= 0) - valueC = ffi.new("char[?]", length + 1) - length = ffi.C.WideCharToMultiByte(to, 0, valueW, size, valueC, length, nil, nil) - assert(length == size) - valueC[length + 1] = 0 - - return ffi.string(valueC) - end - - function filesystem.codepageUtf8ToSys(value) - return convert(codepageUtf8, codepageSys, value) - end - - function filesystem.codepageSysToUtf8(value) - return convert(codepageSys, codepageUtf8, value) - end -end - return filesystem diff --git a/src/utils/utils.lua b/src/utils/utils.lua index 87c362f7..a3bc1fbb 100644 --- a/src/utils/utils.lua +++ b/src/utils/utils.lua @@ -842,10 +842,6 @@ for k, v <- filesystem do utils[k] = v end -function utils.getenv(key) - return filesystem.codepageSysToUtf8(os.getenv(key)) -end - -- Add filesystem specific helper methods local osFilename = utils.getOS():lower():gsub(" ", "_") local hasOSHelper, osHelper = requireUtils.tryrequire("utils.system." .. osFilename) From afcdde86ed071c970e2b959710fc6401f764359e Mon Sep 17 00:00:00 2001 From: Cruor Date: Wed, 1 Nov 2023 16:56:10 +0100 Subject: [PATCH 3/3] Added fallback drawing for entities Makes it easier to find entities that are missing any drawing code Should also indirectly make selecting them easier --- src/entities.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/entities.lua b/src/entities.lua index d8e747ca..2b141ef0 100644 --- a/src/entities.lua +++ b/src/entities.lua @@ -227,6 +227,16 @@ function entities.getEntityDrawable(name, handler, room, entity, viewport) end return drawableSprites + + else + -- No drawing defined for the entity, use fallback + -- Make sure the entity doesn't have color or any other special attributes + local position = { + x = entity.x, + y = entity.y + } + + return entities.getDrawable(name, missingEntityHandler, room, position, viewport) end end