本文整理汇总了C++中CKnights::AddUser方法的典型用法代码示例。如果您正苦于以下问题:C++ CKnights::AddUser方法的具体用法?C++ CKnights::AddUser怎么用?C++ CKnights::AddUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CKnights
的用法示例。
在下文中一共展示了CKnights::AddUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RecvCreateKnights
/***
* We've been told from another server that a clan has been created.
***/
void CUdpSocket::RecvCreateKnights(char* pBuf)
{
int index = 0, send_index = 0, knightsindex = 0, nation = 0, community = 0;
char knightsname[MAX_ID_SIZE+1], chiefname[MAX_ID_SIZE+1];
CKnights* pKnights = NULL;
community = GetByte( pBuf, index );
knightsindex = GetShort( pBuf, index );
nation = GetByte( pBuf, index );
if (!GetKOString(pBuf, knightsname, index, MAX_ID_SIZE)
|| !GetKOString(pBuf, chiefname, index, MAX_ID_SIZE))
return;
pKnights = new CKnights();
pKnights->m_sIndex = knightsindex;
pKnights->m_byFlag = community;
pKnights->m_byNation = nation;
strcpy(pKnights->m_strName, knightsname);
strcpy(pKnights->m_strChief, chiefname);
pKnights->AddUser(chiefname);
g_pMain->m_KnightsArray.PutData( pKnights->m_sIndex, pKnights );
//TRACE("UDP - RecvCreateKnights - knname=%s, name=%s, index=%d\n", knightsname, chiefname, knightsindex);
}
示例2: RecvJoinKnights
/***
* We've been told from another server that someone has joined (or rejected joining) a clan.
***/
void CUdpSocket::RecvJoinKnights(char* pBuf, BYTE command)
{
int knightsindex = 0, index = 0;
char charid[MAX_ID_SIZE+1];
CString clanNotice;
knightsindex = GetShort( pBuf, index );
if (!GetKOString(pBuf, charid, index, MAX_ID_SIZE))
return;
CKnights *pKnights = g_pMain->GetClanPtr(knightsindex);
if (pKnights == NULL)
return;
if (command == KNIGHTS_JOIN)
{
clanNotice = g_pMain->GetServerResource(IDS_KNIGHTS_JOIN);
pKnights->AddUser(charid);
TRACE("UDP - RecvJoinKnights - name=%s, index=%d\n", charid, knightsindex);
}
else
{
clanNotice = g_pMain->GetServerResource(IDS_KNIGHTS_WITHDRAW);
pKnights->RemoveUser(charid);
TRACE("UDP - RecvJoinKnights - name=%s, index=%d\n", charid, knightsindex );
}
pKnights->SendChat(clanNotice, charid);
}
示例3: result
void CKnightsManager::ReqCreateKnights(CUser *pUser, Packet & pkt)
{
if (pUser == nullptr)
return;
Packet result(WIZ_KNIGHTS_PROCESS, uint8(KNIGHTS_CREATE));
string strKnightsName, strChief;
uint16 sClanID;
uint8 bFlag, bNation;
int8 bResult;
pkt >> bFlag >> sClanID >> bNation >> strKnightsName >> strChief;
bResult = g_DBAgent.CreateKnights(sClanID, bNation, strKnightsName, strChief, bFlag);
if (bResult < 0)
{
result << bResult;
pUser->Send(&result);
return;
}
CKnights *pKnights = new CKnights();
pKnights->m_sIndex = sClanID;
pKnights->m_byFlag = bFlag;
pKnights->m_byNation = bNation;
pKnights->m_strName = strKnightsName;
pKnights->m_strChief = pUser->GetName();
pUser->GoldLose(CLAN_COIN_REQUIREMENT, false);
g_pMain->m_KnightsArray.PutData(pKnights->m_sIndex, pKnights);
pKnights->AddUser(pUser);
// Ensure the clan leader's fame is set
// CKnights::AddUser() will default it to TRAINEE, so it needs to be set afterwards.
pUser->m_bFame = CHIEF;
result << uint8(1) << pUser->GetSocketID()
<< sClanID << strKnightsName
<< pKnights->m_byGrade << pKnights->m_byRanking
<< pUser->m_iGold;
pUser->SendToRegion(&result);
}
示例4: ReqCreateKnights
void CKnightsManager::ReqCreateKnights(CUser *pUser, Packet & pkt)
{
if (pUser == nullptr)
return;
Packet result(WIZ_KNIGHTS_PROCESS, uint8(KNIGHTS_CREATE));
string strKnightsName, strChief;
uint16 sClanID;
uint8 bFlag, bNation;
int8 bResult;
pkt >> bFlag >> sClanID >> bNation >> strKnightsName >> strChief;
bResult = g_DBAgent.CreateKnights(sClanID, bNation, strKnightsName, strChief, bFlag);
if (bResult < 0)
{
result << bResult;
pUser->Send(&result);
return;
}
CKnights *pKnights = new CKnights();
pKnights->m_sIndex = sClanID;
pKnights->m_byFlag = bFlag;
pKnights->m_byNation = bNation;
pKnights->m_strName = strKnightsName;
pKnights->m_strChief = pUser->GetName();
pUser->m_iGold -= CLAN_COIN_REQUIREMENT;
pUser->m_bFame = CHIEF;
g_pMain->m_KnightsArray.PutData(pKnights->m_sIndex, pKnights);
pKnights->AddUser(pUser);
result << uint8(1) << pUser->GetSocketID()
<< sClanID << strKnightsName
<< pKnights->m_byGrade << pKnights->m_byRanking
<< pUser->m_iGold;
pUser->SendToRegion(&result);
}