Ejemplo n.º 1
0
void MapManager::Update(uint32 diff)
{
    i_timer.Update(diff);
    if (!i_timer.Passed())
        return;

    for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter)
        iter->second->Update((uint32)i_timer.GetCurrent());

    for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
    {
        WorldObject::UpdateHelper helper((*iter));
        helper.Update((uint32)i_timer.GetCurrent());
    }

    // remove all maps which can be unloaded
    MapMapType::iterator iter = i_maps.begin();
    while (iter != i_maps.end())
    {
        Map* pMap = iter->second;
        // check if map can be unloaded
        if (pMap->CanUnload((uint32)i_timer.GetCurrent()))
        {
            pMap->UnloadAll(true);
            delete pMap;

            i_maps.erase(iter++);
        }
        else
            ++iter;
    }

    i_timer.SetCurrent(0);
}
Ejemplo n.º 2
0
void MapManager::Update(uint32 diff)
{
    i_timer.Update(diff);
    if (!i_timer.Passed())
        return;

    for (auto& i_map : i_maps)
        i_map.second->Update((uint32)i_timer.GetCurrent());

    for (Transport* m_Transport : m_Transports)
        m_Transport->Update((uint32)i_timer.GetCurrent());

    // remove all maps which can be unloaded
    MapMapType::iterator iter = i_maps.begin();
    while (iter != i_maps.end())
    {
        Map* pMap = iter->second;
        // check if map can be unloaded
        if (pMap->CanUnload((uint32)i_timer.GetCurrent()))
        {
            pMap->UnloadAll(true);
            delete pMap;

            i_maps.erase(iter++);
        }
        else
            ++iter;
    }

    i_timer.SetCurrent(0);
}
Ejemplo n.º 3
0
void MapManager::Update(uint32 diff)
{
    i_timer.Update(diff);
    if( !i_timer.Passed())
        return;

    UpdateLoadBalancer(true);

    for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
    {
        if (m_updater.activated())
        {
            m_updater.schedule_update(*iter->second, (uint32)i_timer.GetCurrent());
        }
        else
            iter->second->Update((uint32)i_timer.GetCurrent());
    }

    if (m_updater.activated())
        m_updater.wait();

    UpdateLoadBalancer(false);

    if (m_updater.IsBroken() || m_threadsCountPreferred != m_threadsCount)
    {
        m_updater.ReActivate(m_threadsCountPreferred);
        sLog.outDetail("MapManager::Update map virtual server threads pool reactivated, new threads count is %u", m_threadsCountPreferred);
        m_threadsCount = m_threadsCountPreferred;
    }

    for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
    {
        WorldObject::UpdateHelper helper((*iter));
        helper.Update((uint32)i_timer.GetCurrent());
    }

    //remove all maps which can be unloaded
    MapMapType::iterator iter = i_maps.begin();
    while(iter != i_maps.end())
    {
        Map * pMap = iter->second;
        //check if map can be unloaded
        if(pMap->CanUnload((uint32)i_timer.GetCurrent()))
        {
            pMap->UnloadAll(true);
            delete pMap;

            i_maps.erase(iter++);
        }
        else
            ++iter;
    }

    i_timer.SetCurrent(0);
}
Ejemplo n.º 4
0
void
MapManager::Update(uint32 diff)
{
    i_timer.Update(diff);
    if ( !i_timer.Passed() )
        return;

    MapMapType::iterator iter = i_maps.begin();
    std::vector<Map*> update_queue(i_maps.size());

    int omp_set_num_threads(sWorld.getConfig(CONFIG_UINT32_NUMTHREADS));

    for (uint32 i = 0; iter != i_maps.end(); ++iter, ++i)
        update_queue[i] = iter->second;

    uint32 i = 0;
    #pragma omp parallel for schedule(dynamic) private(i) shared(update_queue)
    for (i = 0; i < i_maps.size(); ++i)
        update_queue[i]->Update(i_timer.GetCurrent());

    for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
        (*iter)->Update(i_timer.GetCurrent());

    //remove all maps which can be unloaded
    iter = i_maps.begin();
    while(iter != i_maps.end())
    {
        Map * pMap = iter->second;
        //check if map can be unloaded
        if(pMap->CanUnload((uint32)i_timer.GetCurrent()))
        {
            pMap->UnloadAll(true);
            delete pMap;

            i_maps.erase(iter++);
        }
        else
            ++iter;
    }

    i_timer.SetCurrent(0);
}
Ejemplo n.º 5
0
void MapManager::Update(uint32 diff)
{
    i_timer.Update(diff);
    if (!i_timer.Passed())
        return;

    for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
    {
	 if (m_updater.activated())
            m_updater.schedule_update(*iter->second, (uint32)i_timer.GetCurrent());
	 else
            iter->second->Update((uint32)i_timer.GetCurrent());
    }

    if (m_updater.activated())
	 m_updater.wait();

    for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
        (*iter)->Update((uint32)i_timer.GetCurrent());

    //remove all maps which can be unloaded
    MapMapType::iterator iter = i_maps.begin();
    while(iter != i_maps.end())
    {
        Map * pMap = iter->second;
        //check if map can be unloaded
        if(pMap->CanUnload((uint32)i_timer.GetCurrent()))
        {
            pMap->UnloadAll(true);
            delete pMap;

            i_maps.erase(iter++);
        }
        else
            ++iter;
    }

    i_timer.SetCurrent(0);
}
Ejemplo n.º 6
0
void MapManager::Update(uint32 diff)
{
    i_timer.Update(diff);
    if( !i_timer.Passed())
        return;

    UpdateLoadBalancer(true);

    for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
    {
        if (m_updater.activated())
        {
            m_updater.schedule_update(*iter->second, (uint32)i_timer.GetCurrent());
        }
        else
            iter->second->Update((uint32)i_timer.GetCurrent());
    }

    if (m_updater.activated())
        m_updater.wait();

    UpdateLoadBalancer(false);

    if (m_updater.IsBroken() || m_threadsCountPreferred != m_threadsCount)
    {
        m_updater.ReActivate(m_threadsCountPreferred);
        sLog.outDetail("MapManager::Update map virtual server threads pool reactivated, new threads count is %u", m_threadsCountPreferred);
        m_threadsCount = m_threadsCountPreferred;
    }

    for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter)
    {
        WorldObject::UpdateHelper helper((*iter));
        helper.Update((uint32)i_timer.GetCurrent());
    }

    bool b_stat = false;
    if (m_statisticInterval < diff)
    {
        b_stat = true;
        m_statisticInterval = sWorld.getConfig(CONFIG_UINT32_VMSS_STATISTIC_INTERVAL);
    }
    else
        m_statisticInterval -= diff;

    //remove all maps which can be unloaded
    MapMapType::iterator iter = i_maps.begin();
    while(iter != i_maps.end())
    {
        Map * pMap = iter->second;
        //check if map can be unloaded
        if(pMap->CanUnload((uint32)i_timer.GetCurrent()))
        {
            pMap->UnloadAll(true);
            delete pMap;

            i_maps.erase(iter++);
        }
        else
        {
            ++iter;
            if (sWorld.getConfig(CONFIG_BOOL_VMSS_STATISTIC_ENABLE) && b_stat)
                UpdateStatisticForMap(pMap);
        }
    }

    if (sWorld.getConfig(CONFIG_BOOL_VMSS_STATISTIC_ENABLE) && b_stat)
    {
        if (m_statMaps.size() != sWorld.getConfig(CONFIG_UINT32_VMSS_STATISTIC_THREADSCOUNT))
            m_statMaps.resize(sWorld.getConfig(CONFIG_UINT32_VMSS_STATISTIC_THREADSCOUNT), (Map*)NULL);

        for (std::vector<Map*>::iterator i = m_statMaps.begin(); i != m_statMaps.end(); ++i)
        {
            Map* map = *i;
            if (map)
                map->PrintStatistic();
        }
        m_statMaps.clear();
    }

    i_timer.SetCurrent(0);
}