Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lua/entities/gmod_wire_digitalscreen/cl_init.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include("shared.lua")


local dsDrawRate = GetConVar("wire_digitalscreen_draw_rate")

Check warning on line 3 in lua/entities/gmod_wire_digitalscreen/cl_init.lua

View workflow job for this annotation

GitHub Actions / lint

"Trailing whitespace"

Trailing whitespace

function ENT:SendData()
net.Start("wire_interactiveprop_action")
Expand Down Expand Up @@ -143,7 +143,7 @@

function ENT:Think()
if self.buffer[1] ~= nil then
local maxtime = SysTime() + RealFrameTime() * 0.05 -- do more depending on client FPS. Higher fps = more work
local maxtime = SysTime() + RealFrameTime() * (0.05*dsDrawRate:GetFloat()) -- do more depending on client FPS. Higher fps = more work

while SysTime() < maxtime and self.buffer[1] do
if not self.co or coroutine.status(self.co) == "dead" then
Expand Down Expand Up @@ -320,7 +320,7 @@

if self.NeedRefresh then
self.NeedRefresh = false
local maxtime = SysTime() + RealFrameTime() * 0.01
local maxtime = SysTime() + RealFrameTime() * (0.01*dsDrawRate:GetFloat())

self.GPU:RenderToGPU(function()
local idx = 0
Expand Down
21 changes: 18 additions & 3 deletions lua/entities/gmod_wire_digitalscreen/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

ENT.WireDebugName = "DigitalScreen"

local dsDrawRate = CreateConVar("wire_digitalscreen_draw_rate", 1, { FCVAR_REPLICATED, FCVAR_ARCHIVE })
local dsNetBandwidth = CreateConVar("wire_digitalscreen_net_bandwidth", 200000, { FCVAR_ARCHIVE })
local dsNetBandwidthValue = dsNetBandwidth:GetInt()

function ENT:InitInteractive()
local model = self:GetModel()
Expand Down Expand Up @@ -127,7 +130,9 @@
function ENT:ReadCell(Address)
Address = math.floor(Address)
if Address < 0 then return nil end
if Address >= 1048577 then return nil end
if Address >= 1048578 then return nil end
if (Address==1048577) then return math.Round(dsNetBandwidthValue/2) end -- report its netbandwidth
if (Address==1048576) then return dsDrawRate:GetFloat() end -- report its draw rate

return self.Memory[Address] or 0
end
Expand Down Expand Up @@ -170,9 +175,19 @@
----------------------------------------------------
-- Processing limiters and global bandwidth limiters
local maxProcessingTime = engine.TickInterval() * 0.9
local defaultMaxBandwidth = 10000 -- 10k per screen max limit - is arbitrary. needs to be smaller than the global limit.
local defaultMaxGlobalBandwidth = 20000 -- 20k is a good global limit in my testing. higher than that seems to cause issues

local defaultMaxBandwidth = math.Round(dsNetBandwidthValue/2) -- 10k per screen max limit - is arbitrary. needs to be smaller than the global limit.
local defaultMaxGlobalBandwidth = dsNetBandwidthValue -- 20k is a good global limit in my testing. higher than that seems to cause issues
local maxBandwidth = defaultMaxBandwidth

local function updateBW()
dsNetBandwidthValue = dsNetBandwidth:GetInt()

defaultMaxBandwidth = math.Round(dsNetBandwidthValue/2)

Check warning on line 186 in lua/entities/gmod_wire_digitalscreen/init.lua

View workflow job for this annotation

GitHub Actions / lint

"Trailing whitespace"

Trailing whitespace
defaultMaxGlobalBandwidth = dsNetBandwidthValue
end
cvars.AddChangeCallback("wire_digitalscreen_net_bandwidth", updateBW)

local globalBandwidthLookup = {}
local function calcGlobalBW()
maxBandwidth = defaultMaxGlobalBandwidth
Expand Down
Loading