|
294 | 294 | loadFiles("",file.Find("entities/gmod_wire_expression2/core/cl_*.lua", "LUA")) |
295 | 295 | end |
296 | 296 |
|
297 | | -local E2FunctionQueue = WireLib.NetQueue("e2_functiondata") |
298 | | -local E2FUNC_SENDMISC, E2FUNC_SENDFUNC, E2FUNC_DONE = 0, 1, 2 |
299 | 297 | if SERVER then |
| 298 | + util.AddNetworkString("e2_functiondata") |
300 | 299 | -- Serverside files are loaded in extloader |
301 | 300 | include("extloader.lua") |
302 | 301 |
|
@@ -335,28 +334,14 @@ if SERVER then |
335 | 334 | local function sendData(ply) |
336 | 335 | if not (IsValid(ply) and ply:IsPlayer()) then return end |
337 | 336 |
|
338 | | - local queue = E2FunctionQueue.plyqueues[ply] |
339 | | - queue:add(function() |
340 | | - net.WriteUInt(E2FUNC_SENDMISC, 8) |
341 | | - net.WriteTable(miscdata[1]) |
342 | | - net.WriteTable(miscdata[2]) |
343 | | - net.WriteTable(miscdata[3]) |
344 | | - end) |
345 | | - for signature, tab in pairs(functiondata) do |
346 | | - queue:add(function() |
347 | | - net.WriteUInt(E2FUNC_SENDFUNC, 8) |
348 | | - net.WriteString(signature) -- The function signature ["holoAlpha(nn)"] |
349 | | - net.WriteString(tab[1]) -- The function's return type ["s"] |
350 | | - net.WriteUInt(tab[2] or 0, 16) -- The function's cost [5] |
351 | | - net.WriteTable(tab[3] or {}) -- The function's argnames table (if a table isn't set, it'll just send a 1 byte blank table) |
352 | | - net.WriteString(tab[4] or "unknown") |
353 | | - net.WriteTable(tab[5] or {}) -- Attributes |
354 | | - end) |
355 | | - end |
356 | | - queue:add(function() |
357 | | - net.WriteUInt(E2FUNC_DONE, 8) |
358 | | - end) |
359 | | - E2FunctionQueue:flushQueue(ply, queue) |
| 337 | + local data = WireLib.von.serialize( { |
| 338 | + miscdata = miscdata, |
| 339 | + functiondata = functiondata |
| 340 | + } ) |
| 341 | + |
| 342 | + net.Start("e2_functiondata") |
| 343 | + net.WriteStream(data) |
| 344 | + net.Send(ply) |
360 | 345 | end |
361 | 346 |
|
362 | 347 | local antispam = WireLib.RegisterPlayerTable() |
@@ -425,16 +410,24 @@ elseif CLIENT then |
425 | 410 | E2Lib.Env.Events = events |
426 | 411 | end |
427 | 412 |
|
428 | | - function E2FunctionQueue.receivecb() |
429 | | - local state = net.ReadUInt(8) |
430 | | - if state == E2FUNC_SENDFUNC then |
431 | | - insertData(net.ReadString(), net.ReadString(), net.ReadUInt(16), net.ReadTable(), net.ReadString(), net.ReadTable()) |
432 | | - elseif state == E2FUNC_SENDMISC then |
433 | | - insertMiscData(net.ReadTable(), net.ReadTable(), net.ReadTable()) |
434 | | - elseif state == E2FUNC_DONE then |
| 413 | + net.Receive("e2_functiondata", function() |
| 414 | + net.ReadStream( nil, function( data ) |
| 415 | + local deserialized = WireLib.von.deserialize(data) |
| 416 | + if not deserialized then |
| 417 | + error("Failed to deserialize E2 function data from server!\n") |
| 418 | + end |
| 419 | + |
| 420 | + wire_expression2_reset_extensions() |
| 421 | + |
| 422 | + insertMiscData(deserialized.miscdata[1], deserialized.miscdata[2], deserialized.miscdata[3]) |
| 423 | + |
| 424 | + for signature, tab in pairs(deserialized.functiondata) do |
| 425 | + insertData(signature, tab[1], tab[2] or 0, tab[3] or {}, tab[4] or "unknown", tab[5] or {}) |
| 426 | + end |
| 427 | + |
435 | 428 | doneInsertingData() |
436 | | - end |
437 | | - end |
| 429 | + end ) |
| 430 | + end) |
438 | 431 | end |
439 | 432 |
|
440 | 433 | -- this file just generates the docs so it doesn't need to run every time. |
|
0 commit comments