From 6b12a531091c032c9299a1a260a22eacf226c598 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 31 Jan 2013 04:19:18 +0100 Subject: file select's exit counter now ignores non-levels --- src/newer.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/newer.cpp') diff --git a/src/newer.cpp b/src/newer.cpp index 50fc1d1..3635c09 100644 --- a/src/newer.cpp +++ b/src/newer.cpp @@ -1,5 +1,6 @@ #include #include +#include "levelinfo.h" int lastLevelIDs[] = { -1, /*no world*/ @@ -91,3 +92,40 @@ int getStarCoinCount() { return coinsEarned; } + + +struct GEIFS { + int starCoins, exits; +}; +extern "C" GEIFS *GrabExitInfoForFileSelect(GEIFS *out, SaveBlock *save) { + out->starCoins = 0; + out->exits = 0; + + for (int i = 0; i < dLevelInfo_c::s_info.sectionCount(); i++) { + dLevelInfo_c::section_s *section = dLevelInfo_c::s_info.getSectionByIndex(i); + + for (int j = 0; j < section->levelCount; j++) { + dLevelInfo_c::entry_s *l = §ion->levels[j]; + if (l->flags & 2) { + //OSReport("Checking %d-%d...\n", l->worldSlot+1, l->levelSlot+1); + u32 cond = save->GetLevelCondition(l->worldSlot, l->levelSlot); + if ((l->flags & 0x10) && (cond & COND_NORMAL)) + out->exits++; + if ((l->flags & 0x20) && (cond & COND_SECRET)) + out->exits++; + if (cond & COND_COIN1) + out->starCoins++; + if (cond & COND_COIN2) + out->starCoins++; + if (cond & COND_COIN3) + out->starCoins++; + } + } + } + + OSReport("Done, got %d coins and %d exits\n", out->starCoins, out->exits); + + return out; +} + + -- cgit v1.2.3