Exemple #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;
}
Exemple #2
0
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;
}
Exemple #3
0
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;
}
Exemple #4
0
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;
}
Exemple #5
0
int g_PlayerTimerCallBackFun(void * pOwner, char * szScriptFileName)
{
	if (!pOwner)
		return 0;
	KPlayer * pPlayer = (KPlayer * )pOwner;
	pPlayer->ExecuteScript(szScriptFileName, "OnTimer", 0);
	return 1;
};
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;
}
Exemple #7
0
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;
}
int KHero::LuaGetOwner(Lua_State* L)
{
    KPlayer* pPlayer = GetOwner();
    if (pPlayer)
    {
        return pPlayer->LuaGetObj(L);
    }

    return 0;
}
Exemple #9
0
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);
}
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;
}
Exemple #11
0
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);
}
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;
}
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;
}
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;
}
Exemple #15
0
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;
}
BOOL KPlayerBaseProcess::OnSyncSelf( LPCBYTE pData, UINT uDataLen )
{
	KS2C_SYNC_SELF* pSData = (KS2C_SYNC_SELF* )pData;

	g_cOrpgWorld.m_dwClientSceneId = pSData->dwSceneId;

	KPlayer* pPlayer = g_cPlayerMgr.GetById(g_cOrpgWorld.m_dwClientPlayerId);
	QCONFIRM_RET_FALSE(pPlayer);
	
	// 为了加载地图时,加快3D地图的加载所作的优化
	pPlayer->m_nX = pSData->nX;
	pPlayer->m_nY = pSData->nY;
	pPlayer->m_nZ = pSData->nZ;
	pPlayer->m_nFaceDirection = pSData->nDirectionXY;

	IKScene* pScene = g_cOrpgWorld.LoadScene(pSData->dwSceneId);
	QCONFIRM_RET_FALSE(pScene);

	//modify by wdb
	const KSCENE_CONFIG* pSceneCfg = g_pSceneMgr->GetSceneInfo(g_cOrpgWorld.m_dwClientSceneId);
	QCONFIRM_RET_FALSE(pSceneCfg);

	CHAR szNavPath[MAX_PATH] = {0};	
	snprintf(szNavPath,
			 countof(szNavPath) - 1,
			 "%s/%s%s",
			 pSceneCfg->szPath,
			 pSceneCfg->szClass,
			 KD_SCENE_NAVFILE_EXT);

	IKPlayerFindPath* pIKPlayerFindPath = GetPlayerFindPath(pPlayer);
	QCONFIRM_RET_FALSE(pIKPlayerFindPath);
	BOOL bLoadRet = pIKPlayerFindPath->LoadNavPath(szNavPath);
	if (!bLoadRet)
	{
		QLogPrintf(LOG_INFO, "Load Scene Name:%s Navigate Path File %s Failed!\n", pSceneCfg->szClass, szNavPath);
	}

	pScene->AddPlayer(pPlayer, pSData->nX, pSData->nY, pSData->nZ);
	pPlayer->m_cPlayerClient.DynamicSceneFlag(pSData->nDynamicScene);
	pPlayer->m_nDirectionXY = pSData->nDirectionXY;
	pPlayer->m_nFaceDirection = pSData->nDirectionXY;
	pPlayer->m_sMoveCtrl.nMoveCount = 0;

	pPlayer->FireEvent(emKOBJEVENTTYPE_CHARACTER_ENTER_SCENE, pPlayer->GetId(), FALSE, 0);

	return TRUE;
}
Exemple #17
0
KPlayer* KAccount::getPlayer(const char* serverName, const char* player)
{
    ServerMap::iterator it = m_serverMap.find(serverName);
    if(it == m_serverMap.end())
        return NULL;

    KServer* pServer = it->second;
    int n = pServer->playerCount();
    for(int i=0; i<n; i++)
    {
        KPlayer* p = pServer->playerAt(i);
        if(stricmp(p->name(), player) == 0)
            return p;
    }
    return NULL;
}
Exemple #18
0
void KGameChat::addMessage(int fromId, const QString& text)
{
 if (!d->mGame) {
	qCWarning(GAMES_PRIVATE_KGAME) << "no KGame object has been set";
	addMessage(i18n("Player %1", fromId), text);
 } else {
	KPlayer* p = d->mGame->findPlayer(fromId);
	if (p) {
		qCDebug(GAMES_PRIVATE_KGAME) << "adding message of player" << p->name() << "id=" << fromId;
		addMessage(p->name(), text);
	} else {
		qCWarning(GAMES_PRIVATE_KGAME) << "Could not find player id" << fromId;
		addMessage(i18nc("Unknown player", "Unknown"), text);
	}
 }
}
Exemple #19
0
// 最大血量
BOOL FactionManager::SetMaxLife( KCharacter& rcCharacter, DWORD nOldValue, DWORD nNewValue )
{
	INT nDelta = nNewValue - nOldValue;

	PROCESS_ERROR(nDelta != 0);

	if(IS_PLAYER(rcCharacter.GetId()))
	{
		KPlayer* pPlayer = (KPlayer*)&rcCharacter;
		ScriptSafe cSafeScript = g_cScriptManager.GetSafeScript();
		cSafeScript->CallTableFunction("BufferMagicEffect", "Add_MaxLifeEx", 2, "od", pPlayer->GetScriptInterface(), nDelta);
	}

EXIT0:
	return TRUE;
}
Exemple #20
0
INT KPlayerMgr::Add(LPCSTR pszName, DWORD dwId /*= KD_BAD_ID*/ )
{
	INT nIndex = m_cObjMgr.Add(dwId);

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

	// TODO: 人物创建时应该先SyncToNeighborPlayers,否则周围玩家的SetVar会失效 kk

	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 nIndex;
}
Exemple #21
0
KPlayer* KSO3World::NewPlayer(DWORD dwPlayerID)
{
    KPlayer*    pResult         = NULL;
	BOOL        bRetCode        = false;
	KPlayer*    pPlayer         = NULL;
    BOOL        bRegisterFlag   = false;
    BOOL        bInitFlag       = false;

	assert(dwPlayerID != ERROR_ID);

    pPlayer = KMemory::New<KPlayer>();
    KGLOG_PROCESS_ERROR(pPlayer);

    bRetCode = g_pSO3World->m_PlayerSet.Register(pPlayer, dwPlayerID);
    KGLOG_PROCESS_ERROR(bRetCode);
    bRegisterFlag = true;

	bRetCode = pPlayer->Init();
	KGLOG_PROCESS_ERROR(bRetCode);
    bInitFlag = true;

    pResult = pPlayer;
Exit0:
    if (pResult == NULL)
    {
        if (bInitFlag)
        {
            pPlayer->UnInit();
            bInitFlag = false;
        }

        if (bRegisterFlag)
        {
            g_pSO3World->m_PlayerSet.Unregister(pPlayer);
            bRegisterFlag = false;
        }

        if (pPlayer != NULL)
        {
            KMemory::Delete(pPlayer);
            pPlayer = NULL;
        }
    }
	return pResult;
}
Exemple #22
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;
}
Exemple #23
0
INT KPlayerMgr::GetAllPlayerId(std::vector<DWORD>* pvecPlayerId)
{
	INT nResult = 0;
	INT nPlayerIndex = 0;

	LOG_PROCESS_ERROR(pvecPlayerId && "[KPlayerMgrSys]:非法的参数");
	do 
	{
		nPlayerIndex = m_cObjMgr.NextUsedIndex(nPlayerIndex);
		if (nPlayerIndex > 0)
		{
			KPlayer* pPlayer = m_cObjMgr.GetByIndex(nPlayerIndex);
			LOG_PROCESS_ERROR(pPlayer && "[KPlayerMgrSys]:遍历到未知的玩家");
			pvecPlayerId->push_back(pPlayer->GetId());
		}

	} while ( 0 < nPlayerIndex);

	nResult = 1;
EXIT0:
	return nResult;
}
Exemple #24
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;
}
Exemple #25
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;
}
Exemple #26
0
VOID KItemTimeoutCtrl::RemoveItem(INT nItemIdx)
{
	ASSERT(nItemIdx > 0);
	do
	{
		KItem* pItem = &Item[nItemIdx];
		INT nPlayerIdx = pItem->GetBelong();
		if (nPlayerIdx <= 0)
		{
			ASSERT(FALSE);
			break;
		}
	
		CHAR szMsg[1024];
		sprintf(szMsg, "您的%s超过有效期已被删除!", pItem->GetOrgName());
		KPlayer* pOwner = g_cPlayerMgr.GetByIndex(nPlayerIdx);

		if (m_pItemList->Remove(nItemIdx, emKLOSEITEM_TIMEOUT))
		{
			g_cItemMgr.Remove(
				nItemIdx,
				emITEM_DATARECORD_REMOVE,
				emITEM_CONSUMEMODE_USINGTIMEOUT,
				pOwner
				);

			g_ChatChannelManager.ProcessRespond(trLocalSys, emKSYSTEMMSG_NORMAL,
				pOwner->GetId(), "系统", szMsg, emQCHAT_PANEL);
		}
		else
		{
			QLogPrintf(LOG_ERR, "KItemTimeoutCtrl::RemoveItem failed Idx % Owner %s GDP %d,%d,%d",
				pItem->GetGameIndex(), pOwner->GetName(),
				pItem->GetGenre(), pItem->GetDetailType(), pItem->GetParticular());
		}
	}
	while (0);
}
Exemple #27
0
INT KPlayerMgr::GetAllPlayers(std::vector<KPlayer*>& rvPlayers)
{
	INT nResult = 0;
	INT nPlayerIndex = 0;

	while ((nPlayerIndex = m_cObjMgr.NextUsedIndex(nPlayerIndex)) > 0)
	{
		KPlayer* pPlayer = m_cObjMgr.GetByIndex(nPlayerIndex);
		if (pPlayer->GetGameState() == gsPlaying)
		{
			LOG_PROCESS_ERROR(pPlayer);
			rvPlayers.push_back(pPlayer);
		}
		else
		{
			//QLogPrintf(LOG_INFO, "KPlayerMgr::GetAllPlayers Cull %d %d", pPlayer->GetPlayerId(), pPlayer->GetGameState());
		}
	}

	nResult = 1;
EXIT0:
	return nResult;
}
BOOL KPlayerBaseProcess::PtcPlayerData( LPCBYTE pData, UINT uDataLen )
{
	KS2C_PLAYERDATA* pSData = (KS2C_PLAYERDATA* )pData;
	// CheckSize
	QCONFIRM_RET_FALSE(_offsetof(KS2C_PLAYERDATA, sVarSync.aMapVarSet) + sizeof(KMAP_VAR_VALUE) *
		(pSData->sVarSync.wMapVarNum) == uDataLen);

	Q_Printl("Received Player Data. Client Player Rolename: " << pSData->szPlayerName <<
		" Id:" << pSData->dwPlayerId);

	g_cOrpgWorld.m_dwClientPlayerId = pSData->dwPlayerId;
	g_cOrpgWorld.m_dwLogicFrames = pSData->dwLogicFrames;
	g_cOrpgWorld.m_nServerId = pSData->nServerId;

    InitStartTimeEvaluation(&g_cOrpgWorld.m_StartTimeEvaluation);
    g_cOrpgWorld.m_nStartLoop = g_cOrpgWorld.m_dwLogicFrames;
    g_cOrpgWorld.m_nGSGameLoop = g_cOrpgWorld.m_dwLogicFrames;
    g_cOrpgWorld.m_dwStartTime = timeGetTime();
	g_cOrpgWorld.m_dwServerTime = pSData->dwServerTime;

	KPlayer* pPlayer = g_cOrpgWorld.AddPlayer(pSData->szPlayerName, pSData->dwPlayerId);
	QCONFIRM_RET_FALSE(pPlayer);
	g_cScriptManager.SetMe((QLunaBase*)pPlayer->GetScriptInterface());

	pPlayer->SetKinId(0);
	pPlayer->SetKinName("");
	pPlayer->SetKinFigure(0);
	pPlayer->m_cPlayerClient.LoadSyncVarSelf(pSData->sVarSync);

	g_cOrpgWorld.m_cEventCreator.FireEvent(emKOBJEVENTTYPE_PLAYER_LOGIN, g_cOrpgWorld.m_dwClientPlayerId, 0, 0);		// by houxuan, 玩家登陆事件

	// 通知服务端已完成加载
	DoSyncEnd();

	return TRUE;
}
BOOL KPlayerBaseProcess::OnSyncPlayer( LPCBYTE pData, UINT uDataLen )
{
	KS2C_SYNC_PLAYER* pReceived = (KS2C_SYNC_PLAYER*)pData;
	// CheckSize
	QCONFIRM_RET_FALSE(_offsetof(KS2C_SYNC_PLAYER, sVarSync.aMapVarSet) + sizeof(KMAP_VAR_VALUE) *
		(pReceived->sVarSync.wMapVarNum) == uDataLen);

	// TODO: improve
	KPlayer* pPlayer = g_cPlayerMgr.GetById(pReceived->dwPlayerId);
	if (pPlayer)
	{
		pPlayer->m_cPlayerClient.LoadSyncVarOther(pReceived->sVarSync);
		pPlayer->SetPosition(pReceived->nX, pReceived->nY, pReceived->nZ);
		pPlayer->SetMoveState((KE_MOVE_STATE)pReceived->nMoveState);
		pPlayer->m_nVelocityXY = pReceived->nVelocityXY;
		pPlayer->m_nDestX = pReceived->nDestX;
		pPlayer->m_nDestY = pReceived->nDestY;
		pPlayer->m_nDestZ = pReceived->nDestZ;
		pPlayer->m_nFaceDirection = pReceived->nDirectionXY; // 暂时用速度方向代替
		pPlayer->SetKinName(pReceived->szKinName);
		pPlayer->SetKinId(pReceived->dwKinId);
		pPlayer->SetKinFigure(pReceived->dwKinFigure);

		QLogPrintf(LOG_LEVEL_WARNING, "[PlayerBaseProcess] %s :player_id=%d,already exists", __FUNCTION__, pReceived->dwPlayerId);
		return FALSE;
	}
	else
	{
		pPlayer = g_cOrpgWorld.AddPlayer(pReceived->szName, pReceived->dwPlayerId);
		QCONFIRM_RET_FALSE(pPlayer);

		pPlayer->m_cPlayerClient.LoadSyncVarOther(pReceived->sVarSync);

		// get client scene
		IKScene* pScene = g_pSceneMgr->FirstScene();
		QCONFIRM_RET_FALSE(pScene);

		pScene->AddPlayer(pPlayer, pReceived->nX, pReceived->nY, pReceived->nZ);
		pPlayer->SetMoveState((KE_MOVE_STATE)pReceived->nMoveState);
		pPlayer->m_nVelocityXY = pReceived->nVelocityXY;
		pPlayer->m_nDestX = pReceived->nDestX;
		pPlayer->m_nDestY = pReceived->nDestY;
		pPlayer->m_nDestZ = pReceived->nDestZ;
		pPlayer->m_nFaceDirection = pReceived->nDirectionXY; // 暂时用速度方向代替
		pPlayer->SetKinName(pReceived->szKinName);
		pPlayer->SetKinId(pReceived->dwKinId);
		pPlayer->SetKinFigure(pReceived->dwKinFigure);
		pPlayer->FireEvent(emKOBJEVENTTYPE_CHARACTER_ENTER_SCENE, pPlayer->GetId(), FALSE, 0);
		return TRUE;
	}

	return TRUE;
}
Exemple #30
0
BOOL KAwardMgr::ScenenItemAward(std::vector<KPlayer*>& vecPlayer, DWORD dwAwardID)
{
    BOOL            bResult         = false;
    BOOL            bRetCode        = false;
    KAwardTable*    pAwardTable     = NULL;
    KAWARD_ITEM*    pAwardItem      = NULL;
    KPlayer*        pPlayer         = NULL; 
    KSystemMailTxt* pSysMailTxt     = NULL;
    int             nValuePoint     = 0;

    pAwardTable = g_pSO3World->m_AwardMgr.GetAwardTable(dwAwardID);
    KGLOG_PROCESS_ERROR(pAwardTable);

    pAwardItem = pAwardTable->GetRandomAward();
    KGLOG_PROCESS_ERROR(pAwardItem);
    KGLOG_PROCESS_ERROR(pAwardItem->dwTabType);

    pSysMailTxt = g_pSO3World->m_Settings.m_SystemMailMgr.GetSystemMailTxt(KMAIL_BATTLE_AWARD);
    KGLOG_PROCESS_ERROR(pSysMailTxt);

    for (size_t i = 0; i < vecPlayer.size(); ++i)
    {
        pPlayer = vecPlayer[i];

        KGLOG_PROCESS_ERROR(pPlayer);

        if (pAwardItem->dwTabType == ittOther || pAwardItem->dwTabType == ittEquip)
        {
            bRetCode = GetAwardItemValuePoint(pAwardItem, nValuePoint);
            KGLOG_PROCESS_ERROR(bRetCode);

            bRetCode = pPlayer->SafeAddItem(pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, 
                pSysMailTxt->m_szMailTitl, pSysMailTxt->m_szSendName, pSysMailTxt->m_szMailTxt
            );
            KGLOG_PROCESS_ERROR(bRetCode);

            PLAYER_LOG(
                pPlayer, "item,additem,%u-%u,%d,%d,%s,%d",
                pAwardItem->dwTabType, pAwardItem->dwIndex, pAwardItem->nStackNum, nValuePoint, 
                "SceneAward", pPlayer->m_dwMapID
            );
        }
        else if (pAwardItem->dwTabType == ittFashion)
        {
            bRetCode = pPlayer->m_Wardrobe.AddFashion(pAwardItem->dwIndex);
            KGLOG_CHECK_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittCheerleading)
        {
            KGCheerleadingInfo* pCheerleadingInfo = g_pSO3World->m_ItemHouse.GetCheerleadingInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pCheerleadingInfo);

            bRetCode = pPlayer->m_CheerleadingMgr.AddCheerleading(pCheerleadingInfo->dwID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
        else if (pAwardItem->dwTabType == ittTeamLogo)
        {
            KTEAM_LOGO_INFO*    pTeamLogoInfo = NULL;

            pTeamLogoInfo = g_pSO3World->m_ItemHouse.GetTeamLogoInfo(pAwardItem->dwIndex);
            KGLOG_PROCESS_ERROR(pTeamLogoInfo);

            bRetCode = pPlayer->AddTeamLogo((WORD)pTeamLogoInfo->nID);
            KGLOG_PROCESS_ERROR(bRetCode);
        }
    }

    bResult = true;
Exit0:
    return bResult;
}