Changeset - r14161:b62f02f583d3
[Not reviewed]
master
0 10 0
yexo - 15 years ago 2010-01-04 18:33:43
yexo@openttd.org
(svn r18719) -Feature: don't delete the rough/rocky status of a tile when it's covered by snow, this allows rocky tiles under snow if you have a variable snowline
10 files changed with 147 insertions and 38 deletions:
0 comments (0 inline, 0 general)
docs/landscape.html
Show inline comments
 
@@ -8,18 +8,19 @@
 
 <title>OpenTTD Landscape Internals</title>
 
</head>
 

	
 
<body>
 

	
 
 <h3><a name="Landscape">Landscape</a></h3>
 
 <p>Seven attributes (counting &quot;<span style="font-weight: bold;">type_height</span>&quot;) hold the informations about a tile.<BR>
 
 <p>Eight attributes (counting &quot;<span style="font-weight: bold;">type_height</span>&quot;) hold the informations about a tile.<BR>
 
  These attributes are referred to as
 
  "<span style="font-weight: bold;">type_height</span>",
 
  "<span style="font-weight: bold;">m1</span>", "<span style="font-weight: bold;">m2</span>",
 
  "<span style="font-weight: bold;">m3</span>", "<span style="font-weight: bold;">m4</span>",
 
  "<span style="font-weight: bold;">m5</span>" and "<span style="font-weight: bold;">m6</span>".<BR>
 
  "<span style="font-weight: bold;">m5</span>", "<span style="font-weight: bold;">m6</span>"
 
  and "<span style="font-weight: bold;">m7</span>".<BR>
 
  The most important value is the class of a tile, stored in the upper 4 bits
 
  of the <span style="font-weight: bold;">type_height</span> attribute. The lower 4 bits are used to encode the height and
 
  slope data.
 
 </p>
 

	
 
 Special Attribute : <span style="font-weight: bold;">m6</span>. There are 4 bits of it that are used accross multiple tile classes<br>
 
@@ -77,12 +78,13 @@
 
   <td valign=top nowrap>&nbsp;</td>
 
   <td>
 
    <ul>
 
     <li>m1: <a href="#OwnershipInfo">owner</a> of the tile (normally <tt>10</tt>)</li>
 
     <li>m2: see fields</li>
 
     <li>m3 bits 3..0: see fields</li>
 
     <li>m3 bit 4: set if the tile is covered with snow</li>
 
     <li>m4 bits 7..5: type of hedge on the SW border of the tile (1 through 6, or 0=none)</li>
 
     <li>m4 bits 4..2: same as 7..5, but for the SE border</li>
 
     <li>m5 bits 7..5: update counter, incremented on every periodic processing for tile types,
 
         other than <tt>03</tt>, <tt>07</tt>, <tt>0B</tt>, <tt>10</tt> and above.<BR>
 
         on wraparound, the tile is updated (for fields, the type of fields in m3 is increased, for other types the tile type in m5 is increased).<BR>
 
         For snow and desert, these bits are not used, tile is updated on every periodic processing.</li>
 
@@ -719,14 +721,13 @@
 
  </tr>
 
  <tr>
 
   <td valign=top nowrap>&nbsp;</td>
 
   <td>
 
    <ul>
 
     <li>m1: <a href="#OwnershipInfo">owner</a> (normally <tt>10</tt>)</li>
 
     <li>m2 bits 7..6: ground density
 
     <li>m2 bits 5..4: ground
 
     <li>m2 bits 8..6: ground
 
      <table>
 

	
 
       <tr>
 
        <td align=left><tt>0</tt>&nbsp; </td>
 
        <td>on grass</td>
 
       </tr>
 
@@ -742,14 +743,20 @@
 
       </tr>
 

	
 
       <tr>
 
        <td align=left><tt>3</tt>&nbsp; </td>
 
        <td>on shore (density must be 3)</td>
 
       </tr>
 

	
 
       <tr>
 
        <td align=left><tt>4</tt>&nbsp; </td>
 
        <td>on snow with rough land underneed</td>
 
       </tr>
 
      </table>
 
     </li>
 
     <li>m2 bits 5..4: ground density</li>
 
     <li>m2 bits 3..0: update counter, incremented on every periodic processing.<br>
 
          on wraparound the growth status is updated (or, if it's <tt>3</tt>, a random action is taken)</li>
 
     <li>m3 bits 7..0: type of trees:
 
      <table>
 
       <tr>
 
        <td nowrap valign=top><tt>00</tt>..<tt>0B</tt>&nbsp; </td>
docs/landscape_grid.html
Show inline comments
 
@@ -65,24 +65,24 @@ the array so you can quickly see what is
 
    <tr>
 
      <td rowspan="2">0</td>
 
      <td class="caption">ground</td>
 
      <td class="bits">XXXX XXXX</td>
 
      <td class="bits"><span class="option">~~~~ ~~~~</span></td>
 
      <td class="bits"><span class="free">OOOO OOOO OOOO OOOO</span></td>
 
      <td class="bits"><span class="free">OOOO OOOO</span></td>
 
      <td class="bits"><span class="free">OOO</span>X <span class="free">OOOO</span></td>
 
      <td class="bits">XXXX XX<span class="free">OO</span></td>
 
      <td class="bits">XXXX XXXX</td>
 
      <td class="bits">XX<span class="free">OO OO</span>XX</td>
 
      <td class="bits"><span class="free">OOOO OOOO</span></td>
 
    </tr>
 
    <tr>
 
      <td class="caption">farmland</td>
 
      <td class="bits">-inherit-</td>
 
      <td class="bits"><span class="option">~~~~ ~~~~</span></td>
 
      <td class="bits">XXXX XXXX XXXX XXXX</td>
 
      <td class="bits"><span class="free">OOOO</span> XXXX</td>
 
      <td class="bits"><span class="free">OOO</span>X XXXX</td>
 
      <td class="bits">-inherit-</td>
 
      <td class="bits">-inherit-</td>
 
      <td class="bits">XX<span class="free">OO OO</span>XX</td>
 
      <td class="bits"><span class="free">OOOO OOOO</span></td>
 
    </tr>
 
    <tr>
 
@@ -167,13 +167,13 @@ the array so you can quickly see what is
 
    </tr>
 
    <tr>
 
      <td>4</td>
 
      <td class="caption">trees</td>
 
      <td class="bits">XXXX XXXX</td>
 
      <td class="bits"><span class="option">~~~~ ~~~~</span></td>
 
      <td class="bits"><span class="free">OOOO OOOO</span> XXXX XXXX</td>
 
      <td class="bits"><span class="free">OOOO OOO</span>X XXXX XXXX</td>
 
      <td class="bits"><span class="option">~~</span>XX XXXX</td>
 
      <td class="bits">XXXX XX<span class="free">OO</span></td>
 
      <td class="bits">XX<span class="free">OO O</span>XXX</td>
 
      <td class="bits"><span class="free">OOOO OO</span>XX</td>
 
      <td class="bits"><span class="free">OOOO OOOO</span></td>
 
    </tr>
src/ai/api/ai_tile.cpp
Show inline comments
 
@@ -109,27 +109,27 @@
 
}
 

	
 
/* static */ bool AITile::IsRockTile(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return false;
 

	
 
	return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_ROCKS));
 
	return (::IsTileType(tile, MP_CLEAR) && ::GetRawClearGround(tile) == ::CLEAR_ROCKS);
 
}
 

	
 
/* static */ bool AITile::IsRoughTile(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return false;
 

	
 
	return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_ROUGH));
 
	return (::IsTileType(tile, MP_CLEAR) && ::GetRawClearGround(tile) == ::CLEAR_ROUGH);
 
}
 

	
 
/* static */ bool AITile::IsSnowTile(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return false;
 

	
 
	return (::IsTileType(tile, MP_CLEAR) && ::IsClearGround(tile, CLEAR_SNOW));
 
	return (::IsTileType(tile, MP_CLEAR) && ::IsSnowTile(tile));
 
}
 

	
 
/* static */ bool AITile::IsDesertTile(TileIndex tile)
 
{
 
	if (!::IsValidTile(tile)) return false;
 

	
src/clear_cmd.cpp
Show inline comments
 
@@ -155,17 +155,17 @@ void TileLoopClearHelper(TileIndex tile)
 
static void TileLoopClearAlps(TileIndex tile)
 
{
 
	int k = GetTileZ(tile) - GetSnowLine() + TILE_HEIGHT;
 

	
 
	if (k < 0) {
 
		/* Below the snow line, do nothing if no snow. */
 
		if (!IsClearGround(tile, CLEAR_SNOW)) return;
 
		if (!IsSnowTile(tile)) return;
 
	} else {
 
		/* At or above the snow line, make snow tile if needed. */
 
		if (!IsClearGround(tile, CLEAR_SNOW)) {
 
			SetClearGroundDensity(tile, CLEAR_SNOW, 0);
 
		if (!IsSnowTile(tile)) {
 
			MakeSnow(tile);
 
			MarkTileDirtyByTile(tile);
 
			return;
 
		}
 
	}
 
	/* Update snow density. */
 
	uint curent_density = GetClearDensity(tile);
 
@@ -174,13 +174,13 @@ static void TileLoopClearAlps(TileIndex 
 
	if (curent_density < req_density) {
 
		AddClearDensity(tile, 1);
 
	} else if (curent_density > req_density) {
 
		AddClearDensity(tile, -1);
 
	} else {
 
		/* Density at the required level. */
 
		if (k < 0) SetClearGroundDensity(tile, CLEAR_GRASS, 3);
 
		if (k < 0) ClearSnow(tile);
 
	}
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
static void TileLoopClearDesert(TileIndex tile)
 
{
src/clear_map.h
Show inline comments
 
@@ -26,21 +26,45 @@ enum ClearGround {
 
	CLEAR_SNOW   = 4, ///< 0-3
 
	CLEAR_DESERT = 5  ///< 1,3
 
};
 

	
 

	
 
/**
 
 * Test if a tile is covered with snow.
 
 * @param t the tile to check
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return whether the tile is covered with snow.
 
 */
 
static inline bool IsSnowTile(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return HasBit(_m[t].m3, 4);
 
}
 

	
 
/**
 
 * Get the type of clear tile but never return CLEAR_SNOW.
 
 * @param t the tile to get the clear ground type of
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the ground type
 
 */
 
static inline ClearGround GetRawClearGround(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return (ClearGround)GB(_m[t].m5, 2, 3);
 
}
 

	
 
/**
 
 * Get the type of clear tile.
 
 * @param t the tile to get the clear ground type of
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the ground type
 
 */
 
static inline ClearGround GetClearGround(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return (ClearGround)GB(_m[t].m5, 2, 3);
 
	if (IsSnowTile(t)) return CLEAR_SNOW;
 
	return GetRawClearGround(t);
 
}
 

	
 
/**
 
 * Set the type of clear tile.
 
 * @param t  the tile to set the clear ground type of
 
 * @param ct the ground type
 
@@ -73,12 +97,24 @@ static inline uint GetClearDensity(TileI
 
static inline void AddClearDensity(TileIndex t, int d)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	_m[t].m5 += d;
 
}
 

	
 
/**
 
 * Set the density of a non-field clear tile.
 
 * @param t the tile to set the density of
 
 * @param d the new density
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void SetClearDensity(TileIndex t, uint d)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	SB(_m[t].m5, 0, 2, d);
 
}
 

	
 

	
 
/**
 
 * Get the counter used to advance to the next clear density/field type.
 
 * @param t the tile to get the counter of
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the value of the counter
 
@@ -266,7 +302,35 @@ static inline void MakeField(TileIndex t
 
	_m[t].m4 = 0 << 5 | 0 << 2;
 
	SetClearGroundDensity(t, CLEAR_FIELDS, 3);
 
	SB(_m[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
}
 

	
 
/**
 
 * Make a snow tile.
 
 * @param t the tile to make snowy
 
 * @pre GetClearGround(t) != CLEAR_SNOW
 
 */
 
static inline void MakeSnow(TileIndex t)
 
{
 
	assert(GetClearGround(t) != CLEAR_SNOW);
 
	SetBit(_m[t].m3, 4);
 
	if (GetClearGround(t) == CLEAR_FIELDS) {
 
		SetClearGroundDensity(t, CLEAR_GRASS, 0);
 
	} else {
 
		SetClearDensity(t, 0);
 
	}
 
}
 

	
 
/**
 
 * Clear the snow from a tile and return it to it's previous type.
 
 * @param t the tile to clear of snow
 
 * @pre GetClearGround(t) == CLEAR_SNOW
 
 */
 
static inline void ClearSnow(TileIndex t)
 
{
 
	assert(GetClearGround(t) == CLEAR_SNOW);
 
	ClrBit(_m[t].m3, 4);
 
	SetClearDensity(t, 3);
 
}
 

	
 
#endif /* CLEAR_MAP_H */
src/saveload/afterload.cpp
Show inline comments
 
@@ -117,13 +117,13 @@ void SetWaterClassDependingOnSurrounding
 
				/* Shore or flooded halftile */
 
				has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER);
 
				break;
 

	
 
			case MP_TREES:
 
				/* trees on shore */
 
				has_water |= (GetTreeGround(neighbour) == TREE_GROUND_SHORE);
 
				has_water |= (GB(_m[neighbour].m2, 4, 2) == TREE_GROUND_SHORE);
 
				break;
 

	
 
			default: break;
 
		}
 
	}
 

	
 
@@ -1434,14 +1434,14 @@ bool AfterLoadGame()
 
	 * grassy trees were always drawn fully grassy. Furthermore, trees on rough
 
	 * land used to have zero density, now they have full density. Therefore,
 
	 * make all grassy/rough land trees have a density of 3. */
 
	if (CheckSavegameVersion(81)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (GetTileType(t) == MP_TREES) {
 
				TreeGround groundType = GetTreeGround(t);
 
				if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3);
 
				TreeGround groundType = (TreeGround)GB(_m[t].m2, 4, 2);
 
				if (groundType != TREE_GROUND_SNOW_DESERT) SB(_m[t].m2, 6, 2, 3);
 
			}
 
		}
 
	}
 

	
 

	
 
	if (CheckSavegameVersion(93)) {
 
@@ -1973,12 +1973,33 @@ bool AfterLoadGame()
 
		Train *t;
 
		FOR_ALL_TRAINS(t) {
 
			t->force_proceed = min<byte>(t->force_proceed, 1);
 
		}
 
	}
 

	
 
	/* The bits for the tree ground and tree density have
 
	 * been swapped (m2 bits 7..6 and 5..4. */
 
	if (CheckSavegameVersion(135)) {
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			if (IsTileType(t, MP_CLEAR)) {
 
				if (GetRawClearGround(t) == CLEAR_SNOW) {
 
					SetClearGroundDensity(t, CLEAR_GRASS, GetClearDensity(t));
 
					SetBit(_m[t].m3, 4);
 
				} else {
 
					ClrBit(_m[t].m3, 4);
 
				}
 
			}
 
			if (IsTileType(t, MP_TREES)) {
 
				uint density = GB(_m[t].m2, 6, 2);
 
				uint ground = GB(_m[t].m2, 4, 2);
 
				uint counter = GB(_m[t].m2, 0, 4);
 
				_m[t].m2 = ground << 6 | density << 4 | counter;
 
			}
 
		}
 
	}
 

	
 
	/* Road stops is 'only' updating some caches */
 
	AfterLoadRoadStops();
 
	AfterLoadLabelMaps();
 

	
 
	GamelogPrintDebug(1);
 

	
src/saveload/saveload.cpp
Show inline comments
 
@@ -44,13 +44,13 @@
 
#include "../engine_base.h"
 

	
 
#include "table/strings.h"
 

	
 
#include "saveload_internal.h"
 

	
 
extern const uint16 SAVEGAME_VERSION = 134;
 
extern const uint16 SAVEGAME_VERSION = 135;
 

	
 
SavegameType _savegame_type; ///< type of savegame we are loading
 

	
 
uint32 _ttdp_version;     ///< version of TTDP savegame (if applicable)
 
uint16 _sl_version;       ///< the major savegame version identifier
 
byte   _sl_minor_version; ///< the minor savegame version, DO NOT USE!
src/smallmap_gui.cpp
Show inline comments
 
@@ -371,13 +371,13 @@ static inline uint32 GetSmallMapVegetati
 
			return (IsClearGround(tile, CLEAR_GRASS) && GetClearDensity(tile) < 3) ? MKCOLOUR(0x37373737) : _vegetation_clear_bits[GetClearGround(tile)];
 

	
 
		case MP_INDUSTRY:
 
			return GetIndustrySpec(Industry::GetByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOUR(0xD0D0D0D0) : MKCOLOUR(0xB5B5B5B5);
 

	
 
		case MP_TREES:
 
			if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT) {
 
			if (GetTreeGround(tile) == TREE_GROUND_SNOW_DESERT || GetTreeGround(tile) == TREE_GROUND_ROUGH_SNOW) {
 
				return (_settings_game.game_creation.landscape == LT_ARCTIC) ? MKCOLOUR(0x98575798) : MKCOLOUR(0xC25757C2);
 
			}
 
			return MKCOLOUR(0x54575754);
 

	
 
		default:
 
			return ApplyMask(MKCOLOUR(0x54545454), &_smallmap_vehicles_andor[t]);
src/tree_cmd.cpp
Show inline comments
 
@@ -65,13 +65,13 @@ static bool CanPlantTreesOnTile(TileInde
 
{
 
	switch (GetTileType(tile)) {
 
		case MP_WATER:
 
			return !IsBridgeAbove(tile) && IsCoast(tile) && !IsSlopeWithOneCornerRaised(GetTileSlope(tile, NULL));
 

	
 
		case MP_CLEAR:
 
			return !IsBridgeAbove(tile) && !IsClearGround(tile, CLEAR_FIELDS) && !IsClearGround(tile, CLEAR_ROCKS) &&
 
			return !IsBridgeAbove(tile) && !IsClearGround(tile, CLEAR_FIELDS) && GetRawClearGround(tile) != CLEAR_ROCKS &&
 
			       (allow_desert || !IsClearGround(tile, CLEAR_DESERT));
 

	
 
		default: return false;
 
	}
 
}
 

	
 
@@ -98,16 +98,18 @@ static void PlantTreesOnTile(TileIndex t
 
		case MP_WATER:
 
			ground = TREE_GROUND_SHORE;
 
			break;
 

	
 
		case MP_CLEAR:
 
			switch (GetClearGround(tile)) {
 
				case CLEAR_GRASS:  ground = TREE_GROUND_GRASS;       density = GetClearDensity(tile); break;
 
				case CLEAR_ROUGH:  ground = TREE_GROUND_ROUGH;                                        break;
 
				default:           ground = TREE_GROUND_SNOW_DESERT; density = GetClearDensity(tile); break;
 
				case CLEAR_GRASS:  ground = TREE_GROUND_GRASS;       break;
 
				case CLEAR_ROUGH:  ground = TREE_GROUND_ROUGH;       break;
 
				case CLEAR_SNOW:   ground = GetRawClearGround(tile) == CLEAR_ROUGH ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT; break;
 
				default:           ground = TREE_GROUND_SNOW_DESERT; break;
 
			}
 
			if (GetClearGround(tile) != CLEAR_ROUGH) density = GetClearDensity(tile);
 
			break;
 

	
 
		default: NOT_REACHED();
 
	}
 

	
 
	MakeTree(tile, treetype, count, growth, ground, density);
 
@@ -160,13 +162,13 @@ static void PlaceTree(TileIndex tile, ui
 

	
 
	if (tree != TREE_INVALID) {
 
		PlantTreesOnTile(tile, tree, GB(r, 22, 2), min(GB(r, 16, 3), 6));
 

	
 
		/* Rerandomize ground, if neither snow nor shore */
 
		TreeGround ground = GetTreeGround(tile);
 
		if (ground != TREE_GROUND_SNOW_DESERT && ground != TREE_GROUND_SHORE) {
 
		if (ground != TREE_GROUND_SNOW_DESERT && ground != TREE_GROUND_ROUGH_SNOW && ground != TREE_GROUND_SHORE) {
 
			SetTreeGroundDensity(tile, (TreeGround)GB(r, 28, 1), 3);
 
		}
 

	
 
		/* Set the counter to a random start value */
 
		SetTreeCounter(tile, (TreeGround)GB(r, 24, 4));
 
	}
 
@@ -466,13 +468,13 @@ static void DrawTile_Trees(TileInfo *ti)
 
	if (IsInvisibilitySet(TO_TREES)) return;
 

	
 
	uint tmp = CountBits(ti->tile + ti->x + ti->y);
 
	uint index = GB(tmp, 0, 2) + (GetTreeType(ti->tile) << 2);
 

	
 
	/* different tree styles above one of the grounds */
 
	if (GetTreeGround(ti->tile) == TREE_GROUND_SNOW_DESERT &&
 
	if ((GetTreeGround(ti->tile) == TREE_GROUND_SNOW_DESERT || GetTreeGround(ti->tile) == TREE_GROUND_ROUGH_SNOW) &&
 
			GetTreeDensity(ti->tile) >= 2 &&
 
			IsInsideMM(index, TREE_SUB_ARCTIC << 2, TREE_RAINFOREST << 2)) {
 
		index += 164 - (TREE_SUB_ARCTIC << 2);
 
	}
 

	
 
	assert(index < lengthof(_tree_layout_sprite));
 
@@ -596,20 +598,25 @@ static void TileLoopTreesDesert(TileInde
 

	
 
static void TileLoopTreesAlps(TileIndex tile)
 
{
 
	int k = GetTileZ(tile) - GetSnowLine() + TILE_HEIGHT;
 

	
 
	if (k < 0) {
 
		if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT) return;
 
		SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 3);
 
		switch (GetTreeGround(tile)) {
 
			case TREE_GROUND_SNOW_DESERT: SetTreeGroundDensity(tile, TREE_GROUND_GRASS, 3); break;
 
			case TREE_GROUND_ROUGH_SNOW:  SetTreeGroundDensity(tile, TREE_GROUND_ROUGH, 3); break;
 
			default: return;
 
		}
 
	} else {
 
		uint density = min((uint)k / TILE_HEIGHT, 3);
 

	
 
		if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT ||
 
				GetTreeDensity(tile) != density) {
 
			SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, density);
 
		if (GetTreeGround(tile) != TREE_GROUND_SNOW_DESERT && GetTreeGround(tile) != TREE_GROUND_ROUGH_SNOW) {
 
			TreeGround tg = GetTreeGround(tile) == TREE_GROUND_ROUGH ? TREE_GROUND_ROUGH_SNOW : TREE_GROUND_SNOW_DESERT;
 
			SetTreeGroundDensity(tile, tg, density);
 
		} else if (GetTreeDensity(tile) != density) {
 
			SetTreeGroundDensity(tile, GetTreeGround(tile), density);
 
		} else {
 
			if (GetTreeDensity(tile) == 3) {
 
				uint32 r = Random();
 
				if (Chance16I(1, 200, r)) {
 
					SndPlayTileFx((r & 0x80000000) ? SND_39_HEAVY_WIND : SND_34_WIND, tile);
 
				}
 
@@ -706,14 +713,23 @@ static void TileLoop_Trees(TileIndex til
 
			} else {
 
				/* just one tree, change type into MP_CLEAR */
 
				switch (GetTreeGround(tile)) {
 
					case TREE_GROUND_SHORE: MakeShore(tile); break;
 
					case TREE_GROUND_GRASS: MakeClear(tile, CLEAR_GRASS, GetTreeDensity(tile)); break;
 
					case TREE_GROUND_ROUGH: MakeClear(tile, CLEAR_ROUGH, 3); break;
 
					case TREE_GROUND_ROUGH_SNOW:
 
						MakeClear(tile, CLEAR_ROUGH, 3);
 
						MakeSnow(tile);
 
						break;
 
					default: // snow or desert
 
						MakeClear(tile, _settings_game.game_creation.landscape == LT_TROPIC ? CLEAR_DESERT : CLEAR_SNOW, GetTreeDensity(tile));
 
						if (_settings_game.game_creation.landscape == LT_TROPIC) {
 
							MakeClear(tile, CLEAR_DESERT, GetTreeDensity(tile));
 
						} else {
 
							MakeClear(tile, CLEAR_GRASS, GetTreeDensity(tile));
 
							MakeSnow(tile);
 
						}
 
						break;
 
				}
 
			}
 
			break;
 

	
 
		default:
src/tree_map.h
Show inline comments
 
@@ -55,12 +55,13 @@ enum {
 
 */
 
enum TreeGround {
 
	TREE_GROUND_GRASS       = 0, ///< normal grass
 
	TREE_GROUND_ROUGH       = 1, ///< some rough tile
 
	TREE_GROUND_SNOW_DESERT = 2, ///< a desert or snow tile, depend on landscape
 
	TREE_GROUND_SHORE       = 3, ///< shore
 
	TREE_GROUND_ROUGH_SNOW  = 4, ///< a snow tile that is rough underneed
 
};
 

	
 

	
 
/**
 
 * Returns the treetype of a tile.
 
 *
 
@@ -88,13 +89,13 @@ static inline TreeType GetTreeType(TileI
 
 * @return The groundtype of the tile
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline TreeGround GetTreeGround(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_TREES));
 
	return (TreeGround)GB(_m[t].m2, 4, 2);
 
	return (TreeGround)GB(_m[t].m2, 6, 3);
 
}
 

	
 
/**
 
 * Returns the 'density' of a tile with trees.
 
 *
 
 * This function returns the density of a tile which got trees. Note
 
@@ -113,13 +114,13 @@ static inline TreeGround GetTreeGround(T
 
 * @pre Tile must be of type MP_TREES
 
 * @see GetTreeCount
 
 */
 
static inline uint GetTreeDensity(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_TREES));
 
	return GB(_m[t].m2, 6, 2);
 
	return GB(_m[t].m2, 4, 2);
 
}
 

	
 
/**
 
 * Set the density and ground type of a tile with trees.
 
 *
 
 * This functions saves the ground type and the density which belongs to it
 
@@ -130,14 +131,14 @@ static inline uint GetTreeDensity(TileIn
 
 * @param d The density to save with
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
 
{
 
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
 
	SB(_m[t].m2, 4, 2, g);
 
	SB(_m[t].m2, 6, 2, d);
 
	SB(_m[t].m2, 4, 2, d);
 
	SB(_m[t].m2, 6, 3, g);
 
}
 

	
 
/**
 
 * Returns the number of trees on a tile.
 
 *
 
 * This function returns the number of trees of a tile (1-4).
 
@@ -274,13 +275,13 @@ static inline void SetTreeCounter(TileIn
 
 * @param density the density (not the number of trees)
 
 */
 
static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
 
{
 
	SetTileType(t, MP_TREES);
 
	SetTileOwner(t, OWNER_NONE);
 
	_m[t].m2 = density << 6 | ground << 4 | 0;
 
	_m[t].m2 = ground << 6 | density << 4 | 0;
 
	_m[t].m3 = type;
 
	_m[t].m4 = 0 << 5 | 0 << 2;
 
	_m[t].m5 = count << 6 | growth;
 
	SB(_m[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
}
0 comments (0 inline, 0 general)