Inexor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
command.hpp
Go to the documentation of this file.
1 
5 #pragma once
6 
12 
13 enum
14 {
15  VAL_NULL = 0,
23 };
24 
25 enum
26 {
47 
48  CODE_OP_MASK = 0x3F,
49  CODE_RET = 6,
50  CODE_RET_MASK = 0xC0,
51 
52  /* return type flags */
57 };
58 
59 enum
60 {
64  ID_NOSYNC_VAR, // only cubescript var, but no flex binding (InexorTreeAPI)
68 };
69 
70 enum
71 {
72  IDF_PERSIST = 1<<0,
73  IDF_OVERRIDE = 1<<1,
74  IDF_HEX = 1<<2,
75  IDF_READONLY = 1<<3,
77  IDF_UNKNOWN = 1<<5,
78  IDF_ARG = 1<<6
79 };
80 
81 struct ident;
82 
83 struct identval
84 {
85  union
86  {
87  int i; // ID_VAR, VAL_INT
88  float f; // ID_FVAR, VAL_FLOAT
89  char *s; // ID_SVAR, VAL_STR
90  const uint *code; // VAL_CODE
91  ident *id; // VAL_IDENT
92  };
93 };
94 
95 struct tagval : identval
96 {
97  int type;
98 
99  void setint(int val) { type = VAL_INT; i = val; }
100  void setfloat(float val) { type = VAL_FLOAT; f = val; }
101  void setstr(char *val) { type = VAL_STR; s = val; }
102  void setnull() { type = VAL_NULL; i = 0; }
103  void setcode(const uint *val) { type = VAL_CODE; code = val; }
104  void setmacro(const uint *val) { type = VAL_MACRO; code = val; }
105  void setident(ident *val) { type = VAL_IDENT; id = val; }
106 
107  const char *getstr() const;
108  int getint() const;
109  float getfloat() const;
110  bool getbool() const;
111 
112  void cleanup();
113 };
114 
116 {
118  int valtype;
120 };
121 
123 {
124  SharedVar<int> *i; // ID_VAR
125  SharedVar<float> *f; // ID_FVAR
126  SharedVar<char*> *s; // ID_SVAR
127  // Non-Tree-API synced vars (only cubescript, no Tree syncing):
128  int *iold; // ID_NOSYNC_VAR
129 };
130 
131 typedef void (__cdecl *identfun)();
132 
133 struct ident
134 {
135  uchar type; // one of ID_* above
136  union
137  {
138  uchar valtype; // ID_ALIAS
139  uchar numargs; // ID_COMMAND
140  };
142  int index;
143  const char *name;
144  union
145  {
146  struct // ID_VAR, ID_FVAR, ID_SVAR
147  {
148  union
149  {
150  struct { int minval, maxval; }; // ID_VAR
151  struct { float minvalf, maxvalf; }; // ID_FVAR
152  };
153  identvalptr storage;
154  identval overrideval;
155  };
156  struct // ID_ALIAS
157  {
158  uint *code;
159  identval val;
160  identstack *stack;
161  };
162  struct // ID_COMMAND
163  {
164  const char *args;
165  uint argmask;
166  };
167  };
168  identfun fun; // ID_VAR, ID_FVAR, ID_SVAR, ID_COMMAND
169 
170  ident() {}
171  // ID_VAR
172  ident(int t, const char *n, int m, int x, SharedVar<int> *s, void *f = nullptr, int flags = 0)
173  : type(t), flags(flags | (m > x ? IDF_READONLY : 0)), name(n), minval(m), maxval(x), fun((identfun)f)
174  { storage.i = s; }
175  // ID_VAR oldschool (without InexorTree binding)
176  ident(int t, const char *n, int m, int x, int *s, void *f = nullptr, int flags = 0)
177  : type(t), flags(flags | (m > x ? IDF_READONLY : 0)), name(n), minval(m), maxval(x), fun((identfun)f)
178  { storage.iold = s; }
179  // ID_FVAR
180  ident(int t, const char *n, float m, float x, SharedVar<float> *s, void *f = nullptr, int flags = 0)
181  : type(t), flags(flags | (m > x ? IDF_READONLY : 0)), name(n), minvalf(m), maxvalf(x), fun((identfun)f)
182  { storage.f = s; }
183  // ID_SVAR
184  ident(int t, const char *n, SharedVar<char*> *s, void *f = nullptr, int flags = 0)
185  : type(t), flags(flags), name(n), fun((identfun)f)
186  { storage.s = s; }
187  // ID_ALIAS
188  ident(int t, const char *n, char *a, int flags)
189  : type(t), valtype(VAL_STR), flags(flags), name(n), code(nullptr), stack(nullptr)
190  { val.s = a; }
191  ident(int t, const char *n, int a, int flags)
192  : type(t), valtype(VAL_INT), flags(flags), name(n), code(nullptr), stack(nullptr)
193  { val.i = a; }
194  ident(int t, const char *n, float a, int flags)
195  : type(t), valtype(VAL_FLOAT), flags(flags), name(n), code(nullptr), stack(nullptr)
196  { val.f = a; }
197  ident(int t, const char *n, int flags)
198  : type(t), valtype(VAL_NULL), flags(flags), name(n), code(nullptr), stack(nullptr)
199  {}
200  ident(int t, const char *n, const tagval &v, int flags)
201  : type(t), valtype(v.type), flags(flags), name(n), code(nullptr), stack(nullptr)
202  { val = v; }
203  // ID_COMMAND
204  ident(int t, const char *n, const char *args, uint argmask, int numargs, void *f = nullptr, int flags = 0)
205  : type(t), numargs(numargs), flags(flags), name(n), args(args), argmask(argmask), fun((identfun)f)
206  {}
207 
208  void changed() { if(fun) fun(); }
209 
210  void setval(const tagval &v)
211  {
212  valtype = v.type;
213  val = v;
214  }
215 
216  void setval(const identstack &v)
217  {
218  valtype = v.valtype;
219  val = v.val;
220  }
221 
222  void forcenull()
223  {
224  if(valtype==VAL_STR) delete[] val.s;
225  valtype = VAL_NULL;
226  }
227 
228  float getfloat() const;
229  int getint() const;
230  const char *getstr() const;
231  void getval(tagval &v) const;
232 };
233 
234 extern void addident(ident *id);
235 
236 extern tagval *commandret;
237 extern const char *intstr(int v);
238 extern void intret(int v);
239 extern const char *floatstr(float v);
240 extern void floatret(float v);
241 extern void stringret(char *s);
242 extern void result(tagval &v);
243 extern void result(const char *s);
244 
245 static inline int parseint(const char *s)
246 {
247  return int(strtoul(s, nullptr, 0));
248 }
249 
250 static inline float parsefloat(const char *s)
251 {
252  // not all platforms (windows) can parse hexadecimal integers via strtod
253  char *end;
254  double val = strtod(s, &end);
255  return val || end==s || (*end!='x' && *end!='X') ? float(val) : float(parseint(s));
256 }
257 
258 static inline void intformat(char *buf, int v, int len = 20) { nformatstring(buf, len, "%d", v); }
259 static inline void floatformat(char *buf, float v, int len = 20) { nformatstring(buf, len, v==int(v) ? "%.1f" : "%.7g", v); }
260 
261 static inline const char *getstr(const identval &v, int type)
262 {
263  switch(type)
264  {
265  case VAL_STR: case VAL_MACRO: return v.s;
266  case VAL_INT: return intstr(v.i);
267  case VAL_FLOAT: return floatstr(v.f);
268  default: return "";
269  }
270 }
271 inline const char *tagval::getstr() const { return ::getstr(*this, type); }
272 inline const char *ident::getstr() const { return ::getstr(val, valtype); }
273 
274 static inline int getint(const identval &v, int type)
275 {
276  switch(type)
277  {
278  case VAL_INT: return v.i;
279  case VAL_FLOAT: return int(v.f);
280  case VAL_STR: case VAL_MACRO: return parseint(v.s);
281  default: return 0;
282  }
283 }
284 inline int tagval::getint() const { return ::getint(*this, type); }
285 inline int ident::getint() const { return ::getint(val, valtype); }
286 
287 static inline float getfloat(const identval &v, int type)
288 {
289  switch(type)
290  {
291  case VAL_FLOAT: return v.f;
292  case VAL_INT: return float(v.i);
293  case VAL_STR: case VAL_MACRO: return parsefloat(v.s);
294  default: return 0.0f;
295  }
296 }
297 inline float tagval::getfloat() const { return ::getfloat(*this, type); }
298 inline float ident::getfloat() const { return ::getfloat(val, valtype); }
299 
300 inline void ident::getval(tagval &v) const
301 {
302  switch(valtype)
303  {
304  case VAL_STR: case VAL_MACRO: v.setstr(newstring(val.s)); break;
305  case VAL_INT: v.setint(val.i); break;
306  case VAL_FLOAT: v.setfloat(val.f); break;
307  default: v.setnull(); break;
308  }
309 }
310 
311 
312 extern int variable(const char *name, int min, int cur, int max, SharedVar<int> *storage, identfun fun, int flags);
313 extern int variable(const char *name, int min, int cur, int max, int *storage, identfun fun, int flags);
314 extern float fvariable(const char *name, float min, float cur, float max, SharedVar<float> *storage, identfun fun, int flags);
315 extern char *svariable(const char *name, const char *cur, SharedVar<char*> *storage, identfun fun, int flags);
316 extern void setvar(const char *name, int i, bool dofunc = true, bool doclamp = true);
317 extern void setfvar(const char *name, float f, bool dofunc = true, bool doclamp = true);
318 extern void setsvar(const char *name, const char *str, bool dofunc = true);
319 extern void setvarchecked(ident *id, int val);
320 extern void setfvarchecked(ident *id, float val);
321 extern void setsvarchecked(ident *id, const char *val);
322 extern void touchvar(const char *name);
323 extern int getvar(const char *name);
324 extern int getvarmin(const char *name);
325 extern int getvarmax(const char *name);
326 extern bool identexists(const char *name);
327 extern ident *getident(const char *name);
328 extern ident *newident(const char *name, int flags = 0);
329 extern ident *readident(const char *name);
330 extern ident *writeident(const char *name, int flags = 0);
331 extern bool addcommand(const char *name, identfun fun, const char *narg);
332 extern bool addkeyword(int type, const char *name);
333 extern uint *compilecode(const char *p);
334 extern void keepcode(uint *p);
335 extern void freecode(uint *p);
336 extern void executeret(const uint *code, tagval &result = *commandret);
337 extern void executeret(const char *p, tagval &result = *commandret);
338 extern char *executestr(const uint *code);
339 extern char *executestr(const char *p);
340 extern int execute(const uint *code);
341 extern int execute(const char *p);
342 extern bool executebool(const uint *code);
343 extern bool executebool(const char *p);
344 extern bool execfile(const char *cfgfile, bool msg = true);
345 extern const char *getcurexecdir();
346 extern void alias(const char *name, const char *action);
347 extern void alias(const char *name, tagval &v);
348 extern const char *getalias(const char *name);
349 extern const char *escapestring(const char *s);
350 extern const char *escapeid(const char *s);
351 static inline const char *escapeid(ident &id) { return escapeid(id.name); }
352 extern bool validateblock(const char *s);
353 extern void explodelist(const char *s, vector<char *> &elems, int limit = -1);
354 extern char *indexlist(const char *s, int pos);
355 extern int listlen(const char *s);
356 extern void printvar(ident *id);
357 extern void printvar(ident *id, int i);
358 extern void printfvar(ident *id, float f);
359 extern void printsvar(ident *id, const char *s);
360 extern int clampvar(ident *id, int i, int minval, int maxval);
361 extern float clampfvar(ident *id, float f, float minval, float maxval);
362 extern void loopiter(ident *id, identstack &stack, const tagval &v);
363 extern void loopend(ident *id, identstack &stack);
364 
365 #define loopstart(id, stack) if((id)->type != ID_ALIAS) return; identstack stack;
366 static inline void loopiter(ident *id, identstack &stack, int i) { tagval v; v.setint(i); loopiter(id, stack, v); }
367 static inline void loopiter(ident *id, identstack &stack, float f) { tagval v; v.setfloat(f); loopiter(id, stack, v); }
368 static inline void loopiter(ident *id, identstack &stack, const char *s) { tagval v; v.setstr(newstring(s)); loopiter(id, stack, v); }
369 
370 
371 // nasty macros for registering script functions, abuses globals to avoid excessive infrastructure
372 #define KEYWORD(name, type) UNUSED static bool __dummy_##name = addkeyword(type, #name)
373 #define COMMANDN(name, fun, nargs) UNUSED static bool __dummy_##fun = addcommand(#name, (identfun)fun, nargs); SharedFunc(name)
374 #define COMMAND(name, nargs) COMMANDN(name, name, nargs)
375 
376 #define _VAR(name, global, min, cur, max, persist) SharedVar<int> global((int)cur); UNUSED int dummy_register_##global = variable(#name, min, cur, max, &global, NULL, persist)
377 #define _VAR_NOSYNC(name, global, min, cur, max, persist) int global((int)cur); UNUSED int dummy_register_##global = variable(#name, min, cur, max, &global, NULL, persist)
379 
380 #define VARN(name, global, min, cur, max) _VAR(name, global, min, cur, max, 0)
381 #define VARN_NOSYNC(name, global, min, cur, max) _VAR_NOSYNC(name, global, min, cur, max, 0)
382 #define VARNP(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_PERSIST)
383 #define VARNR(name, global, min, cur, max) _VAR(name, global, min, cur, max, IDF_OVERRIDE)
384 #define VAR(name, min, cur, max) _VAR(name, name, min, cur, max, 0)
385 #define VAR_NOSYNC(name, min, cur, max) _VAR_NOSYNC(name, name, min, cur, max, 0)
386 #define VARP(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_PERSIST)
387 #define VARR(name, min, cur, max) _VAR(name, name, min, cur, max, IDF_OVERRIDE)
388 #define _VARF(name, global, min, cur, max, body, persist) void var_##name(); SharedVar<int> global((int)cur); UNUSED int dummy_register_##global = variable(#name, min, cur, max, &global, var_##name, persist); void var_##name() { body; }
389 #define VARFN(name, global, min, cur, max, body) _VARF(name, global, min, cur, max, body, 0)
390 #define VARF(name, min, cur, max, body) _VARF(name, name, min, cur, max, body, 0)
391 #define VARFP(name, min, cur, max, body) _VARF(name, name, min, cur, max, body, IDF_PERSIST)
392 #define VARFR(name, min, cur, max, body) _VARF(name, name, min, cur, max, body, IDF_OVERRIDE)
393 
394 #define _HVAR(name, global, min, cur, max, persist) SharedVar<int> global(cur); UNUSED int dummy_register_##global = variable(#name, min, cur, max, &global, NULL, persist | IDF_HEX)
395 #define HVARN(name, global, min, cur, max) _HVAR(name, global, min, cur, max, 0)
396 #define HVARNP(name, global, min, cur, max) _HVAR(name, global, min, cur, max, IDF_PERSIST)
397 #define HVARNR(name, global, min, cur, max) _HVAR(name, global, min, cur, max, IDF_OVERRIDE)
398 #define HVAR(name, min, cur, max) _HVAR(name, name, min, cur, max, 0)
399 #define HVARP(name, min, cur, max) _HVAR(name, name, min, cur, max, IDF_PERSIST)
400 #define HVARR(name, min, cur, max) _HVAR(name, name, min, cur, max, IDF_OVERRIDE)
401 #define _HVARF(name, global, min, cur, max, body, persist) void var_##name(); SharedVar<int> global((int)cur); UNUSED int dummy_register_##global = variable(#name, min, cur, max, &global, var_##name, persist | IDF_HEX); void var_##name() { body; }
402 #define HVARFN(name, global, min, cur, max, body) _HVARF(name, global, min, cur, max, body, 0)
403 #define HVARF(name, min, cur, max, body) _HVARF(name, name, min, cur, max, body, 0)
404 #define HVARFP(name, min, cur, max, body) _HVARF(name, name, min, cur, max, body, IDF_PERSIST)
405 #define HVARFR(name, min, cur, max, body) _HVARF(name, name, min, cur, max, body, IDF_OVERRIDE)
406 
407 #define _FVAR(name, global, min, cur, max, persist) SharedVar<float> global((float)cur); UNUSED float dummy_register_##global = fvariable(#name, min, cur, max, &global, NULL, persist)
408 #define FVARN(name, global, min, cur, max) _FVAR(name, global, min, cur, max, 0)
409 #define FVARNP(name, global, min, cur, max) _FVAR(name, global, min, cur, max, IDF_PERSIST)
410 #define FVARNR(name, global, min, cur, max) _FVAR(name, global, min, cur, max, IDF_OVERRIDE)
411 #define FVAR(name, min, cur, max) _FVAR(name, name, min, cur, max, 0)
412 #define FVARP(name, min, cur, max) _FVAR(name, name, min, cur, max, IDF_PERSIST)
413 #define FVARR(name, min, cur, max) _FVAR(name, name, min, cur, max, IDF_OVERRIDE)
414 #define _FVARF(name, global, min, cur, max, body, persist) void var_##name(); SharedVar<float> global((float)cur); UNUSED float dummy_register_##global = fvariable(#name, min, cur, max, &global, var_##name, persist); void var_##name() { body; }
415 #define FVARFN(name, global, min, cur, max, body) _FVARF(name, global, min, cur, max, body, 0)
416 #define FVARF(name, min, cur, max, body) _FVARF(name, name, min, cur, max, body, 0)
417 #define FVARFP(name, min, cur, max, body) _FVARF(name, name, min, cur, max, body, IDF_PERSIST)
418 #define FVARFR(name, min, cur, max, body) _FVARF(name, name, min, cur, max, body, IDF_OVERRIDE)
419 
420 
421 #define _SVAR(name, global, cur, persist) SharedVar<char*> global((char *)cur); UNUSED char* dummy_register_##global = *global = (char*)svariable(#name, cur, &global, NULL, persist)
422 #define SVARN(name, global, cur) _SVAR(name, global, cur, 0)
423 #define SVARNP(name, global, cur) _SVAR(name, global, cur, IDF_PERSIST)
424 #define SVARNR(name, global, cur) _SVAR(name, global, cur, IDF_OVERRIDE)
425 #define SVAR(name, cur) _SVAR(name, name, cur, 0)
426 #define SVARP(name, cur) _SVAR(name, name, cur, IDF_PERSIST)
427 #define SVARR(name, cur) _SVAR(name, name, cur, IDF_OVERRIDE)
428 #define _SVARF(name, global, cur, body, persist) void var_##name(); SharedVar<char*> global((char*)cur); UNUSED char* dummy_register_##global = *global = (char*)svariable(#name, cur, &global, var_##name, persist); void var_##name() { body; }
429 #define SVARFN(name, global, cur, body) _SVARF(name, global, cur, body, 0)
430 #define SVARF(name, cur, body) _SVARF(name, name, cur, body, 0)
431 #define SVARFP(name, cur, body) _SVARF(name, name, cur, body, IDF_PERSIST)
432 #define SVARFR(name, cur, body) _SVARF(name, name, cur, body, IDF_OVERRIDE)
433 
434 // anonymous inline commands, uses nasty template trick with line numbers to keep names unique
435 #define ICOMMANDNS(name, cmdname, nargs, proto, b)\
436 template<int N> struct cmdname; \
437 template<> struct cmdname<__LINE__> \
438 { \
439  static bool init; \
440  static void run proto; \
441 }; \
442 bool cmdname<__LINE__>::init = addcommand(name, (identfun)cmdname<__LINE__>::run, nargs); \
443 void cmdname<__LINE__>::run proto \
444 { b; }
445 
446 #define ICOMMANDN(name, cmdname, nargs, proto, b) ICOMMANDNS(#name, cmdname, nargs, proto, b)
447 #define ICOMMANDNAME(name) _icmd_##name
448 #define ICOMMAND(name, nargs, proto, b) ICOMMANDN(name, ICOMMANDNAME(name), nargs, proto, b)
449 #define ICOMMANDSNAME _icmds_
450 #define ICOMMANDS(name, nargs, proto, b) ICOMMANDNS(name, ICOMMANDSNAME, nargs, proto, b)
451 
452 
454 
457 #define ICOMMANDERR(name, nargs, proto, b) \
458  ICOMMAND(name, nargs, proto, \
459  try { \
460  b; \
461  } catch (inexor::util::InexorException &e) { \
462  Log.std->error("EXCEPTION in {0}: {1}", #name, e.message()); \
463  } \
464  )
465 
466 enum { KR_CONSOLE = 1<<0, KR_GUI = 1<<1, KR_EDITMODE = 1<<2 };
467 
468 
470 extern int identflags;
471 
472 extern void clearoverrides();
473 extern void writecfg(const char *name = nullptr);
474 extern void loadhistory();
475 extern void writehistory();
476 
477 extern void checksleep(int millis);
478 extern void clearsleep(bool clearoverrides = true);
479 
480 
char * svariable(const char *name, const char *cur, SharedVar< char * > *storage, identfun fun, int flags)
Definition: command.cpp:542
ivec cur
Definition: octaedit.cpp:167
typedef void(APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location
static float getfloat(const identval &v, int type)
Definition: command.hpp:287
Definition: command.hpp:44
Definition: command.hpp:49
Definition: command.hpp:38
Definition: command.hpp:33
static int getint(const identval &v, int type)
Definition: command.hpp:274
void addident(ident *id)
Definition: command.cpp:348
ident(int t, const char *n, const tagval &v, int flags)
Definition: command.hpp:200
void printfvar(ident *id, float f)
Definition: command.cpp:1589
Definition: command.hpp:42
const T & max(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:224
Definition: command.hpp:44
identfun fun
Definition: command.hpp:168
void setval(const tagval &v)
Definition: command.hpp:210
void clearoverrides()
Definition: command.cpp:224
int type
Definition: command.hpp:97
Definition: command.hpp:76
Definition: command.hpp:30
Definition: command.hpp:39
Definition: command.hpp:55
unsigned int uint
Definition: cube_types.hpp:9
int clampvar(ident *id, int i, int minval, int maxval)
Definition: command.cpp:662
static float parsefloat(const char *s)
Definition: command.hpp:250
Definition: command.hpp:46
Definition: command.hpp:50
uint * compilecode(const char *p)
Definition: command.cpp:1522
int index
Definition: command.hpp:142
Definition: command.hpp:44
void loopiter(ident *id, identstack &stack, const tagval &v)
Definition: command.cpp:2455
ushort flags
Definition: command.hpp:141
Definition: command.hpp:44
int getvarmax(const char *name)
Definition: command.cpp:615
void getval(tagval &v) const
Definition: command.hpp:300
Definition: command.hpp:44
Definition: command.hpp:65
Definition: command.hpp:466
Definition: command.hpp:38
Definition: command.hpp:28
const char * getstr() const
Definition: command.hpp:272
ident(int t, const char *n, int m, int x, SharedVar< int > *s, void *f=nullptr, int flags=0)
Definition: command.hpp:172
void setint(int val)
Definition: command.hpp:99
Definition: command.hpp:73
Definition: command.hpp:32
char * executestr(const uint *code)
Definition: command.cpp:2161
void stringret(char *s)
Definition: command.cpp:2568
Definition: command.hpp:36
Definition: command.hpp:44
Definition: command.hpp:53
Definition: command.hpp:42
void changed()
Definition: command.hpp:208
ident * writeident(const char *name, int flags=0)
Definition: command.cpp:426
Definition: command.hpp:17
int getvar(const char *name)
Definition: command.cpp:603
Definition: command.hpp:39
Definition: command.hpp:78
Definition: command.hpp:30
ident * newident(const char *name, int flags=0)
Definition: command.cpp:411
Definition: command.hpp:35
Definition: command.hpp:38
Definition: command.hpp:74
Definition: command.hpp:44
Definition: command.hpp:43
void explodelist(const char *s, vector< char * > &elems, int limit=-1)
Definition: command.cpp:2656
float getfloat() const
Definition: command.hpp:297
Definition: command.hpp:466
void touchvar(const char *name)
Definition: command.cpp:640
int valtype
Definition: command.hpp:118
bool executebool(const uint *code)
Definition: command.cpp:2241
ident()
Definition: command.hpp:170
const char * intstr(int v)
Definition: command.cpp:2411
Definition: command.hpp:45
void printvar(ident *id)
Definition: command.cpp:1599
Definition: command.hpp:122
Definition: command.hpp:21
int getint() const
Definition: command.hpp:285
tagval * commandret
Definition: command.cpp:173
SharedVar< char * > * s
Definition: command.hpp:126
#define __cdecl
Definition: cube_tools.hpp:51
void setsvarchecked(ident *id, const char *val)
Definition: command.cpp:722
void setfloat(float val)
Definition: command.hpp:100
ICOMMAND * f(float *a, float *b), floatret(*a **b)
int execute(const uint *code)
Definition: command.cpp:2179
bool addkeyword(int type, const char *name)
Definition: command.cpp:758
Definition: command.hpp:61
Definition: command.hpp:48
Definition: command.hpp:42
Definition: command.hpp:66
int getint() const
Definition: command.hpp:284
unsigned short ushort
Definition: cube_types.hpp:8
Definition: command.hpp:19
Definition: command.hpp:63
Definition: command.hpp:115
float clampfvar(ident *id, float f, float minval, float maxval)
Definition: command.cpp:694
Definition: command.hpp:20
void alias(const char *name, const char *action)
Definition: command.cpp:504
void nformatstring(char *d, int len, const char *fmt,...) PRINTFARGS(3
Definition: cube_formatting.hpp:33
void setident(ident *val)
Definition: command.hpp:105
bool identexists(const char *name)
Definition: command.cpp:637
static int parseint(const char *s)
Definition: command.hpp:245
Definition: command.hpp:83
Definition: command.hpp:56
Definition: command.hpp:42
Definition: command.hpp:75
Definition: command.hpp:64
void cleanup()
Definition: command.cpp:148
bool execfile(const char *cfgfile, bool msg=true)
Definition: command.cpp:2262
Definition: command.hpp:44
void intret(int v)
Definition: command.cpp:2418
void executeret(const uint *code, tagval &result=*commandret)
Definition: command.cpp:2147
Definition: command.hpp:15
void forcenull()
Definition: command.hpp:222
Definition: command.hpp:77
static const char * getstr(const identval &v, int type)
Definition: command.hpp:261
const T & min(const inexor::rpc::SharedVar< T > &a, const T &b)
Definition: SharedVar.hpp:210
void setcode(const uint *val)
Definition: command.hpp:103
static void intformat(char *buf, int v, int len=20)
Definition: command.hpp:258
char * indexlist(const char *s, int pos)
Definition: command.cpp:2663
Definition: command.hpp:54
bool validateblock(const char *s)
Definition: command.cpp:2332
ident * readident(const char *name)
Definition: command.cpp:437
int identflags
Definition: command.cpp:41
SharedVar< float > * f
Definition: command.hpp:125
Definition: command.hpp:466
Definition: command.hpp:30
const char * getcurexecdir()
Definition: command.cpp:2260
Definition: command.hpp:62
Definition: command.hpp:133
void setstr(char *val)
Definition: command.hpp:101
Definition: command.hpp:29
Definition: command.hpp:39
void checksleep(int millis)
Definition: command.cpp:3235
void t(T x, const char *cmp)
Definition: utilTest.cpp:52
void setvarchecked(ident *id, int val)
Definition: command.cpp:674
void writecfg(const char *name=nullptr)
Definition: command.cpp:2350
ident(int t, const char *n, const char *args, uint argmask, int numargs, void *f=nullptr, int flags=0)
Definition: command.hpp:204
Definition: command.hpp:40
ident(int t, const char *n, int a, int flags)
Definition: command.hpp:191
int getvarmin(const char *name)
Definition: command.cpp:609
Definition: command.hpp:72
Definition: command.hpp:22
unsigned char uchar
Basic type definitions.
Definition: cube_types.hpp:7
Definition: command.hpp:18
bool addcommand(const char *name, identfun fun, const char *narg)
Definition: command.cpp:740
Definition: command.hpp:34
const char * getstr() const
Definition: command.hpp:271
void setsvar(const char *name, const char *str, bool dofunc=true)
Definition: command.cpp:596
int listlen(const char *s)
Definition: command.cpp:2670
void setval(const identstack &v)
Definition: command.hpp:216
Definition: command.hpp:16
void setfvar(const char *name, float f, bool dofunc=true, bool doclamp=true)
Definition: command.cpp:588
void loopend(ident *id, identstack &stack)
Definition: command.cpp:2470
int end()
Definition: glemu.cpp:256
void writehistory()
Definition: console.cpp:382
void printsvar(ident *id, const char *s)
Definition: command.cpp:1594
Definition: command.hpp:27
Definition: command.hpp:67
uchar type
Definition: command.hpp:135
SharedVar< int > * i
Definition: command.hpp:124
void(__cdecl * identfun)()
Definition: command.hpp:131
hashnameset< ident > idents
Definition: command.cpp:37
void setfvarchecked(ident *id, float val)
Definition: command.cpp:703
Definition: command.hpp:31
Definition: command.hpp:44
float getfloat() const
Definition: command.hpp:298
uchar flags[MAXBRUSH][MAXBRUSH]
Definition: octaedit.cpp:1742
void result(tagval &v)
Definition: command.cpp:2562
Definition: command.hpp:39
ident * getident(const char *name)
Definition: command.cpp:638
static void floatformat(char *buf, float v, int len=20)
Definition: command.hpp:259
const char * floatstr(float v)
Definition: command.cpp:2423
const char * escapeid(const char *s)
Definition: command.cpp:2326
void setvar(const char *name, int i, bool dofunc=true, bool doclamp=true)
Definition: command.cpp:569
SharedVar wrapper for primitive/immutable objects.
Definition: SharedVar.hpp:55
void setmacro(const uint *val)
Definition: command.hpp:104
void freecode(uint *p)
Definition: command.cpp:1554
Definition: command.hpp:37
Definition: command.hpp:43
Definition: command.hpp:40
void clearsleep(bool clearoverrides=true)
Definition: command.cpp:3254
float fvariable(const char *name, float min, float cur, float max, SharedVar< float > *storage, identfun fun, int flags)
Definition: command.cpp:536
const char * escapestring(const char *s)
Definition: command.cpp:2296
const char * getalias(const char *name)
Definition: command.cpp:654
ident(int t, const char *n, SharedVar< char * > *s, void *f=nullptr, int flags=0)
Definition: command.hpp:184
Definition: cube_hash.hpp:224
ident(int t, const char *n, float a, int flags)
Definition: command.hpp:194
void keepcode(uint *p)
Definition: command.cpp:1533
identval val
Definition: command.hpp:117
Definition: command.hpp:41
ident(int t, const char *n, char *a, int flags)
Definition: command.hpp:188
char * newstring(size_t l)
Definition: cube_tools.hpp:71
int * iold
Definition: command.hpp:128
int variable(const char *name, int min, int cur, int max, SharedVar< int > *storage, identfun fun, int flags)
Definition: command.cpp:524
Definition: command.hpp:40
void loadhistory()
Definition: console.cpp:395
void floatret(float v)
Definition: command.cpp:2430
identstack * next
Definition: command.hpp:119
Definition: command.hpp:41
ident(int t, const char *n, int flags)
Definition: command.hpp:197
void setnull()
Definition: command.hpp:102
ident(int t, const char *n, float m, float x, SharedVar< float > *s, void *f=nullptr, int flags=0)
Definition: command.hpp:180
Definition: command.hpp:40
ident(int t, const char *n, int m, int x, int *s, void *f=nullptr, int flags=0)
Definition: command.hpp:176
Definition: command.hpp:95
const char * name
Definition: command.hpp:143
bool getbool() const