mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-25 11:10:47 +00:00
- migrated SW's savegame code to the same containers as the other front ends.
Fortunately everything here was wrapped in macros so that it was relatively simple to change.
This commit is contained in:
parent
3bb46a4d8d
commit
8492e3c67a
3 changed files with 82 additions and 67 deletions
|
@ -56,59 +56,57 @@ enum MenuIndex_t {
|
||||||
MENU_NULL = INT32_MIN, // sentinel for "do nothing"
|
MENU_NULL = INT32_MIN, // sentinel for "do nothing"
|
||||||
MENU_CLOSE = -2, // sentinel for "close the menu"/"no menu"
|
MENU_CLOSE = -2, // sentinel for "close the menu"/"no menu"
|
||||||
MENU_PREVIOUS = -1, // sentinel for "go to previous menu"
|
MENU_PREVIOUS = -1, // sentinel for "go to previous menu"
|
||||||
MENU_MAIN = 0,
|
MENU_MAIN = 0, // done
|
||||||
MENU_MAIN_INGAME = 50,
|
MENU_MAIN_INGAME = 50, // done
|
||||||
MENU_EPISODE = 100,
|
MENU_EPISODE = 100, // done
|
||||||
MENU_USERMAP = 101,
|
MENU_USERMAP = 101,
|
||||||
MENU_NEWGAMECUSTOM = 102,
|
MENU_NEWGAMECUSTOM = 102, // done
|
||||||
MENU_NEWGAMECUSTOMSUB = 103,
|
MENU_NEWGAMECUSTOMSUB = 103,// done
|
||||||
MENU_SKILL = 110,
|
MENU_SKILL = 110, // done
|
||||||
MENU_GAMESETUP = 200,
|
|
||||||
MENU_OPTIONS = 202,
|
MENU_OPTIONS = 202,
|
||||||
|
MENU_GAMESETUP = 200,
|
||||||
|
MENU_CHEATS = 800, // IF script hacked
|
||||||
|
MENU_CHEATENTRY = 801, // IF script hacked
|
||||||
|
MENU_CHEAT_WARP = 802,
|
||||||
|
MENU_CHEAT_SKILL = 803,
|
||||||
|
MENU_DISPLAYSETUP = 234,
|
||||||
|
MENU_SCREENSETUP = 233, // HUD
|
||||||
|
MENU_COLCORR = 231, // color correction
|
||||||
|
MENU_COLCORR_INGAME = 232, // almost the same for ingame - not needed
|
||||||
MENU_VIDEOSETUP = 203,
|
MENU_VIDEOSETUP = 203,
|
||||||
|
MENU_POLYMOST = 230,
|
||||||
|
MENU_POLYMER = 240, // Who needs a renderer that's folding performance-wise with a single light?
|
||||||
|
MENU_SOUND = 700,
|
||||||
|
MENU_SOUND_INGAME = 701, // Just the same with different exit logic.
|
||||||
|
MENU_ADVSOUND = 702, // Only needed for space reasons. Fold into main sound menu.
|
||||||
|
MENU_PLAYER = 20002,
|
||||||
|
MENU_MACROS = 20004,
|
||||||
|
MENU_CONTROLS = 220,
|
||||||
MENU_KEYBOARDSETUP = 204,
|
MENU_KEYBOARDSETUP = 204,
|
||||||
|
MENU_KEYBOARDKEYS = 209,
|
||||||
MENU_MOUSESETUP = 205,
|
MENU_MOUSESETUP = 205,
|
||||||
|
MENU_MOUSEBTNS = 210, // folded with keyboard
|
||||||
|
MENU_MOUSEADVANCED = 212,
|
||||||
MENU_JOYSTICKSETUP = 206,
|
MENU_JOYSTICKSETUP = 206,
|
||||||
MENU_JOYSTICKBTNS = 207,
|
MENU_JOYSTICKBTNS = 207,
|
||||||
MENU_JOYSTICKAXES = 208,
|
MENU_JOYSTICKAXES = 208,
|
||||||
MENU_KEYBOARDKEYS = 209,
|
|
||||||
MENU_MOUSEBTNS = 210,
|
|
||||||
MENU_MOUSEADVANCED = 212,
|
|
||||||
MENU_JOYSTICKAXIS = 213,
|
MENU_JOYSTICKAXIS = 213,
|
||||||
MENU_TOUCHSETUP = 214,
|
|
||||||
MENU_TOUCHSENS = 215,
|
|
||||||
MENU_TOUCHBUTTONS = 216,
|
|
||||||
MENU_CONTROLS = 220,
|
|
||||||
MENU_POLYMOST = 230,
|
|
||||||
MENU_COLCORR = 231,
|
|
||||||
MENU_COLCORR_INGAME = 232,
|
|
||||||
MENU_SCREENSETUP = 233,
|
|
||||||
MENU_DISPLAYSETUP = 234,
|
|
||||||
MENU_POLYMER = 240,
|
|
||||||
MENU_LOAD = 300,
|
MENU_LOAD = 300,
|
||||||
MENU_SAVE = 350,
|
MENU_SAVE = 350,
|
||||||
MENU_STORY = 400,
|
MENU_STORY = 400,
|
||||||
MENU_F1HELP = 401,
|
MENU_F1HELP = 401,
|
||||||
MENU_QUIT = 500,
|
|
||||||
MENU_QUITTOTITLE = 501,
|
|
||||||
MENU_QUIT_INGAME = 502,
|
|
||||||
MENU_NETSETUP = 600,
|
|
||||||
MENU_NETWAITMASTER = 601,
|
|
||||||
MENU_NETWAITVOTES = 603,
|
|
||||||
MENU_SOUND = 700,
|
|
||||||
MENU_SOUND_INGAME = 701,
|
|
||||||
MENU_ADVSOUND = 702,
|
|
||||||
MENU_SAVESETUP = 750,
|
|
||||||
MENU_SAVECLEANVERIFY = 751,
|
|
||||||
MENU_CHEATS = 800,
|
|
||||||
MENU_CHEATENTRY = 801,
|
|
||||||
MENU_CHEAT_WARP = 802,
|
|
||||||
MENU_CHEAT_SKILL = 803,
|
|
||||||
MENU_CREDITS = 990,
|
MENU_CREDITS = 990,
|
||||||
MENU_CREDITS2 = 991,
|
MENU_CREDITS2 = 991,
|
||||||
MENU_CREDITS3 = 992,
|
MENU_CREDITS3 = 992,
|
||||||
MENU_CREDITS4 = 993,
|
MENU_CREDITS4 = 993,
|
||||||
MENU_CREDITS5 = 994,
|
MENU_CREDITS5 = 994,
|
||||||
|
MENU_QUIT = 500,
|
||||||
|
MENU_QUITTOTITLE = 501,
|
||||||
|
MENU_QUIT_INGAME = 502,
|
||||||
|
|
||||||
|
MENU_SAVESETUP = 750,
|
||||||
|
|
||||||
|
MENU_SAVECLEANVERIFY = 751,
|
||||||
MENU_LOADVERIFY = 1000,
|
MENU_LOADVERIFY = 1000,
|
||||||
MENU_LOADDELVERIFY = 1100,
|
MENU_LOADDELVERIFY = 1100,
|
||||||
MENU_NEWVERIFY = 1500,
|
MENU_NEWVERIFY = 1500,
|
||||||
|
@ -123,9 +121,11 @@ enum MenuIndex_t {
|
||||||
MENU_ADULTPASSWORD = 10001,
|
MENU_ADULTPASSWORD = 10001,
|
||||||
MENU_RESETPLAYER = 15000,
|
MENU_RESETPLAYER = 15000,
|
||||||
MENU_BUYDUKE = 20000,
|
MENU_BUYDUKE = 20000,
|
||||||
|
|
||||||
|
MENU_NETSETUP = 600,
|
||||||
|
MENU_NETWAITMASTER = 601,
|
||||||
|
MENU_NETWAITVOTES = 603,
|
||||||
MENU_NETWORK = 20001,
|
MENU_NETWORK = 20001,
|
||||||
MENU_PLAYER = 20002,
|
|
||||||
MENU_MACROS = 20004,
|
|
||||||
MENU_NETHOST = 20010,
|
MENU_NETHOST = 20010,
|
||||||
MENU_NETOPTIONS = 20011,
|
MENU_NETOPTIONS = 20011,
|
||||||
MENU_NETUSERMAP = 20012,
|
MENU_NETUSERMAP = 20012,
|
||||||
|
|
|
@ -26,19 +26,31 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
#include "cache1d.h"
|
#include "cache1d.h"
|
||||||
|
#include "savegamehelp.h"
|
||||||
|
|
||||||
BEGIN_SW_NS
|
BEGIN_SW_NS
|
||||||
|
|
||||||
typedef FILE* MFILE_WRITE;
|
typedef FileWriter* MFILE_WRITE;
|
||||||
typedef FILE* MFILE_READ;
|
typedef FileReader* MFILE_READ;
|
||||||
|
|
||||||
|
inline size_t MREAD(void* buf, size_t size, size_t nelem, FileReader* handle)
|
||||||
|
{
|
||||||
|
return handle->Read(buf, size * nelem) / size;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t MWRITE(void* buf, size_t size, size_t nelem, FileWriter* handle)
|
||||||
|
{
|
||||||
|
return handle->Write(buf, size * nelem) / size;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MCLOSE_WRITE(FileWriter* handle)
|
||||||
|
{
|
||||||
|
FinishSavegameWrite();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void MCLOSE_READ(FileReader* handle)
|
||||||
|
{
|
||||||
|
FinishSavegameRead();
|
||||||
|
}
|
||||||
|
|
||||||
// This needs some real fixing...
|
|
||||||
#define MREAD(ptr, size, num,handle) fread((ptr),(size),(num),(handle))
|
|
||||||
#define MWRITE(ptr, size, num,handle) fwrite((ptr),(size),(num),(handle))
|
|
||||||
#define MOPEN_WRITE(name) fopen(name,"wb")
|
|
||||||
#define MOPEN_READ(name) fopen(name,"rb")
|
|
||||||
#define MCLOSE_WRITE(handle) fclose(handle)
|
|
||||||
#define MCLOSE_READ(handle) fclose(handle)
|
|
||||||
#define MOPEN_WRITE_ERR nullptr
|
|
||||||
#define MOPEN_READ_ERR nullptr
|
|
||||||
END_SW_NS
|
END_SW_NS
|
||||||
|
|
|
@ -56,6 +56,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
|
||||||
#include "colormap.h"
|
#include "colormap.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "i_specialpaths.h"
|
#include "i_specialpaths.h"
|
||||||
|
#include "savegamehelp.h"
|
||||||
|
|
||||||
//void TimerFunc(task * Task);
|
//void TimerFunc(task * Task);
|
||||||
BEGIN_SW_NS
|
BEGIN_SW_NS
|
||||||
|
@ -240,24 +241,17 @@ int SaveGame(short save_num)
|
||||||
PANEL_SPRITE tpanel_sprite;
|
PANEL_SPRITE tpanel_sprite;
|
||||||
PANEL_SPRITEp psp,cur,next;
|
PANEL_SPRITEp psp,cur,next;
|
||||||
SECTOR_OBJECTp sop;
|
SECTOR_OBJECTp sop;
|
||||||
char game_name[256];
|
|
||||||
int cnt = 0, saveisshot=0;
|
int cnt = 0, saveisshot=0;
|
||||||
OrgTileP otp, next_otp;
|
OrgTileP otp, next_otp;
|
||||||
|
|
||||||
Saveable_Init();
|
Saveable_Init();
|
||||||
|
|
||||||
|
|
||||||
#if 0 // A lot of work is needed here... (Thank God for all the macros around the load/save functions. :) )
|
|
||||||
FStringf base("save%04d", save_num);
|
FStringf base("save%04d", save_num);
|
||||||
auto game_name = G_BuildSaveName(base);
|
auto game_name = G_BuildSaveName(base);
|
||||||
OpenSaveGameForWrite(game_name);
|
OpenSaveGameForWrite(game_name);
|
||||||
G_WriteSaveHeader(SaveGameDescr[save_num], LevelInfo[Level].LevelName, LevelInfo[Level].Description);
|
G_WriteSaveHeader(SaveGameDescr[save_num], LevelInfo[Level].LevelName, LevelInfo[Level].Description);
|
||||||
auto fil = WriteSavegameChunk("snapshot.sw");
|
fil = WriteSavegameChunk("snapshot.sw");
|
||||||
#endif
|
|
||||||
|
|
||||||
snprintf(game_name, 256, "%sgame%d.sav", M_GetSavegamesPath().GetChars(), save_num);
|
|
||||||
if ((fil = MOPEN_WRITE(game_name)) == MOPEN_WRITE_ERR)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
MWRITE(&GameVersion,sizeof(GameVersion),1,fil);
|
MWRITE(&GameVersion,sizeof(GameVersion),1,fil);
|
||||||
|
|
||||||
|
@ -711,6 +705,7 @@ int SaveGame(short save_num)
|
||||||
|
|
||||||
int LoadGameFullHeader(short save_num, char *descr, short *level, short *skill)
|
int LoadGameFullHeader(short save_num, char *descr, short *level, short *skill)
|
||||||
{
|
{
|
||||||
|
#if 0 // only used by the menu. Will go away soon.
|
||||||
MFILE_READ fil;
|
MFILE_READ fil;
|
||||||
char game_name[256];
|
char game_name[256];
|
||||||
short tile;
|
short tile;
|
||||||
|
@ -738,10 +733,14 @@ int LoadGameFullHeader(short save_num, char *descr, short *level, short *skill)
|
||||||
MCLOSE_READ(fil);
|
MCLOSE_READ(fil);
|
||||||
|
|
||||||
return tile;
|
return tile;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGameDescr(short save_num, char *descr)
|
void LoadGameDescr(short save_num, char *descr)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
MFILE_READ fil;
|
MFILE_READ fil;
|
||||||
char game_name[256];
|
char game_name[256];
|
||||||
short tile;
|
short tile;
|
||||||
|
@ -761,6 +760,7 @@ void LoadGameDescr(short save_num, char *descr)
|
||||||
MREAD(descr, sizeof(SaveGameDescr[0]),1,fil);
|
MREAD(descr, sizeof(SaveGameDescr[0]),1,fil);
|
||||||
|
|
||||||
MCLOSE_READ(fil);
|
MCLOSE_READ(fil);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -780,7 +780,6 @@ int LoadGame(short save_num)
|
||||||
int16_t data_ndx;
|
int16_t data_ndx;
|
||||||
PANEL_SPRITEp psp,next,cur;
|
PANEL_SPRITEp psp,next,cur;
|
||||||
PANEL_SPRITE tpanel_sprite;
|
PANEL_SPRITE tpanel_sprite;
|
||||||
char game_name[256];
|
|
||||||
OrgTileP otp, next_otp;
|
OrgTileP otp, next_otp;
|
||||||
|
|
||||||
int RotNdx;
|
int RotNdx;
|
||||||
|
@ -791,9 +790,13 @@ int LoadGame(short save_num)
|
||||||
|
|
||||||
Saveable_Init();
|
Saveable_Init();
|
||||||
|
|
||||||
snprintf(game_name, 256, "%sgame%d.sav", M_GetSavegamesPath().GetChars(), save_num);
|
FStringf base("save%04d", save_num);
|
||||||
if ((fil = MOPEN_READ(game_name)) == MOPEN_READ_ERR)
|
auto game_name = G_BuildSaveName(base);
|
||||||
return -1;
|
OpenSaveGameForRead(game_name);
|
||||||
|
|
||||||
|
auto filr = ReadSavegameChunk("snapshot.sw");
|
||||||
|
if (!filr.isOpen()) return -1;
|
||||||
|
fil = &filr;
|
||||||
|
|
||||||
MREAD(&i,sizeof(i),1,fil);
|
MREAD(&i,sizeof(i),1,fil);
|
||||||
if (i != GameVersion)
|
if (i != GameVersion)
|
||||||
|
|
Loading…
Reference in a new issue