1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
/* Data structures defining the properties of types.
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Stanley T. Shebs.
Xconq is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version. See the file COPYING. */
#include "config.h"
#include "misc.h"
#include "lisp.h"
#include "game.h"
#ifdef offsetof
#define OFFS(TYPE,FLD) (offsetof(TYPE, FLD))
#else
#define OFFS(TYPE,FLD) \
((unsigned int) (((char *) (&(((TYPE *) NULL)->FLD))) - ((char *) NULL)))
#endif
PropertyDefn utypedefns[] = {
#undef DEF_UPROP_I
#define DEF_UPROP_I(NAME,FNAME,DOC,SLOT,LO,DFLT,HI) \
{ NAME, FNAME, NULL, NULL, OFFS(Utype, SLOT), DOC, DFLT, NULL, LO, HI },
#undef DEF_UPROP_S
#define DEF_UPROP_S(NAME,FNAME,DOC,SLOT,DFLT) \
{ NAME, NULL, FNAME, NULL, OFFS(Utype, SLOT), DOC, 0, DFLT, 0, 0 },
#undef DEF_UPROP_L
#define DEF_UPROP_L(NAME,FNAME,DOC,SLOT) \
{ NAME, NULL, NULL, FNAME, OFFS(Utype, SLOT), DOC, 0, NULL, 0, 0 },
#include "utype.def"
{ NULL }
};
PropertyDefn mtypedefns[] = {
#undef DEF_MPROP_I
#define DEF_MPROP_I(NAME,FNAME,DOC,SLOT,LO,DFLT,HI) \
{ NAME, FNAME, NULL, NULL, OFFS(Mtype, SLOT), DOC, DFLT, NULL, LO, HI },
#undef DEF_MPROP_S
#define DEF_MPROP_S(NAME,FNAME,DOC,SLOT,DFLT) \
{ NAME, NULL, FNAME, NULL, OFFS(Mtype, SLOT), DOC, 0, DFLT, 0, 0 },
#undef DEF_MPROP_L
#define DEF_MPROP_L(NAME,FNAME,DOC,SLOT) \
{ NAME, NULL, NULL, FNAME, OFFS(Mtype, SLOT), DOC, 0, NULL, 0, 0 },
#include "mtype.def"
{ NULL }
};
PropertyDefn ttypedefns[] = {
#undef DEF_TPROP_I
#define DEF_TPROP_I(NAME,FNAME,DOC,SLOT,LO,DFLT,HI) \
{ NAME, FNAME, NULL, NULL, OFFS(Ttype, SLOT), DOC, DFLT, NULL, LO, HI },
#undef DEF_TPROP_S
#define DEF_TPROP_S(NAME,FNAME,DOC,SLOT,DFLT) \
{ NAME, NULL, FNAME, NULL, OFFS(Ttype, SLOT), DOC, 0, DFLT, 0, 0 },
#undef DEF_TPROP_L
#define DEF_TPROP_L(NAME,FNAME,DOC,SLOT) \
{ NAME, NULL, NULL, FNAME, OFFS(Ttype, SLOT), DOC, 0, NULL, 0, 0 },
#include "ttype.def"
{ NULL }
};
#undef DEF_UPROP_I
#define DEF_UPROP_I(name,FNAME,doc,SLOT,lo,dflt,hi) \
int FNAME(u) int u; { checku(u); return utypes[u].SLOT; }
#undef DEF_UPROP_S
#define DEF_UPROP_S(name,FNAME,doc,SLOT,dflt) \
char *FNAME(u) int u; { checku(u); return utypes[u].SLOT; }
#undef DEF_UPROP_L
#define DEF_UPROP_L(name,FNAME,doc,SLOT) \
Obj *FNAME(u) int u; { checku(u); return utypes[u].SLOT; }
#include "utype.def"
/* Define functions for all material type properties. */
#undef DEF_MPROP_I
#define DEF_MPROP_I(name,FNAME,doc,SLOT,lo,dflt,hi) \
int FNAME(m) int m; { checkm(m); return mtypes[m].SLOT; }
#undef DEF_MPROP_S
#define DEF_MPROP_S(name,FNAME,doc,SLOT,dflt) \
char *FNAME(m) int m; { checkm(m); return mtypes[m].SLOT; }
#undef DEF_MPROP_L
#define DEF_MPROP_L(name,FNAME,doc,SLOT) \
Obj *FNAME(m) int m; { checkm(m); return mtypes[m].SLOT; }
#include "mtype.def"
/* Define functions for all terrain type properties. */
#undef DEF_TPROP_I
#define DEF_TPROP_I(name,FNAME,doc,SLOT,lo,dflt,hi) \
int FNAME(t) int t; { checkt(t); return ttypes[t].SLOT; }
#undef DEF_TPROP_S
#define DEF_TPROP_S(name,FNAME,doc,SLOT,dflt) \
char *FNAME(t) int t; { checkt(t); return ttypes[t].SLOT; }
#undef DEF_TPROP_L
#define DEF_TPROP_L(name,FNAME,doc,SLOT) \
Obj *FNAME(t) int t; { checkt(t); return ttypes[t].SLOT; }
#include "ttype.def"
/* Acquire a unit type extension property by name. */
/* (At any given time, there may be no parts of Xconq that use extension
properties, since releases will usually integrate all properties into
the normal set of property definitions ([umt]type.def). However, these
extension accessors should be kept around, so that they're available
when needed.) */
Obj *
get_u_extension(u, name, dflt)
int u;
char *name;
Obj *dflt;
{
Obj *ext = u_extensions(u), *rest, *bdg;
for_all_list(ext, rest) {
bdg = car(rest);
if (consp(bdg)
&& symbolp(car(bdg))
&& strcmp(c_string(car(bdg)), name) == 0) {
return cadr(bdg);
}
}
return dflt;
}
/* Acquire a material type extension property by name. */
Obj *
get_m_extension(m, name, dflt)
int m;
char *name;
Obj *dflt;
{
Obj *ext = m_extensions(m), *rest, *bdg;
for_all_list(ext, rest) {
bdg = car(rest);
if (consp(bdg)
&& symbolp(car(bdg))
&& strcmp(c_string(car(bdg)), name) == 0) {
return cadr(bdg);
}
}
return dflt;
}
/* Acquire a terrain type extension property by name. */
Obj *
get_t_extension(t, name, dflt)
int t;
char *name;
Obj *dflt;
{
Obj *ext = t_extensions(t), *rest, *bdg;
for_all_list(ext, rest) {
bdg = car(rest);
if (consp(bdg)
&& symbolp(car(bdg))
&& strcmp(c_string(car(bdg)), name) == 0) {
return cadr(bdg);
}
}
return dflt;
}
|