more cleanup in parameters, restartGame cleanup

This commit is contained in:
Zeno Rogue 2018-06-11 00:58:38 +02:00
parent 90573cf456
commit 98246d3066
20 changed files with 344 additions and 307 deletions

View File

@ -1166,10 +1166,6 @@ void initgraph() {
restartGraph(); restartGraph();
initgeo();
buildpolys();
if(noGUI) { if(noGUI) {
#if CAP_COMMANDLINE #if CAP_COMMANDLINE
arg::read(2); arg::read(2);

View File

@ -205,65 +205,58 @@ int arg::readCommon() {
// mode changes: // mode changes:
#define TOGGLE(x, param, act) \ #define TOGGLE(x, param, act) \
else if(args()[0] == '-' && args()[1] == x && !args()[2]) { showstartmenu = false; if(curphase == 3) {act;} else {PHASE(2); param = !param;} } \ else if(args()[0] == '-' && args()[1] == x && !args()[2]) { showstartmenu = false; act; } \
else if(args()[0] == '-' && args()[1] == x && args()[2] == '1') { showstartmenu = false; if(curphase == 3 && !param) {act;} else {PHASE(2); param = true;} } \ else if(args()[0] == '-' && args()[1] == x && args()[2] == '1') { showstartmenu = false; if(!param) act; } \
else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu = false; if(curphase == 3 && param) {act;} else {PHASE(2); param = false;} } else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu = false; if(param) act; }
TOGGLE('o', vid.usingGL, switchGL()) TOGGLE('o', vid.usingGL, switchGL())
TOGGLE('C', chaosmode, restartGame(rg::chaos)) TOGGLE('C', chaosmode, stop_game_and_switch_mode(rg::chaos))
TOGGLE('7', nonbitrunc, restartGame(rg::bitrunc)) TOGGLE('7', nonbitrunc, stop_game_and_switch_mode(rg::bitrunc))
TOGGLE('f', vid.full, switchFullscreen()) TOGGLE('f', vid.full, switchFullscreen())
TOGGLE('T', tactic::on, restartGame(rg::tactic)) TOGGLE('T', tactic::on, stop_game_and_switch_mode(rg::tactic))
TOGGLE('S', shmup::on, restartGame(rg::shmup)) TOGGLE('S', shmup::on, stop_game_and_switch_mode(rg::shmup))
TOGGLE('H', hardcore, switchHardcore()) TOGGLE('H', hardcore, switchHardcore())
TOGGLE('R', randomPatternsMode, restartGame(rg::randpattern)) TOGGLE('R', randomPatternsMode, stop_game_and_switch_mode(rg::randpattern))
TOGGLE('i', inv::on, restartGame(rg::inv)) TOGGLE('i', inv::on, stop_game_and_switch_mode(rg::inv))
else if(argis("-peace")) { else if(argis("-peace")) {
peace::otherpuzzles = true; peace::otherpuzzles = true;
if(curphase == 3) restartGame(rg::peace); stop_game_and_switch_mode(peace::on ? 0 : rg::peace);
else peace::on = !peace::on;
} }
else if(argis("-pmem")) { else if(argis("-pmem")) {
peace::otherpuzzles = false; peace::otherpuzzles = false;
if(curphase == 3) restartGame(rg::peace); stop_game_and_switch_mode(peace::on ? 0 : rg::peace);
else peace::on = !peace::on;
} }
else if(argis("-geo")) { else if(argis("-geo")) {
if(curphase == 3) { shift(); targetgeometry = (eGeometry) argi();
shift(); targetgeometry = (eGeometry) argi(); stop_game_and_switch_mode(rg::geometry);
restartGame(rg::geometry);
}
else {
PHASE(2); shift(); geometry = targetgeometry = (eGeometry) argi();
}
} }
else if(argis("-gp")) { else if(argis("-gp")) {
PHASEFROM(2); PHASEFROM(2);
if(nonbitrunc && curphase == 3) restartGame(rg::bitrunc); stop_game_and_switch_mode(rg::nothing);
shift(); gp::param.first = argi(); shift(); gp::param.first = argi();
shift(); gp::param.second = argi(); shift(); gp::param.second = argi();
if(curphase == 3) restartGame(rg::gp); stop_game_and_switch_mode(rg::gp);
} }
// 'do something' // 'do something'
else if(argis("-W")) { else if(argis("-W")) {
PHASEFROM(2); PHASEFROM(2);
shift(); shift();
firstland0 = firstland = specialland = readland(args()); firstland0 = firstland = specialland = readland(args());
if(curphase == 3) restartGame(); stop_game_and_switch_mode(rg::nothing);
showstartmenu = false; showstartmenu = false;
} }
else if(argis("-canvas")) { else if(argis("-canvas")) {
PHASEFROM(2); CHEAT PHASEFROM(2);
firstland = specialland = laCanvas; firstland = specialland = laCanvas;
shift(); shift();
if(args() == "i") canvas_invisible = !canvas_invisible; if(args() == "i") canvas_invisible = !canvas_invisible;
else if(args().size() == 1) patterns::whichCanvas = args()[0]; else if(args().size() == 1) patterns::whichCanvas = args()[0];
else patterns::canvasback = arghex(); else patterns::canvasback = arghex();
if(curphase == 3) restartGame(); stop_game_and_switch_mode(rg::nothing);
} }
else if(argis("-pattern")) { else if(argis("-pattern")) {
PHASEFROM(2); CHEAT PHASEFROM(2);
shift(); shift();
const char *c = argcs(); const char *c = argcs();
using namespace patterns; using namespace patterns;
@ -318,24 +311,16 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
else if(argis("-test")) else if(argis("-test"))
callhooks(hooks_tests); callhooks(hooks_tests);
else if(argis("-qpar2")) { else if(argis("-qpar2")) {
if(curphase == 3) { stop_game_and_switch_mode(rg::nothing);
restartGame(rg::geometry);
}
else {
PHASE(2);
}
if(geometry == gQuotient2) restartGame(rg::geometry);
int a, b; int a, b;
shift(); sscanf(argcs(), "%d,%d", &a, &b); shift(); sscanf(argcs(), "%d,%d", &a, &b);
using namespace fieldpattern; using namespace fieldpattern;
current_extra = a; current_extra = a;
fgeomextras[current_extra].current_prime_id = b; fgeomextras[current_extra].current_prime_id = b;
enableFieldChange(); enableFieldChange();
if(curphase == 3) { if(geometry != gQuotient2) {
targetgeometry = gQuotient2; restartGame(rg::geometry); targetgeometry = gQuotient2; stop_game_and_switch_mode(rg::geometry);
} }
else
geometry = gQuotient2;
} }
else if(argis("-tpar")) { else if(argis("-tpar")) {
torusconfig::torus_mode = torusconfig::tmSingle; torusconfig::torus_mode = torusconfig::tmSingle;
@ -346,7 +331,8 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
); );
} }
else if(argis("-tparx")) { else if(argis("-tparx")) {
shift(); sscanf(argcs(), "%d,%d,%d", shift();
sscanf(argcs(), "%d,%d,%d",
(int*) &torusconfig::torus_mode, (int*) &torusconfig::torus_mode,
&torusconfig::sdx, &torusconfig::sdx,
&torusconfig::sdy &torusconfig::sdy
@ -357,14 +343,13 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
torusconfig::activate(); torusconfig::activate();
} }
else if(argis("-cs")) { else if(argis("-cs")) {
shift(); shift(); CHEAT
fieldpattern::matrix M = currfp.strtomatrix(args()); fieldpattern::matrix M = currfp.strtomatrix(args());
fieldpattern::subpathid = currfp.matcode[M]; fieldpattern::subpathid = currfp.matcode[M];
fieldpattern::subpathorder = currfp.order(M); fieldpattern::subpathorder = currfp.order(M);
autocheat = true;
} }
else if(argis("-csp")) { else if(argis("-csp")) {
autocheat = true; CHEAT
currfp.findsubpath(); currfp.findsubpath();
} }
else if(argis("-quantum")) { else if(argis("-quantum")) {
@ -373,13 +358,16 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
} }
else if(argis("-P")) { else if(argis("-P")) {
PHASE(2); shift(); PHASE(2); shift();
vid.scfg.players = argi(); vid.scfg.players = argi();
// todo phase3 restart stop_game_and_switch_mode(rg::nothing);
} }
else if(argis("-PM")) { else if(argis("-PM")) {
PHASEFROM(2); shift(); pmodel = eModel(argi()); PHASEFROM(2); shift(); pmodel = eModel(argi());
} }
else if(argis("-offline")) offlineMode = true; else if(argis("-offline")) {
PHASE(1);
offlineMode = true;
}
else if(argis("-debugf")) { else if(argis("-debugf")) {
debugfile = fopen("hyperrogue-debug.txt", "w"); debugfile = fopen("hyperrogue-debug.txt", "w");
shift(); debugflags = argi(); shift(); debugflags = argi();
@ -389,6 +377,7 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
shift(); debugflags = argi(); shift(); debugflags = argi();
} }
else if(argis("-each")) { else if(argis("-each")) {
PHASEFROM(2); start_game();
shift(); int q = argi(); autocheat = true; shift(); int q = argi(); autocheat = true;
for(int i=0; i<ittypes; i++) for(int i=0; i<ittypes; i++)
if(itemclass(eItem(i)) == IC_TREASURE) if(itemclass(eItem(i)) == IC_TREASURE)
@ -414,12 +403,10 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
if(clHeight) vid.yres = clHeight; if(clHeight) vid.yres = clHeight;
if(clFont) vid.fsize = clFont; if(clFont) vid.fsize = clFont;
} }
else if(argis("--version") || argis("-v")) {
printf("HyperRogue version " VER "\n");
exit(0);
}
else if(argis("--run")) { else if(argis("--run")) {
PHASE(3); mainloop(); quitmainloop = false; PHASE(3);
start_game();
mainloop(); quitmainloop = false;
} }
else if(argis("--msg")) { else if(argis("--msg")) {
shift(); addMessage(args()); shift(); addMessage(args());
@ -430,11 +417,11 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
} }
#if CAP_TOUR #if CAP_TOUR
else if(argis("--tour")) { else if(argis("--tour")) {
PHASE(3); tour::start(); PHASEFROM(2); start_game(); tour::start();
} }
else if(argis("--presentation")) { else if(argis("--presentation")) {
PHASE(3); tour::texts = false; PHASEFROM(2); tour::texts = false;
tour::start(); start_game(); tour::start();
} }
#endif #endif
else if(argis("--draw")) { else if(argis("--draw")) {
@ -445,7 +432,7 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
exit(0); exit(0);
} }
else if(argis("-gencells")) { else if(argis("-gencells")) {
PHASE(3); shift(); PHASEFROM(2); shift(); start_game();
printf("Generating %d cells...\n", argi()); printf("Generating %d cells...\n", argi());
celllister cl(cwt.c, 50, argi(), NULL); celllister cl(cwt.c, 50, argi(), NULL);
printf("Cells generated: %d\n", size(cl.lst)); printf("Cells generated: %d\n", size(cl.lst));
@ -480,7 +467,7 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
} }
#if CAP_SDL #if CAP_SDL
else if(argis("-pngshot")) { else if(argis("-pngshot")) {
PHASE(3); shift(); PHASE(3); shift(); start_game();
printf("saving PNG screenshot to %s\n", argcs()); printf("saving PNG screenshot to %s\n", argcs());
saveHighQualityShot(argcs()); saveHighQualityShot(argcs());
} }
@ -503,7 +490,7 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
shift(); svg::gamma = argf(); shift(); svg::gamma = argf();
} }
else if(argis("-svgshot")) { else if(argis("-svgshot")) {
PHASE(3); shift(); PHASE(3); shift(); start_game();
printf("saving SVG screenshot to %s\n", argcs()); printf("saving SVG screenshot to %s\n", argcs());
svg::render(argcs()); svg::render(argcs());
} }
@ -531,6 +518,10 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
} }
// informational // informational
else if(argis("--version") || argis("-v")) {
printf("HyperRogue version " VER "\n");
exit(0);
}
else if(argis("-fi")) { else if(argis("-fi")) {
fieldpattern::info(); fieldpattern::info();
exit(0); exit(0);

View File

@ -306,22 +306,22 @@ bool have_current_settings() {
void resetModes(char leave) { void resetModes(char leave) {
popAllGames(); popAllGames();
firstland = laIce; specialland = laIce; vid.scfg.players = 1; firstland = laIce; specialland = laIce; vid.scfg.players = 1;
if(shmup::on != (leave == rg::shmup)) restartGame(rg::shmup); if(shmup::on != (leave == rg::shmup)) stop_game_and_switch_mode(rg::shmup);
if(inv::on != (leave == rg::inv)) restartGame(rg::inv); if(inv::on != (leave == rg::inv)) stop_game_and_switch_mode(rg::inv);
if(chaosmode != (leave == rg::chaos)) restartGame(rg::chaos); if(chaosmode != (leave == rg::chaos)) stop_game_and_switch_mode(rg::chaos);
if(gp::on != (leave == rg::gp)) restartGame(rg::gp); if(gp::on != (leave == rg::gp)) stop_game_and_switch_mode(rg::gp);
if(nonbitrunc != (leave == rg::bitrunc)) restartGame(rg::bitrunc); if(nonbitrunc != (leave == rg::bitrunc)) stop_game_and_switch_mode(rg::bitrunc);
if(peace::on != (leave == rg::peace)) restartGame(rg::peace); if(peace::on != (leave == rg::peace)) stop_game_and_switch_mode(rg::peace);
#if CAP_TOUR #if CAP_TOUR
if(tour::on != (leave == rg::tour)) restartGame(rg::tour); if(tour::on != (leave == rg::tour)) stop_game_and_switch_mode(rg::tour);
#endif #endif
if(yendor::on != (leave == rg::yendor)) restartGame(rg::yendor); if(yendor::on != (leave == rg::yendor)) stop_game_and_switch_mode(rg::yendor);
if(tactic::on != (leave == rg::tactic)) restartGame(rg::tactic); if(tactic::on != (leave == rg::tactic)) stop_game_and_switch_mode(rg::tactic);
if(randomPatternsMode != (leave == rg::randpattern)) restartGame(rg::randpattern); if(randomPatternsMode != (leave == rg::randpattern)) stop_game_and_switch_mode(rg::randpattern);
if(geometry != gNormal && leave != rg::geometry) { if(geometry != gNormal && leave != rg::geometry) {
targetgeometry = gNormal; targetgeometry = gNormal;
restartGame(rg::geometry); stop_game_and_switch_mode(rg::geometry);
} }
pmodel = mdDisk; vid.alpha = 1; vid.scale = 1; pmodel = mdDisk; vid.alpha = 1; vid.scale = 1;
@ -332,6 +332,7 @@ void resetModes(char leave) {
vid.monmode = DEFAULT_MONMODE; vid.monmode = DEFAULT_MONMODE;
vid.wallmode = DEFAULT_WALLMODE; vid.wallmode = DEFAULT_WALLMODE;
start_game();
} }
#if CAP_CONFIG #if CAP_CONFIG

View File

@ -365,8 +365,6 @@ void handleKeyNormal(int sym, int uni) {
if(sym == SDLK_KP5 && DEFAULTCONTROL) movepcto(-1, 1); if(sym == SDLK_KP5 && DEFAULTCONTROL) movepcto(-1, 1);
// if(sym == SDLK_F4) restartGameSwitchEuclid();
if(sym == SDLK_F5) { if(sym == SDLK_F5) {
#if CAP_DAILY #if CAP_DAILY
if(daily::on) daily::handleQuit(1); if(daily::on) daily::handleQuit(1);
@ -374,7 +372,7 @@ void handleKeyNormal(int sym, int uni) {
#endif #endif
if(needConfirmation()) if(needConfirmation())
pushScreen(showMission); pushScreen(showMission);
else restartGame(); else restart_game();
} }
if(sym == SDLK_ESCAPE) { if(sym == SDLK_ESCAPE) {

View File

@ -71,14 +71,16 @@ void showQuotientConfig() {
else if(uni == 'p') else if(uni == 'p')
nextPrime(gxcur); nextPrime(gxcur);
else if(uni == 'x' || uni == '\n') { else if(uni == 'x' || uni == '\n') {
targetgeometry = gxcur.base; restartGame(rg::geometry); targetgeometry = gxcur.base; stop_game_and_switch_mode(rg::geometry);
enableFieldChange(); enableFieldChange();
targetgeometry = gQuotient2; restartGame(rg::geometry); targetgeometry = gQuotient2; stop_game_and_switch_mode(rg::geometry);
start_game();
} }
else if(uni == 'c') { else if(uni == 'c') {
targetgeometry = gEuclid; restartGame(rg::geometry); targetgeometry = gEuclid; stop_game_and_switch_mode(rg::geometry);
fieldpattern::quotient_field_changed = false; fieldpattern::quotient_field_changed = false;
targetgeometry = gQuotient2; restartGame(rg::geometry); targetgeometry = gQuotient2; stop_game_and_switch_mode(rg::geometry);
start_game();
} }
else if(doexiton(sym, uni)) else if(doexiton(sym, uni))
popScreen(); popScreen();
@ -184,22 +186,24 @@ void showTorusConfig() {
else if(uni == 't') else if(uni == 't')
torus_bitrunc = !torus_bitrunc; torus_bitrunc = !torus_bitrunc;
else if((uni == 'a' || uni == '\n') && torusconfig::newqty >= 3 && valid) { else if((uni == 'a' || uni == '\n') && torusconfig::newqty >= 3 && valid) {
targetgeometry = gNormal; restartGame(rg::geometry, false, true); targetgeometry = gNormal; stop_game_and_switch_mode(rg::geometry);
torusconfig::torus_mode = torusconfig::newmode; torusconfig::torus_mode = torusconfig::newmode;
torusconfig::qty = torusconfig::newqty; torusconfig::qty = torusconfig::newqty;
torusconfig::dy = torusconfig::newdy; torusconfig::dy = torusconfig::newdy;
torusconfig::sdx = torusconfig::newsdx; torusconfig::sdx = torusconfig::newsdx;
torusconfig::sdy = torusconfig::newsdy; torusconfig::sdy = torusconfig::newsdy;
torusconfig::activate(); torusconfig::activate();
if((square && torus_bitrunc) != nonbitrunc) restartGame(rg::bitrunc, false, true); if((square && torus_bitrunc) != nonbitrunc) stop_game_and_switch_mode(rg::bitrunc);
targetgeometry = gTorus; restartGame(rg::geometry, false, true); targetgeometry = gTorus; stop_game_and_switch_mode(rg::geometry);
start_game();
} }
else if(uni == 'c') { else if(uni == 'c') {
targetgeometry = gEuclid; restartGame(rg::geometry, false, true); targetgeometry = gEuclid; stop_game_and_switch_mode(rg::geometry);
torusconfig::torus_mode = torusconfig::tmSingle; torusconfig::torus_mode = torusconfig::tmSingle;
torusconfig::qty = torusconfig::def_qty; torusconfig::qty = torusconfig::def_qty;
torusconfig::dy = torusconfig::def_dy; torusconfig::dy = torusconfig::def_dy;
targetgeometry = gTorus; restartGame(rg::geometry, false, true); targetgeometry = gTorus; stop_game_and_switch_mode(rg::geometry);
start_game();
} }
else if(uni == 'z') editScale(); else if(uni == 'z') editScale();
#if CAP_RUG #if CAP_RUG
@ -329,16 +333,16 @@ void showEuclideanMenu() {
dialog::handleNavigation(sym, uni); dialog::handleNavigation(sym, uni);
if(uni >= 'a' && uni < 'a'+gGUARD) { if(uni >= 'a' && uni < 'a'+gGUARD) {
targetgeometry = eGeometry(uni - 'a'); targetgeometry = eGeometry(uni - 'a');
restartGame(geometry == targetgeometry ? rg::nothing : rg::geometry); stop_game_and_switch_mode(geometry == targetgeometry ? rg::nothing : rg::geometry);
pushScreen(showEuclideanMenu); start_game();
} }
else if(uni == 't') { else if(uni == 't') {
if(euclid6) ; if(euclid6) ;
else if(S3 == 3) else if(S3 == 3)
gp::configure(); gp::configure();
else { else {
restartGame(rg::bitrunc); stop_game_and_switch_mode(rg::bitrunc);
pushScreen(showEuclideanMenu); start_game();
} }
} }
else if(uni == '2' || sym == SDLK_F1) gotoHelp(euchelp); else if(uni == '2' || sym == SDLK_F1) gotoHelp(euchelp);
@ -424,16 +428,16 @@ void showEuclideanMenu() {
} }
else if(uni == '1') { else if(uni == '1') {
if(chaosUnlocked) { if(chaosUnlocked) {
restartGame(rg::chaos); stop_game_and_switch_mode(rg::chaos);
pushScreen(showEuclideanMenu); start_game();
} }
} }
else if(lid >= 0 && lid < size(landlist)) { else if(lid >= 0 && lid < size(landlist)) {
eLand nland = landlist[lid]; eLand nland = landlist[lid];
if(landvisited[nland]) { if(landvisited[nland]) {
firstland = specialland = nland; firstland = specialland = nland;
restartGame(tactic::on ? rg::tactic : rg::nothing); stop_game_and_switch_mode(tactic::on ? rg::tactic : rg::nothing);
pushScreen(showEuclideanMenu); start_game();
} }
} }
else if(uni == '2' || sym == SDLK_F1) gotoHelp(euchelp); else if(uni == '2' || sym == SDLK_F1) gotoHelp(euchelp);

View File

@ -543,18 +543,19 @@ namespace gp {
auto g = screens; auto g = screens;
if(xy.first == 0 && xy.second == 0) xy.first = 1; if(xy.first == 0 && xy.second == 0) xy.first = 1;
if(xy.first == 1 && xy.second == 0) { if(xy.first == 1 && xy.second == 0) {
if(gp::on) restartGame(rg::bitrunc); if(gp::on) stop_game_and_switch_mode(rg::bitrunc);
if(!nonbitrunc) restartGame(rg::bitrunc); if(!nonbitrunc) stop_game_and_switch_mode(rg::bitrunc);
} }
else if(xy.first == 1 && xy.second == 1) { else if(xy.first == 1 && xy.second == 1) {
if(gp::on) restartGame(rg::bitrunc); if(gp::on) stop_game_and_switch_mode(rg::bitrunc);
if(nonbitrunc) restartGame(rg::bitrunc); if(nonbitrunc) stop_game_and_switch_mode(rg::bitrunc);
} }
else { else {
if(nonbitrunc) restartGame(rg::bitrunc); if(nonbitrunc) stop_game_and_switch_mode(rg::bitrunc);
param = xy; param = xy;
restartGame(rg::gp); stop_game_and_switch_mode(rg::gp);
} }
start_game();
#if CAP_TEXTURE #if CAP_TEXTURE
if(texture_remap) if(texture_remap)
texture::config.remap(old_tstate, old_tstate_max); texture::config.remap(old_tstate, old_tstate_max);

15
hyper.h
View File

@ -362,7 +362,7 @@ int towerval(cell *c, cellfunction* cf = &coastvalEdge);
int hrandpos(); // 0 to HRANDMAX int hrandpos(); // 0 to HRANDMAX
namespace rg { namespace rg {
// possible parameters e.g. for restartGame and wrongmode // possible parameters e.g. for restart_game and wrongmode
static const char nothing = 0; static const char nothing = 0;
static const char peace = 'P'; static const char peace = 'P';
static const char inv = 'i'; static const char inv = 'i';
@ -381,10 +381,9 @@ namespace rg {
// wrongmode only -- marks 'global' achievements not related to the current mode // wrongmode only -- marks 'global' achievements not related to the current mode
static const char global = 'x'; static const char global = 'x';
// wrongmode only -- change vid.scfg.players then restartGame(rg::nothing) instead // wrongmode only -- change vid.scfg.players then restart_game(rg::nothing) instead
static const char multi = 'm'; static const char multi = 'm';
} }
void restartGame(char switchWhat = 0, bool push = false, bool keep_screens = false);
int landMultiplier(eLand l); int landMultiplier(eLand l);
eItem treasureType(eLand l); eItem treasureType(eLand l);
@ -2954,7 +2953,6 @@ extern void initializeCLI();
static const int max_vec = (1<<14); static const int max_vec = (1<<14);
extern void popGame();
string helptitle(string s, int col); string helptitle(string s, int col);
pair<int, int> cell_to_pair(cell *c); pair<int, int> cell_to_pair(cell *c);
extern bool nohud, nofps; extern bool nohud, nofps;
@ -3400,3 +3398,12 @@ void handle_event(SDL_Event& ev);
#ifndef XPRINTF #ifndef XPRINTF
template<class...T> void Xprintf(const char *fmt, T... t) { printf(fmt, t...); } template<class...T> void Xprintf(const char *fmt, T... t) { printf(fmt, t...); }
#endif #endif
void pop_game();
void push_game();
void start_game();
void stop_game();
void switch_game_mode(char switchWhat);
void stop_game_and_switch_mode(char switchWhat = rg::nothing); // stop_game + switch_game_mode
void restart_game(char switchWhat = rg::nothing); // popAllScreens + popAllGames + stop_game + switch_game_mode + start_game

View File

@ -89,8 +89,7 @@ void showDemo() {
} }
else if(sym == 'f') { else if(sym == 'f') {
firstland = laIce; firstland = laIce;
if(tactic::on) restartGame(rg::tactic); restart_game(tactic::on ? rg::tactic : rg::nothing);
else restartGame();
} }
#if CAP_TOUR #if CAP_TOUR
else if(sym == 'T') { else if(sym == 'T') {
@ -100,18 +99,15 @@ void showDemo() {
#endif #endif
else if(sym == 't') { else if(sym == 't') {
firstland = laTemple; firstland = laTemple;
if(!tactic::on) restartGame(rg::tactic); restart_game(tactic::on ? rg::tactic : rg::nothing);
else restartGame();
} }
else if(sym == 'l') { else if(sym == 'l') {
firstland = laStorms; firstland = laStorms;
if(!tactic::on) restartGame(rg::tactic); restart_game(tactic::on ? rg::tactic : rg::nothing);
else restartGame();
} }
else if(sym == 'b') { else if(sym == 'b') {
firstland = laBurial; firstland = laBurial;
if(!tactic::on) restartGame(rg::tactic); restart_game(tactic::on ? rg::tactic : rg::nothing);
else restartGame();
items[itOrbSword] = 60; items[itOrbSword] = 60;
} }
}; };

View File

@ -475,12 +475,9 @@ void initAll() {
#if CAP_SAVE #if CAP_SAVE
loadsave(); loadsave();
#endif #endif
resetGeometry(); start_game();
initcells();
shmup::safety = safety; shmup::safety = safety;
initgame();
restartGraph();
if(!shmup::on) { if(!shmup::on) {
restoreGolems(items[itOrbLife], moGolem); items[itOrbLife] = 0; restoreGolems(items[itOrbLife], moGolem); items[itOrbLife] = 0;

View File

@ -817,7 +817,7 @@ namespace mapeditor {
dialog::openColorDialog((unsigned&)(paintwhat = (painttype ==6 ? paintwhat : 0x808080))); dialog::openColorDialog((unsigned&)(paintwhat = (painttype ==6 ? paintwhat : 0x808080)));
} }
else if(sym == SDLK_F5) { else if(sym == SDLK_F5) {
restartGame(); restart_game();
} }
else if(sym == SDLK_F2) { else if(sym == SDLK_F2) {
dialog::openFileDialog(levelfile, XLAT("level to save:"), ".lev", [] () { dialog::openFileDialog(levelfile, XLAT("level to save:"), ".lev", [] () {
@ -1323,8 +1323,9 @@ namespace mapeditor {
int tg, nt, wp; int tg, nt, wp;
fscanf(f, "%d%d%d%d\n", &tg, &nt, &wp, &patterns::subpattern_flags); fscanf(f, "%d%d%d%d\n", &tg, &nt, &wp, &patterns::subpattern_flags);
patterns::whichPattern = wp; patterns::whichPattern = wp;
if(tg != geometry) { targetgeometry = eGeometry(tg); restartGame(rg::geometry, 0, true); } if(tg != geometry) { targetgeometry = eGeometry(tg); stop_game_and_switch_mode(rg::geometry); }
if(nt != nonbitrunc) { restartGame(rg::bitrunc, 0, true); } if(nt != nonbitrunc) stop_game_and_switch_mode(rg::bitrunc);
start_game();
} }
while(true) { while(true) {

View File

@ -261,7 +261,7 @@ void showMainMenu() {
else if(sym == 't') scores::load(); else if(sym == 't') scores::load();
#endif #endif
else if(uni == 'r' || sym == SDLK_F5) { else if(uni == 'r' || sym == SDLK_F5) {
restartGame(); restart_game();
} }
else if(sym == 'q' || sym == SDLK_F10) { else if(sym == 'q' || sym == SDLK_F10) {
#if ISMOBILE #if ISMOBILE
@ -414,7 +414,7 @@ void showDisplayMode() {
void switchHardcore() { void switchHardcore() {
if(hardcore && !canmove) { if(hardcore && !canmove) {
restartGame(); restart_game();
hardcore = false; hardcore = false;
} }
else if(hardcore && canmove) { hardcore = false; } else if(hardcore && canmove) { hardcore = false; }
@ -506,7 +506,7 @@ void showChangeMode() {
else { else {
popScreen(); popScreen();
firstland = princess::challenge ? laPalace : laIce; firstland = princess::challenge ? laPalace : laIce;
restartGame(); restart_game();
} }
} }
@ -525,7 +525,7 @@ void showChangeMode() {
else if(xuni == 'p') else if(xuni == 'p')
pushScreen(peace::showMenu); pushScreen(peace::showMenu);
else if(xuni == 'i') { else if(xuni == 'i') {
restartGame(rg::inv); restart_game(rg::inv);
} }
#if CAP_TOUR #if CAP_TOUR
else if(uni == 'T') { else if(uni == 'T') {
@ -533,14 +533,14 @@ void showChangeMode() {
} }
#endif #endif
else if(uni == 'C') { else if(uni == 'C') {
if(chaosUnlocked) restartGame(rg::chaos); if(chaosUnlocked) restart_game(rg::chaos);
if(chaosmode) help_nochaos(); if(chaosmode) help_nochaos();
} }
else if(xuni == 'P') { else if(xuni == 'P') {
if(!princess::everSaved) if(!princess::everSaved)
addMessage(XLAT("Save %the1 first to unlock this challenge!", moPrincess)); addMessage(XLAT("Save %the1 first to unlock this challenge!", moPrincess));
else else
restartGame(rg::princess); restart_game(rg::princess);
} }
#if CAP_EDIT #if CAP_EDIT
else if(xuni == 'm') { else if(xuni == 'm') {
@ -556,7 +556,7 @@ void showChangeMode() {
#endif #endif
else if(xuni == 's') { else if(xuni == 's') {
#if ISMOBILE==1 #if ISMOBILE==1
restartGame(rg::shmup); restart_game(rg::shmup);
#else #else
multi::shmupcfg = shmup::on; multi::shmupcfg = shmup::on;
pushScreen(shmup::showShmupConfig); pushScreen(shmup::showShmupConfig);
@ -566,7 +566,7 @@ void showChangeMode() {
switchHardcore(); switchHardcore();
else if(xuni == 'r') { else if(xuni == 'r') {
firstland = laIce; firstland = laIce;
restartGame(rg::randpattern); restart_game(rg::randpattern);
} }
else if(doexiton(sym, uni)) else if(doexiton(sym, uni))
popScreen(); popScreen();
@ -777,7 +777,7 @@ void showStartMenu() {
if(!sphere) { if(!sphere) {
specialland = laHalloween; specialland = laHalloween;
targetgeometry = gSphere; targetgeometry = gSphere;
restartGame(rg::geometry); restart_game(rg::geometry);
vid.alpha = 999; vid.alpha = 999;
vid.scale = 998; vid.scale = 998;
} }

View File

@ -1315,21 +1315,24 @@ namespace patterns {
canvasback = c >> 8; canvasback = c >> 8;
firstland = specialland = laCanvas; firstland = specialland = laCanvas;
randomPatternsMode = false; randomPatternsMode = false;
restartGame(0, false, true); stop_game();
start_game();
}; };
} }
else if(uni == 'i') { else if(uni == 'i') {
canvas_invisible = !canvas_invisible; canvas_invisible = !canvas_invisible;
firstland = specialland = laCanvas; firstland = specialland = laCanvas;
randomPatternsMode = false; randomPatternsMode = false;
restartGame(0, false, true); stop_game();
start_game();
} }
else if((uni >= 'a' && uni <= 'z') || (uni >= 'A' && uni <= 'Z')) { else if((uni >= 'a' && uni <= 'z') || (uni >= 'A' && uni <= 'Z')) {
whichCanvas = uni; whichCanvas = uni;
subcanvas = rand(); subcanvas = rand();
firstland = specialland = laCanvas; firstland = specialland = laCanvas;
randomPatternsMode = false; randomPatternsMode = false;
restartGame(0, false, true); stop_game();
start_game();
if(uni == 'x' || uni == 'z' || uni == 't') if(uni == 'x' || uni == 'z' || uni == 't')
whichPattern = PAT_ZEBRA, subpattern_flags = SPF_SYM0123 | SPF_ROT; whichPattern = PAT_ZEBRA, subpattern_flags = SPF_SYM0123 | SPF_ROT;
if(uni == 'e') if(uni == 'e')
@ -1640,9 +1643,10 @@ namespace patterns {
auto old_tstate_max = texture::config.tstate_max; auto old_tstate_max = texture::config.tstate_max;
#endif #endif
auto &g = cpatterns[cgroup].geometries[uni - 'a']; auto &g = cpatterns[cgroup].geometries[uni - 'a'];
if(g.geo != geometry) { targetgeometry = g.geo; restartGame(rg::geometry, false, true); } if(g.geo != geometry) { targetgeometry = g.geo; stop_game_and_switch_mode(rg::geometry); }
if(gp::on) restartGame(rg::gp, false, true); if(gp::on) stop_game_and_switch_mode(rg::gp);
if(g.nonbitru != nonbitrunc) restartGame(rg::bitrunc, false, true); if(g.nonbitru != nonbitrunc) stop_game_and_switch_mode(rg::bitrunc);;
start_game();
whichPattern = g.whichPattern; whichPattern = g.whichPattern;
subpattern_flags = g.subpattern_flags; subpattern_flags = g.subpattern_flags;
#if CAP_TEXTURE #if CAP_TEXTURE

View File

@ -179,7 +179,7 @@ hint hints[] = {
}, },
[]() { []() {
#if CAP_INV #if CAP_INV
restartGame(rg::inv); restart_game(rg::inv);
#endif #endif
} }
}, },
@ -273,7 +273,7 @@ hint hints[] = {
resetModes(); resetModes();
specialland = laHalloween; specialland = laHalloween;
targetgeometry = gSphere; targetgeometry = gSphere;
restartGame(rg::geometry); restart_game(rg::geometry);
vid.alpha = 999; vid.alpha = 999;
vid.scale = 998; vid.scale = 998;
} }
@ -476,7 +476,7 @@ void handleKeyQuit(int sym, int uni) {
if(sym == SDLK_RETURN || sym == SDLK_KP_ENTER || sym == SDLK_F10) quitmainloop = true; if(sym == SDLK_RETURN || sym == SDLK_KP_ENTER || sym == SDLK_F10) quitmainloop = true;
else if(uni == 'r' || sym == SDLK_F5) { else if(uni == 'r' || sym == SDLK_F5) {
restartGame(); restart_game(rg::nothing);
msgs.clear(); msgs.clear();
} }
else if(uni == 'v') popScreenAll(), pushScreen(showMainMenu); else if(uni == 'v') popScreenAll(), pushScreen(showMainMenu);

View File

@ -546,12 +546,6 @@ void sominit(int initto) {
init(); kind = kKohonen; init(); kind = kKohonen;
/* if(geometry != gQuotient1) {
targetGeometry = gQuotient1;
restartGame(rg::geometry);
}
if(!nonbitrunc) restartGame(rg::bitrunc); */
printf("Initializing SOM (1)\n"); printf("Initializing SOM (1)\n");
vector<cell*> allcells; vector<cell*> allcells;

View File

@ -1342,11 +1342,10 @@ void init() {
#if !ISWEB #if !ISWEB
mapeditor::drawplayer = false; mapeditor::drawplayer = false;
firstland = specialland = laCanvas; firstland = specialland = laCanvas;
if(!shmup::on) restartGame(rg::shmup); restart_game(shmup::on ? rg::shmup : rg::nothing);
else restartGame();
#else #else
firstland = specialland = laCanvas; firstland = specialland = laCanvas;
restartGame(); restart_game(rg::nothing);
#endif #endif
on = true; on = true;
items[itOrbLife] = 0; items[itOrbLife] = 0;
@ -1839,7 +1838,7 @@ slide rvslides[] = {
if(mode == pmStartAll) firstland = specialland = laPalace; if(mode == pmStartAll) firstland = specialland = laPalace;
if(mode == 4) { if(mode == 4) {
tour::slides = default_slides; tour::slides = default_slides;
while(tour::on) restartGame(rg::tour, false); while(tour::on) restart_game(rg::tour);
firstland = specialland = laIce; firstland = specialland = laIce;
tour::start(); tour::start();
} }
@ -1973,7 +1972,7 @@ slide rvslides[] = {
"Press '5' to leave the presentation.", "Press '5' to leave the presentation.",
[] (presmode mode) { [] (presmode mode) {
firstland = specialland = laIce; firstland = specialland = laIce;
if(mode == 4) restartGame(rg::tour); if(mode == 4) restart_game(rg::tour);
} }
} }
}; };

View File

@ -407,8 +407,8 @@ help += XLAT("This menu can be also used to configure keys.\n\n");
} }
else if(doexiton(sym, uni)) { else if(doexiton(sym, uni)) {
popScreen(); popScreen();
if(shmup::on != shmupcfg) { restartGame(rg::shmup); resetScores(); } if(shmup::on != shmupcfg) { restart_game(rg::shmup); resetScores(); }
else if(vid.scfg.players != players) { restartGame(); resetScores(); } else if(vid.scfg.players != players) { restart_game(); resetScores(); }
} }
} }
else if(sc == SCJOY) { else if(sc == SCJOY) {

View File

@ -4,6 +4,10 @@
// routines for: initializing/closing, loading/saving, and cheating // routines for: initializing/closing, loading/saving, and cheating
bool need_reset_geometry = true;
bool game_active;
bool cblind; bool cblind;
bool autocheat; bool autocheat;
bool canvas_invisible; bool canvas_invisible;
@ -1059,9 +1063,10 @@ namespace gamestack {
}; };
void popGame() { void pop_game() {
if(gamestack::pushed()) { if(gamestack::pushed()) {
gamestack::pop(); gamestack::pop();
game_active = true;
} }
} }
@ -1071,152 +1076,175 @@ void popAllGames() {
} }
} }
void restartGame(char switchWhat, bool push, bool keep_screens) { void stop_game() {
if(!keep_screens) popScreenAll(); if(!game_active) return;
DEBB(DF_INIT, (debugfile,"restartGame\n")); achievement_final(true);
#if CAP_SAVE
saveStats();
if(push) { #endif
gamestack::push(); for(int i=0; i<ittypes; i++) items[i] = 0;
pd_from = NULL; lastkills = 0; for(int i=0; i<motypes; i++) kills[i] = 0;
centerover.c = NULL; for(int i=0; i<10; i++) explore[i] = 0;
} for(int i=0; i<10; i++) for(int l=0; l<landtypes; l++)
else { exploreland[i][l] = 0;
popAllGames();
achievement_final(true); for(int i=0; i<numplayers(); i++)
#if CAP_SAVE if(multi::playerActive(i))
saveStats(); multi::deaths[i]++;
#endif
for(int i=0; i<ittypes; i++) items[i] = 0; #if CAP_SAVE
lastkills = 0; for(int i=0; i<motypes; i++) kills[i] = 0; anticheat::tampered = false;
for(int i=0; i<10; i++) explore[i] = 0; #endif
for(int i=0; i<10; i++) for(int l=0; l<landtypes; l++) achievementsReceived.clear();
exploreland[i][l] = 0; princess::saved = false;
princess::nodungeon = false;
for(int i=0; i<numplayers(); i++) princess::reviveAt = 0;
if(multi::playerActive(i)) princess::forceVizier = false;
multi::deaths[i]++; princess::forceMouse = false;
knighted = 0;
#if CAP_SAVE // items[itGreenStone] = 100;
anticheat::tampered = false; clearMemory();
#endif game_active = false;
achievementsReceived.clear();
princess::saved = false;
princess::nodungeon = false;
princess::reviveAt = 0;
princess::forceVizier = false;
princess::forceMouse = false;
knighted = 0;
// items[itGreenStone] = 100;
clearMemory();
}
#if CAP_DAILY #if CAP_DAILY
if(daily::on && !among(switchWhat, rg::daily, rg::daily_off)) if(daily::on && !among(switchWhat, rg::daily, rg::daily_off))
daily::turnoff(); daily::turnoff();
#endif #endif
if(switchWhat == rg::peace) { }
peace::on = !peace::on;
tactic::on = yendor::on = princess::challenge =
randomPatternsMode = inv::on = false;
}
if(switchWhat == rg::inv) {
inv::on = !inv::on;
if(tactic::on) firstland = laIce;
tactic::on = yendor::on = princess::challenge =
randomPatternsMode = peace::on = false;
}
if(switchWhat == rg::chaos) {
if(euclid || sphere || quotient)
geometry = gNormal;
if(tactic::on) firstland = laIce;
yendor::on = tactic::on = princess::challenge = false;
resetGeometry();
chaosmode = !chaosmode;
}
#if CAP_TOUR
if(switchWhat == rg::tour) {
geometry = gNormal;
yendor::on = tactic::on = princess::challenge = peace::on = inv::on = false;
chaosmode = nonbitrunc = randomPatternsMode = false;
shmup::on = false;
resetGeometry();
tour::on = !tour::on;
}
#endif
if(switchWhat == rg::bitrunc || switchWhat == rg::gp) {
if(euclid6) geometry = gNormal;
nonbitrunc = !nonbitrunc;
gp::on = (switchWhat == rg::gp && !gp::on);
resetGeometry();
#if CAP_TEXTURE
if(texture::config.tstate == texture::tsActive)
texture::config.tstate = texture::tsAdjusting;
if(texture::config.tstate_max == texture::tsActive)
texture::config.tstate = texture::tsAdjusting;
#endif
}
if(switchWhat == rg::geometry) {
if(geometry == targetgeometry) geometry = gNormal;
else geometry = targetgeometry;
if(chaosmode && (euclid || sphere || quotient)) chaosmode = false;
if(nonbitrunc && euclid6) nonbitrunc = false;
if(gp::on && (S3 != 3 || elliptic)) gp::on = false;
resetGeometry(); void push_game() {
#if CAP_TEXTURE gamestack::push();
if(texture::config.tstate == texture::tsActive) pd_from = NULL;
texture::config.tstate = texture::tsOff; centerover.c = NULL;
if(texture::config.tstate_max == texture::tsActive) game_active = false;
texture::config.tstate = texture::tsAdjusting; }
#endif
} void switch_game_mode(char switchWhat) {
if(switchWhat == rg::yendor) { switch(switchWhat) {
yendor::on = !yendor::on; case rg::peace:
tactic::on = false; peace::on = !peace::on;
peace::on = false; tactic::on = yendor::on = princess::challenge =
inv::on = false; randomPatternsMode = inv::on = false;
princess::challenge = false; break;
randomPatternsMode = false;
chaosmode = false; case rg::inv:
if(!yendor::on) firstland = laIce; inv::on = !inv::on;
} if(tactic::on) firstland = laIce;
if(switchWhat == rg::tactic) { tactic::on = yendor::on = princess::challenge =
tactic::on = !tactic::on; randomPatternsMode = peace::on = false;
yendor::on = false; break;
peace::on = false;
inv::on = false; case rg::chaos:
randomPatternsMode = false; if(euclid || sphere || quotient)
princess::challenge = false; geometry = gNormal;
chaosmode = false; if(tactic::on) firstland = laIce;
if(!tactic::on) firstland = laIce; yendor::on = tactic::on = princess::challenge = false;
} need_reset_geometry = true;
if(switchWhat == rg::shmup) { chaosmode = !chaosmode;
shmup::on = !shmup::on; break;
princess::challenge = false;
} #if CAP_TOUR
if(switchWhat == rg::randpattern) { case rg::tour:
randomPatternsMode = !randomPatternsMode; geometry = gNormal;
tactic::on = false; yendor::on = tactic::on = princess::challenge = peace::on = inv::on = false;
yendor::on = false; chaosmode = nonbitrunc = randomPatternsMode = false;
peace::on = false; shmup::on = false;
inv::on = false; need_reset_geometry = true;
princess::challenge = false; tour::on = !tour::on;
} break;
#if CAP_DAILY #endif
if(switchWhat == rg::daily)
daily::setup(); case rg::bitrunc:
if(switchWhat == rg::daily_off) case rg::gp:
daily::turnoff(); if(euclid6) geometry = gNormal;
nonbitrunc = !nonbitrunc;
gp::on = (switchWhat == rg::gp && !gp::on);
need_reset_geometry = true;
#if CAP_TEXTURE
if(texture::config.tstate == texture::tsActive)
texture::config.tstate = texture::tsAdjusting;
if(texture::config.tstate_max == texture::tsActive)
texture::config.tstate = texture::tsAdjusting;
#endif
break;
case rg::geometry:
if(geometry == targetgeometry) geometry = gNormal;
else geometry = targetgeometry;
if(chaosmode && (euclid || sphere || quotient)) chaosmode = false;
if(nonbitrunc && euclid6) nonbitrunc = false;
if(gp::on && (S3 != 3 || elliptic)) gp::on = false;
need_reset_geometry = true;
#if CAP_TEXTURE
if(texture::config.tstate == texture::tsActive)
texture::config.tstate = texture::tsOff;
if(texture::config.tstate_max == texture::tsActive)
texture::config.tstate = texture::tsAdjusting;
#endif
break;
case rg::yendor:
yendor::on = !yendor::on;
tactic::on = false;
peace::on = false;
inv::on = false;
princess::challenge = false;
randomPatternsMode = false;
chaosmode = false;
if(!yendor::on) firstland = laIce;
break;
case rg::tactic:
tactic::on = !tactic::on;
yendor::on = false;
peace::on = false;
inv::on = false;
randomPatternsMode = false;
princess::challenge = false;
chaosmode = false;
if(!tactic::on) firstland = laIce;
break;
case rg::shmup:
shmup::on = !shmup::on;
princess::challenge = false;
break;
case rg::randpattern:
randomPatternsMode = !randomPatternsMode;
tactic::on = false;
yendor::on = false;
peace::on = false;
inv::on = false;
princess::challenge = false;
break;
case rg::princess:
princess::challenge = !princess::challenge;
firstland = princess::challenge ? laPalace : laIce;
shmup::on = false;
tactic::on = false;
yendor::on = false;
chaosmode = false;
inv::on = false;
break;
#if CAP_DAILY
case rg::daily:
daily::setup();
break;
case rg::daily_off:
daily::turnoff();
break;
#endif #endif
if(switchWhat == rg::princess) {
princess::challenge = !princess::challenge;
firstland = princess::challenge ? laPalace : laIce;
shmup::on = false;
tactic::on = false;
yendor::on = false;
chaosmode = false;
inv::on = false;
} }
}
void start_game() {
if(game_active) return;
game_active = true;
if(need_reset_geometry) resetGeometry();
initcells(); initcells();
if(randomPatternsMode) { if(randomPatternsMode) {
@ -1237,7 +1265,20 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
resetmusic(); resetmusic();
resetmusic(); resetmusic();
} }
void restart_game(char switchWhat) {
popScreenAll();
popAllGames();
stop_game();
switch_game_mode(switchWhat);
start_game();
}
void stop_game_and_switch_mode(char switchWhat) {
stop_game();
switch_game_mode(switchWhat);
}
purehookset clearmemory; purehookset clearmemory;
void clearMemory() { void clearMemory() {

View File

@ -875,14 +875,16 @@ bool texture_config::load() {
dynamicval<int> d2(patterns::subpattern_flags, patterns::subpattern_flags); dynamicval<int> d2(patterns::subpattern_flags, patterns::subpattern_flags);
if(targetgeometry != geometry) { if(targetgeometry != geometry) {
restartGame(rg::geometry); stop_game_and_switch_mode(rg::geometry);
return config.load(); return config.load();
} }
if(nonbitrunc != target_nonbitru) { if(nonbitrunc != target_nonbitru) {
restartGame(rg::bitrunc); stop_game_and_switch_mode(rg::bitrunc);
} }
} }
start_game();
if(true) { if(true) {
celllister cl(currentmap->gamestart(), 20, 10000, NULL); celllister cl(currentmap->gamestart(), 20, 10000, NULL);

View File

@ -22,16 +22,17 @@ void setCanvas(presmode mode, char canv) {
static char wc; static char wc;
static eLand ld; static eLand ld;
if(mode == pmStart) { if(mode == pmStart) {
push_game();
wc = patterns::whichCanvas; wc = patterns::whichCanvas;
patterns::whichCanvas = canv; patterns::whichCanvas = canv;
ld = firstland; ld = firstland;
firstland = laCanvas; firstland = laCanvas;
restartGame(0, true); start_game();
} }
if(mode == pmStop) { if(mode == pmStop) {
patterns::whichCanvas = wc; patterns::whichCanvas = wc;
firstland = ld; firstland = ld;
popGame(); pop_game();
} }
} }
@ -73,7 +74,7 @@ void slidehelp() {
} }
void return_geometry() { void return_geometry() {
popGame(); pop_game();
vid.scale = 1; vid.alpha = 1; vid.scale = 1; vid.alpha = 1;
presentation(pmGeometryReset); presentation(pmGeometryReset);
addMessage(XLAT("Returned to your game.")); addMessage(XLAT("Returned to your game."));
@ -99,7 +100,7 @@ bool handleKeyTour(int sym, int uni) {
} }
if(sym == SDLK_BACKSPACE) { if(sym == SDLK_BACKSPACE) {
if(geometry || nonbitrunc) { if(geometry || nonbitrunc) {
popGame(); pop_game();
if(!(flags & QUICKGEO)) return true; if(!(flags & QUICKGEO)) return true;
} }
if(currentslide == 0) { slidehelp(); return true; } if(currentslide == 0) { slidehelp(); return true; }
@ -157,7 +158,9 @@ bool handleKeyTour(int sym, int uni) {
if(sym == '2') targetgeometry = gEuclid, vid.alpha = 1, vid.scale = .5; if(sym == '2') targetgeometry = gEuclid, vid.alpha = 1, vid.scale = .5;
firstland = specialland = cwt.c->land; firstland = specialland = cwt.c->land;
restartGame(sym == '3' ? rg::bitrunc : rg::geometry, true); push_game();
switch_game_mode(sym == '3' ? rg::bitrunc : rg::geometry);
start_game();
presentation(pmGeometryStart); presentation(pmGeometryStart);
string x; string x;
if(slides[currentslide].flags & USE_SLIDE_NAME) { if(slides[currentslide].flags & USE_SLIDE_NAME) {
@ -279,11 +282,11 @@ namespace ss {
keyhandler = [] (int sym, int uni) { keyhandler = [] (int sym, int uni) {
if(uni >= 'a' && uni < 'a' + sssize) { if(uni >= 'a' && uni < 'a' + sssize) {
if(geometry || nonbitrunc) { if(geometry || nonbitrunc) {
popGame(); pop_game();
presentation(pmGeometryReset); presentation(pmGeometryReset);
} }
if(slides != wts) { if(slides != wts) {
while(tour::on) restartGame(rg::tour, false); while(tour::on) restart_game(rg::tour);
slides = wts; slides = wts;
tour::start(); tour::start();
} }
@ -317,7 +320,7 @@ void start() {
presentation(pmStop); presentation(pmStop);
firstland = specialland = laIce; firstland = specialland = laIce;
} }
restartGame(rg::tour); restart_game(rg::tour);
if(tour::on) { if(tour::on) {
slidehelp(); slidehelp();
presentation(pmStart); presentation(pmStart);
@ -370,7 +373,7 @@ slide default_slides[] = {
"as an introduction to hyperbolic geometry."; "as an introduction to hyperbolic geometry.";
if(mode == 4) { if(mode == 4) {
slides = rogueviz::rvtour::rvslides; slides = rogueviz::rvtour::rvslides;
while(tour::on) restartGame(rg::tour, false); while(tour::on) restart_game(rg::tour);
tour::start(); tour::start();
} }
#endif #endif
@ -770,11 +773,13 @@ slide default_slides[] = {
[] (presmode mode) { [] (presmode mode) {
if(mode == 1) { if(mode == 1) {
firstland = cwt.c->land; firstland = cwt.c->land;
restartGame(rg::shmup, true); push_game();
switch_game_mode(rg::shmup);
start_game();
} }
if(mode == 3) { if(mode == 3) {
shmup::clearMonsters(); shmup::clearMonsters();
popGame(); pop_game();
} }
} }
}, },
@ -787,7 +792,7 @@ slide default_slides[] = {
"Press '5' to leave the tutorial mode.", "Press '5' to leave the tutorial mode.",
[] (presmode mode) { [] (presmode mode) {
slidecommand = "leave the Tutorial"; slidecommand = "leave the Tutorial";
if(mode == 4) restartGame(rg::tour); if(mode == 4) restart_game(rg::tour);
} }
} }
}; };

View File

@ -505,13 +505,13 @@ namespace yendor {
if(new_challenge && new_challenge < YENDORLEVELS) { if(new_challenge && new_challenge < YENDORLEVELS) {
if(levelUnlocked(new_challenge) || autocheat) { if(levelUnlocked(new_challenge) || autocheat) {
challenge = new_challenge; challenge = new_challenge;
restartGame(yendor::on ? 0 : rg::yendor); restart_game(yendor::on ? rg::nothing : rg::yendor);
} }
else else
addMessage("Collect 10 treasures in various lands to unlock the challenges there"); addMessage("Collect 10 treasures in various lands to unlock the challenges there");
} }
else if(uni == '0') { else if(uni == '0') {
if(yendor::on) restartGame(rg::yendor); if(yendor::on) restart_game(rg::yendor);
} }
else if(uni == '1') easy = !easy; else if(uni == '1') easy = !easy;
else if(uni == '2' || sym == SDLK_F1) gotoHelp(chelp); else if(uni == '2' || sym == SDLK_F1) gotoHelp(chelp);
@ -748,11 +748,11 @@ namespace tactic {
keyhandler = [] (int sym, int uni) { keyhandler = [] (int sym, int uni) {
if(uni >= 1000 && uni < 1000 + size(landlist)) { if(uni >= 1000 && uni < 1000 + size(landlist)) {
specialland = landlist[uni - 1000]; specialland = landlist[uni - 1000];
restartGame(tactic::on ? 0 : rg::tactic); restart_game(tactic::on ? rg::nothing : rg::tactic);
} }
else if(uni == '0') { else if(uni == '0') {
firstland = laIce; firstland = laIce;
if(tactic::on) restartGame(rg::tactic); if(tactic::on) restart_game(rg::tactic);
else popScreen(); else popScreen();
} }
@ -1086,12 +1086,12 @@ namespace peace {
if(uni == '1') otherpuzzles = !otherpuzzles; if(uni == '1') otherpuzzles = !otherpuzzles;
else if(uni >= 'a' && uni < 'a' + qty) { else if(uni >= 'a' && uni < 'a' + qty) {
specialland = levellist[uni - 'a']; specialland = levellist[uni - 'a'];
restartGame(peace::on ? 0 : rg::peace); restart_game(peace::on ? 0 : rg::peace);
} }
else if(uni == '2') { hint = !hint; popScreen(); } else if(uni == '2') { hint = !hint; popScreen(); }
else if(uni == '0') { else if(uni == '0') {
firstland = laIce; firstland = laIce;
if(peace::on) restartGame(rg::peace); if(peace::on) restart_game(rg::peace);
} }
else if(uni == 'h' || sym == SDLK_F1) gotoHelp(chelp); else if(uni == 'h' || sym == SDLK_F1) gotoHelp(chelp);
else if(doexiton(sym, uni)) popScreen(); else if(doexiton(sym, uni)) popScreen();