当前位置: 首页>>代码示例>>C++>>正文


C++ CContextData::GetPad方法代码示例

本文整理汇总了C++中CContextData::GetPad方法的典型用法代码示例。如果您正苦于以下问题:C++ CContextData::GetPad方法的具体用法?C++ CContextData::GetPad怎么用?C++ CContextData::GetPad使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CContextData的用法示例。


在下文中一共展示了CContextData::GetPad方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetPadFromPlayerPed

IVPad* GetPadFromPlayerPed(IVPed* pPed)
{
	if (pPed && pPed->m_pPlayerInfo && pPed->m_pPlayerInfo->m_bytePlayerNumber == 0 && pPed->m_byteIsPlayerPed) {
		// return the local player pad
		CLogFile::Printf("Return local pad");
		return ((IVPad*(__cdecl*)())(g_pCore->GetBase() + 0x7FD960))();
	}
	else if (pPed->m_byteIsPlayerPed) {
		// Do we have a valid ped pointer?
		if (pPed) {
			// Get the remote players context data
			CContextData * pContextData = CContextDataManager::GetContextData((IVPlayerPed *) pPed);

			// Do we have a valid context data?
			if (pContextData) {
#if 0 // Disabled maybe not needed
				for (int i = 0; i < INPUT_COUNT; i++)
				{
					IVPadData * pPadData = &pContextData->GetPad()->GetPad()->m_padData[i];

					if (pPadData->m_pHistory)
					{
						pPadData->m_byteHistoryIndex++;

						if (pPadData->m_byteHistoryIndex >= MAX_HISTORY_ITEMS)
							pPadData->m_byteHistoryIndex = 0;

						pPadData->m_pHistory->m_historyItems[pPadData->m_byteHistoryIndex].m_byteValue = pPadData->m_byteLastValue;
						pPadData->m_pHistory->m_historyItems[pPadData->m_byteHistoryIndex].m_dwLastUpdate = CGameFunction::GetTimeOfDay();
					}
				}
#endif

				CLogFile::Printf("Return remote pad");
				// return our sync pad
				return pContextData->GetPad()->GetPad();
			}
		}
	}
	return nullptr;
}
开发者ID:B2O,项目名称:IV-Network,代码行数:41,代码来源:CContextSwitch.cpp

示例2: ContextSwitch

void ContextSwitch(IVPed * pPed, bool bPost)
{
    // Do we have a valid ped pointer?
    if(pPed)
    {
        // Get the game pad
        CIVPad * pPad = g_pClient->GetGame()->GetPad();

        /*CContextData * pTestContextInfo = CContextDataManager::GetContextData((IVPlayerPed *)pPed);
        CIVPad * pTestPad = g_pClient->GetGame()->GetPad();
        bool bLocalPlayer = ((IVPlayerPed *)pPed == CPools::GetPlayerInfoFromIndex(0)->m_pPlayerPed);
        if(!bLocalPlayer && pTestContextInfo)
        {
        	pTestPad = pTestContextInfo->GetPad();
        }
        CClientPadState curPad;
        CClientPadState lasPad;
        pTestPad->GetCurrentClientPadState(curPad);
        pTestPad->GetLastClientPadState(lasPad);
        if(curPad.byteKeys[INPUT_MELEE_KICK] && !lasPad.byteKeys[INPUT_MELEE_KICK])
        {
        	CLogFile::Printf("(%d) Melee kick start hold", bLocalPlayer);
        	if(bLocalPlayer)
        		bRecordHistory = true;
        	else
        		bRecordHistory2 = true;
        }
        if(bRecordHistory || bRecordHistory2)
        {
        	CLogFile::Printf("(%d) Current history taken at %d is %d", bLocalPlayer, pTestPad->GetPad()->m_padData[INPUT_MELEE_KICK].m_pHistory->m_historyItems[pTestPad->GetPad()->m_padData[INPUT_MELEE_KICK].m_byteHistoryIndex].m_dwLastUpdateTime, pTestPad->GetPad()->m_padData[INPUT_MELEE_KICK].m_pHistory->m_historyItems[pTestPad->GetPad()->m_padData[INPUT_MELEE_KICK].m_byteHistoryIndex].m_byteValue);
        }
        if(!curPad.byteKeys[INPUT_MELEE_KICK] && lasPad.byteKeys[INPUT_MELEE_KICK])
        {
        	CLogFile::Printf("(%d) Melee kick end hold", bLocalPlayer);
        	if(bLocalPlayer)
        		bRecordHistory = false;
        	else
        		bRecordHistory2 = false;
        }*/

        // Is this not the local player ped?
        if((IVPlayerPed *)pPed != CPools::GetPlayerInfoFromIndex(0)->m_pPlayerPed)
        {
            if(!bPost && !bInLocalContext)
            {
                CLogFile::Printf("Not switching due to not being in local context!");
                return;
            }

            if(bPost && bInLocalContext)
            {
                CLogFile::Printf("Not switching due to being in local context!");
                return;
            }

            // Get the remote players context info
            CContextData * pContextInfo = CContextDataManager::GetContextData((IVPlayerPed *)pPed);

            // Do we have a valid context info?
            if(pContextInfo)
            {
                //CLogFile::SetUseCallback(false);
                //CLogFile::Printf("ContextSwitch(0x%p, %d) (Player Ped %d)", pPed, bPost, pContextInfo->GetPlayerInfo()->GetPlayerNumber());
                //CLogFile::SetUseCallback(true);

                if(!bPost)
                {
                    // Store the local players index
                    m_uiLocalPlayerIndex = CPools::GetLocalPlayerIndex();

                    // Store the local players pad
                    memcpy(&m_localPad, pPad->GetPad(), sizeof(IVPad));

                    // Store the local players camera matrix
                    GetGameCameraMatrix(&m_matLocalCameraMatrix);

                    // Swap the local player index with the remote players index
                    CPools::SetLocalPlayerIndex(pContextInfo->GetPlayerInfo()->GetPlayerNumber());

                    // Set the history values
                    for(int i = 0; i < INPUT_COUNT; i++)
                    {
                        CPadData * pPadData = &pContextInfo->GetPad()->GetPad()->m_padData[i];

                        if(pPadData->m_pHistory)
                        {
                            pPadData->m_byteHistoryIndex++;

                            if(pPadData->m_byteHistoryIndex >= MAX_HISTORY_ITEMS)
                                pPadData->m_byteHistoryIndex = 0;

                            pPadData->m_pHistory->m_historyItems[pPadData->m_byteHistoryIndex].m_byteValue = pContextInfo->GetPad()->GetPad()->m_padData[i].m_byteLastValue;
                            pPadData->m_pHistory->m_historyItems[pPadData->m_byteHistoryIndex].m_dwLastUpdateTime = g_pClient->GetGame()->GetTime();
                        }
                    }

                    // Swap the local players pad with the remote players pad
                    memcpy(pPad->GetPad(), pContextInfo->GetPad()->GetPad(), sizeof(IVPad));

                    // Swap the local players camera matrix with the remote players camera matrix
//.........这里部分代码省略.........
开发者ID:killserver,项目名称:GTA-IV,代码行数:101,代码来源:KeySync.cpp

示例3: ContextSwitch

void ContextSwitch(IVPed * pPed, bool bPost) 
{
	// Do we have a valid ped pointer?
	if(pPed) {
		// Get the remote players context data
		CContextData * pContextData = CContextDataManager::GetContextData((IVPlayerPed *)pPed);

		// Do we have a valid context data?
		if(pContextData) {
			// Is this not the local player?
			if(pContextData->GetPlayerInfo()->GetPlayerNumber() != 0) {
				if(!bPost && !g_bInLocalContext) {
					CLogFile::Printf("Not switching due to not being in local context!");
					return;
				}

				if(bPost && g_bInLocalContext) {
					CLogFile::Printf("Not switching due to being in local context!");
					return;
				}

				// Get the game pad
				CIVPad * pPad = g_pCore->GetGame()->GetPad();

				if(!bPost) {
					// Store the local players index
					g_uiLocalPlayerIndex = g_pCore->GetGame()->GetPools()->GetLocalPlayerIndex();

					// Store the local players pad
					memcpy(&g_localPad, pPad->GetPad(), sizeof(IVPad));

					g_pLocalPlayerInfo = g_pCore->GetGame()->GetPools()->GetPlayerInfoFromIndex(g_uiLocalPlayerIndex);

					g_pCore->GetGame()->GetPools()->SetPlayerInfoAtIndex(g_uiLocalPlayerIndex, pContextData->GetPlayerInfo()->GetPlayerInfo());

					// Set the history values
					for(int i = 0; i < INPUT_COUNT; i++) {
						IVPadData * pPadData = &pContextData->GetPad()->GetPad()->m_padData[i];

						if(pPadData->m_pHistory) {
							pPadData->m_byteHistoryIndex++;

							if(pPadData->m_byteHistoryIndex >= MAX_HISTORY_ITEMS)
								pPadData->m_byteHistoryIndex = 0;

							pPadData->m_pHistory->m_historyItems[pPadData->m_byteHistoryIndex].m_byteValue = pPadData->m_byteLastValue;
							pPadData->m_pHistory->m_historyItems[pPadData->m_byteHistoryIndex].m_dwLastUpdate = CGameFunction::GetTimeOfDay();
						}
					}

					// Swap the local players pad with the remote players pad
					memcpy(pPad->GetPad(), pContextData->GetPad()->GetPad(), sizeof(IVPad));

					// Flag ourselves as no longer in local context
					g_bInLocalContext = false;
				}
				else {
					// Restore the local players pad
					memcpy(pPad->GetPad(), &g_localPad, sizeof(IVPad));

					g_pCore->GetGame()->GetPools()->SetPlayerInfoAtIndex(g_uiLocalPlayerIndex, g_pLocalPlayerInfo);

					// Flag ourselves as back in local context
					g_bInLocalContext = true;
				}
			}
		}
		else
			CLogFile::Printf("ContextSwitch Warning: Invalid Player Ped");
	}
}
开发者ID:B2O,项目名称:IV-Network,代码行数:71,代码来源:CContextSwitch.cpp


注:本文中的CContextData::GetPad方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。