You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Tile data type has a size of 10 bytes, even though the commit log suggests that it should be 8 bytes. This is caused by the 2-byte member 'm2', which is on an alignement boundary, as is shown below. As a result, the map wastes 2 bytes per tile. This was introduced by commit 26873 and #6510 tried to reduce the size of Tile back to 8 bytes, which failed due to the position of m2 in the struct.
The current (r27120) definition of Tile in map_type.h:
struct Tile {
byte type; ///< The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
byte height; ///< The height of the northern corner.
byte m1; ///< Primarily used for ownership information
uint16 m2; ///< Primarily used for indices to towns, industries and stations
byte m3; ///< General purpose
byte m4; ///< General purpose
byte m5; ///< General purpose
};
After m1 the compiler will insert a dummy-byte, to ensure that m2 is properly aligned. After m5 another dummy byte is added also for alignment purposes. It is probably best demonstrated with a test program. So I've attached a small program that you can compile and run to see that the current definition of Tile takes up 10 bytes (and thus is wasting 2 bytes). The problem can be fixed by moving m2 above m1.
bcmpinc opened the ticket and wrote:
Reported version: trunk
Operating system: All
This issue was imported from FlySpray: https://bugs.openttd.org/task/6218
The text was updated successfully, but these errors were encountered: