コード例 #1
0
/**
 * The inner exception handler catches crashes/asserts in native C++ code and is the only way to get the correct callstack
 * when running a 64-bit executable. However, XAudio2 doesn't like this and it may result in no sound.
 */
LAUNCH_API int32 GuardedMainWrapper( const TCHAR* CmdLine, HINSTANCE hInInstance, HINSTANCE hPrevInstance, int32 nCmdShow )
{
	int32 ErrorLevel = 0;
	if ( GEnableInnerException )
	{
#if !PLATFORM_SEH_EXCEPTIONS_DISABLED
	 	__try
#endif
		{
			// Run the guarded code.
			ErrorLevel = GuardedMain( CmdLine, hInInstance, hPrevInstance, nCmdShow );
		}
#if !PLATFORM_SEH_EXCEPTIONS_DISABLED
		__except( ReportCrash( GetExceptionInformation() ), EXCEPTION_CONTINUE_SEARCH )
		{
		}
#endif
	}
	else
	{
コード例 #2
0
/**
 * Because crash reporters can crash, too
 */
void CrashReporterCrashHandler(const FGenericCrashContext& GenericContext)
{
	const FLinuxCrashContext& Context = static_cast< const FLinuxCrashContext& >( GenericContext );

	printf("CrashHandler: Signal=%d\n", Context.Signal);
	ReportCrash(Context);
	if (GLog)
	{
		GLog->Flush();
	}
	if (GWarn)
	{
		GWarn->Flush();
	}
	if (GError)
	{
		GError->Flush();
		GError->HandleError();
	}
	FPlatformMisc::RequestExit(true);
}
コード例 #3
0
/**
 * Good enough default crash reporter.
 */
void DefaultCrashHandler(const FLinuxCrashContext & Context)
{
	printf("DefaultCrashHandler: Signal=%d\n", Context.Signal);

	ReportCrash(Context);
	if (GLog)
	{
		GLog->Flush();
	}
	if (GWarn)
	{
		GWarn->Flush();
	}
	if (GError)
	{
		GError->Flush();
		GError->HandleError();
	}

	return GenerateCrashInfoAndLaunchReporter(Context);
}
コード例 #4
0
/**
 * Good enough default crash reporter.
 */
void DefaultCrashHandler(const FLinuxCrashContext & Context)
{
	// Switch to malloc crash.
	//FMallocCrash::Get().SetAsGMalloc(); 

	printf("DefaultCrashHandler: Signal=%d\n", Context.Signal);

	ReportCrash(Context);
	if (GLog)
	{
		GLog->Flush();
	}
	if (GWarn)
	{
		GWarn->Flush();
	}
	if (GError)
	{
		GError->Flush();
		GError->HandleError();
	}

	return GenerateCrashInfoAndLaunchReporter(Context);
}
コード例 #5
0
void CTranscendenceWnd::Animate (bool bTopMost)

//	Animate
//
//	Called on each frame

	{
	bool bFailed = false;
	CG16bitImage &TheScreen = g_pHI->GetScreen();

	try
		{
		SetProgramState(psAnimating);

		//	Do the appropriate thing

		switch (m_State)
			{
			case gsIntro:
				AnimateIntro(bTopMost);
				break;

			case gsProlog:
				AnimateProlog(bTopMost);
				break;

			case gsInGame:
			case gsDestroyed:
				{
				DWORD dwStartTimer;
				if (m_pTC->GetOptionBoolean(CGameSettings::debugVideo))
					dwStartTimer = ::GetTickCount();

				//	Figure out some stats

				bool bBlind = false;
				bool bSRSEnhanced = false;
				bool bShowMapHUD = false;
				CShip *pShip = NULL;
				if (GetPlayer())
					{
					pShip = GetPlayer()->GetShip();
					bBlind = pShip->IsBlind();
					bSRSEnhanced = pShip->IsSRSEnhanced();
					bShowMapHUD = GetPlayer()->IsMapHUDActive();
					}

				//	Update some displays

				if ((m_iTick % 7) == 0)
					{
					SetProgramState(psUpdatingReactorDisplay);
					m_ReactorDisplay.Update();
					SetProgramState(psAnimating);
					}

				//	If we're showing damage flash, fill the screen

				if (m_iDamageFlash > 0 && (m_iDamageFlash % 2) == 0)
					{
					TheScreen.Fill(0, 0, g_cxScreen, g_cyScreen, CG16bitImage::RGBValue(128,0,0));
					if (pShip && pShip->GetSystem())
						{
						if (m_bShowingMap)
							g_pUniverse->PaintObjectMap(TheScreen, m_rcMainScreen, pShip);
						else
							g_pUniverse->PaintObject(TheScreen, m_rcMainScreen, pShip);
						}
					}

				//	Otherwise, if we're in map mode, paint the map

				else if (m_bShowingMap)
					{
					SetProgramState(psPaintingMap);
					PaintMap();
					SetProgramState(psAnimating);
					}

				//	Otherwise, if we're blind, paint scramble

				else if (bBlind 
						&& (m_iTick % (20 + (((m_iTick / 100) * pShip->GetDestiny()) % 100))) > 15)
					PaintSRSSnow();

				//	Otherwise, paint the normal SRS screen

				else
					{
					SetProgramState(psPaintingSRS);
					g_pUniverse->PaintPOV(TheScreen, m_rcMainScreen, bSRSEnhanced);
					SetProgramState(psAnimating);

					PaintMainScreenBorder();
					}

				if (m_iDamageFlash > 0)
					m_iDamageFlash--;

				//	Paint various displays

				SetProgramState(psPaintingLRS);
				PaintLRS();

				if (!m_bShowingMap || bShowMapHUD)
					{
					SetProgramState(psPaintingArmorDisplay);
					m_ArmorDisplay.Paint(TheScreen);

					SetProgramState(psPaintingReactorDisplay);
					m_ReactorDisplay.Paint(TheScreen);

					SetProgramState(psPaintingTargetDisplay);
					m_TargetDisplay.Paint(TheScreen);

					SetProgramState(psPaintingDeviceDisplay);
					m_DeviceDisplay.Paint(TheScreen);
					}

				if (m_CurrentPicker == pickNone)
					{
					SetProgramState(psPaintingMessageDisplay);
					m_MessageDisplay.Paint(TheScreen);
					}

				SetProgramState(psAnimating);

				if (m_CurrentMenu != menuNone)
					m_MenuDisplay.Paint(TheScreen);
				if (m_CurrentPicker != pickNone)
					m_PickerDisplay.Paint(TheScreen);
				if (m_bDebugConsole)
					m_DebugConsole.Paint(TheScreen);

#ifdef DEBUG_LINE_OF_FIRE
				if (GetPlayer())
					{
					if (!GetPlayer()->GetShip()->IsLineOfFireClear(GetPlayer()->GetShip()->GetPos(),
							NULL,
							GetPlayer()->GetShip()->GetRotation()))
						g_pUniverse->DebugOutput("line of fire blocked");
					}
#endif
#ifdef DEBUG
				PaintDebugLines();
#endif

				//	Figure out how long it took to paint

				if (m_pTC->GetOptionBoolean(CGameSettings::debugVideo))
					{
					DWORD dwNow = ::GetTickCount();
					m_iPaintTime[m_iFrameCount % FRAME_RATE_COUNT] = dwNow - dwStartTimer;
					dwStartTimer = dwNow;
					}

				//	Some debug information

				if (m_pTC->GetOptionBoolean(CGameSettings::debugVideo))
					PaintFrameRate();

				//	Update the screen

				if (bTopMost)
					g_pHI->GetScreenMgr().Blt();

				//	Figure out how long it took to blt

				if (m_pTC->GetOptionBoolean(CGameSettings::debugVideo))
					{
					DWORD dwNow = ::GetTickCount();
					m_iBltTime[m_iFrameCount % FRAME_RATE_COUNT] = dwNow - dwStartTimer;
					dwStartTimer = dwNow;
					}

				//	Update the universe

				if (!m_bPaused || m_bPausedStep)
					{
					SetProgramState(psUpdating);
					g_pUniverse->Update(g_SecondsPerUpdate);
					if (m_bAutopilot)
						{
						g_pUniverse->Update(g_SecondsPerUpdate);
						g_pUniverse->Update(g_SecondsPerUpdate);
						g_pUniverse->Update(g_SecondsPerUpdate);
						g_pUniverse->Update(g_SecondsPerUpdate);
						}
					SetProgramState(psAnimating);

					if (GetPlayer())
						GetPlayer()->Update(m_iTick);
					if (GetPlayer() && GetPlayer()->GetSelectedTarget())
						m_TargetDisplay.Invalidate();
					m_iTick++;

					m_bPausedStep = false;
					}

				m_MessageDisplay.Update();

				//	Figure out how long it took to update

				if (m_pTC->GetOptionBoolean(CGameSettings::debugVideo))
					{
					DWORD dwNow = ::GetTickCount();
					m_iUpdateTime[m_iFrameCount % FRAME_RATE_COUNT] = dwNow - dwStartTimer;
					dwStartTimer = dwNow;
					}

				//	Destroyed?

				if (m_State == gsDestroyed)
					{
					if (!m_bPaused || m_bPausedStep)
						{
						if (--m_iCountdown == 0)
							g_pHI->HICommand(CONSTLIT("gameEndDestroyed"));
						m_bPausedStep = false;
						}
					}

				break;
				}

			case gsDocked:
				{
				//	Paint the screen

				m_pCurrentScreen->Paint(TheScreen);
				m_pCurrentScreen->Update();
				PaintMainScreenBorder();
				m_ArmorDisplay.Paint(TheScreen);
				m_TargetDisplay.Paint(TheScreen);

				//	Debug console

				if (m_bDebugConsole)
					m_DebugConsole.Paint(TheScreen);

				//	We don't paint the LRS because the player doesn't need it and
				//	because it overwrites the credits/cargo space display
				//PaintLRS();

				//	Update the screen

				if (bTopMost)
					g_pHI->GetScreenMgr().Blt();

				//	Update the universe (at 1/4 rate)

				if ((m_iTick % 4) == 0)
					g_pUniverse->Update(g_SecondsPerUpdate);
				m_MessageDisplay.Update();
				m_CurrentDock.Update(m_iTick);
				m_iTick++;

				//	Invalidate areas of the screen that are overlapped by
				//	the displays. Note that we need to convert to main screen
				//	coordinates.

				if (m_pCurrentScreen)
					{
					RECT rcRect = m_ArmorDisplay.GetRect();
					::OffsetRect(&rcRect, -m_rcMainScreen.left, -m_rcMainScreen.top);
					m_pCurrentScreen->Invalidate(rcRect);

					rcRect = m_TargetDisplay.GetRect();
					::OffsetRect(&rcRect, -m_rcMainScreen.left, -m_rcMainScreen.top);
					m_pCurrentScreen->Invalidate(rcRect);

					rcRect = m_rcLRS;
					::OffsetRect(&rcRect, -m_rcMainScreen.left, -m_rcMainScreen.top);
					m_pCurrentScreen->Invalidate(rcRect);

					if (m_bDebugConsole)
						{
						rcRect = m_DebugConsole.GetRect();
						::OffsetRect(&rcRect, -m_rcMainScreen.left, -m_rcMainScreen.top);
						m_pCurrentScreen->Invalidate(rcRect);
						}
					}

				break;
				}

			case gsEnteringStargate:
				{
				//	Update some displays

				if ((m_iTick % 10) == 0)
					m_ReactorDisplay.Update();

				//	Tell the universe to paint

				g_pUniverse->PaintPOV(TheScreen, m_rcMainScreen, false);
				PaintMainScreenBorder();
				PaintLRS();
				m_ArmorDisplay.Paint(TheScreen);
				m_MessageDisplay.Paint(TheScreen);
				m_ReactorDisplay.Paint(TheScreen);
				m_TargetDisplay.Paint(TheScreen);
				m_DeviceDisplay.Paint(TheScreen);

				//	Debug information

				if (m_pTC->GetOptionBoolean(CGameSettings::debugVideo))
					PaintFrameRate();

#ifdef DEBUG
				PaintDebugLines();
#endif

				//	Update the screen

				if (bTopMost)
					g_pHI->GetScreenMgr().Blt();

				//	Update the universe

				g_pUniverse->Update(g_SecondsPerUpdate);
				m_MessageDisplay.Update();
				m_iTick++;

				if (--m_iCountdown == 0)
					EnterStargate();
				break;
				}

			case gsLeavingStargate:
				{
				//	Update some displays

				if ((m_iTick % 10) == 0)
					m_ReactorDisplay.Update();

				//	Tell the universe to paint

				g_pUniverse->PaintPOV(TheScreen, m_rcMainScreen, false);
				PaintMainScreenBorder();
				PaintLRS();
				m_ArmorDisplay.Paint(TheScreen);
				m_MessageDisplay.Paint(TheScreen);
				m_ReactorDisplay.Paint(TheScreen);
				m_TargetDisplay.Paint(TheScreen);
				m_DeviceDisplay.Paint(TheScreen);

				//	Debug information

				if (m_pTC->GetOptionBoolean(CGameSettings::debugVideo))
					PaintFrameRate();

#ifdef DEBUG
				PaintDebugLines();
#endif

				//	Update the screen

				if (bTopMost)
					g_pHI->GetScreenMgr().Blt();

				//	Update the universe

				g_pUniverse->Update(g_SecondsPerUpdate);
				m_MessageDisplay.Update();
				m_iTick++;

				if (--m_iCountdown == 0)
					LeaveStargate();
				break;
				}
			}

		//	Flip

		if (bTopMost)
			g_pHI->GetScreenMgr().Flip();

		SetProgramState(psUnknown);
		}
	catch (...)
		{
		bFailed = true;
		}

	//	Deal with errors/crashes

	if (bFailed)
		{
		g_pHI->GetScreenMgr().StopDX();
		ReportCrash();
		}
	}