本文整理汇总了C++中Agent::getID方法的典型用法代码示例。如果您正苦于以下问题:C++ Agent::getID方法的具体用法?C++ Agent::getID怎么用?C++ Agent::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent::getID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lordWorkingThread
/*************************************************************************
Agent lord working thread
*************************************************************************/
unsigned int System::lordWorkingThread(void)
{
while(true)
{
//----------------------------------------
// wait cmd sign
::WaitForSingleObject(m_hLordCmdSign, INFINITE);
// enter critical section
::EnterCriticalSection(&m_csLordCmdQueue);
if(m_qLordCmd.empty())
{
// leave critical section
::LeaveCriticalSection(&m_csLordCmdQueue);
continue;
}
// get cmd
LordCmd theCmd = m_qLordCmd.front();
m_qLordCmd.pop();
if(m_qLordCmd.empty()) ::ResetEvent(m_hLordCmdSign);
// leave critical section
::LeaveCriticalSection(&m_csLordCmdQueue);
//----------------------------------------
//Process cmd
switch(theCmd.type)
{
// create agents...
case LCT_CreateAgent:
{
bool bStartNow = LOWORD(theCmd.nParam2)==1;
int nCounts = (int)HIWORD(theCmd.nParam2);
AgentCreateParam* pCreateparam = (AgentCreateParam*)(INT_PTR)theCmd.nParam1;
// 保存登录用户名
char buf[128];
int iParam = -1;
std::string sParam;
for( int j=0; j<(int)pCreateparam->vParams.size(); j++ )
{
if( pCreateparam->vParams[j].first == "AccountName" )
{
iParam = j;
sParam = pCreateparam->vParams[j].second;
break;
}
}
// 形如000X时,特殊处理
int iNum = atoi( sParam.substr( sParam.length()-4 ).c_str() );
for( int i=0; i<nCounts; i++ )
{
if( i == 1 )
{
sParam = sParam.substr( 0, sParam.length()-4 );
}
// 一组多用户命名规则
if( i > 0 && iParam >= 0 )
{
sprintf( buf, "%[email protected]", i + iNum );
pCreateparam->vParams[iParam].second = sParam + buf;
}
else
{
sprintf( buf, "@game.hopecool.com" );
pCreateparam->vParams[iParam].second = sParam + buf;
}
Agent* pAgent = m_pAgentManager->createAgent(*pCreateparam);
if(bStartNow)
{
if( pAgent->start() == false )
m_hUnStartAgents.push_back( pAgent->getID() );
::Sleep(AGENT_AROUSE_TIME_INTERVAL);
}
::SendMessage(m_hNotifyWnd, WMA_AGENT_NUM, m_pAgentManager->getAgentNum(), 0);
}
//delete org createparam
delete pCreateparam; pCreateparam=0;
if( m_hUnStartAgents.size() > 0 ) pushLordCommand( LCT_ArouseStartFail );
}
break;
// arouse agent...
case LCT_ArouseAll:
{
//Start all agent
AgentManager::AgentIterator agent = m_pAgentManager->getAgentIterator();
while (!agent.isAtEnd())
{
agent.getCurrentValue()->start();
++agent;
//.........这里部分代码省略.........
示例2:
bool Agent::operator==(Agent &other) const
{
return (this->ID == other.getID());
}