Though now that I have decided to do things right, I am getting the error below from my debugger when trying to step through the application. Without the debugger, it will simply end the program without a crash warning when the user confirms quiting to the menu.
I am at a true loss here of what I can do to resolve this problem I have found myself into. When sorting through all the pointers in the debugger, they all seem to be as they should, no empty pointers where they should be filled. If someone has a spare moment or three, I would very much appreciate it if you could look over the code below and tell me where I have gone awry. Thank you all in advanceUnhandled exception at 0x30c2ee88 in project_Debug.exe: 0xC0000005: Access violation reading location 0x30c2ee88.
//---
In CCore::run method, on the while line.
Code: Select all
// Event method.
bool CPlayState::processEvents(irr::SEvent hEvent)
{
// Process all key input.
if(hEvent.EventType == irr::EET_KEY_INPUT_EVENT)
{
// Switch through key input.
switch(hEvent.KeyInput.Key)
{
case irr::KEY_KEY_Q:
getCore()->getDevice()->getCursorControl()->setVisible(true);
if(bWindowVisible == false)
{
pWindowExit = getCore()->getGui()->addMessageBox(L"Exit?",L"Really exit current game?",true,irr::gui::EMBF_YES | irr::gui::EMBF_NO);
bWindowVisible = true;
}
break;
default:
break;
}
}
// Process all gui events.
if(hEvent.EventType == irr::EET_GUI_EVENT)
{
// Switch through gui events.
switch(hEvent.GUIEvent.EventType)
{
case irr::gui::EGET_MESSAGEBOX_YES:
// Clear the scene manager and gui environment.
getCore()->getSceneManager()->clear();
getCore()->getGui()->clear();
// Stop all playing audio.
getCore()->getAudio()->stopAllSounds();
// Change the current scene.
getCore()->getStateManager()->setCurrentState("Menu");
break;
case irr::gui::EGET_MESSAGEBOX_NO:
// Reset gui environment back to normal.
bWindowVisible = false;
getCore()->getDevice()->getCursorControl()->setVisible(false);
break;
default:
break;
}
}
return false;
}
Code: Select all
// Update method.
void CCore::run()
{
while(pVideo != NULL && pDevice->run())
{
// Get the delta time.
float fUpdateNow = pDevice->getTimer()->getTime();
float fUpdateLast = 0;
float fUpdateDelta = ((fUpdateNow - fUpdateLast) / 1000.0f);
// Update the current state.
if(pStateMgr->getCurrentState() != NULL)
pStateMgr->getCurrentState()->update(fUpdateDelta);
// Update the devices.
if(pVideo->beginScene(true,true,irr::video::SColor(0,100,100,100)) != false)
{
pSceneMgr->drawAll();
pGui->drawAll();
pVideo->endScene();
}
// Update the time.
fUpdateLast = fUpdateNow;
}
}