Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify #2967

Merged
merged 1 commit into from
Jan 4, 2024
Merged
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
3 changes: 1 addition & 2 deletions lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@
local GetTable = EntMeta.GetTable

function EGP:ValidEGP( Ent )
if not IsValid( Ent ) then return false end
return GetTable( Ent ).IsEGP == true
return IsValid( Ent ) and GetTable( Ent ).IsEGP == true
end
end

Expand All @@ -249,7 +248,7 @@
hook.Add("PlayerInitialSpawn","EGP_ScrHW_Request",function(ply)
timer.Simple(1,function()
if (ply and ply:IsValid() and ply:IsPlayer()) then
umsg.Start("EGP_ScrWH_Request",ply) umsg.End()

Check warning on line 251 in lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Deprecated"

Deprecated: Use net messages.
end
end)
end)
Expand Down Expand Up @@ -352,7 +351,7 @@
if dot > 0.999 then -- also account for rounding errors, somehow the dot product can be >1, which makes scaling nan
-- direction stays the same, no need for a corner, just skip this point, unless it is the last segment of a closed path (last segment of a open path is handled explicitly above)
if i == num+1 then
corners[#corners+1] = { r={x=x1-dir.y*size, y=y1+dir.x*size}, l={x=x1+dir.y*size, y=y1-dir.x*size} }

Check warning on line 354 in lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
end
elseif dot < -0.999 then -- new direction is inverse, just add perpendicular nodes
corners[#corners+1] = { r={x=x1-dir.y*size, y=y1+dir.x*size}, l={x=x1+dir.y*size, y=y1-dir.x*size} }
Expand All @@ -360,19 +359,19 @@
local offsetx = -lastdir.y*size-lastdir.x*scaling
local offsety = lastdir.x*size-lastdir.y*scaling
if dot < 0 then -- sharp corner, add two points to the outer edge to not have insanely long spikes
corners[#corners+1] = { r={x=x1+offsetx, y=y1+offsety}, l={x=x1+(lastdir.x+lastdir.y)*size, y=y1+(lastdir.y-lastdir.x)*size} }

Check warning on line 362 in lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
corners[#corners+1] = { r={x=x1+offsetx, y=y1+offsety}, l={x=x1-(dir.x-dir.y)*size, y=y1-(dir.y+dir.x)*size} }
else
corners[#corners+1] = { r={x=x1+offsetx, y=y1+offsety}, l={x=x1-offsetx, y=y1-offsety} }

Check warning on line 365 in lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
end
else -- left bend
local offsetx = lastdir.y*size-lastdir.x*scaling
local offsety = -lastdir.x*size-lastdir.y*scaling
if dot < 0 then
corners[#corners+1] = { l={x=x1+offsetx, y=y1+offsety}, r={x=x1+(lastdir.x-lastdir.y)*size, y=y1+(lastdir.y+lastdir.x)*size} }

Check warning on line 371 in lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
corners[#corners+1] = { l={x=x1+offsetx, y=y1+offsety}, r={x=x1-(dir.x+dir.y)*size, y=y1-(dir.y-dir.x)*size} }
else
corners[#corners+1] = { l={x=x1+offsetx, y=y1+offsety}, r={x=x1-offsetx, y=y1-offsety} }

Check warning on line 374 in lua/entities/gmod_wire_egp/lib/egplib/usefulfunctions.lua

View workflow job for this annotation

GitHub Actions / lint

"Scope depth"

Are you Egyptian? What's with these fucking scope pyramids!?
end
end
end
Expand Down
Loading