Changeset - r3076:e978321c3641
[Not reviewed]
master
0 4 0
tron - 18 years ago 2006-02-24 19:56:24
tron@openttd.org
(svn r3665) Add a function to turn a tile into a clear tile
4 files changed with 18 insertions and 19 deletions:
0 comments (0 inline, 0 general)
clear.h
Show inline comments
 
/* $Id$ */
 

	
 
#ifndef CLEAR_H
 
#define CLEAR_H
 

	
 
#include "macros.h"
 
#include "tile.h"
 

	
 
/* ground type, m5 bits 2...4
 
 * valid densities (bits 0...1) in comments after the enum
 
 */
 
typedef enum ClearGround {
 
	CL_GRASS  = 0, // 0-3
 
@@ -40,7 +41,18 @@ static inline void SetFieldType(TileInde
 
static inline uint GetFenceSE(TileIndex t) { return GB(_m[t].m4, 2, 3); }
 
static inline void SetFenceSE(TileIndex t, uint h) { SB(_m[t].m4, 2, 3, h); }
 

	
 
static inline uint GetFenceSW(TileIndex t) { return GB(_m[t].m4, 5, 3); }
 
static inline void SetFenceSW(TileIndex t, uint h) { SB(_m[t].m4, 5, 3, h); }
 

	
 

	
 
static inline void MakeClear(TileIndex t, ClearGround g, uint density)
 
{
 
	SetTileType(t, MP_CLEAR);
 
	SetTileOwner(t, OWNER_NONE);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0 << 5 | 0 << 2;
 
	_m[t].m5 = 0 << 5 | g << 2 | density;
 
}
 

	
 
#endif
landscape.c
Show inline comments
 
@@ -236,18 +236,13 @@ void DrawFoundation(TileInfo *ti, uint f
 
		OffsetGroundSprite(31, 9);
 
	}
 
}
 

	
 
void DoClearSquare(TileIndex tile)
 
{
 
	SetTileType(tile, MP_CLEAR);
 
	SetTileOwner(tile, OWNER_NONE);
 
	_m[tile].m2 = 0;
 
	_m[tile].m3 = 0;
 
	_m[tile].m4 = 0;
 
	SetClearGroundDensity(tile, CL_GRASS, _generating_world ? 3 : 0);
 
	MakeClear(tile, CL_GRASS, _generating_world ? 3 : 0);
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
uint32 GetTileTrackStatus(TileIndex tile, TransportType mode)
 
{
 
	return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode);
 
@@ -435,18 +430,13 @@ void InitializeLandscape(void)
 
	uint map_size;
 
	uint i;
 

	
 

	
 
	map_size = MapSize();
 
	for (i = 0; i < map_size; i++) {
 
		_m[i].type_height = MP_CLEAR << 4;
 
		_m[i].m1          = OWNER_NONE;
 
		_m[i].m2          = 0;
 
		_m[i].m3          = 0;
 
		_m[i].m4          = 0;
 
		_m[i].m5          = 3;
 
		MakeClear(i, CL_GRASS, 3);
 
		_m[i].extra       = 0;
 
	}
 

	
 
	// create void tiles at the border
 
	for (i = 0; i < MapMaxY(); ++i) MakeVoid(i * MapSizeX() + MapMaxX());
 
	for (i = 0; i < MapSizeX(); ++i) MakeVoid(MapSizeX() * MapMaxY() + i);
terraform_gui.c
Show inline comments
 
@@ -79,14 +79,13 @@ static void GenerateRockyArea(TileIndex 
 
	if (ey < sy) intswap(ey, sy);
 
	size_x = (ex - sx) + 1;
 
	size_y = (ey - sy) + 1;
 

	
 
	BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
 
		if (IsTileType(tile, MP_CLEAR) || IsTileType(tile, MP_TREES)) {
 
			SetTileType(tile, MP_CLEAR);
 
			SetClearGroundDensity(tile, CL_ROCKS, 3);
 
			MakeClear(tile, CL_ROCKS, 3);
 
			MarkTileDirtyByTile(tile);
 
			success = true;
 
		}
 
	} END_TILE_LOOP(tile, size_x, size_y, 0);
 

	
 
	if (success) SndPlayTileFx(SND_1F_SPLAT, end);
tree_cmd.c
Show inline comments
 
@@ -512,18 +512,16 @@ static void TileLoop_Trees(TileIndex til
 
			if (GetTreeCount(tile) > 0) {
 
				/* more than one tree, delete it */
 
				AddTreeCount(tile, -1);
 
				SetTreeGrowth(tile, 3);
 
			} else {
 
				/* just one tree, change type into MP_CLEAR */
 
				SetTileType(tile, MP_CLEAR);
 
				SetTileOwner(tile, OWNER_NONE);
 
				switch (GetTreeGround(tile)) {
 
					case TR_GRASS: SetClearGroundDensity(tile, CL_GRASS, 3); break;
 
					case TR_ROUGH: SetClearGroundDensity(tile, CL_ROUGH, 3); break;
 
					default:       SetClearGroundDensity(tile, CL_SNOW, GetTreeDensity(tile)); break;
 
					case TR_GRASS: MakeClear(tile, CL_GRASS, 3); break;
 
					case TR_ROUGH: MakeClear(tile, CL_ROUGH, 3); break;
 
					default:       MakeClear(tile, CL_SNOW, GetTreeDensity(tile)); break;
 
				}
 
			}
 
			break;
 

	
 
		default:
 
			AddTreeGrowth(tile, 1);
0 comments (0 inline, 0 general)