예제 #1
0
파일: Socket.cpp 프로젝트: TuffLuck/znc
bool CSocket::Listen(unsigned short uPort, bool bSSL, unsigned int uTimeout) {
	if (!m_pModule) {
		DEBUG("ERROR: CSocket::Listen called on instance without m_pModule handle!");
		return false;
	}

	CUser* pUser = m_pModule->GetUser();
	CString sSockName = "MOD::L::" + m_pModule->GetModName();

	if (pUser) {
		sSockName += "::" + pUser->GetUserName();
	}
	// Don't overwrite the socket name if one is already set
	if (!GetSockName().empty()) {
		sSockName = GetSockName();
	}

	return m_pModule->GetManager()->ListenAll(uPort, sSockName, bSSL, SOMAXCONN, this);
}
예제 #2
0
파일: uilogin.cpp 프로젝트: caticat/chat
void UILogin::onLogin()
{
	QString qstrName = m_pLedit->text();
	strcpy_s(g_name,CONST_MAX_NAME_LEN,qstrName.toLocal8Bit());
	CPReqLogin rlogin;
	INIT_CP(rlogin);
	strcpy_s(rlogin.name,CONST_MAX_NAME_LEN,g_name);
	client.Send(EPReq_Login,rlogin);
	//emit onLoginClicked(qstrName);
}
예제 #3
0
/**
 * @brief	Generates a list of the top 10 clan leaders eligible to nominate a King.
 * 			NOTE: These players are senators.
 */
void CKingSystem::LoadRecommendList()
{
	FastGuard lock(m_lock);
	m_top10ClanSet.clear();
	for (int i = 1; i <= 10; i++)
	{
		// Lookup the clan ranking #i.
		_KNIGHTS_RATING * pRating = 
			g_pMain->m_KnightsRatingArray[m_byNation].GetData(i);
		CKnights * pKnights = NULL;

		// Ignore this entry if no such clan is ranked #i
		if (pRating == NULL
			// or for whatever reason the clan no longer exists...
			|| (pKnights = g_pMain->GetClanPtr(pRating->sClanID)) == NULL)
			continue;

		// Add user as senator.
		UpdateElectionList(3, false, pRating->sClanID, pKnights->m_strChief);

		// If the senator's online, we can send them an announcement
		// to tell them they can nominate a King.
		CUser * pUser = g_pMain->GetUserPtr(pKnights->m_strChief, TYPE_CHARACTER);
		if (pUser != NULL)
		{
			Packet result;
			std::string notice;

			// %s can nominate a King
			g_pMain->GetServerResource(IDS_KING_RECOMMEND_REQUEST_MESSAGE, &notice, pKnights->m_strChief.c_str());

			// Wrap it in a "#### NOTICE : ####" block.
			g_pMain->GetServerResource(IDP_ANNOUNCEMENT, &notice, notice.c_str());

			// Construct & send the chat/announcement packet
			ChatPacket::Construct(&result, WAR_SYSTEM_CHAT, &notice);
			pUser->Send(&result);
		}

		// add to our top 10 ranked clan set.
		m_top10ClanSet.insert(pRating->sClanID);
	}
}
예제 #4
0
// 현재 대전장 종료하고 마을로 텔레포트
void	CGuildCombat1to1::GuildCombat1to1Close()
{
	ClearTime();
	m_nState = GC1TO1WAR_CLOSE;

	CUser* pUser = NULL;
	for( int i=0; i<2; i++ )
	{
		for( int j=0; j<(int)( m_vecTenderGuild[m_nIndex[i]].vecMemberId.size() ); j++ )
		{
			pUser = (CUser*)prj.GetUserByID( m_vecTenderGuild[m_nIndex[i]].vecMemberId[j] );
			if( IsPossibleUser( pUser ) )
			{
				SendNowState( pUser );
				pUser->REPLACE( g_uIdofMulti, WI_WORLD_MADRIGAL, D3DXVECTOR3( 6983.0f, 0.0f, 3326.0f ), REPLACE_NORMAL, nDefaultLayer );
			}
		}
	}
}
예제 #5
0
파일: Client.cpp 프로젝트: MrLenin/znc
void CAuthBase::RefuseLogin(const CString& sReason) {
    if (!m_pSock) return;

    CUser* pUser = CZNC::Get().FindUser(GetUsername());

    // If the username is valid, notify that user that someone tried to
    // login. Use sReason because there are other reasons than "wrong
    // password" for a login to be rejected (e.g. fail2ban).
    if (pUser) {
        pUser->PutStatus("A client from [" + GetRemoteIP() +
                         "] attempted "
                         "to login as you, but was rejected [" +
                         sReason + "].");
    }

    GLOBALMODULECALL(OnFailedLogin(GetUsername(), GetRemoteIP()), NOTHING);
    RefusedLogin(sReason);
    Invalidate();
}
예제 #6
0
void CUser::MagicType1(uint32 magicid, uint16 sid, uint16 tid, uint16 data1, uint16 data2, uint16 data3, uint16 data4, uint16 data5, uint16 data6, uint16 data7)
{

    int16 damage = GetDamage(tid, magicid); //Get the amount of damage that will be inflicted.

    _MAGIC_TABLE* pMagic = m_pMain->m_MagictableArray.GetData( magicid ); //Checking if the skill exists has already happened.

    _MAGIC_TYPE1* pMagic_Type1 = m_pMain->m_Magictype1Array.GetData( magicid );
    if( !pMagic_Type1 ) //Shouldn't be necessary unless there's a mismatch in the database.
        return;

    CUser* pTUser = m_pMain->GetUserPtr(tid);     // Get target info.
    if (!pTUser || pTUser->isDead())
        return;

    pTUser->HpChange( -damage );     // Reduce target health point.

    if( pTUser->isDead() ) {    // Check if the target is dead.
        pTUser->m_bResHpType = USER_DEAD;     // Target status is officially dead now.

        if(sid >= NPC_BAND)
            pTUser->ExpChange( -pTUser->m_iMaxExp/100 );     // Reduce target's experience if the source was an NPC.

        if( m_sPartyIndex == -1 ) {    // If the user is not in a party allocate all the National Points to the user, ifnot, divide it between the party.
            LoyaltyChange(tid);
        }
        else {
            LoyaltyDivide(tid);
        }

        GoldChange(tid, 0); //Reward the killer with the money he deserves.

        pTUser->InitType3();	// Re-initialize buffs on the dead person
        pTUser->InitType4();	// Re-initialize buffs on the dead person

        pTUser->m_sWhoKilledMe = sid;
    }
    SendTargetHP( 0, tid, -damage );     // Change the HP of the target.
    if(pMagic->bType2 > 0 && pMagic->bType2 != 1)
        MagicType(pMagic->bType2); //If the skill has a second effect, be sure to cast that one too.

packet_send:
    if (pMagic->bType2 == 0 || pMagic->bType2 == 1) {
        Packet result(WIZ_MAGIC_PROCESS);
        result << MAGIC_EFFECTING << magicid << sid << tid << data1 << data2 << data3;
        if (damage == 0) {
            result << int16(-104);
        }
        else {
            result << uint16(0);
        }

        m_pMain->Send_Region( &result, GetMap(), m_RegionX, m_RegionZ );
    }

    return;
}
예제 #7
0
void CAISocket::RecvMagicAttackResult(Packet & pkt)
{
	uint32 magicid;
	uint16 sid, tid;
	uint8 byCommand; 

	/* 
		This is all so redundant...
		When everything's switched over to pass in Packets
		we can just pass it through directly!
		As it is now.. we still need a length (which we can hardcode, but meh)
	*/
	pkt >> byCommand >> magicid >> sid >> tid;

	pkt.SetOpcode(WIZ_MAGIC_PROCESS);
	if (byCommand == MAGIC_CASTING
		|| (byCommand == MAGIC_EFFECTING && sid >= NPC_BAND && tid >= NPC_BAND))
	{
		CNpc *pNpc = g_pMain->m_arNpcArray.GetData(sid);
		if (!pNpc)
			return;

		pNpc->SendToRegion(&pkt);
	}
	else if (byCommand == MAGIC_EFFECTING)
	{
		if (sid >= USER_BAND && sid < NPC_BAND)
		{
			CUser *pUser = g_pMain->GetUserPtr(sid);
			if (pUser == NULL || pUser->isDead())
				return;

			pUser->SendToRegion(&pkt);
			return;
		}

		// If we're an NPC, casting a skill (rather, it's finished casting) on a player...
		pkt.rpos(0);
		m_MagicProcess.MagicPacket(pkt);
	}
	
}
예제 #8
0
void CPacketProcess::SendUserInfo(CUser * pUser)
{
	CSendPacket * pSendPacket;
	CUserList * pUserList = SMemManager()->GetUserList();
	CUser * pAllUser;

	pSendPacket = SMemManager()->AllocPerSendPacket();
	// 접속자 정보를 보내 준다.
	pSendPacket->Begin();
	pSendPacket->Set8Bit(MSG_SERV_LOGINOK);
	pSendPacket->Set16Bit((short)pUser->GetDatabaseID());
	pSendPacket->Set16Bit((short)SMemManager()->GetCurrentUser());

	// 사용자 정보가 많으면 패킷에 다 못넣으니깐.. 다른 처리 필요.
	pAllUser = pUserList->GetFirstUser();
	while(pAllUser != NULL)
	{
		if(pAllUser->IsOnline())
		{
			pSendPacket->Set16Bit((short)pAllUser->GetDatabaseID());
			pSendPacket->SetString(pAllUser->GetUserNickname());
			// 일단 보내는 패킷의 크기로 패킷의 크기를 넘어서면 사용자 정보 입력을 그만 둔다.
			// 패킷을 완성하고 보낸다. 그리고 다시 연결 패킷을 만들어 보낸다.
			// 이거 아마 동기화 안맞추어주어서 에러 날거 같다.. 난중에 테스트 필!
			// 여기서 유저의 마지막까지 왔는데 패킷이 다찾을때 다음 유저가 널이니까. 버그다..(무슨말인지 알지?)
			if(((pSendPacket->GetSize() + MAX_NICKNAME_LEN + 2) > MAX_PACKETBUFFER_LEN))
			{
				pSendPacket->End();
				pUser->GetSendQueue()->AddTail(pSendPacket);
				pUser->SendPost();

				pSendPacket = SMemManager()->AllocPerSendPacket();
				pSendPacket->Begin();
				pSendPacket->Set8Bit(MSG_SERV_USERLIST);
			}
		}
		pAllUser = pUserList->GetNext(pAllUser);
	}
	pSendPacket->End();
	pUser->GetSendQueue()->AddTail(pSendPacket);
	pUser->SendPost();
}
예제 #9
0
파일: DDom.cpp 프로젝트: careysky/FlyFF
void CDDom::ReturnAll( void )
{
	//CItemElem item;
	//item.m_dwItemId = II_CHR_FOO_COO_REMANTIS;
	//item.m_nItemNum = 5;

	for( vector<u_long>::iterator it = m_User.begin(); it != m_User.end(); ++it )
	{
		CUser* pUser		= static_cast<CUser*>( prj.GetUserByID( (*it) ) );
		if( IsValidObj( pUser ) )
		{
			pUser->m_ddomTeam = MAX_TEAM;
			pUser->SendAdditionalMover( pUser );
			pUser->AddTextD3D( "Thank you for participating", DoubleDom::Color::nBlueCol );
			pUser->Replace( g_uIdofMulti, WI_WORLD_MADRIGAL, D3DXVECTOR3( 6971.0F, 100.0F, 3327.0F ), REPLACE_FORCE, nDefaultLayer );
			//item.SetSerialNumber();
			//g_dpDBClient.SendQueryPostMail( pUser->m_idPlayer, 0, item, 10000, "Double Domination", "Thank you for participating" );
		}
	}
}			
예제 #10
0
void	CPocketController::ProcessExpiring( void )
{
    if( m_pMover->IsNPC() )
        return;
    CUser* pUser	= (CUser*)m_pMover;

    for( int i = 1; i < MAX_POCKET; i++ )
    {
        if( IsAvailable( i ) )
        {
            if( time_null() > m_apPocket[i]->GetExpirationDate() )
            {
                SetAttribute( expired, i, TRUE );
#ifdef __INTERNALSERVER
                pUser->AddPocketView();
#endif	// __INTERNAL_SERVER
            }
        }
    }
}
예제 #11
0
bool CUserPageBuilder::CreatePageOwner(int iUserID, CUser& Owner)
{
	TDVASSERT(iUserID > 0, "CUserPageBuilder::CreatePageOwner(...) called with non-positive ID");

	// create the user object from this ID
	// note that even if the ID is invalid it may not fail at this point
	// due to delayed DB access or whatnot, hence must continue to check
	// all return values for methods called
	Owner.SetSiteID(m_InputContext.GetSiteID());
	bool bSuccess = Owner.CreateFromID(iUserID);
	// check if user is actually active and not a dud
	if (bSuccess)
	{
		bool bActive = false;
		bSuccess = Owner.GetActive(&bActive);
		bSuccess = bSuccess && bActive;
	}
	// return the new object, or NULL for failure
	return bSuccess;
}
예제 #12
0
파일: WebModules.cpp 프로젝트: notry4n/znc
CWebSock::~CWebSock() {
	if (!m_spAuth.IsNull()) {
		m_spAuth->Invalidate();
	}

	// we have to account for traffic here because CSocket does
	// not have a valid CModule* pointer.
	CUser *pUser = GetSession()->GetUser();
	if (pUser) {
		pUser->AddBytesWritten(GetBytesWritten());
		pUser->AddBytesRead(GetBytesRead());
	} else {
		CZNC::Get().AddBytesWritten(GetBytesWritten());
		CZNC::Get().AddBytesRead(GetBytesRead());
	}

	// bytes have been accounted for, so make sure they don't get again:
	ResetBytesWritten();
	ResetBytesRead();
}
예제 #13
0
//
// 파티원들에게 bWin에 따라 승/패 사실을 알리고 듀얼을 종료시킴.
//
void CParty::DoDuelResult( CParty *pDuelOther, BOOL bWin, int nAddFame, float fSubFameRatio )
{
	CUser *pMember;
	int		i;
	
	for( i = 0; i < m_nSizeofMember; i ++ )
	{
		pMember = g_UserMng.GetUserByPlayerID( m_aMember[i].m_uPlayerId );
		if( IsValidObj( pMember ) )
		{
			pMember->AddDuelPartyResult( pDuelOther, bWin );		// 각 멤버들에게 승/패 사실을 알림. / 상대파티원 리스트도 보냄.
			pMember->ClearDuelParty();

			if( bWin )
			{
				pMember->m_nFame += nAddFame;	// 이긴측이면 명성 증가
				pMember->AddDefinedText( TID_GAME_GETFAMEPOINT, "%d", nAddFame );	// xxx 명성 포인트가 증가
#ifdef __WORLDSERVER
				g_dpDBClient.SendLogPkPvp( pMember, NULL, nAddFame, 'E' );
#endif // __WORLDSERVER
			} 
			else
			{
				int nDecVal;
				fSubFameRatio = fSubFameRatio / 100.0f;	// 비율로 환산.
				nDecVal = (int)(pMember->m_nFame * fSubFameRatio);
				if( nDecVal == 0 )	nDecVal = 1;
				pMember->m_nFame -= nDecVal;
				if( pMember->m_nFame < 0 )	pMember->m_nFame = 0;
				pMember->AddDefinedText( TID_GAME_DECFAMEPOINT, "%d", nDecVal );	// xxx 명성 포인트가 감소.
#ifdef __WORLDSERVER
				g_dpDBClient.SendLogPkPvp( NULL, pMember, nAddFame, 'E' );
#endif // __WORLDSERVER
			}
			
			// 바뀐 명성치를 pMember의 주위에 날려줌.
			g_UserMng.AddSetFame( pMember, pMember->m_nFame );
		}
	}
	m_idDuelParty = 0;
}
예제 #14
0
	void CloneUser(const CString& sLine) {
		if (!m_pUser->IsAdmin()) {
			PutModule("Error: You need to have admin rights to add new users!");
			return;
		}

		const CString
			sOldUsername = sLine.Token(1),
			sNewUsername = sLine.Token(2, true);

		if (sOldUsername.empty() || sNewUsername.empty()) {
			PutModule("Usage: cloneuser <oldusername> <newusername>");
			return;
		}

		CUser *pOldUser = CZNC::Get().FindUser(sOldUsername);

		if (!pOldUser) {
			PutModule("Error: User [" + sOldUsername + "] not found!");
			return;
		}

		CUser* pNewUser = new CUser(sOldUsername);
		CString sError;
		if (!pNewUser->Clone(*pOldUser, sError)) {
			delete pNewUser;
			PutModule("Error: Cloning failed! [" + sError + "]");
			return;
		}
		pNewUser->SetUserName(sNewUsername);
		pNewUser->SetIRCConnectEnabled(false);

		if (!CZNC::Get().AddUser(pNewUser, sError)) {
			delete pNewUser;
			PutModule("Error: User not added! [" + sError + "]");
			return;
		}

		PutModule("User [" + sNewUsername + "] added!");
		return;
	}
예제 #15
0
bool CPacketProcess::FromToMessage(CUser * pUser)
{
	CUserList * pUserList = SMemManager()->GetUserList();
	char szTempBuffer[MAX_PACKETBUFFER_LEN];
	short fromUserID, toUserID;

	if(!pUser->GetRecvPacket()->Get16Bit((short)fromUserID))
	{
		ServerLog()->Log("To User Message : fromUserID get Error.");
		return false;
	}
	
	if(!pUser->GetRecvPacket()->Get16Bit((short)toUserID))
	{
		ServerLog()->Log("To User Message : toUserID get Error.");
		return false;
	}
	
	if(!pUser->GetRecvPacket()->GetString(szTempBuffer, MAX_PACKETBUFFER_LEN))
	{
		ServerLog()->Log("To User Message : Message get Error.");
		return false;
	}

	if((fromUserID > MSG_ADMIN_ID) && (toUserID > MSG_ADMIN_ID) && (toUserID != fromUserID))
	{
		ServerLog()->Log("Client(%d) to Client (%d) Send Message.", fromUserID, toUserID);
		CUser * pToUser = pUserList->FindUser(toUserID);
		if(pToUser != NULL)
		{
			pToUser->SendClientMessage(MSG_SERV_TOUSERMSG, fromUserID, szTempBuffer);
			pUser->SendClientMessage(MSG_SERV_TOUSERMSG, fromUserID, szTempBuffer);
		}
		pUser->SetIsAlive(true);
	}
	else
	{
		ServerLog()->Log("from ID(%d), to ID(%d) Send Message Error.", fromUserID, toUserID);
	}
	return true;
}
예제 #16
0
void CUserManage::ReceivedData( int length )
{
	//检验数据
	if( !CheckSum( length ) )
		return;

	char* p = &m_pRecvBuff[4];

	char Index[MAX_PATH];
	sprintf( Index, "%s:%d", inet_ntoa( m_FromAddr.sin_addr ), htons(m_FromAddr.sin_port) );
	CUser* pUser = m_UserMap.GetData( Index );
	if( !pUser )
	{
		pUser = new CUser;
		pUser->Init( this, inet_ntoa( m_FromAddr.sin_addr ), htons(m_FromAddr.sin_port) );
		m_UserMap.PutData( Index, pUser );
	}
	pUser->PutData( m_pRecvBuff, length );
	m_pUdpManage->m_EventQueue.push( pUser );
	PostQueuedCompletionStatus( m_pUdpManage->m_hWorkerIOCPort, (DWORD)0, m_Sid, NULL/*pOvl*/ );
}
예제 #17
0
int __AddAnswer( int nPcId, LPCTSTR lpszWord, LPCTSTR lpszKey, DWORD dwParam1, int nQuest )
{
	CHAR szKey[ 128 ], szWord[ 128 ];

	strcpy( szWord, lpszWord );

	if( lpszKey[0] == '\0' ) 
		strcpy( szKey, szWord );
	else
		strcpy( szKey, lpszKey );

	CUser* pUser = prj.GetUser( nPcId );
	RunScriptFunc rsf;
	rsf.wFuncType		= FUNCTYPE_ADDANSWER;
	lstrcpy( rsf.lpszVal1, szWord );
	lstrcpy( rsf.lpszVal2, szKey );
	rsf.dwVal1 = (DWORD)dwParam1;
	rsf.dwVal2 = nQuest;
	pUser->AddRunScriptFunc( rsf );
	return 1;
}
예제 #18
0
void CGameSocket::RecvUserSetHP(char* pBuf)
{
	int index = 0, nHP = 0;
	short uid=-1;
	

	uid = GetShort( pBuf, index );
	nHP = GetDWORD( pBuf, index );

	// User List에서 User정보,, 삭제...
	CUser* pUser = m_pMain->GetUserPtr(uid);
	if(pUser == NULL)	return;

	if(pUser->m_sHP != nHP)	{
		pUser->m_sHP = nHP;
		//TRACE("**** RecvUserSetHP -- uid = %d, name=%s, HP = %d\n", uid, pUser->m_strUserID, pUser->m_sHP);
		if(pUser->m_sHP <= 0)	{
			pUser->Dead(-100, 0);
		}
	}
}
예제 #19
0
파일: DDom.cpp 프로젝트: careysky/FlyFF
void CDDomTeam::SendPrize( void )
{
	for( vector<DOMPLAYER>::iterator it = m_TeamPlayer.begin(); it != m_TeamPlayer.end(); ++it )
	{
		CUser*	pUser		= static_cast<CUser*>( prj.GetUserByID( it->idObj ) );
		if(	IsValidObj( pUser ) )
		{
			pUser->AddTextD3D( "You have won the Double Domination match!", DoubleDom::Color::nBlueCol );
			//item.SetSerialNumber();
	//		if( pUser->CreateItem( item ) == FALSE )
			//{
			//	g_dpDBClient.SendQueryPostMail( pUser->m_idPlayer, 0, item, 10000, "Double Domination", "You have won the match." );
			//}
		}
		else if( it->idObj != 0 )
		{
			//item.SetSerialNumber();
			//g_dpDBClient.SendQueryPostMail( pUser->m_idPlayer, 0, item, 10000, "Double Domination", "You have won the match." );
		}
	}
}
예제 #20
0
파일: User.cpp 프로젝트: adan830/GameServer
void CUser::SendShow(const USER_SET& setUsers)
{
	CHECK(!setUsers.empty());

	CMsgNetwork msgNetwork;

	CMsgRoleInfo* pMsgRoleInfo = msgNetwork.mutable_msgroleinfo();
	CHECK(this->FillMsgRoleInfo(pMsgRoleInfo, ROLEINFOACT_OTHER_NEW));

	for (USER_SET::iterator it = setUsers.begin(); it != setUsers.end(); ++it)
	{
		CUser* pUser = *it;
		if (pUser == NULL)
		{
			continue;
		}
		msgNetwork.add_idpeer(pUser->GetID());
	}

	CGameKernel::getInstance()->SendPipeMessage(THREAD_INDEX_SERVER_SOCKET, &msgNetwork);
}
예제 #21
0
파일: DDom.cpp 프로젝트: careysky/FlyFF
void CDDom::StartRound( void )
{
	if( GetRunTime() != RUN_COOLDOWN )
		return;

	CString strRound;
	strRound.Format( "The round: %u has begun", m_dwRound +1 );
	for( vector<u_long>::iterator it = m_User.begin(); it != m_User.end(); ++it )
	{
		CUser*	pUser	= static_cast<CUser*>( prj.GetUserByID( (*it ) ) );
		if( IsValidObj( pUser ) )
		{
			pUser->AddTextD3D( strRound, DoubleDom::Color::nBlueCol );
			Safe( pUser );
		} 
	}

	SendTouch( MAX_TEAM, BASE_A );
	SendTouch( MAX_TEAM, BASE_B ); 
	SetRunTime( RUN_FIGHT );
}
예제 #22
0
int __AddKey( int nPcId, LPCTSTR lpszWord, LPCTSTR lpszKey, DWORD dwParam )
{
	CHAR szKey[ 128 ], szWord[ 128 ];

	strcpy( szWord, lpszWord );

	if( lpszKey[0] == '\0' ) 
		strcpy( szKey, szWord );
	else
		strcpy( szKey, lpszKey );

	CUser* pUser	= prj.GetUser( nPcId );
	RunScriptFunc rsf;
	rsf.wFuncType		= FUNCTYPE_ADDKEY;
	lstrcpy( rsf.lpszVal1, szWord );
	lstrcpy( rsf.lpszVal2, szKey );
	rsf.dwVal1	= dwParam;
	rsf.dwVal2 = 0;
	pUser->AddRunScriptFunc( rsf );
	return 1;
}
예제 #23
0
void CUser::ExchangeAgree(Packet & pkt)
{
	if (!isTrading()
		|| isDead())
		return;

	uint8 bResult = pkt.read<uint8>();
	CUser *pUser = g_pMain->GetUserPtr(m_sExchangeUser);
	if (pUser == nullptr) 
	{
		m_sExchangeUser = -1;
		return;
	}
	
	if (pUser->isDead() || pUser->isStoreOpen() || pUser->isMerchanting())
	{
		m_sExchangeUser = -1;
		return;
	}

	if (!bResult || pUser->isDead()) // declined
	{
		m_sExchangeUser = -1;
		pUser->m_sExchangeUser = -1;
		bResult = 0;
	}

	Packet result(WIZ_EXCHANGE, uint8(EXCHANGE_AGREE));
	result << uint16(bResult);
	pUser->Send(&result);
}
예제 #24
0
uint32 CEbenezerDlg::Timer_UpdateSessions(void * lpParam)
{
	while (g_bRunning)
	{
		SessionMap & sessMap = g_pMain->m_socketMgr.GetActiveSessionMap();
		foreach (itr, sessMap)
		{
			CUser * pUser = TO_USER(itr->second);
			uint32 timeout = KOSOCKET_TIMEOUT;

			// User has authed, but isn't in-game yet (creating a character, or is waiting for the game to load).
			if (!pUser->m_strAccountID.empty() && !pUser->isInGame())
				timeout = KOSOCKET_LOADING_TIMEOUT;

			// Disconnect timed out sessions
			if ((UNIXTIME - pUser->GetLastResponseTime()) >= timeout)
			{
				pUser->Disconnect();
				continue;
			}

			// Update the player, and hence any skill effects while we're here.
			if (pUser->isInGame())
				pUser->Update();
		}
		g_pMain->m_socketMgr.ReleaseLock();
		sleep(30 * SECOND);
	}
예제 #25
0
void CUser::ExchangeReq(Packet & pkt)
{
	Packet result(WIZ_EXCHANGE);
	if (isDead())
		goto fail_return;
	else if (isTrading())
	{
		ExchangeCancel();
		return;
	}

	uint16 destid = pkt.read<uint16>();
	CUser* pUser = g_pMain->GetUserPtr(destid);
	if (pUser == NULL
		|| pUser->isTrading()
		|| (pUser->getNation() != getNation() && pUser->getZoneID() != 21 && getZoneID() != 21)
		|| pUser->getZoneID() != getZoneID())
		goto fail_return;

	m_sExchangeUser = destid;
	pUser->m_sExchangeUser = GetSocketID();

	result << uint8(EXCHANGE_REQ) << GetSocketID();
	pUser->Send(&result);
	return;

fail_return:
	result << uint8(EXCHANGE_CANCEL);
	Send(&result);
}
예제 #26
0
void CGameSocket::RecvAttackReq(Packet & pkt)
{
	uint16 sid, tid;
	float rx=0.0f, ry=0.0f, rz=0.0f, fDir = 0.0f, fHitAgi, fAvoidAgi;
	short sDamage, sAC, sItemAC, sAmountLeft, sAmountRight;
	BYTE type, result, bTypeLeft, bTypeRight;

	pkt >> type >> result >> sid >> tid >> sDamage >> sAC >> fHitAgi >> fAvoidAgi
		>> sItemAC >> bTypeLeft >> bTypeRight >> sAmountLeft >> sAmountRight;

	CUser* pUser = g_pMain->GetUserPtr(sid);
	if(pUser == NULL) return;

	if(pUser->m_bLive == USER_DEAD || pUser->m_sHP <= 0)
	{
		if(pUser->m_sHP > 0)
		{
			pUser->m_bLive = USER_LIVE;
			TRACE("##### CGameSocket-Attack Fail : User가 Heal된 경우.. [id=%d, %s, bLive=%d, hp=%d] ######\n", pUser->m_iUserId, pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP);
		}		
		else
		{
			TRACE("##### CGameSocket-Attack Fail : UserDead  [id=%d, %s, bLive=%d, hp=%d] ######\n", pUser->m_iUserId, pUser->m_strUserID, pUser->m_bLive, pUser->m_sHP);
			// 죽은 유저이므로 게임서버에 죽은 처리를 한다...
			Send_UserError(sid, tid);
			return;
		}
	}
	pUser->m_sHitDamage = sDamage;
	pUser->m_fHitrate = fHitAgi;
	pUser->m_fAvoidrate = fAvoidAgi;
	pUser->m_sAC = sAC;
	pUser->m_sItemAC = sItemAC;
	pUser->m_bMagicTypeLeftHand = bTypeLeft;
	pUser->m_bMagicTypeRightHand = bTypeRight;
	pUser->m_sMagicAmountLeftHand = sAmountLeft;
	pUser->m_sMagicAmountRightHand = sAmountRight;

	pUser->Attack(sid, tid);
}
예제 #27
0
	void GetChan(const CString& sLine) {
		const CString var  = sLine.Token(1).AsLower();
		CString username   = sLine.Token(2);
		CString chan = sLine.Token(3, true);

		if (var.empty()) {
			PutModule("Usage: getchan <variable> [username] <chan>");
			return;
		}
		if (chan.empty()) {
			chan = username;
			username = "";
		}
		if (username.empty()) {
			username = m_pUser->GetUserName();
		}

		CUser* user = GetUser(username);
		if (!user)
			return;

		CChan* pChan = user->FindChan(chan);
		if (!pChan) {
			PutModule("Error: Channel not found: " + chan);
			return;
		}

		if (var == "defmodes")
			PutModule("DefModes = " + pChan->GetDefaultModes());
		else if (var == "buffer")
			PutModule("Buffer = " + CString(pChan->GetBufferCount()));
		else if (var == "inconfig")
			PutModule("InConfig = " + pChan->InConfig());
		else if (var == "keepbuffer")
			PutModule("KeepBuffer = " + pChan->KeepBuffer());
		else if (var == "detached")
			PutModule("Detached = " + pChan->IsDetached());
		else
			PutModule("Error: Unknown variable");
	}
예제 #28
0
void CParty::ReplaceLodestar( const CRect &rect )
{
	// locked
	CUser* pUser;
	for( int i = 0; i < m_nSizeofMember; i ++ )		// 극단원 모두에게 듀얼 해제를 세팅하고 클라에도 알림.
	{
		pUser	= g_UserMng.GetUserByPlayerID( m_aMember[i].m_uPlayerId );

		if( IsValidObj( pUser ) )
		{
			CWorld* pWorld	= pUser->GetWorld();
			if( pWorld )
			{
				POINT point	= { (int)pUser->GetPos().x, (int)pUser->GetPos().z	};
				if( rect.PtInRect( point ) )
				{
					PRegionElem pRgnElem	= NULL;
					if( pWorld->GetID() != pWorld->m_dwIdWorldRevival && pWorld->m_dwIdWorldRevival != 0 )
						pRgnElem	= g_WorldMng.GetRevivalPos( pWorld->m_dwIdWorldRevival, pWorld->m_szKeyRevival );
					if( !pRgnElem )	// Find near revival pos
						pRgnElem	= g_WorldMng.GetNearRevivalPos( pWorld->GetID(), pUser->GetPos() );
					if( pRgnElem )
						pUser->REPLACE( g_uIdofMulti, pRgnElem->m_dwWorldId, pRgnElem->m_vPos, REPLACE_NORMAL, nRevivalLayer );
				}
			}
		}
	}
}
예제 #29
0
// function CChatRoom::Post
//  posts a chat message to this chat room
void CChatRoom::Post(int from, const char* message, size_t msglen )
{
	if ( !m_bActive )
	{
		CLog::Error("Could not send a chat message - Chat not intialized", __FUNCTION__);
		return;
	}
	Pthread_mutex_lock(&m_InsideUsersMutex, __FUNCTION__);
	
	list<int>::iterator iter;
	Pthread_mutex_lock(&CUser::m_UserMutex, __FUNCTION__);
	
	for ( iter = m_UsersInside.begin(); iter != m_UsersInside.end(); iter++ )
	{
		CUser* curr = CUser::GetUser(*iter);
		if ( curr != NULL )
		{
			char pack = PACK_CHATMESSAGE;
			unsigned short sendlen = (unsigned short)msglen;
			
			//unsigned short stuff = 13;
	//		CLog::Record("Sending PACK_CHATMESSAGE to %s", curr->GetName());
			curr->SendTo((const char*)&pack, sizeof(char));
			// prepend the message length
			curr->SendTo((const char*)&sendlen, sizeof(unsigned short));

			curr->SendTo((const char*)&from, sizeof(int));
			curr->SendTo((const char*)&this->m_ChatID, sizeof(int));
			curr->SendTo(message, msglen);
		}
	}
	Pthread_mutex_unlock(&CUser::m_UserMutex, __FUNCTION__);
	Pthread_mutex_unlock(&m_InsideUsersMutex, __FUNCTION__);
}
예제 #30
0
파일: Service.cpp 프로젝트: xdkxlk/LMS
/*
收到的数据格式
{
"friends": [
	{"name": "n1", "status": 0},
	{"name":"n2", "status": 1}
	] //0为在线,1在线
	"group": ["group1","group2"]
}
*/
bool CUserService::login(CString name, CString pass, CUser& user)
{
	CUser temp;
	temp.m_userName = name;
	temp.m_password = pass;

	string resData;
	if (!this->sendData("/login", temp.getJson(), resData))
		return false;

	if (this->getCode(resData) != CODE::SUCCESS)
		return false;

	Json::Value jsonObj;
	CJsonUtil::genJsonVal(resData, jsonObj);
	jsonObj = jsonObj["data"];

	user.m_userName = name;
	user.m_password = pass;
	Json::Value friendJsonArray = jsonObj["friends"];
	for (int i = 0; i < friendJsonArray.size(); i++)
	{
		CFriend* fri = new CFriend();
		fri->m_userName = CString(friendJsonArray[i]["name"].asCString());
		fri->m_status = friendJsonArray[i]["status"].asInt();

		user.addFriend(fri);
	}

	Json::Value groupJsonArray = jsonObj["group"];
	for (int i = 0; i < groupJsonArray.size(); i++)
	{
		CGroup* g = new CGroup();
		g->m_name = CString(groupJsonArray[i].asCString());

		user.addGroup(g);
	}

	return true;
}