Prevented 2 errors from happening #778

Merged
merged 2 commits into from Aug 4, 2014

Projects

None yet

6 participants

@Leystryku
Contributor

No description provided.

Leystryku added some commits Aug 4, 2014
@Leystryku Leystryku Update widget.lua
Prevents a stupid error from happening
4e1594f
@Leystryku Leystryku Update nocollide.lua
Prevents a stupid error from happening
d95f01b
@Leystryku Leystryku changed the title from Prevented 2 stupid errors from happening to Prevented 2 errors from happening Aug 4, 2014
@HellaMadMax HellaMadMax commented on the diff Aug 4, 2014
garrysmod/lua/includes/modules/widget.lua
@@ -35,7 +35,7 @@ local function UpdateHovered( pl, mv )
endpos = pl:EyePos() + pl:GetAimVector() * 256,
filter = function( ent )
- return ent:IsValid() && ent:IsWidget()
+ return ent.IsValid && ent:IsValid() && ent:IsWidget()
@HellaMadMax
HellaMadMax Aug 4, 2014 Contributor

Aren't things like this just meant to be "IsValid( ent )"?

@Leystryku
Contributor

The IsValid variant is a bit slower because it would search for the global in _G. It doesn't really matter though

@robotboy655 robotboy655 merged commit 45aa8bf into garrynewman:master Aug 4, 2014
@willox
Collaborator
willox commented Aug 4, 2014

#769 (comment)

So is this a rule or not?

@Acecool
Contributor
Acecool commented Aug 7, 2014

Yeah, it makes sense to use IsValid because it already contains that check, and if an issue arises we can just update it in one spot. For GetClass, maybe an IsValid check should go there, because if it is valid then GetClass will exist.. Either-way it'll resolve the issue.

@samuelmaddock

This looks like it should be IsValid(ent).

Collaborator

I will change it, calm down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment