EloBuddy / EloBuddy.Issues

Issue Tracker for
http://EloBuddy.net
0 stars 2 forks source link

Menu Checkbox crashes Game #59

Closed LXMedia1 closed 8 years ago

LXMedia1 commented 8 years ago

I found a wierd Bug in the Menu who crashes the game

i think its on Automatic check a Checkbox, i post a Code than you can test it yourself.

var useOT = Menu_Keys.Add("useOnTick", new CheckBox("Use OnTick (more fps)", false)); useOT.OnValueChange += fire_useOnTick;

var useOU = Menu_Keys.Add("useOnUpdate", new CheckBox("Use OnUpdate (faster reaction)", true)); useOU.OnValueChange += fire_useOnUpdate;

private static void fire_useOnUpdate(ValueBase sender, ValueBase.ValueChangeArgs args) { if (!args.NewValue) return; if (Menu_Keys["useOnTick"].Cast().CurrentValue) Menu_Keys["useOnTick"].Cast().CurrentValue = false; }

private static void fire_useOnTick(ValueBase<bool> sender, ValueBase<bool>.ValueChangeArgs args)
{
  if (!args.NewValue) return;
  if (Menu_Keys["useOnUpdate"].Cast<CheckBox>().CurrentValue)
    Menu_Keys["useOnUpdate"].Cast<CheckBox>().CurrentValue = false;
}

this code above does not Crash

but this here crash the game

private static void fire_useOnUpdate(ValueBase sender, ValueBase.ValueChangeArgs args) { Menu_Keys["useOnTick"].Cast().CurrentValue = !args.NewValue; }

private static void fire_useOnTick(ValueBase<bool> sender, ValueBase<bool>.ValueChangeArgs args)
{
    Menu_Keys["useOnUpdate"].Cast<CheckBox>().CurrentValue = !args.NewValue;
}

greeting Lexxes ( i do not need any Reply here how to fix it ... just for the Developers to Fix it )

Hellsing commented 8 years ago

So you want to blame us for the stack overflow you are creating with your code?

Hellsing commented 8 years ago

For your interest, you are recursivly triggering the value changed event on the two checkboxes which casues then a stack overflow. To solve this you HAVE to check if the other value is active or not in order to prevent this.

LXMedia1 commented 8 years ago

yes, ofc i blame you for that, its not that i created a ... lets say endlessloop

the Problem is that the Game Crash and not throw errors in Console or is it not your goal to make it so that no code can crash a game ?

LXMedia1 commented 8 years ago

like i wrote on first post

( i do not need any Reply here how to fix it ... just for the Developers to Fix it )

LXMedia1 commented 8 years ago

and i mean to fix that it brings the game to crash and not only throw errors in console

Hellsing commented 8 years ago

You do know that you can't handle a Stack Overflow Exception, right?

You cannot catch stack overflow exceptions, because the exception-handling code may require the stack. Instead, when a stack overflow occurs in a normal application, the Common Language Runtime (CLR) terminates the process.

LXMedia1 commented 8 years ago

well you could make a "timer" and not allow a Menuitem to get changed within 100 ms 2 times...

LXMedia1 commented 8 years ago

then its solved without a overflowexeption

Hellsing commented 8 years ago

That would be useless as it's not up to library code to prevent those errors. You can cause a stack overflow with other things aswell, like properties setting itself and so on...

LXMedia1 commented 8 years ago

well ok, then no problem, i just wanted to help, no reason to be salty (like in your first answer)

i was just thinking couse alot guys call elobuddy > Crashbuddy to search now all stuff and report them that you can change this.

Hellsing commented 8 years ago

i do not need any Reply here how to fix it ... just for the Developers to Fix it

I just told you that it's not in our hands to prevent stack overflow exceptions which are caused by the developers that use our SDK. The code in the SDK itself will never cause such an Exception on it's own, so the only the developers using the code in a completly recursive way can fix their mistake

LXMedia1 commented 8 years ago

yes ok, but in fact its a crash, ofc its couse a assembly and a wrong useage, but its possible to make the sdk imune again such errors, that was what i wanted to report, but if you say you not want the sdk to do that that ok, no problem.

Hellsing commented 8 years ago

You can't prevent stack overflows caused by other developers. Fixing this now with a delay check does not make it any better as it's not up to the SDK to check for such things. Also, developers should not release their stuff which they didn't fully test. this means that even if you caused such an exception, the users won't have it as you should have patched it out already

LXMedia1 commented 8 years ago

Yes, i understand your point.