1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

arg:: Previously some arguments used - while some used --; now both forms are accepted for all arguments. Also empty arguments are ignored.

This commit is contained in:
Zeno Rogue 2018-11-10 19:49:41 +01:00
parent 1d0b5878fc
commit c68de3c94f

View File

@ -70,7 +70,7 @@ namespace arg {
int argi() { return atoi(argcs()); } int argi() { return atoi(argcs()); }
unsigned arghex() { return strtoll(argcs(), NULL, 16); } unsigned arghex() { return strtoll(argcs(), NULL, 16); }
ld argf() { return parseld(args()); } ld argf() { return parseld(args()); }
bool argis(const string& s) { return args() == s; } 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]); shift(); }
@ -105,37 +105,37 @@ int arg::readCommon() {
debugfile = stderr; debugfile = stderr;
shift(); debugflags = argi(); shift(); debugflags = argi();
} }
else if(argis("--run")) { else if(argis("-run")) {
PHASE(3); PHASE(3);
start_game(); start_game();
mainloop(); quitmainloop = false; mainloop(); quitmainloop = false;
} }
else if(argis("--msg")) { else if(argis("-msg")) {
shift(); addMessage(args()); shift(); addMessage(args());
printf("%s\n", args().c_str()); printf("%s\n", args().c_str());
} }
else if(argis("--msg0")) { else if(argis("-msg0")) {
clearMessages(); clearMessages();
} }
#if CAP_TOUR #if CAP_TOUR
else if(argis("--tour")) { else if(argis("-tour")) {
PHASEFROM(2); start_game(); tour::start(); PHASEFROM(2); start_game(); tour::start();
} }
else if(argis("--presentation")) { else if(argis("-presentation")) {
PHASEFROM(2); tour::texts = false; PHASEFROM(2); tour::texts = false;
start_game(); tour::start(); start_game(); tour::start();
} }
#endif #endif
else if(argis("--draw")) { else if(argis("-draw")) {
PHASE(3); drawscreen(); PHASE(3); drawscreen();
} }
else if(argis("--rotate")) { else if(argis("-rotate")) {
PHASE(3); PHASE(3);
shift(); ld a = argf(); shift(); ld a = argf();
shift(); ld b = argf(); shift(); ld b = argf();
View = View * spin(M_PI * 2 * a / b); View = View * spin(M_PI * 2 * a / b);
} }
else if(argis("--exit")) { else if(argis("-exit")) {
PHASE(3); printf("Success.\n"); PHASE(3); printf("Success.\n");
exit(0); exit(0);
} }
@ -148,7 +148,7 @@ int arg::readCommon() {
} }
// informational // informational
else if(argis("--version") || argis("-v")) { else if(argis("-version") || argis("-v")) {
printf("HyperRogue version " VER "\n"); printf("HyperRogue version " VER "\n");
exit(0); exit(0);
} }
@ -182,7 +182,8 @@ int arg::readCommon() {
printf("\n"); printf("\n");
exit(0); exit(0);
} }
else if(argis("--help") || argis("-h")) { else if(argis("")) {}
else if(argis("-help") || argis("-h")) {
printf("Press F1 while playing to get ingame options.\n\n"); printf("Press F1 while playing to get ingame options.\n\n");
printf("HyperRogue accepts the following command line options:\n"); printf("HyperRogue accepts the following command line options:\n");
printf(" -c FILE - use the specified configuration file\n"); printf(" -c FILE - use the specified configuration file\n");