Add Int64 conversion functions to EncodedValue.lua and enhance script middleware selection in project.rs

- Implemented int64FromPod and int64ToPod functions for converting between Lua numbers and msgpack Int64 representation, addressing precision concerns for large integers.
- Updated the middleware_for_script function to determine the correct script directory based on the RunContext property, improving middleware selection for Script instances.
- Adjusted syncback logic to utilize the new middleware selection for Scripts, ensuring accurate handling of different script types during project synchronization.
This commit is contained in:
Joe 2026-02-01 20:51:13 -06:00
parent 04cf9ac91d
commit 76e4bc4f25
2 changed files with 78 additions and 7 deletions

View file

@ -4,6 +4,36 @@ local function identity(...)
return ...
end
-- Convert msgpack Int64 representation to a Lua number
-- Note: Lua numbers are doubles, so precision may be lost for values > 2^53
local function int64FromPod(pod)
-- If it's already a number, return it
if type(pod) == "number" then
return pod
end
-- If it's a msgpack Int64 table, convert to number
if type(pod) == "table" and pod.mostSignificantPart ~= nil and pod.leastSignificantPart ~= nil then
local most = pod.mostSignificantPart
local least = pod.leastSignificantPart
local value = most * 0x100000000 + least
-- Handle signed integers (negative values have MSB set)
if most >= 0x80000000 then
value = value - 0x10000000000000000
end
return value
end
return pod
end
-- Convert a Lua number to msgpack Int64 if needed, otherwise return as-is
-- For values that fit in Lua's safe integer range, returning plain number works
-- because msgpack will encode it appropriately
local function int64ToPod(roblox)
-- Just return the number - msgpack will handle encoding
-- For values outside safe range, this might lose precision
return roblox
end
local function unpackDecoder(f)
return function(value)
return f(unpack(value))
@ -302,8 +332,8 @@ types = {
},
Int64 = {
fromPod = identity,
toPod = identity,
fromPod = int64FromPod,
toPod = int64ToPod,
},
MaterialColors = {