Skip to content

Commit

Permalink
Fixed server redirect info not being loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
TwistedTail committed May 26, 2020
1 parent 7c16fcb commit 918d828
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lua/afsu/base/sv_base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,16 @@ do -- File saving and loading
if not CheckFile(File) then return end
if not AFSU[Name] then return end

AFSU[Name] = util.JSONToTable(file.Read(File))
local Table = util.JSONToTable(file.Read(File))
local Data = AFSU[Name]

if next(Data) then
for K in pairs(Data) do Data[K] = nil end
end

for K, V in pairs(Table) do
Data[K] = V
end
end

function AFSU.SaveTableToFile(File, Name)
Expand Down
9 changes: 9 additions & 0 deletions lua/afsu/server/concmd/other/sv_connect.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

local LoadFileToTable = AFSU.LoadFileToTable
local UpdateLookup = AFSU.GetLookupTable
local GetLookup = AFSU.GetLookupTable
local SendMessage = AFSU.SendMessage
local Response = AFSU.SendResponse
Expand Down Expand Up @@ -28,3 +30,10 @@ AFSU.RegisterSingleCommand("connect", function(Player, Name)

timer.Simple(1, function() Response(Player, "Connect", { IP = Data.Address }) end)
end, 0)

hook.Add("Initialize", "AFSU Redirect Init", function()
LoadFileToTable(AFSU.HostnamesFile, "Hostnames")
UpdateLookup("Hostnames", "Name", true)

hook.Remove("Initialize", "AFSU Redirect Init")
end)

0 comments on commit 918d828

Please sign in to comment.