当前位置: 首页>>代码示例>>C++>>正文


C++ CNpc::Init方法代码示例

本文整理汇总了C++中CNpc::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ CNpc::Init方法的具体用法?C++ CNpc::Init怎么用?C++ CNpc::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CNpc的用法示例。


在下文中一共展示了CNpc::Init方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateNpcThread

bool CServerDlg::CreateNpcThread()
{
	m_TotalNPC = m_sMapEventNpc;
	m_CurrentNPC = 0;

	LOAD_TABLE_ERROR_ONLY(CNpcPosSet, &m_GameDB, nullptr, false, false);

	Guard lock(m_npcThreadLock);
	Guard lock2(m_eventThreadLock);
	foreach_stlmap (itr, g_arZone)
	{
		CNpcThread * pNpcThread = new CNpcThread();
		m_arNpcThread.insert(make_pair(itr->first, pNpcThread));
		m_arEventNpcThread.insert(make_pair(itr->first, new CNpcThread()));

		foreach_stlmap (npcItr, m_arNpc)
		{
			if (npcItr->second->GetZoneID() != itr->first)
				continue;

			CNpc * pNpc = npcItr->second;
			pNpc->Init();
			pNpcThread->m_pNpcs.insert(pNpc);
		}
	}
开发者ID:srmeier,项目名称:KnightOnline,代码行数:25,代码来源:ServerDlg.cpp

示例2: CreateNpcThread

BOOL CServerDlg::CreateNpcThread()
{
	m_TotalNPC = m_sMapEventNpc;
	m_CurrentNPC = 0;
	m_CurrentNPCError = 0;

	LOAD_TABLE_ERROR_ONLY(CNpcPosSet, &m_GameDB, NULL, false);
			
	int nThreadNumber = 0;
	DWORD id;

	foreach_stlmap (itr, g_arZone)
	{
		CNpcThread * pNpcThread = new CNpcThread;
		pNpcThread->m_sThreadNumber = nThreadNumber++;
		pNpcThread->m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&NpcThreadProc, pNpcThread, CREATE_SUSPENDED, &id);
		m_arNpcThread.push_back(pNpcThread);

		foreach_stlmap (npcItr, m_arNpc)
		{
			if (npcItr->second->m_bCurZone != itr->first)
				continue;

			CNpc * pNpc = npcItr->second;
			pNpc->Init();
			pNpcThread->m_pNpcs.insert(pNpc);
		}
	}
开发者ID:66gs,项目名称:snoxd-koserver,代码行数:28,代码来源:ServerDlg.cpp

示例3: CreateNpcThread

BOOL CServerDlg::CreateNpcThread()
{
    m_TotalNPC = m_sMapEventNpc;
    m_CurrentNPC = 0;
    m_CurrentNPCError = 0;

    LOAD_TABLE_ERROR_ONLY(CNpcPosSet, &m_GameDB, NULL, false);

    int step = 0, nThreadNumber = 0;
    CNpcThread* pNpcThread = NULL;
    DWORD id;

    foreach_stlmap (itr, m_arNpc)
    {
        if (step == 0)
            pNpcThread = new CNpcThread;

        CNpc *pNpc = pNpcThread->m_pNpc[step] = itr->second;
        pNpc->m_sThreadNumber = nThreadNumber;
        pNpc->Init();

        ++step;

        if( step == NPC_NUM )
        {
            pNpcThread->m_sThreadNumber = nThreadNumber++;
            pNpcThread->m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&NpcThreadProc, &(pNpcThread->m_ThreadInfo), CREATE_SUSPENDED, &id);
            m_arNpcThread.push_back( pNpcThread );
            step = 0;
        }
    }
    if( step != 0 )
    {
        pNpcThread->m_sThreadNumber = nThreadNumber++;
        pNpcThread->m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&NpcThreadProc, &(pNpcThread->m_ThreadInfo), CREATE_SUSPENDED, &id);
        m_arNpcThread.push_back( pNpcThread );
    }

    m_hZoneEventThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&ZoneEventThreadProc, (LPVOID)(this), CREATE_SUSPENDED, &id);
    printf("[Monster Init - %d, threads=%d]\n", m_TotalNPC, m_arNpcThread.size());
    return TRUE;
}
开发者ID:heaheart,项目名称:snoxd-koserver,代码行数:42,代码来源:ServerDlg.cpp

示例4: CreateNpcThread

bool CServerDlg::CreateNpcThread()
{
	m_TotalNPC = m_sMapEventNpc;
	m_CurrentNPC = 0;

	LOAD_TABLE_ERROR_ONLY(CNpcPosSet, &m_GameDB, nullptr, false);
			
	foreach_stlmap (itr, g_arZone)
	{
		CNpcThread * pNpcThread = new CNpcThread;
		m_arNpcThread.push_back(pNpcThread);

		foreach_stlmap (npcItr, m_arNpc)
		{
			if (npcItr->second->m_bCurZone != itr->first)
				continue;

			CNpc * pNpc = npcItr->second;
			pNpc->Init();
			pNpcThread->m_pNpcs.insert(pNpc);
		}
	}
开发者ID:ZeusAFK,项目名称:snoxd-koserver,代码行数:22,代码来源:ServerDlg.cpp

示例5: CreateNpcThread

//	Npc Thread 를 만든다.
BOOL CServerDlg::CreateNpcThread()
{
    BOOL	bMoveNext	= TRUE;
    int		nSerial		= m_sMapEventNpc;
    int		nPathSerial = 1;
    int		nNpcCount	= 0;
    int		i=0, j=0;
    int nRandom = 0, nServerNum = 0;
    double  dbSpeed = 0;

    m_TotalNPC = 0;			// DB에 있는 수
    m_CurrentNPC = 0;
    m_CurrentNPCError = 0;

    CNpcTable*	pNpcTable = NULL;
    CRoomEvent* pRoom = NULL;

    CNpcPosSet NpcPosSet;

    char szPath[500];
    char szX[5];
    char szZ[5];

    float fRandom_X = 0.0f;
    float fRandom_Z = 0.0f;

    int nMonsterNumber = 0;

    try
    {
        if(NpcPosSet.IsOpen()) NpcPosSet.Close();
        if(!NpcPosSet.Open())	{
            AfxMessageBox(_T("MONSTER_POS DB Open Fail!"));
            return FALSE;
        }
        if(NpcPosSet.IsBOF())	{
            AfxMessageBox(_T("MONSTER_POS DB Empty!"));
            return FALSE;
        }

        NpcPosSet.MoveFirst();

        while(!NpcPosSet.IsEOF())	{
            nMonsterNumber = NpcPosSet.m_NumNPC;
            //if( NpcPosSet.m_ZoneID == 101 )	{	// 테스트를 위해서,,
            //	nMonsterNumber = 1;
            //if(nMonsterNumber > 4)	{
            //	nMonsterNumber = nMonsterNumber / 4;
            //}
            //}
            nServerNum = 0;
            nServerNum = GetServerNumber( NpcPosSet.m_ZoneID );

            if( m_byZone == nServerNum || m_byZone == UNIFY_ZONE)	{
                for(j=0; j<nMonsterNumber; j++)		{
                    CNpc*		pNpc		= new CNpc();

                    pNpc->m_byMoveType = NpcPosSet.m_ActType;
                    pNpc->m_byInitMoveType = NpcPosSet.m_ActType;

                    bool bMonster = (NpcPosSet.m_ActType < 100);
                    if (bMonster)
                        pNpcTable = m_arMonTable.GetData(NpcPosSet.m_NpcID);
                    else
                    {
                        pNpc->m_byMoveType = NpcPosSet.m_ActType - 100;
                        //pNpc->m_byInitMoveType = NpcPosSet.m_ActType - 100;
                        pNpcTable = m_arNpcTable.GetData(NpcPosSet.m_NpcID);
                    }

                    if (pNpcTable == NULL)
                    {
                        char buff[128] = {0};
                        sprintf(buff, "NPC %d not found in %s table.", pNpc->m_sNid, bMonster ? "K_MONSTER" : "K_NPC");
                        AfxMessageBox(buff);
                        delete pNpc;
                        return FALSE;
                    }

                    pNpc->Load(nSerial++, pNpcTable);
                    pNpc->m_byBattlePos = 0;

                    if(pNpc->m_byMoveType >= 2)	{
                        pNpc->m_byBattlePos = myrand( 1, 3 );
                        pNpc->m_byPathCount = nPathSerial++;
                    }

                    pNpc->InitPos();

                    if( bMoveNext )	{
                        bMoveNext = FALSE;
                        nNpcCount = NpcPosSet.m_NumNPC;
                    }

                    //////// MONSTER POS ////////////////////////////////////////
                    pNpc->m_bCurZone = NpcPosSet.m_ZoneID;

                    // map에 몬스터의 위치를 랜덤하게 위치시킨다.. (테스트 용 : 수정-DB에서 읽어오는데로 몬 위치 결정)
                    nRandom = abs(NpcPosSet.m_LeftX - NpcPosSet.m_RightX);
//.........这里部分代码省略.........
开发者ID:jakenewby,项目名称:snoxd-koserver-1,代码行数:101,代码来源:ServerDlg.cpp


注:本文中的CNpc::Init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。