Skip to content

Commit

Permalink
New Menu Update
Browse files Browse the repository at this point in the history
- Improved ACF Menu Tool.
- Improved ACF Copy Tool.
- Piledriver Entities.
- Improved Rack and Missile Mechanics.
- Further Improved Computers.
- Changed GLATGM Guidance.
- Improved E2 and Starfall Compatibility.
- Clientside Debris by Aversion.
- Several Bugfixes.
- You can find the entire changelog on https://steamcommunity.com/groups/officialacf/announcements/detail/4439953942452950620
  • Loading branch information
TwistedTail committed Jan 19, 2021
2 parents 2515552 + 2e04bf0 commit 40a67db
Show file tree
Hide file tree
Showing 205 changed files with 20,272 additions and 16,228 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/GLuaFixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,21 @@ on:
paths:
- 'lua/**'
- '!lua/entities/gmod_wire_expression2/**'
- '!lua/starfall/**'
pull_request:
paths:
- 'lua/**'
- '!lua/entities/gmod_wire_expression2/**'
- '!lua/starfall/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Download GLuaFixer 1.12.0
run: curl -o glualint.zip -L https://github.com/FPtje/GLuaFixer/releases/download/1.12.0/glualint-1.12.0-linux.zip
- name: Download GLuaFixer 1.17.0
run: curl -o glualint.zip -L https://github.com/FPtje/GLuaFixer/releases/download/1.17.0/glualint-1.17.0-linux.zip
- name: Extract glualint.zip
run: unzip glualint.zip
- name: Remove blacklisted folders
run: rm -r lua/entities/gmod_wire_expression2/ lua/starfall/
run: rm -r lua/entities/gmod_wire_expression2/
- name: Initiate linting
run: ./glualint lua
9 changes: 8 additions & 1 deletion .glualint.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,31 @@
"lint_syntaxErrors": true,
"lint_syntaxInconsistencies": true,
"lint_deprecated": true,
"lint_trailingWhitespace": true,
"lint_whitespaceStyle": true,
"lint_beginnerMistakes": true,
"lint_emptyBlocks": true,
"lint_shadowing": true,
"lint_gotos": true,
"lint_doubleNegations": true,
"lint_redundantIfStatements": true,
"lint_redundantParentheses": true,
"lint_duplicateTableKeys": true,
"lint_profanity": true,
"lint_unusedVars": true,
"lint_unusedParameters": true,
"lint_unusedLoopVars": true,
"lint_ignoreFiles": [],

"prettyprint_spaceAfterParens": false,
"prettyprint_spaceAfterBrackets": false,
"prettyprint_spaceAfterBraces": false,
"prettyprint_spaceAfterLabel": false,
"prettyprint_spaceBeforeComma": false,
"prettyprint_spaceAfterComma": true,
"prettyprint_semicolons": false,
"prettyprint_cStyle": false,
"prettyprint_indentation": "\t"
"prettyprint_rejectInvalidCode": false,
"prettyprint_indentation": "\t",
"log_format": "auto"
}
387 changes: 133 additions & 254 deletions lua/acf/base/acf_globals.lua

Large diffs are not rendered by default.

166 changes: 166 additions & 0 deletions lua/acf/base/data_vars/cl_data_vars.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
local ACF = ACF
local Client = ACF.ClientData
local Server = ACF.ServerData
local Queued = { Client = {}, Server = {} }
local LastSent = { Client = {}, Server = {} }

local function PrepareQueue(Type, Values, Result)
local Queue = Queued[Type]

if not next(Queue) then return end

local Sent = LastSent[Type]
local Data = {}

for K in pairs(Queue) do
local Value = Values[K]

if Value ~= Sent[K] then
Data[K] = Value
end

Queue[K] = nil
end

Result[Type] = Data
end

local function SendQueued()
local Result = {}

PrepareQueue("Client", Client, Result)
PrepareQueue("Server", Server, Result)

if next(Result) then
local JSON = util.TableToJSON(Result)

net.Start("ACF_DataVarNetwork")
net.WriteString(JSON)
net.SendToServer()
end
end

local function NetworkData(Key, IsServer)
local Type = IsServer and "Server" or "Client"
local Destiny = Queued[Type]

if Destiny[Key] then return end -- Already queued

Destiny[Key] = true

-- Avoiding net message spam by sending all the events of a tick at once
if timer.Exists("ACF Network Data Vars") then return end

timer.Create("ACF Network Data Vars", 0, 1, SendQueued)
end

do -- Server data var syncronization
local function ProcessData(Values, Received)
if not Received then return end

for K, V in pairs(Received) do
if Values[K] ~= V then
Values[K] = V

hook.Run("ACF_OnServerDataUpdate", nil, K, V)
end

Received[K] = nil
end
end

net.Receive("ACF_DataVarNetwork", function(_, Player)
local Received = util.JSONToTable(net.ReadString())

if IsValid(Player) then return end -- NOTE: Can this even happen?

ProcessData(Server, Received)
end)

-- We'll request the server data vars as soon as the player starts moving
hook.Add("InitPostEntity", "ACF Request Data Vars", function()
net.Start("ACF_RequestDataVars")
net.SendToServer()

hook.Remove("InitPostEntity", "ACF Request Data Vars")
end)
end

do -- Client data getter functions
local function GetData(Key, Default)
if Key == nil then return Default end

local Value = Client[Key]

if Value ~= nil then return Value end

return Default
end

function ACF.GetAllClientData(NoCopy)
if NoCopy then return Client end

local Result = {}

for K, V in pairs(Client) do
Result[K] = V
end

return Result
end

function ACF.GetClientBool(Key, Default)
return tobool(GetData(Key, Default))
end

function ACF.GetClientNumber(Key, Default)
local Value = GetData(Key, Default)

return ACF.CheckNumber(Value, 0)
end

function ACF.GetClientString(Key, Default)
local Value = GetData(Key, Default)

return ACF.CheckString(Value, "")
end

ACF.GetClientData = GetData
ACF.GetClientRaw = GetData
end

do -- Client data setter function
function ACF.SetClientData(Key, Value, Forced)
if not isstring(Key) then return end

Value = Value or false

if Forced or Client[Key] ~= Value then
Client[Key] = Value

hook.Run("ACF_OnClientDataUpdate", LocalPlayer(), Key, Value)

NetworkData(Key)
end
end
end

do -- Server data setter function
function ACF.SetServerData(Key, Value, Forced)
if not isstring(Key) then return end

local Player = LocalPlayer()

if not ACF.CanSetServerData(Player) then return end

Value = Value or false

if Forced or Server[Key] ~= Value then
Server[Key] = Value

hook.Run("ACF_OnServerDataUpdate", Player, Key, Value)

NetworkData(Key, true)
end
end
end

0 comments on commit 40a67db

Please sign in to comment.