chiark / gitweb /
fix up silly compiler warning and improve readability a bit
[trains.git] / layout / layout-data.h
1 /*
2  */
3 /* The output from the layout processing system to the control
4  * software, describing the layout and the trains, is a data structure
5  * as described in this header file, in <name-of-layout>.layout-data.o
6  * (where <name-of-layout> is currently `ours').
7  *
8  * Alternatively, <name-of-layout>.redacted.forsafety contains data in
9  * the form described at the top of redactgraph.c.
10  */
11
12 #ifndef LAYOUT_DATA_H
13 #define LAYOUT_DATA_H
14
15 /*========== basic types etc. ==========*/
16
17 typedef int TrainNum;
18 typedef int SegmentNum;
19 typedef long MovPosComb;
20 typedef long Speed;
21 typedef int BoardObject;
22 typedef int Small;
23 typedef int Distance;
24 typedef short SegmentNumInMap;
25
26 typedef enum {
27   mfk_none,
28   mfk_point
29   /* must also add new entries to movpos.c:methodinfos */
30 } MovFeatKind;
31
32 /*========== data from config files and layout cad/cam ==========*/
33
34 typedef struct {
35   unsigned next_backwards:1;
36   SegmentNum next;
37 } SegmentLinkInfo;
38
39 typedef struct {
40   const char *pname;
41   MovFeatKind kind;
42   Small posns;
43   MovPosComb weight;
44   const BoardObject *boob;
45 } MovFeatInfo;
46
47 typedef struct {
48   const char *pname;
49   Distance dist;
50   SegmentLinkInfo backwards, forwards;
51 } SegPosCombInfo;
52
53 typedef struct {
54   const char *pname;
55   unsigned invertible:1;
56   Small n_movfeats;
57   const MovFeatInfo *movfeats;
58   MovPosComb n_poscombs;
59   const SegPosCombInfo *poscombs;
60   BoardObject sense, invert;
61 } SegmentInfo;
62
63 /* This data array has no sentinel member.  Use the info_nsegments
64  * constant.  Alternatively, it is legal to sed out everything from
65  * <name-of-layout>.layout-data.c from the first #include onwards, and
66  * this will give a definition of NUM_SEGMENTS.
67  */
68
69 extern const SegmentNum info_nsegments;
70 extern const SegmentInfo info_segments[];
71 extern const SegmentNumInMap info_segmentmap[];
72 extern const int info_segmentmaplen;
73
74 extern const BoardObject info_maxreverse; /* max. reverse + 1 */
75
76 #define NOTA(thing) (-1)
77 #define SOMEP(x) ((x) >= 0)
78
79 #endif /*LAYOUT_DATA_H*/