changeset 11294:63f980601558 draft

(svn r15643) -Fix [FS#2711]: be more strict with zeroing unused map array bits
author smatz <smatz@openttd.org>
date Sun, 08 Mar 2009 16:10:39 +0000
parents 49968fa7d5e4
children 33477e9d4345
files src/bridge_map.h src/clear_map.h src/industry_map.h src/rail_map.h src/road_map.h src/station_map.h src/tree_map.h src/tunnel_map.h src/unmovable_map.h src/water_map.h
diffstat 10 files changed, 54 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/src/bridge_map.h
+++ b/src/bridge_map.h
@@ -173,6 +173,7 @@
 	_m[t].m4 = 0;
 	_m[t].m5 = 1 << 7 | tt << 2 | d;
 	SB(_m[t].m6, 2, 4, bridgetype);
+	_me[t].m7 = 0;
 }
 
 /**
--- a/src/clear_map.h
+++ b/src/clear_map.h
@@ -238,8 +238,9 @@
 	_m[t].m2 = 0;
 	_m[t].m3 = 0;
 	_m[t].m4 = 0 << 5 | 0 << 2;
-	SetClearGroundDensity(t, g, density);
-	SB(_m[t].m6, 2, 4, 0); // Clear the rest of m6, bits 2 to 5
+	SetClearGroundDensity(t, g, density); // Sets m5
+	SB(_m[t].m6, 2, 4, 0); // Other bits are "tropic zone" and "bridge above"
+	_me[t].m7 = 0;
 }
 
 
@@ -257,6 +258,8 @@
 	_m[t].m3 = field_type;
 	_m[t].m4 = 0 << 5 | 0 << 2;
 	SetClearGroundDensity(t, CLEAR_FIELDS, 3);
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 #endif /* CLEAR_MAP_H */
--- a/src/industry_map.h
+++ b/src/industry_map.h
@@ -166,25 +166,6 @@
 }
 
 /**
- * Make the given tile an industry tile
- * @param t      the tile to make an industry tile
- * @param index  the industry this tile belongs to
- * @param gfx    the graphics to use for the tile
- * @param random the random value
- */
-static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
-{
-	SetTileType(t, MP_INDUSTRY);
-	_m[t].m1 = 0;
-	_m[t].m2 = index;
-	_m[t].m3 = 0;
-	_m[t].m4 = 0;
-	SetIndustryGfx(t, gfx);
-	_me[t].m7 = random;
-	SetWaterClass(t, wc);
-}
-
-/**
  * Returns this indutry tile's construction counter value
  * @param tile the tile to query
  * @pre IsTileType(tile, MP_INDUSTRY)
@@ -321,4 +302,24 @@
 	SB(_m[tile].m6, 3, 3, triggers);
 }
 
+/**
+ * Make the given tile an industry tile
+ * @param t      the tile to make an industry tile
+ * @param index  the industry this tile belongs to
+ * @param gfx    the graphics to use for the tile
+ * @param random the random value
+ */
+static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
+{
+	SetTileType(t, MP_INDUSTRY);
+	_m[t].m1 = 0;
+	_m[t].m2 = index;
+	_m[t].m3 = 0;
+	_m[t].m4 = 0;
+	SetIndustryGfx(t, gfx); // m5, part of m6
+	SetIndustryTriggers(t, 0); // rest of m6
+	SetIndustryRandomBits(t, random); // m7
+	SetWaterClass(t, wc);
+}
+
 #endif /* INDUSTRY_MAP_H */
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -607,6 +607,8 @@
 	_m[t].m3 = r;
 	_m[t].m4 = 0;
 	_m[t].m5 = RAIL_TILE_NORMAL << 6 | b;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 
@@ -618,6 +620,8 @@
 	_m[t].m3 = r;
 	_m[t].m4 = 0;
 	_m[t].m5 = RAIL_TILE_DEPOT << 6 | d;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 
@@ -629,6 +633,8 @@
 	_m[t].m3 = r;
 	_m[t].m4 = 0;
 	_m[t].m5 = RAIL_TILE_WAYPOINT << 6 | a;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 #endif /* RAIL_MAP_H */
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -390,7 +390,6 @@
 	_m[t].m3 = (HasBit(rot, ROADTYPE_TRAM) ? bits : 0);
 	_m[t].m4 = 0;
 	_m[t].m5 = (HasBit(rot, ROADTYPE_ROAD) ? bits : 0) | ROAD_TILE_NORMAL << 6;
-	SetRoadOwner(t, ROADTYPE_TRAM, tram);
 	SB(_m[t].m6, 2, 4, 0);
 	_me[t].m7 = rot << 6;
 	SetRoadOwner(t, ROADTYPE_TRAM, tram);
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -314,7 +314,9 @@
 	_m[t].m3 = 0;
 	_m[t].m4 = 0;
 	_m[t].m5 = section;
+	SB(_m[t].m6, 2, 1, 0);
 	SB(_m[t].m6, 3, 3, st);
+	_me[t].m7 = 0;
 }
 
 static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
--- a/src/tree_map.h
+++ b/src/tree_map.h
@@ -274,6 +274,8 @@
 	_m[t].m3 = type;
 	_m[t].m4 = 0 << 5 | 0 << 2;
 	_m[t].m5 = count << 6 | growth;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 #endif /* TREE_MAP_H */
--- a/src/tunnel_map.h
+++ b/src/tunnel_map.h
@@ -53,6 +53,8 @@
 	_m[t].m3 = 0;
 	_m[t].m4 = 0;
 	_m[t].m5 = TRANSPORT_ROAD << 2 | d;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 	SetRoadOwner(t, ROADTYPE_ROAD, o);
 	if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o);
 	SetRoadTypes(t, r);
@@ -73,6 +75,8 @@
 	_m[t].m3 = r;
 	_m[t].m4 = 0;
 	_m[t].m5 = TRANSPORT_RAIL << 2 | d;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 #endif /* TUNNEL_MAP_H */
--- a/src/unmovable_map.h
+++ b/src/unmovable_map.h
@@ -192,6 +192,8 @@
 	_m[t].m3 = 0;
 	_m[t].m4 = 0;
 	_m[t].m5 = u;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 
--- a/src/water_map.h
+++ b/src/water_map.h
@@ -146,6 +146,8 @@
 	_m[t].m3 = WATER_CLASS_SEA;
 	_m[t].m4 = 0;
 	_m[t].m5 = 0;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 static inline void MakeShore(TileIndex t)
@@ -156,6 +158,8 @@
 	_m[t].m3 = 0;
 	_m[t].m4 = 0;
 	_m[t].m5 = 1;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 static inline void MakeRiver(TileIndex t, uint8 random_bits)
@@ -166,6 +170,8 @@
 	_m[t].m3 = WATER_CLASS_RIVER;
 	_m[t].m4 = random_bits;
 	_m[t].m5 = 0;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
@@ -177,6 +183,8 @@
 	_m[t].m3 = WATER_CLASS_CANAL;
 	_m[t].m4 = random_bits;
 	_m[t].m5 = 0;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, WaterClass original_water_class)
@@ -187,6 +195,8 @@
 	_m[t].m3 = original_water_class;
 	_m[t].m4 = 0;
 	_m[t].m5 = base + a * 2;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 static inline void MakeLockTile(TileIndex t, Owner o, byte section, WaterClass original_water_class)
@@ -197,6 +207,8 @@
 	_m[t].m3 = original_water_class;
 	_m[t].m4 = 0;
 	_m[t].m5 = section;
+	SB(_m[t].m6, 2, 4, 0);
+	_me[t].m7 = 0;
 }
 
 static inline void MakeLock(TileIndex t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper)