Exemple #1
0
// -------------------------------------------------------------------------
BOOL KCharacterServer::SyncVarAround( WORD wVarGroup, WORD wVarId )
{
	BOOL 		bResult 		= FALSE;
	KS2C_SYNC_VAR_AROUND sSync;
	IKScene*	pScene 			= NULL;
	DWORD 		dwSceneId     	= 0;
	BOOL 		bNpc			= FALSE;
	KNpc		*pNpc          	= FALSE;
	DWORD		dwTemplateId 	=  0;
	sSync.dwId = m_rcCharacter.GetId();
	sSync.byVarGroup = (BYTE)wVarGroup;
	sSync.byVarId = (BYTE)wVarId;
	sSync.dwVarValue = (DWORD)m_rcCharacter.GetVar(wVarGroup, wVarId);
	pScene = m_rcCharacter.GetScene();
	PROCESS_ERROR(pScene);
	dwSceneId = pScene->GetId();
	bNpc = IS_NPC(m_rcCharacter.GetId());
	//by ldy 判读蛮荒之地里面的boss才同步血量
	if((dwSceneId >= 353 && dwSceneId <= 356) && bNpc)
	{
		pNpc = (KNpc*)&m_rcCharacter;
		dwTemplateId = pNpc->GetTemplateId();
		PROCESS_ERROR(dwTemplateId >= 2807 && dwTemplateId <= 2813);
	}
	bResult = BroadcastNearby(&sSync, sizeof(sSync), FALSE);
	bResult = TRUE;
EXIT0:
	return bResult;
}
Exemple #2
0
// 1 : indicates sucess
// 0 : non waiting connection or operations will complete later
//-1 : accept failed. this indicates a serious system error
inline INT g_AcceptSocketStream(SOCKET hListenSocket, PSocketStream &pAsyncSocketStream, INT *pErrorCode /* = NULL */)
{
	CHECK_RETURN_BOOL(INVALID_SOCKET != hListenSocket);
	INT nResult = 1;
	g_SetErrorCode(pErrorCode, 0);
	struct sockaddr_in saRemoteAddr;
	SOCKET hRemoteSocket = INVALID_SOCKET;
	SockLen nAddrLen = sizeof(struct sockaddr_in);
	BOOL bLoopFlag = TRUE, bRetCode = FALSE;

	while (bLoopFlag)
	{
		g_ZeroMemory(&saRemoteAddr, nAddrLen);
		hRemoteSocket = (SOCKET)::accept(hListenSocket, (struct sockaddr *)&saRemoteAddr, &nAddrLen);

		if (SOCKET_ERROR == hRemoteSocket)
		{
			if (g_IsSocketCanRestore())
			{// interrupted system call, try again
				continue;
			}

			if (g_IsSocketWouldBlock())
			{
				nResult = 0;
				g_SetErrorCode(pErrorCode, 0);
				goto Exit0;
			}
			nResult = -1;
			// save other error code
			INT nErrorCode = g_GetSocketLastError();
			g_SetErrorCode(pErrorCode, nErrorCode);
			goto Exit0;
		}

		g_SetSocketNonBlock(hRemoteSocket, pErrorCode);

		pAsyncSocketStream = ::new SocketStream();
		PROCESS_ERROR(NULL != pAsyncSocketStream);

		bRetCode = pAsyncSocketStream->Init(hRemoteSocket, ::inet_ntoa(saRemoteAddr.sin_addr), saRemoteAddr.sin_port);
		PROCESS_ERROR(bRetCode);

		break;
	}

	return nResult;
Exit0:
	if (NULL != pAsyncSocketStream)
	{
		pAsyncSocketStream->UnInit();
		g_SafelyDeletePtr(pAsyncSocketStream);
	}
	g_SetErrorCode(pErrorCode, -1);
	return nResult;
}
Exemple #3
0
BOOL KRankHandler::DoSwapRankRespond(INT nConnIndex, INT nRankId, DWORD dwSrcId, INT nSrcRank, DWORD dwDestId, INT nDestRank, BOOL bSucceed)
{
	BOOL						bRetCode = FALSE;
	BOOL						bResult	 = FALSE;
	R2S_SWAP_RANK_RESPOND*		pRespond = NULL;
	IMemBlock*					piPackage = NULL;

	KRole* pRole = g_pGameCenter->m_RoleManager.GetRole(dwSrcId);
	PROCESS_ERROR(pRole);

	piPackage = QCreateMemBlock(sizeof(R2S_SWAP_RANK_RESPOND));
	pRespond = (R2S_SWAP_RANK_RESPOND*)piPackage->GetData();
	LOG_PROCESS_ERROR(pRespond);

	pRespond->wProtocolID = r2s_swap_rank_respond;
	pRespond->nRankId = nRankId;
	strcpy(pRespond->szSrcPlayerName, pRole->getName());		;
	pRespond->nSrcRank = nSrcRank;
	pRespond->dwDestId = dwDestId;
	pRespond->nDestRank = nDestRank;
	pRespond->bSucceed = bSucceed;

	bRetCode = Send(nConnIndex, piPackage);
	LOG_PROCESS_ERROR(bRetCode);

	bResult = TRUE;
EXIT0:
	SAFE_RELEASE(piPackage);
	return bResult;
}
Exemple #4
0
// -------------------------------------------------------------------------
// @ClientSvr(C/S)	: 
// @ClassName		: KLuaPlayerItem
// @LuaApiName		: FindItemId
// @Description		: 在指定空间里查找指定类型的道具
// @ReturnCode		: 返回nRoom,nX,nY,失败返回nil
// @ArgumentFlag	: d
// @ArgumentComment	: nItemId
// @LuaMarkEnd
// -------------------------------------------------------------------------
INT KLuaPlayerItem::LuaFindItemId(QLuaScript& sc)
{
	INT nRet = 0;
	INT nItemId = sc.GetInt(1);
	INT nListIdx = 0;
	KLISTITEM* pListItem = NULL;
	PROCESS_ERROR(nItemId);
	m_pPlayerItem->SearchID(nItemId, &nListIdx);
	pListItem = m_pPlayerItem->GetItem(nListIdx);
	PROCESS_ERROR(pListItem);
	nRet += sc.PushNumber(pListItem->sPos.eRoom);
	nRet += sc.PushNumber(pListItem->sPos.nX);
	nRet += sc.PushNumber(pListItem->sPos.nY);
EXIT0:
	return nRet;
}
Exemple #5
0
BOOL FactionManager::SetLevel( KCharacter& rcCharacter, WORD wOldValue, WORD wNewValue )
{
	//QLogPrintf(LOG_INFO,"..FactionManager::SetLevel..");
	BOOL bRetCode = FALSE;
	PlayerFaction* playerFaction = NULL;
	PROCESS_ERROR(rcCharacter.GetLevel() && wOldValue != wNewValue);

	playerFaction = rcCharacter.GetCtrl<PlayerFaction>();
	LOG_PROCESS_ERROR(playerFaction);
	playerFaction->OnFactionRouteChange(rcCharacter.GetLevel(), rcCharacter.GetPrimaryFaction(), rcCharacter.GetCurrentRoute());

	playerFaction->OnLevelChange(wOldValue, wNewValue);

	if (wOldValue != 0 && wOldValue != wNewValue && wNewValue == ARENA_OPEN_LEVEL)
	{
		// 按战斗力加入竞技场排行榜
		PlayerArena* pPlayerArena = rcCharacter.GetCtrl<PlayerArena>();
		LOG_PROCESS_ERROR(pPlayerArena);
		pPlayerArena->AddArenaRank();
	}

	g_cCharacterHelper.CalcFightScore(rcCharacter);		// 这句话和上面的AddArenaRank顺序不能变,涉及到排名顺序问题

	bRetCode = TRUE;
EXIT0:
	return bRetCode;
}
Exemple #6
0
CONST QAssetAward* KAwardSetting::RequestAssetAward(QString moduleName, INT nLevel)
{
	QModuleAssetAward* pTargetModuleAward = NULL;
	std::vector<QModuleAssetAward*>::iterator it;
	std::map<INT, QAssetAward*>::iterator it_find;
	QAssetAward* pTargetAward = NULL;

	for (it = m_vecModuleAssetAwards.begin(); it != m_vecModuleAssetAwards.end(); ++it)
	{
		if (moduleName ==  (*it)->szModuleName)
		{
			pTargetModuleAward = (*it);
			break;
		}
	}
	assert(pTargetModuleAward);
	LOG_PROCESS_ERROR(pTargetModuleAward);

	it_find = pTargetModuleAward->mapAssetAwards.find(nLevel);
	PROCESS_ERROR(it_find != pTargetModuleAward->mapAssetAwards.end());

	pTargetAward = pTargetModuleAward->mapAssetAwards[nLevel];

	
	if(!pTargetAward)
	{
		QLogPrintf(LOG_ERR,"Can't find level, modulename:%s, level:%d\n", moduleName.CStr(), nLevel);
	}
	//QCONFIRM_RET_NULL(pTargetAward);
	
EXIT0:
	return pTargetAward;
}
Exemple #7
0
BOOL KDoodadMgr::RemoveFromScene( DWORD dwId )
{
	BOOL bResult = FALSE;
	KDoodad* pstDoodad = NULL;
	IKScene* pScene = NULL;

	PROCESS_ERROR(pstDoodad = m_cObjPool.GetById(dwId));
	PROCESS_ERROR(pScene = pstDoodad->GetScene());
	PROCESS_ERROR(pScene->RemoveDoodad(pstDoodad));

	g_cScriptManager.GetSafeScript()->CallTableFunction("Doodad", "OnLeaveScene", 1, "os",
		pstDoodad->GetScriptInterface(), pstDoodad->m_strClass.c_str());

	bResult = TRUE;
EXIT0:
	return bResult;
}
Exemple #8
0
BOOL KDoodadMgr::AddToScene(KDoodad* pstDoodad, DWORD dwSceneId, INT nX, INT nY, INT nZ)
{
	BOOL bResult = FALSE;
	IKScene* pScene = NULL;
	INT nIdx = 0;

	PROCESS_ERROR(pstDoodad);
	PROCESS_ERROR(pScene = g_pSceneMgr->GetScene(dwSceneId));

	PROCESS_ERROR(pScene->AddDoodad(pstDoodad, nX, nY, nZ));

	g_cScriptManager.GetSafeScript()->CallTableFunction("Doodad", "OnEnterScene", 1, "os",
		pstDoodad->GetScriptInterface(), pstDoodad->m_strClass.c_str());

	bResult = TRUE;
EXIT0:
	return bResult;
}
Exemple #9
0
BOOL SelecterServer::Init(CONST STRING strIpAddress, CONST USHORT usPort)
{
	m_usPort = usPort;
	m_strIpAddress = strIpAddress;

	BOOL bRetCode = FALSE;

	m_hListenSocket = g_CreateListenSocket(m_strIpAddress.c_str(), m_usPort);
	PROCESS_ERROR(INVALID_SOCKET != m_hListenSocket);

	bRetCode = g_SetSocketNonBlock(m_hListenSocket);
	PROCESS_ERROR(bRetCode);

	return TRUE;

Exit0:
	g_CloseSocket(m_hListenSocket);
	return FALSE;
}
Exemple #10
0
BOOL KAwardSetting::HasAssetAward(LPCSTR szModuleName, INT nLevel)
{
	BOOL bResult = FALSE;
	QString strModuleName(szModuleName);
	CONST QAssetAward* pAssetAward = g_cAwardSetting.RequestAssetAward(strModuleName, nLevel);
	PROCESS_ERROR(pAssetAward);

	bResult = TRUE;
EXIT0:
	return bResult;
}
Exemple #11
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 #12
0
inline HANDLE_EVENT g_CreateEvent(BOOL bManualReset, BOOL bInitialState)
{
#ifdef PLATFORM_OS_WINDOWS
	HANDLE_EVENT hEvent = ::CreateEvent(NULL, bManualReset, bInitialState, NULL);
	PROCESS_ERROR(NULL != hEvent);
#else
	INT nReCode = 0;
	// std::nothrow 在内存不足时,new (std::nothrow)并不抛出异常,而是将指针置NULL。
	HANDLE_EVENT hEvent = ::new(std::nothrow) EventHandleData;
	PROCESS_ERROR(NULL != hEvent);

	hEvent->m_bState = bInitialState;
	hEvent->m_bManualReset = bManualReset;
	nReCode = ::pthread_cond_init(&hEvent->m_cond, NULL);
    PROCESS_ERROR(0 == nReCode);
#endif // PLATFORM_OS_WINDOWS
	return hEvent;

Exit0:
	g_DestroyEvent(hEvent);
	return NULL;
}
Exemple #13
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 #14
0
BOOL ObjectBuffer::HasBuffer(Buffer* buf)
{
	BUFFER_ARRAY::iterator it_buf;

	PROCESS_ERROR(buf);

	for (it_buf = m_arrBuffers.begin(); it_buf != m_arrBuffers.end(); ++it_buf)
	{
		if ((*it_buf) == buf)
			return TRUE;
	}
EXIT0:
	return FALSE;
}
Exemple #15
0
BOOL KDoodadMgr::DestroyDoodad( DWORD dwId )
{
	BOOL bResult = FALSE;
	KDoodad* pstDoodad = NULL;

	PROCESS_ERROR(pstDoodad = m_cObjPool.GetById(dwId));

	pstDoodad->Uninit();
	m_cObjPool.Remove(dwId);

	bResult = TRUE;
EXIT0:
	return bResult;
}
BOOL KGC_CoordinatorClient::Init(PCSTR pszIp, INT nPort)
{
	INT nRet = FALSE;
	LOG_PROCESS_ERROR(pszIp);

	m_strCoordinatorIp = pszIp;
	m_nCoordinatorPort = nPort;
	m_piSocket = NULL;

	nRet = Connect(pszIp, nPort);
	PROCESS_ERROR(nRet);

EXIT0:
	return nRet;
}
Exemple #17
0
BOOL KNetConnectPlayer::SendData( INT nPlayerIndex, LPCBYTE pData, UINT uDataLen )
{
	BOOL bResult 		= FALSE;
	INT  nConnectIndex 	= 0;
	BOOL bRet 			= FALSE;
	TxStat(pData, uDataLen);
	LOG_PROCESS_ERROR(nPlayerIndex > 0 && nPlayerIndex <= m_nMaxConnId);
	nConnectIndex = m_pnPlayerIndex2ConnId[nPlayerIndex];
	PROCESS_ERROR(nConnectIndex > 0);
	bRet = g_piSocketServer->Send(nConnectIndex, 0, pData, uDataLen);
	LOG_PROCESS_ERROR(bRet);
	bResult = TRUE;
EXIT0:
	return bResult;
}
Exemple #18
0
void QMailModule::OnReturnMail(KPlayer* pPlayer, char* pData, size_t uDataLen)
{
	BOOL                bRetCode    = false;
	C2S_RETURN_MAIL*    pPak        = (C2S_RETURN_MAIL*)pData;

	LOG_PROCESS_ERROR(pPlayer);
	LOG_PROCESS_ERROR(pData);
	LOG_PROCESS_ERROR(uDataLen == sizeof(C2S_RETURN_MAIL));

	bRetCode = MailRelayClient::DoReturnMail(pPlayer->m_dwId, pPak->dwMailID);
	PROCESS_ERROR(bRetCode);

EXIT0:
	return;
}
Exemple #19
0
//---------------------------------------------------------------------------
// 函数:	Save
// 功能:	保存当前的INI文件
// 返回:	1 成功, 0失败
//---------------------------------------------------------------------------
int QIniFileImpl::Save(const char* FileName)
{
	int			nResult         = false;
	IFile*		piFile          = NULL;
	SECNODE*	SecNode         = m_Header.pNextNode;
	KEYNODE*	KeyNode         = NULL;
    DWORD       dwStringLen     = 0;
    DWORD       dwWriteSize     = 0;
    const char  cszNewLine[3]   = "\r\n";

    piFile = g_CreateFile(FileName);
    PROCESS_ERROR(piFile);

	while (SecNode != NULL)
	{
		dwStringLen = (DWORD)strlen(SecNode->pSection);
		dwWriteSize = piFile->Write(SecNode->pSection, dwStringLen);
		PROCESS_ERROR(dwWriteSize == dwStringLen);
		dwWriteSize = piFile->Write(cszNewLine, 2);
		PROCESS_ERROR(dwWriteSize == 2);

		KeyNode = SecNode->RootNode.pNextNode;
		while (KeyNode != NULL)
		{
			dwStringLen = (DWORD)strlen(KeyNode->pKey);
			dwWriteSize = piFile->Write(KeyNode->pKey, dwStringLen);
			PROCESS_ERROR(dwWriteSize == dwStringLen);
			dwWriteSize = piFile->Write("=", 1);
			PROCESS_ERROR(dwWriteSize == 1);
			dwStringLen = (DWORD)strlen(KeyNode->pValue);
			dwWriteSize = piFile->Write(KeyNode->pValue, dwStringLen);
			PROCESS_ERROR(dwWriteSize == dwStringLen);
			dwWriteSize = piFile->Write(cszNewLine, 2);
			PROCESS_ERROR(dwWriteSize == 2);
			KeyNode = KeyNode->pNextNode;
		}
		dwWriteSize = piFile->Write(cszNewLine, 2);
		PROCESS_ERROR(dwWriteSize == 2);
		SecNode = SecNode->pNextNode;
	}
	nResult = true;
EXIT0:
	SAFE_RELEASE(piFile);
	return nResult;
}
Exemple #20
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 #21
0
void KSndaAgency::Activate()
{
	PROCESS_ERROR(m_bOpen);

	g_SDOAVerifyRespondQueueLock.Lock();
	while (!g_SDOAVerifyRespondQueue.empty())
	{
		KTOKEN_VERIFY_RESPOND& rRespond = g_SDOAVerifyRespondQueue.front();
		OnTokenVerifyRespond(&rRespond);

		g_SDOAVerifyRespondQueue.pop();
	}
	g_SDOAVerifyRespondQueueLock.Unlock();

EXIT0:
	return;
}
Exemple #22
0
BOOL KEscortModule::OnDelayLoadRespond(IMemBlock* piBuffer, DWORD dwSrcId, DWORD dwRoleId)
{
	BOOL bResult = FALSE;
	KDelayRoleData sDelayData;
	KEscortCtrl* pEscortCtrl = NULL;
	KPlayer* pPlayer = g_cPlayerMgr.GetById(dwSrcId);
	PROCESS_ERROR(pPlayer);

	memset(&sDelayData, 0, sizeof(KDelayRoleData));
	memcpy(&sDelayData, piBuffer->GetData(), piBuffer->GetSize());

	pEscortCtrl = pPlayer->GetCtrl<KEscortCtrl>();
	pEscortCtrl->OnLoadDelayRoleDataRespond(dwSrcId, dwRoleId, &sDelayData);

	bResult = TRUE;
EXIT0:
	return bResult;
}
BOOL KPlayerBaseProcess::OnSyncMove( LPCBYTE pData, UINT uDataLen )
{
	KS2C_SYNC_MOVE* pReceived = (KS2C_SYNC_MOVE*)pData;
	KCharacter* pSceneObj = NULL;
	KCharacter* pFollowTarget = NULL;
	INT nX = 0, nY = 0, nZ = 0;

	if (IS_PLAYER(pReceived->dwId) || IS_NPC(pReceived->dwId))
		pSceneObj = KCharacterMgr::GetById(pReceived->dwId);
	else
		QLogPrintf(LOG_LEVEL_WARNING, "OnSyncMove unknown 0x%x", pReceived->dwId);
	PROCESS_ERROR(pSceneObj);

	if (pSceneObj->GetFollowTarget() != KD_BAD_ID)
		pFollowTarget = KCharacterMgr::GetById(pSceneObj->GetFollowTarget());

	 // 在开始移动的时候同步位置
	if (!pFollowTarget && cmsOnStand == pSceneObj->GetMoveState())
	{
		pSceneObj->SetPosition(pReceived->nX, pReceived->nY, pReceived->nZ);
	}
	else
	{
		pSceneObj->GetPosition(nX, nY, nZ);
		if (g_GetDistance2(nX, nY, pReceived->nX, pReceived->nY) > KD_FOLLOW_DISTANCE2_MAX)
		{
			pSceneObj->SetPosition(pReceived->nX, pReceived->nY, pReceived->nZ);
		}
	}

	pSceneObj->SetMoveMode(pReceived->nMoveMode);
	pSceneObj->GoTo(pReceived->nDestX, pReceived->nDestY, pReceived->nDestZ);
	pSceneObj->SetMoveState((KE_MOVE_STATE)pReceived->nMoveState);

EXIT0:
	if (pReceived && !pSceneObj)
	{
		QLogPrintf(LOG_LEVEL_WARNING, "OnSyncMove [0x%x] not found, re-syncing...", pReceived->dwId);
		//DoApplySyncNeighbor(pReceived->dwId);
		g_cOrpgWorld.AddApplySyncNeighbor(pReceived->dwId);
	}

	return TRUE;
}
Exemple #24
0
BOOL KDoodadMgr::CheckAutoPick(KDoodad* pDoodad)
{
	BOOL bResult = FALSE;
	KPlayer* pPlayer = NULL;

	pPlayer = g_cPlayerMgr.GetById(pDoodad->m_dwOwnerId);
	PROCESS_ERROR(pPlayer);

	// 经验直接给
	if(pDoodad->m_nGenre == 18 && pDoodad->m_nDetail == 1 && pDoodad->m_nParticular == 222)
	{
		g_cPlayerBaseProcess.DoPickUpDoodad(pPlayer, pDoodad->GetId(), FALSE);

		bResult = TRUE;
	}

EXIT0:
	return bResult;
}
BOOL KPlayerBaseProcess::OnSyncDoodadExtra( LPCBYTE pData, UINT uDataLen )
{
	BOOL bResult = FALSE;
	KDoodad* pDoodad = NULL;
	KS2C_SYNC_DOODAD_EXTRA* pReceived = NULL;
	BOOL bBegin = FALSE;
	DWORD* pdwExtraHeader = NULL;
	BYTE* pstExtraData = NULL;
	
	PROCESS_ERROR(pReceived = (KS2C_SYNC_DOODAD_EXTRA*)pData);
	PROCESS_ERROR(pDoodad = g_cDoodadMgr.GetById(pReceived->dwDoodadId));

	PROCESS_ERROR(pDoodad->BeginSetExtra());
	bBegin = TRUE;

	//PROCESS_ERROR(pDoodad->ClearExtra());
	pdwExtraHeader = (DWORD*)pReceived->acData;
	pstExtraData = (BYTE*)(pReceived->acData + pReceived->dwExtraCount * sizeof(DWORD));
	for (DWORD dwI = 0; dwI < pReceived->dwExtraCount; dwI++)
	{
		KDoodadExtraField* pstExtraField = NULL;

		pstExtraField = (KDoodadExtraField*)pstExtraData;
		if (0 == pstExtraField->dwType)
		{
			PROCESS_ERROR(pDoodad->SetExtraNumber(pstExtraField->dwId, pstExtraField->adwData[0], FALSE));
		}
		else if (1 == pstExtraField->dwType)
		{
			PROCESS_ERROR(pDoodad->SetExtraString(pstExtraField->dwId, (CONST CHAR*)pstExtraField->adwData, FALSE));
		}

		pstExtraData += pdwExtraHeader[dwI];
	}

	PROCESS_ERROR(pDoodad->EndSetExtra(FALSE));
	bBegin = FALSE;
	/*事件*/

	bResult = TRUE;
EXIT0:
	if (bBegin)
	{
		if (pDoodad)
		{
			pDoodad->EndSetExtra(FALSE);
		}
	}
	return bResult;
}
Exemple #26
0
BOOL KDoodadMgr::NotifyRemoveFromScene( DWORD dwId )
{
	BOOL bResult = FALSE;
	KDoodad* pstDoodad = NULL;

#ifdef GAME_SERVER
	PROCESS_ERROR(pstDoodad = GetById(dwId));
	if (pstDoodad->m_eState == emKDOODADSTATE_OPING)
	{
		pstDoodad->CancelDialog(pstDoodad->m_pCurrPlayer);
	}
	// 同步需要取场景,必须放在Uninit之前
	g_cPlayerBaseProcess.DoSyncLeave(*pstDoodad, TRUE);
#endif

	bResult = TRUE;
#ifdef GAME_SERVER
EXIT0:
#endif
	return bResult;
}
Exemple #27
0
BOOL KStageCtrl::Active()
{
	if(g_cOrpgWorld.m_dwLogicFrames % GAME_FPS != 0)
	{
		goto EXIT0;
	}

	PROCESS_ERROR(sMopInfo.nState == emMopStateDoing);

	if(sMopInfo.nLeftTime > 0)
	{
		--sMopInfo.nLeftTime;
		if(sMopInfo.nLeftTime <= 0)
		{
			OnFinishMop();
		}
	}

EXIT0:
	return TRUE;
}
Exemple #28
0
int KGameserverEyes::OnG2LCommonProtocol(BYTE* pData, size_t uDataLen)
{
	int nResult = 0;
	KSubProtocolHead* pHead = (KSubProtocolHead*)pData;

	PROCESS_ERROR(uDataLen == sizeof(KSubProtocolHead));

	/* 请求进程id */
	if (pHead->wSubProtocol == emKPROTOCOL_G2L_PIDREQ)
	{
		KPROTOCOL_L2G_PIDRET sRet;
		sRet.wProtocol = l2g_header_def;
		sRet.wSubProtocol = emKPROTOCOL_L2G_PIDRET;
		sRet.nPid = getpid();
		sRet.wServer = 0;
		m_Stream.PutPack(&sRet, sizeof(sRet));
	}

	nResult = 1;
EXIT0:
	return nResult;
}
Exemple #29
0
int KGameserverEyes::SendPlayerCount(int nOnline)
{
	int nResult = 0;
	l2e_PlayerCount* pPlayerCnt = NULL;
	size_t uPackLen = 0;
	int* pnCount = NULL;
	int i = 0;

	uPackLen = sizeof(l2e_PlayerCount) + sizeof(int) * emKGUARD_PLAYERCOUNT_COUNT;
	if ( uPackLen > m_uBufferLen )
	{
		if ( m_pszBuffer )
			free( m_pszBuffer );
		m_uBufferLen = 0;
		m_pszBuffer = NULL;
		m_pszBuffer = (char*)malloc(uPackLen);
		PROCESS_ERROR(m_pszBuffer);
		m_uBufferLen = uPackLen;
	}
	pPlayerCnt = (l2e_PlayerCount*)m_pszBuffer;
	pPlayerCnt->wProtocol = l2e_header_def;
	pPlayerCnt->wSubProtocol = l2e_PlayerCount_def;
	pPlayerCnt->uCount = emKGUARD_PLAYERCOUNT_COUNT;
	pPlayerCnt->wServer = 0;

	pnCount = (int*)(pPlayerCnt + 1);
	for ( i = 0; i < emKGUARD_PLAYERCOUNT_COUNT; i++ )
	{
		pnCount[i] = 0;
	}
	pnCount[emKGUARD_PLAYERCOUNT_TOTOAL] = nOnline;

	m_Stream.PutPack(pPlayerCnt, uPackLen);

	nResult = 1;
EXIT0:
	return nResult;
}
Exemple #30
0
int KGameserverEyes::Init(int nKey)
{
	int nResult = 0;
	int nRet = 0;

	nRet = KEyes::Init(nKey);
	PROCESS_ERROR(nRet);

	m_fLastPerformance          = 0.0f;
	m_fLastClientFlux           = 0.0f;

	nRet = GetSelfName(m_szSelfName, sizeof(m_szSelfName));
	LOG_CHECK_ERROR(nRet);

	//m_pMapDesc = (l2e_update_map_list::KMapDesc*)malloc(KD_GSEYE_DEFAULT_MAP_COUNT*sizeof(l2e_update_map_list::KMapDesc));
	//PROCESS_ERROR(m_pMapDesc);
	m_nMapDesc = KD_GSEYE_DEFAULT_MAP_COUNT;
	m_nCurMapDesc = 0;

	nResult = 1;
EXIT0:
	return nResult;
}