• parent tool crashes. the fix... stop the self love and inbreeding from happening
    10 replies, posted
Lately i've seen a ton of crashes in my server when its close to full. I had a feeling it was because of the Parent tool we use (so we can use large ships without lag). Then after building something nearly 6 times over i came up with a fix that should work on all parent tools. last updated: 9/14/2011 [code] local meta = FindMetaTable( "Entity" ) if (!meta.OldSetParent) then --dont set twice, then we really crash stuff meta.OldSetParent = meta.SetParent --lets fix some parenting error bullshit function meta:SetParent( ent ) --some checks to prevent crashes! if self.Entity:GetParent() == self.Entity or ent == self.Entity then return self.Entity end return self:OldSetParent(ent) --passed checks ok to save now end end[/code] Yes the people that code these tools should really code these checks into their tool, but most are not and I'm to lazy to recode one. If someone wants to package this up to make it easier for not-so-smart people that are likely going to post below feel free.
You should not override this function, just add some checks before the function gets called. Also, you would have to check through ALL parents using a loop to prevent the crashes, at the moment you are only checking the parent and the parents parent.
I don't really care. Hence why i posted [quote]Yes the people that code these tools should really code these checks into [B]their tool,[/B] but most are not and [B]I'm to lazy to recode one.[/B][/quote]
You should care because this could create other problems for people, defeating the purpose of this in the first place.
[QUOTE=-TB-;32181701]You should care because this could create other problems for people, defeating the purpose of this in the first place.[/QUOTE]What problems?
How would this possibly create problems? It's just stopping the game from crashing when parenting two objects when they are already parented.
[LUA] if ValidEntity(parent) then return false end [/LUA] So it's not okay to parent a prop to another prop who is already parented to something? because it works fine for me. When you make code like this that overwrites functions and people start using it, something of it could possibly conflict with other peoples' addons and then everyone starts complaining. I'm just agreeing with what Wizard of Ass is saying. It wouldn't be a matter of recoding a tool than just adding an if statement where the left click function of the tool is.
[QUOTE=-TB-;32223830]So it's not okay to parent a prop to another prop who is already parented to something? because it works fine for me.[/QUOTE] Then don't use it. My server doesn't crash anymore using parent tools. I prefer to not crash every 10 minutes over have a small chance of some random addon not working sometime in the future. edit: Removed the first check to make you happy. I thought I've seen crashes when changing parents but just tested it again and it doesn't seem to do it.
So basically you come and post a shitty fix, then people point you at your mistakes and that it is not a totally complete fix. You totally seem to ignore what they say. Not nice.
[QUOTE=Insomnia Array;32253281]So basically you come and post a shitty fix, then people point you at your mistakes and that it is not a totally complete fix. You totally seem to ignore what they say. Not nice.[/QUOTE] Shitty fix that works :)
Updated the code. Found out under some things SetParent needs to return an entity for adv dups to work (even though wiki says it returns nil).
Sorry, you need to Log In to post a reply to this thread.