Game::Run is loop of main thread, while ChangeState is (when necessary) called by other, boost::thread. When this program crashes, the boost::thread is at line this->NewState = NewState;, while main thread is sleeping (Window->display())
If I switch Thread in debugger to the thread calling the ChangeState, I notice that this pointer is invalid (0xcdcdcdcd)... and thats why I get access violation error, but if I switch back to main thread, the this pointer is stil valid (pointing somewhere randomly)...
That thread called Game::ChangeState from this code:
1 2 3 4 5 6 7 8 9
void WorldSession::HandleLoginOpcode()
{
// bla bla ....
World* pWorld = new World(MeID);
this->pWorld = pWorld;
pWorld->LoadTileMap(MapID);
sGame->ChangeState(pWorld);
printf("Packet is good!\n");
}
And the sGame pointer here is still valid pointer...
Please add
pWorld->LoadTileMap(MapID);
std::cout << sGame << std::endl; // new line
sGame->ChangeState(pWorld);
If it invalid, possible that your program try to access to deleted pointer when exit on some exception.
Or possible that you have different sGame on WorldSession.cpp, main.cpp (may be dll-exe linking)...
There is no such thing as boost::singleton (at least in my version). There are few in /detail/ but seem to be only for internal usage.
I use MSVC++ 2010.
That outputs CDCDCDCD.
There is no dll linking, WorldSession is in exe... Nor it was possible that it got deleted, as I said, main thread is usually sleeping in Window->display(); (which is actually where it spends 99.99% of time) when it crashes
Even better, you could git clone it yourself: (or download zipball)
https://github.com/krofna/Warrior-of-Dreamworld
(NOTE: branch Thread is the bugged one)
Game.cpp:31:12: warning: deleting object of abstract class type ‘GameState’ which has non-virtual destructor will cause undefined behaviour
World.cpp:43:25: warning: deleting object of polymorphic class type ‘WorldObject’ which has non-virtual destructor might cause undefined behaviour
Get used to compile with warnings.
About the includes, some are relatives, other suppose that you include the path in the command.
¿Which version of SFML are you using? By instance, Login fails because there is no sf::Keyboard::Backspace (in 2.0 there is Back, in 1.6 there is no sf::Keyboard)
Done compiling, ¿what do I link against?
talked too soon, damn sql