Example #1
0
/*!
\b Parameters:

\arg \b pVertexX, pVertexY		One vertex of the grid

\b Operation:

This method returns the vertical position of the vertex passed as parameter.

Remember that there is always one vertex more (horizontal or vertical) than number of blocks.
For example, a grid of 2x2 blocks would have 3x3 vertices.
*/
int IND_Surface::GetVertexPosY	(int pVertexX, int pVertexY)
{
	if (!IsHaveGrid	()) return 0;

	// ----- Corners -----

	if (pVertexX == 0 && pVertexY == 0)
		return (int) mSurface.mVertexArray [((GetNumBlocks() - GetBlocksX()) * 4) + 2].mY;
	
	if (pVertexX == GetBlocksX() && pVertexY == GetBlocksY())
		return (int) mSurface.mVertexArray [((GetBlocksX() - 1) * 4) + 1].mY;

	if (pVertexX == GetBlocksX() && pVertexY == 0)
		return (int) mSurface.mVertexArray [(GetNumBlocks() - 1) * 4].mY;

	if (pVertexX == 0 && pVertexY == GetBlocksY())
		return (int) mSurface.mVertexArray [3].mY;

	// ----- Borders -----

	if (pVertexX == 0)
		return (int) mSurface.mVertexArray [(abs (GetBlocksY() - pVertexY - 1) * GetBlocksX() * 4) + 2].mY;

	if (pVertexX == GetBlocksX())
		return (int) mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY) * GetBlocksX()) + GetBlocksX() - 1) * 4) + 1].mY;

	if (pVertexY == GetBlocksY())
		return (int) mSurface.mVertexArray [((pVertexX) * 4) + 3].mY;

	if (pVertexY == 0)
		return (int) mSurface.mVertexArray [((GetNumBlocks() - GetBlocksX() + pVertexX - 1) * 4)].mY;

	// ----- Inside (we must move 4 vertices) -----

	if (pVertexX > 0 && pVertexX < GetBlocksX() && pVertexY > 0 && pVertexY < GetBlocksY())
		return (int) mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY - 1) * GetBlocksX()) + pVertexX - 1) * 4)].mY;

	return 0;
}
Example #2
0
u32 BlockDevice::CalculateCRC() {
	u32 crc = crc32(0, Z_NULL, 0);

	u8 block[2048];
	for (u32 i = 0; i < GetNumBlocks(); ++i) {
		if (!ReadBlock(i, block, true)) {
			ERROR_LOG(HLE, "Failed to read block for CRC");
			return 0;
		}
		crc = crc32(crc, block, 2048);
	}

	return crc;
}
Example #3
0
void CodeTorrent::PrintFileInfo() {

	HAGGLE_DBG(" ========= File Info =========\n");
	if (identity == CT_SERVER)
		HAGGLE_DBG(" SERVER\n");
	else
		HAGGLE_DBG(" CLIENT\n");
	HAGGLE_DBG(" File name: %s\n", GetFileName());
	HAGGLE_DBG(" File Size: %d\n", GetFileSize());
	HAGGLE_DBG(" Number Generations: %d\n", GetNumGens());
	HAGGLE_DBG(" Block Size: %d\n", GetBlockSize());
	HAGGLE_DBG(" Num Blocks: %d\n", GetNumBlocks());
	//HAGGLE_DBG(" Num Blocks per Gen: %d\n", GetNumBlocksGen());
	HAGGLE_DBG(" Field Size: %d bits\n", GetFieldSize());
	HAGGLE_DBG(" ============================\n");
}
Example #4
0
/*!
\b Parameters:

\arg \b pVertexX, pVertexY		The vertex we want to move
\arg \b pX, pY					The new position for the vertex

\b Operation:

This method changes the position of one of the vertices of the grid. The vertices starts
from 0 to n, from left to right and from up to down. So: (0,0) is the upper-left vertex
of the grid and (n, n) is the lower-right vertex of the grid.

Remember that there is always one vertex more (horizontal or vertical) that number of blocks.
For example, a grid of 2x2 blocks would have 3x3 vertices.
*/
bool IND_Surface::SetVertexPos (int pVertexX, int pVertexY, int pX, int pY)
{
	if (!IsHaveGrid	()) return 0;

	// ----- Corners (we must move 1 vertex) -----

	if (pVertexX == 0 && pVertexY == 0)
	{
		mSurface.mVertexArray [((GetNumBlocks() - GetBlocksX()) * 4) + 2].mX = (float) pX;
		mSurface.mVertexArray [((GetNumBlocks() - GetBlocksX()) * 4) + 2].mY = (float) pY;
		return 1;
	}
	
	if (pVertexX == GetBlocksX() && pVertexY == GetBlocksY())
	{
		mSurface.mVertexArray [((GetBlocksX() - 1) * 4) + 1].mX = (float) pX;
		mSurface.mVertexArray [((GetBlocksX() - 1) * 4) + 1].mY = (float) pY;
		return 1;
	}

	if (pVertexX == GetBlocksX() && pVertexY == 0)
	{
		mSurface.mVertexArray [(GetNumBlocks() - 1) * 4].mX = (float) pX;
		mSurface.mVertexArray [(GetNumBlocks() - 1) * 4].mY = (float) pY;
		return 1;
	}

	if (pVertexX == 0 && pVertexY == GetBlocksY())
	{
		mSurface.mVertexArray [3].mX = (float) pX;
		mSurface.mVertexArray [3].mY = (float) pY;
		return 1;
	}

	// ----- Borders (we must move 2 vertices) -----

	if (pVertexX == 0)
	{
		mSurface.mVertexArray [(abs (GetBlocksY() - pVertexY - 1) * GetBlocksX() * 4) + 2].mX = (float) pX;
		mSurface.mVertexArray [(abs (GetBlocksY() - pVertexY - 1) * GetBlocksX() * 4) + 2].mY = (float) pY;
		mSurface.mVertexArray [(abs (GetBlocksY() - pVertexY) * GetBlocksX() * 4) + 3].mX = (float) pX;
		mSurface.mVertexArray [(abs (GetBlocksY() - pVertexY) * GetBlocksX() * 4) + 3].mY = (float) pY;
		return 1;
	}

	if (pVertexX == GetBlocksX())
	{
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY - 1) * GetBlocksX()) + GetBlocksX() - 1) * 4)].mX = (float) pX;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY - 1) * GetBlocksX()) + GetBlocksX() - 1) * 4)].mY = (float) pY;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY) * GetBlocksX()) + GetBlocksX() - 1) * 4) + 1].mX = (float) pX;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY) * GetBlocksX()) + GetBlocksX() - 1) * 4) + 1].mY = (float) pY;
		return 1;
	}

	if (pVertexY == GetBlocksY())
	{
		mSurface.mVertexArray [((pVertexX - 1) * 4) + 1].mX = (float) pX;
		mSurface.mVertexArray [((pVertexX - 1)* 4) + 1].mY = (float) pY;
		mSurface.mVertexArray [((pVertexX) * 4) + 3].mX = (float) pX;
		mSurface.mVertexArray [((pVertexX) * 4) + 3].mY = (float) pY;
		return 1;
	}

	if (pVertexY == 0)
	{
		mSurface.mVertexArray [((GetNumBlocks() - GetBlocksX() + pVertexX - 1) * 4)].mX = (float) pX;
		mSurface.mVertexArray [((GetNumBlocks() - GetBlocksX() + pVertexX - 1) * 4)].mY = (float) pY;
		mSurface.mVertexArray [((GetNumBlocks() - GetBlocksX() + pVertexX) * 4) + 2].mX = (float) pX;
		mSurface.mVertexArray [((GetNumBlocks() - GetBlocksX() + pVertexX) * 4) + 2].mY = (float) pY;
		return 1;
	}

	// ----- Inside (we must move 4 vertices) -----

	if (pVertexX > 0 && pVertexX < GetBlocksX() && pVertexY > 0 && pVertexY < GetBlocksY())
	{
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY - 1) * GetBlocksX()) + pVertexX - 1) * 4)].mX = (float) pX;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY - 1) * GetBlocksX()) + pVertexX - 1) * 4)].mY = (float) pY;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY - 1) * GetBlocksX()) + pVertexX) * 4) + 2].mX = (float) pX;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY - 1) * GetBlocksX()) + pVertexX) * 4) + 2].mY = (float) pY;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY) * GetBlocksX()) + pVertexX - 1) * 4) + 1].mX = (float) pX;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY) * GetBlocksX()) + pVertexX - 1) * 4) + 1].mY = (float) pY;	
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY) * GetBlocksX()) + pVertexX) * 4) + 3].mX = (float) pX;
		mSurface.mVertexArray [(((abs (GetBlocksY() - pVertexY) * GetBlocksX()) + pVertexX) * 4) + 3].mY = (float) pY;	
		return 1;
	}

	return 0;
}