Garry's Mod Leaks

[LEAK]Atlas Chat

Submitted by Pan26, , Thread ID: 207263

Thread Closed

RE: [LEAK]Atlas Chat

#5
25-05-2021, 10:33 PM
stevo45os Wrote:
Quick Question: Is line 329 to 337 at "atlaschat/lua/atlaschat/cl_init.lua" for clearing chat?
idk seems hella sketch look at this code with the comment "a shitty hack for tabs" i dont suggest using
Code:
local function __clean(s, replacement)
local p, len = 1, #s

while p <= len do
  if   p == s:find("[%z\1-\127]", p) then p = p + 1
  elseif p == s:find("[\194-\223][\128-\191]", p) then p = p + 2
  elseif p == s:find(    "\224[\160-\191][\128-\191]", p)
    or p == s:find("[\225-\236][\128-\191][\128-\191]", p)
    or p == s:find(    "\237[\128-\159][\128-\191]", p)
    or p == s:find("[\238-\239][\128-\191][\128-\191]", p) then p = p + 3
  elseif p == s:find(    "\240[\144-\191][\128-\191][\128-\191]", p)
    or p == s:find("[\241-\243][\128-\191][\128-\191][\128-\191]", p)
    or p == s:find(    "\244[\128-\143][\128-\191][\128-\191]", p) then p = p + 4
  else
   s = s:sub(1, p-1)..replacement..s:sub(p+1)
  end
end

return s
end

atlaschat.fontCache = atlaschat.fontCache or {}

function atlaschat.BuildFontCache(text, font)
local text = tostring(text)
text = __clean(text, " ")
text = text:gsub("\t", "  ") -- a shitty hack for tabs

local font = font or atlaschat.font:GetString()
local lowered = string.lower(font)
local len = string.utf8len(text)

if (!atlaschat.fontCache[lowered]) then atlaschat.fontCache[lowered] = {} end

surface.SetFont(font)

for i = 1, len do
local character = string.utf8sub(text, i, i)

if (!atlaschat.fontCache[lowered][character]) then
local width = surface.GetTextSize(character)

atlaschat.fontCache[lowered][character] = width
end
end

width = surface.GetTextSize("")

atlaschat.fontCache[lowered][""] = width
end

Users browsing this thread: 5 Guest(s)