1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-14 01:16:50 +00:00

restartGame, wrong mode, and resetModes now use constants instead of magic char names

This commit is contained in:
Zeno Rogue 2018-04-09 18:05:23 +02:00
parent b9a6402ba7
commit 033c626dfc
19 changed files with 135 additions and 136 deletions

View File

@ -83,38 +83,13 @@ vector<string> achievementsReceived;
bool wrongMode(char flags) { bool wrongMode(char flags) {
if(cheater) return true; if(cheater) return true;
if(flags == 'x') return false; if(flags == rg::global) return false;
if(nonbitrunc != (flags == '7')) return true; if(nonbitrunc != (flags == rg::bitrunc)) return true;
if(gp::on) return true; if(gp::on) return true;
switch(flags) { if((geometry != gNormal) != (flags == rg::geometry)) return true;
case 'e':
if(geometry != gEuclid)
return true;
break;
case 'E':
if(geometry != gSphere && geometry != gElliptic)
return true;
break;
case 'q':
if(geometry != gQuotient)
return true;
break;
case 'Q': if(shmup::on != (flags == rg::shmup)) return true;
if(geometry != gQuotient2)
return true;
break;
default:
if(geometry != gNormal)
return true;
break;
}
if(shmup::on != (flags == 's')) return true;
if(randomPatternsMode) return true; if(randomPatternsMode) return true;
if(yendor::on) return true; if(yendor::on) return true;
if(peace::on) return true; if(peace::on) return true;
@ -122,8 +97,8 @@ bool wrongMode(char flags) {
#if CAP_TOUR #if CAP_TOUR
if(tour::on) return true; if(tour::on) return true;
#endif #endif
if(chaosmode != (flags == 'C')) return true; if(chaosmode != (flags == rg::chaos)) return true;
if((numplayers() > 1) != (flags == 'm')) return true; if((numplayers() > 1) != (flags == rg::multi)) return true;
return false; return false;
} }
@ -173,11 +148,11 @@ void achievement_collection(eItem it, int prevgold, int newgold) {
if(randomPatternsMode) return; if(randomPatternsMode) return;
int q = items[it]; int q = items[it];
if(it == itTreat && q == 50) if(it == itTreat && q == 50 && (geometry == gSphere || geometry == gElliptic))
achievement_gain("HALLOWEEN1", 'E'); achievement_gain("HALLOWEEN1", rg::geometry);
if(it == itTreat && q == 100) if(it == itTreat && q == 100 && (geometry == gSphere || geometry == gElliptic))
achievement_gain("HALLOWEEN2", 'E'); achievement_gain("HALLOWEEN2", rg::geometry);
if(q == 1) { if(q == 1) {
if(it == itDiamond) achievement_gain("DIAMOND1"); if(it == itDiamond) achievement_gain("DIAMOND1");
@ -245,7 +220,7 @@ void achievement_collection(eItem it, int prevgold, int newgold) {
// 32 // 32
if(it == itHolyGrail) { if(it == itHolyGrail) {
if(q == 1) achievement_gain("GRAIL2"), achievement_gain("GRAILH", '7'); if(q == 1) achievement_gain("GRAIL2"), achievement_gain("GRAILH", rg::bitrunc);
if(q == 3) achievement_gain("GRAIL3"); if(q == 3) achievement_gain("GRAIL3");
if(q == 8) achievement_gain("GRAIL4"); if(q == 8) achievement_gain("GRAIL4");
} }
@ -448,7 +423,7 @@ void achievement_collection(eItem it, int prevgold, int newgold) {
if(it == itOrbYendor) { if(it == itOrbYendor) {
achievement_gain("YENDOR2"); achievement_gain("YENDOR2");
if(pureHardcore()) achievement_gain("HARDCORE"); if(pureHardcore()) achievement_gain("HARDCORE");
if(shmup::on) achievement_gain("SHMUP", 's'); if(shmup::on) achievement_gain("SHMUP", rg::shmup);
} }
} }
@ -486,8 +461,8 @@ void achievement_count(const string& s, int current, int prev) {
achievement_gain("LIGHTNING2"); achievement_gain("LIGHTNING2");
if(s == "LIGHTNING" && current-prev >= 10) if(s == "LIGHTNING" && current-prev >= 10)
achievement_gain("LIGHTNING3"); achievement_gain("LIGHTNING3");
if(s == "MIRAGE" && current >= 35) if(s == "MIRAGE" && current >= 35 && geometry == gEuclid)
achievement_gain("MIRAGE", 'e'); achievement_gain("MIRAGE", rg::geometry);
if(s == "ORB" && current >= 10) if(s == "ORB" && current >= 10)
achievement_gain("ORB3"); achievement_gain("ORB3");
if(s == "BUG" && current >= 1000) if(s == "BUG" && current >= 1000)

View File

@ -275,29 +275,29 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '1') { showstartmenu
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(curphase == 3 && param) {act;} else {PHASE(2); param = false;} }
TOGGLE('o', vid.usingGL, switchGL()) TOGGLE('o', vid.usingGL, switchGL())
TOGGLE('C', chaosmode, restartGame('C')) TOGGLE('C', chaosmode, restartGame(rg::chaos))
TOGGLE('7', nonbitrunc, restartGame('7')) TOGGLE('7', nonbitrunc, restartGame(rg::bitrunc))
TOGGLE('f', vid.full, switchFullscreen()) TOGGLE('f', vid.full, switchFullscreen())
TOGGLE('T', tactic::on, restartGame('t')) TOGGLE('T', tactic::on, restartGame(rg::tactic))
TOGGLE('S', shmup::on, restartGame('s')) TOGGLE('S', shmup::on, restartGame(rg::shmup))
TOGGLE('H', hardcore, switchHardcore()) TOGGLE('H', hardcore, switchHardcore())
TOGGLE('R', randomPatternsMode, restartGame('r')) TOGGLE('R', randomPatternsMode, restartGame(rg::randpattern))
TOGGLE('i', inv::on, restartGame('i')) TOGGLE('i', inv::on, restartGame(rg::inv))
else if(argis("-peace")) { else if(argis("-peace")) {
peace::otherpuzzles = true; peace::otherpuzzles = true;
if(curphase == 3) restartGame('P'); if(curphase == 3) restartGame(rg::peace);
else peace::on = true; else peace::on = true;
} }
else if(argis("-pmem")) { else if(argis("-pmem")) {
peace::otherpuzzles = false; peace::otherpuzzles = false;
if(curphase == 3) restartGame('P'); if(curphase == 3) restartGame(rg::peace);
else peace::on = true; else peace::on = true;
} }
else if(argis("-geo")) { else if(argis("-geo")) {
if(curphase == 3) { if(curphase == 3) {
shift(); targetgeometry = (eGeometry) argi(); shift(); targetgeometry = (eGeometry) argi();
restartGame('g'); restartGame(rg::geometry);
} }
else { else {
PHASE(2); shift(); geometry = targetgeometry = (eGeometry) argi(); PHASE(2); shift(); geometry = targetgeometry = (eGeometry) argi();
@ -330,12 +330,12 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
callhooks(hooks_tests); callhooks(hooks_tests);
else if(argis("-qpar2")) { else if(argis("-qpar2")) {
if(curphase == 3) { if(curphase == 3) {
restartGame('g'); restartGame(rg::geometry);
} }
else { else {
PHASE(2); PHASE(2);
} }
if(geometry == gQuotient2) restartGame('g'); 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;
@ -343,7 +343,7 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
fgeomextras[current_extra].current_prime_id = b; fgeomextras[current_extra].current_prime_id = b;
enableFieldChange(); enableFieldChange();
if(curphase == 3) { if(curphase == 3) {
targetgeometry = gQuotient2; restartGame('g'); targetgeometry = gQuotient2; restartGame(rg::geometry);
} }
else else
geometry = gQuotient2; geometry = gQuotient2;
@ -388,10 +388,10 @@ else if(args()[0] == '-' && args()[1] == x && args()[2] == '0') { showstartmenu
} }
else if(argis("-gp")) { else if(argis("-gp")) {
PHASE(3); PHASE(3);
if(nonbitrunc) restartGame('7'); if(nonbitrunc) restartGame(rg::bitrunc);
shift(); gp::param.first = argi(); shift(); gp::param.first = argi();
shift(); gp::param.second = argi(); shift(); gp::param.second = argi();
restartGame('w'); restartGame(rg::gp);
} }
else if(argis("-P")) { else if(argis("-P")) {
PHASE(2); shift(); PHASE(2); shift();

View File

@ -298,21 +298,21 @@ bool have_current_settings() {
void resetModes(char leave) { void resetModes(char leave) {
popAllGames(); popAllGames();
firstland = laIce; vid.scfg.players = 1; firstland = laIce; vid.scfg.players = 1;
if(shmup::on != (leave == 's')) restartGame('s'); if(shmup::on != (leave == rg::shmup)) restartGame(rg::shmup);
if(inv::on != (leave == 'i')) restartGame('i'); if(inv::on != (leave == rg::inv)) restartGame(rg::inv);
if(chaosmode != (leave == 'C')) restartGame('C'); if(chaosmode != (leave == rg::chaos)) restartGame(rg::chaos);
if(nonbitrunc != (leave == '7')) restartGame('7'); if(nonbitrunc != (leave == rg::bitrunc)) restartGame(rg::bitrunc);
if(peace::on != (leave == 'P')) restartGame('P'); if(peace::on != (leave == rg::peace)) restartGame(rg::peace);
#if CAP_TOUR #if CAP_TOUR
if(tour::on != (leave == 'T')) restartGame('T'); if(tour::on != (leave == rg::tour)) restartGame(rg::tour);
#endif #endif
if(yendor::on != (leave == 'y')) restartGame('y'); if(yendor::on != (leave == rg::yendor)) restartGame(rg::yendor);
if(tactic::on != (leave == 't')) restartGame('t'); if(tactic::on != (leave == rg::tactic)) restartGame(rg::tactic);
if(randomPatternsMode != (leave == 'r')) restartGame('r'); if(randomPatternsMode != (leave == rg::randpattern)) restartGame(rg::randpattern);
if(geometry != gNormal && leave != 'g') { if(geometry != gNormal && leave != rg::geometry) {
targetgeometry = gNormal; targetgeometry = gNormal;
restartGame('g'); restartGame(rg::geometry);
} }
pmodel = mdDisk; vid.alpha = 1; vid.scale = 1; pmodel = mdDisk; vid.alpha = 1; vid.scale = 1;

View File

@ -4233,7 +4233,8 @@ void moveWorm(cell *c) {
else else
addMessage(XLAT("The sandworm explodes!")); addMessage(XLAT("The sandworm explodes!"));
playSound(NULL, "explosion"); playSound(NULL, "explosion");
achievement_gain("ZEBRAWORM", 'q'); if(geometry == gQuotient)
achievement_gain("ZEBRAWORM", rg::geometry);
} }
return; return;
} }
@ -6726,7 +6727,7 @@ bool collectItem(cell *c2, bool telekinesis) {
achievement_victory(true); achievement_victory(true);
if(chaosmode && gold() >= 300 && !chaosAchieved) { if(chaosmode && gold() >= 300 && !chaosAchieved) {
achievement_gain("CHAOS", 'C'); achievement_gain("CHAOS", rg::chaos);
chaosAchieved = true; chaosAchieved = true;
} }

View File

@ -71,14 +71,14 @@ 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('g'); targetgeometry = gxcur.base; restartGame(rg::geometry);
enableFieldChange(); enableFieldChange();
targetgeometry = gQuotient2; restartGame('g'); targetgeometry = gQuotient2; restartGame(rg::geometry);
} }
else if(uni == 'c') { else if(uni == 'c') {
targetgeometry = gEuclid; restartGame('g'); targetgeometry = gEuclid; restartGame(rg::geometry);
fieldpattern::quotient_field_changed = false; fieldpattern::quotient_field_changed = false;
targetgeometry = gQuotient2; restartGame('g'); targetgeometry = gQuotient2; restartGame(rg::geometry);
} }
else if(doexiton(sym, uni)) else if(doexiton(sym, uni))
popScreen(); popScreen();
@ -184,22 +184,22 @@ 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('g', false, true); targetgeometry = gNormal; restartGame(rg::geometry, false, true);
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('7', false, true); if((square && torus_bitrunc) != nonbitrunc) restartGame(rg::bitrunc, false, true);
targetgeometry = gTorus; restartGame('g', false, true); targetgeometry = gTorus; restartGame(rg::geometry, false, true);
} }
else if(uni == 'c') { else if(uni == 'c') {
targetgeometry = gEuclid; restartGame('g', false, true); targetgeometry = gEuclid; restartGame(rg::geometry, false, true);
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('g', false, true); targetgeometry = gTorus; restartGame(rg::geometry, false, true);
} }
else if(uni == 'z') editScale(); else if(uni == 'z') editScale();
#if CAP_RUG #if CAP_RUG
@ -329,7 +329,7 @@ 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 ? 0 : 'g'); restartGame(geometry == targetgeometry ? rg::nothing : rg::geometry);
pushScreen(showEuclideanMenu); pushScreen(showEuclideanMenu);
} }
else if(uni == 't') { else if(uni == 't') {
@ -337,7 +337,7 @@ void showEuclideanMenu() {
else if(S3 == 3) else if(S3 == 3)
gp::configure(); gp::configure();
else { else {
restartGame('7'); restartGame(rg::bitrunc);
pushScreen(showEuclideanMenu); pushScreen(showEuclideanMenu);
} }
} }
@ -423,7 +423,7 @@ void showEuclideanMenu() {
} }
else if(uni == '1') { else if(uni == '1') {
if(chaosUnlocked) { if(chaosUnlocked) {
restartGame('C'); restartGame(rg::chaos);
pushScreen(showEuclideanMenu); pushScreen(showEuclideanMenu);
} }
} }
@ -431,7 +431,7 @@ void showEuclideanMenu() {
eLand nland = landlist[lid]; eLand nland = landlist[lid];
if(landvisited[nland]) { if(landvisited[nland]) {
specialland = nland; specialland = nland;
restartGame(tactic::on ? 't' : 0); restartGame(tactic::on ? rg::tactic : rg::nothing);
pushScreen(showEuclideanMenu); pushScreen(showEuclideanMenu);
} }
} }

View File

@ -407,17 +407,17 @@ namespace gp {
param = loc(x, y); param = loc(x, y);
auto g = screens; auto g = screens;
if(x == 1 && y == 0) { if(x == 1 && y == 0) {
if(gp::on) restartGame('7'); if(gp::on) restartGame(rg::bitrunc);
if(!nonbitrunc) restartGame('7'); if(!nonbitrunc) restartGame(rg::bitrunc);
} }
else if(x == 1 && y == 1) { else if(x == 1 && y == 1) {
if(gp::on) restartGame('7'); if(gp::on) restartGame(rg::bitrunc);
if(nonbitrunc) restartGame('7'); if(nonbitrunc) restartGame(rg::bitrunc);
} }
else { else {
if(nonbitrunc) restartGame('7'); if(nonbitrunc) restartGame(rg::bitrunc);
param = loc(x, y); param = loc(x, y);
restartGame('w'); restartGame(rg::gp);
} }
screens = g; screens = g;
} }

23
hyper.h
View File

@ -362,7 +362,30 @@ typedef int cellfunction(cell*);
int towerval(cell *c, cellfunction* cf = &coastvalEdge); int towerval(cell *c, cellfunction* cf = &coastvalEdge);
#define HRANDMAX 0x7FFFFFFF #define HRANDMAX 0x7FFFFFFF
int hrandpos(); // 0 to HRANDMAX int hrandpos(); // 0 to HRANDMAX
namespace rg {
// possible parameters e.g. for restartGame and wrongmode
static const char nothing = 0;
static const char peace = 'P';
static const char inv = 'i';
static const char chaos = 'C';
static const char tactic = 't';
static const char tour = 'T';
static const char geometry = 'g'; // change targetgeometry first
static const char bitrunc = '7';
static const char gp = 'w'; // change gp::param first
static const char yendor = 'y';
static const char shmup = 's';
static const char randpattern = 'r';
static const char princess = 'p';
// wrongmode only -- marks 'global' achievements not related to the current mode
static const char global = 'x';
// wrongmode only -- change vid.scfg.players then restartGame(rg::nothing) instead
static const char multi = 'm';
}
void restartGame(char switchWhat = 0, bool push = false, bool keep_screens = false); 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);
void buildBarrier(cell *c, int d, eLand l = laNone); void buildBarrier(cell *c, int d, eLand l = laNone);

View File

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

View File

@ -529,9 +529,9 @@ void sominit(int initto) {
/* if(geometry != gQuotient1) { /* if(geometry != gQuotient1) {
targetGeometry = gQuotient1; targetGeometry = gQuotient1;
restartGame('g'); restartGame(rg::geometry);
} }
if(!nonbitrunc) restartGame('7'); */ if(!nonbitrunc) restartGame(rg::bitrunc); */
printf("Initializing SOM (1)\n"); printf("Initializing SOM (1)\n");

View File

@ -1310,8 +1310,8 @@ 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('g', 0, true); } if(tg != geometry) { targetgeometry = eGeometry(tg); restartGame(rg::geometry, 0, true); }
if(nt != nonbitrunc) { restartGame('7', 0, true); } if(nt != nonbitrunc) { restartGame(rg::bitrunc, 0, true); }
} }
while(true) { while(true) {

View File

@ -514,7 +514,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('i'); restartGame(rg::inv);
} }
#if CAP_TOUR #if CAP_TOUR
else if(uni == 'T') { else if(uni == 'T') {
@ -522,14 +522,14 @@ void showChangeMode() {
} }
#endif #endif
else if(uni == 'C') { else if(uni == 'C') {
if(chaosUnlocked) restartGame('C'); if(chaosUnlocked) restartGame(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('p'); restartGame(rg::peace);
} }
#if CAP_EDIT #if CAP_EDIT
else if(xuni == 'm') { else if(xuni == 'm') {
@ -545,7 +545,7 @@ void showChangeMode() {
#endif #endif
else if(xuni == 's') { else if(xuni == 's') {
#if ISMOBILE==1 #if ISMOBILE==1
restartGame('s'); restartGame(rg::shmup);
#else #else
multi::shmupcfg = shmup::on; multi::shmupcfg = shmup::on;
pushScreen(shmup::showShmupConfig); pushScreen(shmup::showShmupConfig);
@ -555,7 +555,7 @@ void showChangeMode() {
switchHardcore(); switchHardcore();
else if(xuni == 'r') { else if(xuni == 'r') {
firstland = laIce; firstland = laIce;
restartGame('r'); restartGame(rg::randpattern);
} }
else if(doexiton(sym, uni)) else if(doexiton(sym, uni))
popScreen(); popScreen();
@ -758,7 +758,7 @@ void showStartMenu() {
if(!sphere) { if(!sphere) {
specialland = laHalloween; specialland = laHalloween;
targetgeometry = gSphere; targetgeometry = gSphere;
restartGame('g'); restartGame(rg::geometry);
vid.alpha = 999; vid.alpha = 999;
vid.scale = 998; vid.scale = 998;
} }

View File

@ -1531,8 +1531,8 @@ 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('g', false, true); } if(g.geo != geometry) { targetgeometry = g.geo; restartGame(rg::geometry, false, true); }
if(g.nonbitru != nonbitrunc) restartGame('7', false, true); if(g.nonbitru != nonbitrunc) restartGame(rg::bitrunc, false, true);
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('i'); restartGame(rg::inv);
#endif #endif
} }
}, },
@ -273,7 +273,7 @@ hint hints[] = {
resetModes(); resetModes();
specialland = laHalloween; specialland = laHalloween;
targetgeometry = gSphere; targetgeometry = gSphere;
restartGame('g'); restartGame(rg::geometry);
vid.alpha = 999; vid.alpha = 999;
vid.scale = 998; vid.scale = 998;
} }

View File

@ -1340,7 +1340,7 @@ void init() {
#if !ISWEB #if !ISWEB
mapeditor::drawplayer = false; mapeditor::drawplayer = false;
firstland = specialland = laCanvas; firstland = specialland = laCanvas;
if(!shmup::on) restartGame('s'); if(!shmup::on) restartGame(rg::shmup);
else restartGame(); else restartGame();
#else #else
firstland = specialland = laCanvas; firstland = specialland = laCanvas;
@ -1834,7 +1834,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('T', false); while(tour::on) restartGame(rg::tour, false);
firstland = specialland = laIce; firstland = specialland = laIce;
tour::start(); tour::start();
} }
@ -1959,7 +1959,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('T'); if(mode == 4) restartGame(rg::tour);
} }
} }
}; };

View File

@ -407,7 +407,7 @@ 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('s'); resetScores(); } if(shmup::on != shmupcfg) { restartGame(rg::shmup); resetScores(); }
else if(vid.scfg.players != players) { restartGame(); resetScores(); } else if(vid.scfg.players != players) { restartGame(); resetScores(); }
} }
} }

View File

@ -1078,18 +1078,18 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
// items[itGreenStone] = 100; // items[itGreenStone] = 100;
clearMemory(); clearMemory();
} }
if(switchWhat == 'P') { if(switchWhat == rg::peace) {
peace::on = !peace::on; peace::on = !peace::on;
tactic::on = yendor::on = princess::challenge = tactic::on = yendor::on = princess::challenge =
randomPatternsMode = inv::on = false; randomPatternsMode = inv::on = false;
} }
if(switchWhat == 'i') { if(switchWhat == rg::inv) {
inv::on = !inv::on; inv::on = !inv::on;
if(tactic::on) firstland = laIce; if(tactic::on) firstland = laIce;
tactic::on = yendor::on = princess::challenge = tactic::on = yendor::on = princess::challenge =
randomPatternsMode = peace::on = false; randomPatternsMode = peace::on = false;
} }
if(switchWhat == 'C') { if(switchWhat == rg::chaos) {
if(euclid || sphere || quotient) if(euclid || sphere || quotient)
geometry = gNormal; geometry = gNormal;
if(tactic::on) firstland = laIce; if(tactic::on) firstland = laIce;
@ -1098,7 +1098,7 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
chaosmode = !chaosmode; chaosmode = !chaosmode;
} }
#if CAP_TOUR #if CAP_TOUR
if(switchWhat == 'T') { if(switchWhat == rg::tour) {
geometry = gNormal; geometry = gNormal;
yendor::on = tactic::on = princess::challenge = peace::on = inv::on = false; yendor::on = tactic::on = princess::challenge = peace::on = inv::on = false;
chaosmode = nonbitrunc = randomPatternsMode = false; chaosmode = nonbitrunc = randomPatternsMode = false;
@ -1107,10 +1107,10 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
tour::on = !tour::on; tour::on = !tour::on;
} }
#endif #endif
if(switchWhat == '7' || switchWhat == 'w') { if(switchWhat == rg::bitrunc || switchWhat == rg::gp) {
if(euclid6) geometry = gNormal; if(euclid6) geometry = gNormal;
nonbitrunc = !nonbitrunc; nonbitrunc = !nonbitrunc;
gp::on = (switchWhat == 'w'); gp::on = (switchWhat == rg::gp);
resetGeometry(); resetGeometry();
#if CAP_TEXTURE #if CAP_TEXTURE
if(texture::config.tstate == texture::tsActive) if(texture::config.tstate == texture::tsActive)
@ -1119,7 +1119,7 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
texture::config.tstate = texture::tsAdjusting; texture::config.tstate = texture::tsAdjusting;
#endif #endif
} }
if(switchWhat == 'g') { if(switchWhat == rg::geometry) {
if(geometry == targetgeometry) geometry = gNormal; if(geometry == targetgeometry) geometry = gNormal;
else geometry = targetgeometry; else geometry = targetgeometry;
if(chaosmode && (euclid || sphere || quotient)) chaosmode = false; if(chaosmode && (euclid || sphere || quotient)) chaosmode = false;
@ -1134,7 +1134,7 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
texture::config.tstate = texture::tsAdjusting; texture::config.tstate = texture::tsAdjusting;
#endif #endif
} }
if(switchWhat == 'y') { if(switchWhat == rg::yendor) {
yendor::on = !yendor::on; yendor::on = !yendor::on;
tactic::on = false; tactic::on = false;
peace::on = false; peace::on = false;
@ -1144,7 +1144,7 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
chaosmode = false; chaosmode = false;
if(!yendor::on) firstland = laIce; if(!yendor::on) firstland = laIce;
} }
if(switchWhat == 't') { if(switchWhat == rg::tactic) {
tactic::on = !tactic::on; tactic::on = !tactic::on;
yendor::on = false; yendor::on = false;
peace::on = false; peace::on = false;
@ -1154,11 +1154,11 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
chaosmode = false; chaosmode = false;
if(!tactic::on) firstland = laIce; if(!tactic::on) firstland = laIce;
} }
if(switchWhat == 's') { if(switchWhat == rg::shmup) {
shmup::on = !shmup::on; shmup::on = !shmup::on;
princess::challenge = false; princess::challenge = false;
} }
if(switchWhat == 'r') { if(switchWhat == rg::randpattern) {
randomPatternsMode = !randomPatternsMode; randomPatternsMode = !randomPatternsMode;
tactic::on = false; tactic::on = false;
yendor::on = false; yendor::on = false;
@ -1166,7 +1166,7 @@ void restartGame(char switchWhat, bool push, bool keep_screens) {
inv::on = false; inv::on = false;
princess::challenge = false; princess::challenge = false;
} }
if(switchWhat == 'p') { if(switchWhat == rg::princess) {
princess::challenge = !princess::challenge; princess::challenge = !princess::challenge;
firstland = princess::challenge ? laPalace : laIce; firstland = princess::challenge ? laPalace : laIce;
shmup::on = false; shmup::on = false;

View File

@ -861,12 +861,12 @@ 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('g'); restartGame(rg::geometry);
return config.load(); return config.load();
} }
if(nonbitrunc != target_nonbitru) { if(nonbitrunc != target_nonbitru) {
restartGame('7'); restartGame(rg::bitrunc);
} }
} }

View File

@ -150,7 +150,7 @@ bool handleKeyTour(int sym, int uni) {
if(sym == '1') targetgeometry = gSphere; if(sym == '1') targetgeometry = gSphere;
if(sym == '2') targetgeometry = gEuclid; if(sym == '2') targetgeometry = gEuclid;
firstland = specialland = cwt.c->land; firstland = specialland = cwt.c->land;
restartGame(sym == '3' ? '7' : 'g', true); restartGame(sym == '3' ? rg::bitrunc : rg::geometry, true);
presentation(pmGeometryStart); presentation(pmGeometryStart);
return true; return true;
} }
@ -258,7 +258,7 @@ namespace ss {
presentation(pmGeometryReset); presentation(pmGeometryReset);
} }
if(slides != wts) { if(slides != wts) {
while(tour::on) restartGame('T', false); while(tour::on) restartGame(rg::tour, false);
slides = wts; slides = wts;
tour::start(); tour::start();
} }
@ -292,7 +292,7 @@ void start() {
presentation(pmStop); presentation(pmStop);
firstland = specialland = laIce; firstland = specialland = laIce;
} }
restartGame('T'); restartGame(rg::tour);
if(tour::on) { if(tour::on) {
slidehelp(); slidehelp();
presentation(pmStart); presentation(pmStart);
@ -345,7 +345,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('T', false); while(tour::on) restartGame(rg::tour, false);
tour::start(); tour::start();
} }
#endif #endif
@ -742,7 +742,7 @@ slide default_slides[] = {
[] (presmode mode) { [] (presmode mode) {
if(mode == 1) { if(mode == 1) {
firstland = cwt.c->land; firstland = cwt.c->land;
restartGame('s', true); restartGame(rg::shmup, true);
} }
if(mode == 3) { if(mode == 3) {
shmup::clearMonsters(); shmup::clearMonsters();
@ -759,7 +759,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('T'); if(mode == 4) restartGame(rg::tour);
} }
} }
}; };

View File

@ -98,9 +98,9 @@ namespace yendor {
if(tscore > tscorelast) { if(tscore > tscorelast) {
tscorelast = tscore; tscorelast = tscore;
if(tscore >= 1000) achievement_gain("YENDC1", 'x'); if(tscore >= 1000) achievement_gain("YENDC1", rg::global);
if(tscore >= 5000) achievement_gain("YENDC2", 'x'); if(tscore >= 5000) achievement_gain("YENDC2", rg::global);
if(tscore >= 15000) achievement_gain("YENDC3", 'x'); if(tscore >= 15000) achievement_gain("YENDC3", rg::global);
} }
achievement_score(LB_YENDOR_CHALLENGE, tscore); achievement_score(LB_YENDOR_CHALLENGE, tscore);
@ -504,13 +504,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 : 'y'); restartGame(yendor::on ? 0 : 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('y'); if(yendor::on) restartGame(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);
@ -742,11 +742,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)) {
firstland = specialland = landlist[uni - 1000]; firstland = specialland = landlist[uni - 1000];
restartGame(tactic::on ? 0 : 't'); restartGame(tactic::on ? 0 : rg::tactic);
} }
else if(uni == '0') { else if(uni == '0') {
firstland = laIce; firstland = laIce;
if(tactic::on) restartGame('t'); if(tactic::on) restartGame(rg::tactic);
else popScreen(); else popScreen();
} }
@ -1074,12 +1074,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 : 'P'); restartGame(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('P'); if(peace::on) restartGame(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();