Exemplo n.º 1
0
void lcdTest(){

	printf("Screen (%dx%d).\n",SCREENWIDTH, SCREENHEIGHT);
	printf("Blocks (%dx%d).\n",W_BLOCKS, H_BLOCKS);
	printf("Block size (%dx%d).\n",BLOCK_WIDTH, BLOCK_HEIGHT);
	Color w = {.red = 255,.green = 0,.blue = 0};
	for (int c = 0; c < H_BLOCKS; c++){
			if (c % 2 == 0) setBlock(c,c,Red);
			else setBlock(c,c,Blue);
	}
		refreshScreen(currentFrameBuffer);
}
void playerStep(){
	
	int x = rand()%3-1;
	int y = rand()%3-1;
	while(board[playerPos.x+x][playerPos.y+y] == Rock){
		 x = rand()%3-1;
		 y = rand()%3-1;
		while(x == 0 && y == 0){
		x = rand()%3-1;
		y = rand()%3-1;
		}
		
	}
	boardFlag[playerPos.x][playerPos.y] = 1;
	boardFlag[playerPos.x+x][playerPos.y+y] = 1;

	board[playerPos.x][playerPos.y] = Ground;
	board[playerPos.x+x][playerPos.y+y] = Pacman;
	playerPos.x = playerPos.x+x;
	playerPos.y = playerPos.y+y;


}
Exemplo n.º 2
0
Arquivo: lunxun.c Projeto: jsvisa/apue
int main(int argc, char **argv) {
	int sock;
	int clientSock;
	struct sockaddr_in addr, clientAddr;
	socklen_t len;
	char *tmp;
	time_t t;
	int size;
	char buf[1024];
	pid_t pid;

	sock = socket(AF_INET, SOCK_STREAM, 0);
	
	addr.sin_family = AF_INET;
	addr.sin_port = htons(atoi(argv[1]));
	addr.sin_addr.s_addr = INADDR_ANY;

	len = sizeof(addr);
	if(bind(sock, (struct sockaddr *)&addr, len) < 0) {
		perror("Bind");
		return 1;
	}

	setBlock(STDIN_FILENO, 0);
	listen(sock, 10);
	while(1) {
		len = sizeof(clientAddr);
		clientSock = accept(sock, (struct sockaddr *)&clientAddr, &len);
		if(clientSock < 0) {
			perror("accept");
		}
		setBlock(clientSock, 0);
		while(1) {
			size = recv(clientSock, buf, sizeof(buf)-1, 0);
			if(size <= 0) {
				if(errno != EAGAIN) {
					printf("errno=%d\n", errno);
					printf("客户端连接已断开\n");
					close(clientSock);
					break;
				}
			}
			else {
				buf[size] = '\0';
				printf("%s", buf);
			}
			size = read(STDIN_FILENO, buf, sizeof(buf)-1);
			if(size > 0) {
				buf[size] = '\0';
				send(clientSock, buf, size, 0);
			}
			usleep(300);
		}
	}
	return 0;
}
Exemplo n.º 3
0
bool Tank::command(enumOrder order)
{
	float stepX = 0.0f;
	float stepY = 0.0f;
	float fRotation = getRotation();

	switch (order)
	{
	case cmdNothing:
		break;
	case cmdGoUP:
		stepY = 1.0f;
		fRotation = 0.0f;
		break;
	case cmdGoDown:
		stepY = -1.0f;
		fRotation = 180.0f;
		break;
	case cmdGoLeft:
		stepX = -1.0f;
		fRotation = 270.0f;
		break;
	case cmdGoRight:
		stepX = 1.0f;
		fRotation = 90.0f;
		break;
	case cmdFire:
		//调用子弹开火
		return mBullet->fire();
	default:
		break;
	}

	//根据运行方向旋转坦克
	setRotation(fRotation);

	CCRect rect = this->boundingBox();
	mMovedRect.setRect(rect.getMinX() + stepX,rect.getMinY() + stepY, 
		rect.size.width, rect.size.height);
	//检测地图上的碰撞
	if (!mTileMapInfo->collisionTest(mMovedRect))
	{
		setBlock(false);
		return true;
	}
	//如果碰撞了就不要移动,设置为阻塞状态
	setBlock(true);

	return false;
}
Exemplo n.º 4
0
void initMainGameTable()
{
	int i;
	int j;
	int x,y;


	/* malloc memory space for blocks */

	for(i=0;i<VBLOCKS;i++)
		for(j=0;j<HBLOCKS;j++){
			gameTable[i][j]=newBlock();
		}


		printf("Block table malloced\n");


	/* assign positions to malloced blocks */


		
	

		for(i=0,y=0;i<VBLOCKS;i++)
			for(j=0,x=0;j<HBLOCKS;j++)
				setBlock(gameTable[i][j],j,i);
				
			
	 printf("Blocks placed\n");	

}
Exemplo n.º 5
0
int WorldMap::fillSphere(const v3d_t& pos, double radius, int blockType, BYTE uniqueLighting) {
  BoundingSphere s(pos, radius);

  int blocksFilled = 0;

  v3di_t start = v3di_v(static_cast<int>(pos.x - (radius + 1)),
    static_cast<int>(pos.y - (radius + 1)),
    static_cast<int>(pos.z - (radius + 1)));

  v3di_t stop = v3di_v(static_cast<int>(pos.x + (radius + 1)),
    static_cast<int>(pos.y + (radius + 1)),
    static_cast<int>(pos.z + (radius + 1)));

  v3di_t i;
  block_t block;
  block.type = blockType;
  block.uniqueLighting = uniqueLighting;

  for (i.z = start.z; i.z <= stop.z; i.z++) {
    for (i.y = start.y; i.y <= stop.y; i.y++) {
      for (i.x = start.x; i.x <= stop.x; i.x++) {
        if (s.isPointInside(v3d_v (static_cast<int>(i.x + 0.5),
          static_cast<int>(i.y + 0.5),
          static_cast<int>(i.z + 0.5))))
        {
          setBlock(i, block);
        }
      }
    }
  }


  return blocksFilled;
  //  return 0;
}
Exemplo n.º 6
0
void fillWorld(World *world) {
    int cx, cy, cz, bx, by, bz;

    for (cx = 0; cx < world->size; cx++) {
        for (cy = 0; cy < world->size; cy++) {
            for (cz = 0; cz < world->size; cz++) {
                for (bx = 0; bx < CHUNK_SIZE; bx++) {
                    for (by = 0; by < CHUNK_SIZE; by++) {
                        for (bz = 0; bz < CHUNK_SIZE; bz++) {
                            int r = (!bx|(bx==CHUNK_SIZE-1))&(!bz|(bz==CHUNK_SIZE-1));
                            int m = (bx + by + bz) % 2 ? -1 : (-1 << 6);
                            if (r) {
                                m = 0;
                                r = 255;
                            }

                            if (by == 0 && cy == 0) {
                                setBlock(getChunk(world, cx, cy, cz), bx, by, bz,
                                    (Block){1, {{255 & (r|m), 255 & m, 255 & m, 255}}});
                            }
                            // } else if (((bx == 0 && cx == 0) || (bz == 0 && cz == 0)) && by == 1 && cy == 0) {
                            //     setBlock(getChunk(world, cx, cy, cz), bx, by, bz,
                            //         (Block){1, {{255 & m, 255 & m, 255 & m, 255}}});
                            // }
                        }
                    }
                }

                renderChunk(getChunk(world, cx, cy, cz));
            }
        }
    }
}
NOX::Abstract::MultiVector&
LOCA::Extended::MultiVector::setBlock(const NOX::Abstract::MultiVector& source,
				      const std::vector<int>& index)
{
  return setBlock(dynamic_cast<const LOCA::Extended::MultiVector&>(source), 
		  index);
}
Exemplo n.º 8
0
	void BlockMap::setBlock(Block * b)
	{
		if(b != nullptr)
			setBlock(b->getPosition(), b);
		else
			std::cout << "WARNING: BlockMap::setBlock: null block passed" << std::endl;
	}
Exemplo n.º 9
0
// constructor from data
void NewtonEulerDSTest::testBuildNewtonEulerDS1()
{
  std::cout << "--> Test: constructor 1." <<std::endl;

  SP::NewtonEulerDS ds(new NewtonEulerDS(q0, velocity0, mass,  inertia ));
  double time = 1.5;
  ds->initialize(time);
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildNewtonEulerDS1A : ", Type::value(*ds) == Type::NewtonEulerDS, true);
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildNewtonEulerDS1B : ", ds->number() == 0, true);
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildNewtonEulerDS1D : ", ds->dimension() == 6, true);
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildNewtonEulerDS1D : ", ds->getqDim() == 7, true);
  CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildNewtonEulerDS1D : ", ds->scalarMass() == mass, true);

  SP::SimpleMatrix massMatrix(new SimpleMatrix(6,6));
  massMatrix->setValue(0, 0, mass);
  massMatrix->setValue(1, 1, mass);
  massMatrix->setValue(2, 2, mass);

  Index dimIndex(2);
  dimIndex[0] = 3;
  dimIndex[1] = 3;
  Index startIndex(4);
  startIndex[0] = 0;
  startIndex[1] = 0;
  startIndex[2] = 3;
  startIndex[3] = 3;
  setBlock(inertia, massMatrix, dimIndex, startIndex);

  CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildNewtonEulerDS1D : ", *(ds->mass()) == *(massMatrix), true);

  CPPUNIT_ASSERT_EQUAL_MESSAGE("testBuildNewtonEulerDS1D : ", ds->computeKineticEnergy() == 595.0, true);

  std::cout << "--> Constructor 1 test ended with success." <<std::endl;
}
Exemplo n.º 10
0
void CTeris_1View::StartCXY()
{
	
	GetDocument()->DeleteContents();
	this->initialBigBox();
	this->initialMoveBox();
	this->initialNextBox();
	GetDocument()->mode=CXY;
	GetDocument()->score=0;
	this->Invalidate();
	flag=TRUE;
	switch(GetDocument()->Num){
	case 1://贪吃蛇
		
		MessageBox("我相信,贪吃蛇,你一定玩过.\r但是,贪吃的俄罗斯方块你玩过吗?\r程先生是一个很奇怪的人.\r所以他设计的方块很奇怪\rtips:通关当且仅当获得1024分.");
		setFood();		
		break;
	case 2://黑洞模式
		MessageBox("有一天,程先生想到一个奇怪的游戏。");
		setBlock();
		break;
	case 4://坦克大战
		MessageBox("小时候,程先生有一台小霸王。\r里面有一个游戏叫做,坦克大战。\rtips:通关当且仅当获得1024分");
		break;
	case 3://华容道
		MessageBox("相信你已经觉得程先生是一个想象力丰富的人.\r所以,你应该知道,这一关,应该不同");
		break;
	}
	
}
Exemplo n.º 11
0
void step(){
    energymean = 0;
    int i;
    int prog[INSTRUCTIONS];
    repBlocks = 0;
    quantityMoved = 0;
    quantityKiled = 0;
    for(i = 0; i < INSTRUCTIONS; i++){
        prog[i] = rand() % 8;
    }
    setBlock(rand() % X_SIZE,0, prog, NULL, 0, 50, 50, 0);
    for(i = 0; i < X_SIZE; i++){
        memset(grid[i], NULL, sizeof(grid[i][0]) * Y_SIZE);
    }
    for(i = 0; i < lastBlock; i++){
        blockList[i].verified = 0;
        blockList[i].moved = 0;
        grid[blockList[i].x][blockList[i].y] = &blockList[i];
    }
    resoursesDistribuition();

    for(i = 0; i < lastBlock; i++){
        run(&blockList[i]);
    }
    fall();
    resolveKileds();
    resolveRep();
    resolveMoves();
}
Exemplo n.º 12
0
void CTeris_1View::upDateMoveAndNextBox()
{
	CTeris_1Doc* pDoc = GetDocument();
	pDoc->box.RemoveAt(1);
	CBox *tmp=(CBox *)pDoc->box.GetAt(1);
	tmp->NextResetMove();
	//delete tmp;
	if(GetDocument()->mode==CXY){
		
		CBox *b=(CBox *)pDoc->box.GetAt(0);
		b->LOCAL[CXYx][CXYy].canSee=SEE;
		switch(GetDocument()->Num){
			
		case 1:
			
			
			setFood();
			break;
		case 2:
			setBlock();
			break;
			
			
		}
		
	}
	initialNextBox();
}
Exemplo n.º 13
0
void
Field::addBlock(int blockX, int blockY, Color color, bool on)
{
  switch(color)
    {
    case YELLOW:
      yellowBlocks.push_front(new Block(blockX, blockY, color, on));
      break;

    case GREEN:
      greenBlocks.push_front(new Block(blockX, blockY, color, on));
      break;

    case BLUE:
      blueBlocks.push_front(new Block(blockX, blockY, color, on));
      break;

    default:
      consoleDemoInit();
      printf("ERROR: Default case reached in Field::addBlock()\n");
      while(1);
      break;
    }

  if(on)
    setBlock(blockX, blockY, BLOCK);
}
Exemplo n.º 14
0
//////////////////////////////////////////////////////////////
// Process operations.
//////////////////////////////////////////////////////////////
void Gsolve::process( const Eref& e, ProcPtr p )
{
	// cout << stoichPtr_ << "	dsolve = " <<	dsolvePtr_ << endl;
	if ( !stoichPtr_ )
		return;
	// First, handle incoming diffusion values. Note potential for
	// issues with roundoff if diffusion is not integral.
	if ( dsolvePtr_ ) {
		vector< double > dvalues( 4 );
		dvalues[0] = 0;
		dvalues[1] = getNumLocalVoxels();
		dvalues[2] = 0;
		dvalues[3] = stoichPtr_->getNumVarPools();
		dsolvePtr_->getBlock( dvalues );
		// Here we need to convert to integers, just in case. Normally
		// one would use a stochastic (integral) diffusion method with 
		// the GSSA, but in mixed models it may be more complicated.
		vector< double >::iterator i = dvalues.begin() + 4;
		for ( ; i != dvalues.end(); ++i ) {
		//	cout << *i << "	" << round( *i ) << "		";
			*i = round( *i );
		}
		setBlock( dvalues );
	}
	// Second, take the arrived xCompt reac values and update S with them.
	// Here the roundoff issues are handled by the GssaVoxelPools functions
	for ( unsigned int i = 0; i < xfer_.size(); ++i ) {
		XferInfo& xf = xfer_[i];
		// cout << xfer_.size() << "	" << xf.xferVoxel.size() << endl;
		for ( unsigned int j = 0; j < xf.xferVoxel.size(); ++j ) {
			pools_[xf.xferVoxel[j]].xferIn( xf, j, &sys_ );
		}
	}
	// Third, record the current value of pools as the reference for the
	// next cycle.
	for ( unsigned int i = 0; i < xfer_.size(); ++i ) {
		XferInfo& xf = xfer_[i];
		for ( unsigned int j = 0; j < xf.xferVoxel.size(); ++j ) {
			pools_[xf.xferVoxel[j]].xferOut( j, xf.lastValues, xf.xferPoolIdx );
		}
	}

	// Fourth, update the mol #s
	for ( vector< GssaVoxelPools >::iterator 
					i = pools_.begin(); i != pools_.end(); ++i ) {
		i->advance( p, &sys_ );
	}

	// Finally, assemble and send the integrated values off for the Dsolve.
	if ( dsolvePtr_ ) {
		vector< double > kvalues( 4 );
		kvalues[0] = 0;
		kvalues[1] = getNumLocalVoxels();
		kvalues[2] = 0;
		kvalues[3] = stoichPtr_->getNumVarPools();
		getBlock( kvalues );
		dsolvePtr_->setBlock( kvalues );
	}
}
Exemplo n.º 15
0
    void 
ChartView::updateView(Block *block)
{
    if(block == m_block)
        return;
    setBlock(block);
    updateView();
}
Exemplo n.º 16
0
int createPipe(SOCKET fds[2])
{
    if ( ::pipe(fds) != 0 )
    {
    #ifdef _NO_EXCEPTION
        return -1;
    #else
        tbutil::SyscallException ex(__FILE__,__LINE__);
        ex._error = tbutil::getSystemErrno();
        throw ex;
    #endif
    }
#ifdef _NO_EXCEPTION
    const int iRet = setBlock(fds[0],true);
    if ( iRet != 0 )
    {
        return iRet;
    }
    const int iRet2 = setBlock(fds[1] , true );
    if ( iRet2 != 0 )
    {
        return iRet2;
    }
#else
    try
    {
        setBlock(fds[0] , true );
    }
    catch(...)
    {
        closeSocketNoThrow( fds[0] );
        throw;
    }

    try
    {
        setBlock(fds[1] , true );
    }
    catch(...)
    {
        closeSocketNoThrow( fds[1] );
        throw;
    }
#endif
    return EXIT_SUCCESS;
} 
Exemplo n.º 17
0
bool BlockExplorer::switchTo(const QString& query)
{
    bool IsOk;
    int64_t AsInt = query.toInt(&IsOk);
    // If query is integer, get hash from height
    if (IsOk && AsInt >= 0 && AsInt <= chainActive.Tip()->nHeight) {
        std::string hex = getexplorerBlockHash(AsInt);
        uint256 hash = uint256S(hex);
        CBlockIndex* pIndex = mapBlockIndex[hash];
        if (pIndex) {
            setBlock(pIndex);
            return true;
        }
    }

    // If the query is not an integer, assume it is a block hash
    uint256 hash = uint256S(query.toUtf8().constData());

    // std::map<uint256, CBlockIndex*>::iterator iter = mapBlockIndex.find(hash);
    BlockMap::iterator iter = mapBlockIndex.find(hash);
    if (iter != mapBlockIndex.end()) {
        setBlock(iter->second);
        return true;
    }

    // If the query is neither an integer nor a block hash, assume a transaction hash
    CTransaction tx;
    uint256 hashBlock = 0;
    if (GetTransaction(hash, tx, hashBlock, true)) {
        setContent(TxToString(hashBlock, tx));
        return true;
    }

    // If the query is not an integer, nor a block hash, nor a transaction hash, assume an address
    CBitcoinAddress Address;
    Address.SetString(query.toUtf8().constData());
    if (Address.IsValid()) {
        std::string Content = AddressToString(Address);
        if (Content.empty())
            return false;
        setContent(Content);
        return true;
    }

    return false;
}
Exemplo n.º 18
0
void
Field::toggleBlocksAndSwitches(Color color)
{
  std::list<Block *>::iterator blIt;
  std::list<Switch *>::iterator swIt;
  int blockX, blockY;

  switch(color)
    {
    case YELLOW:
      for(blIt = yellowBlocks.begin();blIt != yellowBlocks.end();blIt++)
	{
	  bool on = (*blIt)->toggle();
	  blockX = (*blIt)->getX() / 32;
	  blockY = (*blIt)->getY() / 32;
	  setBlock(blockX, blockY, on ? BLOCK : EMPTY);
	}
      for(swIt = yellowSwitches.begin();swIt != yellowSwitches.end();swIt++)
	(*swIt)->toggle();
      break;

    case GREEN:
      for(blIt = greenBlocks.begin();blIt != greenBlocks.end();blIt++)
	{
	  bool on = (*blIt)->toggle();
	  blockX = (*blIt)->getX() / 32;
	  blockY = (*blIt)->getY() / 32;
	  setBlock(blockX, blockY, on ? BLOCK : EMPTY);
	}
      for(swIt = greenSwitches.begin();swIt != greenSwitches.end();swIt++)
	(*swIt)->toggle();
      break;

    case BLUE:
      for(blIt = blueBlocks.begin();blIt != blueBlocks.end();blIt++)
	{
	  bool on = (*blIt)->toggle();
	  blockX = (*blIt)->getX() / 32;
	  blockY = (*blIt)->getY() / 32;
	  setBlock(blockX, blockY, on ? BLOCK : EMPTY);
	}
      for(swIt = blueSwitches.begin();swIt != blueSwitches.end();swIt++)
	(*swIt)->toggle();
      break;
    }
}
Exemplo n.º 19
0
Arquivo: mm.c Projeto: ndukweiko/mm
/* Allocate a block of size size and return a pointer to it. */
void* mm_malloc (size_t size) {
  size_t reqSize;
  BlockInfo * ptrFreeBlock = NULL;
  size_t precedingBlockUseTag;
  // Zero-size requests get NULL.
  if (size == 0) {
    return NULL;
  }

  // Add one word for the initial size header.
  // Note that we don't need to boundary tag when the block is used!
  size += WORD_SIZE;
  if (size <= MIN_BLOCK_SIZE) {
    // Make sure we allocate enough space for a blockInfo in case we
    // free this block (when we free this block, we'll need to use the
    // next pointer, the prev pointer, and the boundary tag).
    reqSize = MIN_BLOCK_SIZE;
  } 
  
  else {
    // Round up for correct alignment
    reqSize = ALIGNMENT * ((size + ALIGNMENT - 1) / ALIGNMENT);
  }



  
  ptrFreeBlock = searchFreeList(reqSize); //test for available block
  if(ptrFreeBlock != NULL){ //if block of correct size available:
    precedingBlockUseTag = (ptrFreeBlock)->sizeAndTags & (TAG_PRECEDING_USED); //test to see if block preceeding the block to be allocated is allocated
    setBlock(ptrFreeBlock, reqSize, precedingBlockUseTag);//call to helper function, setBlock
  }

  else{
    requestMoreSpace(reqSize); //request a freeBlock of the appropriate size
    ptrFreeBlock = searchFreeList(reqSize);//search the free list now that we know the free block is there
    precedingBlockUseTag = TAG_PRECEDING_USED;
    setBlock(ptrFreeBlock, reqSize, precedingBlockUseTag);//call to helper function, setBlock


  }
  
  return UNSCALED_POINTER_ADD(ptrFreeBlock, WORD_SIZE);

}
Exemplo n.º 20
0
void printBoard(){
	
	for (int i = 0; i < H_BLOCKS; i++){
		for(int j = 0; j < W_BLOCKS; j++){
			 setBlock(i,j,board[i][j]);
		}
	}
refreshScreen(currentFrameBuffer);	
}
void StructureUtil::fill(BlockSource& world, const BlockPos& pos, int length, int heigth, int width, Block* block, int meta) {
	for (int x = pos.x; x < pos.x + length; x++) {
		for (int y = pos.y; y < pos.y + height; y++) {
			for (int z = pos.z; z < pos.z + width; z++) {
				setBlock(world, {x, y, z}, block, meta);
			}
		}
	}
}
Exemplo n.º 22
0
void field::newFruit()
{
  int x;
  int y;
  do
  {
    x = rand() % WIDTH;
    y = rand() % HEIGHT;
  } while (block(x, y) != EMPTY);
  setBlock(FRUIT, x, y);
}
void StructureUtil::fillPerimeter(BlockSource& world, const BlockPos& pos, int length, int heigth, int width, Block* block) {
	for (int x = pos.x; x < pos.x + length; x++) {
		for (int y = pos.y; y < pos.y + height; y++) {
			for (int z = pos.z; z < pos.z + width; z++) {
				if ((x == pos.x) || (x == pos.x + length - 1) || (z == pos.z) || (z == pos.z + width - 1)) {
					setBlock(world, {x, y, z}, block);
				}
			}
		}
	}
}
Exemplo n.º 24
0
static void drawSplines(TCBSpline* spline, int maxDots, int maxTime, float* buffer, int width, int height, float r, float g, float b)
{
	for (int j = 0; j < maxDots; j++)
	{	
		
		float curTime = (float)(j / (float)maxDots)*(float)maxTime;		

		VectorFloat pos = spline->getPos(curTime);

		setBlock(buffer, width, height, (int)pos.x, (int)pos.y, r, g, b);
		
	}
}
Exemplo n.º 25
0
EnableableNode::EnableableNode(QDataStream& stream)
    : Node(stream)
{
    addPort(new InputPort(this, "Enabled", "", Port::Scalar));

    addSetting(new BoolSetting(this, "Enabled", "", true, true, false));

    setting<BoolSetting>("Enabled")->connectPort(inputPort("Enabled"));

    connect(setting<BoolSetting>("Enabled"), &BoolSetting::changed, [this]() {
        setBlock(!setting<BoolSetting>("Enabled")->value());
    });
}
Exemplo n.º 26
0
	void Level::raiseWater()
	{
		if(waterLevel < getHeight() - 2)
		{
			waterLevel++;
			for(Int32 x = 1; x < getWidth() - 1; x++)
			{
				if(!isWall(x, waterLevel, false))
				{
					setBlock(waterBlock, x, waterLevel);
				}
			}
		}
	}
Exemplo n.º 27
0
aol::Vector<_DataType> & aol::Vector<_DataType>::copyUnblockedFrom ( const MultiVector<_DataType> & multiVector ) {
  if ( _size != multiVector.getTotalSize() ) {
    cerr << _size << " " << multiVector.getTotalSize() << endl;
    throw aol::Exception ( "aol::Vector::assignFrom ( MultiVector & ) : dimensions do not match.", __FILE__, __LINE__ );
  }

  setZero();
  int components = multiVector.numComponents();
  int n = 0;
  for ( int i = 0; i < components; ++i ) {
    setBlock ( n, multiVector[i] );
    n += multiVector[i].size();
  }
  return *this;
}
Exemplo n.º 28
0
void
Field::update()
{
  for(int i = 0;i < 16*12;i++)
    {
      if(breakables[i])
	{
	  breakables[i]->update();
	  if(breakables[i]->destroy())
	    {
	      setBlock(i % 16, i / 16, EMPTY);
	    }
	}
    }
}
Exemplo n.º 29
0
void FileBlocks::setBlocks(unsigned long beginIndex, unsigned long length, unsigned long* addresses) throw(
	ArrayIndexOutOfBoundsException*,
	HardDiskNotInitializedException*,
	InvalidBlockNumberException*,
	IOException*)
{
	if ((beginIndex+length) > MAX_BLOCKS)
	{
		throw new ArrayIndexOutOfBoundsException(beginIndex+length);
	}

	for (unsigned long i = 0; i < length; i++)
	{
		setBlock(beginIndex+i, addresses[i]);
	}
}
Exemplo n.º 30
0
void PropertyWidget::setParcel(int blockId, int parcelId, Block& block) {
	setBlock(blockId, block);

	QString str;
	str.setNum(parcelId);
	ui.lineEditParcelId->setText(str);

	Block::parcelGraphVertexIter vi, viEnd;
	int cnt = 0;
	for (boost::tie(vi, viEnd) = boost::vertices(block.myParcels); vi != viEnd; ++vi, ++cnt) {
		if (cnt == parcelId) {
			ui.comboBoxParcelType->setCurrentIndex(block.myParcels[*vi].parcelType);
			break;
		}
	}
}