(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
Replace some direct references to _map_type_and_height with TileHeight()/IsTileType()
This commit is contained in:
		
							
								
								
									
										16
									
								
								clear_cmd.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								clear_cmd.c
									
									
									
									
									
								
							| @@ -52,7 +52,7 @@ static int TerraformGetHeightOfTile(TerraformerState *ts, TileIndex tile) | |||||||
| 			return mod->height; | 			return mod->height; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return _map_type_and_height[tile] & 0xF; | 	return TileHeight(tile); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile) | static void TerraformAddDirtyTile(TerraformerState *ts, TileIndex tile) | ||||||
| @@ -91,7 +91,7 @@ static int TerraformProc(TerraformerState *ts, uint tile, int mode) | |||||||
| 	if ((r=TerraformAllowTileProcess(ts, tile)) <= 0) | 	if ((r=TerraformAllowTileProcess(ts, tile)) <= 0) | ||||||
| 		return r; | 		return r; | ||||||
|  |  | ||||||
| 	if ((_map_type_and_height[tile] >> 4) == MP_RAILWAY) { | 	if (IsTileType(tile, MP_RAILWAY)) { | ||||||
| 		static const byte _railway_modes[4] = {8, 0x10, 4, 0x20}; | 		static const byte _railway_modes[4] = {8, 0x10, 4, 0x20}; | ||||||
| 		static const byte _railway_dangslopes[4] = {0xd, 0xe, 7, 0xb}; | 		static const byte _railway_dangslopes[4] = {0xd, 0xe, 7, 0xb}; | ||||||
| 		static const byte _railway_dangslopes2[4] = {0x2, 0x1, 0x8, 0x4}; | 		static const byte _railway_dangslopes2[4] = {0x2, 0x1, 0x8, 0x4}; | ||||||
| @@ -239,25 +239,25 @@ int32 CmdTerraformLand(int x, int y, uint32 flags, uint32 p1, uint32 p2) | |||||||
|  |  | ||||||
| 	if (p1 & 1) { | 	if (p1 & 1) { | ||||||
| 		if (!TerraformTileHeight(&ts, tile+TILE_XY(1,0), | 		if (!TerraformTileHeight(&ts, tile+TILE_XY(1,0), | ||||||
| 				(_map_type_and_height[tile+TILE_XY(1,0)]&0xF) + direction)) | 				TileHeight(tile + TILE_XY(1, 0)) + direction)) | ||||||
| 					return CMD_ERROR; | 					return CMD_ERROR; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (p1 & 2) { | 	if (p1 & 2) { | ||||||
| 		if (!TerraformTileHeight(&ts, tile+TILE_XY(1,1), | 		if (!TerraformTileHeight(&ts, tile+TILE_XY(1,1), | ||||||
| 				(_map_type_and_height[tile+TILE_XY(1,1)]&0xF) + direction)) | 				TileHeight(tile + TILE_XY(1, 1)) + direction)) | ||||||
| 					return CMD_ERROR; | 					return CMD_ERROR; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (p1 & 4) { | 	if (p1 & 4) { | ||||||
| 		if (!TerraformTileHeight(&ts, tile+TILE_XY(0,1), | 		if (!TerraformTileHeight(&ts, tile+TILE_XY(0,1), | ||||||
| 				(_map_type_and_height[tile+TILE_XY(0,1)]&0xF) + direction)) | 				TileHeight(tile + TILE_XY(0, 1)) + direction)) | ||||||
| 					return CMD_ERROR; | 					return CMD_ERROR; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (p1 & 8) { | 	if (p1 & 8) { | ||||||
| 		if (!TerraformTileHeight(&ts, tile+TILE_XY(0,0), | 		if (!TerraformTileHeight(&ts, tile+TILE_XY(0,0), | ||||||
| 				(_map_type_and_height[tile+TILE_XY(0,0)]&0xF) + direction)) | 				TileHeight(tile + TILE_XY(0, 0)) + direction)) | ||||||
| 					return CMD_ERROR; | 					return CMD_ERROR; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -338,7 +338,7 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) | |||||||
| 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); | 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); | ||||||
|  |  | ||||||
| 	// remember level height | 	// remember level height | ||||||
| 	h = _map_type_and_height[p1]&0xF; | 	h = TileHeight(p1); | ||||||
|  |  | ||||||
| 	ex >>= 4; ey >>= 4; | 	ex >>= 4; ey >>= 4; | ||||||
|  |  | ||||||
| @@ -356,7 +356,7 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2) | |||||||
| 	cost = 0; | 	cost = 0; | ||||||
|  |  | ||||||
| 	BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) | 	BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) | ||||||
| 		curh = _map_type_and_height[tile2]&0xF; | 		curh = TileHeight(tile2); | ||||||
| 		while (curh != h) { | 		while (curh != h) { | ||||||
| 			ret = DoCommandByTile(tile2, 8, (curh > h)?0:1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND); | 			ret = DoCommandByTile(tile2, 8, (curh > h)?0:1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND); | ||||||
| 			if (ret == CMD_ERROR) break; | 			if (ret == CMD_ERROR) break; | ||||||
|   | |||||||
| @@ -20,7 +20,7 @@ static void DisasterClearSquare(uint tile) | |||||||
| 	if (!EnsureNoVehicle(tile)) | 	if (!EnsureNoVehicle(tile)) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
| 	type = _map_type_and_height[tile] >> 4; | 	type = TileType(tile); | ||||||
|  |  | ||||||
| 	if (type == MP_RAILWAY) { | 	if (type == MP_RAILWAY) { | ||||||
| 		if (IS_HUMAN_PLAYER(_map_owner[tile])) | 		if (IS_HUMAN_PLAYER(_map_owner[tile])) | ||||||
|   | |||||||
							
								
								
									
										13
									
								
								landscape.c
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								landscape.c
									
									
									
									
									
								
							| @@ -53,12 +53,12 @@ uint GetTileSlope(uint tile, int *h) | |||||||
|  |  | ||||||
| 	assert(tile < MapSize() && TileX(tile) != MapMaxX() && TileY(tile) != MapMaxY()); | 	assert(tile < MapSize() && TileX(tile) != MapMaxX() && TileY(tile) != MapMaxY()); | ||||||
|  |  | ||||||
| 	min = a = _map_type_and_height[tile] & 0xF; | 	min = a = TileHeight(tile); | ||||||
| 	b = _map_type_and_height[tile+TILE_XY(1,0)] & 0xF; | 	b = TileHeight(tile + TILE_XY(1,0)); | ||||||
| 	if (min >= b) min = b; | 	if (min >= b) min = b; | ||||||
| 	c = _map_type_and_height[tile+TILE_XY(0,1)] & 0xF; | 	c = TileHeight(tile + TILE_XY(0,1)); | ||||||
| 	if (min >= c) min = c; | 	if (min >= c) min = c; | ||||||
| 	d = _map_type_and_height[tile+TILE_XY(1,1)] & 0xF; | 	d = TileHeight(tile + TILE_XY(1,1)); | ||||||
| 	if (min >= d) min = d; | 	if (min >= d) min = d; | ||||||
|  |  | ||||||
| 	r = 0; | 	r = 0; | ||||||
| @@ -634,14 +634,13 @@ static void CreateDesertOrRainForest() | |||||||
| { | { | ||||||
| 	uint tile; | 	uint tile; | ||||||
| 	const TileIndexDiffC *data; | 	const TileIndexDiffC *data; | ||||||
| 	byte mt; |  | ||||||
| 	int i; | 	int i; | ||||||
|  |  | ||||||
| 	for (tile = 0; tile != MapSize(); ++tile) { | 	for (tile = 0; tile != MapSize(); ++tile) { | ||||||
| 		for (data = _make_desert_or_rainforest_data; | 		for (data = _make_desert_or_rainforest_data; | ||||||
| 				data != endof(_make_desert_or_rainforest_data); ++data) { | 				data != endof(_make_desert_or_rainforest_data); ++data) { | ||||||
| 			mt = _map_type_and_height[TILE_MASK(tile + ToTileIndexDiff(*data))]; | 			TileIndex t = tile + ToTileIndexDiff(*data); | ||||||
| 			if ((mt & 0xf) >= 4 || (mt >> 4) == MP_WATER) break; | 			if (TileHeight(t) >= 4 || IsTileType(t, MP_WATER)) break; | ||||||
| 		} | 		} | ||||||
| 		if (data == endof(_make_desert_or_rainforest_data)) | 		if (data == endof(_make_desert_or_rainforest_data)) | ||||||
| 			SetMapExtraBits(tile, 1); | 			SetMapExtraBits(tile, 1); | ||||||
|   | |||||||
| @@ -1147,18 +1147,18 @@ static void CommonRaiseLowerBigLand(uint tile, int mode) | |||||||
| 			/* Raise land */ | 			/* Raise land */ | ||||||
| 			h = 15; | 			h = 15; | ||||||
| 			BEGIN_TILE_LOOP(tile2, size, size, tile) | 			BEGIN_TILE_LOOP(tile2, size, size, tile) | ||||||
| 				h = min(h, _map_type_and_height[tile2]&0xF); | 				h = min(h, TileHeight(tile2)); | ||||||
| 			END_TILE_LOOP(tile2, size, size, tile) | 			END_TILE_LOOP(tile2, size, size, tile) | ||||||
| 		} else { | 		} else { | ||||||
| 			/* Lower land */ | 			/* Lower land */ | ||||||
| 			h = 0; | 			h = 0; | ||||||
| 			BEGIN_TILE_LOOP(tile2, size, size, tile) | 			BEGIN_TILE_LOOP(tile2, size, size, tile) | ||||||
| 				h = max(h, _map_type_and_height[tile2]&0xF); | 				h = max(h, TileHeight(tile2)); | ||||||
| 			END_TILE_LOOP(tile2, size, size, tile) | 			END_TILE_LOOP(tile2, size, size, tile) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		BEGIN_TILE_LOOP(tile2, size, size, tile) | 		BEGIN_TILE_LOOP(tile2, size, size, tile) | ||||||
| 			if ((uint)(_map_type_and_height[tile2]&0xF) == h) { | 			if (TileHeight(tile2) == h) { | ||||||
| 				DoCommandP(tile2, 8, (uint32)mode, NULL, CMD_TERRAFORM_LAND | CMD_AUTO); | 				DoCommandP(tile2, 8, (uint32)mode, NULL, CMD_TERRAFORM_LAND | CMD_AUTO); | ||||||
| 			} | 			} | ||||||
| 		END_TILE_LOOP(tile2, size, size, tile) | 		END_TILE_LOOP(tile2, size, size, tile) | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								map.h
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								map.h
									
									
									
									
									
								
							| @@ -73,10 +73,15 @@ static inline TileIndexDiff TileOffsByDir(uint dir) | |||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| static inline uint TilePixelHeight(TileIndex tile) | static inline uint TileHeight(TileIndex tile) | ||||||
| { | { | ||||||
| 	assert(tile < MapSize()); | 	assert(tile < MapSize()); | ||||||
| 	return (_map_type_and_height[tile] & 0xf) * 8; | 	return _map_type_and_height[tile] & 0xf; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | static inline uint TilePixelHeight(TileIndex tile) | ||||||
|  | { | ||||||
|  | 	return TileHeight(tile) * 8; | ||||||
| } | } | ||||||
|  |  | ||||||
| static inline int TileType(TileIndex tile) | static inline int TileType(TileIndex tile) | ||||||
|   | |||||||
| @@ -310,7 +310,7 @@ static inline uint32 GetSmallMapCountoursPixels(uint tile) | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return (_map_height_bits[_map_type_and_height[tile] & 0xF] & _smallmap_contours_andor[t][1]) | _smallmap_contours_andor[t][0]; | 	return (_map_height_bits[TileHeight(tile)] & _smallmap_contours_andor[t][1]) | _smallmap_contours_andor[t][0]; | ||||||
| } | } | ||||||
|  |  | ||||||
| static void DrawSmallMapContours(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) | static void DrawSmallMapContours(byte *dst, uint xc, uint yc, int pitch, int reps, uint32 mask) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 tron
					tron