mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
- Blood load/save works.
This commit is contained in:
parent
eb668180c8
commit
e743268c4b
10 changed files with 60 additions and 97 deletions
|
@ -95,6 +95,8 @@ struct GameInterface : ::GameInterface
|
|||
void StartGame(FGameStartup& gs) override;
|
||||
void DrawNativeMenuText(int fontnum, int state, double xpos, double ypos, float fontscale, const char* text, int flags) override;
|
||||
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
||||
bool SaveGame(FSaveGameNode*) override;
|
||||
bool LoadGame(FSaveGameNode*) override;
|
||||
};
|
||||
|
||||
END_BLD_NS
|
||||
|
|
|
@ -141,29 +141,22 @@ static std::unique_ptr<CGameMenuItemQAV> itemBloodQAV; // This must be global to
|
|||
|
||||
void UpdateNetworkMenus(void)
|
||||
{
|
||||
// Kept as a reminder to reimplement later.
|
||||
#if 0
|
||||
if (gGameOptions.nGameType > 0)
|
||||
// For now disable the network menu item as it is not yet functional.
|
||||
for (auto name : { NAME_MainMenu, NAME_IngameMenu })
|
||||
{
|
||||
itemMain1.resource = &menuNetStart;
|
||||
itemMain1.data = 2;
|
||||
FMenuDescriptor** desc = MenuDescriptors.CheckKey(name);
|
||||
if (desc != NULL && (*desc)->mType == MDESC_ListMenu)
|
||||
{
|
||||
FListMenuDescriptor* ld = static_cast<FListMenuDescriptor*>(*desc);
|
||||
for (auto& li : ld->mItems)
|
||||
{
|
||||
if (li->GetAction(nullptr) == NAME_MultiMenu)
|
||||
{
|
||||
li->mEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
itemMain1.resource = &menuEpisode;
|
||||
itemMain1.data = -1;
|
||||
}
|
||||
if (gGameOptions.nGameType > 0)
|
||||
{
|
||||
itemMainSave1.resource = &menuNetStart;
|
||||
itemMainSave1.data = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
itemMainSave1.resource = &menuEpisode;
|
||||
itemMainSave1.data = -1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -181,7 +174,7 @@ protected:
|
|||
|
||||
void PostDraw()
|
||||
{
|
||||
//itemBloodQAV->Draw();
|
||||
itemBloodQAV->Draw();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -64,8 +64,6 @@ void ReadGameOptionsLegacy(GAMEOPTIONS &gameOptions, GAMEOPTIONSLEGACY &gameOpti
|
|||
strcpy(gameOptions.zLevelName, gameOptionsLegacy.zLevelName);
|
||||
strcpy(gameOptions.zLevelSong, gameOptionsLegacy.zLevelSong);
|
||||
gameOptions.nTrackNumber = gameOptionsLegacy.nTrackNumber;
|
||||
strcpy(gameOptions.szSaveGameName, gameOptionsLegacy.szSaveGameName);
|
||||
strcpy(gameOptions.szUserGameName, gameOptionsLegacy.szUserGameName);
|
||||
gameOptions.nSaveGameSlot = gameOptionsLegacy.nSaveGameSlot;
|
||||
gameOptions.picEntry = gameOptionsLegacy.picEntry;
|
||||
gameOptions.uMapCRC = gameOptionsLegacy.uMapCRC;
|
||||
|
|
|
@ -50,7 +50,7 @@ BEGIN_BLD_NS
|
|||
GAMEOPTIONS gGameOptions;
|
||||
|
||||
GAMEOPTIONS gSingleGameOptions = {
|
||||
0, 2, 0, 0, "", "", 2, "", "", 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 3600, 1800, 1800, 7200
|
||||
0, 2, 0, 0, "", "", 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 3600, 1800, 1800, 7200
|
||||
};
|
||||
|
||||
EPISODEINFO gEpisodeInfo[kMaxEpisodes+1];
|
||||
|
|
|
@ -41,8 +41,6 @@ struct GAMEOPTIONS {
|
|||
char zLevelName[BMAX_PATH];
|
||||
char zLevelSong[BMAX_PATH];
|
||||
int nTrackNumber; //at12a;
|
||||
char szSaveGameName[BMAX_PATH];
|
||||
char szUserGameName[BMAX_PATH];
|
||||
short nSaveGameSlot;
|
||||
int picEntry;
|
||||
unsigned int uMapCRC;
|
||||
|
|
|
@ -51,7 +51,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
BEGIN_BLD_NS
|
||||
|
||||
GAMEOPTIONS gSaveGameOptions[10];
|
||||
char *gSaveGamePic[10];
|
||||
unsigned int gSavedOffset = 0;
|
||||
|
||||
|
@ -101,7 +100,7 @@ void LoadSave::Write(void *pData, int nSize)
|
|||
ThrowError("File error #%d writing save file.", errno);
|
||||
}
|
||||
|
||||
void LoadSave::LoadGame(const char *pzFile)
|
||||
bool GameInterface::LoadGame(FSaveGameNode* node)
|
||||
{
|
||||
bool demoWasPlayed = gDemo.at1;
|
||||
if (gDemo.at1)
|
||||
|
@ -117,18 +116,18 @@ void LoadSave::LoadGame(const char *pzFile)
|
|||
memset(sprite, 0, sizeof(spritetype)*kMaxSprites);
|
||||
automapping = 1;
|
||||
}
|
||||
OpenSaveGameForRead(pzFile);
|
||||
hLFile = ReadSavegameChunk("snapshot.bld");
|
||||
if (!hLFile.isOpen())
|
||||
ThrowError("Error loading save file.");
|
||||
LoadSave *rover = head.next;
|
||||
while (rover != &head)
|
||||
OpenSaveGameForRead(node->Filename);
|
||||
LoadSave::hLFile = ReadSavegameChunk("snapshot.bld");
|
||||
if (!LoadSave::hLFile.isOpen())
|
||||
return false;
|
||||
LoadSave *rover = LoadSave::head.next;
|
||||
while (rover != &LoadSave::head)
|
||||
{
|
||||
rover->Load();
|
||||
rover = rover->next;
|
||||
}
|
||||
|
||||
hLFile.Close();
|
||||
LoadSave::hLFile.Close();
|
||||
FinishSavegameRead();
|
||||
if (!gGameStarted)
|
||||
scrLoadPLUs();
|
||||
|
@ -182,30 +181,39 @@ void LoadSave::LoadGame(const char *pzFile)
|
|||
|
||||
netBroadcastPlayerInfo(myconnectindex);
|
||||
//sndPlaySong(gGameOptions.zLevelSong, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void LoadSave::SaveGame(const char *pzFile)
|
||||
bool GameInterface::SaveGame(FSaveGameNode* node)
|
||||
{
|
||||
OpenSaveGameForWrite(pzFile);
|
||||
hSFile = WriteSavegameChunk("snapshot.bld");
|
||||
if (hSFile == NULL)
|
||||
ThrowError("File error #%d creating save file.", errno);
|
||||
dword_27AA38 = 0;
|
||||
dword_27AA40 = 0;
|
||||
LoadSave *rover = head.next;
|
||||
while (rover != &head)
|
||||
{
|
||||
rover->Save();
|
||||
if (dword_27AA38 > dword_27AA40)
|
||||
dword_27AA40 = dword_27AA38;
|
||||
dword_27AA38 = 0;
|
||||
rover = rover->next;
|
||||
}
|
||||
auto & li = gEpisodeInfo[gGameOptions.nEpisode].at28[gGameOptions.nLevel];
|
||||
G_WriteSaveHeader(gGameOptions.szUserGameName, li.at0, li.at90);
|
||||
OpenSaveGameForWrite(node->Filename);
|
||||
LoadSave::hSFile = WriteSavegameChunk("snapshot.bld");
|
||||
|
||||
FinishSavegameWrite();
|
||||
hSFile = NULL;
|
||||
try
|
||||
{
|
||||
dword_27AA38 = 0;
|
||||
dword_27AA40 = 0;
|
||||
LoadSave* rover = LoadSave::head.next;
|
||||
while (rover != &LoadSave::head)
|
||||
{
|
||||
rover->Save();
|
||||
if (dword_27AA38 > dword_27AA40)
|
||||
dword_27AA40 = dword_27AA38;
|
||||
dword_27AA38 = 0;
|
||||
rover = rover->next;
|
||||
}
|
||||
}
|
||||
catch (std::runtime_error & err)
|
||||
{
|
||||
// Let's not abort for write errors.
|
||||
Printf(TEXTCOLOR_RED "%s\n", err.what());
|
||||
return false;
|
||||
}
|
||||
auto & li = gEpisodeInfo[gGameOptions.nEpisode].at28[gGameOptions.nLevel];
|
||||
G_WriteSaveHeader(node->SaveTitle, FStringf("%s.map", li.at0), li.at90);
|
||||
LoadSave::hSFile = NULL;
|
||||
|
||||
return FinishSavegameWrite();
|
||||
}
|
||||
|
||||
class MyLoadSave : public LoadSave
|
||||
|
@ -431,41 +439,6 @@ void MyLoadSave::Save(void)
|
|||
|
||||
void LoadSavedInfo(void)
|
||||
{
|
||||
FString path = M_GetSavegamesPath() + "game*.sav";
|
||||
TArray<FString> saves;
|
||||
D_AddWildFile(saves, path);
|
||||
int nCount = 0;
|
||||
for (auto & savename : saves)
|
||||
{
|
||||
OpenSaveGameForRead(savename);
|
||||
auto hFile = ReadSavegameChunk("snapshot.bld");
|
||||
if (!hFile.isOpen())
|
||||
{
|
||||
FinishSavegameRead();
|
||||
ThrowError("Error loading save file header.");
|
||||
}
|
||||
int vc;
|
||||
short v4;
|
||||
vc = 0;
|
||||
v4 = word_27AA54;
|
||||
if ((uint32_t)hFile.Read(&vc, sizeof(vc)) != sizeof(vc))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (vc != 0x5653424e/*'VSBN'*/)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
hFile.Read(&v4, sizeof(v4));
|
||||
if (v4 != BYTEVERSION)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((uint32_t)hFile.Read(&gSaveGameOptions[nCount], sizeof(gSaveGameOptions[0])) != sizeof(gSaveGameOptions[0]))
|
||||
ThrowError("Error reading save file.");
|
||||
nCount++;
|
||||
}
|
||||
FinishSavegameRead();
|
||||
}
|
||||
|
||||
void UpdateSavedInfo(int nSlot)
|
||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include <stdio.h>
|
||||
#include "levels.h"
|
||||
|
||||
struct FSavegameNode;
|
||||
BEGIN_BLD_NS
|
||||
|
||||
class LoadSave {
|
||||
|
@ -49,12 +50,11 @@ public:
|
|||
virtual void Load(void);
|
||||
void Read(void *, int);
|
||||
void Write(void *, int);
|
||||
static void LoadGame(const char *);
|
||||
static void SaveGame(const char *);
|
||||
static void LoadGame(FSavegameNode *);
|
||||
static void SaveGame(FSavegameNode*);
|
||||
};
|
||||
|
||||
extern unsigned int gSavedOffset;
|
||||
extern GAMEOPTIONS gSaveGameOptions[];
|
||||
extern char *gSaveGamePic[10];
|
||||
void UpdateSavedInfo(int nSlot);
|
||||
void LoadSavedInfo(void);
|
||||
|
|
|
@ -2032,8 +2032,6 @@ void SaveGame(CGameMenuItemZEditBitmap *pItem, CGameMenuEvent *event)
|
|||
}
|
||||
FStringf basename("save%04d", nSlot);
|
||||
auto strSaveGameName = G_BuildSaveName(basename);
|
||||
strcpy(gGameOptions.szUserGameName, strRestoreGameStrings[nSlot]);
|
||||
sprintf(gGameOptions.szSaveGameName, "%s", strSaveGameName.GetChars());
|
||||
gGameOptions.nSaveGameSlot = nSlot;
|
||||
viewLoadingScreen(2518, "Saving", "Saving Your Game", strRestoreGameStrings[nSlot]);
|
||||
videoNextPage();
|
||||
|
|
|
@ -165,7 +165,7 @@ protected:
|
|||
|
||||
if (savegameManager.SavegameCount() > 0)
|
||||
{
|
||||
if (Selected > savegameManager.SavegameCount()) Selected = 0;
|
||||
if (Selected >= savegameManager.SavegameCount()) Selected = 0;
|
||||
FString text = (Selected == -1 || !savegameManager.GetSavegame(Selected)->bOldVersion) ? GStrings("MNU_NOPICTURE") : GStrings("MNU_DIFFVERSION");
|
||||
int textlen = NewSmallFont->StringWidth(text) * CleanXfac;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ xx(Controlmessage)
|
|||
|
||||
xx(MainMenu)
|
||||
xx(IngameMenu)
|
||||
xx(MultiMenu)
|
||||
xx(HelpMenu)
|
||||
xx(CreditsMenu)
|
||||
xx(SaveGameMenu)
|
||||
|
|
Loading…
Reference in a new issue