示例#1
0
void VDAVIOutputSegmentedVideoStream::write(uint32 flags, const void *pBuffer, uint32 cbBuffer, uint32 samples) {
	if (mPendingRuns.empty())
		mPendingRuns.push_back(Run());
	else if (flags & AVIIF_KEYFRAME) {
		mPendingRuns.back().mbClosed = true;
		mPendingRuns.push_back(Run());
	}

	Run& run = mPendingRuns.back();
	run.mBlocks.push_back(Block());
	run.mSize += (cbBuffer + 1) & ~1;			// evenify for AVI
	Block& block = run.mBlocks.back();

	block.data = new char[cbBuffer];
	block.size = cbBuffer;
	block.capacity = cbBuffer;
	block.flags = flags;

	memcpy(block.data, pBuffer, cbBuffer);
	++mSamplesWritten;
	++mBufferedSamples;

	run.mEndTime = VDRoundToInt64(mSamplesWritten * (1000000.0 * (double)streamInfo.dwScale / (double)streamInfo.dwRate));

	mpParent->Update();
}
示例#2
0
void CArea::Split(std::list<CArea> &m_areas)const
{
	if(HolesLinked())
	{
		for(std::list<CCurve>::const_iterator It = m_curves.begin(); It != m_curves.end(); It++)
		{
			const CCurve& curve = *It;
			m_areas.push_back(CArea());
			m_areas.back().m_curves.push_back(curve);
		}
	}
	else
	{
		CArea a = *this;
		a.Reorder();

		if(CArea::m_please_abort)return;

		for(std::list<CCurve>::const_iterator It = a.m_curves.begin(); It != a.m_curves.end(); It++)
		{
			const CCurve& curve = *It;
			if(curve.IsClockwise())
			{
				if(m_areas.size() > 0)
					m_areas.back().m_curves.push_back(curve);
			}
			else
			{
				m_areas.push_back(CArea());
				m_areas.back().m_curves.push_back(curve);
			}
		}
	}
}
示例#3
0
void
endProfile(trace::Call &call, bool isDraw) {
    if (retrace::profilingWithBackends) {
        if (profilingBoundaries[QUERY_BOUNDARY_CALL] ||
            profilingBoundaries[QUERY_BOUNDARY_DRAWCALL]) {
            if (curMetricBackend) {
                curMetricBackend->endQuery(isDraw ? QUERY_BOUNDARY_DRAWCALL : QUERY_BOUNDARY_CALL);
            }
        }
        return;
    }

    /* CPU profiling for all calls */
    if (retrace::profilingCpuTimes) {
        CallQuery& query = callQueries.back();
        query.cpuEnd = getCurrentTime();
    }

    /* GPU profiling only for draw calls */
    if (isDraw) {
        if (retrace::profilingGpuTimes) {
            glEndQuery(GL_TIME_ELAPSED);
        }

        if (retrace::profilingPixelsDrawn) {
            glEndQuery(GL_SAMPLES_PASSED);
        }
    }

    if (retrace::profilingMemoryUsage) {
        CallQuery& query = callQueries.back();
        query.vsizeEnd = os::getVsize();
        query.rssEnd = os::getRss();
    }
}
示例#4
0
void Pickup::do_pickup( const tripoint &pickup_target_arg, bool from_vehicle,
                        std::list<int> &indices, std::list<int> &quantities, bool autopickup )
{
    bool got_water = false;
    int cargo_part = -1;
    vehicle *veh = nullptr;
    bool weight_is_okay = (g->u.weight_carried() <= g->u.weight_capacity());
    bool volume_is_okay = (g->u.volume_carried() <= g->u.volume_capacity());
    bool offered_swap = false;
    // Convert from player-relative to map-relative.
    tripoint pickup_target = pickup_target_arg + g->u.pos();
    // Map of items picked up so we can output them all at the end and
    // merge dropping items with the same name.
    PickupMap mapPickup;

    if( from_vehicle ) {
        int veh_root_part = -1;
        veh = g->m.veh_at( pickup_target, veh_root_part );
        cargo_part = veh->part_with_feature( veh_root_part, "CARGO", false );
    }

    while( g->u.moves >= 0 && !indices.empty() ) {
        // Pulling from the back of the (in-order) list of indices insures
        // that we pull from the end of the vector.
        int index = indices.back();
        int quantity = quantities.back();
        // Whether we pick the item up or not, we're done trying to do so,
        // so remove it from the list.
        indices.pop_back();
        quantities.pop_back();

        item *target = nullptr;
        if( from_vehicle ) {
            target = g->m.item_from( veh, cargo_part, index );
        } else {
            target = g->m.item_from( pickup_target, index );
        }

        if( target == nullptr ) {
            continue; // No such item.
        }

        pick_one_up( pickup_target, *target, veh, cargo_part, index, quantity,
                     got_water, offered_swap, mapPickup, autopickup );
    }

    if( !mapPickup.empty() ) {
        show_pickup_message(mapPickup);
    }

    if (got_water) {
        add_msg(m_info, _("You can't pick up a liquid!"));
    }
    if (weight_is_okay && g->u.weight_carried() > g->u.weight_capacity()) {
        add_msg(m_bad, _("You're overburdened!"));
    }
    if (volume_is_okay && g->u.volume_carried() > g->u.volume_capacity()) {
        add_msg(m_bad, _("You struggle to carry such a large volume!"));
    }
}
示例#5
0
void create_pipe(){
    static const double h_min=(DISPLAY_HEIGHT-barrier_height_range)/2.0f;
    static const double h_max=(DISPLAY_HEIGHT-(DISPLAY_HEIGHT-barrier_height_range)/2.0f)-barrier_gap;
    double height=drand(h_min,h_max);

// init upper pipe
    pipes.push_back(new my_pipe);
    pipes.back()->set_values(my_pipe::pipe_image,40+DISPLAY_WIDTH,al_get_bitmap_height(my_pipe::pipe_image)/2-height-barrier_gap,-(DISPLAY_WIDTH/barrier_lifetime),0);
    pipes.back()->has_passed=0;
    pipes.back()->is_pair_leader=1;

// init lower pipe
    pipes.push_back(new my_pipe);
    pipes.back()->set_values(my_pipe::pipe_image,40+DISPLAY_WIDTH,al_get_bitmap_height(my_pipe::pipe_image)/2+DISPLAY_HEIGHT-height,-(DISPLAY_WIDTH/barrier_lifetime),0);
    pipes.back()->has_passed=0;
    pipes.back()->is_pair_leader=0;
    menu->to_top();
    start_button->to_top();
    quit_button->to_top();
    score_string->to_top();
#ifdef NDEBUG
    tick_string->to_top();
    vel_string->to_top();
#endif
    bird->to_top();
}
示例#6
0
void Variables::leaveScope(bool insideLoop)
{
    if (insideLoop) {
        // read variables are read again in subsequent run through loop
        std::set<unsigned int> const & currentVarReadInScope = _varReadInScope.back();
        for (std::set<unsigned int>::const_iterator readIter = currentVarReadInScope.begin();
             readIter != currentVarReadInScope.end();
             ++readIter) {
            read(*readIter, nullptr);
        }
    }

    std::list<std::set<unsigned int> >::reverse_iterator reverseReadIter = _varReadInScope.rbegin();
    ++reverseReadIter;
    if (reverseReadIter != _varReadInScope.rend()) {
        // Transfer read variables into previous scope

        std::set<unsigned int> const & currentVarAddedInScope = _varAddedInScope.back();
        std::set<unsigned int>  & currentVarReadInScope = _varReadInScope.back();
        for (std::set<unsigned int>::const_iterator addedIter = currentVarAddedInScope.begin();
             addedIter != currentVarAddedInScope.end();
             ++addedIter) {
            currentVarReadInScope.erase(*addedIter);
        }
        std::set<unsigned int> & previousVarReadInScope = *reverseReadIter;
        previousVarReadInScope.insert(currentVarReadInScope.begin(),
                                      currentVarReadInScope.end());
    }
    _varReadInScope.pop_back();
    _varAddedInScope.pop_back();
}
示例#7
0
void
endProfile(trace::Call &call, bool isDraw) {

    /* CPU profiling for all calls */
    if (retrace::profilingCpuTimes) {
        CallQuery& query = callQueries.back();
        query.cpuEnd = getCurrentTime();
    }

    /* GPU profiling only for draw calls */
    if (isDraw) {
        if (retrace::profilingGpuTimes) {
            glEndQuery(GL_TIME_ELAPSED);
        }

        if (retrace::profilingPixelsDrawn) {
            glEndQuery(GL_SAMPLES_PASSED);
        }
    }

    if (retrace::profilingMemoryUsage) {
        CallQuery& query = callQueries.back();
        query.vsizeEnd = os::getVsize();
        query.rssEnd = os::getRss();
    }
}
示例#8
0
    inline void add_value(const string_t& _value)
    {
        assert(has_value.size());
        assert(!has_value.back());

        has_value.back() = true;
        out << ">" << _value;
    }
示例#9
0
void Pickup::do_pickup( point pickup_target, bool from_vehicle,
                        std::list<int> &indices, std::list<int> &quantities, bool autopickup )
{
    bool got_water = false;
    int cargo_part = -1;
    vehicle *veh = nullptr;
    bool weight_is_okay = (g->u.weight_carried() <= g->u.weight_capacity());
    bool volume_is_okay = (g->u.volume_carried() <= g->u.volume_capacity() -  2);
    bool offered_swap = false;
    // Convert from player-relative to map-relative.
    pickup_target.x += g->u.xpos();
    pickup_target.y += g->u.ypos();
    // Map of items picked up so we can output them all at the end and
    // merge dropping items with the same name.
    std::map<std::string, int> mapPickup;
    std::map<std::string, item> item_info;

    if( from_vehicle ) {
        int veh_root_part = -1;
        veh = g->m.veh_at( pickup_target.x, pickup_target.y, veh_root_part );
        cargo_part = veh->part_with_feature( veh_root_part, "CARGO", false );
    }

    std::vector<item> &here = from_vehicle ? veh->parts[cargo_part].items :
        g->m.i_at_mutable( pickup_target.x, pickup_target.y );

    // Grow here vector if needed to avoid resize operations invalidating pointers during operation.
    here.reserve( here.size() + 1 );

    while( g->u.moves >= 0 && !indices.empty() ) {
        // Pulling from the back of the (in-order) list of indices insures
        // that we pull from the end of the vector.
        int index = indices.back();
        int quantity = quantities.back();
        // Whether we pick the item up or not, we're done trying to do so,
        // so remove it from the list.
        indices.pop_back();
        quantities.pop_back();

        pick_one_up( pickup_target, here[index], veh, cargo_part, index, quantity,
                     got_water, offered_swap, mapPickup, item_info, autopickup );
    }

    if( !mapPickup.empty() ) {
        show_pickup_message(mapPickup, item_info);
    }

    if (got_water) {
        add_msg(m_info, _("You can't pick up a liquid!"));
    }
    if (weight_is_okay && g->u.weight_carried() >= g->u.weight_capacity()) {
        add_msg(m_bad, _("You're overburdened!"));
    }
    if (volume_is_okay && g->u.volume_carried() > g->u.volume_capacity() - 2) {
        add_msg(m_bad, _("You struggle to carry such a large volume!"));
    }
}
示例#10
0
void delkey(HANDLE hCalc){
	if (!button_list.empty()){
	UINT style = GetWindowLong(button_list.back(),GWL_STYLE);
				style &= ~WS_VISIBLE;
				SetWindowLong(button_list.back(),GWL_STYLE,style);
				//UpdateWindow((HWND)hCalc);
				SendMessage((HWND)hCalc,WM_PAINT,0,0);
				button_list.pop_back();
	}
}
示例#11
0
 void reset()
 {
     while (!active.empty()) {
         delete active.back();
         active.pop_back();
     }
     while (!inactive.empty()) {
         delete inactive.back();
         inactive.pop_back();
     }
 }
示例#12
0
void MultitouchNavigation::rotateZ(const std::list<TouchContact> &contacts)
{
    // get current screen position of finger
    osg::Vec3d curr3DVec1(contacts.front().x, cover->frontWindowVerticalSize - contacts.front().y, 0.);
    osg::Vec3d curr3DVec2(contacts.back().x, cover->frontWindowVerticalSize - contacts.back().y, 0.);

    if (_counter > 0)
    {
        // figure out rotation
        osg::Vec3d lineCurrCurr = osg::Vec3d(curr3DVec1.x(), curr3DVec1.y(), 1.0) ^ osg::Vec3d(curr3DVec2.x(), curr3DVec2.y(), 1.0);
        osg::Vec3d linePrevPrev = osg::Vec3d(_prev3DVec1.x(), _prev3DVec1.y(), 1.0) ^ osg::Vec3d(_prev3DVec2.x(), _prev3DVec2.y(), 1.0);
        osg::Vec3d interception = lineCurrCurr ^ linePrevPrev;
        if (interception.z() != 0.)
        {
            double x = interception.x() / interception.z();
            double y = interception.y() / interception.z();

            // calculate ModelView - Projection - Window Transformation
            osg::Camera *cam = coVRConfig::instance()->channels[0].camera;
            osg::Matrix MVPW(cam->getViewMatrix() * cam->getProjectionMatrix() * cam->getViewport()->computeWindowMatrix());
            osg::Matrixd inverseMVPW = osg::Matrixd::inverse(MVPW);
            // determine z-plane of Xform in screen coordinates
            osg::Vec3d XformTranslation2D = cover->getXformMat().getTrans() * MVPW;
            // rotation center in Xform coordinates
            osg::Vec3d currentVector3D(x, y, XformTranslation2D.z());
            currentVector3D = currentVector3D * inverseMVPW;

            // calculate angle & axis
            double angle = angleBetween3DVectors((_prev3DVec1 - _prev3DVec2), (curr3DVec1 - curr3DVec2));
            osg::Vec3d axis = cover->getViewerMat().getTrans() - currentVector3D;
            osg::Vec3d sign = (_prev3DVec1 - _prev3DVec2) ^ (curr3DVec1 - curr3DVec2);
            sign.normalize();
            axis.x() = axis.x() * sign.z();
            axis.y() = axis.y() * sign.z();
            axis.z() = axis.z() * sign.z();
            osg::Quat delta = osg::Quat(angle, axis);

            // create copy of XformMat for calculation
            osg::Matrixd Xform = cover->getXformMat();
            // translate coordinate system to center of line
            Xform.postMultTranslate(-currentVector3D);
            // rotate
            Xform.postMultRotate(delta);
            // translate back to origin
            Xform.postMultTranslate(currentVector3D);
            // set XformMat to copy
            cover->setXformMat(Xform);
        }
    }

    _prev3DVec1 = curr3DVec1;
    _prev3DVec2 = curr3DVec2;
    _counter++;
}
示例#13
0
	void add(int value)
	{
		if(inRep)
			tmp.push_back(value);
		else
		{
			// add 'value' here.
			nodes.push_back(CNode());
			nodes.back().value = value;
			root->children.push_back(&nodes.back());
		}
	}
示例#14
0
void Constraint::Disconnect(std::list<HeeksObj*> parents)
{
	HeeksObj* owner = GetFirstOwner();
	if(parents.back() == owner)
	{
		this->RemoveOwner(owner);
		return;
	}
	owner = GetNextOwner();
	if(parents.back() == owner)
		RemoveOwner(owner);
}
	void Identifier::algorithm_nearestFit(std::list<Frame> & frames)
	{
		Frame * current = &frames.front();
		Frame * previous = &(*(++frames.begin()));
		
		static std::list<std::list<Error>> errorMapping;
		static std::vector<std::list<std::list<Error>::iterator>> errorMapIterators;
		errorMapping.clear();
		errorMapIterators.clear();

		float distanceError, areaError, error;
		std::list<Error>::iterator errorMapIteratorIterator;
		std::list<std::list<Error>>::iterator errorMapIterator;
		int pIndex;
		for(std::vector<Object>::iterator c = current->objects.begin(); c != current->objects.end(); c++)
		{
			errorMapIterator = errorMapping.insert(errorMapping.end(), std::list<Error>());
			errorMapIterators.push_back(std::list<std::list<Error>::iterator>());
			pIndex = 0;
			for(std::vector<Object>::iterator p = previous->objects.begin(); p != previous->objects.end(); p++)
			{
				distanceError = std::pow(c->x - p->x - p->dx, 2) + std::pow(c->y - p->y - p->dy, 2);
				error = distanceError;

				errorMapIteratorIterator = errorMapping.back().insert(errorMapping.back().end(),Error(&(*p), &(*c), pIndex, error));
				errorMapIterators[pIndex].push_back(errorMapIteratorIterator);
				pIndex++;
			}
			errorMapping.back().sort();
		}

		for(int i = 0; i < std::min(current->objects.size(), previous->objects.size()); i++)
		{
			errorMapping.sort();
			errorMapping.front().front().current->id = errorMapping.front().front().previous->id;
			errorMapping.front().front().current->model = errorMapping.front().front().previous->model;
			errorMapping.front().front().current->isDecided = true;
			
			while(it != errorMapIterator->end())
				.erase(it)
			
		}

		for(std::vector<Object>::iterator c = current->objects.begin(); c != current->objects.end(); c++)
		{
			if(!c->isDecided)
				c->id = newID();
		}

		

	}
示例#16
0
void IGFrameManager::postTreatVerticalList (std::list <IGSmartPtr <IGFrame>> &lFrameList)
{
	float fSeparationStep = (lFrameList.back()->GetFrameTopF() + lFrameList.back()->GetFrameHeightF() - lFrameList.front()->GetFrameTopF()) / (float)lFrameList.size();
	float fSeparationValue = lFrameList.front()->GetFrameTopF();
	for (std::list<IGSmartPtr <IGFrame>>::const_iterator iterFrames = lFrameList.begin(); 
		iterFrames != lFrameList.end();
		++iterFrames)
	{
		(*iterFrames)->SetFrameTopF (fSeparationValue);
		(*iterFrames)->SetFrameHeightF (fSeparationStep);
		fSeparationValue += fSeparationStep;
	}
}
int CDirectoryMonitor::WatchDirectory(TCHAR *Directory,UINT WatchFlags,
void (*DirectoryAltered)(TCHAR *szFileName,DWORD dwAction,void *pData),
BOOL bWatchSubTree,void *pData)
{
	CDirInfo	pDirInfo;

	if(Directory == NULL)
		return -1;

	pDirInfo.m_pDirectoryMonitor	= this;
	pDirInfo.m_hThread				= m_hThread;
	pDirInfo.m_WatchFlags			= WatchFlags;
	pDirInfo.m_UniqueId				= m_UniqueId;
	pDirInfo.m_DirectoryAltered		= DirectoryAltered;
	pDirInfo.m_pData				= pData;
	pDirInfo.m_bWatchSubTree		= bWatchSubTree;
	pDirInfo.m_bMarkedForDeletion	= FALSE;

	/* This suppresses crtical error message boxes, such as the one
	that mey arise from CreateFile() when opening attempting to
	open a floppy drive that doesn't have a floppy disk (also
	CD/DVD drives etc). */
	SetErrorMode(SEM_FAILCRITICALERRORS);

	StringCchCopy(pDirInfo.m_DirPath,MAX_PATH,Directory);

	pDirInfo.m_hDirectory = CreateFile(pDirInfo.m_DirPath,
	FILE_LIST_DIRECTORY,FILE_SHARE_READ|FILE_SHARE_DELETE|FILE_SHARE_WRITE,
	NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED,NULL);

	if(pDirInfo.m_hDirectory == INVALID_HANDLE_VALUE)
	{
		free(pData);
		return -1;
	}

	EnterCriticalSection(&m_cs);

	/* TODO: This operation alters the list, including the
	previously inserted item (e.g by updating list pointers).
	Therefore, need to lock access between this function and
	other reads of the inserted item. */
	m_DirWatchInfoList.push_back(pDirInfo);

	m_DirWatchInfoList.back().m_Async.hEvent = &m_DirWatchInfoList.back();
	QueueUserAPC(WatchDirectoryInternal,m_hThread,(ULONG_PTR)&m_DirWatchInfoList.back());

	LeaveCriticalSection(&m_cs);

	return m_UniqueId++;
}
示例#18
0
QueueItem::QueueItem(Media media, std::list< QueueItem* >& queue, WContainerWidget* container, Session* session, WContainerWidget* parent)
  : WContainerWidget(parent), PlaylistItem(media)
{
  QueueItem *queueItem = this;
  Dbo::Transaction t(*session);
  WAnchor *anchor = new WAnchor{this};
  anchor->addWidget(WW<WText>(media.title(t)).css("link-hand").onClick([=](WMouseEvent&){ playSignal.emit(this); }));
  WContainerWidget *actionsContainer = WW<WContainerWidget>(anchor).css("pull-right");
  auto fixButtons = [=,&queue] {
    for(QueueItem *item: queue) {
      item->upButton->setHidden(item == queue.front());
      item->downButton->setHidden(item == queue.back());
    }
  };
  
  auto moveElement = [=,&queue](int direction) {
    auto element = std::find(begin(queue), end(queue), queueItem);
    auto nextElement = element;
    direction>0 ? nextElement++ : nextElement--;
    swap(*nextElement, *element);
    int index = container->indexOf(queueItem);
    container->removeWidget(queueItem);
    container->insertWidget(index + direction, queueItem);
    fixButtons();
  };
  
  actionsContainer->addWidget(upButton = WW<WImage>(Settings::staticPath("/icons/actions/up.png"))
    .css("link-hand").onClick([=,&queue](WMouseEvent){
    if(queue.front() == queueItem) return;
    moveElement(-1);
  }));
  actionsContainer->addWidget(downButton = WW<WImage>(Settings::staticPath("/icons/actions/down.png"))
    .css("link-hand").onClick([=,&queue](WMouseEvent){
    if(queue.back() == queueItem) return;
    moveElement(+1);
  }));
  actionsContainer->addWidget(removeButton = WW<WImage>(Settings::staticPath("/icons/actions/delete.png"))
    .css("link-hand").onClick([=,&queue](WMouseEvent){
    queue.erase(std::remove(begin(queue), end(queue), queueItem));
    delete queueItem;
    fixButtons();
  }));
  upButton->setHiddenKeepsGeometry(true);
  downButton->setHiddenKeepsGeometry(true);
  container->addWidget(this);
  queue.push_back(this);
  fixButtons();
}
示例#19
0
文件: _trace.cpp 项目: Jeitan/cartopy
GEOSGeometry *LineAccumulator::as_geom(GEOSContextHandle_t handle)
{
    m_lines.remove_if(degenerate_line);

    if(m_lines.size() > 1)
    {
        //std::cerr << "Checking first & last" << std::endl;
        Point first, last;
        first = m_lines.front().front();
        last = m_lines.back().back();
        //std::cerr << "first: " << first.x << ", " << first.y << std::endl;
        //std::cerr << "last: " << last.x << ", " << last.y << std::endl;
        if(close(first.x, last.x) && close(first.y, last.y))
        {
            m_lines.front().pop_front();
            m_lines.back().splice(m_lines.back().end(), m_lines.front());
            m_lines.pop_front();
        }
    }

    std::vector<GEOSGeometry *> geoms;
    std::list<Line>::const_iterator ilines;
    for(ilines = m_lines.begin(); ilines != m_lines.end(); ++ilines)
    {
        std::list<Point>::const_iterator ipoints;
        int i;

        GEOSCoordSequence *coords = GEOSCoordSeq_create_r(handle, (*ilines).size(), 2);
        for(ipoints = (*ilines).begin(), i = 0; ipoints != (*ilines).end(); ++ipoints, ++i)
        {
            GEOSCoordSeq_setX_r(handle, coords, i, ipoints->x);
            GEOSCoordSeq_setY_r(handle, coords, i, ipoints->y);
        }
        geoms.push_back(GEOSGeom_createLineString_r(handle, coords));
    }

    GEOSGeometry *geom;
    if(geoms.empty())
    {
        geom = GEOSGeom_createEmptyCollection_r(handle, GEOS_MULTILINESTRING);
    }
    else
    {
        geom = GEOSGeom_createCollection_r(handle, GEOS_MULTILINESTRING,
                                           &geoms[0], geoms.size());
    }
    return geom;
}
示例#20
0
  //------------------------------------------------------------------------------------------------------------------------------------
  void passAdvertisement(const SOCKADDR& host, Util::MemoryFrame ad)
  {
    INTERLOCKED;

    // find if the list already has an ad from this host
    AdFile *adFile = nullptr;
    for(auto &g : gameList)
    {
      // if peer IDs equal
      if ( !memcmp(&g.gameInfo.saHost, &host, sizeof(SOCKADDR)) )
      {
        adFile = &g;
        break;
      }
    }

    // if the ad is from a new host, create a new adFile
    if(!adFile)
    {
      AdFile g;
      gameList.push_back(g);
      adFile = &gameList.back();
      adFile->gameInfo.dwIndex = ++nextGameAdID;
    }

    // init the new entry
    Util::MemoryFrame::from(adFile->gameInfo).writeAs(ad.readAs<game>());
    Util::MemoryFrame::from(adFile->extraBytes).write(ad);
    adFile->gameInfo.dwTimer = GetTickCount();
    adFile->gameInfo.saHost = host;
    adFile->gameInfo.pExtra = adFile->extraBytes;
  }
示例#21
0
long findTriangleNumber(long k,std::list<long>& primes,std::list<long>::iterator& iter)
{
	long trinum = k*(k+1)/2;
	while(primes.back()*primes.back()<trinum)
	{
		growingPrimeSet(primes,*iter,*(++iter));
	}
	std::map<long,int> fac;
	factor(trinum,primes,fac);
	long r = 1;
	for (auto mi = fac.begin(); mi != fac.end() ; ++ mi)
	{
		r *= (mi->second+1);
	}
	return r;
}
示例#22
0
bool PickerCells::saveOpenCategories(std::list<std::list<std::string> >& masterList,
			const std::list<std::string> &parentHier,
			PickerCell *selectedCell) const {
	bool hasSelectedCell=false;
	for (int i=0; i<count(); i++) {
		const PickerCell* cell = cellAt(i);
		if (cell == selectedCell) {
			hasSelectedCell=true;
		}
		if (!cell->hideChildren()) {
			masterList.push_back(parentHier);
			std::list<std::string> * newItem = &masterList.back();
			(*newItem).push_back(cell->id());
			PickerCells *newCells = cell->children();
			bool savedCell=false;
			if (newCells) {
				savedCell = newCells->saveOpenCategories(masterList, (*newItem), selectedCell);
			}
			if (savedCell) {
				(*newItem).push_back(selectedCell->id());
			}
		}
	}
	return hasSelectedCell;
}
示例#23
0
int check_collisions(const std::list<Link>& this_snake,
                      const std::list<Link>& other) {
  // Only need to check head
  const Link head = this_snake.back();

  // Check self collisions
  std::list<Link>::const_iterator it = this_snake.begin();
  while (it != --this_snake.end()) {
    if (head.x == it->x && head.y == it->y) {
      return head.player;
    }
    ++it;
  }

  // Check other collisions
  std::list<Link>::const_iterator othit = other.begin();
  while (othit != other.end()) {
    if (head.x == othit->x && head.y == othit->y) {
      return head.player;
    }
    ++othit;
  }

  // Check wall check_collisions
  if (head.x == 0 || head.x == MAX_BOARD_X ||
      head.y == 0 || head.y == MAX_BOARD_Y) {
    return head.player;
  }
  return 0;
}
示例#24
0
        void RemoveCrystal()
        {
            if (!luiCrystals.empty())
            {
                if (instance)
                    if (GameObject* temp = instance->instance->GetGameObject(luiCrystals.back()))
                        temp->SetGoState(GO_STATE_READY);
                luiCrystals.pop_back();
            }
            if (luiCrystals.empty())
            {
                me->CastStop();
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                Phase = PHASE_2;
                events.Reset();
                events.ScheduleEvent(EVENT_BLIZZARD,0);
                events.ScheduleEvent(EVENT_BLAST,urand(20000,30000));
                events.ScheduleEvent(EVENT_CURSE,5000);
                events.ScheduleEvent(EVENT_BOLT,2000);

                if (IsHeroic())
                    events.ScheduleEvent(EVENT_HERO_SUMMON,0);
            }
        }
示例#25
0
 size_t socket_t::send_all(const std::list<container_t>& messages, int flags) {
   const auto* last_message = &messages.back();
   size_t total = 0;
   for(const auto& message : messages)
     total += static_cast<size_t>(send<container_t>(message, (last_message == &message ? 0 : ZMQ_SNDMORE) | flags));
   return total;
 }
示例#26
0
//==============================================================================
//
// Get Vertex
//
// look up a vertex object given its "state"
//
//==============================================================================
Graph::Vertex *Graph::GetVertex(std::vector<int>& state)
{
    // TODO: ideally this should be implemented with hashing to be more
    // efficient, but this is just to get it done:
    std::list<Vertex>::iterator iter;
    for (iter = vtxList.begin(); iter != vtxList.end(); iter++)
    {
        Vertex *vtx = &(*iter);
        if (std::equal(vtx->state.begin(), vtx->state.end(), state.begin()))
        {
            return vtx;
        }
    }

    // if we made it here, this vertex doesn't exist. Create it.
    Vertex newVtx;
    memset(&newVtx, 0, sizeof(Vertex));

    newVtx.color = kVertexColor_White;
    newVtx.state = state;
    newVtx.index = numVertices++;
    vtxList.push_back(newVtx);

    return &vtxList.back();
}
示例#27
0
                /**
                 * Add a null terminated string to the store. This will
                 * automatically get more memory if we are out.
                 * Returns a pointer to the copy of the string we have
                 * allocated.
                 */
                const char* add(const char* string) {
                    size_t len = std::strlen(string) + 1;

                    assert(len <= m_chunk_size);

                    size_t chunk_len = m_chunks.back().size();
                    if (chunk_len + len > m_chunks.back().capacity()) {
                        add_chunk();
                        chunk_len = 0;
                    }

                    m_chunks.back().append(string);
                    m_chunks.back().append(1, '\0');

                    return m_chunks.back().c_str() + chunk_len;
                }
示例#28
0
void			Display::addSnakeSprite(std::list<ISnake *> sList)
{
  ISnake	*back;
  back = sList.back();
  this->addElem(back->getX(), back->getY(), "boule.png");
  this->_snakeSize += 1;
}
示例#29
0
    inline void open_object(const string_t& _name)
    {
        if(has_value.size() && !has_value.back())
        {
            has_value.back() = true;
            out << ">\n";
        }

        has_value.push_back(false);

        if (indent)
            _indent();

        ++level;
        out << "<" << _name;
    }
示例#30
0
VOID StoreMulti(ADDRINT addr, UINT64 size)
{
#ifdef ONLY_MAIN
	if(!g_bEnable)
		return;
#endif

	UINT64 frame = g_FrameStack.back();
#ifdef ZERO_STACK	
	if( g_hFrame2Size[frame] == 0 )
		return;
#endif
	
	UINT64 line = addr >> g_nProfDistPower;
	if( line < 0x400000 )
		return;

	UINT64 nSize = size >> 3; 			// 64-bit memory width, which equals 2^3=8 bytes

	
	g_hFrame2W[frame] += nSize;
	
    g_hLine2W[line] += nSize;	
	g_hLine2Frames[line].insert( frame );	
}