From 9fc4e5524f1866f29b045280a39279fb8daf10f5 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Tue, 17 Jul 2018 14:18:41 +0200 Subject: [PATCH] irr:: ignore achievements/leaderboards; rewritten the modecode/finalAchievement code a bit --- achievement.cpp | 61 +++++++++++++++------------- hyper.h | 1 + irregular.cpp | 9 +++++ yendor.cpp | 103 ++++++++++++++++++------------------------------ 4 files changed, 81 insertions(+), 93 deletions(-) diff --git a/achievement.cpp b/achievement.cpp index d197dae0..d18a9b73 100644 --- a/achievement.cpp +++ b/achievement.cpp @@ -79,6 +79,7 @@ bool wrongMode(char flags) { if(flags == rg::global) return false; if(nonbitrunc != (flags == rg::bitrunc)) return true; if(gp::on) return true; + if(irr::on) return true; if((geometry != gNormal) != (flags == rg::geometry)) return true; @@ -563,12 +564,14 @@ int next_stat_tick; void achievement_final(bool really_final) { if(offlineMode) return; + #ifdef HAVE_ACHIEVEMENTS if(ticks > next_stat_tick) { upload_score(LB_STATISTICS, time(NULL)); next_stat_tick = ticks + 600000; } if(cheater) return; + #if CAP_TOUR if(tour::on) return; #endif @@ -584,13 +587,6 @@ void achievement_final(bool really_final) { return; } - if(sphere && specialland == laHalloween) { - if(shmup::on || chaosmode || nonbitrunc || numplayers() > 1 || tactic::on || randomPatternsMode) - return; - achievement_score(LB_HALLOWEEN, items[itTreat]); - return; - } - #if CAP_DAILY if(daily::on) { daily::uploadscore(really_final); @@ -598,33 +594,42 @@ void achievement_final(bool really_final) { } #endif + int specialcode = 0; + if(shmup::on) specialcode++; + if(chaosmode) specialcode+=2; + if(nonbitrunc) specialcode+=4; + if(numplayers() > 1) specialcode+=8; + if(inv::on) specialcode+=16; + + if(sphere && specialland == laHalloween) { + if(specialcode) return; + achievement_score(LB_HALLOWEEN, items[itTreat]); + return; + } + if(geometry) return; + if(gp::on) return; + if(irr::on) return; - // no leaderboards for two special modes at once - int specials = 0; - if(shmup::on) specials++; - if(chaosmode) specials++; - if(nonbitrunc) specials++; - if(gp::on) specials++; - #if CAP_DALIY - if(daily::on) return; - #endif - if(inv::on) specials++; - if(specials > 1) return; - - if(numplayers() > 1 && chaosmode) return; - if(numplayers() > 1 && nonbitrunc) return; - if(numplayers() > 1 && inv::on) return; - + // determine the correct leaderboard ID for 'total score' + // or return if no leaderboard for the current mode + int sid; + switch(specialcode) { + case 0: sid = 0; break; + case 1: sid = 28; break; + case 2: sid = 53; break; + case 4: sid = 57; break; + case 8: sid = 61; break; + case 9: sid = 44; break; + case 16: sid = 69; break; + default: return; + } + int total_improved = 0; specific_improved = 0; specific_what = 0; - if(!shmup::on && !chaosmode && !nonbitrunc && numplayers() == 1 && !inv::on) improveItemScores(); - - int sid = nonbitrunc ? 57 : chaosmode ? 53 : shmup::on ? (numplayers() > 1 ? 44 : 28) : - inv::on ? 69 : - (numplayers() > 1 ? 61 : 0); + if(specials == 0) improveItemScores(); int tg = gold(); if(tg && haveLeaderboard(sid)) { diff --git a/hyper.h b/hyper.h index 02d81a30..667daa8f 100644 --- a/hyper.h +++ b/hyper.h @@ -2563,6 +2563,7 @@ namespace irr { bool ctof(cell* c); bool supports(eGeometry g); void visual_creator(); + unsigned char density_code(); } extern hrmap *currentmap; diff --git a/irregular.cpp b/irregular.cpp index c355a932..5a88a219 100644 --- a/irregular.cpp +++ b/irregular.cpp @@ -576,6 +576,15 @@ int readArgs() { return 0; } +unsigned char density_code() { + if(sc < 128) return sc; + else { + int t = 127, a = sc; + while(a > 127) a = a * 9/10, t++; + return t; + } + } + bool pseudohept(cell* c) { return cells[cellindex[c]].is_pseudohept; } diff --git a/yendor.cpp b/yendor.cpp index 94f7167e..03fed64a 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -795,6 +795,17 @@ namespace tactic { }; +// Identifiers for the current combinations of game modes +// These are recorded in the save file, so it is somewhat +// important that they do not change for already existing +// modes, as otherwise the scores would be lost. +// Unfortunately, the codes assigned when HyperRogue had +// just a few special modes did not really follow a specific +// rule, so this system has grown rather ugly as the +// number of special modes kept growing... + +// mode codes for 'old' modes, from 0 to 255 + int modecodetable[42][6] = { { 0, 38, 39, 40, 41, 42}, // softcore hyperbolic { 7, 43, 44, 45, 46, 47}, // hardcore hyperbolic @@ -839,14 +850,14 @@ int modecodetable[42][6] = { {242,243,244,245,246,247}, // hardcore heptagonal elliptic chaosmode {248,249,250,251,252,253}, // shmup heptagonal elliptic chaosmode }; -// unused code: 25 -int newmodecode = 255; +// unused codes: 6 (cheat/tampered), 25, 254, 255 int modecode() { #if CAP_SAVE if(anticheat::tampered || cheater) return 6; #endif + // compute the old code int xcode = 0; if(shmup::on) xcode += 2; @@ -858,82 +869,44 @@ int modecode() { if(sphere) { xcode += 9; if(elliptic) xcode += 6; - if(nonbitrunc) xcode += 3; } if(chaosmode) xcode += 21; int np = numplayers()-1; if(np<0 || np>5) np=5; + // bits: 0 to 7 int mct = modecodetable[xcode][np]; -/* - if(geometry == gTorus) mct += 512; - if(geometry == gZebraQuotient) mct += 1024; - if(geometry == gFieldQuotient) mct += 1536; - */ -#if CAP_INV - if(inv::on) mct += 2048; -#endif - if(peace::on) mct += 4096; -#if CAP_TOUR - if(tour::on) mct += 8192; -#endif - if(numplayers() == 7) mct += 16384; - - if(gp::on) { - mct += 32768; - mct += gp::param.first << 16; - mct += gp::param.second << 21; - } - + // bits: 9, 10, 15, 16, (reserved for later) 17, 18 mct += ginf[geometry].xcode; - return mct; - } +#if CAP_INV + if(inv::on) mct += (1<<11); +#endif + if(peace::on) mct += (1<<12); +#if CAP_TOUR + if(tour::on) mct += (1<<13); +#endif + if(numplayers() == 7) mct += (1<<14); -void buildmodetable() { - bool codeused[600]; - for(int q=0; q<600; q++) codeused[q] = 0; + // daily/Yendor/Tactics/standard are saved separately, but are using the same codes (Daily uses no code) + // randompattern never records its scores + // no specifics of the advanced configuration of torus/fieldquotient currently recorded - codeused[6] = true; // cheater - - printf("int modecodetable[42][6] = {\n"); - - for(int b=0; b<42; b++) { - extern bool hardcore; - hardcore = (b%3 == 1); - shmup::on = (b%3 == 2); - nonbitrunc = (b/3)%7 == 1 || (b/3)%7 == 4 || (b/3)%7 == 6; - geometry = gNormal; - if((b/3)%7 == 2) geometry = gEuclid; - if((b/3)%7 >= 3) geometry = gSphere; - if((b/3)%7 >= 5) geometry = gElliptic; - chaosmode = b >= 21; - printf(" {"); - for(int p=0; p<6; p++) { - multi::players = p+1; - if(p) printf(","); - int mc = modecode(); - if(codeused[mc]) mc = newmodecode++; - codeused[mc] = true; - printf("%3d", mc); - } - printf("}, //"); - if(hardcore) printf(" hardcore"); - else if(shmup::on) printf(" shmup"); - else printf(" softcore"); - if(nonbitrunc) printf(" heptagonal"); - if(euclid) printf(" euclidean"); - else if(elliptic) printf(" elliptic"); - else if(sphere) printf(" spherical"); - else printf(" hyperbolic"); - if(chaosmode) printf(" chaosmode"); - printf("\n"); + if(gp::on) { + mct += (1 << 19); + auto loc = gp::human_representation(gp::param); + mct += loc.first << 21; // 4 bits + mct += loc.second << 25; // 4 bits } - printf(" }\n"); - for(int i=0; i