本文整理汇总了C++中CContextData类的典型用法代码示例。如果您正苦于以下问题:C++ CContextData类的具体用法?C++ CContextData怎么用?C++ CContextData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CContextData类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: StoreAimTarget
void StoreAimTarget(EFLC::IPed * pPed, CVector3 * vecWeaponTarget)
{
// Do we have a valid ped pointer and target pointer?
if(pPed && vecWeaponTarget)
{
// Get the remote players context data
CContextData * pContextData = CContextDataManager::GetContextData((EFLC::IPlayerPed *)pPed);
// Do we have a valid context data?
if(pContextData)
{
// Is this the local player?
if(pContextData->GetPlayerInfo()->GetPlayerNumber() == 0)
{
pContextData->SetWeaponAimTarget(*vecWeaponTarget);
}
else
{
pContextData->GetWeaponAimTarget(*vecWeaponTarget);
}
}
else
CLogFile::PrintDebugf("StoreAimTarget Warning: Invalid Player Ped");
}
}
示例2: GetLocalPlayerPed
IVPlayerPed * GetLocalPlayerPed()
{
// Default to the local player ped (If available)
IVPlayerInfo * pPlayerInfo = g_pCore->GetGame()->GetPools()->GetPlayerInfoFromIndex(0);
if (pPlayerInfo)
_pPlayerPed = pPlayerInfo->m_pPlayerPed;
else
_pPlayerPed = NULL;
// Is the local player id valid?
if (g_pCore->GetGame()->GetPools()->GetLocalPlayerIndex() != -1)
{
// Is the player index not the local player?
if (g_pCore->GetGame()->GetPools()->GetLocalPlayerIndex() != 0)
{
// Get the context info for the player index
CContextData * pContextInfo = CContextDataManager::GetContextData((BYTE) g_pCore->GetGame()->GetPools()->GetLocalPlayerIndex());
// Is the context info valid?
if (pContextInfo)
{
// Set the player ped to the remote player
_pPlayerPed = pContextInfo->GetPlayerPed()->GetPlayerPed();
}
}
}
return _pPlayerPed;
}
示例3: GetIndexFromPlayerInfo
unsigned int GetIndexFromPlayerInfo(IVPlayerInfo * pPlayerInfo)
{
uiReturnedIndex = 0;
if (pPlayerInfo != g_pCore->GetGame()->GetPools()->GetPlayerInfoFromIndex(0))
{
CContextData * pContextInfo = CContextDataManager::GetContextData(pPlayerInfo);
if (pContextInfo)
uiReturnedIndex = pContextInfo->GetPlayerInfo()->GetPlayerNumber();
}
return uiReturnedIndex;
}
示例4: GetPlayerInfoFromIndex
IVPlayerInfo * GetPlayerInfoFromIndex(unsigned int uiIndex)
{
pReturnedPlayerInfo = g_pCore->GetGame()->GetPools()->GetPlayerInfoFromIndex(0);
if (uiIndex != 0)
{
CContextData * pContextInfo = CContextDataManager::GetContextData(uiIndex);
if (pContextInfo)
pReturnedPlayerInfo = pContextInfo->GetPlayerInfo()->GetPlayerInfo();
}
return pReturnedPlayerInfo;
}
示例5:
CContextData * CContextDataManager::GetContextData(IVPlayerInfo * pPlayerInfo)
{
// Loop through the context info list
for(std::list<CContextData *>::iterator iter = m_contextDataList.begin(); iter != m_contextDataList.end(); iter++)
{
// Get the context info pointer
CContextData * pContextInfo = *iter;
// Is this the context info we are looking for?
if(pContextInfo->GetPlayerInfo()->GetPlayerInfo() == pPlayerInfo)
return pContextInfo;
}
return NULL;
}
示例6:
CContextData * CContextDataManager::GetContextData(IVPlayerInfo * pPlayerInfo)
{
// Loop through the context data list
for(std::list<CContextData *>::iterator iter = m_contextDataList.begin(); iter != m_contextDataList.end(); iter++)
{
// Get the context data pointer
CContextData * pContextData = *iter;
// Is this the context data we're looking for?
if(pContextData->GetPlayerInfo()->GetPlayerInfo() == pPlayerInfo)
{
return pContextData;
}
}
return nullptr;
}
示例7: 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;
}
示例8: StoreArmHeadingUpDown
void StoreArmHeadingUpDown(EFLC::IPed * pPed, float * fArmHeading, float * fArmUpDown)
{
// Do we have a valid ped pointer?
if(pPed)
{
// Get the remote players context data
CContextData * pContextData = CContextDataManager::GetContextData((EFLC::IPlayerPed *)pPed);
// Do we have a valid context data?
if(pContextData)
{
// Is this the local player?
if(pContextData->GetPlayerInfo()->GetPlayerNumber() == 0)
{
pContextData->SetArmHeading(*fArmHeading);
pContextData->SetArmUpDown(*fArmUpDown);
}
else
{
pContextData->GetArmHeading(*fArmHeading);
pContextData->GetArmUpDown(*fArmUpDown);
}
}
else
CLogFile::PrintDebugf("StoreArmHeadingUpDown Warning: Invalid Player Ped");
}
}
示例9: StoreShotSourceTarget
void StoreShotSourceTarget(IVPed * pPed, CVector3 * pWeaponSource, CVector3 * pWeaponTarget)
{
// Do we have a valid ped pointer, source pointer and target pointer?
if(pPed && pWeaponSource && pWeaponTarget)
{
// Get the remote players context data
CContextData * pContextData = CContextDataManager::GetContextData((IVPlayerPed *)pPed);
// Do we have a valid context data?
if(pContextData)
{
// Is this the local player?
if(pContextData->GetPlayerInfo()->GetPlayerNumber() == 0)
{
pContextData->SetWeaponShotSource(*pWeaponSource);
pContextData->SetWeaponShotTarget(*pWeaponTarget);
}
else
{
pContextData->GetWeaponShotSource(*pWeaponSource);
pContextData->GetWeaponShotTarget(*pWeaponTarget);
}
}
else
CLogFile::PrintDebugf("StoreShotSourceTarget Warning: Invalid Player Ped");
}
}
示例10: 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
//.........这里部分代码省略.........
示例11: 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");
}
}