summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-10-18 03:55:02 +0200
committerTreeki <treeki@gmail.com>2012-10-18 03:55:02 +0200
commitedf303f6ba8e30e04e828cb0b9b268d534f194c4 (patch)
tree88a6c51b3045470694cb56c161cdf53a578f0944 /src
parent9af56ee115dea9cbb9ee5b8317fefdb396a0e744 (diff)
downloadkamek-edf303f6ba8e30e04e828cb0b9b268d534f194c4.tar.gz
kamek-edf303f6ba8e30e04e828cb0b9b268d534f194c4.zip
refactored level info a little
Diffstat (limited to 'src')
-rw-r--r--src/koopatlas/core.cpp7
-rw-r--r--src/koopatlas/core.h3
-rw-r--r--src/koopatlas/hud.cpp4
-rw-r--r--src/koopatlas/pathmanager.cpp2
-rw-r--r--src/levelinfo.cpp20
-rw-r--r--src/levelinfo.h2
-rw-r--r--src/pregame.cpp23
7 files changed, 28 insertions, 33 deletions
diff --git a/src/koopatlas/core.cpp b/src/koopatlas/core.cpp
index 462b995..b635ba0 100644
--- a/src/koopatlas/core.cpp
+++ b/src/koopatlas/core.cpp
@@ -176,9 +176,7 @@ bool WMInit_LoadResources1(void *ptr) {
dScKoopatlas_c *wm = (dScKoopatlas_c*)ptr;
- bool result1 = wm->mapListLoader.load("/Maps/List.txt");
- bool result2 = wm->levelInfoLoader.load("/NewerRes/LevelInfo.bin");
- return result1 && result2;
+ return wm->mapListLoader.load("/Maps/List.txt");
}
bool WMInit_LoadResources2(void *ptr) {
@@ -250,8 +248,6 @@ bool WMInit_SetupExtra(void *ptr) {
wm->player->modelHandler->mdlClass->startAnimation(0, 1.2f, 10.0f, 0.0f);
// since we've got all the resources, set up the path data too
- SpammyReport("preparing level info\n");
- wm->levelInfo.load(wm->levelInfoLoader.buffer);
SpammyReport("preparing path manager\n");
wm->pathManager.setup();
@@ -424,7 +420,6 @@ int dScKoopatlas_c::onDelete() {
DVD_FreeFile(GetDVDClass2(), "SI_propeller");
DVD_FreeFile(GetDVDClass2(), "SI_star");
- levelInfoLoader.unload();
mapListLoader.unload();
CleanUpEffectThings();
diff --git a/src/koopatlas/core.h b/src/koopatlas/core.h
index 0f7c3a3..88efdba 100644
--- a/src/koopatlas/core.h
+++ b/src/koopatlas/core.h
@@ -113,9 +113,6 @@ class dScKoopatlas_c : public dScene_c {
const char *getMapNameForIndex(int index);
int getIndexForMapName(const char *name);
- dDvdLoader_c levelInfoLoader;
- dLevelInfo_c levelInfo;
-
void startLevel(dLevelInfo_c::entry_s *level);
bool canDoStuff();
diff --git a/src/koopatlas/hud.cpp b/src/koopatlas/hud.cpp
index a32d32a..2288fe7 100644
--- a/src/koopatlas/hud.cpp
+++ b/src/koopatlas/hud.cpp
@@ -322,7 +322,7 @@ void dWMHud_c::playHideAnim(int id) {
void dWMHud_c::loadHeaderInfo() {
- dLevelInfo_c *levelInfo = &dScKoopatlas_c::instance->levelInfo;
+ dLevelInfo_c *levelInfo = &dLevelInfo_c::s_info;
dLevelInfo_c::entry_s *infEntry = levelInfo->searchBySlot(
nodeForHeader->levelNumber[0]-1, nodeForHeader->levelNumber[1]-1);
@@ -464,7 +464,7 @@ void dWMHud_c::loadFooterInfo() {
bool starVisibility[3];
starVisibility[0] = false;
- dLevelInfo_c *linfo = &dScKoopatlas_c::instance->levelInfo;
+ dLevelInfo_c *linfo = &dLevelInfo_c::s_info;
dLevelInfo_c::entry_s *lastLevel = linfo->searchByDisplayNum(save->newerWorldID, lastLevelIDs[save->newerWorldID]);
if (lastLevel) {
starVisibility[0] = (save->GetLevelCondition(lastLevel->worldSlot,lastLevel->levelSlot) & COND_NORMAL);
diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp
index 5cf029c..95c545f 100644
--- a/src/koopatlas/pathmanager.cpp
+++ b/src/koopatlas/pathmanager.cpp
@@ -746,7 +746,7 @@ void dWMPathManager_c::activatePoint() {
isEnteringLevel = true;
levelStartWait = 40;
- enteredLevel = dScKoopatlas_c::instance->levelInfo.searchBySlot(w, l);
+ enteredLevel = dLevelInfo_c::s_info.searchBySlot(w, l);
}
}
diff --git a/src/levelinfo.cpp b/src/levelinfo.cpp
index d5ef8e7..4d80492 100644
--- a/src/levelinfo.cpp
+++ b/src/levelinfo.cpp
@@ -1,5 +1,25 @@
#include "levelinfo.h"
+dDvdLoader_c s_levelInfoLoader;
+bool s_levelInfoLoaded = false;
+
+dLevelInfo_c dLevelInfo_c::s_info;
+
+bool LoadLevelInfo() {
+ if (s_levelInfoLoaded)
+ return true;
+
+ void *data = s_levelInfoLoader.load("/NewerRes/LevelInfo.bin");
+ if (data) {
+ dLevelInfo_c::s_info.load(data);
+ s_levelInfoLoaded = true;
+ return true;
+ }
+
+ return false;
+}
+
+
void dLevelInfo_c::load(void *buffer) {
data = (header_s*)buffer;
diff --git a/src/levelinfo.h b/src/levelinfo.h
index 8c8fe58..1e9ee6c 100644
--- a/src/levelinfo.h
+++ b/src/levelinfo.h
@@ -47,6 +47,8 @@ public:
const char *getNameForLevel(entry_s *entry) {
return (const char*)data + entry->nameOffset;
}
+
+ static dLevelInfo_c s_info;
};
diff --git a/src/pregame.cpp b/src/pregame.cpp
index 7600902..3a2e89c 100644
--- a/src/pregame.cpp
+++ b/src/pregame.cpp
@@ -2,25 +2,6 @@
#include "levelinfo.h"
#include <newer.h>
-dDvdLoader_c s_levelInfoLoader;
-dLevelInfo_c s_levelInfo;
-bool s_levelInfoLoaded = false;
-
-// TODO: refactor this a tiny bit
-bool LoadLevelInfo() {
- if (s_levelInfoLoaded)
- return true;
-
- void *data = s_levelInfoLoader.load("/NewerRes/LevelInfo.bin");
- if (data) {
- s_levelInfo.load(data);
- s_levelInfoLoaded = true;
- return true;
- }
-
- return false;
-}
-
class PregameLytHandler {
public:
m2d::EmbedLayout_c layout;
@@ -84,10 +65,10 @@ void PregameLytHandler::hijack_loadLevelNumber() {
LevelName = layout.findTextBoxByName("LevelName");
// work out the thing now
- dLevelInfo_c::entry_s *level = s_levelInfo.searchBySlot(CurrentWorld, CurrentLevel);
+ dLevelInfo_c::entry_s *level = dLevelInfo_c::s_info.searchBySlot(CurrentWorld, CurrentLevel);
if (level) {
wchar_t convLevelName[160];
- const char *srcLevelName = s_levelInfo.getNameForLevel(level);
+ const char *srcLevelName = dLevelInfo_c::s_info.getNameForLevel(level);
int i = 0;
while (i < 159 && srcLevelName[i]) {
convLevelName[i] = srcLevelName[i];