// Hyperbolic Rogue -- commandline options // Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details namespace hr { #if CAP_COMMANDLINE const char *scorefile = "hyperrogue.log"; const char *conffile = "hyperrogue.ini"; string levelfile = "hyperrogue.lev"; string picfile = "hyperrogue.pic"; const char *musicfile = ""; const char *loadlevel = NULL; bool appears(const string& haystack, const string& needle) { return haystack.find(needle) != string::npos; } eLand readland(const string& ss) { if(ss == "II") return laCrossroads2; if(ss == "III") return laCrossroads3; if(ss == "IV") return laCrossroads4; if(ss == "V") return laCrossroads5; for(int l=0; l, version " VER "\n"); #ifndef NOLICENSE printf("released under GNU General Public License version 2 and thus\n"); printf("comes with absolutely no warranty; see COPYING for details\n"); #endif #ifdef FHS static string sbuf, cbuf; if(getenv("HOME")) { sbuf = getenv("HOME"); sbuf += "/."; sbuf += scorefile; cbuf = getenv("HOME"); cbuf += "/."; cbuf += conffile; scorefile = sbuf.c_str(); conffile = cbuf.c_str(); } #endif } namespace arg { vector argument; int pos; void lshift() { pos++; } void shift() { lshift(); if(pos > size(argument)) { printf("Missing parameter\n"); exit(1); } } const string& args() { return argument[pos]; } const char* argcs() { return args().c_str(); } int argi() { return atoi(argcs()); } int arghex() { return strtol(argcs(), NULL, 16); } ld argf() { return atof(argcs()); } bool argis(const string& s) { return args() == s; } void init(int argc, char **argv) { for(int i=0; i= '0' && *c <= '9') subpattern_flags ^= 1 << (*c - '0'); else if(*c == '@') subpattern_flags ^= 1 << 10; else if(*c == '-') subpattern_flags ^= 1 << 11; else if(*c == '~') subpattern_flags ^= 1 << 12; else whichPattern = *c; c++; } } // non-categorized: else if(argis("-pal")) { PHASEFROM(2); CHEAT; shift(); int id = argi(); shift(); linepatterns::patterns[id].color |= argi(); } else if(argis("-palrgba")) { PHASEFROM(2); CHEAT; shift(); int id = argi(); shift(); linepatterns::patterns[id].color = arghex(); } else if(argis("-qs")) { CHEAT; shift(); currfp.qpaths.push_back(args()); } else if(argis("-fix")) { PHASE(1); fixseed = true; autocheat = true; } else if(argis("-fixx")) { PHASE(1); fixseed = true; autocheat = true; shift(); startseed = argi(); } else if(argis("-steplimit")) { fixseed = true; autocheat = true; shift(); steplimit = argi(); } else if(argis("-qpar")) { int p; shift(); sscanf(argcs(), "%d,%d,%d", &p, "ientspace::rvadd, "ientspace::rvdir ); autocheat = true; currfp.init(p); } else if(argis("-test")) callhooks(hooks_tests); else if(argis("-qpar2")) { stop_game_and_switch_mode(rg::nothing); int a, b; shift(); sscanf(argcs(), "%d,%d", &a, &b); using namespace fieldpattern; current_extra = a; fgeomextras[current_extra].current_prime_id = b; enableFieldChange(); if(geometry != gQuotient2) { targetgeometry = gQuotient2; stop_game_and_switch_mode(rg::geometry); } } else if(argis("-tpar")) { torusconfig::torus_mode = torusconfig::tmSingle; shift(); sscanf(argcs(), "%d,%d,%d", &torusconfig::qty, &torusconfig::dx, &torusconfig::dy ); } else if(argis("-tparx")) { shift(); sscanf(argcs(), "%d,%d,%d", (int*) &torusconfig::torus_mode, &torusconfig::sdx, &torusconfig::sdy ); if(torusconfig::torus_mode == torusconfig::tmSingle) torusconfig::qty = torusconfig::sdx, torusconfig::dy = torusconfig::sdy; torusconfig::activate(); } else if(argis("-cs")) { shift(); CHEAT fieldpattern::matrix M = currfp.strtomatrix(args()); fieldpattern::subpathid = currfp.matcode[M]; fieldpattern::subpathorder = currfp.order(M); } else if(argis("-csp")) { CHEAT currfp.findsubpath(); } else if(argis("-quantum")) { CHEAT; quantum = true; } else if(argis("-P")) { PHASE(2); shift(); vid.scfg.players = argi(); stop_game_and_switch_mode(rg::nothing); } else if(argis("-PM")) { PHASEFROM(2); shift(); pmodel = eModel(argi()); } else if(argis("-offline")) { PHASE(1); offlineMode = true; } else if(argis("-debugf")) { debugfile = fopen("hyperrogue-debug.txt", "w"); shift(); debugflags = argi(); } else if(argis("-debuge")) { debugfile = stderr; shift(); debugflags = argi(); } else if(argis("-each")) { PHASEFROM(2); start_game(); shift(); int q = argi(); autocheat = true; for(int i=0; i - fieldpattern: quotient by the given (must be followed by qpar)\n"); printf(" -qpar - fieldpattern: use the given prime instead of 43\n"); printf(" -cs - fieldpattern: set subpath to the given (cannot be followed by qpar)\n"); printf(" -csp - fieldpattern: find the subpath of order (cannot be followed by qpar)\n"); printf(" -S* - toggle Shmup\n"); printf(" -P n - switch Shmup number of players (n=1..7)\n"); printf(" -PM - switch the model index\n"); printf(" -H* - toggle Hardcore\n"); printf(" -T* - toggle Tactical\n"); printf(" -7* - toggle heptagonal mode\n"); printf(" -C* - toggle Chaos mode\n"); printf(" -R* - toggle Random Pattern\n"); printf(" -Y id - enable Yendor, level id\n"); printf(" -D - disable all the special game modes\n"); printf(" -L - list of features\n"); printf(" -debugf 7 - output debugging information to hyperrogue-debug.txt\n"); printf(" -debuge 7 - output debugging information to stderr\n"); printf(" -offline - don't connect to Steam (for Steam versions)\n"); printf(" -I ITEM n - start with n of ITEM (activates cheat and disables ghosts)\n"); printf(" -fix - fix the seed\n"); printf("Toggles: -o0 disables, -o1 enables, -o switches"); printf("Not all options are documented, see hyper.cpp"); exit(0); } else if(ca::readArg()) ; else return 1; return 0; } purehookset hooks_config; hookset *hooks_args; namespace arg { int curphase; auto ah = addHook(hooks_args, 0, readCommon); void read(int phase) { curphase = phase; callhooks(hooks_config); while(pos < size(argument)) { for(auto& h: *hooks_args) { int r = h.second(); if(r == 2) return; if(r == 0) { lshift(); goto cont; } } printf("Unknown option: %s\n", argcs()); exit(3); cont: ; } } } #endif }