1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-18 06:50:27 +00:00

fixed arg shifting

This commit is contained in:
Zeno Rogue 2019-04-23 12:02:58 +02:00
parent 38e1dc6a7a
commit c40d7753d0
4 changed files with 12 additions and 6 deletions

View File

@ -191,6 +191,9 @@ treeoflife-white: hyper
collatz: hyper
${CMD} -canvas h -dftcolor 206020FF -ggamma 2 -collatz .3,.5,-.4,.4
collatz-bird: hyper
${CMD} -canvas h -dftcolor R -ggamma 2 -geo 435h -collatz3 txy .3 fd .25 tyz pi/2 / txy -.4 fd .2 tyz pi/2 -PM 0 -rvshape 3 -I Flash 100 -I Speed 100
fullnet: hyper
${CMD} -dftcolor 808080FF -ggamma 2 -back FFFFFF -net

View File

@ -60,9 +60,10 @@ namespace arg {
int pos;
void lshift() { pos++; }
void unshift() { pos--; }
void shift() {
lshift(); if(pos > isize(argument)) { printf("Missing parameter\n"); exit(1); }
lshift(); if(pos >= isize(argument)) { printf("Missing parameter\n"); exit(1); }
}
bool nomore() { return pos >= isize(argument); }
@ -74,7 +75,7 @@ namespace arg {
ld argf() { return parseld(args()); }
bool argis(const string& s) { if(args()[0] == '-' && args()[1] == '-') return args().substr(1) == s; return args() == s; }
void init(int argc, char **argv) { for(int i=0; i<argc; i++) argument.push_back(argv[i]); shift(); }
void init(int argc, char **argv) { for(int i=0; i<argc; i++) argument.push_back(argv[i]); lshift(); }
void phaseerror(int x) {
printf("Command line error: cannot read command '%s' from phase %d in phase %d\n", args().c_str(), x, curphase);

View File

@ -2284,6 +2284,7 @@ namespace arg {
#if CAP_COMMANDLINE
void lshift();
void unshift();
void shift();

View File

@ -1720,15 +1720,16 @@ int readArgs() {
using namespace collatz;
s2 = p2 = s3 = p3 = 0;
start();
shift();
transmatrix *T = &T2;
while(true) {
lshift();
if(arg::nomore()) break;
else if(argis("fd")) { shift(); *T = *T * xpush(argf()); shift(); }
else if(argcs()[0] == 't') { int x = dimid(argcs()[1]); int y = dimid(argcs()[2]); shift(); *T = *T * hr::cspin(x, y, argf()); shift(); }
else if(argis("/")) { shift(); if(T == &T2) T = &T3; else break; }
else if(argis("fd")) { shift(); *T = *T * xpush(argf()); }
else if(argcs()[0] == 't') { int x = dimid(argcs()[1]); int y = dimid(argcs()[2]); shift(); *T = *T * hr::cspin(x, y, argf()); }
else if(argis("/")) { if(T == &T2) T = &T3; else break; }
else break;
}
unshift();
}
else if(argis("-spiral")) {