mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
- savegame and mapinfo cleanup in DN3D and RR frontends.
Also added an "end game" flag to the mapinfo. For those who like to assemble single levels into custom episodes. More features for that to come. ;)
This commit is contained in:
parent
4cc22e155f
commit
0e19d4262e
18 changed files with 142 additions and 139 deletions
|
@ -48,6 +48,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "view.h"
|
||||
#include "savegamehelp.h"
|
||||
#include "z_music.h"
|
||||
#include "mapinfo.h"
|
||||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
|
@ -209,7 +210,13 @@ bool GameInterface::SaveGame(FSaveGameNode* node)
|
|||
return false;
|
||||
}
|
||||
auto & li = gEpisodeInfo[gGameOptions.nEpisode].at28[gGameOptions.nLevel];
|
||||
G_WriteSaveHeader(node->SaveTitle, FStringf("%s.map", li.at0), li.at90);
|
||||
// workaround until the level info here has been transitioned.
|
||||
MapRecord mr;
|
||||
mr.name = li.at90;
|
||||
mr.labelName = li.at0;
|
||||
mr.fileName.Format("%s.map", li.at0);
|
||||
currentLevel = &mr;
|
||||
G_WriteSaveHeader(node->SaveTitle);
|
||||
LoadSave::hSFile = NULL;
|
||||
|
||||
return FinishSavegameWrite();
|
||||
|
|
|
@ -31,8 +31,10 @@
|
|||
#include "enet.h"
|
||||
#endif
|
||||
|
||||
MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts.
|
||||
MapRecord *currentLevel;
|
||||
MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts.
|
||||
MapRecord *currentLevel; // level that is currently played. (The real level, not what script hacks modfifying the current level index can pretend.)
|
||||
MapRecord* lastLevel; // Same here, for the last level.
|
||||
MapRecord userMapRecord; // stand-in for the user map.
|
||||
|
||||
void C_CON_SetAliases();
|
||||
InputState inputState;
|
||||
|
@ -428,6 +430,7 @@ int CONFIG_Init()
|
|||
InitStatistics();
|
||||
M_Init();
|
||||
SetDefaultStrings();
|
||||
if (g_gameType & GAMEFLAG_RR) InitRREndMap(); // this needs to be done better later
|
||||
return gi->app_main();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,11 @@ inline void MakeStringLocalizable(FString "e)
|
|||
if (quote.Len() > 0 && quote[0] != '$' && GStrings[quote]) quote.Insert(0, "$");
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
MI_FORCEEOG = 1,
|
||||
};
|
||||
|
||||
struct MapRecord
|
||||
{
|
||||
int parTime;
|
||||
|
@ -27,6 +32,7 @@ struct MapRecord
|
|||
int messageStart; // messages are stored in the quote array to reduce clutter.
|
||||
FString author;
|
||||
// bool fog, weather; // Blood defines these but they aren't used.
|
||||
int flags;
|
||||
|
||||
const char *DisplayName()
|
||||
{
|
||||
|
@ -47,4 +53,19 @@ struct MapRecord
|
|||
};
|
||||
|
||||
extern MapRecord mapList[512];
|
||||
extern MapRecord *currentLevel;
|
||||
extern MapRecord userMapRecord;
|
||||
extern MapRecord *currentLevel;
|
||||
extern MapRecord* lastLevel;
|
||||
|
||||
|
||||
inline void InitRREndMap()
|
||||
{
|
||||
// RR defines its end map ad-hoc so give it a proper entry to reference (the last one in episode 2 because it needs to be in Ep. 2.)
|
||||
mapList[127].SetName("$TXT_CLOSEENCOUNTERS");
|
||||
mapList[127].SetFileName("endmap.map");
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
RRENDSLOT = 127
|
||||
};
|
|
@ -492,6 +492,7 @@ bool M_SetMenu(FName menu, int param, FName caller)
|
|||
M_StartMessage (GStrings("SAVEDEAD"), 1, -1);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
case NAME_QuitMenu:
|
||||
// This is no separate class
|
||||
|
|
|
@ -198,7 +198,7 @@ void FSavegameManager::ReadSaveStrings()
|
|||
}
|
||||
auto fr = info->NewReader();
|
||||
FString title;
|
||||
int check = G_ValidateSavegame(fr, &title);
|
||||
int check = G_ValidateSavegame(fr, &title, true);
|
||||
fr.Close();
|
||||
delete savegame;
|
||||
if (check != 0)
|
||||
|
@ -377,7 +377,7 @@ unsigned FSavegameManager::ExtractSaveData(int index)
|
|||
|
||||
|
||||
FString comment = sjson_get_string(root, "Creation Time", "");
|
||||
FString fcomment = sjson_get_string(root, "Map File", "");
|
||||
FString fcomment = sjson_get_string(root, "Map Label", "");
|
||||
FString ncomment = sjson_get_string(root, "Map Name", "");
|
||||
FStringf pcomment("%s - %s\n", fcomment.GetChars(), ncomment.GetChars());
|
||||
comment += pcomment;
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "secrets.h"
|
||||
#include "s_music.h"
|
||||
#include "quotemgr.h"
|
||||
#include "mapinfo.h"
|
||||
|
||||
static CompositeSavegameWriter savewriter;
|
||||
static FResourceFile *savereader;
|
||||
|
@ -81,8 +82,21 @@ bool OpenSaveGameForRead(const char *name)
|
|||
SECRET_Load();
|
||||
MUS_Restore();
|
||||
quoteMgr.ReadFromSavegame();
|
||||
}
|
||||
|
||||
auto file = ReadSavegameChunk("info.json");
|
||||
if (!file.isOpen())
|
||||
{
|
||||
FinishSavegameRead();
|
||||
delete savereader;
|
||||
return false;
|
||||
}
|
||||
if (G_ValidateSavegame(file, nullptr, false) <= 0)
|
||||
{
|
||||
FinishSavegameRead();
|
||||
delete savereader;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return savereader != nullptr;
|
||||
}
|
||||
|
||||
|
@ -116,7 +130,7 @@ void FinishSavegameRead()
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
void G_WriteSaveHeader(const char *name, const char*mapname, const char *maptitle)
|
||||
void G_WriteSaveHeader(const char *name)
|
||||
{
|
||||
sjson_context* ctx = sjson_create_context(0, 0, NULL);
|
||||
if (!ctx)
|
||||
|
@ -128,16 +142,20 @@ void G_WriteSaveHeader(const char *name, const char*mapname, const char *maptitl
|
|||
sjson_put_int(ctx, root, "Save Version", savesig.currentsavever);
|
||||
sjson_put_string(ctx, root, "Engine", savesig.savesig);
|
||||
sjson_put_string(ctx, root, "Game Resource", fileSystem.GetResourceFileName(1));
|
||||
sjson_put_string(ctx, root, "Map Name", maptitle);
|
||||
sjson_put_string(ctx, root, "Map Name", currentLevel->DisplayName());
|
||||
sjson_put_string(ctx, root, "Title", name);
|
||||
if (*mapname == '/') mapname++;
|
||||
sjson_put_string(ctx, root, "Map File", mapname);
|
||||
auto fileno = fileSystem.FindFile(mapname);
|
||||
auto mapfile = fileSystem.GetFileContainer(fileno);
|
||||
auto mapcname = fileSystem.GetResourceFileName(mapfile);
|
||||
if (mapcname) sjson_put_string(ctx, root, "Map Resource", mapcname);
|
||||
else return; // this should never happen. Saving on a map that isn't present is impossible.
|
||||
|
||||
sjson_put_string(ctx, root, "Map File", currentLevel->fileName);
|
||||
sjson_put_string(ctx, root, "Map Label", currentLevel->labelName);
|
||||
const char *fn = currentLevel->fileName;
|
||||
if (*fn == '/') fn++;
|
||||
if (!strncmp(fn, "file://", 7) != 0) // this only has meaning for non-usermaps
|
||||
{
|
||||
auto fileno = fileSystem.FindFile(fn);
|
||||
auto mapfile = fileSystem.GetFileContainer(fileno);
|
||||
auto mapcname = fileSystem.GetResourceFileName(mapfile);
|
||||
if (mapcname) sjson_put_string(ctx, root, "Map Resource", mapcname);
|
||||
else return; // this should never happen. Saving on a map that isn't present is impossible.
|
||||
}
|
||||
|
||||
char* encoded = sjson_stringify(ctx, root, " ");
|
||||
|
||||
|
@ -172,6 +190,10 @@ static bool CheckSingleFile (const char *name, bool &printRequires, bool printwa
|
|||
{
|
||||
return true;
|
||||
}
|
||||
if (!strncmp(name, "file://", 7) == 0)
|
||||
{
|
||||
return FileExists(name + 7); // User maps must be present to be validated.
|
||||
}
|
||||
if (fileSystem.CheckIfResourceFileLoaded(name) < 0)
|
||||
{
|
||||
if (printwarn)
|
||||
|
@ -222,7 +244,7 @@ static bool G_CheckSaveGameWads (const char *gamegrp, const char *mapgrp, bool p
|
|||
//
|
||||
//=============================================================================
|
||||
|
||||
int G_ValidateSavegame(FileReader &fr, FString *savetitle)
|
||||
int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu)
|
||||
{
|
||||
auto data = fr.ReadPadded(1);
|
||||
|
||||
|
@ -237,6 +259,7 @@ int G_ValidateSavegame(FileReader &fr, FString *savetitle)
|
|||
FString gamegrp = sjson_get_string(root, "Game Resource", "");
|
||||
FString mapgrp = sjson_get_string(root, "Map Resource", "");
|
||||
FString title = sjson_get_string(root, "Title", "");
|
||||
FString filename = sjson_get_string(root, "Map File", "");
|
||||
auto savesig = gi->GetSaveSig();
|
||||
|
||||
sjson_destroy_context(ctx);
|
||||
|
@ -248,6 +271,30 @@ int G_ValidateSavegame(FileReader &fr, FString *savetitle)
|
|||
// not our business. Leave it alone.
|
||||
return 0;
|
||||
}
|
||||
|
||||
MapRecord *curLevel = nullptr;
|
||||
|
||||
if (!strncmp(filename, "file://", 7) != 0)
|
||||
{
|
||||
for (auto& mr : mapList)
|
||||
{
|
||||
if (mr.fileName.Compare(filename) == 0)
|
||||
{
|
||||
curLevel = &mr;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
curLevel = &userMapRecord;
|
||||
if (!formenu)
|
||||
{
|
||||
userMapRecord.name = "";
|
||||
userMapRecord.SetFileName(filename);
|
||||
}
|
||||
}
|
||||
if (!curLevel) return 0;
|
||||
if (!formenu) currentLevel = curLevel;
|
||||
|
||||
|
||||
if (savever < savesig.minsavever)
|
||||
|
|
|
@ -15,8 +15,8 @@ void FinishSavegameRead();
|
|||
class FileReader;
|
||||
|
||||
FString G_BuildSaveName (const char *prefix);
|
||||
int G_ValidateSavegame(FileReader &fr, FString *savetitle);
|
||||
void G_WriteSaveHeader(const char *name, const char*mapname, const char *title);
|
||||
int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu);
|
||||
void G_WriteSaveHeader(const char* name);
|
||||
|
||||
#define SAVEGAME_EXT ".dsave"
|
||||
|
||||
|
|
|
@ -5764,7 +5764,8 @@ static int G_EndOfLevel(void)
|
|||
{
|
||||
auto &p = *g_player[myconnectindex].ps;
|
||||
|
||||
STAT_Update(ud.eog);
|
||||
if ((currentLevel->flags & MI_FORCEEOG)) ud.eog = 1; // if the finished level says to end the game, end it!
|
||||
STAT_Update(ud.eog);
|
||||
P_SetGamePalette(&p, BASEPAL, 0);
|
||||
P_UpdateScreenPal(&p);
|
||||
|
||||
|
@ -5789,7 +5790,7 @@ static int G_EndOfLevel(void)
|
|||
// Clear potentially loaded per-map ART only after the bonus screens.
|
||||
artClearMapArt();
|
||||
|
||||
if (ud.eog || G_HaveUserMap())
|
||||
if (ud.eog || G_HaveUserMap() || (currentLevel->flags & MI_FORCEEOG))
|
||||
{
|
||||
ud.eog = 0;
|
||||
if ((!g_netServer && ud.multimode < 2))
|
||||
|
@ -5799,8 +5800,6 @@ static int G_EndOfLevel(void)
|
|||
G_DoOrderScreen();
|
||||
#endif
|
||||
p.gm = 0;
|
||||
M_StartControlPanel(false);
|
||||
M_SetMenu(NAME_MainMenu);
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -68,7 +68,6 @@ G_EXTERN actor_t actor[MAXSPRITES];
|
|||
G_EXTERN tiledata_t g_tile[MAXTILES];
|
||||
G_EXTERN animwalltype animwall[MAXANIMWALLS];
|
||||
G_EXTERN char *label;
|
||||
G_EXTERN int32_t g_musicIndex;
|
||||
G_EXTERN char g_loadFromGroupOnly;
|
||||
G_EXTERN char g_skillCnt;
|
||||
G_EXTERN char pus,pub;
|
||||
|
|
|
@ -1720,7 +1720,7 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName)
|
|||
|
||||
if (FileExists(nameBuf))
|
||||
{
|
||||
mapList[USERMAPMUSICFAKESLOT].music = nameBuf;
|
||||
userMapRecord.music = nameBuf;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1728,7 +1728,7 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName)
|
|||
auto &usermapMusic = mapList[MUS_USERMAP].music;
|
||||
if (usermapMusic.IsNotEmpty())
|
||||
{
|
||||
mapList[USERMAPMUSICFAKESLOT].music = usermapMusic;
|
||||
userMapRecord.music = usermapMusic;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1738,7 +1738,7 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName)
|
|||
auto &e1l8 = mapList[7].music;
|
||||
if (e1l8.IsNotEmpty())
|
||||
{
|
||||
mapList[USERMAPMUSICFAKESLOT].music = e1l8;
|
||||
userMapRecord.music = e1l8;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1849,7 +1849,10 @@ int G_EnterLevel(int gameMode)
|
|||
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", boardfilename);
|
||||
return 1;
|
||||
}
|
||||
STAT_NewLevel(boardfilename);
|
||||
userMapRecord.name = "";
|
||||
userMapRecord.SetFileName(boardfilename);
|
||||
currentLevel = &userMapRecord;
|
||||
STAT_NewLevel(boardfilename);
|
||||
G_LoadMapHack(levelName, boardfilename);
|
||||
G_SetupFilenameBasedMusic(levelName, boardfilename);
|
||||
}
|
||||
|
@ -1860,6 +1863,7 @@ int G_EnterLevel(int gameMode)
|
|||
}
|
||||
else
|
||||
{
|
||||
currentLevel = &mm;
|
||||
STAT_NewLevel(mm.fileName);
|
||||
G_LoadMapHack(levelName, mm.fileName);
|
||||
}
|
||||
|
@ -1894,15 +1898,7 @@ int G_EnterLevel(int gameMode)
|
|||
{
|
||||
S_PlayLevelMusicOrNothing(USERMAPMUSICFAKESLOT);
|
||||
}
|
||||
else if (mapList[g_musicIndex].music.IsEmpty() || mm.music.IsEmpty() || mapList[g_musicIndex].music.CompareNoCase(mm.music) == 0 ||
|
||||
g_musicSize == 0 || ud.last_level == -1)
|
||||
{
|
||||
S_PlayLevelMusicOrNothing(mapidx);
|
||||
}
|
||||
else
|
||||
{
|
||||
S_ContinueLevelMusic();
|
||||
}
|
||||
else S_PlayLevelMusicOrNothing(mapidx);
|
||||
}
|
||||
|
||||
M_ClearMenus();
|
||||
|
|
|
@ -151,18 +151,7 @@ static FileReader *OpenSavegame(const char *fn)
|
|||
{
|
||||
return nullptr;
|
||||
}
|
||||
auto file = ReadSavegameChunk("info.json");
|
||||
if (!file.isOpen())
|
||||
{
|
||||
FinishSavegameRead();
|
||||
return nullptr;
|
||||
}
|
||||
if (G_ValidateSavegame(file, nullptr) <= 0)
|
||||
{
|
||||
FinishSavegameRead();
|
||||
return nullptr;
|
||||
}
|
||||
file = ReadSavegameChunk("snapshot.dat");
|
||||
auto file = ReadSavegameChunk("snapshot.dat");
|
||||
if (!file.isOpen())
|
||||
{
|
||||
FinishSavegameRead();
|
||||
|
@ -182,24 +171,6 @@ int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
|||
if (i < 0)
|
||||
goto corrupt;
|
||||
|
||||
ssfil = ReadSavegameChunk("screenshot.dat");
|
||||
|
||||
TileFiles.tileCreate(TILE_LOADSHOT, 200, 320);
|
||||
if (ssfil.isOpen())
|
||||
{
|
||||
if (ssfil.Read(tileData(TILE_LOADSHOT), 320 * 200) != 320 * 200)
|
||||
{
|
||||
OSD_Printf("G_LoadSaveHeaderNew(): failed reading screenshot in \"%s\"\n", fn);
|
||||
goto corrupt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bmemset(tileData(TILE_LOADSHOT), 0, 320*200);
|
||||
}
|
||||
ssfil.Close();
|
||||
tileInvalidate(TILE_LOADSHOT, 0, 255);
|
||||
|
||||
delete fil;
|
||||
FinishSavegameRead();
|
||||
return 0;
|
||||
|
@ -1468,8 +1439,7 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, i
|
|||
auto fw = WriteSavegameChunk("header.dat");
|
||||
fw->Write(&h, sizeof(savehead_t));
|
||||
|
||||
auto& mii = mapList[(MAXLEVELS * ud.volume_number) + ud.level_number];
|
||||
G_WriteSaveHeader(name, mii.fileName, mii.DisplayName());
|
||||
G_WriteSaveHeader(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1487,13 +1457,14 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, i
|
|||
|
||||
|
||||
// write header
|
||||
|
||||
#if 0 // not usable anymore
|
||||
if (spot >= 0 && tileData(TILE_SAVESHOT))
|
||||
{
|
||||
auto fw = WriteSavegameChunk("screenshot.dat");
|
||||
fw->Write(tileData(TILE_SAVESHOT), 320*200);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (spot >= 0)
|
||||
|
|
|
@ -134,7 +134,6 @@ void S_MenuSound(void)
|
|||
|
||||
static void S_SetMusicIndex(unsigned int m)
|
||||
{
|
||||
g_musicIndex = m;
|
||||
ud.music_episode = m / MAXLEVELS;
|
||||
ud.music_level = m % MAXLEVELS;
|
||||
}
|
||||
|
@ -148,7 +147,9 @@ void S_PlayLevelMusicOrNothing(unsigned int m)
|
|||
|
||||
if (retval >= 0)
|
||||
{
|
||||
Mus_Play(mapList[m].fileName, mapList[m].music, true);
|
||||
// Thanks to scripting that stupid slot hijack cannot be refactored - but we'll store the real data elsewhere anyway!
|
||||
auto &mr = m == USERMAPMUSICFAKESLOT ? userMapRecord : mapList[m];
|
||||
Mus_Play(mr.fileName, mr.music, true);
|
||||
S_SetMusicIndex(m);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7196,7 +7196,7 @@ void G_BackToMenu(void)
|
|||
|
||||
static int G_EndOfLevel(void)
|
||||
{
|
||||
STAT_Update(ud.eog);
|
||||
STAT_Update(ud.eog || (currentLevel->flags & MI_FORCEEOG));
|
||||
P_SetGamePalette(g_player[myconnectindex].ps, BASEPAL, 0);
|
||||
P_UpdateScreenPal(g_player[myconnectindex].ps);
|
||||
|
||||
|
@ -7226,7 +7226,7 @@ static int G_EndOfLevel(void)
|
|||
// Clear potentially loaded per-map ART only after the bonus screens.
|
||||
artClearMapArt();
|
||||
|
||||
if (ud.eog)
|
||||
if (ud.eog || (currentLevel->flags & MI_FORCEEOG))
|
||||
{
|
||||
ud.eog = 0;
|
||||
if ((!g_netServer && ud.multimode < 2))
|
||||
|
@ -7234,8 +7234,6 @@ static int G_EndOfLevel(void)
|
|||
if (!VOLUMEALL)
|
||||
G_DoOrderScreen();
|
||||
g_player[myconnectindex].ps->gm = 0;
|
||||
M_StartControlPanel(false);
|
||||
M_SetMenu(NAME_MainMenu);
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -73,7 +73,6 @@ G_EXTERN actor_t actor[MAXSPRITES];
|
|||
G_EXTERN tiledata_t g_tile[MAXTILES];
|
||||
G_EXTERN animwalltype animwall[MAXANIMWALLS];
|
||||
G_EXTERN char *label;
|
||||
G_EXTERN int32_t g_musicIndex;
|
||||
G_EXTERN char g_loadFromGroupOnly;
|
||||
G_EXTERN char g_skillCnt;
|
||||
G_EXTERN char pus,pub;
|
||||
|
|
|
@ -2243,7 +2243,7 @@ static void G_LoadMapHack(char *outbuf, const char *filename)
|
|||
}
|
||||
|
||||
// levnamebuf should have at least size BMAX_PATH
|
||||
void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName, int levelNum)
|
||||
void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName)
|
||||
{
|
||||
char *p;
|
||||
char const *exts[] = {
|
||||
|
@ -2277,12 +2277,12 @@ void G_SetupFilenameBasedMusic(char *nameBuf, const char *fileName, int levelNum
|
|||
|
||||
if (FileExists(nameBuf))
|
||||
{
|
||||
mapList[levelNum].music = nameBuf;
|
||||
userMapRecord.music = nameBuf;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mapList[levelNum].music = "dethtoll.mid";
|
||||
userMapRecord.music = "dethtoll.mid";
|
||||
}
|
||||
|
||||
int G_EnterLevel(int gameMode)
|
||||
|
@ -2378,10 +2378,12 @@ int G_EnterLevel(int gameMode)
|
|||
OSD_Printf(OSD_ERROR "Map \"%s\" not found or invalid map version!\n", boardfilename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
STAT_NewLevel(boardfilename);
|
||||
userMapRecord.name = "";
|
||||
userMapRecord.SetFileName(boardfilename);
|
||||
currentLevel = &userMapRecord;
|
||||
STAT_NewLevel(boardfilename);
|
||||
G_LoadMapHack(levelName, boardfilename);
|
||||
G_SetupFilenameBasedMusic(levelName, boardfilename, m_level_number);
|
||||
G_SetupFilenameBasedMusic(levelName, boardfilename);
|
||||
}
|
||||
else if (engineLoadBoard(mi.fileName, VOLUMEONE, &pPlayer->pos, &lbang, &pPlayer->cursectnum) < 0)
|
||||
{
|
||||
|
@ -2390,6 +2392,7 @@ int G_EnterLevel(int gameMode)
|
|||
}
|
||||
else
|
||||
{
|
||||
currentLevel = &mi;
|
||||
STAT_NewLevel(mi.fileName);
|
||||
G_LoadMapHack(levelName, mi.fileName);
|
||||
}
|
||||
|
@ -2434,14 +2437,7 @@ int G_EnterLevel(int gameMode)
|
|||
|
||||
if (ud.recstat != 2)
|
||||
{
|
||||
if (mapList[g_musicIndex].music.IsEmpty() ||
|
||||
mi.music.IsEmpty() ||
|
||||
mi.music.CompareNoCase(mapList[g_musicIndex].music) ||
|
||||
g_musicSize == 0 ||
|
||||
ud.last_level == -1)
|
||||
{
|
||||
S_PlayLevelMusicOrNothing(mii);
|
||||
}
|
||||
S_PlayLevelMusicOrNothing(mii);
|
||||
}
|
||||
|
||||
if (RR && !(gameMode & MODE_DEMO))
|
||||
|
|
|
@ -146,18 +146,7 @@ static FileReader *OpenSavegame(const char *fn)
|
|||
{
|
||||
return nullptr;
|
||||
}
|
||||
auto file = ReadSavegameChunk("info.json");
|
||||
if (!file.isOpen())
|
||||
{
|
||||
FinishSavegameRead();
|
||||
return nullptr;
|
||||
}
|
||||
if (G_ValidateSavegame(file, nullptr) <= 0)
|
||||
{
|
||||
FinishSavegameRead();
|
||||
return nullptr;
|
||||
}
|
||||
file = ReadSavegameChunk("snapshot.dat");
|
||||
auto file = ReadSavegameChunk("snapshot.dat");
|
||||
if (!file.isOpen())
|
||||
{
|
||||
FinishSavegameRead();
|
||||
|
@ -182,24 +171,6 @@ int32_t G_LoadSaveHeaderNew(char const *fn, savehead_t *saveh)
|
|||
if (i < 0)
|
||||
goto corrupt;
|
||||
|
||||
ssfil = ReadSavegameChunk("screenshot.dat");
|
||||
|
||||
TileFiles.tileCreate(TILE_LOADSHOT, 200, 320);
|
||||
if (ssfil.isOpen())
|
||||
{
|
||||
if (ssfil.Read(tileData(TILE_LOADSHOT), 320 * 200) != 320 * 200)
|
||||
{
|
||||
OSD_Printf("G_LoadSaveHeaderNew(): failed reading screenshot in \"%s\"\n", fn);
|
||||
goto corrupt;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Bmemset(tileData(TILE_LOADSHOT), 0, 320*200);
|
||||
}
|
||||
ssfil.Close();
|
||||
tileInvalidate(TILE_LOADSHOT, 0, 255);
|
||||
|
||||
delete fil;
|
||||
FinishSavegameRead();
|
||||
return 0;
|
||||
|
@ -1169,9 +1140,7 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, i
|
|||
Bstrncpyz(h.savename, name, sizeof(h.savename));
|
||||
auto fw = WriteSavegameChunk("header.dat");
|
||||
fw->Write(&h, sizeof(savehead_t));
|
||||
|
||||
auto& mi = mapList[(MAXLEVELS * ud.volume_number) + ud.level_number];
|
||||
G_WriteSaveHeader(name, mi.fileName, mi.DisplayName());
|
||||
G_WriteSaveHeader(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1190,12 +1159,14 @@ int32_t sv_saveandmakesnapshot(FileWriter &fil, char const *name, int8_t spot, i
|
|||
|
||||
// write header
|
||||
|
||||
#if 0 // not usable anymore
|
||||
if (spot >= 0 && tileData(TILE_SAVESHOT))
|
||||
{
|
||||
auto fw = WriteSavegameChunk("screenshot.dat");
|
||||
fw->Write(tileData(TILE_SAVESHOT), 320*200);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (spot >= 0)
|
||||
|
|
|
@ -123,17 +123,9 @@ void S_MenuSound(void)
|
|||
}
|
||||
|
||||
|
||||
static void S_SetMusicIndex(unsigned int m)
|
||||
{
|
||||
g_musicIndex = m;
|
||||
ud.music_episode = m / MAXLEVELS;
|
||||
ud.music_level = m % MAXLEVELS;
|
||||
}
|
||||
|
||||
void S_PlayLevelMusicOrNothing(unsigned int m)
|
||||
{
|
||||
Mus_Play(mapList[m].fileName, RR ? nullptr : mapList[m].music, true);
|
||||
S_SetMusicIndex(m);
|
||||
}
|
||||
|
||||
int S_TryPlaySpecialMusic(unsigned int m)
|
||||
|
@ -145,7 +137,6 @@ int S_TryPlaySpecialMusic(unsigned int m)
|
|||
{
|
||||
if (!Mus_Play(nullptr, musicfn, 1))
|
||||
{
|
||||
S_SetMusicIndex(m);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -169,10 +160,7 @@ void S_PlayRRMusic(int newTrack)
|
|||
|
||||
void S_PlaySpecialMusicOrNothing(unsigned int m)
|
||||
{
|
||||
if (S_TryPlaySpecialMusic(m))
|
||||
{
|
||||
S_SetMusicIndex(m);
|
||||
}
|
||||
S_TryPlaySpecialMusic(m);
|
||||
}
|
||||
|
||||
void S_Cleanup(void)
|
||||
|
|
|
@ -58,6 +58,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
|||
#include "i_specialpaths.h"
|
||||
#include "savegamehelp.h"
|
||||
#include "z_music.h"
|
||||
#include "mapinfo.h"
|
||||
|
||||
//void TimerFunc(task * Task);
|
||||
BEGIN_SW_NS
|
||||
|
@ -250,7 +251,12 @@ bool GameInterface::SaveGame(FSaveGameNode *sv)
|
|||
|
||||
auto game_name = G_BuildSaveName(sv->Filename);
|
||||
OpenSaveGameForWrite(game_name);
|
||||
G_WriteSaveHeader(sv->SaveTitle, LevelInfo[Level].LevelName, LevelInfo[Level].Description);
|
||||
// workaround until the level info here has been transitioned.
|
||||
MapRecord mr;
|
||||
mr.SetFileName(LevelInfo[Level].Description);
|
||||
mr.labelName = LevelInfo[Level].Description;
|
||||
currentLevel = &mr;
|
||||
G_WriteSaveHeader(sv->SaveTitle);
|
||||
fil = WriteSavegameChunk("snapshot.sw");
|
||||
|
||||
MWRITE(&GameVersion,sizeof(GameVersion),1,fil);
|
||||
|
|
Loading…
Reference in a new issue