(svn r3983) Use existing functions to access tree and road info
authortron
Sun, 19 Mar 2006 16:57:48 +0000
changeset 3271 0e796a2b7c9e
parent 3270 7531dde127ea
child 3272 7e556f209503
(svn r3983) Use existing functions to access tree and road info
rail_cmd.c
tree_cmd.c
--- a/rail_cmd.c	Sun Mar 19 14:43:23 2006 +0000
+++ b/rail_cmd.c	Sun Mar 19 16:57:48 2006 +0000
@@ -269,7 +269,6 @@
 {
 	TileIndex tile;
 	uint tileh;
-	uint m5; /* XXX: Used only as a cache, should probably be removed? */
 	Track track = (Track)p2;
 	TrackBits trackbit;
 	int32 cost = 0;
@@ -279,7 +278,6 @@
 
 	tile = TileVirtXY(x, y);
 	tileh = GetTileSlope(tile, NULL);
-	m5 = _m[tile].m5;
 	trackbit = TrackToTrackBits(track);
 
 	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -326,7 +324,7 @@
 
 			if (flags & DC_EXEC) {
 				_m[tile].m2 &= ~RAIL_MAP2LO_GROUND_MASK; // Bare land
-				_m[tile].m5 = m5 | trackbit;
+				_m[tile].m5 |= trackbit;
 			}
 			break;
 
@@ -341,8 +339,8 @@
 			if (!EnsureNoVehicle(tile)) return CMD_ERROR;
 
 			if (GetRoadType(tile) == ROAD_NORMAL && (
-						(track == TRACK_X && m5 == ROAD_Y) ||
-						(track == TRACK_Y && m5 == ROAD_X) // correct direction?
+						(track == TRACK_X && GetRoadBits(tile) == ROAD_Y) ||
+						(track == TRACK_Y && GetRoadBits(tile) == ROAD_X)
 					)) {
 				if (flags & DC_EXEC) {
 					MakeRoadCrossing(tile, GetTileOwner(tile), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), p1, _m[tile].m2);
--- a/tree_cmd.c	Sun Mar 19 14:43:23 2006 +0000
+++ b/tree_cmd.c	Sun Mar 19 16:57:48 2006 +0000
@@ -286,9 +286,9 @@
 		uint i;
 
 		/* put the trees to draw in a list */
-		i = (ti->map5 >> 6) + 1;
+		i = GetTreeCount(ti->tile) + 1;
 		do {
-			uint32 image = s[0] + (--i == 0 ? GB(ti->map5, 0, 3) : 3);
+			uint32 image = s[0] + (--i == 0 ? GetTreeGrowth(ti->tile) : 3);
 			if (_display_opt & DO_TRANS_BUILDINGS) MAKE_TRANSPARENT(image);
 			te[i].image = image;
 			te[i].x = d->x;
@@ -302,7 +302,7 @@
 			byte min = 0xFF;
 			TreeListEnt *tep = NULL;
 
-			i = (ti->map5 >> 6) + 1;
+			i = GetTreeCount(ti->tile) + 1;
 			do {
 				if (te[--i].image != 0 && te[i].x + te[i].y < min) {
 					min = te[i].x + te[i].y;