Skip to content
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
usermessage.Hook("e2_remoteupload_request", function(um)
local target = um:ReadEntity()
local filepath = um:ReadString()
net.Receive("e2_remoteupload_request", function()
local target = net.ReadEntity()
local filepath = net.ReadString()

if target and target:IsValid() and filepath and file.Exists("expression2/" .. filepath, "DATA") then
local str = file.Read("expression2/" .. filepath)
Expand Down
10 changes: 5 additions & 5 deletions lua/entities/gmod_wire_expression2/core/custom/remoteupload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local function check(ply)
end
end

umsg.PoolString("e2_remoteupload_request")
util.AddNetworkString("e2_remoteupload_request")

local function checkE2Chip(self, this)
if not IsValid(this) then return self:throw("Invalid entity!", nil) end
Expand All @@ -25,10 +25,10 @@ e2function void entity:remoteUpload( string filepath )
if not checkE2Chip(self, this) then return end
if not check(self.player) then return end

umsg.Start( "e2_remoteupload_request", self.player )
umsg.Entity( this )
umsg.String( filepath )
umsg.End()
net.Start( "e2_remoteupload_request" )
net.WriteEntity( this )
net.WriteString( filepath )
net.Send( self.player )
end

__e2setcost(250)
Expand Down
31 changes: 15 additions & 16 deletions lua/entities/gmod_wire_eyepod.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@ if CLIENT then
local rotate90 = false
local freezePitch = true
local freezeYaw = true

local previousEnabled = false

usermessage.Hook("UpdateEyePodState", function(um)
if not um then return end

local eyeAng = um:ReadAngle()
enabled = um:ReadBool()
rotate90 = um:ReadBool()
freezePitch = um:ReadBool() and eyeAng.p
freezeYaw = um:ReadBool() and eyeAng.y
net.Receive("UpdateEyePodState", function()
local eyeAng = net.ReadAngle()
enabled = net.ReadBool()
rotate90 = net.ReadBool()
freezePitch = net.ReadBool() and eyeAng.p
freezeYaw = net.ReadBool() and eyeAng.y
end)

hook.Add("CreateMove", "WireEyePodEyeControl", function(ucmd)
Expand Down Expand Up @@ -52,6 +49,7 @@ if CLIENT then
end

-- Server
util.AddNetworkString("UpdateEyePodState")

function ENT:Initialize()
self:PhysicsInit(SOLID_VPHYSICS)
Expand Down Expand Up @@ -203,13 +201,14 @@ end

function ENT:updateEyePodState(enabled)
self:ColorByLinkStatus(enabled and self.LINK_STATUS_ACTIVE or self.LINK_STATUS_LINKED)
umsg.Start("UpdateEyePodState", self.driver)
umsg.Angle(self.eyeAng)
umsg.Bool(enabled)
umsg.Bool(self.rotate90)
umsg.Bool(self.freezePitch)
umsg.Bool(self.freezeYaw)
umsg.End()

net.Start("UpdateEyePodState")
net.WriteAngle(self.eyeAng)
net.WriteBool(enabled)
net.WriteBool(self.rotate90)
net.WriteBool(self.freezePitch)
net.WriteBool(self.freezeYaw)
net.Send(self.driver)
end

hook.Add("PlayerEnteredVehicle","gmod_wire_eyepod_entervehicle",function(ply,vehicle)
Expand Down
97 changes: 47 additions & 50 deletions lua/entities/gmod_wire_gpu/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,53 @@ local function recalculateMonitorLookup()
end
end

local function GPU_MonitorState(um)
-- Read monitors for this GPU
local gpuIdx = um:ReadLong()
Monitors[gpuIdx] = {}

-- Fetch all monitors
local count = um:ReadShort()
for i=1,count do
Monitors[gpuIdx][i] = um:ReadLong()
end

-- Recalculate small lookup table for monitor system
recalculateMonitorLookup()
end
usermessage.Hook("wire_gpu_monitorstate", GPU_MonitorState)

local actions = {
function() -- 1, wire_gpu_monitorstate
-- Read monitors for this GPU
local gpuIdx = net.ReadUInt(MAX_EDICT_BITS)
Monitors[gpuIdx] = {}

-- Fetch all monitors
local count = net.ReadUInt(16)
for i=1,count do
Monitors[gpuIdx][i] = net.ReadInt(32)
end

--------------------------------------------------------------------------------
-- Update GPU features/memory model
--------------------------------------------------------------------------------
local function GPU_MemoryModel(um)
local GPU = ents.GetByIndex(um:ReadLong())
if not GPU then return end
if not GPU:IsValid() then return end

if GPU.VM then
GPU.VM.ROMSize = um:ReadLong()
GPU.VM.SerialNo = um:ReadFloat()
GPU.VM.RAMSize = GPU.VM.ROMSize
else
GPU.ROMSize = um:ReadLong()
GPU.SerialNo = um:ReadFloat()
end
GPU.ChipType = um:ReadShort()
end
usermessage.Hook("wire_gpu_memorymodel", GPU_MemoryModel)

local function GPU_SetExtensions(um)
local GPU = ents.GetByIndex(um:ReadLong())
if not GPU then return end
if not GPU:IsValid() then return end
local extstr = um:ReadString()
local extensions = CPULib:FromExtensionString(extstr,"GPU")
if GPU.VM then
GPU.VM.Extensions = extensions
CPULib:LoadExtensions(GPU.VM,"GPU")
-- Recalculate small lookup table for monitor system
recalculateMonitorLookup()
end,
function() -- 2, wire_gpu_memorymodel
local GPU = ents.GetByIndex(net.ReadUInt(MAX_EDICT_BITS))
if not GPU then return end
if not GPU:IsValid() then return end

if GPU.VM then
GPU.VM.ROMSize = net.ReadInt(32)
GPU.VM.SerialNo = net.ReadFloat()
GPU.VM.RAMSize = GPU.VM.ROMSize
else
GPU.ROMSize = net.ReadInt(32)
GPU.SerialNo = net.ReadFloat()
end
GPU.ChipType = net.ReadInt(16)
end,
function() -- 3, wire_gpu_extensions
local GPU = ents.GetByIndex(net.ReadUInt(MAX_EDICT_BITS))
if not GPU then return end
if not GPU:IsValid() then return end
local extstr = net.ReadString()
local extensions = CPULib:FromExtensionString(extstr,"GPU")
if GPU.VM then
GPU.VM.Extensions = extensions
CPULib:LoadExtensions(GPU.VM,"GPU")
end
GPU.ZVMExtensions = extstr
end
GPU.ZVMExtensions = extstr
end
usermessage.Hook("wire_gpu_extensions", GPU_SetExtensions)
}

net.Receive("wire_gpu_action", function()
actions[net.ReadUInt(2)]()
end)

local wire_gpu_frameratio = CreateClientConVar("wire_gpu_frameratio",4)

Expand Down Expand Up @@ -374,7 +371,7 @@ function ENT:Draw()

-- Draw GPU itself
self:DrawModel()

local tone = render.GetToneMappingScaleLinear()
render.SetToneMappingScaleLinear(VECTOR_1_1_1)

Expand Down Expand Up @@ -458,7 +455,7 @@ function ENT:Draw()
end
end
end

render.SetToneMappingScaleLinear(tone)
Wire_Render(self)
end
Expand Down
40 changes: 23 additions & 17 deletions lua/entities/gmod_wire_gpu/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ AddCSLuaFile("cl_gpuvm.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")

util.AddNetworkString("wire_gpu_action")
DEFINE_BASECLASS("base_wire_entity")

ENT.WireDebugName = "ZGPU"
Expand Down Expand Up @@ -36,13 +37,16 @@ function ENT:Initialize()
end

function ENT:UpdateClientMonitorState()
umsg.Start("wire_gpu_monitorstate")
umsg.Long(self:EntIndex())
umsg.Short(#self.Monitors)
for idx=1,#self.Monitors do
umsg.Long(self.Monitors[idx])
end
umsg.End()
net.Start("wire_gpu_action")
net.WriteUInt(1, 2)
net.WriteUInt(self:EntIndex(), MAX_EDICT_BITS)
net.WriteUInt(#self.Monitors, 16)

for idx=1,#self.Monitors do
net.WriteInt(self.Monitors[idx], 32)
end

net.Broadcast()
end
--------------------------------------------------------------------------------
-- Set processor
Expand All @@ -65,12 +69,13 @@ function ENT:SetMemoryModel(model,initial)
function()
if not self:IsValid() then return end

umsg.Start("wire_gpu_memorymodel")
umsg.Long(self:EntIndex())
umsg.Long (self.RAMSize)
umsg.Float(self.SerialNo)
umsg.Short(self.ChipType)
umsg.End()
net.Start("wire_gpu_action")
net.WriteUInt(2, 2)
net.WriteUInt(self:EntIndex(), MAX_EDICT_BITS)
net.WriteInt(self.RAMSize, 32)
net.WriteFloat(self.SerialNo)
net.WriteInt(self.ChipType, 16)
net.Broadcast()
end)
end
end
Expand All @@ -81,10 +86,11 @@ function ENT:SetExtensionLoadOrder(extstr)
function()
if not self:IsValid() then return end

umsg.Start("wire_gpu_extensions")
umsg.Long(self:EntIndex())
umsg.String(self.ZVMExtensions)
umsg.End()
net.Start("wire_gpu_action")
net.WriteUInt(3, 2)
net.WriteUInt(self:EntIndex(), MAX_EDICT_BITS)
net.WriteString(self.ZVMExtensions)
net.Broadcast()
end)
end

Expand Down
Loading
Loading