#include <stdio.h> typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint; typedef struct Tile { union { struct { uint8 type:3; uint8 amount:2; uint8 counter:3; uint8 fields:4; uint8 hedge_se:3; /* 1 unused bit */ uint8 hedge_sw:3; /* 13 unused bits */ } clear; struct { uint8 type:2; uint8 track_type:2; uint8 ground:4; union { struct { uint8 tracks:6; /* 2 unused bits */ struct { uint8 present:4; uint8 state:4; uint8 type:2; uint8 semaphore:1; /* 5 unused bits */ } signal; } track; struct { uint8 dir:2; /* 22 unused bits */ } depot; struct { uint8 dir:1; /* 23 unused bits */ } checkpoint; }; } railway; struct { uint8 type:2; uint8 roadwork_counter:5; uint8 snow_or_desert:1; uint8 ground:3; /* 5 unused bits */ union { struct { uint8 pieces:4; /* 12 unused bits */ } road; struct { uint8 road_owner; uint8 dir:1; uint8 lights:1; uint8 track_type:2; /* 4 unused bits */ } crossing; struct { uint8 dir:2; /* 12 unused bits */ } depot; }; } street; struct { uint8 type; uint8 stage:2; uint8 counter:3; /* 3 unused bits */ struct { uint8 pos:7; uint8 moving:1; uint8 dest:6; /* 2 unused bits */ } lift; } town; struct { uint8 type; uint8 ground:2; uint8 ground_amount:2; uint8 counter:4; uint8 count:2; uint8 growth:3; uint8 hedge_sw:3; uint8 hedge_se:3; /* 5 unused bits */ } trees; struct { uint16 index; uint16 part:7; uint16 type:4; uint16 track_type:2; /* 3 unused bits */ } station; struct { uint8 type:3; uint8 part:4; /* 25 unused bits */ } water; struct { uint8 type; uint8 index; uint8 built:1; uint8 stage:2; uint8 counter:3; /* 10 unused bits */ } industry; struct { uint8 transport:2; uint8 dir:2; uint8 track_type:2; uint8 snow_or_desert:1; /* 25 unused bits */ } tunnel; struct { uint8 owner; uint8 type:4; uint8 track_type:2; uint8 transport:2; uint8 dir:1; uint8 end_num:1; uint8 snow_or_desert:1; uint8 is_middle_part:1; /* 4 unused bits */ union { struct { uint8 under_is_transport:1; uint8 under_track_type:2; uint8 piece:3; }; struct { uint8 :6; uint8 under_ground:2; }; struct { uint8 :6; uint8 under_transport:2; }; } middle; } bridge; struct { uint8 type:7; /* 1 unused bit */ uint8 part:4; /* 20 unused bits */ } unmovable; }; uint8 type:4; // MP_* constants uint8 height:4; uint8 slope; uint8 owner:4; /* 12 unused bits */ } Tile; Tile tile; int main(void) { printf("clear %2d\n", sizeof(tile.clear)); printf("railway %2d\n", sizeof(tile.railway)); printf("street %2d\n", sizeof(tile.street)); printf("town %2d\n", sizeof(tile.town)); printf("trees %2d\n", sizeof(tile.trees)); printf("station %2d\n", sizeof(tile.station)); printf("water %2d\n", sizeof(tile.water)); printf("industry %2d\n", sizeof(tile.industry)); printf("tunnel %2d\n", sizeof(tile.tunnel)); printf("bridge %2d\n", sizeof(tile.bridge)); printf("unmovable %2d\n", sizeof(tile.unmovable)); printf("Tile %2d\n", sizeof(tile)); return 0; }