1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 2010-2019 EDuke32 developers and contributors
4 Copyright (C) 2019 Nuke.YKT
5 
6 This file is part of NBlood.
7 
8 NBlood is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License version 2
10 as published by the Free Software Foundation.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 
16 See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 */
22 //-------------------------------------------------------------------------
23 #pragma once
24 #include "common_game.h"
25 #include "inifile.h"
26 
27 #define kMaxMessages 32
28 #define kMaxEpisodes 7
29 #define kMaxLevels 16
30 
31 #pragma pack(push, 1)
32 
33 struct GAMEOPTIONS {
34     char nGameType;
35     char nDifficulty;
36     int nEpisode;
37     int nLevel;
38     char zLevelName[BMAX_PATH];
39     char zLevelSong[BMAX_PATH];
40     int nTrackNumber; //at12a;
41     char szSaveGameName[BMAX_PATH];
42     char szUserGameName[BMAX_PATH];
43     short nSaveGameSlot;
44     int picEntry;
45     unsigned int uMapCRC;
46     char nMonsterSettings;
47     int uGameFlags;
48     int uNetGameFlags;
49     char nWeaponSettings;
50     char nItemSettings;
51     char nRespawnSettings;
52     char nTeamSettings;
53     int nMonsterRespawnTime;
54     int nWeaponRespawnTime;
55     int nItemRespawnTime;
56     int nSpecialRespawnTime;
57     int weaponsV10x;
58     bool bFriendlyFire;
59     bool bKeepKeysOnRespawn;
60     char szUserMap[BMAX_PATH];
61 };
62 
63 #pragma pack(pop)
64 
65 enum {
66     kLevelExitNormal = 0,
67     kLevelExitSecret
68 };
69 
70 enum {
71     MUS_FIRST_SPECIAL = kMaxEpisodes*kMaxLevels,
72 
73     MUS_INTRO = MUS_FIRST_SPECIAL,
74     MUS_LOADING = MUS_FIRST_SPECIAL + 1,
75 };
76 
77 struct LEVELINFO
78 {
79     char Filename[BMAX_PATH];
80     char Title[32];
81     char Author[32];
82     char Song[BMAX_PATH];
83     int SongId;
84     int EndingA;
85     int EndingB;
86     char Messages[kMaxMessages][64];
87     char Fog;
88     char Weather;
89 }; // 0x8ee bytes
90 
91 struct EPISODEINFO
92 {
93     char title[32];
94     int nLevels;
95     unsigned int bloodbath : 1;
96     unsigned int cutALevel : 4;
97     LEVELINFO levelsInfo[kMaxLevels];
98     char cutsceneASmkPath[BMAX_PATH];
99     char cutsceneBSmkPath[BMAX_PATH];
100     int cutsceneAWavRsrcID;
101     int cutsceneBWavRsrcID;
102     char cutsceneAWavPath[BMAX_PATH];
103     char cutsceneBWavPath[BMAX_PATH];
104 };
105 
106 extern EPISODEINFO gEpisodeInfo[];
107 extern GAMEOPTIONS gSingleGameOptions;
108 extern GAMEOPTIONS gGameOptions;
109 extern int gSkill;
110 extern char BloodIniFile[];
111 extern char BloodIniPre[];
112 extern bool bINIOverride;
113 extern int gEpisodeCount;
114 extern int gNextLevel;
115 extern bool gGameStarted;
116 extern int gLevelTime;
117 
118 void levelInitINI(const char *pzIni);
119 void levelOverrideINI(const char *pzIni);
120 void levelPlayIntroScene(int nEpisode);
121 void levelPlayEndScene(int nEpisode);
122 void levelClearSecrets(void);
123 void levelSetupSecret(int nCount);
124 void levelTriggerSecret(int nSecret);
125 void CheckSectionAbend(const char *pzSection);
126 void CheckKeyAbend(const char *pzSection, const char *pzKey);
127 LEVELINFO * levelGetInfoPtr(int nEpisode, int nLevel);
128 char * levelGetFilename(int nEpisode, int nLevel);
129 char * levelGetMessage(int nMessage);
130 char * levelGetTitle(void);
131 char * levelGetAuthor(void);
132 void levelSetupOptions(int nEpisode, int nLevel);
133 void levelLoadMapInfo(IniFile *pIni, LEVELINFO *pLevelInfo, const char *pzSection);
134 void levelLoadDefaults(void);
135 void levelAddUserMap(const char *pzMap);
136 // EndingA is normal ending, EndingB is secret level
137 void levelGetNextLevels(int nEpisode, int nLevel, int *pnEndingA, int *pnEndingB);
138 // arg: 0 is normal exit, 1 is secret level
139 void levelEndLevel(int nExitType);
140 void levelRestart(void);
141 int levelGetMusicIdx(const char *str);
142 bool levelTryPlayMusic(int nEpisode, int nlevel, bool bSetLevelSong = false);
143 void levelTryPlayMusicOrNothing(int nEpisode, int nLevel);
144