示例#1
0
文件: Arena.cpp 项目: careysky/FlyFF
//--------------------Database Operations----------------------
BOOL CArena::Load( void )
{
	CQuery* pQuery = new CQuery;
	if( pQuery->Connect( 3, "Character01", "", "" ) == FALSE )
	{
		pQuery->DisConnect();
		SAFE_DELETE( pQuery );
		return FALSE;
	}

	if( pQuery->Exec( "SELECT * FROM dbo.ARENA" ) == FALSE )
	{
		pQuery->DisConnect();
		SAFE_DELETE( pQuery );
		return FALSE;
	}

	while( pQuery->Fetch() )
	{
		char szQryName[MAX_NAME] = { 0, };
		ARENAPLAYER dbPlayer;

		u_long idPlayer				= static_cast<u_long>( pQuery->GetInt64( "m_idPlayer" ) );

		dbPlayer.nKill				= static_cast<u_int>( pQuery->GetInt64( "m_nKill" ) );
		dbPlayer.nDeath				= static_cast<u_int>( pQuery->GetInt64( "m_nDeath" ) );
		dbPlayer.nRow				= static_cast<u_int>( pQuery->GetInt64( "m_nRow" ) );
		dbPlayer.nJob				= static_cast<u_int>( pQuery->GetInt64( "m_nJob" ) );
		dbPlayer.nDeathMatchWin		= static_cast<u_int>( pQuery->GetInt64( "m_nDeathMatchWin" ) );
		dbPlayer.nDeathMatchLose	= static_cast<u_int>( pQuery->GetInt64( "m_nDeathMatchLose" ) );
		dbPlayer.nDuelWin			= static_cast<u_int>( pQuery->GetInt64( "m_nDuelWin" ) );
		dbPlayer.nDuelLose			= static_cast<u_int>( pQuery->GetInt64( "m_nDuelLose" ) );
		dbPlayer.n64ArenaPoint		=					  pQuery->GetInt64( "m_nArenaPoint" );
						
					pQuery->GetStr( "m_szName", szQryName );
		dbPlayer.szName				=  CString( szQryName );

		m_mArenaMap.insert( make_pair( idPlayer, dbPlayer ) );
	}

	pQuery->DisConnect();
	SAFE_DELETE( pQuery );
	return TRUE;
}
示例#2
0
void ReqSummonPetInfo(LPBMSG_REQSUMMONINFO lpMsg,int aIndex)
{
char szQuery[256];
char szName[MAX_IDSTRING+1] = {0};

	memcpy(szName,lpMsg->szName,MAX_IDSTRING);

	g_Window.ServerLogAdd(ST_EVENTSERVER,"[SUMMON PET] Data request (%s)",szName);

	PBMSG_ANSSUMMONINFO pMsg;

	pMsg.h.c = 0xC1;
	pMsg.h.size = sizeof( pMsg );
	pMsg.h.headcode = 0x66;
	pMsg.h.subcode = 0;

	pMsg.aIndex = lpMsg->aIndex;
	strcpy(pMsg.szName,szName);

	pMsg.result = FALSE;

	sprintf(szQuery,"SELECT summon_level, summon_exp FROM T_SummonPet_Info WHERE memb__char = '%s'",szName);

	if( g_MyEventDB.Exec(szQuery) == TRUE )
	{
		pMsg.result = TRUE;

		pMsg.Level = 0;
		pMsg.Exp = 0;

		if( g_MyEventDB.Fetch() != SQL_NO_DATA )
		{
			pMsg.Level = g_MyEventDB.GetInt("summon_level");
			pMsg.Exp = g_MyEventDB.GetInt64("summon_exp");
		}
		else
		{
			g_MyEventDB.Clear();

			sprintf(szQuery,"INSERT INTO T_SummonPet_Info (memb__char,summon_level,summon_exp) VALUES ('%s',1,0)",szName);
			g_MyEventDB.Exec(szQuery);
		}
	}
	g_MyEventDB.Clear();

	DataSend(aIndex,(LPBYTE)&pMsg,sizeof( pMsg ));
}
示例#3
0
void CHousingDBCtrl::LoadHousingInfo( DWORD dwPlayerId, DPID dpId )
{
    CHousing* pHousing = CHousingMng::GetInstance()->GetHousing( dwPlayerId );
    if( !pHousing )
    {
        pHousing = CHousingMng::GetInstance()->CreateHousing( dwPlayerId );
        if( !pHousing )	// 생성 실패시 그냥 리턴..
            return;

        // DB 로딩...
        CQuery* pQuery = GetQueryObject();
        if( pQuery->Execute( "usp_Housing_Load '%02d', '%07d'", g_appInfo.dwSys, dwPlayerId ) )
        {
            while( pQuery->Fetch() )
            {
                HOUSINGINFO housingInfo;
                housingInfo.dwItemId = static_cast<DWORD>( pQuery->GetInt( "ItemIndex" ) );
                housingInfo.tKeepTime = static_cast<time_t>( pQuery->GetInt64( "tKeepTime" ) );
                housingInfo.bSetup = static_cast<BOOL>( pQuery->GetInt( "bSetup" ) );
                housingInfo.vPos.x = pQuery->GetFloat( "x_Pos" );
                housingInfo.vPos.y = pQuery->GetFloat( "y_Pos" );
                housingInfo.vPos.z = pQuery->GetFloat( "z_Pos" );
                housingInfo.fAngle = pQuery->GetFloat( "fAngle" );

                ItemProp* pItemProp = prj.GetItemProp( housingInfo.dwItemId );
                if( pItemProp && pItemProp->dwItemKind1 == IK1_HOUSING )
                    pHousing->SetFurnitureList( housingInfo, TRUE );
            }

            if( pQuery->MoreResults() )
            {
                while( pQuery->Fetch() )
                    pHousing->SetVisitAllow( pQuery->GetInt( "f_idPlayer" ), TRUE );
            }
        }
    }

    // 하우징 정보를 월드서버에 전달...
    CDPTrans::GetInstance()->SendHousingLoadInfo( dwPlayerId, pHousing, dpId );
}