Beispiel #1
0
int KDumpModuleAnalyzer::GetModules(HANDLE hExceptionThread, PEXCEPTION_POINTERS pExceptionInfo, KDumpModuleInfoVector *pDumpModuleInfoVector)
{
	int nResult = false;
	int nRetCode = false;
	KDumpModuleInfo DefaultModuleInfo;

	KG_PROCESS_ERROR(hExceptionThread);
	KG_PROCESS_ERROR(pExceptionInfo);
	KG_PROCESS_ERROR(pDumpModuleInfoVector);

	nRetCode = GetFilteredModules(hExceptionThread, pExceptionInfo, pDumpModuleInfoVector);
	KG_PROCESS_SUCCESS(nRetCode);

	nRetCode = GetFirstModule(hExceptionThread, pExceptionInfo, pDumpModuleInfoVector);
	KG_PROCESS_SUCCESS(nRetCode);

	DefaultModuleInfo.dwModuleBase = 0;
	DefaultModuleInfo.dwStackAddress = (DWORD64)pExceptionInfo->ExceptionRecord->ExceptionAddress;
	strncpy(DefaultModuleInfo.szModuleName, UNKNOWN_MODULE_NAME, sizeof(DefaultModuleInfo.szModuleName) / sizeof(DefaultModuleInfo.szModuleName[0]));
	DefaultModuleInfo.szModuleName[sizeof(DefaultModuleInfo.szModuleName)  / sizeof(DefaultModuleInfo.szModuleName[0]) - 1] = '\0';
	 
	pDumpModuleInfoVector->push_back(DefaultModuleInfo);

Exit1:
	nResult = true;
Exit0:
	return nResult;
}
BOOL KBroadcastFunc::operator()(KHero* pHero)
{
    BOOL bResult  = false;
    BOOL bRetCode = false;
    int nConnIndex = -1;
    KPlayer* pPlayer = NULL;
   
    KG_PROCESS_SUCCESS(pHero->m_dwID == m_dwExcept);

    KG_PROCESS_SUCCESS(!pHero->IsMainHero());
    
    pPlayer = pHero->GetOwner();
    KG_PROCESS_SUCCESS(!pPlayer);

    nConnIndex = pPlayer->m_nConnIndex;
    KG_PROCESS_SUCCESS(nConnIndex == -1);

    if (m_dwExclusive != ERROR_ID && pHero->m_dwID != m_dwExclusive)
    {
        goto Exit1;
    }

    g_PlayerServer.Send(nConnIndex, m_pvData, m_uSize);

Exit1:
    bResult = true;
Exit0:
    return bResult;
}
BOOL KBuffList::DelBuff(DWORD dwBuffID)
{
    BOOL    bResult     = false;
    KBuff*  pBuff       = NULL;
    KBuffTable::iterator it;

    KG_PROCESS_SUCCESS(!dwBuffID);

    it = m_BuffTable.find(dwBuffID);
    KG_PROCESS_SUCCESS(it == m_BuffTable.end());

    pBuff = g_pSO3World->m_BuffManager.GetBuff(dwBuffID);
    KGLOG_PROCESS_ERROR(pBuff);

    m_pSelf->UnApplyAttribute(pBuff->m_pRollBackAttr);

    m_BuffTable.erase(dwBuffID);

    g_PlayerServer.DoLoseBuffNotify(m_pSelf, dwBuffID);

Exit1:
    bResult = true;
Exit0:
    return bResult;
}
Beispiel #4
0
HRESULT KRLTarget::Hide()
{
	int nRetCode = false;
	HRESULT hr = E_FAIL;
    HRESULT hrResult = E_FAIL;
    IKG3DModel* p3DModel = NULL;

	nRetCode = m_nRLForceRelation == RL_FORCE_RELATION_INVALID;
	KG_PROCESS_SUCCESS(nRetCode);

    p3DModel = m_ap3DModel[m_nRLForceRelation];
	KG_PROCESS_SUCCESS(p3DModel == NULL);

	hr = KModel::PauseAnimation(p3DModel, TRUE);
	KGLOG_COM_PROCESS_ERROR(hr);

    hr = KModel::RemoveRenderEntity(m_pRLScene->m_p3DScene, p3DModel, FALSE);
	KGLOG_COM_PROCESS_ERROR(hr);

	m_nRLForceRelation = RL_FORCE_RELATION_INVALID;

Exit1:
	hrResult = S_OK;
Exit0:
	return hrResult;
}
Beispiel #5
0
void KRLRemoteCharacter::UpdateLifeState(BOOL bUpdateDisplayData)
{
    int nRetCode = false;
    HRESULT hr = E_FAIL;
    BOOL bShowLifeBar = TRUE;
    int nCharacterType = CHARACTER_TYPE_REMOTE_PLAYER;
    KForceRelationModel const* pForceRelationModel = NULL;

    KGLOG_PROCESS_ERROR(m_FrameData.m_pCharacter);

    KG_PROCESS_SUCCESS(!m_FrameData.IsLifeChanged() && !bUpdateDisplayData);

    if (!IS_PLAYER(m_RLCharacter.GetObjectID()))
    {
        KNpc* pNPC = (KNpc*)m_FrameData.m_pCharacter;

        bShowLifeBar = pNPC->m_pTemplate->bCanSeeLifeBar;

        nCharacterType = CHARACTER_TYPE_NPC;
    }

    KG_PROCESS_SUCCESS(!g_pRL->m_Option.bHeadSFXEnabled[nCharacterType][CHARACTER_SFX_LIFE - CHARACTER_SFX_BBOX_BALLOON_BEGIN]);

    KG_PROCESS_SUCCESS(!bShowLifeBar);

    pForceRelationModel = GetForceRelationModel(m_RLCharacter.GetObjectID(), g_pRL->m_pSO3World->m_dwClientPlayerID);
    KGLOG_PROCESS_ERROR(pForceRelationModel);

    hr = m_RLCharacter.m_RenderData.SetPercentage(pForceRelationModel->dwColor, m_FrameData.m_Current.fLifePercentage);
    KGLOG_COM_PROCESS_ERROR(hr);

Exit1:
Exit0:
    return;
}
BOOL KCheckHeroBlowupFunc::operator()(KHero* pHero)
{
    BOOL bResult    = false;
    BOOL bRetCode   = false;
    KLandMine* pLandMine = (KLandMine*)m_pLandMine;
    KVELOCITY vBlowupVelocity = {0};
    KPOSITION Src;
    KPOSITION Dest;
    int nDamage = 0;

    assert(m_pLandMine);

    KGLOG_PROCESS_ERROR(pLandMine->m_nBlowupRange > 0);

    bRetCode = pHero->CanBeAttacked();
    KG_PROCESS_SUCCESS(!bRetCode);

    Src   = pLandMine->GetPosition();
    Dest  = pHero->GetPosition();
    Dest.nZ += pHero->m_nHeight / 2;

    bRetCode = g_InRange(Dest.nX, Dest.nY, Dest.nZ, Src.nX, Src.nY, Src.nZ, pLandMine->m_nBlowupRange);
    KG_PROCESS_SUCCESS(!bRetCode);

    bRetCode = pHero->ApplyGeneralAffect(pLandMine->m_dwAttakerID, pLandMine, pLandMine->m_pTemplate->m_dwAttackAffectID1);
    KGLOG_PROCESS_ERROR(bRetCode);

Exit1:
    bResult = true;
Exit0:
    return bResult;
}
Beispiel #7
0
BOOL KRegion::CheckObstacle(int nXCell, int nYCell, int nLayer)
{
	BOOL bFound = FALSE;

	KG_PROCESS_SUCCESS(nXCell < 0);
	KG_PROCESS_SUCCESS(nXCell >= REGION_GRID_WIDTH);
	KG_PROCESS_SUCCESS(nYCell < 0);
	KG_PROCESS_SUCCESS(nYCell >= REGION_GRID_HEIGHT);

	KCell* pCell = &(m_Cells[nXCell][nYCell]);
	while (pCell)
	{
		if (nLayer >= pCell->m_wLowLayer)
		{
			if (nLayer < pCell->m_wHighLayer)
				return TRUE;
			else
				pCell = pCell->m_pNext;
		}
		else
		{
			return FALSE;
		}
	}

Exit0:
	return FALSE;

Exit1:
	// 非法区域全算障碍
	return TRUE;
}
Beispiel #8
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;
}
Beispiel #9
0
int KTestCommon::ModifyVersionFile(const TCHAR cszFilePath[], const TCHAR cszVersion[])
{
	int nResult  = false;
	int nRetCode = false;
	FILE*  pVerFile = NULL;
	TCHAR* pszRet   = NULL;
	size_t uLength = 0;
	long lOffset = 0L;
	TCHAR szBuffer[MAX_PATH];

	ASSERT(cszFilePath);
	ASSERT(cszVersion);

	//修改版本信息文件中的版本号,用于测试需要
	nRetCode = _tfopen_s(&pVerFile, cszFilePath, _T("r+"));
	KGLOG_PROCESS_ERROR(nRetCode == 0);
	uLength = _tcslen(PRODUCT_VERSION_KEY);
	while (TRUE)
	{
		pszRet = _fgetts(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), pVerFile);
		if (!pszRet)
		{
			nRetCode = ferror(pVerFile);
			KGLOG_PROCESS_ERROR(nRetCode == 0);
			KG_PROCESS_SUCCESS(nRetCode == 0);
		}
		szBuffer[sizeof(szBuffer) / sizeof(TCHAR) - 1] = _T('\0');
		if (szBuffer[0] != _T('#'))
		{
			nRetCode = _tcsncicmp(szBuffer, PRODUCT_VERSION_KEY, uLength);
			if (!nRetCode && szBuffer[uLength] == _T('='))
			{
				lOffset += (long)uLength + 1;
				nRetCode = fseek(pVerFile, lOffset, SEEK_SET); 
				KGLOG_PROCESS_ERROR(nRetCode == 0);
				nRetCode = _fputts(cszVersion, pVerFile);
				KGLOG_PROCESS_ERROR(nRetCode != EOF && nRetCode != WEOF);
				KG_PROCESS_SUCCESS(true);
			}
		}
		lOffset += (long)_tcslen(szBuffer) + 1;
	}

Exit1:
	nResult = true;
Exit0:
	if (pVerFile)
	{
		fclose(pVerFile);
		pVerFile = NULL;
	}
	return nResult;
}
Beispiel #10
0
int KTestCommon::GetCurVersion(const TCHAR cszFilePath[], OUT TCHAR* pRetCurVersion)
{
	int nResult  = false;
	int nRetCode = false;
	FILE*  pVerFile = NULL;
	TCHAR* pszRet   = NULL;
	size_t uLength = 0;
	long lOffset = 0L;
	TCHAR szBuffer[MAX_PATH] = {0};
	static const int sc_nVersionLen = (int)_tcslen(_T("1-0-8-1505")) + 1;

	ASSERT(cszFilePath);
	ASSERT(pRetCurVersion);

	nRetCode = _tfopen_s(&pVerFile, cszFilePath, _T("r"));
	KGLOG_PROCESS_ERROR(nRetCode == 0);
	uLength = _tcslen(PRODUCT_VERSION_KEY);
	while (TRUE)
	{
		pszRet = _fgetts(szBuffer, sizeof(szBuffer) / sizeof(TCHAR), pVerFile);
		if (!pszRet)
		{
			nRetCode = ferror(pVerFile);
			KGLOG_PROCESS_ERROR(nRetCode == 0);
			KG_PROCESS_SUCCESS(nRetCode == 0);
		}
		szBuffer[sizeof(szBuffer) / sizeof(TCHAR) - 1] = _T('\0');
		if (szBuffer[0] != _T('#'))
		{
			nRetCode = _tcsncicmp(szBuffer, PRODUCT_VERSION_KEY, uLength);
			if (!nRetCode && szBuffer[uLength] == _T('='))
			{
				lOffset += (long)uLength + 1;
				nRetCode = fseek(pVerFile, lOffset, SEEK_SET); 
				KGLOG_PROCESS_ERROR(nRetCode == 0);
				pszRet = _fgetts(pRetCurVersion, sc_nVersionLen * sizeof(TCHAR), pVerFile);
				KGLOG_PROCESS_ERROR(pszRet);
				KG_PROCESS_SUCCESS(true);
			}
		}
		lOffset += (long)_tcslen(szBuffer) + 1;
	}

Exit1:
	nResult = true;
Exit0:
	if (pVerFile)
	{
		fclose(pVerFile);
		pVerFile = NULL;
	}
	return nResult;
}
Beispiel #11
0
int KRLTarget::Update(double /* fTime */, double /* fTimeLast */, DWORD /* dwGameLoop */, BOOL /* bFrame */)
{
	int nRetCode = false;
    int nResult = false;
	HRESULT hr = E_FAIL;

    StartProfile(&g_pRL->m_Profile, KRLPROFILE_TARGET);

    nRetCode = m_nObjectType == RL_OBJECT_UNKNOWN;
	KG_PROCESS_SUCCESS(nRetCode);

	nRetCode = m_ap3DModel[m_nRLForceRelation] == NULL;
	KG_PROCESS_SUCCESS(nRetCode);

    switch (m_nObjectType)
    {
    case RL_OBJECT_PLAYER:
    case RL_OBJECT_NPC:
        {
            KRLRemoteCharacter* pRLRemoteCharacter = NULL;

            pRLRemoteCharacter = m_pRLScene->m_CharacterMgr.Lookup(m_dwObjectID);
            if (pRLRemoteCharacter)
            {
                pRLRemoteCharacter->m_RLCharacter.GetPosition(m_vPosition);
            }
            else
            {
                m_vPosition = D3DXVECTOR3(0.0f, 0.0f, 0.0f);

                hr = Hide();
                KGLOG_COM_PROCESS_ERROR(hr);
            }
        }
        break;
    case RL_OBJECT_DOODAD:
    case RL_OBJECT_RIDES:
        break;
    default:
        ASSERT(0);
        break;
    }

	hr = KModel::SetPosition(m_ap3DModel[m_nRLForceRelation], m_vPosition);
	KGLOG_COM_PROCESS_ERROR(hr);

Exit1:
	nResult = true;
Exit0:
    StopProfile(&g_pRL->m_Profile, KRLPROFILE_TARGET);
	return nResult;
}
Beispiel #12
0
void KAIBase::OnAlert(void)
{
	KCharacter* pTarget     = NULL;
	BOOL        bRetCode    = FALSE;

    bRetCode = m_pSelf->m_SelectTarget.GetTarget(&pTarget);
    KG_PROCESS_ERROR(bRetCode && pTarget);

	if (pTarget)
	{
		//目标超出范围
		int nDistance2 = g_GetDistance2(m_pSelf->m_nX, m_pSelf->m_nY, pTarget->m_nX, pTarget->m_nY);

		//按等级修正距离
		int nCheckDistance2 = (int)(m_pAIParam->nAlertRange * m_pAIParam->nAlertRange);

		KG_PROCESS_ERROR(nDistance2 <= nCheckDistance2);

		//朝向目标
		int nDirection  = g_GetDirection(m_pSelf->m_nX, m_pSelf->m_nY, pTarget->m_nX, pTarget->m_nY);
		if (m_pSelf->m_nFaceDirection != nDirection)
		{
			m_pSelf->Turn(nDirection, true, true);
		}
	

		//目标未丢失, 看是否超时
		if (g_pSO3World->m_nGameLoop > m_AlertData.nAlartFrame)
		{
			//超时,进行攻击
			m_pSelf->m_ThreatList.ModifyThreat(pTarget, 0);
			TurnToFight();
			return;
		}
	}
	
	bRetCode = CheckTargetInAttackRange();
	KG_PROCESS_SUCCESS(bRetCode);

	return;
Exit0:
	bRetCode = CheckTargetInAttackRange();
	KG_PROCESS_SUCCESS(bRetCode);
	 
	//什么都没有了,出警戒状态,开始发呆
	ClearTarget();
	DoIdle(1);

	return; 
Exit1:
	return;
}
Beispiel #13
0
float KRLTarget::GetDefaultScale() const
{
    int nResult = false;
	HRESULT hr = E_FAIL;
	D3DXVECTOR3 vObjectMin;
	D3DXVECTOR3 vObjectMax;
	IKG3DModel* p3DModel = NULL;
	float fScale = 1.0f;
	float fObjectDiagonal = 0.0f;

	p3DModel = m_ap3DModel[m_nRLForceRelation];
	KG_PROCESS_SUCCESS(p3DModel == NULL);

    switch (m_nObjectType)
    {
    case RL_OBJECT_PLAYER:
    case RL_OBJECT_NPC:
        {
            KRLRemoteCharacter* pRLRemoteCharacter = NULL;

            pRLRemoteCharacter = m_pRLScene->m_CharacterMgr.Lookup(m_dwObjectID);
            KG_PROCESS_SUCCESS(pRLRemoteCharacter == NULL);

            hr = pRLRemoteCharacter->m_RLCharacter.GetBBox(vObjectMin, vObjectMax);
            KGLOG_COM_PROCESS_ERROR(hr);
        }
        break;
    case RL_OBJECT_DOODAD:
    case RL_OBJECT_RIDES:
        KG_ASSERT_EXIT(0);
        break;
    default:
        KG_ASSERT_EXIT(0);
        break;
    }

	fObjectDiagonal = GetXZPlanePointDistance(vObjectMin, vObjectMax);
	fScale = fObjectDiagonal / m_aModelDiagonal[m_nRLForceRelation];

Exit1:
	nResult = true;
Exit0:
    if (!nResult)
    {
        fScale = 1.0f;
    }
	return fScale;
}
Beispiel #14
0
void KAIBase::OnClearThreat(KCharacter* pCharater)
{
	BOOL bResult = FALSE;

	bResult = IS_PLAYER(m_pSelf->m_dwID);
	KG_PROCESS_SUCCESS(bResult == TRUE);

	// Npc仇恨链接时,会连锁清空仇恨
	if (m_pNpcTeam)
	{
		KNpc* pNpc = NULL;
		int nIndex = 0;
		int nMemberCount = m_pNpcTeam->GetMemberCount();

		for (nIndex = 0; nIndex < nMemberCount; nIndex++)
		{
			pNpc = m_pNpcTeam->GetMember(nIndex);
			if (pNpc && pNpc != m_pSelf && pNpc != pCharater)
			{
				bResult = pNpc->m_ThreatList.ClearThreat(pCharater);
				KGLOG_PROCESS_ERROR(bResult);
			}
		}
	}

Exit1:
	return;
Exit0:
	return;
}
Beispiel #15
0
HRESULT KG3DEnvEffDWController::FrameMove()
{
    KG_PROCESS_SUCCESS(NULL == m_pObj);
    if (m_bIsBlending)	///正在渐变
    {
        _ASSERTE(m_fBlendPercent > 0- FLT_EPSILON);
        DWORD dwNowTime = g_cGraphicsTool.GetNowTime();
        _ASSERTE(dwNowTime > 0.0f);

        m_fBlendPercent = (dwNowTime - m_dwBlendStartMiliSecond) / (m_fNextBlendGap);
        _ASSERTE(m_fBlendPercent >= 0.0f);

        if (m_fBlendPercent < 1.0f)
        {
            m_pObj->AllEnvEff_SetPercent(m_fBlendPercent);
            goto Exit1;
        }

        m_fBlendPercent = 0;///归0

        _ASSERTE(m_BlendQueue.size() == 1);
        m_BlendQueue.pop();

        m_pObj->AllEnvEff_RequestPopFrontState();
        this->UnInitBlendData();
    }///if (m_bIsBlending)	///正在渐变
Exit1:
    return S_OK;
}
Beispiel #16
0
HRESULT KRLTarget::AdjustScale()
{
	HRESULT hr = E_FAIL;
	HRESULT hrResult = E_FAIL;
	IKG3DModel* p3DModel = NULL;
	float fScale = 1.0f;

	p3DModel = m_ap3DModel[m_nRLForceRelation];
	KG_PROCESS_SUCCESS(p3DModel == NULL);

	switch (m_nObjectType)
	{
	case RL_OBJECT_PLAYER:
    case RL_OBJECT_NPC:
        fScale = GetCharcterScale();
		break;
	case RL_OBJECT_UNKNOWN:
        break;
	case RL_OBJECT_DOODAD:	/* fall through */
    case RL_OBJECT_RIDES:
		fScale = GetDefaultScale();
		break;
	};

	hr = KModel::SetScale(p3DModel, fScale);
	KGLOG_COM_PROCESS_ERROR(hr);

Exit1:
	hrResult = S_OK;
Exit0:
	return hrResult;
}
int KCircleMissileProcessor::Start(double fTime, KRLMissile* pRLMissile)
{
	int nRetCode = false;
    int nResult = false;
	KSkill const* pSkill = NULL;
    KMissilePhaseCircleModel* pCircleModel = NULL;
	KCircleMissileParam BeginParam;
	KCircleMissileParam EndParam;

	float fBulletVelocity = 0.0f;

    ASSERT(m_pRLMissile);
    ASSERT(m_pMissilePhaseModel);

    pCircleModel = (KMissilePhaseCircleModel*)m_pMissilePhaseModel;

    pSkill = g_pRL->m_pSO3WorldClient->GetSkill(m_pRLMissile->m_Param.Result.dwSkillID, m_pRLMissile->m_Param.Result.dwSkillLevel);
	KGLOG_PROCESS_ERROR(pSkill);

	// begin
    BeginParam.fLineHeight = ToSceneLength(pCircleModel->nLineHeightBegin);
	BeginParam.fCircleRadius = ToSceneLength(pCircleModel->nCircleRadiusBegin);
	BeginParam.fTerrainOffset = ToSceneLength(pCircleModel->nTerrainOffsetBegin);
	BeginParam.fFOV = ToSceneAngle(pCircleModel->nFOVBegin);
	BeginParam.fFOVAngleVelocity = ToSceneAngleVelocity(pCircleModel->nFOVAngleVelocityBegin);

	// end
    EndParam.fLineHeight = ToSceneLength(pCircleModel->nLineHeightEnd);
	EndParam.fCircleRadius = ToSceneLength(pCircleModel->nCircleRadiusEnd);
	EndParam.fTerrainOffset = ToSceneLength(pCircleModel->nTerrainOffsetEnd);
	EndParam.fFOV = ToSceneAngle(pCircleModel->nFOVEnd);
	EndParam.fFOVAngleVelocity = ToSceneAngleVelocity(pCircleModel->nFOVAngleVelocityEnd);

	// Bullet
	fBulletVelocity = ToSceneVelocity(pSkill->m_nBulletVelocity);

    nRetCode = abs(fBulletVelocity) > FLT_EPSILON;
    KG_PROCESS_SUCCESS(!nRetCode);

    // Track Parameter
    m_fMeteorSpeed = fBulletVelocity * pCircleModel->fSpeedScale;
    m_fMeteorRadius = ToSceneLength(pCircleModel->nMeteorRadius);
    m_fTotalModelScale = pCircleModel->fModelScaleEnd - pCircleModel->fModelScaleBegin;
    m_fParabolaAngle = ToSceneAngle(pCircleModel->nParabolaAngle);

	m_fTotalDistance = EndParam.fLineHeight - BeginParam.fLineHeight;

	nRetCode = InitCircleMissileOrientationData(BeginParam, EndParam);
	KGLOG_PROCESS_ERROR(nRetCode);

    if (m_fTotalDistance <= FLT_EPSILON)
        SetTimeTotal(pCircleModel->fPervasionTime);
    else
        SetTimeTotal(m_fTotalDistance / fBulletVelocity);

Exit1:
	nResult = true;
Exit0:
	return nResult;
}
Beispiel #18
0
BOOL KAwardMgr::GetRoomSizeToAwardAll(DWORD dwAwardTableID, int(&RoomSize)[eppiTotal])
{
    BOOL            bResult     = false;
    BOOL            bRetCode    = false;
    KAwardTable*    pAwardTable = NULL;
    KAWARD_ITEM*    pAwardItem  = NULL;
    int             nPackageIndex   = 0;

    memset(RoomSize, 0, sizeof(RoomSize));
    KG_PROCESS_SUCCESS(dwAwardTableID == ERROR_ID);

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

    for (KAWARD_ITEM_MAP::iterator it = pAwardTable->m_mapAwardItem.begin(); it != pAwardTable->m_mapAwardItem.end(); ++it)
    {
        pAwardItem = &it->second;

        if (pAwardItem->dwTabType == 0)
            continue;

        RoomSize[eppiPlayerItemBox] += 1;
    }

Exit1:
    bResult = true;
Exit0:
    return bResult;
}
Beispiel #19
0
void KAIBase::OnReturn(void)
{
	int nRetCode = cmsInvalid;
	BOOL bRetCode = FALSE;

	bRetCode = CheckReturn();
	KG_PROCESS_SUCCESS(bRetCode);

	nRetCode = m_pSelf->m_eMoveState;

	if (nRetCode == cmsOnStand)
	{
		int nDir = g_GetDirection(m_pSelf->m_nX, m_pSelf->m_nY, m_nReturnX, m_nReturnY);
		m_pSelf->Turn(nDir, true, true);

		// 跑回ReturnPoint
		//KGLogPrintf(KGLOG_DEBUG, "[AI] Return Run to (%d, %d)\n", m_nReturnX, m_nReturnY);
		m_pSelf->RunTo(m_nReturnX, m_nReturnY);
	}

	return;
Exit1:
	//返回原点了,停一秒
	if (m_pNpcTeam)
		DoWait();
	else
		DoIdle(GAME_FPS);

	return;
}
Beispiel #20
0
IKG3Profile_Recorder *KG3DProfile_Manager_Imp::GetRecord(unsigned uUnionID, const char cszName[])
{
    IKG3Profile_Recorder *pRecorder = NULL;
    KG3Profile_Recorder_Imp *pNewRecorder = NULL;
    RECORDER_MAP::iterator itExist;

    ASSERT(cszName);

    KG_PROCESS_SUCCESS(!m_nEnableProfileFlag);

    itExist = m_RecorderMap.find(uUnionID);
    if (itExist != m_RecorderMap.end())
    {
        pRecorder = itExist->second;
    }
    else
    {
        RECORDER_MAP::_Pairib InsertResult;
        pNewRecorder = new KG3Profile_Recorder_Imp(cszName);
        KGLOG_PROCESS_ERROR(pNewRecorder);

        InsertResult = m_RecorderMap.insert(make_pair(uUnionID, pNewRecorder));
        ASSERT(InsertResult.second);

        pRecorder = pNewRecorder;
        pNewRecorder = NULL;
    }
Exit1:
Exit0:
    KG_DELETE(pNewRecorder);
    return pRecorder;
}
Beispiel #21
0
void KG3DAnimationComposer::AddAnimation(KG3DAnimationUpdateExtraInfoCollector *pCollector, 
                                         DWORD dwIndex)
{
    size_t i = 0;
	KG_PROCESS_ERROR(m_SkeletonInfo.size());
	KG_PROCESS_ERROR(m_pModel);
    
	for (i = 0; i < m_SkeletonInfo[0].Info.size(); i++)
    {
        if (pCollector == m_SkeletonInfo[0].Info[i].pCollector)
            break;
    }
    
	//如果找到了存在的Colletor就不用创建新的了
	KG_PROCESS_SUCCESS(i != m_SkeletonInfo[0].Info.size());
    
	for (i = 0; i < m_SkeletonInfo.size(); i++)
    {
        BoneInfoItem Item;
        Item.pCollector = pCollector;
        Item.dwIndex = dwIndex;
        m_SkeletonInfo[i].Info.push_back(Item);
    }
    m_Controller.resize(m_Controller.size() + 1);
	m_TweenTimeInfo.resize(m_TweenTimeInfo.size() + 1);
	m_TweenTimeInfo[m_TweenTimeInfo.size() - 1].Init(m_pSkeleton->GetNumBones());
Exit1:
Exit0:
    return;
}
Beispiel #22
0
void KG3DAnimationComposer::SetSkeleton(KG3DSkeleton* pSkeleton)
{
    HRESULT hrResult = E_FAIL;
    DWORD dwBoneNum = 0;

    m_SkeletonInfo.clear();
    m_pSkeleton = pSkeleton;
    KG_PROCESS_SUCCESS(!m_pSkeleton);

    dwBoneNum = (DWORD)m_pSkeleton->GetNumBones();

    m_SkeletonInfo.resize(dwBoneNum);
	
    KG_DELETE_ARRAY(m_pWorldResult);
    m_pWorldResult = new D3DXMATRIX[dwBoneNum];
    KG_PROCESS_ERROR(m_pWorldResult);

Exit1:
    hrResult = S_OK;
Exit0:
    if (FAILED(hrResult))
    {
        KG_DELETE_ARRAY(m_pWorldResult);
    }
}
Beispiel #23
0
BOOL KLogClient::Send(IKG_Buffer* piBuffer)
{
    BOOL                        bResult      = false;
    int                         nRetCode     = false;
    INTERNAL_PROTOCOL_HEADER*   pHeader      = NULL;
    size_t                      uPakSize     = 0;

    assert(piBuffer);
    KG_PROCESS_SUCCESS(m_piSocketStream == NULL);
    KG_PROCESS_ERROR(!m_bSocketError);

    uPakSize = piBuffer->GetSize();
    assert(uPakSize >= sizeof(INTERNAL_PROTOCOL_HEADER));

    pHeader = (INTERNAL_PROTOCOL_HEADER*)piBuffer->GetData();
    KGLOG_PROCESS_ERROR(pHeader);

    assert(pHeader->wProtocolID > g2l_protocol_begin);
    assert(pHeader->wProtocolID < g2l_protocol_end);

    nRetCode = m_piSocketStream->Send(piBuffer);
    if (nRetCode != 1)
    {
        m_bSocketError = true;
        goto Exit0;
    }

    m_nLastSendPacketTime = g_pSO3World->m_nCurrentTime;

Exit1:
    bResult = true;
Exit0:
    return bResult;
}
HRESULT KG3DResourceDelayReleaseMgr::Push(IUnknown *pResource)
{
    HRESULT         hrResult        = E_FAIL;
    RESOURCE_BLOCK *pResourceBlock  = NULL;

    KG_PROCESS_SUCCESS(!pResource);
    
    if (g_bDelayRelease)
    {
        pResourceBlock = (RESOURCE_BLOCK *)KMemory::RawAlloc(sizeof(RESOURCE_BLOCK));
        KGLOG_PROCESS_ERROR(pResourceBlock);

        pResourceBlock->pResource = pResource;
        pResourceBlock->Link.Next = NULL;

        KG_InterlockedPushEntrySList(&g_ResourceListHead, &pResourceBlock->Link);
    }
    else
    {
        SAFE_RELEASE(pResource);
    }

Exit1:
    hrResult = S_OK;
Exit0:
    return hrResult;
}
Beispiel #25
0
int LoadConfig(BOOL *pnIsClient, char *pszDir, unsigned uSize)
{
    int nResult = false;
    int nRetCode = false;
    const char CONFIGFILE[] = "KG_BoneChecker.ini";
    IIniFile *piFile = NULL;

    *pnIsClient = false;

    piFile = g_OpenIniFile(CONFIGFILE);
    KGLOG_PROCESS_ERROR(piFile);
    
    nRetCode = piFile->GetString("BoneChecker", "SO3ClientDir", "", pszDir, uSize);
    KGLOG_PROCESS_ERROR(nRetCode);

    if (strcmp(pszDir, ""))
    {
        *pnIsClient = true;
        KG_PROCESS_SUCCESS(true);
    }

    nRetCode = piFile->GetString("BoneChecker", "bipdir", "", pszDir, uSize);
    KGLOG_PROCESS_ERROR(nRetCode);

Exit1:
    nResult = true;
Exit0:
    if (!nResult)
        puts("!!!Read Config File Failed.");
    KG_COM_RELEASE(piFile);
    return nResult;
}
Beispiel #26
0
int KTgaManager::IsTgaPosSeted(LPCTSTR pcszName)
{
    int nResult = false;
    int nRetCode = false;
    TCHAR szName[MAX_PATH];
    KG_PROCESS_ERROR(pcszName);

    for (KTgaBlockArray::iterator it = m_aTgaBlock.begin(); it != m_aTgaBlock.end(); ++it) 
    {
        ASSERT(*it);
        if (!((*it)->IsPosHasBeenSeted()))
            continue;

        (*it)->GetName(szName, sizeof(szName) / sizeof(TCHAR));
        nRetCode = _tcsicmp(pcszName, szName); 
        KG_PROCESS_SUCCESS(nRetCode == 0);
    }

    KG_PROCESS_ERROR(true);

Exit1:
    nResult = true;
Exit0:
    return nResult;
}
Beispiel #27
0
int KTestCommon::CloseAndWaitForProcess(HANDLE hProcess)
{
	int nResult  = false;
	int nRetCode = false;
	int nSleepTimes  = 0;
	DWORD dwExitCode = 0;

	nRetCode = ::TerminateProcess(hProcess, 4);
	if (!nRetCode)
	{
		KGLogPrintf(KGLOG_ERR, "Terminate Process Failed");
		KG_PROCESS_ERROR(false);
	}

	//每1秒查看一次进程状态,MAX_TIMEOUT毫秒后如果还是激活状态,就认为关闭失败
	nSleepTimes = MAX_TIMEOUT / 1000;
	for (int i = 0; i < nSleepTimes; i++)
	{
		nRetCode = ::GetExitCodeProcess(hProcess, &dwExitCode);
		KGLOG_PROCESS_ERROR(nRetCode);
		KG_PROCESS_SUCCESS(dwExitCode != STILL_ACTIVE);
		::Sleep(1000);
	}

Exit1:
	nResult = true;
Exit0:
	::CloseHandle(hProcess);
	return nResult;
}
Beispiel #28
0
int KTgaManager::IsFrameShoudBeSaved(LPCTSTR pcszName)
{
    int nResult = false;
    int nRetCode = false;
    TCHAR szName[MAX_PATH];
    KTgaBlock *pBlock = NULL;
    KG_PROCESS_ERROR(pcszName);

    for (KTgaBlockArray::iterator it = m_aTgaBlock.begin(); it != m_aTgaBlock.end(); ++it) 
    {
        pBlock = (*it);
        ASSERT(pBlock);

        pBlock->GetName(szName, sizeof(szName) / sizeof(TCHAR));
        nRetCode = _tcsicmp(pcszName, szName); 
        if (!nRetCode)
            continue;

        //KG_PROCESS_SUCCESS(!(pBlock->IsIndexChangeable()));
        KG_PROCESS_SUCCESS(pBlock->IsPosHasBeenSeted());
    }

    KG_PROCESS_ERROR(true);

Exit1:
    nResult = true;
Exit0:
    return nResult;
}
Beispiel #29
0
BOOL KAwardMgr::GetAwardItemValuePoint(KAWARD_ITEM* pAwardItem, int& nValuePoint)
{
	BOOL bResult  = false;
	BOOL bRetCode = false;
    KGItemInfo* pItemInfo = NULL;

	KGLOG_PROCESS_ERROR(pAwardItem);

    nValuePoint = 0;

    KG_PROCESS_SUCCESS(pAwardItem->dwTabType != ittEquip);

    if (pAwardItem->nQualityLevel != -1)
    {
        pItemInfo = g_pSO3World->m_ItemHouse.GetItemInfo(pAwardItem->dwTabType, pAwardItem->dwIndex);
        KGLOG_PROCESS_ERROR(pItemInfo);

        nValuePoint = g_pSO3World->m_ItemHouse.GetRandomValuePoint(pItemInfo->nLevel, pAwardItem->nQualityLevel);
    }
    else
    {
        int nDeltaValuePoint = pAwardItem->nMaxValuePoint - pAwardItem->nMinValuePoint;
        KGLOG_PROCESS_ERROR(nDeltaValuePoint >= 0);

        nValuePoint = pAwardItem->nMinValuePoint;
        if (nDeltaValuePoint > 0)
            nValuePoint += (int)g_Random(nDeltaValuePoint);
    }

Exit1:
	bResult = true;
Exit0:
	return bResult;
}
Beispiel #30
0
BOOL KGFellowshipMgr::OnLoadFellowshipData(DWORD dwPlayerID, size_t uDataSize, BYTE byData[])
{
    BOOL                bResult         = false;
    BOOL                bRetCode        = false;
    KG_FELLOWSHIP_DB*   pFellowshipDB   = NULL;

    UnloadPlayerFellowship(dwPlayerID);
    m_GroupNamesMap[dwPlayerID].nGroupCount = 0;

    KG_PROCESS_SUCCESS(!uDataSize); // This player do not have any fellowship data saved before. 

    KGLOG_PROCESS_ERROR(uDataSize > sizeof(KG_FELLOWSHIP_DB));
    pFellowshipDB = (KG_FELLOWSHIP_DB*)byData;

    switch(pFellowshipDB->nVersion)
    {
    case 1:
        bRetCode = OnLoadFellowshipDataV1(dwPlayerID, uDataSize, byData);
        KGLOG_PROCESS_ERROR(bRetCode);
        break;

    default:
        KGLogPrintf(KGLOG_ERR, "Unexcepted fellowship data type: %d.", pFellowshipDB->nVersion);
    }

Exit1:
    m_OnlineIDSet.insert(dwPlayerID);
    bResult = true;
Exit0:
    if (!bResult)
    {
        UnloadPlayerFellowship(dwPlayerID);
    }
    return bResult;
}