1 /* Data structures defining the properties of types. 2 Copyright (C) 1991-1996, 1998, 1999 Stanley T. Shebs. 3 4 Xconq is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation; either version 2, or (at your option) 7 any later version. See the file COPYING. */ 8 9 #include "config.h" 10 #include "misc.h" 11 #include "lisp.h" 12 #include "game.h" 13 14 /* (Now implemented in 'config.h'.) */ 15 #if (0) 16 #ifdef offsetof 17 #define OFFS(TYPE,FLD) (offsetof(TYPE, FLD)) 18 #else 19 #define OFFS(TYPE,FLD) \ 20 ((unsigned int) (((char *) (&(((TYPE *) NULL)->FLD))) - ((char *) NULL))) 21 #endif 22 #endif 23 #define OFFS(TYPE,FLD) (offsetof(TYPE, FLD)) 24 25 PropertyDefn utypedefns[] = { 26 27 #undef DEF_UPROP_I 28 #define DEF_UPROP_I(NAME,FNAME,DOC,SLOT,LO,DFLT,HI) \ 29 { NAME, FNAME, NULL, NULL, OFFS(Utype, SLOT), DOC, DFLT, NULL, LO, HI }, 30 #undef DEF_UPROP_S 31 #define DEF_UPROP_S(NAME,FNAME,DOC,SLOT,DFLT) \ 32 { NAME, NULL, FNAME, NULL, OFFS(Utype, SLOT), DOC, 0, DFLT, 0, 0 }, 33 #undef DEF_UPROP_L 34 #define DEF_UPROP_L(NAME,FNAME,DOC,SLOT) \ 35 { NAME, NULL, NULL, FNAME, OFFS(Utype, SLOT), DOC, 0, NULL, 0, 0 }, 36 37 #include "utype.def" 38 39 { NULL } 40 }; 41 42 PropertyDefn mtypedefns[] = { 43 44 #undef DEF_MPROP_I 45 #define DEF_MPROP_I(NAME,FNAME,DOC,SLOT,LO,DFLT,HI) \ 46 { NAME, FNAME, NULL, NULL, OFFS(Mtype, SLOT), DOC, DFLT, NULL, LO, HI }, 47 #undef DEF_MPROP_S 48 #define DEF_MPROP_S(NAME,FNAME,DOC,SLOT,DFLT) \ 49 { NAME, NULL, FNAME, NULL, OFFS(Mtype, SLOT), DOC, 0, DFLT, 0, 0 }, 50 #undef DEF_MPROP_L 51 #define DEF_MPROP_L(NAME,FNAME,DOC,SLOT) \ 52 { NAME, NULL, NULL, FNAME, OFFS(Mtype, SLOT), DOC, 0, NULL, 0, 0 }, 53 54 #include "mtype.def" 55 56 { NULL } 57 }; 58 59 PropertyDefn ttypedefns[] = { 60 61 #undef DEF_TPROP_I 62 #define DEF_TPROP_I(NAME,FNAME,DOC,SLOT,LO,DFLT,HI) \ 63 { NAME, FNAME, NULL, NULL, OFFS(Ttype, SLOT), DOC, DFLT, NULL, LO, HI }, 64 #undef DEF_TPROP_S 65 #define DEF_TPROP_S(NAME,FNAME,DOC,SLOT,DFLT) \ 66 { NAME, NULL, FNAME, NULL, OFFS(Ttype, SLOT), DOC, 0, DFLT, 0, 0 }, 67 #undef DEF_TPROP_L 68 #define DEF_TPROP_L(NAME,FNAME,DOC,SLOT) \ 69 { NAME, NULL, NULL, FNAME, OFFS(Ttype, SLOT), DOC, 0, NULL, 0, 0 }, 70 71 #include "ttype.def" 72 73 { NULL } 74 }; 75 76 PropertyDefn atypedefns[] = { 77 78 #undef DEF_APROP_I 79 #define DEF_APROP_I(NAME,FNAME,DOC,SLOT,LO,DFLT,HI) \ 80 { NAME, FNAME, NULL, NULL, OFFS(Atype, SLOT), DOC, DFLT, NULL, LO, HI }, 81 #undef DEF_APROP_S 82 #define DEF_APROP_S(NAME,FNAME,DOC,SLOT,DFLT) \ 83 { NAME, NULL, FNAME, NULL, OFFS(Atype, SLOT), DOC, 0, DFLT, 0, 0 }, 84 #undef DEF_APROP_L 85 #define DEF_APROP_L(NAME,FNAME,DOC,SLOT) \ 86 { NAME, NULL, NULL, FNAME, OFFS(Atype, SLOT), DOC, 0, NULL, 0, 0 }, 87 88 #include "atype.def" 89 90 { NULL } 91 }; 92 93 /* Define functions for all unit type properties. */ 94 95 #undef DEF_UPROP_I 96 #define DEF_UPROP_I(name,FNAME,doc,SLOT,lo,dflt,hi) \ 97 int FNAME(int u) { checku(u); return utypes[u].SLOT; } 98 #undef DEF_UPROP_S 99 #define DEF_UPROP_S(name,FNAME,doc,SLOT,dflt) \ 100 char *FNAME(int u) { checku(u); return utypes[u].SLOT; } 101 #undef DEF_UPROP_L 102 #define DEF_UPROP_L(name,FNAME,doc,SLOT) \ 103 Obj *FNAME(int u) { checku(u); return utypes[u].SLOT; } 104 105 #include "utype.def" 106 107 /* Define functions for all material type properties. */ 108 109 #undef DEF_MPROP_I 110 #define DEF_MPROP_I(name,FNAME,doc,SLOT,lo,dflt,hi) \ 111 int FNAME(int m) { checkm(m); return mtypes[m].SLOT; } 112 #undef DEF_MPROP_S 113 #define DEF_MPROP_S(name,FNAME,doc,SLOT,dflt) \ 114 char *FNAME(int m) { checkm(m); return mtypes[m].SLOT; } 115 #undef DEF_MPROP_L 116 #define DEF_MPROP_L(name,FNAME,doc,SLOT) \ 117 Obj *FNAME(int m) { checkm(m); return mtypes[m].SLOT; } 118 119 #include "mtype.def" 120 121 /* Define functions for all terrain type properties. */ 122 123 #undef DEF_TPROP_I 124 #define DEF_TPROP_I(name,FNAME,doc,SLOT,lo,dflt,hi) \ 125 int FNAME(int t) { checkt(t); return ttypes[t].SLOT; } 126 #undef DEF_TPROP_S 127 #define DEF_TPROP_S(name,FNAME,doc,SLOT,dflt) \ 128 char *FNAME(int t) { checkt(t); return ttypes[t].SLOT; } 129 #undef DEF_TPROP_L 130 #define DEF_TPROP_L(name,FNAME,doc,SLOT) \ 131 Obj *FNAME(int t) { checkt(t); return ttypes[t].SLOT; } 132 133 #include "ttype.def" 134 135 /* Define functions for all advance type properties. */ 136 137 #undef DEF_APROP_I 138 #define DEF_APROP_I(name,FNAME,doc,SLOT,lo,dflt,hi) \ 139 int FNAME(int a) { checka(a); return atypes[a].SLOT; } 140 #undef DEF_APROP_S 141 #define DEF_APROP_S(name,FNAME,doc,SLOT,dflt) \ 142 char *FNAME(int a) { checka(a); return atypes[a].SLOT; } 143 #undef DEF_APROP_L 144 #define DEF_APROP_L(name,FNAME,doc,SLOT) \ 145 Obj *FNAME(int a) { checka(a); return atypes[a].SLOT; } 146 147 #include "atype.def" 148