1 // script binding functionality 2 3 4 enum { ID_VAR, ID_FVAR, ID_SVAR, ID_COMMAND, ID_CCOMMAND, ID_ALIAS }; 5 6 enum { NO_OVERRIDE = INT_MAX, OVERRIDDEN = 0 }; 7 8 enum { IDF_PERSIST = 1<<0, IDF_OVERRIDE = 1<<1, IDF_WORLD = 1<<2, IDF_COMPLETE = 1<<3, IDF_TEXTURE = 1<<4, IDF_CLIENT = 1<<5, IDF_SERVER = 1<<6, IDF_AUTO = 1<<7, IDF_HEX = 1<<8 }; 9 10 struct identstack 11 { 12 char *action; 13 identstack *next; 14 }; 15 16 union identval 17 { 18 int i; // ID_VAR 19 float f; // ID_FVAR 20 char *s; // ID_SVAR 21 }; 22 23 union identvalptr 24 { 25 int *i; // ID_VAR 26 float *f; // ID_FVAR 27 char **s; // ID_SVAR 28 }; 29 30 struct ident 31 { 32 int type; // one of ID_* above 33 const char *name; 34 union 35 { 36 int minval; // ID_VAR 37 float minvalf; // ID_FVAR 38 }; 39 union 40 { 41 int maxval; // ID_VAR 42 float maxvalf; // ID_FVAR 43 }; 44 int override; // either NO_OVERRIDE, OVERRIDDEN, or value 45 union 46 { 47 void (__cdecl *fun)(); // ID_VAR, ID_COMMAND, ID_CCOMMAND 48 identstack *stack; // ID_ALIAS 49 }; 50 union 51 { 52 const char *narg; // ID_COMMAND, ID_CCOMMAND 53 char *action; // ID_ALIAS 54 identval val;// ID_VAR, ID_FVAR, ID_SVAR 55 }; 56 union 57 { 58 void *self; // ID_COMMAND, ID_CCOMMAND 59 char *isexecuting; // ID_ALIAS 60 identval overrideval; // ID_VAR, ID_FVAR, ID_SVAR 61 }; 62 identval def; 63 identvalptr storage; // ID_VAR, ID_FVAR, ID_SVAR 64 int flags; 65 identident66 ident() {} 67 // ID_VAR 68 ident(int t, const char *n, int m, int c, int x, int *s, void *f, int flags = IDF_COMPLETE) typeident69 : type(t), name(n), minval(m), maxval(x), override(NO_OVERRIDE), fun((void (__cdecl *)())f), flags(flags) 70 { val.i = def.i = c; storage.i = s; } 71 // ID_FVAR 72 ident(int t, const char *n, float m, float c, float x, float *s, void *f, int flags = IDF_COMPLETE) typeident73 : type(t), name(n), minvalf(m), maxvalf(x), override(NO_OVERRIDE), fun((void (__cdecl *)())f), flags(flags) 74 { val.f = def.f = c; storage.f = s; } 75 // ID_SVAR 76 ident(int t, const char *n, char *d, char *c, char **s, void *f, int flags = IDF_COMPLETE) typeident77 : type(t), name(n), override(NO_OVERRIDE), fun((void (__cdecl *)())f), flags(flags) 78 { val.s = c; def.s = d; storage.s = s; } 79 // ID_ALIAS identident80 ident(int t, const char *n, char *a, int flags) 81 : type(t), name(n), override(NO_OVERRIDE), stack(NULL), action(a), isexecuting(NULL), flags(flags) {} 82 // ID_COMMAND, ID_CCOMMAND 83 ident(int t, const char *n, const char *narg, void *f, void *s, int flags = IDF_COMPLETE) typeident84 : type(t), name(n), override(NO_OVERRIDE), fun((void (__cdecl *)(void))f), narg(narg), self(s), flags(flags) {} 85 ~identident86 virtual ~ident() {} 87 88 ident &operator=(const ident &o) { memcpy(this, &o, sizeof(ident)); return *this; } // force vtable copy, ugh 89 changedident90 virtual void changed() { if(fun) fun(); } 91 }; 92 93 extern void addident(const char *name, ident *id); 94 extern void intret(int v); 95 extern const char *floatstr(float v); 96 extern void floatret(float v); 97 extern void result(const char *s); 98 99 typedef hashtable<const char *, ident> identtable; 100 extern identtable *idents; 101 102 extern int variable(const char *name, int min, int cur, int max, int *storage, void (*fun)(), int flags); 103 extern float fvariable(const char *name, float min, float cur, float max, float *storage, void (*fun)(), int flags); 104 extern char *svariable(const char *name, const char *cur, char **storage, void (*fun)(), int flags); 105 extern void setvar(const char *name, int i, bool dofunc = false); 106 extern void setfvar(const char *name, float f, bool dofunc = false); 107 extern void setsvar(const char *name, const char *str, bool dofunc = false); 108 extern void touchvar(const char *name); 109 extern int getvar(const char *name); 110 extern int getvarmin(const char *name); 111 extern int getvarmax(const char *name); 112 extern bool identexists(const char *name); 113 extern ident *getident(const char *name); 114 extern bool addcommand(const char *name, void (*fun)(), const char *narg); 115 116 extern int execute(const char *p); 117 extern char *executeret(const char *p); 118 extern bool execfile(const char *cfgfile, bool msg = true); 119 extern void alias(const char *name, const char *action); 120 extern void worldalias(const char *name, const char *action); 121 extern const char *getalias(const char *name); 122 123 extern bool overrideidents, persistidents, worldidents, interactive; 124 125 extern char *parseword(const char *&p, int arg, int &infix); 126 extern char *parsetext(const char *&p); 127 extern void writeescapedstring(stream *f, const char *s); 128 extern void explodelist(const char *s, vector<char *> &elems); 129 extern int listlen(const char *s); 130 extern char *indexlist(const char *s, int pos); 131 132 extern void clearoverrides(); 133 #ifndef STANDALONE 134 extern void writecfg(); 135 #endif 136 137 extern void checksleep(int millis); 138 extern void clearsleep(bool clearoverrides = true, bool clearworlds = false); 139 140 // nasty macros for registering script functions, abuses globals to avoid excessive infrastructure 141 #define COMMANDN(name, fun, nargs) static bool __dummy_##fun = addcommand(#name, (void (*)())fun, nargs) 142 #define COMMAND(name, nargs) COMMANDN(name, name, nargs) 143 144 #define _VAR(name, global, min, cur, max, persist) int global = variable(#name, min, cur, max, &global, NULL, persist) 145 #define VARN(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_COMPLETE) 146 #define VARNP(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_PERSIST|IDF_COMPLETE) 147 #define VARNR(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_OVERRIDE|IDF_COMPLETE) 148 #define VARNW(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_WORLD|IDF_COMPLETE) 149 #define VARNA(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_PERSIST|IDF_AUTO|IDF_COMPLETE) 150 #define VAR(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_COMPLETE) 151 #define VARP(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_PERSIST|IDF_COMPLETE) 152 #define VARR(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_OVERRIDE|IDF_COMPLETE) 153 #define VARW(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_WORLD|IDF_COMPLETE) 154 #define VARA(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_PERSIST|IDF_AUTO|IDF_COMPLETE) 155 #define _VARF(name, global, min, cur, max, body, persist) void var_##name(); int global = variable(#name, min, cur, max, &global, var_##name, persist); void var_##name() { body; } 156 #define VARFN(name, global, min, cur, max, body) _VARF(name, global, min, cur, max, body, IDF_COMPLETE) 157 #define VARF(name, min, cur, max, body) _VARF(name, name, min, cur, max, body, IDF_COMPLETE) 158 #define VARFP(name, min, cur, max, body) _VARF(name, name, min, cur, max, body, IDF_PERSIST|IDF_COMPLETE) 159 #define VARFR(name, min, cur, max, body) _VARF(name, name, min, cur, max, body, IDF_OVERRIDE|IDF_COMPLETE) 160 #define VARFW(name, min, cur, max, body) _VARF(name, name, min, cur, max, body, IDF_WORLD|IDF_COMPLETE) 161 #define VARFA(name, min, cur, max, body) _VARF(name, name, min, cur, max, body, IDF_PERSIST|IDF_AUTO|IDF_COMPLETE) 162 163 #define _HVAR(name, global, min, cur, max, persist) int global = variable(#name, min, cur, max, &global, NULL, persist | IDF_HEX) 164 #define HVARN(name, global, min, cur, max) _HVAR(name, global, min, cur, max, IDF_COMPLETE) 165 #define HVARNP(name, global, min, cur, max) _HVAR(name, global, min, cur, max, IDF_PERSIST|IDF_COMPLETE) 166 #define HVARNR(name, global, min, cur, max) _HVAR(name, global, min, cur, max, IDF_OVERRIDE|IDF_COMPLETE) 167 #define HVARNW(name, global, min, cur, max) _HVAR(name, global, min, cur, max, IDF_WORLD|IDF_COMPLETE) 168 #define HVARNA(name, global, min, cur, max) _HVAR(name, global, min, cur, max, IDF_PERSIST|IDF_AUTO|IDF_COMPLETE) 169 #define HVAR(name, min, cur, max) _HVAR(name, name, min, cur, max, IDF_COMPLETE) 170 #define HVARP(name, min, cur, max) _HVAR(name, name, min, cur, max, IDF_PERSIST|IDF_COMPLETE) 171 #define HVARR(name, min, cur, max) _HVAR(name, name, min, cur, max, IDF_OVERRIDE|IDF_COMPLETE) 172 #define HVARW(name, min, cur, max) _HVAR(name, name, min, cur, max, IDF_WORLD|IDF_COMPLETE) 173 #define HVARA(name, min, cur, max) _HVAR(name, name, min, cur, max, IDF_PERSIST|IDF_AUTO|IDF_COMPLETE) 174 #define _HVARF(name, global, min, cur, max, body, persist) void var_##name(); int global = variable(#name, min, cur, max, &global, var_##name, persist | IDF_HEX); void var_##name() { body; } 175 #define HVARFN(name, global, min, cur, max, body) _HVARF(name, global, min, cur, max, body, IDF_COMPLETE) 176 #define HVARF(name, min, cur, max, body) _HVARF(name, name, min, cur, max, body, IDF_COMPLETE) 177 #define HVARFP(name, min, cur, max, body) _HVARF(name, name, min, cur, max, body, IDF_PERSIST|IDF_COMPLETE) 178 #define HVARFR(name, min, cur, max, body) _HVARF(name, name, min, cur, max, body, IDF_OVERRIDE|IDF_COMPLETE) 179 #define HVARFW(name, min, cur, max, body) _HVARF(name, name, min, cur, max, body, IDF_WORLD|IDF_COMPLETE) 180 #define HVARFA(name, min, cur, max, body) _HVARF(name, name, min, cur, max, body, IDF_PERSIST|IDF_AUTO|IDF_COMPLETE) 181 182 #define _FVAR(name, global, min, cur, max, persist) float global = fvariable(#name, min, cur, max, &global, NULL, persist) 183 #define FVARN(name, global, min, cur, max) _FVAR(name, global, min, cur, max, IDF_COMPLETE) 184 #define FVARNP(name, global, min, cur, max) _FVAR(name, global, min, cur, max, IDF_PERSIST|IDF_COMPLETE) 185 #define FVARNR(name, global, min, cur, max) _FVAR(name, global, min, cur, max, IDF_OVERRIDE|IDF_COMPLETE) 186 #define FVARNW(name, global, min, cur, max) _FVAR(name, global, min, cur, max, IDF_WORLD|IDF_COMPLETE) 187 #define FVAR(name, min, cur, max) _FVAR(name, name, min, cur, max, IDF_COMPLETE) 188 #define FVARP(name, min, cur, max) _FVAR(name, name, min, cur, max, IDF_PERSIST|IDF_COMPLETE) 189 #define FVARR(name, min, cur, max) _FVAR(name, name, min, cur, max, IDF_OVERRIDE|IDF_COMPLETE) 190 #define FVARW(name, min, cur, max) _FVAR(name, name, min, cur, max, IDF_WORLD|IDF_COMPLETE) 191 #define _FVARF(name, global, min, cur, max, body, persist) void var_##name(); float global = fvariable(#name, min, cur, max, &global, var_##name, persist); void var_##name() { body; } 192 #define FVARFN(name, global, min, cur, max, body) _FVARF(name, global, min, cur, max, body, IDF_COMPLETE) 193 #define FVARF(name, min, cur, max, body) _FVARF(name, name, min, cur, max, body, IDF_COMPLETE) 194 #define FVARFP(name, min, cur, max, body) _FVARF(name, name, min, cur, max, body, IDF_PERSIST|IDF_COMPLETE) 195 #define FVARFR(name, min, cur, max, body) _FVARF(name, name, min, cur, max, body, IDF_OVERRIDE|IDF_COMPLETE) 196 #define FVARFW(name, min, cur, max, body) _FVARF(name, name, min, cur, max, body, IDF_WORLD|IDF_COMPLETE) 197 198 #define _SVAR(name, global, cur, persist) char *global = svariable(#name, cur, &global, NULL, persist) 199 #define SVARN(name, global, cur) _SVAR(name, global, cur, IDF_COMPLETE) 200 #define SVARNP(name, global, cur) _SVAR(name, global, cur, IDF_PERSIST|IDF_COMPLETE) 201 #define SVARNR(name, global, cur) _SVAR(name, global, cur, IDF_OVERRIDE|IDF_COMPLETE) 202 #define SVARNW(name, global, cur) _SVAR(name, global, cur, IDF_WORLD|IDF_COMPLETE) 203 #define SVAR(name, cur) _SVAR(name, name, cur, IDF_COMPLETE) 204 #define SVARP(name, cur) _SVAR(name, name, cur, IDF_PERSIST|IDF_COMPLETE) 205 #define SVARR(name, cur) _SVAR(name, name, cur, IDF_OVERRIDE|IDF_COMPLETE) 206 #define SVARW(name, cur) _SVAR(name, name, cur, IDF_WORLD|IDF_COMPLETE) 207 #define _SVARF(name, global, cur, body, persist) void var_##name(); char *global = svariable(#name, cur, &global, var_##name, persist); void var_##name() { body; } 208 #define SVARFN(name, global, cur, body) _SVARF(name, global, cur, body, IDF_COMPLETE) 209 #define SVARF(name, cur, body) _SVARF(name, name, cur, body, IDF_COMPLETE) 210 #define SVARFP(name, cur, body) _SVARF(name, name, cur, body, IDF_PERSIST|IDF_COMPLETE) 211 #define SVARFR(name, cur, body) _SVARF(name, name, cur, body, IDF_OVERRIDE|IDF_COMPLETE) 212 #define SVARFW(name, cur, body) _SVARF(name, name, cur, body, IDF_WORLD|IDF_COMPLETE) 213 214 // new style macros, have the body inline, and allow binds to happen anywhere, even inside class constructors, and access the surrounding class 215 #define _COMMAND(idtype, tv, n, m, g, proto, b, f) \ 216 struct cmd_##m : ident \ 217 { \ 218 cmd_##m(void *self = NULL) : ident(idtype, #n, g, (void *)run, self, f) \ 219 { \ 220 addident(name, this); \ 221 } \ 222 static void run proto { b; } \ 223 } icom_##m tv 224 #define ICOMMAND(n, g, proto, b) _COMMAND(ID_COMMAND, , n, n, g, proto, b, IDF_COMPLETE) 225 #define ICOMMANDN(n, name, g, proto, b) _COMMAND(ID_COMMAND, , n, name, g, proto, b, IDF_COMPLETE) 226 #define CCOMMAND(n, g, proto, b) _COMMAND(ID_CCOMMAND, (this), n, n, g, proto, b, IDF_COMPLETE) 227 #define CCOMMANDN(n, name, g, proto, b) _COMMAND(ID_CCOMMAND, (this), n, name, g, proto, b, IDF_COMPLETE) 228 229 #define _IVAR(n, m, c, x, b, p) \ 230 struct var_##n : ident \ 231 { \ 232 var_##n() : ident(ID_VAR, #n, m, c, x, &val.i, (void *)NULL, p) \ 233 { \ 234 addident(name, this); \ 235 } \ 236 int operator()() { return val.i; } \ 237 b \ 238 } n 239 #define IVAR(n, m, c, x) _IVAR(n, m, c, x, , IDF_COMPLETE) 240 #define IVARF(n, m, c, x, b) _IVAR(n, m, c, x, void changed() { b; }, IDF_COMPLETE) 241 #define IVARP(n, m, c, x) _IVAR(n, m, c, x, , IDF_PERSIST|IDF_COMPLETE) 242 #define IVARR(n, m, c, x) _IVAR(n, m, c, x, , IDF_OVERRIDE|IDF_COMPLETE) 243 #define IVARW(n, m, c, x) _IVAR(n, m, c, x, , IDF_WORLD|IDF_COMPLETE) 244 #define IVARA(n, m, c, x) _IVAR(n, m, c, x, , IDF_PERSIST|IDF_AUTO|IDF_COMPLETE) 245 #define IVARFP(n, m, c, x, b) _IVAR(n, m, c, x, void changed() { b; }, IDF_PERSIST|IDF_COMPLETE) 246 #define IVARFR(n, m, c, x, b) _IVAR(n, m, c, x, void changed() { b; }, IDF_OVERRIDE|IDF_COMPLETE) 247 #define IVARFW(n, m, c, x, b) _IVAR(n, m, c, x, void changed() { b; }, IDF_WORLD|IDF_COMPLETE) 248 #define IVARFA(n, m, c, x, b) _IVAR(n, m, c, x, void changed() { b; }, IDF_PERSIST|IDF_AUTO|IDF_COMPLETE) 249 250 #define _IFVAR(n, m, c, x, b, p) \ 251 struct var_##n : ident \ 252 { \ 253 var_##n() : ident(ID_FVAR, #n, m, c, x, &val.f, (void *)NULL, p) \ 254 { \ 255 addident(name, this); \ 256 } \ 257 float operator()() { return val.f; } \ 258 b \ 259 } n 260 #define IFVAR(n, m, c, x) _IFVAR(n, m, c, x, , IDF_COMPLETE) 261 #define IFVARF(n, m, c, x, b) _IFVAR(n, m, c, x, void changed() { b; }, IDF_COMPLETE) 262 #define IFVARP(n, m, c, x) _IFVAR(n, m, c, x, , IDF_PERSIST|IDF_COMPLETE) 263 #define IFVARR(n, m, c, x) _IFVAR(n, m, c, x, , IDF_OVERRIDE|IDF_COMPLETE) 264 #define IFVARW(n, m, c, x) _IFVAR(n, m, c, x, , IDF_WORLD|IDF_COMPLETE) 265 #define IFVARFP(n, m, c, x, b) _IFVAR(n, m, c, x, void changed() { b; }, IDF_PERSIST|IDF_COMPLETE) 266 #define IFVARFR(n, m, c, x, b) _IFVAR(n, m, c, x, void changed() { b; }, IDF_OVERRIDE|IDF_COMPLETE) 267 #define IFVARFW(n, m, c, x, b) _IFVAR(n, m, c, x, void changed() { b; }, IDF_WORLD|IDF_COMPLETE) 268 269 #define _ISVAR(n, c, b, p) \ 270 struct var_##n : ident \ 271 { \ 272 var_##n() : ident(ID_SVAR, #n, newstring(c), newstring(c), &val.s, (void *)NULL, p) \ 273 { \ 274 addident(name, this); \ 275 } \ 276 char *operator()() { return val.s; } \ 277 b \ 278 } n 279 #define ISVAR(n, c) _ISVAR(n, c, , IDF_COMPLETE) 280 #define ISVARF(n, c, b) _ISVAR(n, c, void changed() { b; }, IDF_COMPLETE) 281 #define ISVARP(n, c) _ISVAR(n, c, , IDF_PERSIST|IDF_COMPLETE) 282 #define ISVARR(n, c) _ISVAR(n, c, , IDF_OVERRIDE|IDF_COMPLETE) 283 #define ISVARW(n, c) _ISVAR(n, c, , IDF_WORLD|IDF_COMPLETE) 284 #define ISVARFP(n, c, b) _ISVAR(n, c, void changed() { b; }, IDF_PERSIST|IDF_COMPLETE) 285 #define ISVARFR(n, c, b) _ISVAR(n, c, void changed() { b; }, IDF_OVERRIDE|IDF_COMPLETE) 286 #define ISVARFW(n, c, b) _ISVAR(n, c, void changed() { b; }, IDF_WORLD|IDF_COMPLETE) 287 288 // game world controlling stuff 289 #define RUNWORLD(n) { ident *wid = idents->access(n); if(wid && wid->action && wid->flags&IDF_WORLD) { bool _oldworldidents = worldidents; worldidents = true; execute(wid->action); worldidents = _oldworldidents; }; } 290 #if defined(GAMEWORLD) 291 #define ICOMMANDG(n, g, proto, b) _COMMAND(ID_COMMAND, , n, n, g, proto, b, IDF_CLIENT|IDF_COMPLETE) 292 #define ICOMMANDNG(n, name, g, proto, b) _COMMAND(ID_COMMAND, , n, name, g, proto, b, IDF_CLIENT|IDF_COMPLETE) 293 #define CCOMMANDG(n, g, proto, b) _COMMAND(ID_CCOMMAND, (this), n, n, g, proto, b, IDF_CLIENT|IDF_COMPLETE) 294 #define CCOMMANDNG(n, name, g, proto, b) _COMMAND(ID_CCOMMAND, (this), n, name, g, proto, b, IDF_CLIENT|IDF_COMPLETE) 295 #define VARNG(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_CLIENT|IDF_COMPLETE) 296 #define VARG(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_CLIENT|IDF_COMPLETE) 297 #define VARFG(name, min, cur, max, svbody, ccbody) _VARF(name, name, min, cur, max, ccbody, IDF_CLIENT|IDF_COMPLETE) 298 #define HVARNG(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_CLIENT|IDF_COMPLETE|IDF_HEX) 299 #define HVARG(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_CLIENT|IDF_COMPLETE|IDF_HEX) 300 #define HVARFG(name, min, cur, max, svbody, ccbody) _VARF(name, name, min, cur, max, ccbody, IDF_CLIENT|IDF_COMPLETE|IDF_HEX) 301 #define FVARNG(name, global, min, cur, max) _FVAR(name, global, min, cur, max, IDF_CLIENT|IDF_COMPLETE) 302 #define FVARG(name, min, cur, max) _FVAR(name, name, min, cur, max, IDF_CLIENT|IDF_COMPLETE) 303 #define FVARFG(name, min, cur, max, svbody, ccbody) _FVARF(name, name, min, cur, max, ccbody, IDF_CLIENT|IDF_COMPLETE) 304 #define SVARNG(name, global, cur) _SVAR(name, global, cur, IDF_CLIENT|IDF_COMPLETE) 305 #define SVARG(name, cur) _SVAR(name, name, cur, IDF_CLIENT|IDF_COMPLETE) 306 #define SVARFG(name, cur, svbody, ccbody) _SVARF(name, name, cur, ccbody, IDF_CLIENT|IDF_COMPLETE) 307 #elif defined(GAMESERVER) 308 #define ICOMMANDG(n, g, proto, b) _COMMAND(ID_COMMAND, , sv_##n, sv_##n, g, proto, b, IDF_SERVER) 309 #define ICOMMANDNG(n, name, g, proto, b) _COMMAND(ID_COMMAND, , sv_##n, sv_##name, g, proto, b, IDF_SERVER) 310 #define CCOMMANDG(n, g, proto, b) _COMMAND(ID_CCOMMAND, (this), sv_##n, sv_##n, g, proto, b, IDF_SERVER) 311 #define CCOMMANDNG(n, name, g, proto, b) _COMMAND(ID_CCOMMAND, (this), sv_##n, sv_##name, g, proto, b, IDF_SERVER) 312 #define VARNG(name, global, min, cur, max) _VAR(sv_##name, sv_##global, min, cur, max, IDF_SERVER) 313 #define VARG(name, min, cur, max) _VAR(sv_##name, sv_##name, min, cur, max, IDF_SERVER) 314 #define VARFG(name, min, cur, max, svbody, ccbody) _VARF(sv_##name, sv_##name, min, cur, max, svbody, IDF_SERVER) 315 #define HVARNG(name, global, min, cur, max) _VAR(sv_##name, sv_##global, min, cur, max, IDF_SERVER|IDF_HEX) 316 #define HVARG(name, min, cur, max) _VAR(sv_##name, sv_##name, min, cur, max, IDF_SERVER|IDF_HEX) 317 #define HVARFG(name, min, cur, max, svbody, ccbody) _VARF(sv_##name, sv_##name, min, cur, max, svbody, IDF_SERVER|IDF_HEX) 318 #define FVARNG(name, global, min, cur, max) _FVAR(sv_##name, sv_##global, min, cur, max, IDF_SERVER) 319 #define FVARG(name, min, cur, max) _FVAR(sv_##name, sv_##name, min, cur, max, IDF_SERVER) 320 #define FVARFG(name, min, cur, max, svbody, ccbody) _FVARF(sv_##name, sv_##name, min, cur, max, svbody, IDF_SERVER) 321 #define SVARNG(name, global, cur) _SVAR(sv_##name, sv_##global, cur, IDF_SERVER) 322 #define SVARG(name, cur) _SVAR(sv_##name, sv_##name, cur, IDF_SERVER) 323 #define SVARFG(name, cur, svbody, ccbody) _SVARF(sv_##name, sv_##name, cur, svbody, IDF_SERVER) 324 #else 325 #define VARNG(name, global, min, cur, max) extern int name 326 #define VARG(name, min, cur, max) extern int name 327 #define VARFG(name, min, cur, max, svbody, ccbody) extern int name 328 #define HVARNG(name, global, min, cur, max) extern int name 329 #define HVARG(name, min, cur, max) extern int name 330 #define HVARFG(name, min, cur, max, svbody, ccbody) extern int name 331 #define FVARNG(name, global, min, cur, max) extern float name 332 #define FVARG(name, min, cur, max) extern float name 333 #define FVARFG(name, min, cur, max, svbody, ccbody) extern float name 334 #define SVARNG(name, global, cur) extern char *name 335 #define SVARG(name, cur) extern char *name 336 #define SVARFG(name, cur, svbody, ccbody) extern char *name 337 #endif 338