From 05eb1400faaa957905fbbe8fa284df4ab1472a58 Mon Sep 17 00:00:00 2001 From: Treeki Date: Thu, 20 Sep 2012 15:30:05 +0200 Subject: cleaning up in preparation for the new HUD, plus a few other changes --- src/newer.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/newer.cpp') diff --git a/src/newer.cpp b/src/newer.cpp index 6d672e2..2bad8a0 100644 --- a/src/newer.cpp +++ b/src/newer.cpp @@ -1,4 +1,5 @@ #include +#include NWRWorld NewerWorldForLevelID(int w, int l) { switch (w) { @@ -75,3 +76,23 @@ const wchar_t *NewerWorldName(NWRWorld world) { return L"Unknown World"; return NewerWorldNames[world]; } + + +int getStarCoinCount() { + SaveBlock *save = GetSaveFile()->GetBlock(-1); + int coinsSpent = save->credits_hiscore; + int coinsEarned = 0; + + for (int w = 0; w < 10; w++) { + for (int l = 0; l < 10; l++) { + u32 conds = save->GetLevelCondition(w, l); + + if (conds & COND_COIN1) { coinsEarned++; } + if (conds & COND_COIN2) { coinsEarned++; } + if (conds & COND_COIN3) { coinsEarned++; } + } + } + + int coinsLeft = coinsEarned - coinsSpent; + return coinsLeft; +} -- cgit v1.2.3