2019-09-19 22:42:45 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
2019-09-21 18:59:54 +00:00
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "compat.h"
|
|
|
|
#include "common_game.h"
|
|
|
|
|
|
|
|
#include "asound.h"
|
|
|
|
#include "blood.h"
|
|
|
|
#include "config.h"
|
|
|
|
#include "credits.h"
|
|
|
|
#include "endgame.h"
|
|
|
|
#include "inifile.h"
|
|
|
|
#include "levels.h"
|
|
|
|
#include "loadsave.h"
|
|
|
|
#include "messages.h"
|
|
|
|
#include "network.h"
|
|
|
|
#include "screen.h"
|
|
|
|
#include "seq.h"
|
|
|
|
#include "sound.h"
|
|
|
|
#include "sfx.h"
|
|
|
|
#include "view.h"
|
2019-10-07 19:29:52 +00:00
|
|
|
#include "eventq.h"
|
2019-11-24 23:02:00 +00:00
|
|
|
#include "menu/menu.h"
|
2019-09-19 22:42:45 +00:00
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2019-09-19 22:42:45 +00:00
|
|
|
GAMEOPTIONS gGameOptions;
|
|
|
|
|
|
|
|
GAMEOPTIONS gSingleGameOptions = {
|
2019-12-07 17:28:30 +00:00
|
|
|
0, 2, 0, 0, "", 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 3600, 1800, 1800, 7200
|
2019-09-19 22:42:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
EPISODEINFO gEpisodeInfo[kMaxEpisodes+1];
|
|
|
|
|
|
|
|
int gSkill = 2;
|
|
|
|
int gEpisodeCount;
|
|
|
|
int gNextLevel;
|
|
|
|
bool gGameStarted;
|
|
|
|
|
|
|
|
int gLevelTime;
|
|
|
|
|
|
|
|
char BloodIniFile[BMAX_PATH] = "BLOOD.INI";
|
|
|
|
char BloodIniPre[BMAX_PATH];
|
|
|
|
bool bINIOverride = false;
|
|
|
|
IniFile *BloodINI;
|
|
|
|
|
|
|
|
|
|
|
|
void levelInitINI(const char *pzIni)
|
|
|
|
{
|
2019-12-07 09:31:27 +00:00
|
|
|
if (!fileSystem.FileExists(pzIni))
|
2019-09-19 22:42:45 +00:00
|
|
|
ThrowError("Initialization: %s does not exist", pzIni);
|
|
|
|
BloodINI = new IniFile(pzIni);
|
|
|
|
Bstrncpy(BloodIniFile, pzIni, BMAX_PATH);
|
|
|
|
Bstrncpy(BloodIniPre, pzIni, BMAX_PATH);
|
|
|
|
ChangeExtension(BloodIniPre, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void levelOverrideINI(const char *pzIni)
|
|
|
|
{
|
|
|
|
bINIOverride = true;
|
|
|
|
strcpy(BloodIniFile, pzIni);
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelPlayIntroScene(int nEpisode)
|
|
|
|
{
|
|
|
|
gGameOptions.uGameFlags &= ~4;
|
2019-12-25 00:10:13 +00:00
|
|
|
Mus_SetPaused(true);
|
2019-09-19 22:42:45 +00:00
|
|
|
sndKillAllSounds();
|
|
|
|
sfxKillAllSounds();
|
|
|
|
ambKillAll();
|
|
|
|
seqKillAll();
|
|
|
|
EPISODEINFO *pEpisode = &gEpisodeInfo[nEpisode];
|
|
|
|
credPlaySmk(pEpisode->at8f08, pEpisode->at9030, pEpisode->at9028);
|
|
|
|
viewResizeView(gViewSize);
|
|
|
|
credReset();
|
2019-12-25 00:10:13 +00:00
|
|
|
Mus_SetPaused(false);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void levelPlayEndScene(int nEpisode)
|
|
|
|
{
|
|
|
|
gGameOptions.uGameFlags &= ~8;
|
2019-12-07 17:28:30 +00:00
|
|
|
Mus_Stop();
|
2019-09-19 22:42:45 +00:00
|
|
|
sndKillAllSounds();
|
|
|
|
sfxKillAllSounds();
|
|
|
|
ambKillAll();
|
|
|
|
seqKillAll();
|
|
|
|
EPISODEINFO *pEpisode = &gEpisodeInfo[nEpisode];
|
|
|
|
credPlaySmk(pEpisode->at8f98, pEpisode->at90c0, pEpisode->at902c);
|
|
|
|
viewResizeView(gViewSize);
|
|
|
|
credReset();
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelClearSecrets(void)
|
|
|
|
{
|
|
|
|
gSecretMgr.Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelSetupSecret(int nCount)
|
|
|
|
{
|
|
|
|
gSecretMgr.SetCount(nCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelTriggerSecret(int nSecret)
|
|
|
|
{
|
|
|
|
gSecretMgr.Found(nSecret);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CheckSectionAbend(const char *pzSection)
|
|
|
|
{
|
|
|
|
if (!pzSection || !BloodINI->SectionExists(pzSection))
|
|
|
|
ThrowError("Section [%s] expected in BLOOD.INI", pzSection);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CheckKeyAbend(const char *pzSection, const char *pzKey)
|
|
|
|
{
|
|
|
|
dassert(pzSection != NULL);
|
|
|
|
|
|
|
|
if (!pzKey || !BloodINI->KeyExists(pzSection, pzKey))
|
|
|
|
ThrowError("Key %s expected in section [%s] of BLOOD.INI", pzKey, pzSection);
|
|
|
|
}
|
|
|
|
|
2019-12-10 23:57:53 +00:00
|
|
|
MapRecord * levelGetInfoPtr(int nEpisode, int nLevel)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
dassert(nEpisode >= 0 && nEpisode < gEpisodeCount);
|
|
|
|
EPISODEINFO *pEpisodeInfo = &gEpisodeInfo[nEpisode];
|
|
|
|
dassert(nLevel >= 0 && nLevel < pEpisodeInfo->nLevels);
|
2019-12-10 23:57:53 +00:00
|
|
|
return &pEpisodeInfo->levels[nLevel];
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 23:57:53 +00:00
|
|
|
const char * levelGetFilename(int nEpisode, int nLevel)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
dassert(nEpisode >= 0 && nEpisode < gEpisodeCount);
|
|
|
|
EPISODEINFO *pEpisodeInfo = &gEpisodeInfo[nEpisode];
|
|
|
|
dassert(nLevel >= 0 && nLevel < pEpisodeInfo->nLevels);
|
2019-12-10 23:57:53 +00:00
|
|
|
return pEpisodeInfo->levels[nLevel].labelName;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 23:57:53 +00:00
|
|
|
const char * levelGetMessage(int nMessage)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int nEpisode = gGameOptions.nEpisode;
|
|
|
|
int nLevel = gGameOptions.nLevel;
|
|
|
|
dassert(nMessage < kMaxMessages);
|
2019-12-10 23:57:53 +00:00
|
|
|
const char *pMessage = gEpisodeInfo[nEpisode].levels[nLevel].GetMessage(nMessage);
|
2019-09-19 22:42:45 +00:00
|
|
|
if (*pMessage == 0)
|
|
|
|
return NULL;
|
|
|
|
return pMessage;
|
|
|
|
}
|
|
|
|
|
2019-12-10 23:57:53 +00:00
|
|
|
const char * levelGetTitle(void)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int nEpisode = gGameOptions.nEpisode;
|
|
|
|
int nLevel = gGameOptions.nLevel;
|
2019-12-10 23:57:53 +00:00
|
|
|
const char *pTitle = gEpisodeInfo[nEpisode].levels[nLevel].DisplayName();
|
2019-09-19 22:42:45 +00:00
|
|
|
if (*pTitle == 0)
|
|
|
|
return NULL;
|
|
|
|
return pTitle;
|
|
|
|
}
|
|
|
|
|
2019-12-10 23:57:53 +00:00
|
|
|
const char * levelGetAuthor(void)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
int nEpisode = gGameOptions.nEpisode;
|
|
|
|
int nLevel = gGameOptions.nLevel;
|
2019-12-10 23:57:53 +00:00
|
|
|
const char *pAuthor = gEpisodeInfo[nEpisode].levels[nLevel].author;
|
2019-09-19 22:42:45 +00:00
|
|
|
if (*pAuthor == 0)
|
|
|
|
return NULL;
|
|
|
|
return pAuthor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelSetupOptions(int nEpisode, int nLevel)
|
|
|
|
{
|
|
|
|
gGameOptions.nEpisode = nEpisode;
|
|
|
|
gGameOptions.nLevel = nLevel;
|
2019-12-10 23:57:53 +00:00
|
|
|
strcpy(gGameOptions.zLevelName, gEpisodeInfo[nEpisode].levels[nLevel].labelName);
|
2019-09-19 22:42:45 +00:00
|
|
|
gGameOptions.uMapCRC = dbReadMapCRC(gGameOptions.zLevelName);
|
2019-12-10 23:57:53 +00:00
|
|
|
gGameOptions.nTrackNumber = gEpisodeInfo[nEpisode].levels[nLevel].cdSongId;
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
2019-12-10 23:57:53 +00:00
|
|
|
void levelLoadMapInfo(IniFile *pIni, MapRecord *pLevelInfo, const char *pzSection, int epinum, int mapnum)
|
2019-09-19 22:42:45 +00:00
|
|
|
{
|
|
|
|
char buffer[16];
|
2019-12-10 23:57:53 +00:00
|
|
|
pLevelInfo->SetName(pIni->GetKeyString(pzSection, "Title", pLevelInfo->labelName));
|
|
|
|
pLevelInfo->author = pIni->GetKeyString(pzSection, "Author", "");
|
2019-12-25 00:10:13 +00:00
|
|
|
pLevelInfo->music = pIni->GetKeyString(pzSection, "Song", ""); DefaultExtension(pLevelInfo->music, ".mid");
|
2019-12-10 23:57:53 +00:00
|
|
|
pLevelInfo->cdSongId = pIni->GetKeyInt(pzSection, "Track", -1);
|
|
|
|
pLevelInfo->nextLevel = pIni->GetKeyInt(pzSection, "EndingA", -1); //if (pLevelInfo->nextLevel >= 0) pLevelInfo->nextLevel +epinum * kMaxLevels;
|
|
|
|
pLevelInfo->nextSecret = pIni->GetKeyInt(pzSection, "EndingB", -1); //if (pLevelInfo->nextSecret >= 0) pLevelInfo->nextSecret + epinum * kMaxLevels;
|
|
|
|
pLevelInfo->fog = pIni->GetKeyInt(pzSection, "Fog", -0);
|
|
|
|
pLevelInfo->weather = pIni->GetKeyInt(pzSection, "Weather", -0);
|
|
|
|
pLevelInfo->messageStart = 1024 + ((epinum * kMaxLevels) + mapnum) * kMaxMessages;
|
2019-09-19 22:42:45 +00:00
|
|
|
for (int i = 0; i < kMaxMessages; i++)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "Message%d", i+1);
|
2019-12-10 23:57:53 +00:00
|
|
|
quoteMgr.InitializeQuote(pLevelInfo->messageStart + i, pIni->GetKeyString(pzSection, buffer, ""), true);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelLoadDefaults(void)
|
|
|
|
{
|
|
|
|
char buffer[64];
|
|
|
|
char buffer2[16];
|
2019-11-01 21:17:15 +00:00
|
|
|
levelInitINI(G_ConFile()); // This doubles for the INI in the global code.
|
2019-09-19 22:42:45 +00:00
|
|
|
memset(gEpisodeInfo, 0, sizeof(gEpisodeInfo));
|
2019-12-10 23:57:53 +00:00
|
|
|
quoteMgr.InitializeQuote(MUS_INTRO, "PESTIS.MID");
|
2019-09-19 22:42:45 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < kMaxEpisodes; i++)
|
|
|
|
{
|
|
|
|
sprintf(buffer, "Episode%d", i+1);
|
|
|
|
if (!BloodINI->SectionExists(buffer))
|
|
|
|
break;
|
|
|
|
EPISODEINFO *pEpisodeInfo = &gEpisodeInfo[i];
|
2019-11-24 23:02:00 +00:00
|
|
|
auto ep_str = BloodINI->GetKeyString(buffer, "Title", buffer);
|
2019-12-08 23:33:14 +00:00
|
|
|
gVolumeNames[i] = ep_str; // only keep one table for the names. Todo: Consolidate this across games.
|
2019-09-19 22:42:45 +00:00
|
|
|
strncpy(pEpisodeInfo->at8f08, BloodINI->GetKeyString(buffer, "CutSceneA", ""), BMAX_PATH);
|
|
|
|
pEpisodeInfo->at9028 = BloodINI->GetKeyInt(buffer, "CutWavA", -1);
|
|
|
|
if (pEpisodeInfo->at9028 == 0)
|
|
|
|
strncpy(pEpisodeInfo->at9030, BloodINI->GetKeyString(buffer, "CutWavA", ""), BMAX_PATH);
|
|
|
|
else
|
|
|
|
pEpisodeInfo->at9030[0] = 0;
|
|
|
|
strncpy(pEpisodeInfo->at8f98, BloodINI->GetKeyString(buffer, "CutSceneB", ""), BMAX_PATH);
|
|
|
|
pEpisodeInfo->at902c = BloodINI->GetKeyInt(buffer, "CutWavB", -1);
|
|
|
|
if (pEpisodeInfo->at902c == 0)
|
|
|
|
strncpy(pEpisodeInfo->at90c0, BloodINI->GetKeyString(buffer, "CutWavB", ""), BMAX_PATH);
|
|
|
|
else
|
|
|
|
pEpisodeInfo->at90c0[0] = 0;
|
|
|
|
|
|
|
|
pEpisodeInfo->bloodbath = BloodINI->GetKeyInt(buffer, "BloodBathOnly", 0);
|
|
|
|
pEpisodeInfo->cutALevel = BloodINI->GetKeyInt(buffer, "CutSceneALevel", 0);
|
|
|
|
if (pEpisodeInfo->cutALevel > 0)
|
|
|
|
pEpisodeInfo->cutALevel--;
|
2019-12-10 23:57:53 +00:00
|
|
|
pEpisodeInfo->levels = mapList + i * kMaxLevels;
|
2019-09-19 22:42:45 +00:00
|
|
|
int j;
|
|
|
|
for (j = 0; j < kMaxLevels; j++)
|
|
|
|
{
|
2019-12-10 23:57:53 +00:00
|
|
|
auto pLevelInfo = &pEpisodeInfo->levels[j];
|
2019-09-19 22:42:45 +00:00
|
|
|
sprintf(buffer2, "Map%d", j+1);
|
|
|
|
if (!BloodINI->KeyExists(buffer, buffer2))
|
|
|
|
break;
|
|
|
|
const char *pMap = BloodINI->GetKeyString(buffer, buffer2, NULL);
|
|
|
|
CheckSectionAbend(pMap);
|
2019-12-10 23:57:53 +00:00
|
|
|
pLevelInfo->labelName = pMap;
|
|
|
|
pLevelInfo->fileName.Format("%s.map", pMap);
|
|
|
|
levelLoadMapInfo(BloodINI, pLevelInfo, pMap, i, j);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
pEpisodeInfo->nLevels = j;
|
|
|
|
}
|
|
|
|
gEpisodeCount = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelAddUserMap(const char *pzMap)
|
|
|
|
{
|
|
|
|
char buffer[BMAX_PATH];
|
|
|
|
strncpy(buffer, pzMap, BMAX_PATH);
|
|
|
|
ChangeExtension(buffer, ".DEF");
|
|
|
|
|
|
|
|
IniFile UserINI(buffer);
|
|
|
|
int nEpisode = ClipRange(UserINI.GetKeyInt(NULL, "Episode", 0), 0, 5);
|
|
|
|
EPISODEINFO *pEpisodeInfo = &gEpisodeInfo[nEpisode];
|
|
|
|
int nLevel = ClipRange(UserINI.GetKeyInt(NULL, "Level", pEpisodeInfo->nLevels), 0, 15);
|
|
|
|
if (nLevel >= pEpisodeInfo->nLevels)
|
|
|
|
{
|
|
|
|
if (pEpisodeInfo->nLevels == 0)
|
|
|
|
{
|
|
|
|
gEpisodeCount++;
|
2019-12-08 23:33:14 +00:00
|
|
|
gVolumeNames[nEpisode].Format("Episode %d", nEpisode+1);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
nLevel = pEpisodeInfo->nLevels++;
|
|
|
|
}
|
2019-12-10 23:57:53 +00:00
|
|
|
auto pLevelInfo = &pEpisodeInfo->levels[nLevel];
|
2019-09-19 22:42:45 +00:00
|
|
|
ChangeExtension(buffer, "");
|
2019-12-10 23:57:53 +00:00
|
|
|
pLevelInfo->name = buffer;
|
|
|
|
levelLoadMapInfo(&UserINI, pLevelInfo, NULL, nEpisode, nLevel);
|
2019-09-19 22:42:45 +00:00
|
|
|
gGameOptions.nEpisode = nEpisode;
|
|
|
|
gGameOptions.nLevel = nLevel;
|
2019-12-10 23:57:53 +00:00
|
|
|
gGameOptions.uMapCRC = dbReadMapCRC(pLevelInfo->name);
|
|
|
|
strcpy(gGameOptions.zLevelName, pLevelInfo->name);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void levelGetNextLevels(int nEpisode, int nLevel, int *pnEndingA, int *pnEndingB)
|
|
|
|
{
|
|
|
|
dassert(pnEndingA != NULL && pnEndingB != NULL);
|
2019-12-10 23:57:53 +00:00
|
|
|
auto pLevelInfo = &gEpisodeInfo[nEpisode].levels[nLevel];
|
|
|
|
int nEndingA = pLevelInfo->nextLevel;
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nEndingA >= 0)
|
|
|
|
nEndingA--;
|
2019-12-10 23:57:53 +00:00
|
|
|
int nEndingB = pLevelInfo->nextSecret;
|
2019-09-19 22:42:45 +00:00
|
|
|
if (nEndingB >= 0)
|
|
|
|
nEndingB--;
|
|
|
|
*pnEndingA = nEndingA;
|
|
|
|
*pnEndingB = nEndingB;
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelEndLevel(int arg)
|
|
|
|
{
|
|
|
|
int nEndingA, nEndingB;
|
|
|
|
EPISODEINFO *pEpisodeInfo = &gEpisodeInfo[gGameOptions.nEpisode];
|
|
|
|
gGameOptions.uGameFlags |= 1;
|
|
|
|
levelGetNextLevels(gGameOptions.nEpisode, gGameOptions.nLevel, &nEndingA, &nEndingB);
|
|
|
|
switch (arg)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
if (nEndingA == -1)
|
|
|
|
{
|
|
|
|
if (pEpisodeInfo->at8f98[0])
|
|
|
|
gGameOptions.uGameFlags |= 8;
|
|
|
|
gGameOptions.nLevel = 0;
|
|
|
|
gGameOptions.uGameFlags |= 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gNextLevel = nEndingA;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (nEndingB == -1)
|
|
|
|
{
|
|
|
|
if (gGameOptions.nEpisode + 1 < gEpisodeCount)
|
|
|
|
{
|
|
|
|
if (pEpisodeInfo->at8f98[0])
|
|
|
|
gGameOptions.uGameFlags |= 8;
|
|
|
|
gGameOptions.nLevel = 0;
|
|
|
|
gGameOptions.uGameFlags |= 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gGameOptions.nLevel = 0;
|
|
|
|
gGameOptions.uGameFlags |= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
gNextLevel = nEndingB;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void levelRestart(void)
|
|
|
|
{
|
|
|
|
levelSetupOptions(gGameOptions.nEpisode, gGameOptions.nLevel);
|
|
|
|
gStartNewGame = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int levelGetMusicIdx(const char *str)
|
|
|
|
{
|
|
|
|
int32_t lev, ep;
|
|
|
|
signed char b1, b2;
|
|
|
|
|
|
|
|
int numMatches = sscanf(str, "%c%d%c%d", &b1, &ep, &b2, &lev);
|
|
|
|
|
|
|
|
if (numMatches != 4 || Btoupper(b1) != 'E' || Btoupper(b2) != 'L')
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if ((unsigned)--lev >= kMaxLevels || (unsigned)--ep >= kMaxEpisodes)
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
return (ep * kMaxLevels) + lev;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool levelTryPlayMusic(int nEpisode, int nLevel, bool bSetLevelSong)
|
|
|
|
{
|
2019-12-25 00:10:13 +00:00
|
|
|
FString buffer;
|
2019-12-10 23:57:53 +00:00
|
|
|
if (mus_redbook && gEpisodeInfo[nEpisode].levels[nLevel].cdSongId > 0)
|
2019-12-25 00:10:13 +00:00
|
|
|
buffer.Format("blood%02i.ogg", gEpisodeInfo[nEpisode].levels[nLevel].cdSongId);
|
2019-09-19 22:42:45 +00:00
|
|
|
else
|
2019-12-07 17:28:30 +00:00
|
|
|
{
|
2019-12-25 00:10:13 +00:00
|
|
|
buffer = gEpisodeInfo[nEpisode].levels[nLevel].music;
|
|
|
|
DefaultExtension(buffer, ".mid");
|
2019-12-07 17:28:30 +00:00
|
|
|
}
|
2019-12-10 23:57:53 +00:00
|
|
|
return !!Mus_Play(gEpisodeInfo[nEpisode].levels[nLevel].labelName, buffer, true);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void levelTryPlayMusicOrNothing(int nEpisode, int nLevel)
|
|
|
|
{
|
2019-12-25 00:10:13 +00:00
|
|
|
if (!levelTryPlayMusic(nEpisode, nLevel, true))
|
2020-03-01 11:57:23 +00:00
|
|
|
Mus_Play("", "", true);
|
2019-09-19 22:42:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class LevelsLoadSave : public LoadSave
|
|
|
|
{
|
|
|
|
virtual void Load(void);
|
|
|
|
virtual void Save(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static LevelsLoadSave *myLoadSave;
|
|
|
|
|
|
|
|
void LevelsLoadSave::Load(void)
|
|
|
|
{
|
|
|
|
Read(&gNextLevel, sizeof(gNextLevel));
|
|
|
|
Read(&gGameOptions, sizeof(gGameOptions));
|
|
|
|
Read(&gGameStarted, sizeof(gGameStarted));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LevelsLoadSave::Save(void)
|
|
|
|
{
|
|
|
|
Write(&gNextLevel, sizeof(gNextLevel));
|
|
|
|
Write(&gGameOptions, sizeof(gGameOptions));
|
|
|
|
Write(&gGameStarted, sizeof(gGameStarted));
|
|
|
|
}
|
|
|
|
|
|
|
|
void LevelsLoadSaveConstruct(void)
|
|
|
|
{
|
|
|
|
myLoadSave = new LevelsLoadSave();
|
|
|
|
}
|
|
|
|
|
2019-09-22 06:39:22 +00:00
|
|
|
END_BLD_NS
|