コード例 #1
0
ファイル: movement.cpp プロジェクト: edubart/otserv
void MoveEvents::addEvent(MoveEvent* moveEvent, const int32_t& id, MoveListMap& map)
{
	MoveListMap::iterator it = map.find(id);

	if (it == map.end())
	{
		MoveEventList moveEventList;
		moveEventList.moveEvent[moveEvent->getEventType()].push_back(moveEvent);
		map[id] = moveEventList;
	}
	else
	{
		std::list<MoveEvent*>& moveEventList = it->second.moveEvent[moveEvent->getEventType()];

		for (std::list<MoveEvent*>::iterator it = moveEventList.begin(); it != moveEventList.end(); ++it)
		{
			if ((*it)->getSlot() == moveEvent->getSlot())
			{
				std::cout << "Warning: [MoveEvents::addEvent] Duplicate move event found: " << id << std::endl;
			}
		}

		moveEventList.push_back(moveEvent);
	}
}
コード例 #2
0
ファイル: movement.cpp プロジェクト: Fir3element/035
inline void MoveEvents::clearMap(MoveListMap& map)
{
    for(MoveListMap::iterator it = map.begin(); it != map.end(); ++it)
    {
        for(int32_t i = MOVE_EVENT_FIRST; i <= MOVE_EVENT_LAST; ++i)
        {
            EventList& moveEventList = it->second.moveEvent[i];
            for(EventList::iterator it = moveEventList.begin(); it != moveEventList.end(); ++it)
                delete (*it);

            moveEventList.clear();
        }
    }

    map.clear();
}
コード例 #3
0
void MoveEvents::addEvent(MoveEvent* moveEvent, int32_t id, MoveListMap& map)
{
	auto it = map.find(id);
	if (it == map.end()) {
		MoveEventList moveEventList;
		moveEventList.moveEvent[moveEvent->getEventType()].push_back(moveEvent);
		map[id] = moveEventList;
	} else {
		std::list<MoveEvent*>& moveEventList = it->second.moveEvent[moveEvent->getEventType()];
		for (MoveEvent* existingMoveEvent : moveEventList) {
			if (existingMoveEvent->getSlot() == moveEvent->getSlot()) {
				std::cout << "[Warning - MoveEvents::addEvent] Duplicate move event found: " << id << std::endl;
			}
		}
		moveEventList.push_back(moveEvent);
	}
}