#include "stdafx.h"
#include "War3TypesAndConstants.h"
#include "TilePoint.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTilePoint::CTilePoint()
{
	height = TILE_HEIGHT_LEVEL_ZERO;
	waterlevel = TILE_HEIGHT_LEVEL_ZERO;
	flags = 0;
	groundtype = 0;
	details = 0;
	clifftype = 0;
	layer = TILE_LAYER_LEVEL_ZERO;
	selected = false;
	viewcolor.rgbReserved = 0;
	viewcolor.rgbRed = 0;
	viewcolor.rgbGreen = 0;
	viewcolor.rgbBlue = 0;
}

CTilePoint::~CTilePoint()
{

}

BOOL CTilePoint::IsUnderWater()
{
	BOOL bval = false;
	if ((GetGroundLevel() < GetWaterLevel()) && (flags & TILE_FL_WATER))
	{
		bval = true;
	}
	return bval;
}

int CTilePoint::GetGroundLevel()
{
	int ival;
	ival = ((layer - TILE_LAYER_LEVEL_ZERO)*TILE_LAYER_HEIGHT + (height - TILE_HEIGHT_LEVEL_ZERO));
	return ival;
}

int CTilePoint::GetWaterLevel()
{
	return waterlevel - TILE_WATER_OFFSET;
}

BOOL CTilePoint::IsBlight()
{
	BOOL bval = false;
	if (flags & TILE_FL_BLIGHT)
	{
		bval = true;
	}
	return bval;
}
