// Hyperbolic Rogue // Copyright (C) 2011 Zeno Rogue // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define ISANDROID 0 #define ISMOBILE 0 #define ISIOS 0 #define USE_SDL #define USE_COMMANDLINE #ifdef STEAM #define NOLICENSE #endif #include "init.cpp" #ifdef LINUX #include void moreStack() { const rlim_t kStackSize = 1 << 28; // 28; struct rlimit rl; int result; result = getrlimit(RLIMIT_STACK, &rl); if(result == 0) { if(rl.rlim_cur < kStackSize) { // rl.rlim_cur = 1 << 19; // kStackSize; result = setrlimit(RLIMIT_STACK, &rl); if (result != 0) { fprintf(stderr, "setrlimit returned result = %d\n", result); } } } } #endif eLand readland(const char *s) { string ss = s; 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 } int arg::readCommon() { if(argis("-c")) { PHASE(1); shift(); conffile = args(); } else if(argis("-s")) { PHASE(1); shift(); scorefile = args(); } else if(argis("-m")) { PHASE(1); shift(); musicfile = args(); } #ifdef SDLAUDIO else if(argis("-se")) { PHASE(1); shift(); wheresounds = args(); } #endif #ifndef NOEDIT else if(argis("-lev")) { shift(); levelfile = args(); } else if(argis("-pic")) { shift(); picfile = args(); } else if(argis("-load")) { PHASE(3); shift(); mapstream::loadMap(loadlevel); } #endif else if(argis("-canvas")) { firstland = euclidland = laCanvas; shift(); if(args()[1] == 0) mapeditor::whichCanvas = args()[0]; else mapeditor::canvasback = strtol(args(), NULL, 16); } else if(argis("-back")) { shift(); backcolor = strtol(args(), NULL, 16); } else if(argis("-borders")) { shift(); bordcolor = strtol(args(), NULL, 16); } else if(argis("-fore")) { shift(); forecolor = strtol(args(), NULL, 16); } else if(argis("-W2")) { shift(); cheatdest = readland(args()); autocheat = true; } else if(argis("-W")) { shift(); firstland = euclidland = readland(args()); } else if(argis("-I")) { PHASE(3) cheater++; timerghost = false; shift(); eItem i = readItem(args()); shift(); items[i] = argi(); } else if(argis("-M")) { PHASE(3) cheater++; timerghost = false; shift(); eMonster m = readMonster(args()); shift(); int q = argi(); printf("m = %s q = %d\n", dnameof(m), q); restoreGolems(q, m, 7); } else if(argis("-L")) { printf("Treasures:\n"); for(int i=1; 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; } hookset *hooks_main; #ifndef NOMAIN int main(int argc, char **argv) { if(callhandlers(false, hooks_main, argc, argv)) return 0; #ifndef WEB #ifdef LINUX moreStack(); #endif arg::init(argc, argv); initializeCLI(); #endif initAll(); arg::read(3); mainloop(); finishAll(); profile_info(); return 0; } #endif #ifdef USE_COMMANDLINE purehookset hooks_config; hookset *hooks_args; namespace arg { int argc; char **argv; auto ah = addHook(hooks_args, 0, readCommon); void read(int phase) { curphase = phase; callhooks(hooks_config); while(argc) { for(auto& h: *hooks_args) { int r = h.second(); if(r == 2) return; if(r == 0) { lshift(); goto cont; } } printf("Unknown option: %s\n", args()); exit(3); cont: ; } } } #endif