本文整理汇总了C++中KPlayer类的典型用法代码示例。如果您正苦于以下问题:C++ KPlayer类的具体用法?C++ KPlayer怎么用?C++ KPlayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KPlayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoTeamDelMemberNotify
BOOL QPlayerTeam::DoTeamDelMemberNotify(DWORD dwTeamID, int nGroupIndex, DWORD dwMemberID)
{
int nResult = false;
DWORD dwPlayerID = 0;
KPlayer* pPlayer = NULL;
S2C_TEAM_DEL_MEMBER_NOTIFY TeamDelMemberNotify;
QTeamBroadcast Func;
TeamDelMemberNotify.dwTeamID = dwTeamID;
TeamDelMemberNotify.nGroupIndex = nGroupIndex;
TeamDelMemberNotify.dwMemberID = dwMemberID;
pPlayer = g_cPlayerMgr.GetById(dwMemberID);
if (pPlayer)
{
QTeamModule::SendData(pPlayer->GetPlayerIndex(), TeamDelMemberNotify);
}
//else: 玩家可能不在本服务器上
// 为什么不把上面的这个Send纳入下面的循环? 因为这个玩家可能已经从列表中删除了,循环就遍历不到这个玩家.
Func.m_dwTeamID = dwTeamID;
Func.m_dwExceptID = dwMemberID;
Func.m_pvData = (void*)&TeamDelMemberNotify;
Func.m_uSize = sizeof(TeamDelMemberNotify);
g_cTeamServer.Traverse(Func);
nResult = true;
EXIT0:
return nResult;
}
示例2: DelMember
BOOL KTeamClient::DelMember(DWORD dwMemberID, int nGroupIndex)
{
BOOL bResult = false;
KPlayer* pPlayer = NULL;
KG_PROCESS_ERROR(m_dwTeamID != ERROR_ID);
KG_PROCESS_ERROR(nGroupIndex < m_nGroupNum);
for (
KTEAM_MEMBER_LIST::iterator it = m_TeamGroup[nGroupIndex].MemberList.begin();
it != m_TeamGroup[nGroupIndex].MemberList.end(); ++it
)
{
if (it->dwMemberID == dwMemberID)
{
m_TeamGroup[nGroupIndex].MemberList.erase(it);
pPlayer = g_pSO3World->m_PlayerSet.GetObj(dwMemberID);
if (pPlayer)
{
pPlayer->SetCurrentTeamID(m_bSystem, ERROR_ID);
}
bResult = true;
goto Exit0;
}
}
Exit0:
return bResult;
}
示例3: OnPlayerDisconnect
BOOL KNetConnectPlayer::OnPlayerDisconnect( INT nPlayerIndex )
{
INT nConnectId = m_pnPlayerIndex2ConnId[nPlayerIndex];
if (nConnectId > 0)
m_pnConnId2PlayerIndex[nConnectId] = 0;
m_pnPlayerIndex2ConnId[nPlayerIndex] = -1;
KPlayer* pPlayer = g_cPlayerMgr.GetByIndex(nPlayerIndex);
QCONFIRM_RET_FALSE(pPlayer);
//Q_Printl("OnPlayerDisconnect [" << pPlayer->GetId() << "][" << pPlayer->GetName() <<
// "] PlayerIdx[" << pPlayer->GetPlayerIndex() << "] ConnIdx[" << nConnectId << "] ...");
// 通知coordinator玩家离开
g_RelayClient.DoPlayerLeaveGS(pPlayer->GetId());
m_mpAccount2Player.erase(pPlayer->m_cPlayerServer.GetAccount());
pPlayer->m_cPlayerServer.LogoutServer();
pPlayer->m_nTimer = 0;
g_cPlayerMgr.RemoveByIndex(nPlayerIndex);
return TRUE;
}
示例4: AddMember
BOOL KTeamClient::AddMember(DWORD dwMemberID, int nGroupIndex, char szMemberName[])
{
BOOL bResult = false;
KPlayer* pPlayer = NULL;
KTEAM_MEMBER_INFO MemberInfo;
KG_PROCESS_ERROR(m_dwTeamID != ERROR_ID);
KGLOG_PROCESS_ERROR(nGroupIndex < m_nGroupNum);
KG_PROCESS_ERROR(m_TeamGroup[nGroupIndex].MemberList.size() < MAX_PLAYER_PER_GROUP);
memset(&MemberInfo, 0, sizeof(MemberInfo));
strncpy(MemberInfo.szRoleName, szMemberName, sizeof(MemberInfo.szRoleName));
MemberInfo.szRoleName[sizeof(MemberInfo.szRoleName) - 1] = '\0';
MemberInfo.dwMemberID = dwMemberID;
MemberInfo.bDeathFlag = false;
MemberInfo.bOnlineFlag = true;
MemberInfo.nLifePercent = UCHAR_MAX;
MemberInfo.nManaPercent = UCHAR_MAX;
MemberInfo.nRagePercent = UCHAR_MAX;
m_TeamGroup[nGroupIndex].MemberList.push_back(MemberInfo);
pPlayer = g_pSO3World->m_PlayerSet.GetObj(dwMemberID);
if (pPlayer)
{
pPlayer->SetCurrentTeamID(m_bSystem, m_dwTeamID);
}
bResult = true;
Exit0:
return bResult;
}
示例5: g_PlayerTimerCallBackFun
int g_PlayerTimerCallBackFun(void * pOwner, char * szScriptFileName)
{
if (!pOwner)
return 0;
KPlayer * pPlayer = (KPlayer * )pOwner;
pPlayer->ExecuteScript(szScriptFileName, "OnTimer", 0);
return 1;
};
示例6: OnSyncVarSelf
BOOL KPlayerBaseProcess::OnSyncVarSelf( LPCBYTE pData, UINT uDataLen )
{
KS2C_SYNC_VAR_SELF* pReceived = (KS2C_SYNC_VAR_SELF*)pData;
KPlayer* pPlayer = g_cPlayerMgr.GetById(g_cOrpgWorld.m_dwClientPlayerId);
QCONFIRM_RET_FALSE(pPlayer);
pPlayer->SetVar(pReceived->byVarGroup, pReceived->byVarId, (INT)pReceived->dwVarValue);
return TRUE;
}
示例7: KG_PROCESS_ERROR
void KBall::CheckWhetherScored()
{
KG_PROCESS_ERROR(m_bLastFrameState);
KG_PROCESS_ERROR(!m_bCurFrameState);
KG_PROCESS_ERROR(m_nVelocityZ < 0);
//m_nVelocityZ = 0;
m_bLastFrameState = false;
m_bCurFrameState = false;
{
BOOL bRetCode = false;
KHero* pShooter = NULL;
KPlayer* pPlayer = NULL;
KGLOG_PROCESS_ERROR(m_pTargetSocket);
pShooter = m_pScene->GetHeroById(m_dwShooterID);
if (pShooter && pShooter->IsMainHero())
pPlayer = pShooter->GetOwner();
if (pPlayer)
{
KPLAYER_EVENT eEvent = peInvalid;
switch (m_pTargetSocket->m_eFloor)
{
case bfFirst:
case bfSecond:
eEvent = peShootFirstSuccess;
break;
case bfThird:
case bfForth:
eEvent = peShootSecondSuccess;
break;
case bfFifth:
case bfSixth:
eEvent = peShootThirdSuccess;
break;
default:
assert(false);
}
pPlayer->OnEvent(eEvent);
pPlayer->OnEvent(peShootSuccess);
}
if (m_pTargetSocket->m_eFloor == bfFifth || m_pTargetSocket->m_eFloor == bfThird)
{
m_bDoDropRebound = true;
}
}
m_pScene->OnShootBallSuccess(this, m_pTargetSocket);
Exit0:
return;
}
示例8: GetOwner
int KHero::LuaGetOwner(Lua_State* L)
{
KPlayer* pPlayer = GetOwner();
if (pPlayer)
{
return pPlayer->LuaGetObj(L);
}
return 0;
}
示例9: RemoveByIndex
BOOL KPlayerMgr::RemoveByIndex( INT nIndex )
{
KPlayer* pPlayer = m_cObjMgr.GetByIndex(nIndex);
QCONFIRM_RET_FALSE(pPlayer);
// 擦除映射表
m_mapNameToPlayer.erase(pPlayer->GetStrName());
pPlayer->Uninit();
return m_cObjMgr.RemoveByIndex(nIndex);
}
示例10: OnSyncJump
BOOL KPlayerBaseProcess::OnSyncJump( LPCBYTE pData, UINT uDataLen )
{
KS2C_SYNC_JUMP* pReceived = (KS2C_SYNC_JUMP*)pData;
KPlayer* pPlayer = g_cPlayerMgr.GetById(pReceived->dwId);
QCONFIRM_RET_FALSE(pPlayer);
pPlayer->Jump();
return TRUE;
}
示例11: RemoveById
BOOL KPlayerMgr::RemoveById( DWORD dwId )
{
KPlayer* pPlayer = m_cObjMgr.GetById(dwId);
QCONFIRM_RET_FALSE(pPlayer);
// 擦除映射表
m_mapNameToPlayer.erase(pPlayer->GetStrName());
pPlayer->Uninit();
return m_cObjMgr.Remove(dwId);
}
示例12: OnSyncJumpTo
BOOL KPlayerBaseProcess::OnSyncJumpTo( LPCBYTE pData, UINT uDataLen )
{
KS2C_SYNC_JUMP_TO* pReceived = (KS2C_SYNC_JUMP_TO*)pData;
KPlayer* pPlayer = g_cPlayerMgr.GetById(pReceived->dwId);
QCONFIRM_RET_FALSE(pPlayer);
pPlayer->SetPosition(pReceived->nX, pReceived->nY, pReceived->nZ);
pPlayer->JumpTo(pReceived->nDestX, pReceived->nDestY, pReceived->nDestZ);
return TRUE;
}
示例13: Detach
BOOL KPlayerServer::Detach(int nConnIndex)
{
BOOL bResult = false;
KPlayer* pPlayer = NULL;
assert(nConnIndex >= 0 && nConnIndex < m_nMaxConnection);
pPlayer = m_ConnectionDataList[nConnIndex].pPlayer;
KG_PROCESS_ERROR(pPlayer);
// 暂时这么处理,以后应该执行托管
pPlayer->Logout();
m_ConnectionDataList[nConnIndex].pPlayer = NULL;
pPlayer->m_nConnIndex = -1;
switch (pPlayer->m_eGameStatus)
{
case gsPlaying:
pPlayer->RemoveHero();
g_RelayClient.SaveRoleData(pPlayer);
g_pSO3World->DelPlayer(pPlayer);
break;
case gsInHall:
case gsSearchMap:
case gsWaitForNewMapLoading:
g_RelayClient.SaveRoleData(pPlayer);
g_pSO3World->DelPlayer(pPlayer);
break;
//case gsWaitForConnect: 此状态下网关还未解锁,在连接超时处删除玩家
case gsWaitForPermit:
case gsWaitForRoleData:
case gsWaitForTransmissionSave:
case gsWaitForTransmissionGuid:
g_pSO3World->DelPlayer(pPlayer);
break;
default:
KGLogPrintf(
KGLOG_ERR, "Unexpected GameStatus %d for player %s when connection close !",
pPlayer->m_eGameStatus, pPlayer->m_szName
);
break;
}
bResult = true;
Exit0:
return bResult;
}
示例14: OnSyncAdjustMove
BOOL KPlayerBaseProcess::OnSyncAdjustMove( LPCBYTE pData, UINT uDataLen )
{
KS2C_SYNC_ADJUST_MOVE* pReceived = (KS2C_SYNC_ADJUST_MOVE*)pData;
//cprintf("Adjust: %d\n", pPak->nMoveCount);
KPlayer* pPlayer = g_cPlayerMgr.GetById(g_cOrpgWorld.m_dwClientPlayerId);
QCONFIRM_RET_FALSE(pPlayer);
//if (pReceived->nMoveCount < pPlayer->m_sMoveCtrl.nMoveCount || pPlayer->m_pScene == NULL)
//{
// QLogPrintf(
// LOG_DEBUG, "[move] apply adjust(%d < %d)",
// pReceived->nMoveCount, pPlayer->m_sMoveCtrl.nMoveCount
// );
// DoApplyMoveAdjust();
// goto EXIT0;
//}
INT nX = 0, nY = 0, nZ = 0;
pPlayer->GetPosition(nX, nY, nZ);
{
printf("[MoveAdjust] S[%d-%d],c[%d,%d,%d]s[%d,%d,%d],F[%d-%d] Diff[%d]\n",
pPlayer->m_eMoveState,
pReceived->nMoveState,
nX, nY, nZ,
pReceived->nX, pReceived->nY, pReceived->nZ,
g_cOrpgWorld.m_dwLogicFrames, pReceived->dwVirtualFrame,
g_cOrpgWorld.m_dwLogicFrames - pReceived->dwVirtualFrame);
}
pPlayer->SetPosition(pReceived->nX, pReceived->nY, pReceived->nZ);
pPlayer->SetMoveState((KE_MOVE_STATE)pReceived->nMoveState);
pPlayer->m_nVelocityXY = pReceived->nVelocityXY;
pPlayer->m_nDirectionXY = pReceived->nDirectionXY;
pPlayer->m_nDestX = pReceived->nDestX;
pPlayer->m_nDestY = pReceived->nDestY;
pPlayer->m_nDestZ = pReceived->nDestZ;
if (pReceived->dwVirtualFrame < g_cOrpgWorld.m_dwLogicFrames)
{
pPlayer->ForwardPosition(g_cOrpgWorld.m_dwLogicFrames - pReceived->dwVirtualFrame);
}
EXIT0:
return TRUE;
}
示例15: QCONFIRM_RET_FALSE
KPlayer* KPlayerMgr::Add2(LPCSTR pszName, DWORD dwId /*= KD_BAD_ID*/ )
{
INT nIndex = m_cObjMgr.Add(dwId);
KPlayer* pPlayer = m_cObjMgr.GetByIndex(nIndex);
QCONFIRM_RET_FALSE(pPlayer);
BOOL bOk = pPlayer->Init(nIndex, pszName);
QCONFIRM_RET_FALSE(bOk && "Player Init Failed!");
// 名字到对象映射表
m_mapNameToPlayer.insert(std::map<QString, KPlayer*>::value_type(pPlayer->GetStrName(), pPlayer));
return pPlayer;
}