本文整理汇总了C++中CDBAgent::CreateKnights方法的典型用法代码示例。如果您正苦于以下问题:C++ CDBAgent::CreateKnights方法的具体用法?C++ CDBAgent::CreateKnights怎么用?C++ CDBAgent::CreateKnights使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDBAgent
的用法示例。
在下文中一共展示了CDBAgent::CreateKnights方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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->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);
}
示例2: 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);
}