本文整理汇总了C++中CDBAgent::UpdateElectionStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ CDBAgent::UpdateElectionStatus方法的具体用法?C++ CDBAgent::UpdateElectionStatus怎么用?C++ CDBAgent::UpdateElectionStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDBAgent
的用法示例。
在下文中一共展示了CDBAgent::UpdateElectionStatus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleDatabaseRequest_Election
/**
* @brief Handles database requests for the election system.
*
* @param pUser The user making the request, if applicable.
* nullptr if not.
* @param pkt The packet.
*/
void CKingSystem::HandleDatabaseRequest_Election(CUser * pUser, Packet & pkt)
{
uint8 opcode;
pkt >> opcode;
switch (opcode)
{
// Special king system/election database requests
case KING_ELECTION:
{
uint8 byNation, byType;
pkt >> opcode >> byNation >> byType;
switch (opcode)
{
case KING_ELECTION_UPDATE_STATUS: // 7
g_DBAgent.UpdateElectionStatus(byType, byNation);
break;
case KING_ELECTION_UPDATE_LIST: // 6
{
bool bDelete;
uint16 sKnights;
uint32 nVotes = 0;
string strNominee;
pkt >> bDelete >> sKnights >> strNominee;
g_DBAgent.UpdateElectionList(bDelete ? 2 : 1, byType, byNation, sKnights, nVotes, strNominee);
} break;
}
} break;
case KING_ELECTION_NOMINATE:
{
if (pUser == nullptr)
return;
Packet result(WIZ_KING, uint8(KING_ELECTION));
std::string strNominee;
int16 resultCode;
pkt >> strNominee;
resultCode = g_DBAgent.UpdateCandidacyRecommend(pUser->m_strUserID, strNominee, pUser->GetNation());
// On success, we need to sync the local list.
if (resultCode == 1)
{
CKingSystem * pData = g_pMain->m_KingSystemArray.GetData(pUser->GetNation());
if (pData == nullptr)
return;
pData->InsertNominee(strNominee);
}
result << opcode << resultCode;
pUser->Send(&result);
} break;
case KING_ELECTION_NOTICE_BOARD:
{
pkt >> opcode;
if (pUser == nullptr)
return;
if (opcode == KING_CANDIDACY_BOARD_WRITE)
{
string strNotice;
pkt >> strNotice;
g_DBAgent.UpdateCandidacyNoticeBoard(pUser->m_strUserID, pUser->GetNation(), strNotice);
}
} break;
}