Exemple #1
0
KRLTarget::~KRLTarget()
{
	ASSERT(m_nRLForceRelation == RL_FORCE_RELATION_INVALID);

	for (size_t nIndex = 0; nIndex < RL_FORCE_RELATION_COUNT; ++nIndex)
		KGLOG_CHECK_ERROR(m_ap3DModel[nIndex] == NULL);
	KGLOG_CHECK_ERROR(m_pRLScene == NULL);
}
Exemple #2
0
void KAIBase::OnIdle(void)
{
	BOOL bRetCode	= FALSE;

	bRetCode = CheckAttacked();
	KG_PROCESS_SUCCESS(bRetCode);

	bRetCode = CheckTargetInAlertRange();
	KG_PROCESS_SUCCESS(bRetCode);

	bRetCode = CheckTargetInAttackRange();
	KG_PROCESS_SUCCESS(bRetCode);

	KGLOG_PROCESS_ERROR(m_pSelf);
	
	if (g_pSO3World->m_nGameLoop >= m_IdleData.nIdleFrameCount)
	{
		//根据之前的状态恢复工作
		switch(m_eAIMainState)
		{
        case aisInvalid:
            KGLOG_CHECK_ERROR(!"Invalid main state!");
            break;
		case aisIdle:
			//当Npc站立的时候,调整Npc的方向
			if (m_pSelf->m_eMoveState == cmsOnStand 
				&& m_pSelf->m_nFaceDirection != m_nOriginDirection) 
			{
				bRetCode = m_pSelf->Turn(m_nOriginDirection, true, true);
				KGLOG_PROCESS_ERROR(bRetCode);
			}
			break;
		case aisWander:
			DoWander();
			break;
		case aisPatrol:
			DoPatrol();
			break;
		case aisFollow:
			DoFollow();
			break;
		default:
			KGLOG_CHECK_ERROR(FALSE);
			DoIdle();
			break;
		}

		return;
	}
Exit1:
	return;
Exit0:
	return;
}
Exemple #3
0
int KRLRemoteCharacter::UpdateDisplayData(BOOL bForceUpdate)
{
    int nRetCode = false;
    int nResult = false;
    HRESULT hr = E_FAIL;
    KRLCharacterEquipResource EquipResource;
    KRLCharacterDisplayData RLCharacterDisplayData;

    nRetCode = m_RLCharacter.PauseAnimationStatus(&RLCharacterDisplayData);
    KGLOG_CHECK_ERROR(nRetCode);

    nRetCode = m_FrameData.UpdateCurrentRepresentFrameData(true, m_FrameData.GetCurrentPosition());
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = GetCharacterModel(&g_pRL->m_ResourceLimit, 
        m_FrameData.m_pCharacter, &EquipResource);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.UpdateModel(EquipResource, bForceUpdate);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_FrameData.Interpolate(m_RLCharacter.m_RenderData.IsVisible(), true);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.UpdateVehicle(m_FrameData.m_Current.nVehicleTrack, TRUE);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = UpdatePosition(TRUE);
    KGLOG_PROCESS_ERROR(nRetCode);
    
	nRetCode = UpdateYaw(NULL);
	KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = UpdateDirection(bForceUpdate);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.UpdateBalloon();
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.UpdateTitleMark();
    KGLOG_PROCESS_ERROR(nRetCode);

    UpdateSkillBuff();

    UpdateLifeState(TRUE);

    nRetCode = m_RLCharacter.ResumeAnimationStatus(&RLCharacterDisplayData);
    KGLOG_CHECK_ERROR(nRetCode);

    nResult = true;
Exit0:
    return nResult;
}
Exemple #4
0
int KRLLocalCharacter::UpdateDisplayData(BOOL bForceUpdate)
{
    int nRetCode = false;
    int nResult = false;
    HRESULT hr = E_FAIL;
    KRLCharacterEquipResource EquipResource;
    KRLCharacterDisplayData RLCharacterDisplayData;

    nRetCode = m_RLCharacter.PauseAnimationStatus(&RLCharacterDisplayData);
    KGLOG_CHECK_ERROR(nRetCode);

    nRetCode = m_RLCharacter.m_FrameData.UpdateCurrentRepresentFrameData(true);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.m_FrameData.Interpolate(m_RLCharacter.m_RenderData.IsVisible(), true);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = UpdatePosition();
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = UpdateDirection();
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = GetCharacterModel(m_RLCharacter.m_FrameData.m_pCharacter, &EquipResource);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.UpdateModel(EquipResource, bForceUpdate);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.UpdateVehicle(m_RLCharacter.m_FrameData.m_Current.nVehicleTrack, TRUE);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.ResumeAnimationStatus(&RLCharacterDisplayData);
    KGLOG_CHECK_ERROR(nRetCode);

    nRetCode = m_RLCharacter.UpdateBalloon();
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = m_RLCharacter.UpdateTitleMark();
    KGLOG_PROCESS_ERROR(nRetCode);

    UpdateSkillBuff();

    m_bSheath = m_RLCharacter.m_FrameData.m_Current.bSheathFlag;
    m_RLCharacter.UpdateWeaponSocketPosition(m_bSheath);

    nResult = true;
Exit0:
    return nResult;
}
Exemple #5
0
void KGWin32App::Exit()
{
    int nRetCode = false;

    OnExit();

    if (m_hWnd)
    {
        nRetCode = DestroyWindow(m_hWnd);
        KGLOG_CHECK_ERROR(nRetCode);

        m_hWnd = NULL;
    }

    ExitClass();

    for (int nIndex = 0; nIndex < EVENT_TOTAL; ++nIndex)
    {
        if (m_Events[nIndex])
        {
            CloseHandle(m_Events[nIndex]);
            m_Events[nIndex] = NULL;
        }
    }

    m_hInstance = NULL;
    m_szTitle[0] = '\0';
}
Exemple #6
0
int KGWin32App::InitWindow()
{
    int nRetCode = false;
    int nResult = false;

    m_hWnd = CreateWindowExA(
        0,
        m_szClass, 
        m_szTitle,
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
        NULL, 
        NULL, 
        NULL, 
        NULL);
    KGLOG_PROCESS_ERROR(m_hWnd);

    nRetCode = UpdateWindow(m_hWnd);
    KGLOG_PROCESS_ERROR(nRetCode);

    nResult = true;
Exit0:
    if (!nResult)
    {
        if (m_hWnd)
        {
            nRetCode = DestroyWindow(m_hWnd);
            KGLOG_CHECK_ERROR(nRetCode);

            m_hWnd = NULL;
        }
    }
    return nResult;
}
void KGPostRenderTestingMgr::UnInit()
{
	int nRetCode = false;
	HRESULT hrRetCode = E_FAIL;

	for (size_t i = 0; i < m_vecTestCases.size(); i++)
	{
		if (m_vecTestCases[i])
		{
			m_vecTestCases[i]->UnInit();
			SAFE_DELETE(m_vecTestCases[i]);
		}
	}
	m_vecTestCases.clear();
	m_vecEffectType.clear();
	m_vecTestFrame.clear();

 	if (m_pEngineMgr)
 	{	
 		hrRetCode = m_pEngineMgr->UnInit();
 		KGLOG_COM_CHECK_ERROR(hrRetCode);
 		m_pEngineMgr = NULL;
 	}
	if (m_hEngineDLL)
	{
		nRetCode = FreeLibrary(m_hEngineDLL);
		KGLOG_CHECK_ERROR(nRetCode);
		m_hEngineDLL = NULL;
	}
	if (m_bKMemoryInited)
	{
		KMemory::Finalize();
		m_bKMemoryInited = false;
	}
}
Exemple #8
0
BOOL KAIBase::UnInit(void)
{
	BOOL bRetCode = FALSE;

#ifdef _SERVER
	KNpc* pNpc = NULL;

	if (IS_NPC(m_pSelf->m_dwID))
	{
		pNpc = (KNpc*)(m_pSelf);
	}
			
	if (m_pNpcTeam && pNpc)
	{
		bRetCode = m_pNpcTeam->RemoveMember(pNpc->m_nNpcTeamIndex);
		KGLOG_CHECK_ERROR(bRetCode);
	}
	

#endif //_SERVER

	bRetCode = TRUE;
Exit0:
	return bRetCode;
}
int PrefetchCharacterPositionData(KRLCharacterPositionData* pData, KCharacter* pCharacter, int nGameLoop)
{
    int nRetCode = false;
    int nResult = false;
    IKGSO3WorldClient* pSO3WorldClient = NULL;
    KPOSITION_RECORD PositionRecord;

    pSO3WorldClient = g_pRL->m_pSO3WorldClient;
    KGLOG_PROCESS_ERROR(pSO3WorldClient);

    KGLOG_PROCESS_ERROR(pCharacter);

    nRetCode = pSO3WorldClient->BeginForwardCharacterPosition(pCharacter, &PositionRecord);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = pSO3WorldClient->ForwardCharacterPosition(pCharacter, nGameLoop);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = GetCharacterPositionData(pData, pCharacter);
    KGLOG_PROCESS_ERROR(nRetCode);

    nResult = true;
Exit0:
    if (pSO3WorldClient && pCharacter)
    {
        nRetCode = pSO3WorldClient->EndForwardCharacterPosition(pCharacter, &PositionRecord);
        KGLOG_CHECK_ERROR(nRetCode);
    }
    return nResult;
}
Exemple #10
0
void KRLSkillEffectResult::KSkillEffectResultData::InvokeResult(DWORD dwCasterID, DWORD dwTargetID, float fPercent)
{
    int nRetCode = false;
    IKSO3GameWorldUIHandler* pGameWorldUIHandler = NULL;

    pGameWorldUIHandler = g_pRL->m_pGameWorldUIHandler;
    KGLOG_PROCESS_ERROR(pGameWorldUIHandler);

    if (fPercent > m_fPercent)
        fPercent = m_fPercent;

    m_fPercent -= fPercent;

    if (dwTargetID != RL_STUB_TARGET_ID)
    {
        KRLCharacter* pRLCharacter = GetRLCharacter(dwTargetID);
        if (pRLCharacter)
        {
            nRetCode = PlaySkillEffectResult(pRLCharacter, &m_Result);
            KGLOG_CHECK_ERROR(nRetCode);
        }

        BOOL bLastPercent = abs(m_fPercent) <= FLT_EPSILON;

        for (int nType = 0; nType < serTotal; ++nType)
        {
            if (m_Result.aSkillResultValue[nType] == 0)
                continue;

            int nValue = bLastPercent ? m_aValue[nType] : (int)((float)m_Result.aSkillResultValue[nType] * fPercent);

            m_aValue[nType] -= nValue;

            ASSERT(m_aValue[nType] >= 0);

            if (nValue != 0)
            {
                KUIEventSkillEffectText SkillEffectText;

                SkillEffectText.dwCasterID = dwCasterID;
                SkillEffectText.dwTargetID = dwTargetID;
                SkillEffectText.dwSkillID = m_Result.dwSkillID;
                SkillEffectText.dwSkillLevel = m_Result.dwSkillLevel;
                SkillEffectText.nType = nType;
                SkillEffectText.bCriticalStrike = m_Result.bCriticalStrike;
                SkillEffectText.nValue = nValue;

                pGameWorldUIHandler->OnSkillEffectText(SkillEffectText);
            }
        }
    }

Exit0:
    return;
}
BOOL KPlayerServer::ProcessNewConnection(IKG_SocketStream* piSocket)
{
    BOOL            bResult         = false;
    int             nRetCode        = 0;
    int             nConnIndex      = -1;
    u_short         uRemotePort     = 0;
    const char*     pcszIP          = NULL;
    struct in_addr  RemoteIP;
	KSOCKET_STREAM_BODY* 	pSocketBody = NULL;
	INT 					nNagle = 1;

    assert(piSocket);

    nRetCode = m_ConnectionDataListFreeVector.empty();
    KGLOG_PROCESS_ERROR(!nRetCode);

    nRetCode = piSocket->GetRemoteAddress(&RemoteIP, &uRemotePort);
    KGLOG_PROCESS_ERROR(nRetCode);

    pcszIP = inet_ntoa(RemoteIP);
    KGLOG_PROCESS_ERROR(pcszIP);

    nConnIndex = m_ConnectionDataListFreeVector.back();
    m_ConnectionDataListFreeVector.pop_back();

    assert(nConnIndex >= 0 && nConnIndex < m_nMaxConnection);

    nRetCode = piSocket->SetUserData((void*)(ptrdiff_t)nConnIndex);
    KGLOG_PROCESS_ERROR(nRetCode);

	pSocketBody = (KSOCKET_STREAM_BODY*)piSocket;
	nRetCode = setsockopt(pSocketBody->m_nSocketHandle, IPPROTO_TCP, TCP_NODELAY, (char*)&nNagle, sizeof(nNagle));
	KGLOG_CHECK_ERROR(nRetCode >= 0);

    m_ConnectionDataList[nConnIndex].piSocketStream = piSocket;
    m_ConnectionDataList[nConnIndex].piSocketStream->AddRef();

    m_ConnectionDataList[nConnIndex].SocketPacker.Reset();
    m_ConnectionDataList[nConnIndex].dwLastPingTime         = m_dwTimeNow;
    m_ConnectionDataList[nConnIndex].pPlayer                = NULL;
    m_ConnectionDataList[nConnIndex].bSendError             = false;
    m_ConnectionDataList[nConnIndex].uStatSendByteCount     = 0;
    m_ConnectionDataList[nConnIndex].fStatSendSpeed         = 0.0f;
    m_ConnectionDataList[nConnIndex].nStatLastUpdateFrame   = g_pSO3World->m_nGameLoop;

    KGLogPrintf(KGLOG_INFO, "New connection from %s:%u, index = %d\n", pcszIP, uRemotePort, nConnIndex);

    bResult = true;
Exit0:
    if (!bResult)
    {
        piSocket->SetUserData((void *)(ptrdiff_t)-1);
    }
    return bResult;
}
Exemple #12
0
int KRLMissile::Init(KRLScene* pRLScene, KRLMissileParam const* pParam)
{
    int nRetCode = false;
    int nResult = false;
    KRLMissileModel const* pMissileModel = NULL;
    int nInitMissilePhases[RL_MISSILE_PHASE_COUNT] = { 0 };

    memcpy(&m_Param, pParam, sizeof(m_Param));

    ASSERT(pRLScene);
    ASSERT(m_pRLScene == NULL);

    m_pRLScene = pRLScene;

    pMissileModel = g_pRL->m_TableList.GetMissileModel(pParam->dwMissileID);
    KGLOG_PROCESS_ERROR(pMissileModel);

    for (int nPhase = 0; nPhase < RL_MISSILE_PHASE_COUNT; ++nPhase)
    {
        nRetCode = InitMissilePhase(m_RepresentMissile.m_MissilePhases[nPhase], pMissileModel->Params[nPhase], this);
        KGLOG_PROCESS_ERROR(nRetCode);

        nInitMissilePhases[nPhase] = true;
    }

    nRetCode = UpdateResult();
    KGLOG_PROCESS_ERROR(nRetCode);

#if 0
    m_Param.RTParam.vPosition = m_Param.TagParam.vInitialWorldPosition;
    m_Param.RTParam.vVelocity = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
    m_Param.RTParam.qRotation = m_Param.TagParam.qInitialWorldRotation;
    m_Param.RTParam.fScale = 1.0f;
#endif

    nResult = true;
Exit0:
    if (!nResult)
    {
        for (int nPhase = _countof(nInitMissilePhases) - 1; nPhase >= 0; --nPhase)
        {
            if (nInitMissilePhases[nPhase])
            {
                nRetCode = m_RepresentMissile.m_MissilePhases[nPhase].UnInit();
                KGLOG_CHECK_ERROR(nRetCode);
            }
        }

        m_pRLScene = NULL;

        memset(&m_Param, 0, sizeof(m_Param));
    }
    return nResult;
}
Exemple #13
0
HRESULT TransformatCell(KScene* lpLogicalScene, IEKG3DSceneSceneEditor* pEditor, LONG bOnlyAppointCell, LONG bClearCell, IELogicalSceneConnection* pLogicalConnection)
{
	HRESULT bRetCode = NULL;
	if (!bOnlyAppointCell)
	{
		bRetCode = lpLogicalScene->DeleteAllObstacle();
		KGLOG_CHECK_ERROR(bRetCode);
	}
	TransformAllHeightToCellHeight(pEditor,lpLogicalScene,bOnlyAppointCell,bClearCell,pLogicalConnection);
	return S_OK;
}
Exemple #14
0
void KLootList::OnOpen()
{
    BOOL bRetCode = FALSE;

#if defined(_SERVER)
    if (m_bIsOpened == FALSE)
    {
        // 初次打开时的操作
        for (int nItemIndex = 0; nItemIndex < m_nItemCount; nItemIndex++)
        {
            if (m_nLootMode == plmGroupLoot && m_LootList[nItemIndex].pItem &&
                    m_LootList[nItemIndex].pItem->m_GenParam.nQuality >= m_nRollQuality)
            {
                for (int nIndex = 0; nIndex < m_nLooterCount; nIndex++)
                {
                    if (m_pLooterList[nIndex])
                    {
                        bRetCode = g_PlayerServer.DoBeginRollItem(m_pLooterList[nIndex]->m_nConnIndex,
                                   m_LootList[nItemIndex].pItem, m_pDoodad);
                        KGLOG_CHECK_ERROR(bRetCode);
                    }
                }
            }
        }

        KGLOG_PROCESS_ERROR(m_pDoodad);
        //非尸体类型的Doodad被打开了,设置删除时间,尸体类型在生成时已经设置了
        if (m_pDoodad->m_eKind != dkCorpse)
        {
            bRetCode = m_pDoodad->SetDelayRemove();
            KGLOG_CHECK_ERROR(bRetCode);
        }
    }
#endif //_SERVER
    m_bIsOpened = TRUE;

Exit0:
    return;
}
Exemple #15
0
BOOL KDoodad::UpdateObstacle()
{
	BOOL bRetCode = FALSE;

	bRetCode = RemoveObstacle();
	KGLOG_CHECK_ERROR(bRetCode);

	bRetCode = ApplyObstacle();
	KGLOG_PROCESS_ERROR(bRetCode);

	bRetCode = TRUE;
Exit0:
	return bRetCode;
}
Exemple #16
0
BOOL KLootList::UnInit(void)
{
    BOOL bRetCode = FALSE;

    for (int nIndex = 0; nIndex < MAX_LOOT_SIZE; nIndex++)
    {
        if (m_LootList[nIndex].pItem)
        {
            bRetCode = g_ItemLib.FreeItem(m_LootList[nIndex].pItem);
            KGLOG_CHECK_ERROR(bRetCode);

            m_LootList[nIndex].pItem = NULL;
        }
    }

    return TRUE;
}
Exemple #17
0
BOOL KGFellowshipMgr::DelBlackList(DWORD dwPlayerID, DWORD dwAlliedPlayerID)
{
    BOOL bResult    = false;
    int  nRetCode   = 0;

    // Remove relation link, dwPlayerID -X-> dwAlliedPlayerID
    nRetCode = (int)m_BlackListMap.erase(KG_ID_PAIR(dwPlayerID, dwAlliedPlayerID));
    KGLOG_PROCESS_ERROR(nRetCode == 1);

    // Remove reverse relation link, dwPlayerID <-X- dwAlliedPlayerID
    nRetCode = (int)m_ReverseBlackListSet.erase(KG_ID_PAIR(dwAlliedPlayerID, dwPlayerID));
    KGLOG_CHECK_ERROR(nRetCode == 1);

Exit1:
    bResult = true;
Exit0:
    return bResult;
}
int PrefetchEndJumpCharacterPositionData(KRLCharacterPositionData* pData, KCharacter* pCharacter, int* pnGameLoop)
{
    int nRetCode = false;
    int nResult = false;
    int nGameLoop = 0;
    IKGSO3WorldClient* pSO3WorldClient = NULL;
    KPOSITION_RECORD PositionRecord;

    pSO3WorldClient = g_pRL->m_pSO3WorldClient;
    KGLOG_PROCESS_ERROR(pSO3WorldClient);

    KGLOG_PROCESS_ERROR(pCharacter);

    nRetCode = pSO3WorldClient->BeginForwardCharacterPosition(pCharacter, &PositionRecord);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = GetCharacterPositionData(pData, pCharacter);
    KGLOG_PROCESS_ERROR(nRetCode);

    do
    {
        nRetCode = pSO3WorldClient->ForwardCharacterPosition(pCharacter, 1);
        KGLOG_PROCESS_ERROR(nRetCode);

        nRetCode = GetCharacterPositionData(pData, pCharacter);
        KGLOG_PROCESS_ERROR(nRetCode);

        ++nGameLoop;
    }
    while (!OnFloor(pData) && nGameLoop < 10 * GAME_FPS);

    if (pnGameLoop)
        *pnGameLoop = nGameLoop;

    nResult = true;
Exit0:
    if (pSO3WorldClient && pCharacter)
    {
        nRetCode = pSO3WorldClient->EndForwardCharacterPosition(pCharacter, &PositionRecord);
        KGLOG_CHECK_ERROR(nRetCode);
    }
    return nResult;
}
Exemple #19
0
SKILL_RESULT_CODE KLootList::LeaderDistributeItem(KPlayer* pLeader, KPlayer* pDstPlayer,
        KDoodad* pDoodad, DWORD dwItemID)
{
    SKILL_RESULT_CODE nResult = srcFailed;
    BOOL bRetCode = FALSE;

    KGLOG_PROCESS_ERROR(pLeader);
    KGLOG_PROCESS_ERROR(pDstPlayer);
    KGLOG_PROCESS_ERROR(pDoodad);

    KG_PROCESS_ERROR(pDoodad->m_pLootList);
    KGLOG_PROCESS_ERROR(m_nLootMode == plmLeaderLoot);

    //在表中找到指定的物品
    int nItemIndex = 0;
    for (; nItemIndex < MAX_LOOT_SIZE; nItemIndex++)
    {
        if (m_LootList[nItemIndex].pItem == NULL)
            continue;
        if (m_LootList[nItemIndex].pItem->m_dwID == dwItemID)
            break;
    }

    KGLOG_PROCESS_ERROR(m_LootList[nItemIndex].pWinner == pLeader);

    bRetCode = IsInLooterList(pDstPlayer);
    KGLOG_PROCESS_ERROR(bRetCode);

    bRetCode = pDstPlayer->m_ItemList.AddItem(m_LootList[nItemIndex].pItem);
    KG_PROCESS_ERROR_RET_CODE(bRetCode, srcAddLootItemFailed);

    m_LootList[nItemIndex].pItem = NULL;
    m_nLootedCount++;

    bRetCode = g_PlayerServer.DoRollItemMessage(pDstPlayer, pDoodad->m_dwID, dwItemID,
               TRUE, -1);
    KGLOG_CHECK_ERROR(bRetCode);

    nResult = srcSuccess;
Exit0:
    return nResult;
}
Exemple #20
0
BOOL KEscortQuestManager::SetEscortQuestValue(DWORD dwQuestID, int nIndex, int nValue)
{
    BOOL bResult     = false;
    BOOL bRetCode    = false;
    int  nQuestIndex = -1;
    MAP_ESCORT_QUEST::iterator it;
    
    it = m_EscortQuestMap.find(dwQuestID);
    KGLOG_PROCESS_ERROR(it != m_EscortQuestMap.end());

    for (int i = 0; i < MAX_PARTY_SIZE; ++i)
    {
        KPlayer* pPlayer = NULL;

        if (it->second.dwPlayerID[i] == ERROR_ID || !(it->second.bValid[i]))
        {
            continue;
        }
        
        pPlayer = g_pSO3World->m_PlayerSet.GetObj(it->second.dwPlayerID[i]);
        if (pPlayer == NULL || pPlayer->m_pScene == NULL)
        {
            it->second.dwPlayerID[i] = ERROR_ID;
            it->second.bValid[i] = false;
            continue;
        }
        
        nQuestIndex = pPlayer->m_QuestList.GetQuestIndex(dwQuestID);
        KGLOG_CHECK_ERROR(nQuestIndex != -1);

        if (nQuestIndex != -1)
        {
            bRetCode = pPlayer->m_QuestList.SetQuestValue(nQuestIndex, nIndex, nValue);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
    }

    bResult = true;
Exit0:
    return bResult;
}
Exemple #21
0
BOOL KEscortQuestManager::AddPlayerBuff(DWORD dwQuestID, DWORD dwBuffID, int nBuffLevel)
{
    BOOL                bResult     = false;
    BOOL                bRetCode    = false;
    KBUFF_RECIPE_KEY    BuffRecipeKey;
    MAP_ESCORT_QUEST::iterator it;
    
    it = m_EscortQuestMap.find(dwQuestID);
    KGLOG_PROCESS_ERROR(it != m_EscortQuestMap.end());
    
    memset(&BuffRecipeKey, 0, sizeof(BuffRecipeKey));
    
    BuffRecipeKey.dwID      = dwBuffID;
    BuffRecipeKey.nLevel    = nBuffLevel;

    for (int i = 0; i < MAX_PARTY_SIZE; ++i)
    {
        KPlayer*            pPlayer = NULL;

        if (it->second.dwPlayerID[i] == ERROR_ID || !(it->second.bValid[i]))
        {
            continue;
        }
        
        pPlayer = g_pSO3World->m_PlayerSet.GetObj(it->second.dwPlayerID[i]);
        if (pPlayer == NULL || pPlayer->m_pScene == NULL)
        {
            continue;
        }
        
        bRetCode = pPlayer->m_BuffList.CallBuff(
            pPlayer->m_dwID, pPlayer->m_nLevel, BuffRecipeKey, 0, 0
        );
        KGLOG_CHECK_ERROR(bRetCode);
    }

    bResult = true;
Exit0:
    return bResult;
}
void KMovableObject::ClearFollower()
{
    KMovableObject* pMoveObj = NULL;
    std::vector<DWORD> vecTemp(m_vecFollower);
    for (std::vector<DWORD>::const_iterator constIt = vecTemp.begin(); constIt != vecTemp.end(); ++constIt)
    {
        KSceneObject* pObj = (KSceneObject*)m_pScene->GetSceneObjByID(*constIt);
        assert(pObj);
        pMoveObj = dynamic_cast<KMovableObject*>(pObj);
        KGLOG_CHECK_ERROR(pMoveObj);

        pMoveObj->TurnToMoveType(mosFree);
        pMoveObj->RemoveGuide();

        if (!m_pScene->IsBattleFinished() && GetType() == sotHero)
        {
            g_PlayerServer.DoUnTakeDoodad(m_dwID, pMoveObj);
        }
    }

    m_vecFollower.clear();
}
void KGTestMapDisuseResource::UnInit()
{
	int nResult  = false;
	int nRetCode = false;
	HRESULT hrRetCode = E_FAIL;

	m_mapSourceRes.clear();
	m_setUsedRes.clear();
	m_vecMapList.clear();
	m_vecLODRes.clear();
	if (m_pEngineMgr)
	{
		hrRetCode = m_pEngineMgr->UnInit();
		KGLOG_COM_CHECK_ERROR(hrRetCode);
		m_pEngineMgr = NULL;
	}
	if (m_hEngineDLL)
	{
		nRetCode = FreeLibrary(m_hEngineDLL);
		KGLOG_CHECK_ERROR(nRetCode);
		m_hEngineDLL = NULL;
	}
}
Exemple #24
0
BOOL KG3DFontTexture::CleanUp()
{
    int nRetCode = false;

	for (size_t nIndex = 0; nIndex < m_aTextureIndex.size(); ++nIndex)
		m_pRenderer->DeleteTexture(m_aTextureIndex[nIndex]);
	m_aTextureIndex.clear();

	if (m_pFontFace)
	{
        nRetCode = s_FontFacePool.Unload(m_pFontFace);
        KGLOG_CHECK_ERROR(nRetCode);

        m_pFontFace = NULL;
	}

	for (size_t nIndex = 0; nIndex < _countof(m_pGlyphs); ++nIndex)
	{
		KG3DTextureGlyph* pGlyph = m_pGlyphs[nIndex];
		if (pGlyph == NULL)
			continue;
		g_Allocator.Free(pGlyph); 
	}

	m_fontAscender = 0.0f;
	m_fontDescender = 0.0f;

	m_dwFontColor = 0xFFFFFFFF;

	m_fScalingX	= 1.0f;
	m_fScalingY = 1.0f;

	memset(m_pGlyphs, 0, sizeof(m_pGlyphs));

	return TRUE;
}
Exemple #25
0
KAWARD_ITEM*  KAwardMgr::AwardRandomOne(KPlayer* pPlayer, DWORD dwAwardTableID)
{
    BOOL            bRetCode        = false;
    IItem*          pItem           = NULL;
    KAwardTable*    pAwardTable     = NULL;
    KAWARD_ITEM*    pAwardItem      = NULL;
    int             nValuePoint = 0;

    assert(pPlayer);

    bRetCode = HasEnoughBagToAwardRandomOne(pPlayer, dwAwardTableID);
    KGLOG_PROCESS_ERROR(bRetCode);

    pAwardTable = GetAwardTable(dwAwardTableID);
    KGLOG_PROCESS_ERROR(pAwardTable);

    pAwardItem = pAwardTable->GetRandomAward();
    if (pAwardItem)
    {
        if (pAwardItem->dwTabType == ittOther || pAwardItem->dwTabType == ittEquip)
        {
            bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
            KGLOG_PROCESS_ERROR(bRetCode);

            pItem = pPlayer->AddItem(pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint);
            if (pItem)
            {
                PLAYER_LOG(
                    pPlayer, "item,additem,%u-%u,%d,%d,%d,%s,%d",
                    pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, pItem->GetQuality(),
                    "useitem", pPlayer->m_dwMapID
                );
            }
        }
        else if (pAwardItem->dwTabType == ittFashion)
        {
            bRetCode = pPlayer->m_Wardrobe.AddFashion(pAwardItem->dwIndex);
            KGLOG_CHECK_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittCheerleading)
        {
            KGCheerleadingInfo* pCheerleadingInfo = g_pSO3World->m_ItemHouse.GetCheerleadingInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pCheerleadingInfo);

            bRetCode = pPlayer->m_CheerleadingMgr.AddCheerleading(pCheerleadingInfo->dwID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittTeamLogo)
        {
            KTEAM_LOGO_INFO*    pTeamLogoInfo = NULL;

            pTeamLogoInfo = g_pSO3World->m_ItemHouse.GetTeamLogoInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pTeamLogoInfo);

            bRetCode = pPlayer->AddTeamLogo((WORD)pTeamLogoInfo->nID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->nMoney > 0)
        {
            bRetCode = pPlayer->m_MoneyMgr.AddMoney(pAwardItem->eMoneyType, pAwardItem->nMoney);
            KGLOG_PROCESS_ERROR(bRetCode);
            PLAYER_LOG(pPlayer, "money,addmoney,%d,%s,%d-%d,%d,%d", pAwardItem->eMoneyType, "useitem", 0, 0, 0, pAwardItem->nMoney);
        }
    }

Exit0:
    return pAwardItem;
}
Exemple #26
0
BOOL KAwardMgr::AwardAll(KPlayer* pPlayer, DWORD dwAwardTableID, const char szWayID[])
{
    BOOL bResult = false;
    BOOL bRetCode = false;
    KAwardTable* pAwardTable = NULL;
    int nValuePoint = 0;

    assert(szWayID);

    KGLOG_PROCESS_ERROR(pPlayer);
    KGLOG_PROCESS_ERROR(dwAwardTableID);

    pAwardTable = GetAwardTable(dwAwardTableID);
    KGLOG_PROCESS_ERROR(pAwardTable);

    bRetCode = HasEnoughBagToAwardAll(pPlayer, dwAwardTableID);
    KGLOG_PROCESS_ERROR(bRetCode);

    for (KAWARD_ITEM_MAP::iterator it = pAwardTable->m_mapAwardItem.begin(); it != pAwardTable->m_mapAwardItem.end(); ++it)
    {
        KAWARD_ITEM* pAwardItem = &it->second;
        if (pAwardItem->dwTabType == ittOther || pAwardItem->dwTabType == ittEquip)
        {
			IItem* pItem = NULL;

            bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
            KGLOG_PROCESS_ERROR(bRetCode);

            pItem = pPlayer->AddItem(pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint);
            if (pItem)
            {
                PLAYER_LOG(
                    pPlayer, "item,additem,%u-%u,%d,%d,%d,%s,%d",
                    pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, pItem->GetQuality(),
                    szWayID, pPlayer->m_dwMapID
                );
            }
        }
        else if (pAwardItem->dwTabType == ittFashion)
        {
            bRetCode = pPlayer->m_Wardrobe.AddFashion(pAwardItem->dwIndex);
            KGLOG_CHECK_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittCheerleading)
        {
            KGCheerleadingInfo* pCheerleadingInfo = g_pSO3World->m_ItemHouse.GetCheerleadingInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pCheerleadingInfo);

            bRetCode = pPlayer->m_CheerleadingMgr.AddCheerleading(pCheerleadingInfo->dwID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittTeamLogo)
        {
            KTEAM_LOGO_INFO*    pTeamLogoInfo = NULL;

            pTeamLogoInfo = g_pSO3World->m_ItemHouse.GetTeamLogoInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pTeamLogoInfo);

            bRetCode = pPlayer->AddTeamLogo((WORD)pTeamLogoInfo->nID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->nMoney > 0)
        {
            bRetCode = pPlayer->m_MoneyMgr.AddMoney(pAwardItem->eMoneyType, pAwardItem->nMoney);
            KGLOG_PROCESS_ERROR(bRetCode);

            PLAYER_LOG(pPlayer, "money,addmoney,%d,%s,%d-%d,%d,%d", pAwardItem->eMoneyType, szWayID, 0, 0, 0, pAwardItem->nMoney);
        }
    }

    bResult = true;
Exit0:
    return bResult;
}
Exemple #27
0
BOOL KAwardMgr::Award(KPlayer* pPlayer, KAWARD_CARD_TYPE eType, DWORD dwAwardID, unsigned uChooseIndex, BOOL bEndChoose)
{
    BOOL            bResult         = false;
    BOOL            bRetCode        = false;
    IItem*          pItem           = NULL;
    KAwardTable*    pAwardTable     = NULL;
    KAWARD_ITEM*    pAwardItem      = NULL;
    KS2C_Award_Item arrAwardList[cdVipCardCount] = {0};
    IItem*          pLookItem = NULL;
    KSystemMailTxt* pSysMailTxt = NULL;
    KAWARD_ITEM*    pTempItem = NULL;
    KS2C_Award_Item* pAwardItemInfo = NULL;
    KS2C_Award_Item AwardItem;
    DWORD           dwRandSeed = 0;
    int nValuePoint = 0;

    assert(pPlayer);

    KGLOG_PROCESS_ERROR(uChooseIndex < countof(arrAwardList));

    pAwardTable = GetAwardTable(dwAwardID);
    KGLOG_PROCESS_ERROR(pAwardTable);

    pAwardItem = pAwardTable->GetRandomAward();
    if (pAwardItem)
    {
        if (pAwardItem->dwTabType == ittOther || pAwardItem->dwTabType == ittEquip)
        { 
            pSysMailTxt = g_pSO3World->m_Settings.m_SystemMailMgr.GetSystemMailTxt(KMAIL_CHOOSE);
            KGLOG_PROCESS_ERROR(pSysMailTxt);

            bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
            KGLOG_PROCESS_ERROR(bRetCode);
            
            dwRandSeed = KG_GetTickCount();

            bRetCode = pPlayer->SafeAddItem(pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, 
                pSysMailTxt->m_szMailTitl, pSysMailTxt->m_szSendName, pSysMailTxt->m_szMailTxt, dwRandSeed
            );

            pItem = g_pSO3World->m_ItemHouse.CreateItem(pAwardItem->dwTabType, pAwardItem->dwIndex, 0, dwRandSeed, nValuePoint);

            if (bRetCode)
            {
                BroadCastAwardItem(pPlayer, pAwardItem);
 
                if (eType == KAWARD_CARD_TYPE_NORMAL)
                {
                    PLAYER_LOG(
                        pPlayer, "item,additem,%u-%u,%d,%d,%s,%d",
                        pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, 
                        "missionaward", pPlayer->m_dwMapID
                        );
                }
                else if (eType == KAWARD_CARD_TYPE_GOLD)
                {
                    PLAYER_LOG(
                        pPlayer, "item,additem,%u-%u,%d,%d,%s,%d",
                        pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint,
                        "goldaward", pPlayer->m_dwMapID
                        );
                }
                else if (eType == KAWARD_CARD_TYPE_VIP)
                {
                    PLAYER_LOG(
                        pPlayer, "item,additem,%u-%u,%d,%d,%s,%d",
                        pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint,
                        "vipaward", pPlayer->m_dwMapID
                    );
                }
            }
        }
        else if (pAwardItem->dwTabType == ittFashion)
        {
            bRetCode = pPlayer->m_Wardrobe.AddFashion(pAwardItem->dwIndex);
            KGLOG_CHECK_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittCheerleading)
        {
            KGCheerleadingInfo* pCheerleadingInfo = g_pSO3World->m_ItemHouse.GetCheerleadingInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pCheerleadingInfo);

            bRetCode = pPlayer->m_CheerleadingMgr.AddCheerleading(pCheerleadingInfo->dwID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittTeamLogo)
        {
            KTEAM_LOGO_INFO*    pTeamLogoInfo = NULL;

            pTeamLogoInfo = g_pSO3World->m_ItemHouse.GetTeamLogoInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pTeamLogoInfo);

            bRetCode = pPlayer->AddTeamLogo((WORD)pTeamLogoInfo->nID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->nMoney > 0)
        {
            bRetCode = pPlayer->m_MoneyMgr.AddMoney(pAwardItem->eMoneyType, pAwardItem->nMoney);
            KGLOG_PROCESS_ERROR(bRetCode);
            PLAYER_LOG(pPlayer, "money,addmoney,%d,%s,%d-%d,%d,%d", pAwardItem->eMoneyType, "awardtable", 0, 0, 0, pAwardItem->nMoney);


            BroadCastAwardMoney(pPlayer, pAwardItem);
        }

        memset(&AwardItem, 0, sizeof(AwardItem));

        pAwardItemInfo = &AwardItem;

        memset(pAwardItemInfo->RandomAttr, 0, sizeof(pAwardItemInfo->RandomAttr));

        bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
        KGLOG_PROCESS_ERROR(bRetCode);

        pAwardItemInfo->itemType    = (unsigned char)pAwardItem->dwTabType;
        pAwardItemInfo->itemIndex   = pAwardItem->dwIndex;
        pAwardItemInfo->nCount      = (short)pAwardItem->nStackNum;
        pAwardItemInfo->byMoneyType = (BYTE)pAwardItem->eMoneyType;
        pAwardItemInfo->nMoney      = (short)pAwardItem->nMoney;
        pAwardItemInfo->nValuePoint = nValuePoint;

        if (pItem)
        {
            const KItemProperty*    pProperty   = pItem->GetProperty();
            KAttribute*			    pExtAttr    = pProperty->pExtAttr;  

            for (int j = 0; j < countof(pAwardItemInfo->RandomAttr); ++j)
            {
                if (pExtAttr == NULL)
                    break;

                pAwardItemInfo->RandomAttr[j].wKey = (unsigned short)pExtAttr->nKey;
                pAwardItemInfo->RandomAttr[j].wValue = (unsigned short)pExtAttr->nValue1;
                pExtAttr = pExtAttr->pNext;
            }
        }

        g_PlayerServer.DoAwardItemNotify(pPlayer, eType, AwardItem, uChooseIndex);
    }

    KG_PROCESS_SUCCESS(!bEndChoose);

    memset(arrAwardList, 0, sizeof(arrAwardList));
    for (unsigned i = 0; i < countof(arrAwardList); ++i)
    {
        pTempItem = NULL;
        pAwardItemInfo = &arrAwardList[i];

        memset(pAwardItemInfo->RandomAttr, 0, sizeof(pAwardItemInfo->RandomAttr));

        if (i != uChooseIndex)
        {
            const KItemProperty*    pProperty = NULL;
            KAttribute*			    pExtAttr  = NULL;

            pTempItem = pAwardTable->GetOneAwardItemByEqualRate();
            if (pTempItem == NULL)
                continue;

            bRetCode = GetAwardItemValuePoint(pTempItem, nValuePoint);
			KGLOG_PROCESS_ERROR(bRetCode);

            pAwardItemInfo->itemType    = (unsigned char)pTempItem->dwTabType;
            pAwardItemInfo->itemIndex   = pTempItem->dwIndex;
            pAwardItemInfo->nCount      = (short)pTempItem->nStackNum;
            pAwardItemInfo->byMoneyType = (BYTE)pTempItem->eMoneyType;
            pAwardItemInfo->nMoney      = (short)pTempItem->nMoney;
            pAwardItemInfo->nValuePoint = nValuePoint;

            if (pTempItem->dwTabType > 0 && pTempItem->dwIndex > 0)
            {
                pLookItem = g_pSO3World->m_ItemHouse.CreateItem(pTempItem->dwTabType, pTempItem->dwIndex, 0, 0, nValuePoint);
                KGLOG_CHECK_ERROR(pLookItem);
                if (pLookItem)
                {
                    pProperty   = pLookItem->GetProperty();
                    pExtAttr    = pProperty->pExtAttr;  

                    for (int j = 0; j < countof(pAwardItemInfo->RandomAttr); ++j)
                    {
                        if (pExtAttr == NULL)
                            break;

                        pAwardItemInfo->RandomAttr[j].wKey = (unsigned short)pExtAttr->nKey;
                        pAwardItemInfo->RandomAttr[j].wValue = (unsigned short)pExtAttr->nValue1;
                        pExtAttr = pExtAttr->pNext;
                    }

                    g_pSO3World->m_ItemHouse.DestroyItem(pLookItem);
                    pLookItem = NULL;
                }

            }
        }
    }

    g_PlayerServer.DoAwardItemListNotify(pPlayer, eType, arrAwardList, countof(arrAwardList));

Exit1:
    bResult = true;
Exit0:
    if (pLookItem)
    {
        g_pSO3World->m_ItemHouse.DestroyItem(pLookItem);
        pLookItem = NULL;
    }

    if (pItem)
    {
        g_pSO3World->m_ItemHouse.DestroyItem(pItem);
        pItem = NULL;
    }
    return bResult;
}
Exemple #28
0
BOOL KAwardMgr::ScenenItemAward(std::vector<KPlayer*>& vecPlayer, DWORD dwAwardID)
{
    BOOL            bResult         = false;
    BOOL            bRetCode        = false;
    KAwardTable*    pAwardTable     = NULL;
    KAWARD_ITEM*    pAwardItem      = NULL;
    KPlayer*        pPlayer         = NULL; 
    KSystemMailTxt* pSysMailTxt     = NULL;
    int             nValuePoint     = 0;

    pAwardTable = g_pSO3World->m_AwardMgr.GetAwardTable(dwAwardID);
    KGLOG_PROCESS_ERROR(pAwardTable);

    pAwardItem = pAwardTable->GetRandomAward();
    KGLOG_PROCESS_ERROR(pAwardItem);
    KGLOG_PROCESS_ERROR(pAwardItem->dwTabType);

    pSysMailTxt = g_pSO3World->m_Settings.m_SystemMailMgr.GetSystemMailTxt(KMAIL_BATTLE_AWARD);
    KGLOG_PROCESS_ERROR(pSysMailTxt);

    for (size_t i = 0; i < vecPlayer.size(); ++i)
    {
        pPlayer = vecPlayer[i];

        KGLOG_PROCESS_ERROR(pPlayer);

        if (pAwardItem->dwTabType == ittOther || pAwardItem->dwTabType == ittEquip)
        {
            bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
            KGLOG_PROCESS_ERROR(bRetCode);

            bRetCode = pPlayer->SafeAddItem(pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, 
                pSysMailTxt->m_szMailTitl, pSysMailTxt->m_szSendName, pSysMailTxt->m_szMailTxt
            );
            KGLOG_PROCESS_ERROR(bRetCode);

            PLAYER_LOG(
                pPlayer, "item,additem,%u-%u,%d,%d,%s,%d",
                pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, 
                "SceneAward", pPlayer->m_dwMapID
            );
        }
        else if (pAwardItem->dwTabType == ittFashion)
        {
            bRetCode = pPlayer->m_Wardrobe.AddFashion(pAwardItem->dwIndex);
            KGLOG_CHECK_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittCheerleading)
        {
            KGCheerleadingInfo* pCheerleadingInfo = g_pSO3World->m_ItemHouse.GetCheerleadingInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pCheerleadingInfo);

            bRetCode = pPlayer->m_CheerleadingMgr.AddCheerleading(pCheerleadingInfo->dwID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittTeamLogo)
        {
            KTEAM_LOGO_INFO*    pTeamLogoInfo = NULL;

            pTeamLogoInfo = g_pSO3World->m_ItemHouse.GetTeamLogoInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pTeamLogoInfo);

            bRetCode = pPlayer->AddTeamLogo((WORD)pTeamLogoInfo->nID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
    }

    bResult = true;
Exit0:
    return bResult;
}
BOOL KHeroDataList::SaveToProtoBuf(T3DB::KPB_SAVE_DATA* pSaveBuf)
{
    BOOL bResult = false;
    T3DB::KPBHeroDataList* pHeroDataList = NULL;
    T3DB::KPB_HERO_DATA_LIST* pHeroList = NULL;
    T3DB::KPB_BUFF_DATA_LIST* pBuffDataListDB = NULL;
    KHeroData* pHeroData = NULL;
    KBUFF_NODE_MAP::iterator itBuffNode;

    KGLOG_PROCESS_ERROR(pSaveBuf);

    pHeroDataList = pSaveBuf->mutable_herodatalist();
    pHeroList = pHeroDataList->mutable_herodatalistdb();
    pBuffDataListDB = pHeroDataList->mutable_buffdatalistdb();

    pHeroList->set_maxherocount(m_nMaxHeroCount);

    for (KMAP_HERO_DATA::iterator it = m_mapHeroData.begin(); it != m_mapHeroData.end(); ++it)
    {
        pHeroData = &it->second;
        T3DB::KPB_HERO_DATA* pPBHeroData = pHeroDataList->add_herodata();
        
        pPBHeroData->set_index(it->first);
        pPBHeroData->set_level(pHeroData->m_nLevel);
        pPBHeroData->set_templateid(pHeroData->m_dwTemplateID);
        pPBHeroData->set_exp(pHeroData->m_nExp);
        pPBHeroData->set_eol(pHeroData->m_nEol);
        pPBHeroData->set_ladderlevel(pHeroData->m_nLadderLevel);
        pPBHeroData->set_ladderexp(pHeroData->m_nLadderExp);
        pPBHeroData->set_ladderwincount(pHeroData->m_nLadderWinCount);
        pPBHeroData->set_ladderlosecount(pHeroData->m_nLadderLoseCount);
        pPBHeroData->set_ladderdrawcount(pHeroData->m_nLadderDrawCount);
        pPBHeroData->set_freetalent(pHeroData->m_wFreeTalent);
        pPBHeroData->set_fashionid(pHeroData->m_wFashionID);
        pPBHeroData->set_fired(pHeroData->m_bFired);

        pPBHeroData->add_talent(pHeroData->m_wTalent[egymWeightLift]);
        pPBHeroData->add_talent(pHeroData->m_wTalent[egymRunning]);
        pPBHeroData->add_talent(pHeroData->m_wTalent[egymBoxing]);

        pPBHeroData->set_equipscore(m_pPlayer->m_ItemList.GetHeroEquipScore(pHeroData->m_dwTemplateID));

        for (int i = 0; i < KACTIVE_SLOT_TYPE_TOTAL; ++i)
        {
            pPBHeroData->add_selectedactiveskill(pHeroData->m_SelectedActvieSkill[i]);
        }

        for (int i = 0; i < cdPassiveSkillSlotCount; ++i)
        {
            pPBHeroData->add_selectedpassiveskill(pHeroData->m_SelectedPassiveSkill[i]);
        }

        for (int i = 0; i < cdNirvanaSkillSlotCount; ++i)
        {
            pPBHeroData->add_selectednirvanaskill(pHeroData->m_SelectedNirvanaSkill[i]);
        }

        for (int i = 0; i < cdSlamBallSkillSlotCount; ++i)
        {
            pPBHeroData->add_selectedslamballskill(pHeroData->m_SelectedSlamBallSkill[i]);
        }

        // 存储buff数据
        
        itBuffNode = pHeroData->m_mapBuffNode.begin();
        KGLOG_CHECK_ERROR(pHeroData->m_mapBuffNode.size() <= HUNDRED_NUM);
        while (itBuffNode != pHeroData->m_mapBuffNode.end())
        {
            T3DB::KPB_BUFF_DATA* pBuffData = pBuffDataListDB->add_buffdata();
            pBuffData->set_buffid(itBuffNode->first);
            pBuffData->set_leftframe(itBuffNode->second.m_nActiveCount);
            pBuffData->set_activecount(itBuffNode->second.m_nLeftFrame);
            ++itBuffNode;
        }
    }

    bResult = true;
Exit0:
    return bResult;
}
int KGTestMapDisuseResource::LoadEngineDLL()
{
	int nResult  = false;
	int nRetCode = false;
	HRESULT hrRetCode = E_FAIL;
	HWND hWindow = NULL;
	char szEngineDll[MAX_PATH] = {0};

	g_SetRootPath(m_szClientPath);
	::SetCurrentDirectory(m_szClientPath);

	nRetCode = _snprintf_s(
		szEngineDll,
		sizeof(szEngineDll),
		sizeof(szEngineDll) - 1,        
		"%s%s",
		g_szApplicationPath,
		ENGINE_DLL_NAME
		);
	KGLOG_PROCESS_ERROR(nRetCode > 0);

 	nRetCode = _access(szEngineDll, 0);
 	if (nRetCode != 0)
	{
		nRetCode = _snprintf_s(
			szEngineDll,
			sizeof(szEngineDll),
			sizeof(szEngineDll) - 1,        
			"%s%s",
			m_szClientPath,
			ENGINE_DLL_NAME
			);
		KGLOG_PROCESS_ERROR(nRetCode > 0);
	}
	
	m_hEngineDLL = LoadLibrary(szEngineDll);
	KGLOG_PROCESS_ERROR(m_hEngineDLL);

	hWindow = ::GetDesktopWindow();
	KGLOG_PROCESS_ERROR(hWindow);

	typedef HRESULT (*pfnGet3DEngineInterface)(void** ppvEngineManager);
	pfnGet3DEngineInterface Get3DEngineInterface;

	Get3DEngineInterface = (pfnGet3DEngineInterface)GetProcAddress(m_hEngineDLL, "Get3DEngineInterface");
	Get3DEngineInterface((void**)&m_pEngineMgr);
	KGLOG_PROCESS_ERROR(m_pEngineMgr);
	hrRetCode = m_pEngineMgr->Init(0, KG3DENG_CLIENT, hWindow, hWindow);
	KGLOG_COM_PROCESS_ERROR(hrRetCode);

	nResult = true;
Exit0:
	if (!nResult)
	{
		if (m_pEngineMgr)
		{
			hrRetCode = m_pEngineMgr->UnInit();
			KGLOG_COM_CHECK_ERROR(hrRetCode);
			m_pEngineMgr = NULL;
		}
		if (m_hEngineDLL)
		{
			nRetCode = FreeLibrary(m_hEngineDLL);
			KGLOG_CHECK_ERROR(hrRetCode);
			m_hEngineDLL = NULL;
		}
	}
	return nResult;
}