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
2 changes: 1 addition & 1 deletion lua/pac3/core/client/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ function pac.Handleurltex(part, url, callback, shader, additionalData)
if not url:match("https?://.+/%S*") then return false end

pac.urltex.GetMaterialFromURL(
pac.FixUrl(url),
pac.FixUrl(url, "image"),

function(mat, tex)
if not part:IsValid() then return end
Expand Down
15 changes: 11 additions & 4 deletions lua/pac3/core/shared/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ local function http(method, url, headers, cb, failcb)
})
end

function pac.FixUrl(url)
function pac.FixUrl(url, expectedContentType)
url = url:Trim()
url = url:gsub("[\"'<>\n\\]+", "")

Expand All @@ -74,14 +74,21 @@ function pac.FixUrl(url)
return url
end

if url:find("drive.google.com", 1, true) and not url:find("export=download", 1, true) then
if url:find("drive.google.com", 1, true) then
local id =
url:match("https://drive.google.com/file/d/(.-)/") or
url:match("https://drive.google.com/file/d/(.-)$") or
url:match("https://drive.google.com/open%?id=(.-)$")
url:match("https://drive.google.com/open%?id=(.-)$") or
url:match("https://drive.google.com/uc%?export=download&id=(.-)$") or
url:match("https://drive.google.com/uc%?id=(.-)&export=download$")

if id then
return "https://drive.google.com/uc?export=download&id=" .. id
if expectedContentType == "image" then
local thumbnailSize = math.Clamp( pac.urltex.TextureSize, 32, 4096 )
return "https://drive.google.com/thumbnail?id=" .. id .. "&sz=s" .. string.format("%.0f", thumbnailSize)
elseif not url:find("export=download", 1, true) then
return "https://drive.google.com/uc?export=download&id=" .. id
end
end
return url
end
Expand Down
2 changes: 1 addition & 1 deletion lua/pac3/editor/client/saved_parts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ end

local last_backup
local maxBackups = CreateConVar("pac_backup_limit", "100", {FCVAR_ARCHIVE}, "Maximal amount of backups")
local autoload_prompt = CreateConVar("pac_prompt_for_autoload", "1", {FCVAR_ARCHIVE}, "Whether to ask before loading autoload. The prompt can let you choose to not load, pick autoload or the newest backup")
local autoload_prompt = CreateConVar("pac_prompt_for_autoload", "0", {FCVAR_ARCHIVE}, "Whether to ask before loading autoload. The prompt can let you choose to not load, pick autoload or the newest backup")
local auto_spawn_prop = CreateConVar("pac_autoload_preferred_prop", "2", {FCVAR_ARCHIVE}, "When loading a pac with an owner name suggesting a prop, notify you and then wait before auto-applying the outfit next time you spawn a prop.\n" ..
"0 : do not check\n1 : check if only 1 such group is present\n2 : check if multiple such groups are present and queue one group at a time")

Expand Down
14 changes: 7 additions & 7 deletions lua/pac3/editor/client/wear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ do -- from server
pac.dprint("received outfit %q from %s with %i number of children to set on %s", part_data.self.Name or "", tostring(owner), table.Count(part_data.children), part_data.self.OwnerName or "")

if pace.CallHook("WearPartFromServer", owner, part_data, data) == false then return end
if pace.ShouldIgnorePlayer(owner) then pace.RemovePartFromServer(owner, "__ALL__", data) return end
if pace.ShouldIgnorePlayer(owner) and owner ~= LocalPlayer() then pace.RemovePartFromServer(owner, "__ALL__", data) return end

local dupepart = pac.GetPartFromUniqueID(data.player_uid, part_data.self.UniqueID)

Expand Down Expand Up @@ -306,7 +306,7 @@ do
local backup_files, directories = file.Find( "pac3/__backup/*.txt", "DATA", "datedesc")
local latest_outfit = cookie.GetString( "pac_last_loaded_outfit", "" )
if not backup_files then
local pnl = Derma_Query("Do you want to load your autoload outfit?", "PAC3 autoload (pac_prompt_for_autoload)",
local pnl = Derma_Query("Do you want to load your autoload outfit?\nclick outside the window to cancel", "PAC3 autoload (pac_prompt_for_autoload)",
"load pac3/autoload.txt : " .. string.NiceSize(file.Size("pac3/autoload.txt", "DATA")), function()
pac.Message("Wearing autoload...")
pace.LoadParts("autoload")
Expand All @@ -322,13 +322,13 @@ do
end
end,

"cancel", function() pac.Message("Not loading autoload or backups...") end
"don't show this again", function() GetConVar("pac_prompt_for_autoload"):SetBool(false) end
)
pnl.Think = function() if not pnl:HasFocus() or (input.IsMouseDown(MOUSE_LEFT) and not (pnl:IsHovered() or pnl:IsChildHovered())) then pnl:Remove() end end
else
if backup_files[1] then
local latest_autosave = "pac3/__backup/" .. backup_files[1]
local pnl = Derma_Query("Do you want to load an outfit?", "PAC3 autoload (pac_prompt_for_autoload)",
local pnl = Derma_Query("Do you want to load an outfit?\nclick outside the window to cancel", "PAC3 autoload (pac_prompt_for_autoload)",
"load pac3/autoload.txt : " .. string.NiceSize(file.Size("pac3/autoload.txt", "DATA")), function()
pac.Message("Wearing autoload...")
pace.LoadParts("autoload")
Expand All @@ -349,18 +349,18 @@ do
end
end,

"cancel", function() pac.Message("Not loading autoload or backups...") end
"don't show this again", function() GetConVar("pac_prompt_for_autoload"):SetBool(false) end
)
pnl.Think = function() if not pnl:HasFocus() or (input.IsMouseDown(MOUSE_LEFT) and not (pnl:IsHovered() or pnl:IsChildHovered())) then pnl:Remove() end end
else
local pnl = Derma_Query("Do you want to load your autoload outfit?", "PAC3 autoload (pac_prompt_for_autoload)",
local pnl = Derma_Query("Do you want to load your autoload outfit?\nclick outside the window to cancel", "PAC3 autoload (pac_prompt_for_autoload)",
"load pac3/autoload.txt : " .. string.NiceSize(file.Size("pac3/autoload.txt", "DATA")), function()
pac.Message("Wearing autoload...")
pace.LoadParts("autoload")
pace.WearParts()
end,

"cancel", function() pac.Message("Not loading autoload or backups...") end
"don't show this again", function() GetConVar("pac_prompt_for_autoload"):SetBool(false) end
)
pnl.Think = function() if not pnl:HasFocus() or (input.IsMouseDown(MOUSE_LEFT) and not (pnl:IsHovered() or pnl:IsChildHovered())) then pnl:Remove() end end
end
Expand Down
16 changes: 15 additions & 1 deletion lua/pac3/libraries/resource.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ local function download(from, to, callback, on_fail, on_header, check_etag, etag

local allowed = {
[".txt"] = true,
[".jpeg"] = true,
[".jpg"] = true,
[".png"] = true,
[".vtf"] = true,
Expand All @@ -150,7 +151,20 @@ local function download(from, to, callback, on_fail, on_header, check_etag, etag
function(body, len, header)
do
if need_extension then
local ext = header["Content-Type"] and (header["Content-Type"]:match(".-/(.-);") or header["Content-Type"]:match(".-/(.+)")) or "dat"
local ext = "dat"
if header["Content-Type"] then
for _, mime in ipairs( string.Split(header["Content-Type"], ',') ) do -- some common services, including google, serve multi-item mime strings like "image/png,application/binary"
subtype = mime:match(".-/(.-);") or mime:match(".-/(.+)")
if subtype then
subtype = subtype:lower()
if allowed['.' .. subtype] then
ext = subtype
break -- take the first subtype (if any) found in our whitelist
end
end
end
end

if ext == "jpeg" then ext = "jpg" end

if body:StartWith("VTF") then
Expand Down
2 changes: 1 addition & 1 deletion lua/pac3/libraries/urltex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
urltex.ActivePanel:Remove()
end

local enable = CreateClientConVar("pac_enable_urltex", "1", true)

Check warning on line 17 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
local EMPTY_FUNC = function() end
local function findFlag(url, flagID)
local startPos, endPos = url:find(flagID)
if not startPos then return url, false end

if url:sub(endPos + 1, endPos + 1) == ' ' or url:sub(startPos - 1, startPos - 1) == ' ' then
url = url:gsub(' ?' .. flagID .. ' ?', '')

Check warning on line 24 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'double quoted strings' and 'single quoted strings'

Check warning on line 24 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
return url, true
end

Expand All @@ -34,7 +34,7 @@
end

additionalData = additionalData or {}
shader = shader or "VertexLitGeneric"

Check warning on line 37 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'double quoted strings' and 'single quoted strings'
if not enable:GetBool() then return end
local noclampS, noclamp, noclampT

Expand All @@ -50,7 +50,7 @@
elseif noclampS then
urlIndex = urlIndex .. ' noclampS'
elseif noclampT then
urlIndex = urlIndex .. ' noclampT'

Check warning on line 53 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'double quoted strings' and 'single quoted strings'
end

noclamp = noclamp or noclampS and noclampT
Expand All @@ -62,7 +62,7 @@

if isfunction(callback) and not skip_cache and urltex.Cache[urlIndex] then
local tex = urltex.Cache[urlIndex]
local mat = CreateMaterial("pac3_urltex_" .. pac.Hash(), shader, additionalData)

Check warning on line 65 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'double quoted strings' and 'single quoted strings'
mat:SetTexture("$basetexture", tex)
callback(mat, tex)
return
Expand Down Expand Up @@ -113,7 +113,7 @@
urltex.ActivePanel:Remove()
end

url = pac.FixUrl(url)
url = pac.FixUrl(url, "image")
local size = tonumber(data.size or urltex.TextureSize)
local id = "urltex_download_" .. url
local pnl
Expand All @@ -130,7 +130,7 @@
html
{
overflow:hidden;
]] .. (data.size_hack and "margin: -8px -8px;" or "margin: 0px 0px;") .. [[

Check warning on line 133 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
}
</style>
<script>
Expand All @@ -150,7 +150,7 @@
pnl:Refresh()

function pnl:ConsoleMessage(msg)
if msg == 'REAL_FRAME_PASSED' then

Check warning on line 153 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
frames_passed = frames_passed + 1
end
end
Expand Down Expand Up @@ -232,7 +232,7 @@
textureFlags = textureFlags - 8
end

local vertex_mat2 = CreateMaterial("pac3_urltex_" .. crc .. '_hack', 'UnlitGeneric', data.additionalData)

Check warning on line 235 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'

Check warning on line 235 in lua/pac3/libraries/urltex.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
vertex_mat2:SetTexture("$basetexture", tex)
rt = GetRenderTargetEx("pac3_urltex_" .. crc, size, size, RT_SIZE_NO_CHANGE, MATERIAL_RT_DEPTH_NONE, textureFlags, CREATERENDERTARGETFLAGS_UNFILTERABLE_OK, IMAGE_FORMAT_RGB888)
render.PushRenderTarget(rt)
Expand Down
Loading