Changeset - r23379:f080157e5c08
[Not reviewed]
master
0 4 0
Eddi-z - 5 years ago 2019-03-02 17:33:16
43699911+Eddi-z@users.noreply.github.com
Fix #7307: Add WaterClass to MP_TREES, set when trees are on coast tiles (#7309)

This allows allows NewGRF object/industry placement rules to treat trees on coast tiles the same as regular bare coast.
4 files changed with 6 insertions and 3 deletions:
0 comments (0 inline, 0 general)
docs/landscape.html
Show inline comments
 
@@ -756,12 +756,13 @@
 
   <td><strong>Trees </strong></td>
 
  </tr>
 
  <tr>
 
   <td valign=top nowrap>&nbsp;</td>
 
   <td>
 
    <ul>
 
     <li>m1 bits 6..5: water class (sea or land)</li>
 
     <li>m1 bits 4..0: <a href="#OwnershipInfo">owner</a> (normally <tt>10</tt>)</li>
 
     <li>m2 bits 8..6: ground
 
      <table>
 

	
 
       <tr>
 
        <td align=left><tt>0</tt>&nbsp; </td>
docs/landscape_grid.html
Show inline comments
 
@@ -191,13 +191,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">XXXX XXXX</td>
 
      <td class="bits"><span class="free">OOO</span><span class="option">~ ~~~~</span></td>
 
      <td class="bits"><span class="free">O</span>XX<span class="option">~ ~~~~</span></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"><span class="free">OOOO OOOO</span></td>
 
      <td class="bits">XX<span class="free">OO O</span>XXX</td>
 
      <td class="bits"><span class="free">OOOO OOOO</span></td>
 
      <td class="bits"><span class="free">OOOO OOOO</span></td>
src/tree_map.h
Show inline comments
 
@@ -10,12 +10,13 @@
 
/** @file tree_map.h Map accessors for tree tiles. */
 

	
 
#ifndef TREE_MAP_H
 
#define TREE_MAP_H
 

	
 
#include "tile_map.h"
 
#include "water_map.h"
 

	
 
/**
 
 * List of tree types along all landscape types.
 
 *
 
 * This enumeration contains a list of the different tree types along
 
 * all landscape types. The values for the enumerations may be used for
 
@@ -130,12 +131,13 @@ static inline uint GetTreeDensity(TileIn
 
 */
 
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
 
{
 
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
 
	SB(_m[t].m2, 4, 2, d);
 
	SB(_m[t].m2, 6, 3, g);
 
	SetWaterClass(t, g == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
 
}
 

	
 
/**
 
 * Returns the number of trees on a tile.
 
 *
 
 * This function returns the number of trees of a tile (1-4).
src/water_map.h
Show inline comments
 
@@ -91,13 +91,13 @@ static inline WaterTileType GetWaterTile
 
 * You can then subsequently call GetWaterClass().
 
 * @param t Tile to query.
 
 * @return True if the tiletype has a waterclass.
 
 */
 
static inline bool HasTileWaterClass(TileIndex t)
 
{
 
	return IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT);
 
	return IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_TREES);
 
}
 

	
 
/**
 
 * Get the water class at a tile.
 
 * @param t Water tile to query.
 
 * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
 
@@ -201,13 +201,13 @@ static inline bool IsCoast(TileIndex t)
 
 * Is it a coast tile
 
 * @param t Tile to query.
 
 * @return \c true if it is a coast.
 
 */
 
static inline bool IsCoastTile(TileIndex t)
 
{
 
	return IsTileType(t, MP_WATER) && IsCoast(t);
 
	return (IsTileType(t, MP_WATER) && IsCoast(t)) || (IsTileType(t, MP_TREES) && GetWaterClass(t) != WATER_CLASS_INVALID);
 
}
 

	
 
/**
 
 * Is it a water tile with a ship depot on it?
 
 * @param t Water tile to query.
 
 * @return \c true if it is a ship depot tile.
0 comments (0 inline, 0 general)