bool CvTacticalAnalysisCell::CanUseForOperationGatheringCheckWater(bool bWater)
{
	if(bWater != IsWater())
	{
		return false;
	}
	return CanUseForOperationGathering();
}
Ejemplo n.º 2
0
/**
 * Clean up unnecessary RoadBits of a planed tile.
 * @param tile current tile
 * @param org_rb planed RoadBits
 * @return optimised RoadBits
 */
RoadBits CleanUpRoadBits(const TileIndex tile, RoadBits org_rb)
{
	if (!IsValidTile(tile)) return ROAD_NONE;
	for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
		const TileIndex neighbor_tile = TileAddByDiagDir(tile, dir);

		/* Get the Roadbit pointing to the neighbor_tile */
		const RoadBits target_rb = DiagDirToRoadBits(dir);

		/* If the roadbit is in the current plan */
		if (org_rb & target_rb) {
			bool connective = false;
			const RoadBits mirrored_rb = MirrorRoadBits(target_rb);

			if (IsValidTile(neighbor_tile)) {
				switch (GetTileType(neighbor_tile)) {
					/* Always connective ones */
					case MP_CLEAR: case MP_TREES:
						connective = true;
						break;

					/* The conditionally connective ones */
					case MP_TUNNELBRIDGE:
					case MP_STATION:
					case MP_ROAD:
						if (IsNormalRoadTile(neighbor_tile)) {
							/* Always connective */
							connective = true;
						} else {
							const RoadBits neighbor_rb = GetAnyRoadBits(neighbor_tile, ROADTYPE_ROAD) | GetAnyRoadBits(neighbor_tile, ROADTYPE_TRAM);

							/* Accept only connective tiles */
							connective = (neighbor_rb & mirrored_rb) != ROAD_NONE;
						}
						break;

					case MP_RAILWAY:
						connective = IsPossibleCrossing(neighbor_tile, DiagDirToAxis(dir));
						break;

					case MP_WATER:
						/* Check for real water tile */
						connective = !IsWater(neighbor_tile);
						break;

					/* The definitely not connective ones */
					default: break;
				}
			}

			/* If the neighbor tile is inconnective, remove the planed road connection to it */
			if (!connective) org_rb ^= target_rb;
		}
	}

	return org_rb;
}
bool CvTacticalAnalysisCell::CanUseForOperationGatheringCheckWater(bool bWater)
{
	if(bWater != IsWater() || IsImpassableTerrain() || IsImpassableTerritory() || GetEnemyMilitaryUnit() || GetNeutralMilitaryUnit() || GetNeutralCivilianUnit() || IsFriendlyTurnEndTile() || IsEnemyCity() || IsNeutralCity())
	{
		return false;
	}

	return true;
}
Ejemplo n.º 4
0
bool cFinishGenSprinkleFoliage::TryAddSugarcane(cChunkDesc & a_ChunkDesc, int a_RelX, int a_RelY, int a_RelZ)
{
	// We'll be doing comparison to neighbors, so require the coords to be 1 block away from the chunk edges:
	if (
		(a_RelX < 1) || (a_RelX >= cChunkDef::Width  - 1) ||
		(a_RelY < 1) || (a_RelY >= cChunkDef::Height - 2) ||
		(a_RelZ < 1) || (a_RelZ >= cChunkDef::Width  - 1)
	)
	{
		return false;
	}

	// Only allow dirt, grass or sand below sugarcane:
	switch (a_ChunkDesc.GetBlockType(a_RelX, a_RelY, a_RelZ))
	{
		case E_BLOCK_DIRT:
		case E_BLOCK_GRASS:
		case E_BLOCK_SAND:
		{
			break;
		}
		default:
		{
			return false;
		}
	}

	// Water is required next to the block below the sugarcane:
	if (
		!IsWater(a_ChunkDesc.GetBlockType(a_RelX - 1, a_RelY, a_RelZ)) &&
		!IsWater(a_ChunkDesc.GetBlockType(a_RelX + 1, a_RelY, a_RelZ)) &&
		!IsWater(a_ChunkDesc.GetBlockType(a_RelX,     a_RelY, a_RelZ - 1)) &&
		!IsWater(a_ChunkDesc.GetBlockType(a_RelX,     a_RelY, a_RelZ + 1))
	)
	{
		return false;
	}

	// All conditions met, place a sugarcane here:
	a_ChunkDesc.SetBlockType(a_RelX, a_RelY + 1, a_RelZ, E_BLOCK_SUGARCANE);
	return true;
}
Ejemplo n.º 5
0
bool TerrainData::IsUseable(TerrainType t)
{
    if(IsLava(t) || IsWater(t))
        return false;
    switch (t)
    {
    case TT_SNOW:
    case TT_SWAMPLAND:
        return false;
    default:
        return true;
    }
}
Ejemplo n.º 6
0
void World::ResetCanalsTunnels()
{
    while (g_tunnel_list)
    {
        Old_Cont_Node * oldFirst    = g_tunnel_list;
        g_tunnel_list               = g_tunnel_list->m_next;
        delete oldFirst;
    }

    MapPoint pos;

    for (pos.x=0; pos.x<m_size.x; pos.x++) {
       for (pos.y=0; pos.y<m_size.y; pos.y++) {

           Cell * c = GetCell(pos);
           uint32 e = c->GetEnv();

           if ((e & k_BIT_MOVEMENT_TYPE_WATER) || (e & k_BIT_MOVEMENT_TYPE_SHALLOW_WATER))
           {
               if (e & k_MASK_ENV_CANAL_TUNNEL)
               {

                   sint32  old_cont_val = c->GetContinent();
                   if ((0 <= old_cont_val) && IsWater(pos))
                   {
                       g_tunnel_list = new Old_Cont_Node(pos, g_tunnel_list, old_cont_val);
                   }

                   c->SetContinent(INVALID_CONTINENT);
               }
           }
           else if ((e & k_BIT_MOVEMENT_TYPE_LAND) || (e & k_BIT_MOVEMENT_TYPE_MOUNTAIN))
           {
               c->SetContinent(INVALID_CONTINENT);
           }
       }
    }
}
Ejemplo n.º 7
0
void World::GetContinent(const MapPoint &pos, sint16 &cont_number, bool &is_land) const
{
	// E note: I got this error when I made Muntains air only.
	// So this method only checks land and water
	static bool REPORTED_MAP_CONTINENT_NUMBERING_INCORRECT  = false; // Made static so it shows only once
	is_land = !IsWater(pos);

	cont_number = GetCell(pos)->m_continent_number;
	if (is_land)
	{
		cont_number -= LAND_CONTINENT_START;
	}

	if (    (cont_number < 0)
	     || (!is_land && cont_number >= LAND_CONTINENT_START)
	   )
	{
		Assert(REPORTED_MAP_CONTINENT_NUMBERING_INCORRECT);
		REPORTED_MAP_CONTINENT_NUMBERING_INCORRECT = true;
		is_land = false;
		cont_number = 0;
	}
}
Ejemplo n.º 8
0
bool TerrainData::IsAnimated(TerrainType t)
{
    return IsWater(t) || IsLava(t);
}
Ejemplo n.º 9
0
void BLMap::Step(int step)
{
    m_oTypeMapTmp = m_oTypeMap;

    uint w = m_oTypeMapTmp.GetWidth();
    uint h = m_oTypeMapTmp.GetHeight();

    for (uint i=0 ; i<w ; ++i)
    {
        for (uint j=0 ; j<h ; ++j)
        {
            BLZone zone;
            CaseType type = m_oTypeMapTmp.GetCase(i, j);
            for (int k=(int)i-1 ; k<=(int)i+1 ; ++k)
            {
                for (int l=(int)j-1 ; l<=(int)j+1 ; ++l)
                {
                    if (k>=0 && k<(int)w && l>=0 && l<(int)h)
                    {
                        zone.AddType(m_oTypeMapTmp.GetCase(k, l));
                    }
                }
            }

            if (step == 0)
            {
                if (i<2 || j<2 || i>=w-2 || j>=h-2)
                    //if (zone.GetMax() < 9)
                {
                    m_oTypeMap.GetCase(i, j) = LightWater;// (zone.IsWater() ? DarkWater : LightWater);
                }
            }
            else if (step < 5)
            {
                if (zone.GetWaterCount() > Rand(3,5))
                {
                    m_oTypeMap.GetCase(i, j) = LightWater;
                }
                else if (IsWater(type) && zone.GetLandCount() > Rand(3,5))
                {
                    m_oTypeMap.GetCase(i, j) = LightDirt;
                }
                else if (IsLand(type) && zone.GetCount(Tree) > Rand(3,4))
                {
                    m_oTypeMap.GetCase(i, j) = Tree;
                }
                else
                {
                    if (zone.GetCount(type) == 1)
                        m_oTypeMap.GetCase(i, j) = zone.GetMajorType();
                }
            }
            else if (step < 8)
            {
                if (IsLand(type) && zone.GetWaterCount() > 0)
                {
                    m_oTypeMap.GetCase(i, j) = LightDirt;
                }
                else if (IsLand(type) && type != Stone && zone.GetCount(Stone) > 0)
                {
                    m_oTypeMap.GetCase(i, j) = LightDirt;
                }
                else if (zone.IsDirt())
                {
                    m_oTypeMap.GetCase(i, j) = (Rand(2) == 0 ? LightDirt : Stone);
                }
                else if (IsDirt(type) && zone.GetWaterCount() == 0)
                {
                    m_oTypeMap.GetCase(i, j) = LightGrass;
                }
                else if (type == Tree && zone.GetDirtCount() > 0)
                {
                    m_oTypeMap.GetCase(i, j) = LightGrass;
                }
            }
            else if (step < 12)
            {
                if (IsGrass(type) && zone.GetDirtCount() >= 3 && zone.GetCount(Tree) == 0 && Rand(2) == 0)
                {
                    m_oTypeMap.GetCase(i, j) = LightDirt;
                }
            }
            else if (step < 17)
            {
                if (zone.IsWater() && Rand(2) == 0)
                {
                    m_oTypeMap.GetCase(i, j) = DarkWater;
                }
                else if (zone.IsGrass() && Rand(2) == 0)
                {
                    m_oTypeMap.GetCase(i, j) = DarkGrass;
                }
                else if (zone.IsDirt() && Rand(2) == 0)
                {
                    m_oTypeMap.GetCase(i, j) = DarkDirt;
                }
                //else
                //{
                //	if (zone.GetCount(type) == 1)
                //		m_oMap.GetCase(i, j) = zone.GetMajorType();
                //}
            }
        }
    }
}
Ejemplo n.º 10
0
	bool command::IsUserWater(){
		return (IsWater(ArrayOfCommand[1])&& IsMark(ArrayOfCommand[2])  && JumlahString == 1);
	}