Skip to content
Merged
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
4 changes: 0 additions & 4 deletions lua/entities/gmod_wire_egp/lib/egplib/materials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
--------------------------------------------------------
local EGP = EGP

if SERVER then
EGP.PlayerFontCount = EGP.PlayerFontCount or {}
end

if CLIENT then
-- Valid fonts table
EGP.ValidFonts_Lookup = EGP.ValidFonts_Lookup or {}
Expand Down
15 changes: 1 addition & 14 deletions lua/entities/gmod_wire_expression2/core/egpfunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

e2function void wirelink:egpLoadFrame( number index )
if (!EGP:IsAllowed( self, this )) then return end
if (!index) then return end

Check warning on line 62 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'not' and '!'
local bool, frame = EGP:LoadFrame( self.player, nil, tostring(index) )
if (bool) then
if (EGP:IsDifferent( this.RenderTable, frame )) then
Expand All @@ -74,7 +74,7 @@
--------------------------------------------------------

e2function void wirelink:egpOrder(number index, number order)
if not isAllowed(nil, self, this) then return end

Check warning on line 77 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'not' and '!'
local bool, k, v = hasObject(this, index)
if bool then
if EGP.SetOrder(this, k, order) then
Expand Down Expand Up @@ -107,7 +107,7 @@
end

e2function void wirelink:egpOrderBelow( number index, number belowthis )
if not isAllowed(nil, self, this) then return end

Check warning on line 110 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of '!' and 'not'
local bool, k, v = hasObject(this, index)
if bool then
if hasObject(this, belowthis) then
Expand All @@ -125,7 +125,7 @@
-- Box
--------------------------------------------------------
e2function egpobject wirelink:egpBox( number index, vector2 pos, vector2 size )
if (!EGP:IsAllowed( self, this )) then return NULL_EGPOBJECT end

Check warning on line 128 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of '!' and 'not'
local bool, obj = egp_create("Box", { index = index, w = size[1], h = size[2], x = pos[1], y = pos[2] }, this)
if (bool) then EGP:DoAction( this, self, "SendObject", obj ) Update(self,this) end
return obj
Expand Down Expand Up @@ -153,7 +153,7 @@

e2function void wirelink:egpRadius( number index, number radius )
if (!EGP:IsAllowed( self, this )) then return NULL_EGPOBJECT end
local bool, k, v = hasObject(this, index)

Check warning on line 156 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: k
if (bool) then
if v:EditObject({ radius = radius }) then EGP:DoAction( this, self, "SendObject", v ) Update(self,this) end
end
Expand Down Expand Up @@ -198,7 +198,7 @@
e2function void wirelink:egpSetText( number index, string text )
if (!EGP:IsAllowed( self, this )) then return end
if #text>EGP_TEXT_LIMIT then text = string.sub(text, 1, EGP_TEXT_LIMIT) end
local bool, k, v = hasObject(this, index)

Check warning on line 201 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: k
if (bool) then
if v:EditObject({ text = text }) then EGP:DoAction( this, self, "SendObject", v ) Update(self,this) end
end
Expand All @@ -209,7 +209,7 @@
----------------------------
e2function void wirelink:egpAlign( number index, number halign )
if (!EGP:IsAllowed( self, this )) then return end
local bool, k, v = hasObject(this, index)

Check warning on line 212 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: k
if (bool) then
if v:EditObject({ halign = math.Clamp(halign,0,2) }) then EGP:DoAction( this, self, "SendObject", v ) Update(self,this) end
end
Expand All @@ -217,7 +217,7 @@

e2function void wirelink:egpAlign( number index, number halign, number valign )
if (!EGP:IsAllowed( self, this )) then return end
local bool, k, v = hasObject(this, index)

Check warning on line 220 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: k
if (bool) then
if v:EditObject({ valign = math.Clamp(valign,0,2), halign = math.Clamp(halign,0,2) }) then EGP:DoAction( this, self, "SendObject", v ) Update(self,this) end
end
Expand All @@ -228,7 +228,7 @@
----------------------------
e2function void wirelink:egpFiltering( number index, number filtering )
if (!EGP:IsAllowed( self, this )) then return end
local bool, k, v = hasObject(this, index)

Check warning on line 231 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: k
if (bool) then
if v:EditObject({ filtering = math.Clamp(filtering,0,3) }) then EGP:DoAction( this, self, "SendObject", v ) Update(self,this) end
end
Expand All @@ -255,24 +255,11 @@
-- Font
----------------------------
local function canCreateFont( ply, font, size )
size = size or 18

EGP.PlayerFontCount[ply:SteamID64()] = EGP.PlayerFontCount[ply:SteamID64()] or { fonts = {}, count = 0 }
local fontTable = EGP.PlayerFontCount[ply:SteamID64()]

if fontTable.count >= 50 then return false end

local fontName = font .. size
if fontTable.fonts[fontName] then return true end

fontTable.count = fontTable.count + 1
fontTable.fonts[fontName] = true

return true
return WireLib.CanFont(font .. (size or 18), ply)
end

e2function void wirelink:egpFont( number index, string font )
if (!EGP:IsAllowed( self, this )) then return end

Check warning on line 262 in lua/entities/gmod_wire_expression2/core/egpfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'not' and '!'
if #font > 30 then return self:throw("Font string is too long!", nil) end
if not canCreateFont( self.player, font ) then return self:throw("You have reached the maximum amount of fonts!", nil) end

Expand Down
13 changes: 11 additions & 2 deletions lua/entities/gmod_wire_textscreen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,18 @@ end

function ENT:SendConfig(ply)
self.doSendConfig = false

local font = string.sub(self.tfont, 0, 31)
local size = self.chrPerLine

if not WireLib.CheckFont(font .. math.floor(760 / size), self:GetPlayer()) then
font = "Arial"
size = 10
end

WireLib.netStart(self)
net.WriteBit(true) -- Sending Config
net.WriteUInt(self.chrPerLine, 4)
net.WriteUInt(size, 4)
net.WriteUInt(self.textJust, 2)
net.WriteUInt(self.valign, 2)

Expand All @@ -288,7 +297,7 @@ function ENT:SendConfig(ply)
net.WriteUInt(self.bgcolor.r, 8)
net.WriteUInt(self.bgcolor.g, 8)
net.WriteUInt(self.bgcolor.b, 8)
net.WriteString(string.sub(self.tfont,0,31))
net.WriteString(font)
WireLib.netEnd(ply)
end

Expand Down
21 changes: 21 additions & 0 deletions lua/wire/server/wirelib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,27 @@ function WireLib.SoundExists(path, ply)
return path
end

local uniqueFontsTbl = setmetatable({}, {__index=function(t,k) local r={[1]=0} t[k]=r return r end})
local maxUniqueFonts = CreateConVar("wire_fonts_unique_max", "50", FCVAR_ARCHIVE, "The maximum number of fonts a player is allowed to create", 0)

function WireLib.CheckFont(font, ply)
if ply then
-- A player can only create a certain number of fonts
local playerFonts = uniqueFontsTbl[ply:SteamID()]

if not playerFonts[font] then
if playerFonts[1] >= maxUniqueFonts:GetInt() then
return
end

playerFonts[font] = true
playerFonts[1] = playerFonts[1] + 1
end
end

return font
end

-- Notify --

local triv_start = WireLib.Net.Trivial.Start
Expand Down
Loading