Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Crash when Game exits  (Read 2110 times)

0 Members and 1 Guest are viewing this topic.

Krofna

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Crash when Game exits
« on: January 28, 2012, 03:34:24 pm »
After an hour of painfull debugging I have figured out that program will crash ON EXIT if during run-time it enters multiple "main" game loops.
Weird? I know right?

This is my example:

GameLoop calls the Encounter:
Code: [Select]
void Game::GameLoop()
{
    Map Map(Window, World, *this);
    Player Player(Map, LoadFileName);

    while(Window.IsOpened())
    {
        sf::Event Event;
        while(Window.PollEvent(Event))
        {
            if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Escape))
                return;
            else if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Keyboard::Up))
            {
                switch(Player.Move(NORTH))
                {
//...
                case 2:
                    Encounter(Map, Player, NORTH);
                    break;
                }
            }
//...
        }
        Window.Clear();
        DrawAll(Map, Player);
        Window.Display();
    }
}


Then Encounter creates Combat object and enters new loop:

Code: [Select]
void Game::Encounter(Map &map, Player &player, Orientation Direction)
{
    switch(Direction)
    {
    case NORTH:
        switch(player.InteractsWith)
        {
        case ENEMY:
            for(auto itr = Enemies.begin(); itr != Enemies.end(); itr++)
            {
                if(itr->GetX() == player.GetX()/32 && itr->GetY() == player.GetY()/32-1)
                {
                    Combat Combat(Window, player, *itr);
                    switch(Combat.MainLoop())
                    {
//...
                    }
                    return;
                }
            }
            break;
//...
        }
        break;
//...
}
}


Then in Combat::MainLoop() stuff happens:

Code: [Select]
int Combat::MainLoop()
{
    //...
    while(window.IsOpened())
    {
        while(window.PollEvent(Event))
        {
             //...
        }
        window.Clear();
        //...
        window.Display();
    }
}


Now. For sake of debugging, I put the return; right before while(window.PollEvent(Event)), and program did not crash upon game exit. Also, if i put return on next line, it will crash on exit.

These are crash "details":
Quote
Problem signature:
  Problem Event Name:   APPCRASH
  Application Name:   2D Krofna Game Project.exe
  Application Version:   0.0.0.0
  Application Timestamp:   4f240720
  Fault Module Name:   atioglxx.dll
  Fault Module Version:   6.14.10.11318
  Fault Module Timestamp:   4ebb3dc2
  Exception Code:   c0000005
  Exception Offset:   0086c161
  OS Version:   6.1.7600.2.0.0.256.1
  Locale ID:   1050
  Additional Information 1:   0a9e
  Additional Information 2:   0a9e372d3b4ad19135b953a78882e789
  Additional Information 3:   0a9e
  Additional Information 4:   0a9e372d3b4ad19135b953a78882e789



Any idea why this happens?

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Crash when Game exits
« Reply #1 on: January 28, 2012, 05:48:15 pm »
Can you supply info on which SFML version you are using, and confirm you use an ATI graphics card? (atioglxx.dll suggests you do.......)
SFML 2.1

Krofna

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Crash when Game exits
« Reply #2 on: January 28, 2012, 08:38:42 pm »
Quote from: "slotdev"
Can you supply info on which SFML version you are using, and confirm you use an ATI graphics card? (atioglxx.dll suggests you do.......)


I am using ~2 weeks old SFML 2.0.
Yes, I use ATI Sapphire Radeon HD 6850

slotdev

  • Sr. Member
  • ****
  • Posts: 385
    • View Profile
Crash when Game exits
« Reply #3 on: January 29, 2012, 10:12:21 pm »
OK.

There is a known issue with dynamically linked SFML and ATI cards, so static link to SFML and it should resolve it. If you search the forums for "ATI bug" you will find a lot more info.

Good Luck!
SFML 2.1