mirror of
https://github.com/imezx/Warp.git
synced 2026-03-18 00:44:16 +00:00
rewrite(phase2): fix broken client & add buffer type support
This commit is contained in:
parent
391be2dbeb
commit
f98a0a1cc8
3 changed files with 17 additions and 2 deletions
|
|
@ -1 +1 @@
|
|||
{"name":"Warp","className":"ModuleScript","filePaths":["src\\init.luau","default.project.json"],"children":[{"name":"Client","className":"ModuleScript","filePaths":["src\\Client\\init.luau"]},{"name":"Server","className":"ModuleScript","filePaths":["src\\Server\\init.luau"]},{"name":"Thread","className":"ModuleScript","filePaths":["src\\Thread.luau"]},{"name":"Buffer","className":"ModuleScript","filePaths":["src\\Buffer\\init.luau"]}]}
|
||||
{"name":"Warp","className":"ModuleScript","filePaths":["src\\init.luau","default.project.json"],"children":[{"name":"Buffer","className":"ModuleScript","filePaths":["src\\Buffer\\init.luau"]},{"name":"Client","className":"ModuleScript","filePaths":["src\\Client\\init.luau"]},{"name":"Server","className":"ModuleScript","filePaths":["src\\Server\\init.luau"]},{"name":"Thread","className":"ModuleScript","filePaths":["src\\Thread.luau"]}]}
|
||||
|
|
@ -44,6 +44,7 @@ local T_MAPVAR = 0xDA
|
|||
|
||||
-- Typed arrays (homogeneous, no per-element tags)
|
||||
local T_TYPED_ARR = 0xDB
|
||||
local T_BUFFER = 0xDC
|
||||
|
||||
local T_VEC3 = 0xE0 -- f32 precision (12 bytes)
|
||||
local T_VEC3_F16 = 0xE1 -- f16 precision (6 bytes)
|
||||
|
|
@ -634,6 +635,13 @@ packValue = function(w: Writer, v: any): ()
|
|||
wF32(w, kp.Value)
|
||||
wF32(w, kp.Envelope)
|
||||
end
|
||||
elseif t == "buffer" then
|
||||
wByte(w, T_BUFFER)
|
||||
local len = buffer.len(v)
|
||||
wVarUInt(w, len)
|
||||
ensureSpace(w, len)
|
||||
buffer.copy(w.buf, w.cursor, v, 0, len)
|
||||
w.cursor += len
|
||||
else
|
||||
error(`Unsupported type: {t}`)
|
||||
end
|
||||
|
|
@ -927,6 +935,13 @@ unpackValue = function(buf: buffer, pos: number, refs: {any}?): (any, number)
|
|||
return NumberSequence.new(keypoints), pos
|
||||
end
|
||||
|
||||
if t == T_BUFFER then
|
||||
local len; len, pos = readVarUInt(buf, pos)
|
||||
local b = buffer.create(len)
|
||||
buffer.copy(b, 0, buf, pos, len)
|
||||
return b, pos + len
|
||||
end
|
||||
|
||||
error(`(serdes) unknown type: {t}`)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ end
|
|||
if RunService:IsClient() then
|
||||
Event.OnClientEvent:Connect(function(b: buffer, ref: { Instance? })
|
||||
if type(b) ~= "buffer" then return end
|
||||
local contents = Buffer.read(b, ref)
|
||||
local contents = Buffer.readEvents(b, ref, eventSchemas)
|
||||
for _, content in contents do
|
||||
local remote = content[1]
|
||||
local content = content[2]
|
||||
|
|
|
|||
Loading…
Reference in a new issue