Skip to content

Commit

Permalink
Merge branch 'master' into hook-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thecraftianman committed Dec 27, 2023
2 parents 43d1ac0 + 4e92462 commit 681d5f3
Show file tree
Hide file tree
Showing 95 changed files with 1,871 additions and 1,582 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/GLuaFixer.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .github/workflows/GLuaLint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: GLuaLint

on:
push:
paths:
- 'lua/**'
- '!lua/entities/gmod_wire_expression2/**'
pull_request:
paths:
- 'lua/**'
- '!lua/entities/gmod_wire_expression2/**'

jobs:
Lint:
uses: FPtje/GLuaFixer/.github/workflows/glualint.yml@master
with:
config: "./.glualint.json"
4 changes: 2 additions & 2 deletions .glualint.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"lint_unusedVars": true,
"lint_unusedParameters": true,
"lint_unusedLoopVars": true,
"lint_ignoreFiles": [],
"lint_ignoreFiles": ["lua/entities/gmod_wire_expression2/core/custom/*.lua"],

"prettyprint_spaceAfterParens": false,
"prettyprint_spaceAfterBrackets": false,
Expand All @@ -30,4 +30,4 @@
"prettyprint_rejectInvalidCode": false,
"prettyprint_indentation": "\t",
"log_format": "auto"
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
[![Discord Invite](https://img.shields.io/discord/654142834030542878?label=Chat&style=flat-square)](https://discord.gg/jgdzysxjST)
[![Steam Group](https://img.shields.io/badge/ACF%20Official-Join%20Now!-informational?style=flat-square)](https://steamcommunity.com/groups/officialacf)
[![Linting Status](https://img.shields.io/github/workflow/status/Stooberton/ACF-3/GLuaFixer?label=Linter%20Status&style=flat-square)](https://github.com/Stooberton/ACF-3/actions?query=workflow%3AGLuaFixer)
[![Test Suite](https://img.shields.io/github/workflow/status/Stooberton/ACF-3/GLuaTest%20Runner?label=Test%20Suite&style=flat-square)](https://github.com/CFC-Servers/GLuaTest)
[![Linting Status](https://img.shields.io/github/actions/workflow/status/Stooberton/ACF-3/GLuaLint.yml?branch=master&label=Linter%20Status&style=flat-square)](https://github.com/Stooberton/ACF-3/actions?query=workflow%3AGLuaLint)
[![Test Suite](https://img.shields.io/github/actions/workflow/status/Stooberton/ACF-3/gluatest.yml?branch=master&label=Test%20Suite&style=flat-square)](https://github.com/CFC-Servers/GLuaTest)
[![Repository Size](https://img.shields.io/github/repo-size/Stooberton/ACF-3?label=Repository%20Size&style=flat-square)](https://github.com/Stooberton/ACF-3)
[![Commit Activity](https://img.shields.io/github/commit-activity/m/Stooberton/ACF-3?label=Commit%20Activity&style=flat-square)](https://github.com/Stooberton/ACF-3/graphs/commit-activity)

Expand Down
2 changes: 0 additions & 2 deletions lua/acf/ballistics/ballistics_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ function Ballistics.RemoveBullet(Bullet)

Bullet.Removed = true

Ballistics.BulletClient(Bullet, "Update", 1, Bullet.Pos) -- Kills the bullet on the clientside

if not next(Bullets) then
hook.Remove("ACF_OnClock", "ACF Iterate Bullets")
end
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 6 additions & 2 deletions lua/acf/core/classes/entities/registration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,15 @@ do -- Spawning and updating

local HookResult, HookMessage = hook.Run("ACF_CanUpdateEntity", Entity, Data)

if not HookResult then return false, "Couldn't update entity: " .. (HookMessage or "No reason provided.") end
if HookResult == false then
return false, "Couldn't update entity: " .. (HookMessage or "No reason provided.")
end

local Result, Message = Entity:Update(Data)

if not Result then Message = "Couldn't update entity: " .. Message end
if not Result then
Message = "Couldn't update entity: " .. (Message or "No reason provided.")
end

return Result, Message
end
Expand Down
4 changes: 4 additions & 0 deletions lua/acf/core/classes/fuel_tanks/registration.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ end
function FuelTanks.RegisterItem(ID, ClassID, Data)
local Class = Classes.AddGroupItem(ID, ClassID, Entries, Data)

if Class.Name == nil then
Class.Name = "Fuel Box"
end

if Class.IsExplosive == nil then
Class.IsExplosive = true
end
Expand Down
2 changes: 1 addition & 1 deletion lua/acf/core/classes/grouped.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function Classes.AddGroupedFunctions(Namespace, Entries)

local Data = isstring(ID) and Group.Lookup[ID]

return Data and Data.ID == ID or false
return Data and Data.ID ~= ID or false
end
end

Expand Down
2 changes: 1 addition & 1 deletion lua/acf/core/classes/simple.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Classes.AddSimpleFunctions(Namespace, Entries)
function Namespace.IsAlias(ID)
local Data = isstring(ID) and Entries[ID]

return Data and Data.ID == ID or false
return Data and Data.ID ~= ID or false
end
end

Expand Down
22 changes: 13 additions & 9 deletions lua/acf/core/globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ do -- ACF global vars
ACF.ModelData = ACF.ModelData or { Models = {} }

-- General Settings
ACF.Gamemode = 2 -- Gamemode of the server. 1 = Sandbox, 2 = Classic, 3 = Competitive
ACF.LegalChecks = true -- Whether or not IsLegal checks should be run on ACF entities
ACF.Year = 1945
ACF.IllegalDisableTime = 30 -- Time in seconds for an entity to be disabled when it fails ACF.IsLegal
ACF.RestrictInfo = true -- If enabled, players will be only allowed to get info from entities they're allowed to mess with.
Expand All @@ -19,6 +19,7 @@ do -- ACF global vars
ACF.RecoilPush = true -- Whether or not ACF guns apply recoil
ACF.Volume = 1 -- Global volume for ACF sounds
ACF.AllowFunEnts = true -- Allows entities listed under the Fun Stuff option to be used
ACF.AllowProcArmor = false --Allows procedural armor entities to be used.
ACF.WorkshopContent = true -- Enable workshop content download for clients
ACF.WorkshopExtras = false -- Enable extra workshop content download for clients
ACF.SmokeWind = 5 + math.random() * 35 --affects the ability of smoke to be used for screening effect
Expand Down Expand Up @@ -62,12 +63,13 @@ do -- ACF global vars
prop_vehicle_crane = true,
prop_dynamic = true,
npc_strider = true,
npc_dog = true
npc_dog = true,
phys_bone_follower = true,
}

-- Ammo
ACF.AmmoArmor = 5 -- How many millimeters of armor ammo crates have
ACF.AmmoPadding = 10 -- Millimeters of wasted space between rounds
ACF.AmmoPadding = 0.3 -- Ratio of wasted space to projectile case diameter
ACF.AmmoCaseScale = 1 -- How much larger the diameter of the case is versus the projectile (necked cartridges, M829 is 1.4, .50 BMG is 1.6)
ACF.AmmoMinSize = 6 -- Defines the shortest possible length of ammo crates for all their axises, in gmu
ACF.AmmoMaxSize = 96 -- Defines the highest possible length of ammo crates for all their axises, in gmu
Expand Down Expand Up @@ -101,7 +103,7 @@ do -- ACF global vars
ACF.CopperDensity = 8.96e-3 -- kg/cm^3

-- Debris
ACF.ChildDebris = 50 -- higher is more debris props; Chance = ACF.ChildDebris / num_children; Only applies to children of acf-killed parent props
ACF.ChildDebris = 50 -- Higher is more debris props; Chance = ACF.ChildDebris / num_children; Only applies to children of acf-killed parent props
ACF.DebrisIgniteChance = 0.25
ACF.ValidDebris = { -- Whitelist for things that can be turned into debris
acf_ammo = true,
Expand All @@ -119,13 +121,15 @@ do -- ACF global vars
ACF.GunInaccuracyBias = 2 -- Higher numbers make shots more likely to be inaccurate. Choose between 0.5 to 4. Default is 2 (unbiased).

-- Fuel
ACF.FuelRate = 1 --multiplier for fuel usage, 1.0 is approx real world
ACF.RequireFuel = true -- Whether or not fuel usage should be required for engines
ACF.FuelRate = 27.8 -- Multiplier for fuel usage, 1.0 is approx real world
ACF.FuelFactor = 1 -- Multiplier for ACF.FuelRate
ACF.CompFuelRate = 27.8 -- Extra multiplier for fuel consumption on servers with ACF Gamemode set to Competitive
ACF.CompFuelFactor = 1 -- Multiplier for ACF.CompFuelRate
ACF.TankVolumeMul = 1 -- multiplier for fuel tank capacity, 1.0 is approx real world
ACF.FuelMinSize = 6 -- Defines the shortest possible length of fuel tanks for all their axises, in gmu
ACF.FuelMaxSize = 96 -- Defines the highest possible length of fuel tanks for all their axises, in gmu
ACF.FuelArmor = 5 -- How many millimeters of armor fuel tanks have
ACF.TankVolumeMul = 1 -- Multiplier for fuel tank capacity, 1.0 is approx real world
ACF.LiIonED = 0.458 -- li-ion energy density: kw hours / liter
ACF.RefillDistance = 300 --Distance in which ammo crate starts refilling.
ACF.RefillDistance = 300 -- Distance in which ammo crate starts refilling.
ACF.RefillSpeed = 700 -- (ACF.RefillSpeed / RoundMass) / Distance
ACF.RefuelSpeed = 20 -- Liters per second * ACF.FuelRate
end
Expand Down
101 changes: 61 additions & 40 deletions lua/acf/core/networking/model_data/model_data_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,65 +73,86 @@ function ModelData.GetModelData(Model)
end
end

hook.Add("ACF_OnLoadAddon", "ACF_ModelData", function()
local CheckEntity

local CheckEntity
local function UpdateEntity(Entity)
ModelData.Entity = Entity

local function UpdateEntity(Entity)
ModelData.Entity = Entity
for Model, Data in pairs(Standby) do
if Data == true then continue end -- Information hasn't been received yet

for Model, Data in pairs(Standby) do
if Data == true then continue end -- Information hasn't been received yet
Standby[Model] = nil
Models[Model] = Data

hook.Run("ACF_OnReceivedModelData", Model, Data)
end

Standby[Model] = nil
Models[Model] = Data
Entity:CallOnRemove("ACF_ModelData", function()
hook.Add("OnEntityCreated", "ACF_ModelData", CheckEntity)
end)

ModelData.RunCallbacks(Model)
hook.Remove("OnEntityCreated", "ACF_ModelData")
end

Entity:CallOnRemove("ACF_ModelData", function()
hook.Add("OnEntityCreated", "ACF_ModelData", CheckEntity)
end)
CheckEntity = function(Entity)
if Entity:EntIndex() ~= ModelData.EntIndex then return end

hook.Remove("OnEntityCreated", "ACF_ModelData")
end
UpdateEntity(Entity)
end

CheckEntity = function(Entity)
if Entity:EntIndex() ~= ModelData.EntIndex then return end
Network.CreateReceiver("ACF_ModelData_Entity", function(Data)
local Index = Data.Index
local ModelEnt = Entity(Index)

UpdateEntity(Entity)
end
ModelData.EntIndex = Index

Network.CreateReceiver("ACF_ModelData_Entity", function(Data)
local Index = Data.Index
local ModelEnt = Entity(Index)
if not IsValid(ModelEnt) then
hook.Add("OnEntityCreated", "ACF_ModelData", CheckEntity)

ModelData.EntIndex = Index
return
end

if not IsValid(ModelEnt) then
hook.Add("OnEntityCreated", "ACF_ModelData", CheckEntity)
UpdateEntity(ModelEnt)
end)

return
end
Network.CreateSender("ACF_ModelData", function(Queue, Model)
Standby[Model] = true
Queue[Model] = true

UpdateEntity(ModelEnt)
end)
hook.Run("ACF_OnRequestedModelData", Model)
end)

Network.CreateReceiver("ACF_ModelData", function(Data)
local Exists = IsValid(ModelData.Entity)

for Model, Info in pairs(Data) do
if not Exists then
Standby[Model] = Info
else
Standby[Model] = nil
Models[Model] = Info

Network.CreateSender("ACF_ModelData", function(Queue, Model)
Standby[Model] = true
Queue[Model] = true
hook.Run("ACF_OnReceivedModelData", Model, Info)
end
end
end)

hook.Remove("ACF_OnLoadAddon", "ACF_ModelData")
end)

Network.CreateReceiver("ACF_ModelData", function(Data)
local Exists = IsValid(ModelData.Entity)
hook.Add("ACF_OnReceivedModelData", "ACF_ModelData_PanelRefresh", function(Model)
local Data = Callbacks[Model]

for Model, Info in pairs(Data) do
if not Exists then
Standby[Model] = Info
else
Standby[Model] = nil
Models[Model] = Info
if not Data then return end

ModelData.RunCallbacks(Model)
for Object, Callback in pairs(Data) do
if IsValid(Object) then
Callback(Object, Model)
end

Data[Object] = nil
end
end)

Callbacks[Model] = nil
end)
6 changes: 4 additions & 2 deletions lua/acf/core/networking/model_data/model_data_sv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ do -- Model data getter method
end
end

do -- Network handlers
hook.Add("ACF_OnLoadAddon", "ACF_ModelData", function()
Network.CreateSender("ACF_ModelData_Entity", function(Queue, Entity)
Queue.Index = Entity:EntIndex()
end)
Expand All @@ -126,4 +126,6 @@ do -- Network handlers
Network.CreateSender("ACF_ModelData", function(Queue, Model)
Queue[Model] = ModelData.GetModelData(Model)
end)
end

hook.Remove("ACF_OnLoadAddon", "ACF_ModelData")
end)
4 changes: 2 additions & 2 deletions lua/acf/core/round_functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ do -- Ammo crate capacity calculation
local Width = Caliber * ACF.AmmoCaseScale * 0.1 -- mm to cm
local Length = BulletData.PropLength + BulletData.ProjLength + BulletData.Tracer
local MagSize = math.floor(ACF.GetWeaponValue("MagSize", Caliber, WeaponClass, Weapon) or 1)
local Spacing = math.max(0, ToolData.AmmoPadding or ACF.AmmoPadding) * 0.1 + 0.125
local Spacing = math.max(0, ToolData.AmmoPadding or ACF.AmmoPadding) * Width * 0.1 + 0.125
local IsBoxed = WeaponClass.IsBoxed
local Rounds = 0
local ExtraData = {}
Expand Down Expand Up @@ -400,4 +400,4 @@ do -- Ammo crate capacity calculation

return Rounds, ExtraData
end
end
end
Loading

0 comments on commit 681d5f3

Please sign in to comment.