- removed some redundant parts in level.cpp

Let's use the underlying data directly.
This commit is contained in:
Christoph Oelckers 2020-08-03 19:11:48 +02:00
parent 5704c57fe0
commit 825b286424
5 changed files with 5 additions and 55 deletions

View file

@ -109,52 +109,6 @@ void CheckKeyAbend(const char *pzSection, const char *pzKey)
ThrowError("Key %s expected in section [%s] of BLOOD.INI", pzKey, pzSection); 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) void levelSetupOptions(int nEpisode, int nLevel)
{ {
@ -244,6 +198,7 @@ void levelLoadDefaults(void)
void levelAddUserMap(const char *pzMap) void levelAddUserMap(const char *pzMap)
{ {
// FIXME: Make this work with the reworked map system
char buffer[BMAX_PATH]; char buffer[BMAX_PATH];
strncpy(buffer, pzMap, BMAX_PATH); strncpy(buffer, pzMap, BMAX_PATH);
ChangeExtension(buffer, ".DEF"); ChangeExtension(buffer, ".DEF");

View file

@ -104,11 +104,6 @@ void levelSetupSecret(int nCount);
void levelTriggerSecret(int nSecret); void levelTriggerSecret(int nSecret);
void CheckSectionAbend(const char *pzSection); void CheckSectionAbend(const char *pzSection);
void CheckKeyAbend(const char *pzSection, const char *pzKey); 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 levelSetupOptions(int nEpisode, int nLevel);
void levelLoadDefaults(void); void levelLoadDefaults(void);
void levelAddUserMap(const char *pzMap); void levelAddUserMap(const char *pzMap);

View file

@ -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); twod->AddColorOnlyQuad(windowxy1.x, windowxy1.y, (windowxy2.x + 1) - windowxy1.x, (windowxy2.y + 1) - windowxy1.y, 0xff000000);
renderDrawMapView(x,y,nZoom>>2,angle); renderDrawMapView(x,y,nZoom>>2,angle);
sub_2541C(x,y,nZoom>>2,angle); sub_2541C(x,y,nZoom>>2,angle);
const char *pTitle = levelGetTitle(); const char *pTitle = currentLevel->DisplayName();
const char *pFilename = levelGetFilename(gGameOptions.nEpisode, gGameOptions.nLevel); const char *pFilename = currentLevel->LabelName();
if (pTitle) if (pTitle)
sprintf(pBuffer, "%s: %s", pFilename, pTitle); sprintf(pBuffer, "%s: %s", pFilename, pTitle);
else else

View file

@ -2182,7 +2182,7 @@ void trInit(void)
void trTextOver(int nId) void trTextOver(int nId)
{ {
const char *pzMessage = levelGetMessage(nId); const char *pzMessage = currentLevel->GetMessage(nId);
if (pzMessage) if (pzMessage)
viewSetMessage(pzMessage, VanillaMode() ? 0 : 8, MESSAGE_PRIORITY_INI); // 8: gold viewSetMessage(pzMessage, VanillaMode() ? 0 : 8, MESSAGE_PRIORITY_INI); // 8: gold
} }

View file

@ -257,7 +257,7 @@ void viewDrawMapTitle(void)
if (alpha != 0) 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);
} }
} }