From 49877fbfc977b08d1203b0dacb92e36b449fce1e Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 22 Apr 2019 22:59:37 +0200 Subject: [PATCH] arg::nomore(); fixes in collatz3 --- commandline.cpp | 2 ++ hyper.h | 1 + rogueviz.cpp | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/commandline.cpp b/commandline.cpp index a7cedd0a..c94672f4 100644 --- a/commandline.cpp +++ b/commandline.cpp @@ -65,6 +65,8 @@ namespace arg { lshift(); if(pos > isize(argument)) { printf("Missing parameter\n"); exit(1); } } + bool nomore() { return pos >= isize(argument); } + const string& args() { return argument[pos]; } const char* argcs() { return args().c_str(); } int argi() { return atoi(argcs()); } diff --git a/hyper.h b/hyper.h index 6979df98..abf57a78 100644 --- a/hyper.h +++ b/hyper.h @@ -2292,6 +2292,7 @@ namespace arg { int argi(); ld argf(); bool argis(const string& s); + bool nomore(); unsigned arghex(); inline void shift_arg_formula(ld& x, const reaction_t& r = reaction_t()) { shift(); x = argf(); diff --git a/rogueviz.cpp b/rogueviz.cpp index f82f9d0b..89f40812 100644 --- a/rogueviz.cpp +++ b/rogueviz.cpp @@ -1721,9 +1721,9 @@ int readArgs() { shift(); transmatrix *T = &T2; while(true) { - if(arg::pos >= isize(arg::argument)) break; + if(arg::nomore()) break; else if(argis("fd")) { shift(); *T = *T * xpush(argf()); shift(); } - else if(argcs()[0] == 't') { shift(); *T = *T * hr::cspin(dimid(argcs()[1]),dimid(argcs()[2]),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 break; }