Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (7 posts)

Game crashses if I input on menus too fast...

Last post 1/20/2010 3:59 PM by Morgawr. 6 replies.
  • 1/19/2010 5:16 PM

    Game crashses if I input on menus too fast...

    Hello everyone... I'm having a very annoying problem that I cannot solve...

    I am building an RPG and I am almost done with the battle system (The basics at least).. it's a very "simple" (wasn't so simple to build for me hehe) turn based system and so far it's going great...
    I'm using the GameStateManager from the examples on this website, not modified or anything and it has been working fine for everything in my game... however my game keeps crashing if I enter the commands in my battle menu too fast (it crashes exactly in my second battle after defeating half the enemies in the second battle screen...).. let me explain.

    My battle engine is made this way:

    BattleScreen: Displays all the enemy and party on the screen with cool effects and stuff (lies D: )
    BattleMenu: Pops up a menu after a certain amount of time at the bottom of the BattleScreen with basic Attack - Skill - Run
    BattleList: Pops up a menu over the BattleMenu with the list of the names of the enemies to select after choosing Attack command from the above menu.

    They are linked this way:

    BattleScreen creates BattleMenu that is bound with a MenuEvent to BattleScreen. ->
    BattleMenu creates a BattleList upon choosing "Attack" from the menu and BattleList is bound to BattleMenu with a MenuEvent. ->
    BattleList exits after choosing an enemy, returning the MenuEvent to BattleMenu with the details of the enemy chosen etc etc. ->
    BattleMenu receives the event from BattleList and exits, returning a new MenuEvent to BattleScreen with the details of Attack chosen and Enemy selected etc etc ->
    BattleScreen loops through the attack after having received the command from the MenuEvent and then restarts the cycle, popping up again BattleMenu after a set amount of time.

    This is all managed through the GameStateManager engine, everytime a screen exits (everytime I select an action in the popup menus for example) I invoke the event and call this.ExitScreen() on the screen.

    So far, so good.. it works perfectly and, in my opinion, is a pretty versatile way of doing things (it works for skills as well, it just sends a Skill detail in the MenuEvent).. however if I'm just button mashing A on the controller to finish the battle asap (something that EVERYONE does) it works well for the first battle, but exactly after killing the 2nd enemy in the 2nd battle screen (there are 3 enemies everytime in my battles, just a test) the game crashes. It crashes exactly at the same point everytime, and only if I button mash... if I go slowly it works.

    I'm suspecting the game cannot call ExitScreen fast enough for the GameStateManager to remove it before parsing another input of the controller.. the exception I get is an ArgumentOutOfBounds exception at the Screen.Update() loop of the ScreenManager. I tried to manually force the removal calling directly this.ScreenManager.Remove(this) in every sub-menu, but still it crashes... I'd have a lot of code to post and I'd rather not,  but please, help me out... any supposition of why the game does so?
  • 1/19/2010 5:45 PM In reply to

    Re: Game crashses if I input on menus too fast...

    Well, ArgumentOutOfBounds means that the index into an array or list was either less than 0 or greater than the number of elements in the array/list. When the exception comes up can you roll your mouse over the variables and see what the debugger tells you their values are? Or add an if-statement to check to see if the index to the array/list is outside its bounds and put a breakpoint in there.

    The best you can do, really, is just trace your execution path and try to figure out where the logic is getting thrown off. Maybe it's storing an index in the array/list but then an item is removed from the array/list and it attempts to use the previously stored index even though it is no longer valid.
  • 1/19/2010 5:48 PM In reply to

    Re: Game crashses if I input on menus too fast...

    Kainsin:
    Well, ArgumentOutOfBounds means that the index into an array or list was either less than 0 or greater than the number of elements in the array/list. When the exception comes up can you roll your mouse over the variables and see what the debugger tells you their values are? Or add an if-statement to check to see if the index to the array/list is outside its bounds and put a breakpoint in there.

    The best you can do, really, is just trace your execution path and try to figure out where the logic is getting thrown off. Maybe it's storing an index in the array/list but then an item is removed from the array/list and it attempts to use the previously stored index even though it is no longer valid.


    That's what I thought too.. I can use the debugger and I've used it before, but this time it seems a .dll exception... I mean, I get msclib.dll (or something like that) and when I check the line where it crashes, there is no error whatsoever.. it doesnt' say "it crashed here" it just selects the Update method (in green, usually it's yellow in a breakpoint in VS) and says "Oops... System.ArgumentOutOfBoundException at msclib.dll" or something like that.

    I checked the screen collection (the only collection I can think of) but there is nothing "out of bounds"...
  • 1/19/2010 5:57 PM In reply to

    Re: Game crashses if I input on menus too fast...

    Just out of curiosity, in all of your screens are you wrapping all input in a "if(IsActive)" statement? I remember having some odd behavior with trying to remove the screen more than once like that, since the screen continues to update while it's transitioning off.
  • 1/19/2010 9:59 PM In reply to

    Re: Game crashses if I input on menus too fast...

    UberGeekGames:
    Just out of curiosity, in all of your screens are you wrapping all input in a "if(IsActive)" statement? I remember having some odd behavior with trying to remove the screen more than once like that, since the screen continues to update while it's transitioning off.


    I was almost sure you hit the spot there, however it's not the case... I realized the ScreenManager already handles the fact that if the screen is not active it doesn't call the HandleInput function.. only the Update one...

    I'm still as before, still the game crashes and I don't know wtf is happening...


    EDIT:

    Wow now I feel retarded... I noticed I had checked the x86 target box under compile, the build was compiling for x86 but the deployment was to the 360, so I was still running an old build, any changes I made had no effect... I'll try again and see if I can change something FOR REAL now.. anyhow, still no other possible ideas why this is happening? D:
  • 1/20/2010 1:45 PM In reply to

    Re: Game crashses if I input on menus too fast...

    It sounds like you need to add some exception handling and handle button mashing better. :) I could see a problem with button mashing after the last enemy is killed and the screens are transitioning, but there shouldn't be a problem with the 2nd or 3. Of course, without actually seeing the code involved it's almost impossible to offer any more useful advice.
  • 1/20/2010 3:59 PM In reply to

    Re: Game crashses if I input on menus too fast...

    Answer
    Reply Quote
    Jim Perry:
    It sounds like you need to add some exception handling and handle button mashing better. :) I could see a problem with button mashing after the last enemy is killed and the screens are transitioning, but there shouldn't be a problem with the 2nd or 3. Of course, without actually seeing the code involved it's almost impossible to offer any more useful advice.



    Yeah, thanks for the tips... I was able to finally fix this problem... it was really annoying.

    After finding out that I wasn't deploying the right project to the xbox (since it was set on x86 >_____>), I was able to put my hands on the REAL crashing project... and the exception changed... this time it brought me to the correct line of the problem and the solution was pretty clear.

    My problem was that I had added 2 players to my party so they should've, theoretically, taken turns to attack, however I didn't finish setting up the battle system for multiple characters in the party and their turns were overlapping... hence while the enemies died, the second player attacked an already disposed enemy causing the game to crash.

    Now I removed it and will re-add the multiple characters in party feature after I finish all the preparations for the Engine.

    Thanks for the suggestions anyways guys ;)
Page 1 of 1 (7 posts) Previous Discussion Next Discussion