From 5ec0ec1a9b3e3a77801978847ebc5c9477fe2494 Mon Sep 17 00:00:00 2001 From: ZioPao Date: Mon, 29 Sep 2025 01:31:18 +0200 Subject: [PATCH] fix: 42.12 new bodyloc --- .../Controllers/LimitActionsController.lua | 4 +-- common/media/lua/shared/TOC/BodyLocations.lua | 32 ++++++++++++------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/42/media/lua/client/TOC-42/Controllers/LimitActionsController.lua b/42/media/lua/client/TOC-42/Controllers/LimitActionsController.lua index bad1481..0e57d8a 100644 --- a/42/media/lua/client/TOC-42/Controllers/LimitActionsController.lua +++ b/42/media/lua/client/TOC-42/Controllers/LimitActionsController.lua @@ -4,7 +4,7 @@ local OverridenMethodsArchive = require("TOC/OverridenMethodsArchive") local og_ISClothingExtraAction_isValid = OverridenMethodsArchive.Get("ISClothingExtraAction_isValid") ---@diagnostic disable-next-line: duplicate-set-field function ISClothingExtraAction:isValid() - TOC_DEBUG.print("Inside ISClothingExtraAction:isValid 42") - TOC_DEBUG.print(OverridenMethodsArchive.Get("ISClothingExtraAction_isValid")) + -- TOC_DEBUG.print("Inside ISClothingExtraAction:isValid 42") + -- TOC_DEBUG.print(OverridenMethodsArchive.Get("ISClothingExtraAction_isValid")) return LimitActionsController.WrapClothingAction(self, og_ISClothingExtraAction_isValid, instanceItem(self.extra)) end \ No newline at end of file diff --git a/common/media/lua/shared/TOC/BodyLocations.lua b/common/media/lua/shared/TOC/BodyLocations.lua index aa1fb2e..94fe9d6 100644 --- a/common/media/lua/shared/TOC/BodyLocations.lua +++ b/common/media/lua/shared/TOC/BodyLocations.lua @@ -1,5 +1,6 @@ require("TOC/Debug") require("NPCs/BodyLocations") +local StaticData = require("TOC/StaticData") local BodyLocationsAPI = {} local function customGetVal(obj, int) return getClassFieldVal(obj, getClassField(obj, int)) end @@ -8,6 +9,8 @@ local group = BodyLocations.getGroup("Human") ---@type ArrayList local list = customGetVal(group, 1) +-- TODO Not sure if this method actually works as intende with b42, but for our use case it's fine... + ---@param toRelocateOrCreate string ---@param locationElement string ---@param afterBoolean boolean @@ -19,7 +22,15 @@ function BodyLocationsAPI.MoveOrCreateBeforeOrAfter(toRelocateOrCreate, location if itemToMoveTo ~= nil then -- Check type of arg 1 == string - if not, error out. if type(toRelocateOrCreate) ~= "string" then error("Argument 1 is not of type string. Please re-check!", 2) end - local curItem = group:getOrCreateLocation(toRelocateOrCreate) -- get current item - or create + + local curItem + if StaticData.COMPAT_42 then + curItem = BodyLocation.new(group, toRelocateOrCreate) -- create new item + group:getAllLocations():add(curItem) -- add to the list + else + curItem = group:getOrCreateLocation(toRelocateOrCreate) -- get current item - or create + + end list:remove(curItem) -- remove from the list local index = group:indexOf(locationElement) -- get current index after removal of the location to move to if afterBoolean then index = index + 1 end -- if we want it after it, we increase the index to move to by one @@ -32,19 +43,18 @@ function BodyLocationsAPI.MoveOrCreateBeforeOrAfter(toRelocateOrCreate, location end end -function TestBodyLocations() - local group = BodyLocations.getGroup("Human") - local x = group:getAllLocations() +-- function TestBodyLocations() +-- local group = BodyLocations.getGroup("Human") +-- local x = group:getAllLocations() - for i=0, x:size() -1 do +-- for i=0, x:size() -1 do - ---@type BodyLocation - local bl = x:get(i) +-- ---@type BodyLocation +-- local bl = x:get(i) - print(bl:getId()) - end - -end +-- print(bl:getId()) +-- end +-- end -- MultiItem causes a ton of issues... fucking hell