|
发表于 2003-10-4 23:05:00
|
显示全部楼层
Re:各位!真正的入口在launcher_main和launcher目录里面的!!
//-----------------------------------------------------------------------------
// Purpose: The real entry point for the application
// Input : hInstance -
// hPrevInstance -
// lpCmdLine -
// nCmdShow -
// Output : int APIENTRY
//-----------------------------------------------------------------------------
extern "C" __declspec(dllexport) int LauncherMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow )
{
// Register myself as the primary thread.
//Plat_RegisterPrimaryThread();
// Hook the debug output stuff.
SpewOutputFunc( LauncherDefaultSpewFunc );
// Quickly check the hardware key, essentially a warning shot.
if( !Plat_VerifyHardwareKeyPrompt() )
{
return -1;
}
// Start VCR mode?
const char *filename;
CommandLine()->CreateCmdLine( g_pVCR->Hook_GetCommandLine() );
if( CommandLine()->CheckParm( "-vcrrecord", &filename ) )
{
if ( !g_pVCR->Start( filename, true, &g_VCRHelpers ) )
{
Error( "-vcrrecord: can't open '%s' for writing.\n", filename );
return -1;
}
}
else if( CommandLine()->CheckParm( "-vcrplayback", &filename ) )
{
if ( !g_pVCR->Start( filename, false, &g_VCRHelpers ) )
{
Error( "-vcrplayback: can't open '%s' for reading.\n", filename );
return -1;
}
}
// initialize winsock
WSAData wsaData;
int nReturnCode = ::WSAStartup( MAKEWORD(2,0), &wsaData );
registry->Init();
CommandLine()->CreateCmdLine( g_pVCR->Hook_GetCommandLine() );
UTIL_GetBaseAndGameDir( GetBaseDirectory(), GetGameDirectory() );
// Set default game directory
if ( !CommandLine()->CheckParm( "-defaultgamedir" ) )
{
CommandLine()->AppendParm( "-defaultgamedir", GetGameDirectory() );
}
bool memdump = CommandLine()->CheckParm( "-leakcheck" ) ? true : false;
_chdir( GetBaseDirectory() );
bool restart = true;
while ( restart )
{
// Set engine string (from registry or command line override),
// remove -gl, -d3d, etc. from command line and write current value
// into registry
restart = false;
if ( LoadAppSystems() )
{
// NOTE: This is sort of a hack required because we're running hl2/hl2.exe
// instead of running directly from the bin directory
g_pFileSystem->RemoveSearchPath( NULL, "EXECUTABLE_PATH" );
g_pFileSystem->AddSearchPath( UTIL_GetExecutableDir(), "EXECUTABLE_PATH" );
if ( InitAppSystems( (void *)hInstance ) )
{
#if 1 // #ifdef LAUNCHER_LOADS_ENGINE_AS_DLL
// running in debug mode, load engine via normal interface
IEngineAPI *engineAPI = ( IEngineAPI * )LauncherFactory( VENGINE_LAUNCHER_API_VERSION, NULL );
if ( engineAPI )
{
restart = engineAPI->Run( ( void * )hInstance, GetBaseDirectory(), LauncherFactory );
}
#else
// blob unload information
BlobFootprint_t g_blobfootprintClient;
// running securely, load blob'd engine
IEngineAPI *engineAPI = NULL;
NLoadBlobFile(enginedll, &g_blobfootprintClient, &engineAPI, FALSE);
if (engineAPI)
{
// Unmount and remount the filesystem as the engine will mount it on its own.
restart = engineAPI->Run( ( void * )hInstance, UTIL_GetBaseDir(), (char *)CommandLine()->GetCmdLine(), Sys_GetFactoryThis() );
}
// free the blob
FreeBlob(&g_blobfootprintClient);
#endif // LAUNCHER_LOADS_ENGINE_AS_DLL
ShutdownAppSystems();
}
UnloadAppSystems();
}
// Remove any overrides in case settings changed
CommandLine()->RemoveParm( "-sw" );
CommandLine()->RemoveParm( "-startwindowed" );
CommandLine()->RemoveParm( "-windowed" );
CommandLine()->RemoveParm( "-window" );
CommandLine()->RemoveParm( "-full" );
CommandLine()->RemoveParm( "-fullscreen" );
};
registry->Shutdown();
// shutdown winsock
::WSACleanup();
if ( memdump )
{
g_pMemAlloc->DumpStats();
}
return 0;
}
|
|