Esempio n. 1
0
File SDClass::open(char *filepath, uint8_t mode) {
  /*

     Open the supplied file path for reading or writing.

     The file content can be accessed via the `file` property of
     the `SDClass` object--this property is currently
     a standard `SdFile` object from `sdfatlib`.

     Defaults to read only.

     If `write` is true, default action (when `append` is true) is to
     append data to the end of the file.

     If `append` is false then the file will be truncated first.

     If the file does not exist and it is opened for writing the file
     will be created.

     An attempt to open a file for reading that does not exist is an
     error.

   */

  // TODO: Allow for read&write? (Possibly not, as it requires seek.)

  fileOpenMode = mode;
  walkPath(filepath, root, callback_openPath, this);

  return File();

}
Esempio n. 2
0
boolean SDClass::exists(char *filepath) {
  /*

     Returns true if the supplied file path exists.

   */
  return walkPath(filepath, root, callback_pathExists);
}
Esempio n. 3
0
boolean MemoryCardDevice::makeDir(char *filepath) {
  /*
  
    A rough equivalent to `mkdir -p`.
  
   */
  return walkPath(filepath, root, callback_makeDirPath);
}
Esempio n. 4
0
boolean SDClass::rmdir(char *filepath) {
  /*
  
    Remove a single directory or a heirarchy of directories.

    A rough equivalent to `rm -rf`.
  
   */
  return walkPath(filepath, root, callback_rmdir);
}
Esempio n. 5
0
boolean SDClass::mkdir(char *filepath) {
  /*
  
    Makes a single directory or a heirarchy of directories.

    A rough equivalent to `mkdir -p`.
  
   */
  return walkPath(filepath, root, callback_makeDirPath);
}
Esempio n. 6
0
boolean MemoryCardDevice::open(char *filepath,
			       boolean write, boolean append) {
  /*
   */

  // TODO: Allow for read&write? (Possibly not as it requires seek.)

  uint8_t oflag = O_RDONLY;

  if (write) {
    oflag = O_CREAT | O_WRITE;
    if (append) {
      oflag |= O_APPEND;
    } else {
      oflag |= O_TRUNC;
    }
  }
  
  fileOpenMode = oflag;
  walkPath(filepath, root, callback_openPath, this);
}
Esempio n. 7
0
boolean SDClass::remove(char *filepath) {
  return walkPath(filepath, root, callback_remove);
}
Esempio n. 8
0
	GLvoid CImp::update(GLfloat deltaTime)
	{
		if (m_impState == IS_IDLE)
		{
			Idle(deltaTime);
			//check for next space digging
			//check for next space claiming
			//check for next space walling

			//check for digging
			//check for claiming
			//check for walling

			checkNearestForDigging();
			checkNearestForClaiming();
			checkNearestForWalling();

			checkForDigging();
			checkForClaiming();
			checkForWalling();
		} else if (m_impState == IS_GOING_TO_DEPOSITING_GOLD_DESTINATION)
		{
			useAction(AA_WALK);
			walkPath(deltaTime);		
		} else if (m_impState == IS_GOING_TO_DIGGING_DESTINATION)
		{
			useAction(AA_WALK);
			walkPath(deltaTime);
		} else if (m_impState == IS_GOING_TO_CLAIMING_DESTINATION)
		{
			useAction(AA_WALK);
			walkPath(deltaTime);
		} else if (m_impState == IS_GOING_TO_WALLING_DESTINATION)
		{
			useAction(AA_WALK);
			walkPath(deltaTime);
		} else if (m_impState == IS_AT_DEPOSITING_GOLD)
		{
			m_impState = IS_DEPOSITING_GOLD;
		} else if (m_impState == IS_AT_DIGGING_BLOCK)
		{
			faceBlock(mCurrentBlock);
			m_impState = IS_DIGGING;
			useAction(AA_DIG);
		} else if (m_impState == IS_AT_CLAIMING_BLOCK)
		{
			m_impState = IS_CLAIMING;
			useAction(AA_CLAIM);
		} else if (m_impState == IS_AT_WALLING_BLOCK)
		{
			faceBlock(mCurrentBlock);
			m_impState = IS_WALLING;
			useAction(AA_CLAIM);
		} else if (m_impState == IS_DEPOSITING_GOLD)
		{
			//Todo: if a block has a 250 gold, upp it to 500...
			bool found = false;
			for (std::vector<block_objects::CBlockObject*>::iterator rmIter = mCurrentBlock->getBlockObjects()->begin(); rmIter != mCurrentBlock->getBlockObjects()->end(); rmIter++)
			{
				block_objects::CBlockObject *bObject = *rmIter;

				if (bObject->getName() == "MODEL_GOLD250")
					found = true;

			}
			if(!found)
			{
				mCurrentBlock->addModel("MODEL_GOLD250",mPosition);
				PLAYER0_MONEY = PLAYER0_MONEY + this->getGold();//do for other teams
				this->setGold(0);	
				m_impState = IS_IDLE;
				useAction(AA_IDLE);
			}
			else
			{
				checkGoldLevels();
			}
		} else if (m_impState == IS_DIGGING)
		{
			if(mCurrentBlock->isLow() || !mCurrentBlock->isMarked())
			{
				m_impState = IS_IDLE;
				useAction(AA_IDLE);
				return;
			}
			if(mCurrentBlock->getType() == CV_BLOCK_TYPE_GOLD_ID)
				//TODO: use a new formula
				this->setGold(this->getGold() + 1);
			mCurrentBlock->decLife(deltaTime*m_MoveSpeed);
			if (mCurrentBlock->getLife()<=0.0f)
			{
				mCurrentBlock->digBlock();

				m_impState = IS_IDLE;
				useAction(AA_IDLE);
			}
			//Check if you have gold :)
			checkGoldLevels();
		} else if (m_impState == IS_CLAIMING)
		{
			mCurrentBlock->decLife(deltaTime*m_MoveSpeed);
			if (mCurrentBlock->getLife()<=0.0f)
			{
				mCurrentBlock->claimBlock(this->getOwner());
				m_impState = IS_IDLE;
				useAction(AA_IDLE);
			}
		} else if (m_impState == IS_WALLING)
		{
			if(mCurrentBlock->isLow() || mCurrentBlock->isMarked())
			{
				m_impState = IS_IDLE;
				useAction(AA_IDLE);
				return;
			}
			mCurrentBlock->addLife(deltaTime*m_MoveSpeed);
			if (mCurrentBlock->getLife()>=9.0f)
			{
				mCurrentBlock->fortifyBlock(this->getOwner());

				m_impState = IS_IDLE;
				useAction(AA_IDLE);
			}
		}
	}
Esempio n. 9
0
boolean MemoryCardDevice::exists(char *filepath, SdFile& parentDir) {
  /*
   */
  return walkPath(filepath, parentDir, callback_pathExists);
}