예제 #1
0
CDPClientArray::Connect( CServerDesc *pServer )
{
	CMclAutoLock Lock( m_AddRemoveLock );
	CServerDescArray::iterator i = m_apServer.find( pServer->GetKey() );
	if( i == m_apServer.end() )
	{
		CDPClient* pClient;
		if( m_pFirstFree == NULL ) {
			pClient		= new CDPClient;
		}
		else {
			pClient		= m_pFirstFree;
			m_pFirstFree	= m_pFirstFree->pNext;
		}
		pClient->m_pServer	= pServer;
		g_MyTrace.Add( pServer->GetKey(), TRUE, "%04d", pServer->GetKey() );
		if( pClient->CreateDPObject( FALSE ) && pClient->InitConnection( (LPVOID)pServer->m_szAddr, PN_WORLDSRVR + (u_short)pServer->GetKey() ) && pClient->JoinSession( NULL ) )
		{
			bool bResult	= m_apServer.insert( CServerDescArray::value_type( pServer->GetKey(), pServer ) ).second;
			ASSERT( bResult );
			Add( pClient );
			g_MyTrace.Add( pServer->GetKey(), FALSE, "%04d", pServer->GetKey() );
			return TRUE;
		}
		SAFE_DELETE( pClient );
	}
	return FALSE;
}
예제 #2
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HWND hWnd;

	hInst = hInstance; // Store instance handle in our global variable

	hMainWnd	= hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
	  CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

	if (!hWnd)
		return FALSE;

	SetTimer( hMainWnd, 3, SEC( 60 ), NULL );	// 10(s)

	int x = 480, y = 606;
	SetWindowPos( hWnd, NULL, x, y, 400, 416, SWP_SHOWWINDOW );

	g_MyTrace.Initialize( hWnd, "SquireD", RGB( 0x00, 0x00, 0x00 ), RGB( 0xff, 0xff, 0xff ) );

	CTime time	= CTime::GetCurrentTime();
	g_MyTrace.Add( 0, FALSE, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) );
	g_MyTrace.AddLine( '\0' );

#ifndef _DEBUG
//   InitEH();
#endif	// _DEBUG

	if( !Script( "CacheServer.ini" ) )
		return FALSE;

	if( InitializeNetLib() == FALSE )
		return FALSE;

	if( !g_DPCoreClient.ConnectToServer( g_szCoreAddr, PN_CORESRVR + 1 ) )
		return FALSE;
	
#ifdef __CRC
	if( !g_DPCacheSrvr.StartServer( g_uPort, FALSE, CSock::crcRead ) )
#else	// __CRC
	if( !g_DPCacheSrvr.StartServer( g_uPort ) )
#endif	// __CRC
		return FALSE;


	g_MyTrace.AddLine( '-' );
	char lpszIpAddr[16];
	g_DPCoreClient.GetPlayerAddr( DPID_SERVERPLAYER, lpszIpAddr );

	g_MyTrace.Add( CMyTrace::Key( "main" ), FALSE, "%s", lpszIpAddr );
	g_MyTrace.AddLine( '-' );

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}
예제 #3
0
void CDPCoreClient::SysMessageHandler( LPDPMSG_GENERIC lpMsg, DWORD dwMsgSize, DPID idFrom )
{
	switch( lpMsg->dwType )
	{
		case DPSYS_DESTROYPLAYERORGROUP:
			{
				g_MyTrace.Add( CMyTrace::Key( "main" ), TRUE, "destroy player or group." );
				break;
			}
	}
}
예제 #4
0
파일: user.cpp 프로젝트: iceberry/flyffsf
BOOL CUserMng::RemoveUser( DPID dpid )
{
	CMclAutoLock	Lock( m_AddRemoveLock );
	map<DPID, CUser*>::iterator i	= find( dpid );
	if( i != end() )
	{
		CUser* pRemoved		= i->second;
		SAFE_DELETE( pRemoved );
		erase( dpid );
#ifdef _DEBUG
	g_MyTrace.Add( CMyTrace::Key( "count" ), FALSE, "// %04d", size() );
#endif	// _DEBUG
		return TRUE;
	}
	WriteError( "REMOVE//0" );
	return FALSE;
}
예제 #5
0
파일: user.cpp 프로젝트: iceberry/flyffsf
BOOL CUserMng::AddUser( DPID dpid )
{
	CUser* pUser	= new CUser( dpid );

	CMclAutoLock	Lock( m_AddRemoveLock );

	bool bResult	= insert( map<DPID, CUser*>::value_type( dpid, pUser ) ).second;
	if( bResult == false )
	{
		WriteError( "ADD//0" );
		SAFE_DELETE( pUser );
		return FALSE;
	}
#ifdef _DEBUG
	g_MyTrace.Add( CMyTrace::Key( "count" ), FALSE, "// %04d", size() );
#endif	// _DEBUG
	return TRUE;
}
예제 #6
0
BOOL CDPClientArray::Remove( CDPClient* pClient )
{
	CPlayerMng::Instance()->DestroyPlayer( pClient );
	CDPClient *pCur, *pPrev		= NULL;
	CMclAutoLock Lock( m_AddRemoveLock );

	pCur	= m_pFirstActive;
	while( pCur )
		{
		if( pCur == pClient )
		{
			if( pPrev ) {
				pPrev->pNext	= pCur->pNext;
			}
			else {
				m_pFirstActive	= m_pFirstActive->pNext;
			}

			CServerDescArray::iterator i	= m_apServer.find( pClient->m_pServer->GetKey() );
			if( i != m_apServer.end() )
			{
				m_apServer.erase( pClient->m_pServer->GetKey() );
				g_MyTrace.Add( pClient->m_pServer->GetKey(), TRUE, "%04d", pClient->m_pServer->GetKey() );
				SAFE_DELETE( pClient->m_pServer );
			}

			pClient->pNext	= m_pFirstFree;
			m_pFirstFree	= pClient;

			return TRUE;
		}
		pPrev	= pCur;
		pCur		= pCur->pNext;
	}
	return FALSE;
}
예제 #7
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
#ifndef _DEBUG
//   InitEH();
#endif	// _DEBUG

#ifdef __BILLING0712
	if( ::CreateBillingMgr() == FALSE )		// CreateWindow전에 호출되어야 한다.
		return FALSE;
#endif

	HWND hWnd;
	hInst = hInstance; // Store instance handle in our global variable
	hMainWnd = hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);	
	if( !hWnd )
		return FALSE;
	
	HMENU hMenu		= GetMenu( hWnd );
	CheckMenuItem( hMenu, IDM_OPT_INTERNAL, MF_CHECKED );
	EnableMenuItem( hMenu, IDM_OPT_INTERNAL, MF_DISABLED | MF_GRAYED );
	g_dpSrvr.m_bCheckAddr	= true;

	int x = 400, y = 416;
	SetWindowPos( hWnd, NULL, x, y, 400, 416, SWP_SHOWWINDOW );

	LOAD_WS2_32_DLL;

	::srand( timeGetTime() );

	// Script함수의 호출순서가 중요하다. (menu -> script -> createdbworker)
	if( Script( "AccountServer.ini" ) == FALSE )	
		return FALSE;

#ifdef __SECURITY_0628
	LoadResAuth( "Flyff.b" );
#endif	// __SECURITY_0628

//	if( CQuery::EnableConnectionPooling() )
//		OutputDebugString( "EnableConnectionPooling\n" );

	g_DbManager.CreateDbWorkers();
	
	if( g_dpSrvr.LoadAddrPmttd( "pmttd.ini" ) == false )
	{
		TRACE("LoadAddrPmttd false\n");
	}	
	
	if( g_dpSrvr.LoadIPCut( "IPCut.ini" ) == FALSE )
	{
		TRACE( "LoadIPCut FALSE\n" );
	}
	
	g_MyTrace.Initialize( hWnd, "SquireD", RGB( 0x00, 0x00, 0x00 ), RGB( 0xff, 0xff, 0xff ) );
	CTime time	= CTime::GetCurrentTime();
	g_MyTrace.Add( 0, FALSE, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) );
	g_MyTrace.AddLine( '\0' );
	
	if( FALSE == g_dpSrvr.StartServer( PN_ACCOUNTSRVR_0 )
		|| FALSE == g_dpDbSrvr.StartServer( PN_ACCOUNTSRVR_1 )
		|| FALSE == CDPAdbill::GetInstance()->StartServer( PN_ADBILL )
		/*
#ifdef __GIFTBOX0213
		|| FALSE == CDPWldSrvr::GetInstance()->StartServer( PN_ACCOUNTSRVR_2 )
#endif	// __GIFTBOX0213
		*/
		 )
	{
		AfxMessageBox( "Unable to start server" );
		return FALSE;
	}

#ifdef __BILLING0712
	if( GetBillingMgr()->Init( hWnd ) == false )
		return FALSE;
#endif

	SetTimer( hWnd, IDT_SENDPLAYERCOUNT, 1000 * 60, NULL );
	SetTimer( hWnd, IDT_TIME_CHECKADDR, 1000 * 30, NULL );
	if( ::GetLanguage() == LANG_THA )
		SetTimer( hWnd, IDT_PREVENT_EXCESS, 1000 * 60, NULL );

/*
#ifdef __S0114_RELOADPRO
	SetTimer( hWnd, IDT_RELOAD_PROJECT, 1000 * 30, NULL );
#endif // __S0114_RELOADPRO
*/
	SetTimer( hWnd, IDT_BUYING_INFO, 500, NULL );

	if( FALSE == g_DbManager.AllOff() )
		return FALSE;

	ShowWindow(hWnd, nCmdShow);
	UpdateWindow(hWnd);	
	return TRUE;
}
예제 #8
0
BOOL Script( LPCSTR lpszFileName )
{
	CScanner s;
	CServerDesc* pServer;
	POINT topLeft;
	SIZE	size;

	if( s.Load( lpszFileName ) )
	{
		g_MyTrace.AddLine( '-' );

		s.GetToken();

		while( s.tok != FINISHED )
		{
			if( s.Token == "Sys" )
			{
				g_dwSys	= s.GetNumber();
			}
			else if( s.Token ==  "dwId" )
			{
				g_dwId = s.GetNumber();
			}
			else if( s.Token == "Database" )
			{
				s.GetToken();
				strcpy( szDataBaseAddr, s.Token );
			}
			else if( s.Token == "Certifier" )
			{
				s.GetToken();
				strcpy( szCertifierAddr, s.Token );
			}
			else if( s.Token == "TEST" )
			{
				s_bTest	= TRUE;			
			}
			else if( s.Token == "PartyExpRate" )
			{
				s_fPartyExpRate		= s.GetFloat();
			}
			else
			{
				pServer		= new CServerDesc;
				u_long uKey	= (u_long)_ttoi( s.Token );
				pServer->SetKey( uKey );

				if( s.GetToken() == DELIMITER )
				{
					while( s.GetToken() != DELIMITER )
					{
						CJurisdiction* pJurisdiction	= new CJurisdiction;
						pJurisdiction->m_dwWorldID	= (DWORD)_ttoi( s.Token );
						topLeft.x	= s.GetNumber();	topLeft.y	= s.GetNumber();
						size.cx		= s.GetNumber();	size.cy		= s.GetNumber();
						pJurisdiction->m_rect.SetRect( topLeft.x, topLeft.y, topLeft.x + size.cx, topLeft.y + size.cy );
						pJurisdiction->m_wLeft	= s.GetNumber();	pJurisdiction->m_wRight		= s.GetNumber();
						pServer->m_lspJurisdiction.push_back( pJurisdiction );
					}
				}
		#ifdef __STL_0402
				bool bResult	= g_dpCoreSrvr.m_apSleepServer.insert( CServerDescArray::value_type( pServer->GetKey(), pServer ) ).second;
				ASSERT( bResult );
		#else	// __STL_0402
				g_dpCoreSrvr.m_apSleepServer.SetAt( pServer->GetKey(), pServer );
		#endif	// __STL_0402
				g_MyTrace.Add( pServer->GetKey(), TRUE, "%04d", pServer->GetKey() );
			}
			s.GetToken();
		}
		g_MyTrace.AddLine( '-' );

		return TRUE;
	}

	Error( "Can't open file, %s.\n", lpszFileName );
	return FALSE;
}
예제 #9
0
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
	HWND hWnd;

   hInst = hInstance; // Store instance handle in our global variable

	hMainWnd	= hWnd	=
		CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);

   if (!hWnd)
   {
      return FALSE;
   }

	int x = 0, y = 416;
	SetWindowPos( hWnd, NULL, x, y, 400, 416, SWP_SHOWWINDOW );

	g_GameTimer.Compute();
	SetTimer( hWnd, TIMER_ID_DEFAULT, 1000, NULL );

#if !defined(__INTERNALSERVER)
	SetTimer( hWnd, TIMER_ID_WANTED, g_uWantedElapse, NULL );
#endif

#ifdef __EVENT0913
	SetTimer( hWnd, TIMER_ID_EVENT0913, 1000, NULL );
#endif	// __EVENT0913
#ifdef __EVENT1206
	SetTimer( hWnd, TIMER_ID_EVENT1206, 1000 * 60, NULL );
#endif	// __EVENT1206

	SetTimer( hWnd, TIMER_ID_EVENT, 1000 * 60, NULL );

	g_MyTrace.Initialize( hWnd, "SquireD", RGB( 0xff, 0xff, 0xff ), RGB( 0x00, 0x00, 0x00 ) );

	CTime time	= CTime::GetCurrentTime();
	g_MyTrace.Add( 0, FALSE, "%s", time.Format( "%Y/%m/%d %H:%M:%S" ) );
	g_MyTrace.AddLine( '\0' );

#ifndef _DEBUG
//	InitEH();
#endif	// _DEBUG

	g_TickCount.Start();

	if( !Script( "CoreServer.ini" ) )
	{
		return FALSE;
	}
	
	if( InitializeNetLib() == FALSE )
		return FALSE;

	if( !g_dpCoreSrvr.StartServer( PN_CORESRVR + 0 ) )
		return FALSE;

	if( !g_DPCacheSrvr.StartServer( PN_CORESRVR + 1 ) )
		return FALSE;

	if( !g_dpLoginSrvr.StartServer( PN_CORESRVR + 2 ) )
		return FALSE;

	if( !g_dpDatabaseClient.ConnectToServer( szDataBaseAddr, PN_DBSRVR_2, FALSE ) )
	{
		Error( "Not TransServer Connect" );
		return FALSE;
	}

	if( !g_PartyMng.CreateWorkers() )
	{
		assert( 0 );
	}

#ifdef __ENVIRONMENT_EFFECT
	if( CEnvironment::GetInstance()->CreateWorkers() == FALSE )
	{
		assert( 0 );
	}
#else // __ENVIRONMENT_EFFECT
	if( !g_Environment.CreateWorkers() )
	{
		assert( 0 );
	}
#endif // __ENVIRONMENT_EFFECT

   ShowWindow(hWnd, nCmdShow);
   UpdateWindow(hWnd);

   return TRUE;
}