summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-03-08 16:10:39 +0000
committersmatz <smatz@openttd.org>2009-03-08 16:10:39 +0000
commite124aa8fd62f3260d2a127aab1e9bc6f5a303480 (patch)
tree093e5d2cab6ed85f891e85bb8d9947464dbc8706
parent7c8474da13d295ddb6224fe66c41e4ba4ac0f050 (diff)
downloadopenttd-e124aa8fd62f3260d2a127aab1e9bc6f5a303480.tar.xz
(svn r15643) -Fix [FS#2711]: be more strict with zeroing unused map array bits
-rw-r--r--src/bridge_map.h1
-rw-r--r--src/clear_map.h7
-rw-r--r--src/industry_map.h39
-rw-r--r--src/rail_map.h6
-rw-r--r--src/road_map.h1
-rw-r--r--src/station_map.h2
-rw-r--r--src/tree_map.h2
-rw-r--r--src/tunnel_map.h4
-rw-r--r--src/unmovable_map.h2
-rw-r--r--src/water_map.h12
10 files changed, 54 insertions, 22 deletions
diff --git a/src/bridge_map.h b/src/bridge_map.h
index 7a6035ca6..7615ebe13 100644
--- a/src/bridge_map.h
+++ b/src/bridge_map.h
@@ -173,6 +173,7 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, D
_m[t].m4 = 0;
_m[t].m5 = 1 << 7 | tt << 2 | d;
SB(_m[t].m6, 2, 4, bridgetype);
+ _me[t].m7 = 0;
}
/**
diff --git a/src/clear_map.h b/src/clear_map.h
index 98fd12034..f3459f0b1 100644
--- a/src/clear_map.h
+++ b/src/clear_map.h
@@ -238,8 +238,9 @@ static inline void MakeClear(TileIndex t, ClearGround g, uint density)
_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 @@ static inline void MakeField(TileIndex t, uint field_type, IndustryID industry)
_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 */
diff --git a/src/industry_map.h b/src/industry_map.h
index 158d0d92e..abfbfdf4a 100644
--- a/src/industry_map.h
+++ b/src/industry_map.h
@@ -166,25 +166,6 @@ static inline bool IsIndustryTileOnWater(TileIndex t)
}
/**
- * 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 @@ static inline void SetIndustryTriggers(TileIndex tile, byte triggers)
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 */
diff --git a/src/rail_map.h b/src/rail_map.h
index a6077cf0d..7c8c31f85 100644
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -607,6 +607,8 @@ static inline void MakeRailNormal(TileIndex t, Owner o, TrackBits b, RailType r)
_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 @@ static inline void MakeRailDepot(TileIndex t, Owner o, DiagDirection d, RailType
_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 @@ static inline void MakeRailWaypoint(TileIndex t, Owner o, Axis a, RailType r, ui
_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 */
diff --git a/src/road_map.h b/src/road_map.h
index 2b87216f9..c3fba22f5 100644
--- a/src/road_map.h
+++ b/src/road_map.h
@@ -390,7 +390,6 @@ static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, Tow
_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);
diff --git a/src/station_map.h b/src/station_map.h
index d9b0499e4..e706dd2a6 100644
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -314,7 +314,9 @@ static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType
_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)
diff --git a/src/tree_map.h b/src/tree_map.h
index f63c53f2f..ab2fef701 100644
--- a/src/tree_map.h
+++ b/src/tree_map.h
@@ -274,6 +274,8 @@ static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth,
_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 */
diff --git a/src/tunnel_map.h b/src/tunnel_map.h
index b5e2e8a5d..69a2dfa27 100644
--- a/src/tunnel_map.h
+++ b/src/tunnel_map.h
@@ -53,6 +53,8 @@ static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTyp
_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 @@ static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailTyp
_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 */
diff --git a/src/unmovable_map.h b/src/unmovable_map.h
index 027ca7b6b..04aecf916 100644
--- a/src/unmovable_map.h
+++ b/src/unmovable_map.h
@@ -192,6 +192,8 @@ static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o)
_m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = u;
+ SB(_m[t].m6, 2, 4, 0);
+ _me[t].m7 = 0;
}
diff --git a/src/water_map.h b/src/water_map.h
index a0faab036..be6c22b90 100644
--- a/src/water_map.h
+++ b/src/water_map.h
@@ -146,6 +146,8 @@ static inline void MakeWater(TileIndex t)
_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 @@ static inline void MakeShore(TileIndex t)
_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 @@ static inline void MakeRiver(TileIndex t, uint8 random_bits)
_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 @@ static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
_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 @@ static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a, W
_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 @@ static inline void MakeLockTile(TileIndex t, Owner o, byte section, WaterClass o
_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)