Cleans up gamemode hook calls using SendLua. Prevents errors in non-sandbox gamemodes.
What's wrong with hook.Run?
Nothing as such, but it only gets the gamemode with gmod.GetGamemode and then passes everything onto hook.Call. It's good for module environments where the GAMEMODE global isn't directly accessible, but for anything in the standard environment, it's quicker and simpler just to use hook.Call.
The GAMEMODE global is completely useless for gamemode methods. Use self.
If you want your useless microseconds of speed at least get it right.
As far as I am aware, both work inside GM methods. You are right in that I should be using self, however; I'll swap it in a sec.
If I sound like an asshole it's because I don't like your change. I just don't understand why people favour worse code for such a small optimization.
The SendLua changes are fine (but could surely use hook.Run too heh).
Is there any particular benefit, other than that it looks a tad nicer? It's the sum of small differences that produces the biggest effects, and I doubt the interpreter (or users) give a shit how pretty the code is.
Saving the world, one line of ugly code at a time
Pretty code is important. If you want a faster game go optimize the widget system's PlayerTick hook. That's a real issue.
Readable code is important. An extra arg is worthwhile to avoid two needless calls, in my opinion.
-snip- base GM changes removed
Since I'm making changes to cl_init on the base GM in #865, I'm going to remove the changes from this one. While I'm at it, what are your thoughts on this, @robotboy655? hook.Run or hook.Call? There's no point in changes if noone approves.
Before I look into this, remove all the whitespace changes from all your commits. It clogs up the things you actually want to change. I said numerous times that you shouldn't bother removing whitespace from entire file. I will do it myself once I deal with most of the PRs.
Don't change hook.Run to hook.Call, but you may change it other way around.
I will do. Okay, that settles it.
Oh, and no hard feelings @wiox, I don't take things personally.
GM hook calls
All GM method calls via SendLua now use hook.Run
(Sorted & rebased)
I know it's not a part of this pr, but I hate the SendLua functions being used for hints. Slow and potentially exploitable. Luckily wiremod uses net messages for their e2 hints.
I'm not especially fond of it either. I reckon it'd be nice to have a global function serverside, using net to call hooks on clients, but this is something to think about after the update and when all these pulls have been sorted out.