Example #1
0
void MotionMaster::DirectClean(bool reset, bool all)
{
    while (all ? !empty() : size() > 1)
    {
        MovementGenerator* curr = top();
        pop();
        curr->Finalize(*m_owner);

        if (!isStatic(curr))
            delete curr;
    }

    if (!all && reset)
    {
        MANGOS_ASSERT(!empty());
        top()->Reset(*m_owner);
    }
}
Example #2
0
void
MotionMaster::DelayedClean()
{
    if (empty() || size() == 1)
        return;

    if(!m_expList)
        m_expList = new ExpireList();

    while( !empty() && size() > 1 )
    {
        MovementGenerator *curr = top();
        pop();
        curr->Finalize(*i_owner);
        if( !isStatic( curr ) )
            m_expList->push_back(curr);
    }
}
Example #3
0
void
MotionMaster::DirectClean(bool reset)
{
    while( !empty() && size() > 1 )
    {
        MovementGenerator *curr = top();
        pop();
        curr->Finalize(*i_owner);
        if( !isStatic( curr ) )
            delete curr;
    }

    if (reset)
    {
        assert( !empty() );
        top()->Reset(*i_owner);
    }
}
Example #4
0
void
MotionMaster::DirectClean(bool reset, bool all)
{
    while( all ? !empty() : size() > 1 )
    {
        MovementGenerator *curr = top();
        pop();
        if (i_owner && i_owner->IsInWorld())
            curr->Finalize(*i_owner);
        if (!isStatic( curr ))
            delete curr;
    }

    if (!all && reset)
    {
        if (!empty())
            top()->Reset(*i_owner);
    }
}
Example #5
0
void
MotionMaster::DelayedClean()
{
    if (empty() || size() == 1)
        return;

    if(!m_expList)
        m_expList = new ExpireList();

	int i=0;
    while( !empty() && size() > 1 )
    {
		i++;
		if(i>2500)
			sLog.outError("MotionMaster::DelayedClean Boucle");
        MovementGenerator *curr = top();
        pop();
        curr->Finalize(*i_owner);
        if( !isStatic( curr ) )
            m_expList->push_back(curr);
    }
}
Example #6
0
void
MotionMaster::Initialize()
{
    // clear ALL movement generators (including default)
    while(!empty())
    {
        MovementGenerator *curr = top();
        pop();
        curr->Finalize(*i_owner);
        if( !isStatic( curr ) )
            delete curr;
    }

    // set new default movement generator
    if(i_owner->GetTypeId() == TYPEID_UNIT)
    {
        MovementGenerator* movement = FactorySelector::selectMovementGenerator((Creature*)i_owner);
        push(  movement == NULL ? &si_idleMovement : movement );
        top()->Initialize(*i_owner);
    }
    else
        push(&si_idleMovement);
}
Example #7
0
void MotionMaster::DelayedClean(bool reset, bool all)
{
    if (reset)
        m_cleanFlag |= MMCF_RESET;
    else
        m_cleanFlag &= ~MMCF_RESET;

    if (empty() || (!all && size() == 1))
        return;

    if (!m_expList)
        m_expList = new ExpireList();

    while (all ? !empty() : size() > 1)
    {
        MovementGenerator* curr = top();
        pop();
        curr->Finalize(*m_owner);

        if (!isStatic(curr))
            m_expList->push_back(curr);
    }
}
Example #8
0
int InitSim (SimPara &para, VASTPara_Net &netpara)
{
    g_para = para;
    g_vastnetpara = netpara;

    // note there's no need to assign the gateway ID as it'll be found automatically
    g_vastnetpara.model        = (VAST_NetModel)para.NET_MODEL;
    g_vastnetpara.port         = GATEWAY_DEFAULT_PORT;    
    g_vastnetpara.client_limit = para.PEER_LIMIT;
    g_vastnetpara.relay_limit  = para.RELAY_LIMIT;        
    g_vastnetpara.conn_limit   = para.CONNECT_LIMIT;
    g_vastnetpara.recv_quota   = para.DOWNLOAD_LIMIT;
    g_vastnetpara.send_quota   = para.UPLOAD_LIMIT;

    // create / open position log file
    char filename[80];
    sprintf (filename, VAST_POSFILE_FORMAT, para.NODE_SIZE, para.WORLD_WIDTH, para.WORLD_HEIGHT, para.TIME_STEPS);

    FileClassFactory fcf;
    g_pos_record = fcf.CreateFileClass (0);
    bool replay = true;
    if (g_pos_record->open (filename, SFMode_Read) == false)
    {
        replay = false;
        g_pos_record->open (filename, SFMode_Write);
    }

    // create behavior model
    g_move_model.initModel (g_para.MOVE_MODEL, g_pos_record, replay, 
                            Position (0,0), Position ((coord_t)g_para.WORLD_WIDTH, (coord_t)g_para.WORLD_HEIGHT),
                            g_para.NODE_SIZE, g_para.TIME_STEPS, (double)g_para.VELOCITY);    

    // close position log file
    fcf.DestroyFileClass (g_pos_record);

    // initialize random number generator
    //srand ((unsigned int)time (NULL));
    srand (37);
    g_last_seed = rand ();

    // randomly choose which nodes will be the relays
    int num_relays = 1;
    int i;
    for (i=0; i < para.NODE_SIZE; i++)
    {
        g_as_relay.push_back (false);
        g_as_matcher.push_back (false);
    }

    // determine which nodes will be relays & matchers
    g_as_relay[0] = true;
    g_as_matcher[0] = true;

    i = 1;
    while (num_relays < para.RELAY_SIZE)
    {
        //if (rand () % 100 <= ((float)para.RELAY_SIZE / (float)para.NODE_SIZE * 100))
        //{    
            g_as_relay[i] = true;
            num_relays++;
        //}
        if (++i == para.NODE_SIZE)
            i = 0;
    }

    i = 1;
    while (i < para.MATCHER_SIZE)
    {
        g_as_matcher[i++] = true;       
    }

    // starts stat collections
    g_stat.init_timer (g_para);
    return 0;
}