本文整理汇总了C++中CUser类的典型用法代码示例。如果您正苦于以下问题:C++ CUser类的具体用法?C++ CUser怎么用?C++ CUser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DEBUG
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: lock
/**
* @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, ¬ice, pKnights->m_strChief.c_str());
// Wrap it in a "#### NOTICE : ####" block.
g_pMain->GetServerResource(IDP_ANNOUNCEMENT, ¬ice, notice.c_str());
// Construct & send the chat/announcement packet
ChatPacket::Construct(&result, WAR_SYSTEM_CHAT, ¬ice);
pUser->Send(&result);
}
// add to our top 10 ranked clan set.
m_top10ClanSet.insert(pRating->sClanID);
}
}
示例3: ClearTime
// 현재 대전장 종료하고 마을로 텔레포트
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 );
}
}
}
}
示例4: RefuseLogin
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();
}
示例5: GetDamage
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;
}
示例6: length
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);
}
}
示例7: SMemManager
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();
}
示例8: ReturnAll
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" );
}
}
}
示例9: SetAttribute
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
}
}
}
}
示例10: TDVASSERT
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;
}
示例11: GetSession
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();
}
示例12: DoDuelResult
//
// 파티원들에게 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;
}
示例13: CloneUser
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;
}
示例14: sprintf
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*/ );
}
示例15: __AddAnswer
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;
}