Пример #1
0
static void untrackRef(Ref* ref)
{
    auto iter = std::find(__refAllocationList.begin(), __refAllocationList.end(), ref);
    if (iter == __refAllocationList.end())
    {
        log("[memory] CORRUPTION: Attempting to free (%s) with invalid ref tracking record.\n", typeid(*ref).name());
        return;
    }

    __refAllocationList.erase(iter);
}
Пример #2
0
 void FilterTargets(std::list<Unit*>& unitList)
 {
     for (std::list<Unit*>::iterator itr = unitList.begin(); itr != unitList.end();)
     {
         if ((*itr)->GetTypeId() == TYPEID_PLAYER && (*itr)->ToPlayer()->GetQuestStatus(GetSpellInfo()->Effects[EFFECT_1].CalcValue()) == QUEST_STATUS_INCOMPLETE)
             ++itr;
         else
             unitList.erase(itr++);
     }
     unitList.push_back(GetCaster());
 }
Пример #3
0
//_______________________________________________________________________________________
//Прокручивает очередь отправленных сообщений, начиная со самых старых. Если ReceivedMsg!=NULL,
//то сначала анализирует принятое сообщение на соответствие списку. Если соответствие
//найдено, выполняет действие, удаляет отправленное. Если не найдено, принимает
//асинхронное сообщение.
//Перед выходом проверяет список на таймаут (выдает сообщение и удаляет).  
void CComThreadBasic::AnalyseMsgWithWaitList(std::list<ComMsg>& List, ComMsg *ReceivedMsg)
{
	std::list<ComMsg>::iterator iter;
	//ComMsg SentMsg;
	bool Processed=false;
	if(ReceivedMsg!=NULL)
	{
		for (iter = List.begin(); iter != List.end();)
		{
			if(AnalyseCorrectMsg(ReceivedMsg, &(*iter)))
			{
				//Сообщение обработано. Удаление задания из очереди, выход
				List.erase(iter);
				Processed=true;
				break;
			}
			else
				++iter;
		}

		if(!Processed)
		{
			//Прием асинхронного (неинициированного этой программой) сообщения
			AnalyseCorrectMsg(ReceivedMsg, NULL);
		}
	}

	//Проверка на таймаут
	ULONG TickCount=GetTickCount();
	for (iter = List.begin(); iter != List.end();)
	{
		if(TickCount-iter->TimeStamp>m_ReplyTimeout*1000)
		{
			//Таймаут.
			ReportTimeOut(&(*iter));
			iter=List.erase(iter);
		}
		else
			++iter;
	}
}
Пример #4
0
void deleteShape()
{
	for (std::list<Shape>::iterator it = listOfShapes.begin(); it != listOfShapes.end(); it++)
	{
		if(it->shapeId == selected)
		{
			selected = 0;
			listOfShapes.erase(it);
			break;
		}
	}
}
Пример #5
0
bool MeshProjection::connectLines(std::list< std::pair<Base::Vector3f, Base::Vector3f> >& cutLines,
                                  const Base::Vector3f& startPoint, const Base::Vector3f& endPoint,
                                  std::vector<Base::Vector3f>& polyline) const
{
    const float fMaxDist = float(sqrt(FLOAT_MAX)); // max. length of a gap
    const float fMinEps  = 1.0e-4f;

    polyline.clear();
    polyline.push_back(startPoint);

    Base::Vector3f curr(startPoint);
    while ((curr != endPoint) && (!cutLines.empty())) {
        std::list< std::pair<Base::Vector3f, Base::Vector3f> >::iterator it, pCurr = cutLines.end();

        // get nearest line
        float  fMin  = fMaxDist * fMaxDist;

        bool  bPos = false;
        for (it = cutLines.begin(); it != cutLines.end(); ++it) {
            float fD1 = Base::DistanceP2(curr, it->first);
            float fD2 = Base::DistanceP2(curr, it->second);
            if (std::min<float>(fD1, fD2) < fMin) {
                pCurr = it;
                bPos  = fD1 < fD2;
                fMin  = std::min<float>(fD1, fD2);
                if (fMin < fMinEps) // abort because next line already found
                    break;
            }
        }

        if (pCurr != cutLines.end()) {
            if (bPos) {
                if (fMin > fMinEps) // gap, insert point
                    polyline.push_back(pCurr->first);
                polyline.push_back(pCurr->second);
                curr = pCurr->second;
            }
            else {
                if (fMin > fMinEps) // gap, insert point
                    polyline.push_back(pCurr->second);
                polyline.push_back(pCurr->first);
                curr = pCurr->first;
            }
        }
        else {
            return false;  // abort because no line was found
        }

        cutLines.erase(pCurr); 
    }

    return true;
}
Пример #6
0
void IPrimitiveEditor::removeFromModified ()
{
	// Already inserted ?
	if (_ModifiedIterator != ModifiedPrimitive.end ())
	{
		// Remove from the container
		ModifiedPrimitive.erase (_ModifiedIterator);

		// Clear it
		_ModifiedIterator = ModifiedPrimitive.end ();
	}
}
Пример #7
0
void IPrimitiveEditor::removeFromSelection ()
{
	// Already inserted ?
	if (_SelectionIterator != Selection.end ())
	{
		// Remove from the container
		Selection.erase (_SelectionIterator);

		// Clear it
		_SelectionIterator = Selection.end ();
	}
}
Пример #8
0
std::vector<int> ChowLiuTree::extractChildren(std::list<info> &remaining_edges, int q) {

    std::vector<int> children;
    std::list<info>::iterator edge = remaining_edges.begin();

    while(edge != remaining_edges.end()) {
        if(edge->word1 == q) {
            children.push_back(edge->word2);
            edge = remaining_edges.erase(edge);
            continue;
        }
        if(edge->word2 == q) {
            children.push_back(edge->word1);
            edge = remaining_edges.erase(edge);
            continue;
        }
        edge++;
    }

    return children;
}
Пример #9
0
	void do_register_drawable(const std::shared_ptr<drawable>& drawable)
	{
		drawables_.push_back(drawable);
		auto it = drawables_.begin();
		while(it != drawables_.end())
		{
			if(it->lock())
				++it;
			else	
				it = drawables_.erase(it);			
		}
	}
Пример #10
0
void MultiQueueMigrator::RemoveFromList(std::list<uint64_t> list, uint64_t pageNo)
{
	std::list<uint64_t>::iterator iter;
	for(iter = list.begin(); iter != list.end(); iter++)
	{
		if(pageNo == *iter)
		{
			list.erase(iter);
			return;
		}
	}	
}
Пример #11
0
void RemoveEmptyGames() {
    for (std::list<Game *>::iterator ptr(games.begin()), end(games.begin()), del; ptr != end;) {
        del = ptr;
        Game *g = *ptr;
        ++ptr;
        if (g->a == 0 && g->b == 0) {
            MakeDirty();
            games.erase(del);
            delete g;
        }
    }
}
Пример #12
0
void wk_gateKeeper(DS::SocketHandle sockp)
{
    GateKeeper_Private client;
    client.m_crypt = 0;

    s_clientMutex.lock();
    client.m_sock = sockp;
    s_clients.push_back(&client);
    s_clientMutex.unlock();

    try {
        gate_init(client);

        for ( ;; ) {
            uint16_t msgId = DS::CryptRecvValue<uint16_t>(client.m_sock, client.m_crypt);
            switch (msgId) {
            case e_CliToGateKeeper_PingRequest:
                cb_ping(client);
                break;
            case e_CliToGateKeeper_FileServIpAddressRequest:
                cb_fileServIpAddress(client);
                break;
            case e_CliToGateKeeper_AuthServIpAddressRequest:
                cb_authServIpAddress(client);
                break;
            default:
                /* Invalid message */
                fprintf(stderr, "[GateKeeper] Got invalid message ID %d from %s\n",
                        msgId, DS::SockIpAddress(client.m_sock).c_str());
                DS::CloseSock(client.m_sock);
                throw DS::SockHup();
            }
        }
    } catch (const DS::SockHup&) {
        // Socket closed...
    } catch (const std::exception& ex) {
        fprintf(stderr, "[GateKeeper] Error processing client message from %s: %s\n",
                DS::SockIpAddress(sockp).c_str(), ex.what());
    }

    s_clientMutex.lock();
    auto client_iter = s_clients.begin();
    while (client_iter != s_clients.end()) {
        if (*client_iter == &client)
            client_iter = s_clients.erase(client_iter);
        else
            ++client_iter;
    }
    s_clientMutex.unlock();

    DS::CryptStateFree(client.m_crypt);
    DS::FreeSock(client.m_sock);
}
Пример #13
0
void UpdateJoystickEvents()
{
	std::list<JoystickEvent_t*>::iterator i;
	event_t    event;

	if(!JoyEventList.size())
		return;

	i = JoyEventList.begin();
	while(i != JoyEventList.end())
	{
		if((*i)->Event.type == SDL_JOYHATMOTION)
		{
			// Hat position released
			if(!(SDL_JoystickGetHat(openedjoy, (*i)->Event.jhat.hat) & (*i)->Event.jhat.value))
				event.type = ev_keyup;
			// Hat button still held - Repeat at key repeat interval
			else if((SDL_GetTicks() - (*i)->RegTick >= SDL_DEFAULT_REPEAT_DELAY) && 
		            (SDL_GetTicks() - (*i)->LastTick >= SDL_DEFAULT_REPEAT_INTERVAL*2))
			{
				(*i)->LastTick = SDL_GetTicks();
				event.type = ev_keydown;
			}
			else
			{
				i++;
				continue;
			}

			event.data1 = event.data2 = event.data3 = 0;

			if((*i)->Event.jhat.value == SDL_HAT_UP)
				event.data1 = ((*i)->Event.jhat.hat * 4) + KEY_HAT1;
			else if((*i)->Event.jhat.value == SDL_HAT_RIGHT)
				event.data1 = ((*i)->Event.jhat.hat * 4) + KEY_HAT2;
			else if((*i)->Event.jhat.value == SDL_HAT_DOWN)
				event.data1 = ((*i)->Event.jhat.hat * 4) + KEY_HAT3;
			else if((*i)->Event.jhat.value == SDL_HAT_LEFT)
				event.data1 = ((*i)->Event.jhat.hat * 4) + KEY_HAT4;

			D_PostEvent(&event);

			if(event.type == ev_keyup)
			{
				// Delete the released event
				delete *i;
				i = JoyEventList.erase(i);
				continue;
			}
		}
		i++;
	}
}
Пример #14
0
	void RemoveZonesAt(short rzx,short rzy)
		{
		std::list<ZoneRef>::iterator zli;
		//erase all zones in list
		for(zli=zonelist.begin();zli!=zonelist.end();zli++)
			if(zli->PointInZone(rzx,rzy))
				zonelist.erase(zli);
		//erase all zones in children's lists
		for(int i=0;i<4;i++)
			if(children[i])
				children[i]->RemoveZonesAt(rzx,rzy);
		}
Пример #15
0
void CWebserverAppTraits::RemoveFromPendingDelete(wxObject *object)
{
	wxMutexLocker lock(m_lock);

	for(std::list<wxObject *>::iterator i = m_sched_delete.begin();
	    i != m_sched_delete.end(); i++) {
		if (*i == object) {
			m_sched_delete.erase(i);
			return;
		}
	}
}
Пример #16
0
/* Removes a mapping specified by a pointer */
static bool keyRemoveMappingPt(KEY_MAPPING *psToRemove)
{
	auto mapping = std::find_if(keyMappings.begin(), keyMappings.end(), [psToRemove](KEY_MAPPING const &mapping) {
		return &mapping == psToRemove;
	});
	if (mapping != keyMappings.end())
	{
		keyMappings.erase(mapping);
		return true;
	}
	return false;
}
Пример #17
0
  void remove_connection(std::list<ConnectionInfo>::iterator & it){

    std::vector<_input *> &ve = it->out_node->outputs[it->outlet];
    for(auto it2 = ve.begin();it2 != ve.end();it2++){
      if(*it2 == it->in_node->inputs[it->inlet]){
	ve.erase(it2);
	return;
      }
    }
    connections.erase(it);

  }
Пример #18
0
    void checkout(string str) {
        for(auto it=shelf.begin(); it!=shelf.end(); it++) {
            if(str==it->getTitle()) {
                shelfSpace+=it->getBookLength();
                Book myBook = Book(it->getTitle(),it->getBookLength());
                shelf.erase(it);
                out.push_back(myBook);
                break;
            }
        }

    }
Пример #19
0
void RemoveChatUser(const TTV_ChatUserInfo* user)
{
	for (auto iter = gChatUsers.begin(); iter != gChatUsers.end(); ++iter)
	{
		std::shared_ptr<ChatUser> cur = *iter;
		if (strcmp(user->displayName, cur->username) == 0)
		{
			gChatUsers.erase(iter);
			return;
		}
	}
}
Пример #20
0
 void merge(const binomial_heap& heap)
 {
     auto it1 = root_list.begin();
     auto it2 = heap.root_list.begin();
     
     while (it2 != heap.root_list.end()) //merge
     {
         if ((*it1)->get_size() >= (*it2)->get_size())
         {
             root_list.insert(it1, *it2);
             ++it2;
         }
         ++it1;
     }
     
     auto it = root_list.begin();
     
     while ((it != root_list.end()) && (++it != root_list.end()))
     {
         --it;
         if ((*it)->get_size() == (*(++it))->get_size())
         {
             typename std::list<binomial_tree<T>*>::iterator add;
             if (++it != root_list.end())
             {
                 --it;
                 if ((*it)-> get_size() == (*(++it))->get_size())
                 {
                     add = it;
                 }
                 else
                 {
                     add = --it;
                 }
             }
             else
             {
                 add = --it;
             }
             --it;
             *it = (*it)->merge(**add);
             auto copy = it;
             ++it;
             root_list.erase(it);
             it = copy;
         }
         else
         {
             ++it;
         }
     }
 }
Пример #21
0
void processNetworkQueue() {
    // attach workers to NetWorkerData
    auto taskItr = s_urlTaskQueue.begin();
    for(auto& worker : s_Workers) {
        if(taskItr == s_urlTaskQueue.end()) {
            break;
        }
        if(worker.isAvailable()) {
            worker.perform(std::move(*taskItr));
            taskItr = s_urlTaskQueue.erase(taskItr);
        }
    }
}
Пример #22
0
void ActorFactory::destoryActor(hcts::Actor* ptr)
{
	assert(ptr);
	for (auto i = d_actorList.begin(); i != d_actorList.end();++i)
	{
		if (*i == ptr)
		{
			d_actorList.erase(i);
			delete ptr;
			return;
		}
	}
}
void updateRemainningJob(ostream& os, float t){
	list<Job*>::iterator itJob = remainningJobs.begin();
	//check the remaining number of jobs.
	while (itJob != remainningJobs.end()) {
		if ((*itJob)->ifFinished()){
			cout<<"Job "<<(*itJob)->getID() <<" has finished"<<endl;
//			os<<(*itJob)->getID()<<"\t"<<t<<endl;
			itJob = remainningJobs.erase(itJob);
		}else{
			++itJob;
		}
	}
}
Пример #24
0
 void SendAddsUpStairs(uint32 count)
 {
     //pop a add from list, send him up the stairs...
     for (uint32 addCount = 0; addCount<count && !addsAtBase.empty(); addCount++)
     {
         if (Creature* add = instance->GetCreature(*addsAtBase.begin()))
         {
             add->GetMotionMaster()->MovePath(PATH_ADDS, false);
             movedadds.push_back(add->GetGUID());
         }
         addsAtBase.erase(addsAtBase.begin());
     }
 }
Пример #25
0
void
TextLineTracer::filterEdgyCurves(std::list<std::vector<QPointF> >& polylines)
{
	std::list<std::vector<QPointF> >::iterator it(polylines.begin());
	std::list<std::vector<QPointF> >::iterator const end(polylines.end());	
	while (it != end) {
		if (!isCurvatureConsistent(*it)) {
			polylines.erase(it++);
		} else {
			++it;
		}
	}
}
Пример #26
0
            void FilterTargets(std::list<WorldObject*>& targets)
            {
                if (targets.empty())
                    return;

                targets.sort(Trinity::ObjectDistanceOrderPred(GetCaster(), false));
                if (targets.size() > GetSpellValue()->MaxAffectedTargets)
                {
                    std::list<WorldObject*>::iterator itr = targets.begin();
                    std::advance(itr, GetSpellValue()->MaxAffectedTargets);
                    targets.erase(itr, targets.end());
                }
            }
int ShapesScenePrivate::removeNode(const NodePtr &node)
{
    int index = 0;
    for (auto it = m_nodes.begin(), end = m_nodes.end(); it != end; ++it, ++index) {
        if (node == *it) {
            m_nodes.erase(it);
            if (node == m_pickedNode)
                m_pickedNode.reset();
            return index;
        }
    }
    return -1;
}
Пример #28
0
            void RemoveSocket(Socket *socket)
            {
                std::lock_guard<std::mutex> guard(m_socketLock);
                std::lock_guard<std::mutex> closingGuard(m_closingSocketLock);

                for (auto i = m_sockets.begin(); i != m_sockets.end(); ++i)
                    if (i->get() == socket)
                    {
                        m_closingSockets.push_front(std::move(*i));
                        m_sockets.erase(i);
                        return;
                    }
            }
Пример #29
0
	void RefreshStack () {
		for (typename std::list<T*>::iterator itState = stateList.begin();
				itState != stateList.end(); itState++) {
			if ((*itState)->pop) {
				delete *itState;
				itState = --stateList.erase(itState);
			}
			else
			if ((*itState)->off) {
				(*itState)->Init();
			}
		}
	}
Пример #30
0
void cancelUrlRequest(const std::string& _url) {

    // Only clear this request if a worker has not started operating on it!
    // otherwise it gets too convoluted with curl!
    auto itr = s_urlTaskQueue.begin();
    while(itr != s_urlTaskQueue.end()) {
        if((*itr)->url == _url) {
            itr = s_urlTaskQueue.erase(itr);
        } else {
            itr++;
        }
    }
}