Esempio n. 1
0
void InitializeHacks()
{
	CtrlDetours_ClientCommand(true);
	CtrlDetours_BuyCommands(true);
	CtrlDetours_Natives(true);

	InitGlobalVars();
}
ULONG Init(VOID)
#endif
{
    /* Add ExitProc to the exit list to handle the exit processing.  If
     * there is an error, then terminate the process since there have
     * not been any resources allocated yet
     */
   if (DosExitList(EXLST_ADD, (PFNEXITLIST)ExitProc))
   {
       MessageBox(HWND_DESKTOP,
                  IDMSG_CANNOTLOADEXITLIST, 0,
                  MB_OK | MB_ERROR,
                  TRUE);
       DosExit(EXIT_PROCESS, RETURN_ERROR);
   }

   /* load application name from resource file */
   if(0==WinLoadString(vhab, (HMODULE)NULL, IDS_APPNAME, CCHAPPNAME, szAppName))
       return IDMSG_CANNOTLOADSTRING;

   /* register the main client window class */
   if (!WinRegisterClass(vhab,
                szAppName,
                (PFNWP)MainWndProc,
                0L,
                0))
       return IDMSG_INITFAILED;

   /*
    * create main application window & detach scrollbars
    */
   if (!InitMainWindow())
       return IDMSG_MAINWINCREATEFAILED;

   /*
    * set up globals used for sizing & system pointers
    */
   if (!InitGlobalVars())
      return IDMSG_INITFAILED;

   /*
    * this function prepares the application for loading images
    */
   InitClientArea(vhwndClient);

   /*
    * initialize help mechanism
    */
#ifdef HELP_MANAGER_ENABLED
   HelpInit();
#endif

   return NO_ERROR;
}  /* End of Init */
Esempio n. 3
0
BOOL Init3DEngine(unsigned uMode, unsigned int uFlag, HWND hBaseWindow, HWND hRenderWindow, BSTR strEnginePath, BSTR strStartUpPath)
{
	ATLTRACE("#####################3DEngine Initializing!##################\r\n");

	BOOL bRetCode = false;
	KGLOG_PARAM LogParam;
	char szCWD[MAX_PATH];
	getcwd(szCWD, sizeof(szCWD));
	memset(&LogParam, 0, sizeof(LogParam));
	snprintf(LogParam.szPath,sizeof(LogParam.szPath),"%s\\logs",szCWD);
	LogParam.szPath[sizeof(LogParam.szPath) - 1] = '\0';

	strcpy(LogParam.szIdent, "AtlaxKG3D");
	LogParam.nMaxLineEachFile = 65536;
	LogParam.Options = (KGLOG_OPTIONS)KGLOG_OPTION_FILE;
	bRetCode = KGLogInit(LogParam, NULL);
	if (!bRetCode)
	{
		::MessageBox(NULL, "Log文件初始化失败!", NULL, NULL);
		return FALSE;
	}

	TCHAR szCurDir[MAX_PATH];
	sprintf(szCurDir, BSTR_TO_STRING(strStartUpPath));
	strcat(szCurDir, "/3DProxy/");
	g_SetRootPath(szCurDir);
	SetCurrentDirectory(szCurDir);

	KGLogPrintf(KGLOG_DEBUG, "strStartUpPath=%s", BSTR_TO_STRING(strStartUpPath));
	
#ifdef _DEBUG
	strcat(szCurDir, "KG3DEngineD.dll");
#else
	strcat(szCurDir, "KG3DEngine.dll");
#endif
	g_3dEngineDll.Init(szCurDir);
	KGLogPrintf(KGLOG_DEBUG, "%s loaddll成功", szCurDir);

	g_SetRootPath(BSTR_TO_STRING(strEnginePath)); // in Engine_lua5(D).dll
	lstrcpy(g_EnginePath, BSTR_TO_STRING(strEnginePath));
	SetCurrentDirectory(BSTR_TO_STRING(strEnginePath));
	lstrcpy(g_szDefWorkDirectory, g_EnginePath);

	HMODULE h = g_3dEngineDll.GetDllHandle();
	_ASSERTE(h);
	if (!h) return FALSE;
	
	KGLogPrintf(KGLOG_DEBUG, "g_3dEngineDll loaddll成功");	

	if (lstrlen(g_EnginePath) <= 0)
	{
		HMODULE hDll = GetModuleHandle("atlax.dll");
		if (hDll)
		{
			KGLogPrintf(KGLOG_DEBUG, "atlax.dll loaddll成功");
			TCHAR szBuf[MAX_PATH + 1];
			GetModuleFileName(hDll, szBuf, MAX_PATH);
			CString strTemp = szBuf;
			CString strDir = strTemp.Left(strTemp.ReverseFind('\\'));
			SetCurrentDirectory(strDir);
		}
	}
	else //
	{
		SetCurrentDirectory(g_EnginePath);
	}

	typedef HRESULT (*pfnGet3DEngineInterface)(void** pEngineManager);
	pfnGet3DEngineInterface Get3DEngineInterface = (pfnGet3DEngineInterface)GetProcAddress(h, "Get3DEngineInterface");
	_ASSERTE(Get3DEngineInterface);
	if (!Get3DEngineInterface) return FALSE;

	IEKG3DEngineManager* pInterface = NULL;
	HRESULT hret = Get3DEngineInterface((void**)&pInterface);
	if (FAILED(hret))
		return FALSE;
	else
	{
		KGLogPrintf(KGLOG_DEBUG, "pre pInterface->Init");

        if (FAILED(pInterface->Init(uMode, uFlag, hBaseWindow, hRenderWindow)))
        {
            return FALSE;
        }

        pInterface->SetAutoReloadTexture(TRUE);

		InitGlobalVars(pInterface);
		ATLTRACE("=================3DEngine Initialized!==================\r\n");
		return TRUE;
	}
}
Esempio n. 4
0
BOOL Init3DEngine(unsigned uMode, unsigned int uFlag, HWND hBaseWindow, HWND hRenderWindow, BSTR strEnginePath, BSTR strStartUpPath)
{
	ATLTRACE("#####################3DEngine Initializing!##################\r\n");
	
	TCHAR szCurDir[MAX_PATH];
	sprintf(szCurDir, BSTR_TO_STRING(strStartUpPath));
	//strcat(szCurDir, "/3DProxy/");
	//g_SetRootPath(szCurDir);
	//SetCurrentDirectory(szCurDir);
	
#ifdef _DEBUG
	strcat(szCurDir, "KG3DEngineD.dll");
#else
	strcat(szCurDir, "KG3DEngine.dll");
#endif
	g_3dEngineDll.Init(szCurDir);

	g_SetRootPath(BSTR_TO_STRING(strEnginePath)); // in Engine_lua5(D).dll
	lstrcpy(g_EnginePath, BSTR_TO_STRING(strEnginePath));
	SetCurrentDirectory(BSTR_TO_STRING(strEnginePath));
	lstrcpy(g_szDefWorkDirectory, g_EnginePath);

	HMODULE h = g_3dEngineDll.GetDllHandle();
	_ASSERTE(h);
	if (!h) return FALSE;
	
	if (lstrlen(g_EnginePath) <= 0)
	{
		HMODULE hDll = GetModuleHandle("atlax.dll");
		if (hDll)
		{
			TCHAR szBuf[MAX_PATH + 1];
			GetModuleFileName(hDll, szBuf, MAX_PATH);
			CString strTemp = szBuf;
			CString strDir = strTemp.Left(strTemp.ReverseFind('\\'));
			SetCurrentDirectory(strDir);
		}
	}
	else //
	{
		SetCurrentDirectory(g_EnginePath);
	}

	typedef HRESULT (*pfnGet3DEngineInterface)(void** pEngineManager);
	pfnGet3DEngineInterface Get3DEngineInterface = (pfnGet3DEngineInterface)GetProcAddress(h, "Get3DEngineInterface");
	_ASSERTE(Get3DEngineInterface);
	if (!Get3DEngineInterface) return FALSE;

	IEKG3DEngineManager* pInterface = NULL;
	HRESULT hret = Get3DEngineInterface((void**)&pInterface);
	if (FAILED(hret))
		return FALSE;
	else
	{
        if (FAILED(pInterface->Init(uMode, uFlag, hBaseWindow, hRenderWindow)))
        {
            return FALSE;
        }

        pInterface->SetAutoReloadTexture(TRUE);

		InitGlobalVars(pInterface);
		ATLTRACE("=================3DEngine Initialized!==================\r\n");
		return TRUE;
	}
}