游戏开发论坛

 找回密码
 立即注册
搜索
查看: 7212|回复: 8

各位!真正的入口在launcher_main和launcher目录里面的!!

[复制链接]

8

主题

60

帖子

60

积分

注册会员

Rank: 2

积分
60
发表于 2003-10-4 22:16:00 | 显示全部楼层 |阅读模式
真正的入口在launcher_main和launcher目录里面的!!

static bool LoadAppSystems( )
{
        // Start up the file system
        FileSystem_LoadFileSystemModule();
        if (!FileSystem_Init( ))
                return false;

        // Load up the material system
        s_hMatSystemModule = FileSystem_LoadModule("materialsystem.dll");
        if (!s_hMatSystemModule)
        {
                Error( "Unable to load materialsystem.dll" );
                return false;
        }

        s_MaterialSystemFactory = Sys_GetFactory(s_hMatSystemModule);
        if (!s_MaterialSystemFactory)
        {
                Error( "Unable to get materialsystem factory" );
                return false;
        }

        // Load up the engine
        s_hEngineModule = FileSystem_LoadModule( "engine.dll" );
        if ( !s_hEngineModule )
        {
                Error( "Unable to load engine.dll" );
                return false;
        }

        s_EngineFactory = Sys_GetFactory( s_hEngineModule );
        if ( !s_EngineFactory )
        {
                Error( "Unable to get engine factory" );
                return false;
        }

        // Load up vgui2
        s_hVGuiModule = FileSystem_LoadModule( "vgui2.dll" );
        if ( !s_hVGuiModule )
        {
                Error( "Unable to load vgui2.dll" );
                return false;
        }

        s_VGuiFactory = Sys_GetFactory( s_hVGuiModule );
        if ( !s_VGuiFactory )
        {
                Error( "Unable to get vgui2 factory" );
                return false;
        }

        // Load up the mat system surface
        s_hVguiMatSurfaceModule = FileSystem_LoadModule("vguimatsurface.dll");
        if (!s_hVguiMatSurfaceModule)
        {
                Error( "Unable to load vguimatsurface.dll" );
                return false;
        }

        s_VGuiMatSurfaceFactory = Sys_GetFactory(s_hVguiMatSurfaceModule);
        if (!s_VGuiMatSurfaceFactory)
        {
                Error( "Unable to get vguimatsurface factory" );
                return false;
        }

        return true;
}

加载个个模块DLL的代码!

8

主题

60

帖子

60

积分

注册会员

Rank: 2

积分
60
 楼主| 发表于 2003-10-4 22:22:00 | 显示全部楼层

Re:各位!真正的入口在launcher_main和launcher目录里面的!!

倒……
\src_main\launcher_main
main.cpp
自己看看去!!

23

主题

53

帖子

53

积分

注册会员

Rank: 2

积分
53
发表于 2003-10-4 22:41:00 | 显示全部楼层

Re: 嗯嗯,同意RanderBoy的看法。

大家可以留意一下luncher_main里的vc porject文件。里面有以下的build cmd
BuildCmds= \
        if exist ..\..\hl2.exe attrib -r ..\..\hl2.exe \
        copy $(TargetPath) ..\..\hl2.exe \
        if exist ..\..\tf2.exe attrib -r ..\..\tf2.exe \
        copy $(TargetPath) ..\..\tf2.exe \
        if exist $(TargetDir)\launcher_main.map copy $(TargetDir)\launcher_main.map ..\..\tf2.map \
        if exist $(TargetDir)\launcher_main.map copy $(TargetDir)\launcher_main.map ..\..\hl2.map \
        attrib -r ..\..\tf2.dat \
        attrib -r ..\..\hl2.dat \
        ..\..\bin\newdat ..\..\tf2.exe \
        ..\..\bin\newdat ..\..\hl2.exe \

由这部分编译指令看出是程序的入口,但是这个程序只不过是调用了luncher.dll来启动游戏的引擎。还需要更深入分析IGame接口才行。

由此看来,IGame是游戏程序的接口,IApplication是游戏相关工具程序的接口,大家可以留意一下Vmtedit.cpp (src_main\utils\vmtedit),Vmtedit应该游戏的附带工具,所以实现了IApplication,通过DEFINE_APPLICATION_OBJECT_GLOBALVAR宏定义了__g_pApplicationObject。看来HL2的Mod真是达到了比较大的重用。

16

主题

76

帖子

105

积分

注册会员

Rank: 2

积分
105
发表于 2003-10-4 23:01:00 | 显示全部楼层

Re:各位!真正的入口在launcher_main和launcher目录里面的!!

oh s***
?]看清楚啊~~~

16

主题

76

帖子

105

积分

注册会员

Rank: 2

积分
105
发表于 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;
}


8

主题

60

帖子

60

积分

注册会员

Rank: 2

积分
60
 楼主| 发表于 2003-10-4 23:11:00 | 显示全部楼层

Re:各位!真正的入口在launcher_main和launcher目录里面的!!

呵呵~~顺藤摸瓜!找到
核心ENGINE的入口!!
sys_dll.cpp-------------------------Win32 system interface code
这个里面有DLLMAIN。还有初始化内存。载入物理模块。还有个Sys_InitGame, Sys_ShutdownGame
呵呵~~在顺这这个文件找。不出几天。核心结构估计就能摸清楚了。

4

主题

26

帖子

27

积分

注册会员

Rank: 2

积分
27
发表于 2003-10-4 23:23:00 | 显示全部楼层

Re:各位!真正的入口在launcher_main和launcher目录里面的!!

哈!没错,我也是刚才在编译那些文件的时候发现的!我已经编译出hl2.exe的文件了!不过肯定少一些东西,出现了异常,所以不得已只能中止!!唉!

8

主题

60

帖子

60

积分

注册会员

Rank: 2

积分
60
 楼主| 发表于 2003-10-4 23:37:00 | 显示全部楼层

Re:各位!真正的入口在launcher_main和launcher目录里面的!!

楼上的兄弟。
我这里,无论怎样都没能编译成功。不知道为什么
能写个你的配置吗?
如果你用批处理文件,那给个你机器的环境变量吧!

4

主题

26

帖子

27

积分

注册会员

Rank: 2

积分
27
发表于 2003-10-5 00:16:00 | 显示全部楼层

Re:各位!真正的入口在launcher_main和launcher目录里面的!!

我没有用批处理文件作,我也不太会改他的%MSDEV%这个环境变量!
我就是直接生成文件的!lancher_main的时候升成了hl2.exe文件,哈!
我的机器配置吗?!p4 2.4 512ddr333 80G 这有关系吗!?
我用的是xp pro的!vs.net 2002+简体中文.net freamwork 1.1
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2024-5-20 10:13

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表