1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2025-10-25 02:47:40 +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

@@ -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);