Example #1
0
MDFlib::MDFTX::MDFTX(QFile* file, long pTX, unsigned short byteOrder)
{
    myMDFFile = file;
    QByteArray byteArray;
    QDataStream instream(myMDFFile);

    QString blockType;
    unsigned short blockSize;
    QString text;

    if(byteOrder == 0)
    {
        instream.setByteOrder(QDataStream::LittleEndian);
    }
    else
    {
        instream.setByteOrder(QDataStream::BigEndian);
    }
    myMDFFile->seek(pTX);

    byteArray = myMDFFile->read(2);
    blockType.append(byteArray.data());

    myMDFFile->seek(pTX + 2);
    instream >> blockSize;

    myMDFFile->seek(pTX + 4);
    byteArray = myMDFFile->read(blockSize);
    text.append(byteArray.data());

    setBlockType(&blockType);
    setBlockSize(blockSize);
    setText(&text);
}
Example #2
0
void WorldMap::fillVolume(v3di_t a, v3di_t b, int blockType) {
  if (a.x > b.x) {
    int temp = a.x;
    a.x = b.x;
    b.x = temp;
  }
  if (a.y > b.y) {
    int temp = a.y;
    a.y = b.y;
    b.y = temp;
  }
  if (a.z > b.z) {
    int temp = a.z;
    a.z = b.z;
    b.z = temp;
  }

  v3di_t pos;
  for (pos.z = a.z; pos.z <= b.z; pos.z++) {
    for (pos.y = a.y; pos.y <= b.y; pos.y++) {
      for (pos.x = a.x; pos.x <= b.x; pos.x++) {
        // clear first to ensure we have all the neighbors
        if (gBlockData.get(blockType)->solidityType != BLOCK_SOLIDITY_TYPE_ROCK || gBlockData.get(blockType)->alpha < 1.0) {
          clearBlock(pos);
        }
        setBlockType(pos, blockType);
      }
    }
  }
}
Example #3
0
int addToGrid(MazeMap maze, int *row, int *col, char value, char wallCharacter)	{
	if (value != '\n')	{
		if(*col == maze->width )	{
			*row = *row +1;
			*col = 0;
		}
		maze->mazeGrid[(*row)][(*col)].block = value;
		
		if(maze->mazeGrid[(*row)][(*col)].block == wallCharacter)	{
			setBlockType(maze, *row, *col, WALL);
		} else {
			setBlockType(maze, *row, *col, MISC);	
		}
		*col = *col + 1;	
	}
	return value;
}
Example #4
0
Character::Character(MessageIn &msg):
    Being(OBJECT_CHARACTER),
    mClient(NULL),
    mConnected(true),
    mTransactionHandler(NULL),
    mSpecialUpdateNeeded(false),
    mDatabaseID(-1),
    mHairStyle(0),
    mHairColor(0),
    mLevel(1),
    mLevelProgress(0),
    mUpdateLevelProgress(false),
    mRecalculateLevel(true),
    mParty(0),
    mTransaction(TRANS_NONE),
    mTalkNpcId(0),
    mNpcThread(0),
    mKnuckleAttackInfo(0)
{
    const AttributeManager::AttributeScope &attr =
                           attributeManager->getAttributeScope(CharacterScope);
    LOG_DEBUG("Character creation: initialisation of "
              << attr.size() << " attributes.");
    for (AttributeManager::AttributeScope::const_iterator it1 = attr.begin(),
         it1_end = attr.end(); it1 != it1_end; ++it1)
        mAttributes.insert(std::make_pair(it1->first, Attribute(*it1->second)));

    setWalkMask(Map::BLOCKMASK_WALL);
    setBlockType(BLOCKTYPE_CHARACTER);

    // Get character data.
    mDatabaseID = msg.readInt32();
    setName(msg.readString());
    deserializeCharacterData(*this, msg);
    mOld = getPosition();
    Inventory(this).initialize();
    modifiedAllAttribute();
    setSize(16);

    // Default knuckle attack
    int damageBase = this->getModifiedAttribute(ATTR_STR);
    int damageDelta = damageBase / 2;
    Damage knuckleDamage;
    knuckleDamage.skill = skillManager->getDefaultSkillId();
    knuckleDamage.base = damageBase;
    knuckleDamage.delta = damageDelta;
    knuckleDamage.cth = 2;
    knuckleDamage.element = ELEMENT_NEUTRAL;
    knuckleDamage.type = DAMAGE_PHYSICAL;
    knuckleDamage.range = DEFAULT_TILE_LENGTH;

    mKnuckleAttackInfo = new AttackInfo(0, knuckleDamage, 7, 3, 0);
    addAttack(mKnuckleAttackInfo);
}
Example #5
0
bool WorldMap::updateFluid( int columnIndex ) {
  // need four neighbors?

  bool changesMade = false;

  v3di_t worldPosition;

  int highestBlockHeight = mColumns[columnIndex].getHighestBlockHeight ();
  int lowestBlockHeight = mColumns[columnIndex].getLowestBlockHeight ();

  char blockType;

  for (worldPosition.y = highestBlockHeight; worldPosition.y >= lowestBlockHeight; worldPosition.y--) {
    for (int z = 0; z < WORLD_CHUNK_SIDE; z++) {
      worldPosition.z = mColumns[columnIndex].mWorldPosition.z + z;

      for (int x = 0; x < WORLD_CHUNK_SIDE; x++) {
        worldPosition.x = mColumns[columnIndex].mWorldPosition.x + x;

        blockType = getBlockType (worldPosition);

        if (gBlockData.get(blockType)->solidityType == BLOCK_SOLIDITY_TYPE_LIQUID) {
          changesMade |= updateLiquidBlock (blockType, columnIndex, worldPosition);
        }
      }
    }
  }

  if (changesMade) {
    // clean up the placeholders
    for (worldPosition.y = lowestBlockHeight; worldPosition.y <= highestBlockHeight; worldPosition.y++) {
      for (int z = -1; z <= WORLD_CHUNK_SIDE; z++) {
        worldPosition.z = mColumns[columnIndex].mWorldPosition.z + z;

        for (int x = -1; x <= WORLD_CHUNK_SIDE; x++) {
          worldPosition.x = mColumns[columnIndex].mWorldPosition.x + x;

          blockType = getBlockType (worldPosition);

          if (blockType >= BLOCK_TYPE_PLACEHOLDER) {
            setBlockType (worldPosition, blockType - BLOCK_TYPE_PLACEHOLDER);
          }
        }
      }
    }
  }

  return changesMade;
}
Example #6
0
int findEntrance(MazeMap maze,int *eRow, int *eCol)	{

	int side,top;
	BOOL entranceFound;
	for(side = 0,entranceFound=FALSE; side < maze->height && entranceFound == FALSE; side++)	{
		if((getBlock(maze,side,LEFTSIDE)) == ' ') {
			entranceFound = TRUE;
		}
	}

	for(top = 0; top < maze->width; top++)	{
		if((getBlock(maze,TOPSIDE,side)) == ' ')	{
		//determines if opening on top is closer than opening on side to left hand corner
			if(--side >= top)	{ 
				*eRow = TOPSIDE;
				*eCol = top;
				return(setBlockType(maze,TOPSIDE,top,ENTRANCE));
			}
		}
	}
		*eRow = --side;
		*eCol = LEFTSIDE;
		return(setBlockType(maze,side,LEFTSIDE,ENTRANCE));
}
Example #7
0
bool WorldMap::updateLiquidBlock( int blockType, int columnIndex, const v3di_t& worldPosition ) {
  char neighborType;

  char air = BLOCK_TYPE_AIR;
  char liquid = blockType + BLOCK_TYPE_PLACEHOLDER;

  // check relevant neigh-bros
  v3di_t neighborPosition;

  // down first
  neighborPosition = v3di_add (worldPosition, v3di_v (0, -1, 0));
  neighborType = getBlockType (neighborPosition);
  if (neighborType == BLOCK_TYPE_AIR ||
    neighborType == BLOCK_TYPE_INVALID) {
    setBlockType (worldPosition, air);
    setBlockType (neighborPosition, liquid);

    // all done for this time slice
    return true;
  }

  bool changesMade = false;

  int numWaterNeighbors = countLiquidNeighbors( blockType, worldPosition );

  if (numWaterNeighbors < 2) {
    setBlockType (worldPosition, air);

    // all done for this time slice
    return true;
  }
  else {
    // -x
    neighborPosition = v3di_add (worldPosition, v3di_v (-1, 0, 0));
    neighborType = getBlockType (neighborPosition);
    if (neighborType == BLOCK_TYPE_AIR) {
      setBlockType (neighborPosition, liquid);
      changesMade = true;
    }

    // +x
    neighborPosition = v3di_add (worldPosition, v3di_v (+1, 0, 0));
    neighborType = getBlockType (neighborPosition);
    if (neighborType == BLOCK_TYPE_AIR) {
      setBlockType (neighborPosition, liquid);
      changesMade = true;
    }

    // -z
    neighborPosition = v3di_add (worldPosition, v3di_v (0, 0, -1));
    neighborType = getBlockType (neighborPosition);
    if (neighborType == BLOCK_TYPE_AIR) {
      setBlockType (neighborPosition, liquid);
      changesMade = true;
    }

    // +z
    neighborPosition = v3di_add (worldPosition, v3di_v (0, 0, +1));
    neighborType = getBlockType (neighborPosition);
    if (neighborType == BLOCK_TYPE_AIR) {
      setBlockType (neighborPosition, liquid);
      changesMade = true;
    }
  }

  return changesMade;
}