⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dragon.cpp

📁 网络游戏龙族 完整的登陆器 C++ 源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	{	//< CSD-031030
		if (!g_mgrLimit.Load("./data_b5/AbilityLimit.bin"))
		{
			if (!g_mgrLimit.Load("./data/AbilityLimit.bin"))
			{
				MessageBox(NULL,"Loading LimitData Error","Limit Data", NULL);
				return false; 
			}
		}
	}	//> CSD-031030
	else
	{
		if (!g_mgrLimit.Load("./data/AbilityLimit.bin"))
		{
			MessageBox(NULL,"Loading LimitData Error","Limit Data", NULL);
			return false; 
		}
	}
	//> CSD-021015
	if (!InitNation()) 
	{
        MessageBox(NULL,"Loading NationData Error","Nation Data",NULL);
		return false; 
	}
	//________________________________________________________________ // 010904 LTS

#ifdef USE_PROFILER	// 031013 kyo
	g_ProFileMgr.Init();
	g_ProFileMgr.AddCounter("GameProc", "GameProc" );
	g_ProFileMgr.AddCounter("GameProc", "Protocol" );
	g_ProFileMgr.AddCounter("GameProc", "Input" );
#endif 

#ifndef LIGHT_VERSION_
	InitHorseAniTable();		// LTS HORSERIDER
#endif

MAIN_MENU_:

	LoadMenuData( 0 );
	LoadMenuData( 4 );
	StartMenuSetting();      //霸烙阑 矫累窍扁 傈俊 皋春 备炼眉甸阑 檬扁拳  GamePorc() 傈俊 龋免MenuSetting();      //霸烙阑 矫累窍扁 傈俊 皋春 备炼眉甸阑 檬扁拳  GamePorc() 傈俊 龋免
	
	PlayBackMusic( g_hwndMain, 0 );
	
	CursorNo( 1 );

	struct tm *today;
	time_t lTime;
	time( &lTime );
	today = localtime( &lTime );
	//Log( "Packet罐澜.txt", "%02d:%02d  %d", today->tm_min, today->tm_sec, addlen );
	if( today->tm_mon == 11 && ( today->tm_mday == 24 ||  today->tm_mday == 25  ))  
	{
		g_bIsChristmas = true;
	}

	// 0811 NPC KHS
	LoadNPCAccessTable();
	g_FrameMgr.InitTime();
	while( TRUE )
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
		{
			if (!GetMessage(&msg, NULL, 0, 0 )){break;}
			
			// soto-030602 磊侥 措拳惑磊俊. Tab虐甫 冈捞磊.
			if(g_hMultiDlg)
			{
				if ( IsDialogMessage(g_hMultiDlg, &msg) == FALSE )
				{
					TranslateMessage(&msg);
					DispatchMessage(&msg);
				}
			}
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else
		{
#ifdef ALT_TAB_BLOCK
			if (g_DirectDrawInfo.lpDirectDraw==NULL)		// 竣萍宏绰 登菌瘤父 辑其捞胶啊 绝促	// LTS 020725
			{
				SetFocus2(HWND_GAME_MAIN);//021001 lsw
				ShowWindow(g_hwndMain,SW_RESTORE);
				UpdateWindow(g_hwndMain);
			}
#endif
			if( !StartMenuProc( &g_DirectDrawInfo ))
			{
				PostMessage(g_hwndMain, WM_CLOSE, 0, 0);
				goto END_;
			}

			if (QuitFlag == SWD_QUIT || QuitFlag == SWD_LOGON) 
			{
				goto END_;
			}
			if( SMenu[MN_MAININTERFACE].bActive == TRUE ) 
			{
				goto START_GAME_;
			}
		}
	}
	goto END_;		
					
START_GAME_:		
					
	MenuSetting();	
	SendAllReady();	
	// 屏焊扁 历乏篮 扁夯栏肺 焊捞霸 茄促.  0818 khs
	// 010205 KHS
	if( SCharacterData.nLevel < 8 )  ViewTipToggle = 1;
					
	double		StartTime, Duration;
	StartTime = timeGetTime( );
	ListenCommand = CMD_NONE;
	while( 1 )			
	{						
		Duration = timeGetTime( ) - StartTime;	// 5檬甫 扁促赴促. 
		if ( Duration > 1000 )
		{			
			break;	
		}			
					
		if ( ProtocolProc( &connections ) < 0 )	break;
	}				
					
	InitBytesRoutine();	// 
	YouCanHeroActionProc =0; YouCanViewTipsCheck  = 0;

	CLottoMgr::Create();//soto-030501
	g_FrameMgr.InitTime();


	while( TRUE )
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE ))//PM_NOREMOVE
		{
			if (!GetMessage(&msg, NULL, 0, 0 )){break;}
			TranslateMessage(&msg); 
			DispatchMessage(&msg);
		}
		else
		{

#ifdef ALT_TAB_BLOCK
			if (g_DirectDrawInfo.lpDirectDraw==NULL)		// 竣萍宏绰 登菌瘤父 辑其捞胶啊 绝促	// LTS 020725
			{
				SetFocus2(HWND_GAME_MAIN);//021001 lsw
				ShowWindow(g_hwndMain,SW_RESTORE);
				UpdateWindow(g_hwndMain);
			}
#endif
			if (!GameProc(&g_DirectDrawInfo))
			{
				PostMessage(g_hwndMain, WM_CLOSE, 0, 0);
				goto END_;
			}

			if (QuitFlag == SWD_QUIT || QuitFlag == SWD_LOGON) 
			{
				goto GOTO_MAIN_MENU_;			//0201 YGI
			}
		}
	}		


	goto END_;
			
GOTO_MAIN_MENU_:
	ReStartMenu( );
	pMusic->Stop();
	Release( &connections );				// Release()龋免..
	FreeTOI();
	DestroyRoofHeader( &g_RoofHeader );			
	DestroyEventList();							
	FreeMapSource();							
	DestroyItemList();
	FreeCharacterSpriteDataAll( 0, MAX_CHARACTER_SPRITE_ );	
	DestroyCharacterListExceptHero();

	CLottoMgr::Destroy();//soto-030501

	goto MAIN_MENU_;

#ifndef _DEBUG	// 031110 YGI
	}
	__except(pException = GetExceptionInformation())//020508 lsw
	{
		::DumpException( pException, "Exception Raised on WinMain()");		
	}
#endif

END_:
	CloseNation(); // 010904 LTS	//皋牢皋春俊 困摹窍霸 登搁 Closenation捞 拌加龋免等促.. 
									//g_pNation捞 拌加 瘤况柳促. 
	ExitApplication(EA_NORMAL);
	return msg.wParam;
}

ATOM
MyRegisterClass( HINSTANCE hInstance )
{
	WNDCLASSEX	wcex;

	wcex.cbSize			= sizeof( WNDCLASSEX );
	wcex.style			= CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
	wcex.lpfnWndProc	= ( WNDPROC )WndProc;
	wcex.cbClsExtra		= 0;
	wcex.cbWndExtra		= 0;
	wcex.hInstance		= hInstance;
	wcex.hIcon			= LoadIcon( hInstance, ( LPCTSTR )IDI_DRAGON );
	wcex.hCursor		= NULL;// LoadCursor( NULL, IDC_ARROW );
	wcex.hbrBackground	= ( HBRUSH )( COLOR_WINDOW + 1 );
	
	//acer7
	if( SysInfo.enable_menu ) 
	{
		if( SysInfo.notdead )
		{
			wcex.lpszMenuName	= ( LPCSTR )IDC_DRAGON;
		}
		else
		{
			wcex.lpszMenuName	= ( LPCSTR )IDR_GM;
		}
	}
	else 
	{
		wcex.lpszMenuName	= NULL; 
	}

	wcex.lpszClassName	= g_szWindowClass;
	wcex.hIconSm		= LoadIcon( wcex.hInstance, ( LPCTSTR )IDI_SMALL );

	return	RegisterClassEx( &wcex );
}

BOOL
InitInstance( HINSTANCE hInstance, int nCmdShow )
{
	HWND		hWnd;
	int			cx, cy;
	int         nStyle = 0;

	g_hInstance = hInstance;

    cx = SCREEN_WIDTH + GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
    cy = SCREEN_HEIGHT + GetSystemMetrics( SM_CYSIZEFRAME ) * 2 + GetSystemMetrics( SM_CYMENU );


	switch( SysInfo.dx )
	{
		case 0 :	nStyle = WS_OVERLAPPEDWINDOW;	break;
		case 1 :	nStyle = WS_POPUP;		break;
	}

	if( GetSysInfo( SI_GAME_MAKE_MODE ) == 0 )
		if(FindWindow("DRAGONRAJA_CLASS","DragonRaja Online")){ return FALSE; }

	hWnd = CreateWindow( g_szWindowClass,
						 g_szTitle,
						 nStyle,
						 0,0,
						 cx,
						 cy,
						 NULL,
						 NULL,
						 hInstance,
						 NULL );
	if ( !hWnd )
	{
		return	FALSE;
	}
	
	g_hwndMain = hWnd;
	
	ShowWindow( hWnd, nCmdShow );
	UpdateWindow( hWnd );

	return	TRUE;
}	

BOOL
InitApplication( HINSTANCE hInstance, LPSTR lpCmdLine )
{	
	ModeSetting( g_hwndMain, hInstance);
	if( SysInfo.result == 999 ) return FALSE;
	
	MakeSizeofSOU2();	
	
	
	LoadString( hInstance, IDS_APP_TITLE, g_szTitle, MAX_LOADSTRING);
	LoadString( hInstance, IDC_DRAGONRAJA_CLASS, g_szWindowClass, MAX_LOADSTRING );
	MyRegisterClass( hInstance );
	
//	ParseCommandLine( lpCmdLine );
	srand( ::timeGetTime() );
	
	SetCurrentWorkingDirectory();
	SetInfoFile();
	
	if ( !LoadGameInfo( ) )
	{
		return	FALSE;
	}

	pMusic->Stop();

	CoInitialize( NULL );
	if ( !::Initialize() )
	{
		return	FALSE;
	}
	g_pointMouseX = SCREEN_WIDTH / 2;
	g_pointMouseY = SCREEN_HEIGHT / 2;
	g_nLButtonState = g_nRButtonState = g_nOldLButtonState = g_nOldRButtonState = STATE_BUTTON_RELEASED;
	g_nSensitivity = 0;
	
	return	TRUE;
}	

void ExitApplication( const eExitAppType eEAType )
{
	CrackMgr.StopCrackThread();

	SendLogOut();
	GameEndFree();

	::Release( &connections );
	
	EndLoadCharSpriteDataThread();
	DestroyCharacterList( &g_CharacterList );
	CleanupDirectDraw( &g_DirectDrawInfo );
	StopBackMusic( g_hwndMain );
	FreeSfx();
	CoUninitialize( );
	FreeAllOfMenu();		// 0927 YGI
	DeleteAllSkillData();
	pMusic->Stop();
	if(EA_NORMAL != eEAType)
	{
		g_DBGLog.Log(LOG_LV1,"ExitApplication Call(%d)",eEAType);
	}

	if( CheckSumError ) 
	{
		JustMsg( "Found corrupted or tampered files while loading. \nExiting program. [%d]", CheckSumError);
	}

	FreeItemTable();

	delete g_pBill;
	delete lan;

	exit(0);
}
	
void ParseCommandLine( LPSTR lpCmdLine )
{	
	while ( lpCmdLine[ 0 ] == '-' || lpCmdLine[ 0 ] == '/' )
	{
		lpCmdLine++;
	
		switch ( *lpCmdLine++ )
		{
		case	'f':
		case	'F':
			g_DirectDrawInfo.bFullscreen = FALSE; // LTS TEST
			break;
		}
	
		lpCmdLine = EatFrontWhiteChar( lpCmdLine );
	}
}
void SetCurrentWorkingDirectory( void )
{	
	char*	ptr;
	
	GetModuleFileName( g_hInstance, g_szCWD, sizeof( g_szCWD ) );
	ptr = strrchr( g_szCWD, '\\' );
	*ptr = 0;
}

char*
GetCurrentWorkingDirectory( void )
{	
	return	g_szCWD;
}	

void SetInfoFile( void )
{	
	wsprintf( g_szInfoFile, "%s/dragon.ini", g_szCWD );
}	
	
char*
GetInfoFile( void )
{	
	return	g_szInfoFile;
}	
	
char*
EatFrontWhiteChar( char* pStr )
{	
	char*	szWhite = " \t\n\r";
	
    if ( pStr )
    {
		while ( *pStr )
		{
			if ( strchr( szWhite, *pStr ) )
			{
				pStr++;
			}
			else
			{
				break;
			}
		}	
    }
        
    return  pStr;    
}	
	
char*
EatRearWhiteChar( char* pStr )
{	
	char*	szWhite = " \t\n\r";
	char*	pRear;
	
	pRear = pStr + strlen( pStr ) - 1;
	if ( pRear )
	{
		while ( pStr <= pRear )
		{
			if ( strchr( szWhite, *pRear ) )
			{
				*pRear-- = 0;
			}
			else
			{
				break;
			}
		}
	}
	
	return	pStr;
}	
	
BOOL
ShowErrorMessage( char* lpszMessage )
{	
	MessageBox( g_hwndMain, lpszMessage, "Dragon Raja Online", MB_OK );
	return	FALSE;
}	
	
	
	
	

														
///////////////////////////////////////////////////////////////////////////////
// window procedure										
																
void MouseProcess( UINT message, WPARAM wParam, LPARAM lParam)
{	
	int x, y;

	switch( message )										
	{														
	case WM_LBUTTONUP     :	g_nLButtonState = STATE_BUTTON_RELEASED; LButtonDownIng= 0;	tool_MyHouseLBU( wParam, lParam ); ReleaseCapture();				break;
	case WM_LBUTTONDOWN   :	YouCanHeroActionProc = 1; YouCanViewTipsCheck  = 1;g_nLButtonState = STATE_BUTTON_PRESSED;  LButtonDownIng= 1;	tool_MyHouseLBD( wParam, lParam ); SetCapture( g_hwndMain);		break;
	case WM_RBUTTONUP	  :	g_nRButtonState = STATE_BUTTON_RELEASED; RButtonDownIng= 0;	ReleaseCapture();				break;
	case WM_RBUTTONDOWN   :	g_nRButtonState = STATE_BUTTON_PRESSED;	 RButtonDownIng= 1;	SetCapture( g_hwndMain);  		break;
	case WM_LBUTTONDBLCLK :	g_nLDButtonState = STATE_BUTTON_DOUBLECLICK;	SetCapture( g_hwndMain);		break;
	case WM_RBUTTONDBLCLK :	g_nRDButtonState = STATE_BUTTON_DOUBLECLICK;	SetCapture( g_hwndMain);		break;
	}												
							
	x = LOWORD( lParam );
	y = HIWORD( lParam );

#ifdef _DEBUG
	y += ::GetSystemMetrics(SM_CYMENUSIZE);
#endif
	
	if(LButtonDownIng==1 )								
	{															
		g_DragMouse.ex=x+Mapx;	//付快胶狼 拳搁谅钎俊 甘狼 例措 谅钎甫 歹窃
		g_DragMouse.ey=y+Mapy;	
	}


	AdjustSkillMouseCursor( &x, &y );
		
	
	// 泅犁 畴啊促 扁贱阑 窍绰 吝捞搁   付快胶绰 弊 冠胶救俊 乐绢具 茄促. 
	g_pointMouseY = g_pointMouse.y = y;
	g_pointMouseX = g_pointMouse.x = x;
	Mox =  Mapx + g_pointMouseX;		Moy =  Mapy + g_pointMouseY;
	
	/*int		SkillNo;
int		SkillStatus;
Spr	   *SkillIcon;
int		SkillItemNo;			// 扁贱俊 荤侩瞪  Item狼 锅龋.
POS		SkillItemPOS;			// 扁贱俊 荤侩瞪  Item狼 困摹蔼.



bool	SkillMouseDontMoveFlag;	//	畴啊促甫 秦具 窍绰 扁贱篮 茄锅 弊镑阑 急琶窍搁   坷弗率付快胶肺 秒家窍电啊 NogadaCount啊 Max啊 瞪锭鳖瘤 扁促妨具 茄促. 
DWORD	SkillRetryTime;
int		SkillDontMoveSx,SkillDontMoveSy,SkillDontMoveEx,SkillDontMoveEy;
bool	YouCanNogadaFlag;
*/

}															

//1206 zhh

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -