69 float i, j, f,
f2, f3, rpnpos;
84 for(rpnpos = 1; rpnpos < argc; ++rpnpos)
86 rpncmd =
argv(rpnpos);
91 }
else if(
substring(rpncmd, 0, 1) ==
"0") {
93 }
else if(f >= 2 &&
substring(rpncmd, 0, 1) ==
"+") {
95 }
else if(f >= 2 &&
substring(rpncmd, 0, 1) ==
"-") {
97 }
else if(f >= 2 &&
substring(rpncmd, 0, 1) ==
"/") {
99 }
else if(rpncmd ==
"clear") {
101 }
else if(rpncmd ==
"def" || rpncmd ==
"=") {
117 LOG_INFO(
"rpn: empty cvar name for 'def'");
120 }
else if(rpncmd ==
"defs" || rpncmd ==
"@") {
124 while(
rpn_sp > 1 && (j || i > 0))
142 LOG_INFO(
"rpn: empty cvar name for 'defs'");
145 }
else if(rpncmd ==
"load") {
147 }
else if(rpncmd ==
"exch") {
152 }
else if(rpncmd ==
"dup") {
154 }
else if(rpncmd ==
"pop") {
156 }
else if(rpncmd ==
"add" || rpncmd ==
"+") {
159 }
else if(rpncmd ==
"sub" || rpncmd ==
"-") {
162 }
else if(rpncmd ==
"mul" || rpncmd ==
"*") {
165 }
else if(rpncmd ==
"div" || rpncmd ==
"/") {
168 }
else if(rpncmd ==
"mod" || rpncmd ==
"%") {
172 }
else if(rpncmd ==
"pow" || rpncmd ==
"**") {
175 }
else if(rpncmd ==
"bitand" || rpncmd ==
"&") {
178 }
else if(rpncmd ==
"bitor" || rpncmd ==
"|") {
181 }
else if(rpncmd ==
"bitxor" || rpncmd ==
"^") {
184 }
else if(rpncmd ==
"and" || rpncmd ==
"&&") {
187 }
else if(rpncmd ==
"or" || rpncmd ==
"||") {
190 }
else if(rpncmd ==
"xor" || rpncmd ==
"^^") {
193 }
else if(rpncmd ==
"bitnot") {
195 }
else if(rpncmd ==
"not") {
197 }
else if(rpncmd ==
"abs") {
199 }
else if(rpncmd ==
"sgn") {
207 }
else if(rpncmd ==
"neg" || rpncmd ==
"~") {
209 }
else if(rpncmd ==
"floor" || rpncmd ==
"f") {
211 }
else if(rpncmd ==
"ceil" || rpncmd ==
"c") {
213 }
else if(rpncmd ==
"exp") {
215 }
else if(rpncmd ==
"log") {
217 }
else if(rpncmd ==
"sin") {
219 }
else if(rpncmd ==
"cos") {
221 }
else if(rpncmd ==
"max") {
225 }
else if(rpncmd ==
"min") {
229 }
else if(rpncmd ==
"bound") {
234 }
else if(rpncmd ==
"when") {
242 }
else if(rpncmd ==
">" || rpncmd ==
"gt") {
245 }
else if(rpncmd ==
"<" || rpncmd ==
"lt") {
248 }
else if(rpncmd ==
"==" || rpncmd ==
"eq") {
251 }
else if(rpncmd ==
">=" || rpncmd ==
"ge") {
254 }
else if(rpncmd ==
"<=" || rpncmd ==
"le") {
257 }
else if(rpncmd ==
"!=" || rpncmd ==
"ne") {
260 }
else if(rpncmd ==
"rand") {
262 }
else if(rpncmd ==
"crc16") {
264 }
else if(rpncmd ==
"put") {
272 }
else if(rpncmd ==
"get") {
276 }
else if(rpncmd ==
"dbpush") {
286 }
else if(rpncmd ==
"dbpop") {
298 LOG_INFO(
"rpn: database underflow");
300 }
else if(rpncmd ==
"dbget") {
310 }
else if(rpncmd ==
"dblen") {
312 }
else if(rpncmd ==
"dbclr") {
317 }
else if(rpncmd ==
"dbsave") {
321 }
else if(rpncmd ==
"dbload") {
328 }
else if(rpncmd ==
"dbins") {
343 for(--j; j >= i; --j)
351 }
else if(rpncmd ==
"dbext") {
375 }
else if(rpncmd ==
"dbread") {
384 }
else if(rpncmd ==
"dbat") {
386 }
else if(rpncmd ==
"dbmov") {
394 LOG_INFO(
"rpn: database cursor out of bounds");
402 }
else if(rpncmd ==
"dbgoto") {
408 LOG_INFO(
"rpn: empty database, cannot move cursor");
422 LOG_INFO(
"rpn: database cursor destination out of bounds");
430 }
else if(rpncmd ==
"union") {
440 for(i = 0; i < f; ++i)
442 for(i = f; i <
f2; ++i) {
443 for(j = 0; j < f; ++j)
453 }
else if(rpncmd ==
"intersection") {
463 for(i = 0; i < f; ++i) {
464 for(j = f; j <
f2; ++j)
475 }
else if(rpncmd ==
"difference") {
485 for(i = 0; i < f; ++i) {
486 for(j = f; j <
f2; ++j)
488 goto skip_difference;
490 LABEL(skip_difference)
496 }
else if(rpncmd ==
"shuffle") {
501 for(i = 0; i < f - 1; ++i) {
505 for(j = 0; j < i; ++j)
508 for(j = i; j < f; ++j)
518 }
else if(rpncmd ==
"fexists_assert") {
524 LOG_INFO(
"rpn: ERROR: ", s,
" does not exist!");
528 }
else if(rpncmd ==
"fexists") {
537 }
else if(rpncmd ==
"localtime") {
539 }
else if(rpncmd ==
"gmtime") {
541 }
else if(rpncmd ==
"time") {
543 }
else if(rpncmd ==
"digest") {
546 }
else if(rpncmd ==
"sprintf1s") {
549 }
else if(rpncmd ==
"eval") {
563 LOG_INFO(
"rpn: still on stack: ", s);
573 LOG_HELP(
"Usage:^3 ", GetProgramCommandPrefix(),
" rpn <expression>");
574 LOG_HELP(
" Operator description (x: string, s: set, f: float):");
575 LOG_HELP(
" x pop -----------------------------> : removes the top");
576 LOG_HELP(
" x dup -----------------------------> x x : duplicates the top");
577 LOG_HELP(
" x x exch --------------------------> x x : swap the top two");
578 LOG_HELP(
" /cvarname load --------------------> x : loads a cvar");
579 LOG_HELP(
" /cvarname x def -------------------> : writes to a cvar");
580 LOG_HELP(
" f f add|sub|mul|div|mod|pow -------> f : adds/... two numbers");
581 LOG_HELP(
" f f and|or|xor|bitand|bitor|bitxor > f : logical and bitwise operations");
582 LOG_HELP(
" f f eq|ne|gt|ge|lt|le|max|min -----> f : compares two numbers");
583 LOG_HELP(
" f neg|abs|sgn|rand|floor|ceil------> f : negates/... a number");
584 LOG_HELP(
" f not|bitnot ----------------------> f : logical and bitwise negation");
585 LOG_HELP(
" f exp|log|sin|cos -----------------> f : exponential function & Co.");
586 LOG_HELP(
" f f f bound -----------------------> f : bounds the middle number");
587 LOG_HELP(
" f1 f2 b when ----------------------> f : f1 if b, f2 otherwise");
588 LOG_HELP(
" s s union|intersection|difference -> s : set operations");
589 LOG_HELP(
" s shuffle -------------------------> s : randomly arrange elements");
590 LOG_HELP(
" /key /value put -------------------> : set a database key");
591 LOG_HELP(
" /key get --------------------------> s : get a database value");
592 LOG_HELP(
" x dbpush --------------------------> : pushes the top onto the database");
593 LOG_HELP(
" dbpop|dbget -----------------------> x : removes/reads DB's top");
594 LOG_HELP(
" dblen|dbat ------------------------> f : gets the DB's size/cursor pos");
595 LOG_HELP(
" dbclr -----------------------------> : clear the DB");
596 LOG_HELP(
" s dbsave|dbload--------------------> : save/load the DB to/from a file");
597 LOG_HELP(
" x dbins ---------------------------> : moves the top into the DB");
598 LOG_HELP(
" dbext|dbread ----------------------> x : extract/get from the DB's cursor");
599 LOG_HELP(
" f dbmov|dbgoto --------------------> : move or set the DB's cursor");
600 LOG_HELP(
" s localtime -----------------------> s : formats the current local time");
601 LOG_HELP(
" s gmtime --------------------------> s : formats the current UTC time");
602 LOG_HELP(
" time ------------------------------> f : seconds since VM start");
603 LOG_HELP(
" s /MD4 digest ---------------------> s : MD4 digest");
604 LOG_HELP(
" s /SHA256 digest ------------------> s : SHA256 digest");
605 LOG_HELP(
" s /formatstring sprintf1s ---------> s : sprintf with 1 string (pad, cut)");
606 LOG_HELP(
" s eval ----------------------------> : does something eval");
607 LOG_HELP(
" Set operations operate on 'such''strings'.");
608 LOG_HELP(
" Unknown tokens insert their cvar value.");
void GenericCommand_rpn(int request, int argc, string command)
ERASEABLE int db_create()
ERASEABLE void db_put(int db, string key, string value)
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1 f1points s1 s2
ERASEABLE int db_load(string filename)
const int CMD_REQUEST_USAGE
ERASEABLE void db_close(int db)
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1 f1points f2
string rpn_stack[MAX_RPN_STACK]
spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 spree_cen s1 f1 s1 strcat(_("Level %s: "), "^BG%s\3\, _("^BGPress ^F2%s^BG to enter the game"))
ERASEABLE void db_save(int db, string filename)
const int CMD_REQUEST_COMMAND
ERASEABLE string db_get(int db, string key)
ERASEABLE bool fexists(string f)