From 825b2864242a616db1333dc1e9889fbcf14d8e4f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 3 Aug 2020 19:11:48 +0200 Subject: [PATCH] - removed some redundant parts in level.cpp Let's use the underlying data directly. --- source/blood/src/levels.cpp | 47 +---------------------------------- source/blood/src/levels.h | 5 ---- source/blood/src/map2d.cpp | 4 +-- source/blood/src/triggers.cpp | 2 +- source/blood/src/view.cpp | 2 +- 5 files changed, 5 insertions(+), 55 deletions(-) diff --git a/source/blood/src/levels.cpp b/source/blood/src/levels.cpp index bde36ed3b..545249b6b 100644 --- a/source/blood/src/levels.cpp +++ b/source/blood/src/levels.cpp @@ -109,52 +109,6 @@ void CheckKeyAbend(const char *pzSection, const char *pzKey) ThrowError("Key %s expected in section [%s] of BLOOD.INI", pzKey, pzSection); } -MapRecord * levelGetInfoPtr(int nEpisode, int nLevel) -{ - dassert(nEpisode >= 0 && nEpisode < gEpisodeCount); - EPISODEINFO *pEpisodeInfo = &gEpisodeInfo[nEpisode]; - dassert(nLevel >= 0 && nLevel < pEpisodeInfo->nLevels); - return &pEpisodeInfo->levels[nLevel]; -} - -const char * levelGetFilename(int nEpisode, int nLevel) -{ - dassert(nEpisode >= 0 && nEpisode < gEpisodeCount); - EPISODEINFO *pEpisodeInfo = &gEpisodeInfo[nEpisode]; - dassert(nLevel >= 0 && nLevel < pEpisodeInfo->nLevels); - return pEpisodeInfo->levels[nLevel].labelName; -} - -const char * levelGetMessage(int nMessage) -{ - int nEpisode = gGameOptions.nEpisode; - int nLevel = gGameOptions.nLevel; - dassert(nMessage < kMaxMessages); - const char *pMessage = gEpisodeInfo[nEpisode].levels[nLevel].GetMessage(nMessage); - if (*pMessage == 0) - return NULL; - return pMessage; -} - -const char * levelGetTitle(void) -{ - int nEpisode = gGameOptions.nEpisode; - int nLevel = gGameOptions.nLevel; - const char *pTitle = gEpisodeInfo[nEpisode].levels[nLevel].DisplayName(); - if (*pTitle == 0) - return NULL; - return pTitle; -} - -const char * levelGetAuthor(void) -{ - int nEpisode = gGameOptions.nEpisode; - int nLevel = gGameOptions.nLevel; - const char *pAuthor = gEpisodeInfo[nEpisode].levels[nLevel].author; - if (*pAuthor == 0) - return NULL; - return pAuthor; -} void levelSetupOptions(int nEpisode, int nLevel) { @@ -244,6 +198,7 @@ void levelLoadDefaults(void) void levelAddUserMap(const char *pzMap) { + // FIXME: Make this work with the reworked map system char buffer[BMAX_PATH]; strncpy(buffer, pzMap, BMAX_PATH); ChangeExtension(buffer, ".DEF"); diff --git a/source/blood/src/levels.h b/source/blood/src/levels.h index 8000be60d..6d8788852 100644 --- a/source/blood/src/levels.h +++ b/source/blood/src/levels.h @@ -104,11 +104,6 @@ void levelSetupSecret(int nCount); void levelTriggerSecret(int nSecret); void CheckSectionAbend(const char *pzSection); void CheckKeyAbend(const char *pzSection, const char *pzKey); -MapRecord * levelGetInfoPtr(int nEpisode, int nLevel); -const char * levelGetFilename(int nEpisode, int nLevel); -const char * levelGetMessage(int nMessage); -const char * levelGetTitle(void); -const char * levelGetAuthor(void); void levelSetupOptions(int nEpisode, int nLevel); void levelLoadDefaults(void); void levelAddUserMap(const char *pzMap); diff --git a/source/blood/src/map2d.cpp b/source/blood/src/map2d.cpp index 6e9d22d0e..30ed614be 100644 --- a/source/blood/src/map2d.cpp +++ b/source/blood/src/map2d.cpp @@ -201,8 +201,8 @@ void CViewMap::sub_25C74(void) twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000); renderDrawMapView(x,y,nZoom>>2,angle); sub_2541C(x,y,nZoom>>2,angle); - const char *pTitle = levelGetTitle(); - const char *pFilename = levelGetFilename(gGameOptions.nEpisode, gGameOptions.nLevel); + const char *pTitle = currentLevel->DisplayName(); + const char *pFilename = currentLevel->LabelName(); if (pTitle) sprintf(pBuffer, "%s: %s", pFilename, pTitle); else diff --git a/source/blood/src/triggers.cpp b/source/blood/src/triggers.cpp index d01a1068c..5bfa6bb67 100644 --- a/source/blood/src/triggers.cpp +++ b/source/blood/src/triggers.cpp @@ -2182,7 +2182,7 @@ void trInit(void) void trTextOver(int nId) { - const char *pzMessage = levelGetMessage(nId); + const char *pzMessage = currentLevel->GetMessage(nId); if (pzMessage) viewSetMessage(pzMessage, VanillaMode() ? 0 : 8, MESSAGE_PRIORITY_INI); // 8: gold } diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 01ebf8e2c..55f8f05d7 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -257,7 +257,7 @@ void viewDrawMapTitle(void) if (alpha != 0) { - viewDrawText(1, levelGetTitle(), 160, 50, -128, 0, 1, 1, 0, alpha); + viewDrawText(1, currentLevel->DisplayName(), 160, 50, -128, 0, 1, 1, 0, alpha); } }