Skip to content

Commit

Permalink
Fixed a bug with -disablehttp, moved shipped playlist to data_static,…
Browse files Browse the repository at this point in the history
… added BBC to playlists, removed DW playlist
  • Loading branch information
Grocel committed Jul 31, 2024
1 parent aec2918 commit 172add7
Show file tree
Hide file tree
Showing 27 changed files with 29 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[playlist]
NumberOfEntries=1
File1=http://stream.live.vc.bbcmedia.co.uk/bbc_world_service
Title1=BBC World Service Online
Length1=-1
Version=2
2 changes: 2 additions & 0 deletions data_static/streamradio/version.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
445
1722461645
2 changes: 1 addition & 1 deletion git-hooks-pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
filename="materials/3dstreamradio/_data/version.vmt"
filename="data_static/streamradio/version.txt"
version=$(head -n 1 $filename)
nextversion=$(($version + 1))
timestap=$(date -u +%s)
Expand Down
6 changes: 3 additions & 3 deletions lua/streamradio_core/_load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LIB.Loaded = nil
LIB.Errors = {}

local function getVersion()
local versiondata = file.Read("materials/3dstreamradio/_data/version.vmt", "GAME") or ""
local versiondata = file.Read("data_static/streamradio/version.txt", "GAME") or ""
versiondata = string.Explode("[\r\n|\r|\n]", versiondata, true) or {}

local Version = string.Trim(tostring(versiondata[1] or ""))
Expand Down Expand Up @@ -270,13 +270,13 @@ local function loadAddon()
-- Sometimes the version is not known, yet.

if CLIENT then
local NEED_VERSION = 230904
local NEED_VERSION = 240730

if VERSION < NEED_VERSION then
versionError = string.format("Your GMod-Client (version: %s) is too old!\nPlease update the GMod-Client to version %s or newer!", VERSION, NEED_VERSION)
end
else
local NEED_VERSION = 230628
local NEED_VERSION = 240730

if VERSION < NEED_VERSION then
versionError = string.format("The GMod-Server (version: %s) is too old!\nPlease update the GMod-Server to version %s or newer!\nTell an Admin!", VERSION, NEED_VERSION)
Expand Down
12 changes: 10 additions & 2 deletions lua/streamradio_core/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ local function request(url, callback, parameters, method, headers, body, type)
return
end

local failed = false

requestdata.failed = function(err)
callcallbacks(rq, false, {
err = err or "",
Expand All @@ -92,6 +94,7 @@ local function request(url, callback, parameters, method, headers, body, type)
})

cleanDoneQuene()
failed = true
end

requestdata.success = function(code, body, headers)
Expand Down Expand Up @@ -125,11 +128,16 @@ local function request(url, callback, parameters, method, headers, body, type)
})

cleanDoneQuene()
failed = false
end

HTTP(requestdata)

rq.started = true

local success = HTTP(requestdata)

if not success and not failed then
requestdata.failed("HTTP failed")
end
end

function LIB.RequestRaw(url, callback, body, method, headers, type)
Expand Down
17 changes: 7 additions & 10 deletions lua/streamradio_core/server/sv_resource.lua
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
resource.AddWorkshop( "246756300" ) -- Workshop download

-- Workaround Garry code that disallows shipping *.txt files for the data folder to Workshop.
local WorkshopDataDirectory = "materials/3dstreamradio/_data"
local g_staticDataDirectory = "data_static"

local function CopyFiles( dir )
file.CreateDir( dir )
local files, directories = file.Find(WorkshopDataDirectory .. "/" .. dir .. "/*", "GAME")
local files, directories = file.Find(g_staticDataDirectory .. "/" .. dir .. "/*", "GAME")

for _, f in ipairs(files or {}) do
local filename = dir .. "/" .. f
local fullpath = WorkshopDataDirectory .. "/" .. filename
local fullpath = g_staticDataDirectory .. "/" .. filename

if not file.Exists(fullpath, "GAME") then continue end

local ext = string.GetExtensionFromFilename(filename)
if ext ~= "vmt" then continue end
if not file.Exists(fullpath, "GAME") then
continue
end

local newfilename = string.StripExtension(filename) .. ".txt"
file.Write(newfilename, file.Read(fullpath, "GAME") or "")
file.Write(filename, file.Read(fullpath, "GAME") or "")
end

for _, d in ipairs(directories or {}) do
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions materials/3dstreamradio/_data/version.vmt

This file was deleted.

0 comments on commit 172add7

Please sign in to comment.