Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
INT KNetConnectPlayer::OnClientLogin2( DWORD dwRoleId, const GUID& rConnGuid, INT nConnectId, BOOL bHidden /*= FALSE*/,BOOL bTinyTerminal)
{
	INT nRetCode = FALSE;
	KPlayer* pPlayer = NULL;
	INT nPlayerIndex = 0;
	pPlayer = g_cPlayerMgr.GetById(dwRoleId);
	LOG_PROCESS_ERROR(pPlayer);
	LOG_PROCESS_ERROR(pPlayer->GetGameState() == gsWaitForConnect);
	LOG_PROCESS_ERROR(pPlayer->m_cPlayerServer.m_Guid == rConnGuid);
	pPlayer->SetTinyTerminal(bTinyTerminal);
	nPlayerIndex = pPlayer->GetPlayerIndex();
	
	m_pnConnId2PlayerIndex[nConnectId] = nPlayerIndex;
	m_pnPlayerIndex2ConnId[nPlayerIndex] = nConnectId;

	m_mpAccount2Player[pPlayer->m_cPlayerServer.m_strAccount] = nPlayerIndex;

	g_RelayClient.DoConfirmPlayerLoginRequest(dwRoleId);

	pPlayer->SetGameState(gsWaitForPermit);
	pPlayer->m_nTimer       = 0;
	
	nRetCode = TRUE;
EXIT0:
	if (!nRetCode)
	{
		QLogPrintf(LOG_INFO, "Invalid Client: %d\n", nConnectId);

		if (pPlayer)
			QLogPrintf(LOG_INFO, "Player %d state %d\n", dwRoleId, pPlayer->GetGameState());
	}
	return nRetCode;
}
Ejemplo n.º 3
0
BOOL QPlayerTeam::DoApplyJoinTeamRequest(DWORD dwLeader, const char cszApplySrc[])
{
	int                             nResult         = false;
	int                             nRetCode        = false;
	KPlayer*                        pTeamLeader    = NULL;
	S2C_APPLY_JOIN_TEAM_REQUEST     TeamApply;

	pTeamLeader = g_cPlayerMgr.GetById(dwLeader);
	PROCESS_ERROR(pTeamLeader);

	PROCESS_ERROR(CanTeamProcess(pTeamLeader));

	strncpy(TeamApply.szApplySrc, cszApplySrc, sizeof(TeamApply.szApplySrc));
	TeamApply.szApplySrc[sizeof(TeamApply.szApplySrc) - 1] = '\0';

	nRetCode = QTeamModule::SendData(pTeamLeader->GetPlayerIndex(), TeamApply);
	PROCESS_ERROR(nRetCode);

	nResult = true;
EXIT0:
	return nResult;
}
Ejemplo n.º 4
0
BOOL QPlayerTeam::DoInvitePlayerJoinTeamRequest(DWORD dwInviteDst, const char cszInviteSrc[])
{
	int                             nResult         = false;
	int                             nRetCode        = false;
	KPlayer*                        pInviteDst      = NULL;
	S2C_INVITE_JOIN_TEAM_REQUEST    TeamInvite;

	pInviteDst = g_cPlayerMgr.GetById(dwInviteDst);
	PROCESS_ERROR(pInviteDst);

	PROCESS_ERROR(CanTeamProcess(pInviteDst));

	strncpy(TeamInvite.szInviteSrc, cszInviteSrc, sizeof(TeamInvite.szInviteSrc));
	TeamInvite.szInviteSrc[sizeof(TeamInvite.szInviteSrc) - 1] = '\0';

	nRetCode = QTeamModule::SendData(pInviteDst->GetPlayerIndex(), TeamInvite);
	PROCESS_ERROR(nRetCode);

	nResult = true;
EXIT0:
	return nResult;
}
Ejemplo n.º 5
0
BOOL KPlayerMgr::Activate()
{
	static INT nPlayerIndex = 0;
	m_timeActivate = KSysService::GameTime(NULL);

	for (INT i = 0; i < KD_BATCH_PROCESS_PLAYER_MAX; ++i)
	{
		if (nPlayerIndex > m_cObjMgr.GetMaxCount())
		{
			nPlayerIndex = 0;
			break;
		}
		nPlayerIndex = m_cObjMgr.NextUsedIndex(nPlayerIndex);
		if (nPlayerIndex <= 0)
			break;

		KPlayer* pPlayer = m_cObjMgr.GetByIndex(nPlayerIndex);
		QCONFIRM_RET_FALSE(pPlayer);

		PLAYER_GAME_STATE eGameState = pPlayer->GetGameState();
		switch (eGameState)
		{
		case emPLAYERSTATE_BEGIN: // kick out
			break;
		case gsPlaying:
			OnRegularProcess(pPlayer);
			break;
		case gsWaitForConnect:
			// 等待登陆倒计时
			if (pPlayer->m_nTimer++ >= LOGIN_TIMEOUT)
			{
				QLogPrintf(
					LOG_INFO, "Login timeout: acc = %s, role = %s\n", 
					pPlayer->m_cPlayerServer.GetAccount(), pPlayer->GetName()
					);
				g_cNetConnectPlayer.KickOutPlayer(pPlayer->GetPlayerIndex());
			}
			break;

		case gsWaitForPermit:
		case gsWaitForRoleData:
			// 等待登陆倒计时
			if (pPlayer->m_nTimer++ >= LOGIN_TIMEOUT)
			{
				QLogPrintf(
					LOG_INFO, "Relay permission or query role data, kicking (%s, %d)\n", 
					pPlayer->GetName(), pPlayer->GetPlayerIndex()
					);
				g_cNetConnectPlayer.KickOutPlayer(pPlayer->GetPlayerIndex());
			}
			break;

		case gsWaitForLoginLoading:
		case gsWaitForNewMapLoading:
			break;

		case gsDeleting:
			// 掉线倒计时
			if (pPlayer->m_nTimer++ >= LOGOUT_WAITING_TIME/* || !pPlayer->m_bFightState*/)
			{
				//pPlayer->SavePosition();

				//// 这里之所以调RemovePlayer是为了在Save之前触发Trap(如果有的话),Trap可能会涉及存盘角色数据
				//g_pWorld->RemovePlayer(pPlayer);

				//g_RelayClient.SaveRoleData(pPlayer);

				//g_pWorld->m_FellowshipMgr.UnloadPlayerFellowship(pPlayer->m_dwID);

				g_cNetConnectPlayer.KickOutPlayer(pPlayer->GetPlayerIndex());
			}
			break;
		default:
			break;
		}
	}
	return TRUE;
}