Changeset - r8368:229f823c854a
[Not reviewed]
master
0 5 0
peter1138 - 16 years ago 2008-01-20 18:30:53
peter1138@openttd.org
(svn r11934) -Codechange: add persistent random data for river and canal tiles.
5 files changed with 27 insertions and 12 deletions:
0 comments (0 inline, 0 general)
docs/landscape.html
Show inline comments
 
@@ -865,6 +865,11 @@
 
       </tr>
 

	
 
       <tr>
 
        <td noswap valign=top><tt>02</tt>&nbsp; </td>
 
        <td align=left>river</td>
 
       </tr>
 

	
 
       <tr>
 
        <td nowrap valign=top><tt>10</tt>..<tt>1B</tt>&nbsp; </td>
 
        <td align=left>canal locks
 
         <table>
 
@@ -945,7 +950,8 @@
 
       </tr>
 
      </table>
 
     </li>
 
     <li>m4: Owner of the water</li>
 
     <li>m4: Owner of the water when ship depot</li>
 
     <li>m4: Random data for canal or river tiles</li>
 
     <li>m6 bits 7..6 : Possibility of a bridge above, in the <a href="#bridge_direction">direction specified</a></li>
 
     <li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
 
    </ul>
src/newgrf_canal.cpp
Show inline comments
 
@@ -11,6 +11,7 @@
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_canal.h"
 
#include "tile_map.h"
 
#include "water_map.h"
 

	
 

	
 
/** Table of canal 'feature' sprite groups */
 
@@ -21,7 +22,7 @@ const SpriteGroup *_canal_sg[CF_END];
 
 * three functions are stubs. */
 
static uint32 CanalGetRandomBits(const ResolverObject *object)
 
{
 
	return 0;
 
	return GetWaterTileRandomBits(object->u.canal.tile);
 
}
 

	
 

	
 
@@ -47,6 +48,9 @@ static uint32 CanalGetVariable(const Res
 

	
 
		case 0x81:
 
			return GetTerrainType(tile);
 

	
 
		case 0x83:
 
			return GetWaterTileRandomBits(tile);
 
	}
 

	
 
	DEBUG(grf, 1, "Unhandled canal property 0x%02X", variable);
src/openttd.cpp
Show inline comments
 
@@ -1710,7 +1710,7 @@ bool AfterLoadGame()
 
						if (GB(_m[t].m5, 3, 2) == 0) {
 
							MakeClear(t, CLEAR_GRASS, 3);
 
						} else {
 
							MakeCanal(t, (GetTileOwner(t) == OWNER_WATER) ? OWNER_NONE : GetTileOwner(t));
 
							MakeCanal(t, (GetTileOwner(t) == OWNER_WATER) ? OWNER_NONE : GetTileOwner(t), Random());
 
						}
 
					}
 
					SetBridgeMiddle(t, axis);
src/water_cmd.cpp
Show inline comments
 
@@ -56,7 +56,7 @@ void MakeWaterOrCanalDependingOnSurround
 

	
 
	/* Non-sealevel -> canal */
 
	if (TileHeight(t) != 0) {
 
		MakeCanal(t, o);
 
		MakeCanal(t, o, Random());
 
		return;
 
	}
 

	
 
@@ -71,7 +71,7 @@ void MakeWaterOrCanalDependingOnSurround
 
		}
 
	}
 
	if (has_canal || !has_water) {
 
		MakeCanal(t, o);
 
		MakeCanal(t, o, Random());
 
	} else {
 
		MakeWater(t);
 
	}
 
@@ -128,7 +128,7 @@ void MakeWaterOrCanalDependingOnOwner(Ti
 
	if (o == OWNER_WATER) {
 
		MakeWater(tile);
 
	} else {
 
		MakeCanal(tile, o);
 
		MakeCanal(tile, o, Random());
 
	}
 
}
 

	
 
@@ -305,9 +305,9 @@ CommandCost CmdBuildCanal(TileIndex tile
 
			if (TileHeight(tile) == 0 && p2 == 1) {
 
				MakeWater(tile);
 
			} else if (p2 == 2) {
 
				MakeRiver(tile);
 
				MakeRiver(tile, Random());
 
			} else {
 
				MakeCanal(tile, _current_player);
 
				MakeCanal(tile, _current_player, Random());
 
			}
 
			MarkTileDirtyByTile(tile);
 
			MarkTilesAroundDirty(tile);
src/water_map.h
Show inline comments
 
@@ -108,6 +108,11 @@ static inline byte GetSection(TileIndex 
 
	return GB(_m[t].m5, 0, 4);
 
}
 

	
 
static inline byte GetWaterTileRandomBits(TileIndex t)
 
{
 
	return _m[t].m4;
 
}
 

	
 

	
 
static inline void MakeWater(TileIndex t)
 
{
 
@@ -129,24 +134,24 @@ static inline void MakeShore(TileIndex t
 
	_m[t].m5 = 1;
 
}
 

	
 
static inline void MakeRiver(TileIndex t)
 
static inline void MakeRiver(TileIndex t, uint8 random_bits)
 
{
 
	SetTileType(t, MP_WATER);
 
	SetTileOwner(t, OWNER_WATER);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m4 = random_bits;
 
	_m[t].m5 = 2;
 
}
 

	
 
static inline void MakeCanal(TileIndex t, Owner o)
 
static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
 
{
 
	assert(o != OWNER_WATER);
 
	SetTileType(t, MP_WATER);
 
	SetTileOwner(t, o);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m4 = random_bits;
 
	_m[t].m5 = 0;
 
}
 

	
0 comments (0 inline, 0 general)