BAGEL: Renames in baglib/save_game_file.h

This commit is contained in:
Eugene Sandulenko 2024-05-05 10:07:00 +02:00
parent e59e9afcae
commit 5bfcd7a608
10 changed files with 63 additions and 63 deletions

View File

@ -158,7 +158,7 @@ Common::Error BagelEngine::saveGameState(int slot, const Common::String &desc, b
}
Common::Error BagelEngine::saveGameState(int slot, const Common::String &desc,
bool isAutosave, ST_BAGEL_SAVE &saveData) {
bool isAutosave, StBagelSave &saveData) {
_saveData = saveData;
return Engine::saveGameState(slot, desc, isAutosave);
}

View File

@ -36,7 +36,7 @@ class BagelEngine : public Engine {
private:
const ADGameDescription *_gameDescription;
Common::RandomSource _randomSource;
ST_BAGEL_SAVE _saveData;
StBagelSave _saveData;
bool canSaveLoadFromWindow() const;
@ -92,7 +92,7 @@ public:
*/
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave,
ST_BAGEL_SAVE &saveData);
StBagelSave &saveData);
/**
* Load a game state

View File

@ -67,7 +67,7 @@ static char g_stringArray[NUM_MSG_STRINGS][512];
// static initializations
bool CBagMasterWin::_objSaveFl = false;
ST_OBJ *CBagMasterWin::_objList = nullptr;
StObj *CBagMasterWin::_objList = nullptr;
CBagCursor *CBagMasterWin::_cursorList[MAX_CURSORS];
int CBagMasterWin::_menuCount = 0;
int CBagMasterWin::_curCursor = 0;
@ -372,10 +372,10 @@ ErrorCode CBagMasterWin::loadFile(const CBofString &wldName, const CBofString &s
// Only allocate the object list when we really need it...
if (_objList == nullptr) {
_objList = (ST_OBJ *)bofAlloc(MAX_OBJS * sizeof(ST_OBJ));
_objList = (StObj *)bofAlloc(MAX_OBJS * sizeof(StObj));
if (_objList != nullptr) {
// Init to zero (we might not use all slots)
bofMemSet(_objList, 0, MAX_OBJS * sizeof(ST_OBJ));
bofMemSet(_objList, 0, MAX_OBJS * sizeof(StObj));
} else {
reportError(ERR_MEMORY, "Could not allocate Object list");
@ -1405,7 +1405,7 @@ void CBagMasterWin::setActiveCursor(int cursorId) {
}
}
void CBagMasterWin::fillSaveBuffer(ST_BAGEL_SAVE *saveBuf) {
void CBagMasterWin::fillSaveBuffer(StBagelSave *saveBuf) {
assert(isValidObject(this));
assert(saveBuf != nullptr);
@ -1414,7 +1414,7 @@ void CBagMasterWin::fillSaveBuffer(ST_BAGEL_SAVE *saveBuf) {
//
// 1st, wipe it
bofMemSet(saveBuf, 0, sizeof(ST_BAGEL_SAVE));
bofMemSet(saveBuf, 0, sizeof(StBagelSave));
CBagel *app = CBagel::getBagApp();
if (app != nullptr) {
@ -1490,7 +1490,7 @@ void CBagMasterWin::fillSaveBuffer(ST_BAGEL_SAVE *saveBuf) {
assert(_objList != nullptr);
bofMemCopy(&saveBuf->m_stObjListEx[0], _objList, sizeof(ST_OBJ) * MAX_OBJS);
bofMemCopy(&saveBuf->m_stObjListEx[0], _objList, sizeof(StObj) * MAX_OBJS);
saveBuf->m_bUseEx = 1;
}
@ -1528,12 +1528,12 @@ bool CBagMasterWin::showSaveDialog(CBofWindow *win, bool bSaveBkg) {
logInfo("Showing Save Screen");
CBofSound::pauseSounds();
ST_BAGEL_SAVE *saveBuf = (ST_BAGEL_SAVE *)bofAlloc(sizeof(ST_BAGEL_SAVE));
StBagelSave *saveBuf = (StBagelSave *)bofAlloc(sizeof(StBagelSave));
if (saveBuf != nullptr) {
fillSaveBuffer(saveBuf);
CBagSaveDialog saveDialog;
saveDialog.setSaveGameBuffer((byte *)saveBuf, sizeof(ST_BAGEL_SAVE));
saveDialog.setSaveGameBuffer((byte *)saveBuf, sizeof(StBagelSave));
// Use specified bitmap as this dialog's image
CBofBitmap *bmp = Bagel::loadBitmap(_sysScreen.getBuffer());
@ -1573,7 +1573,7 @@ bool CBagMasterWin::showSaveDialog(CBofWindow *win, bool bSaveBkg) {
return savedFl;
}
void CBagMasterWin::doRestore(ST_BAGEL_SAVE *saveBuf) {
void CBagMasterWin::doRestore(StBagelSave *saveBuf) {
assert(isValidObject(this));
assert(saveBuf != nullptr);
@ -1647,17 +1647,17 @@ void CBagMasterWin::doRestore(ST_BAGEL_SAVE *saveBuf) {
if (sdevManager != nullptr) {
// Restore any extra obj list info (for .WLD swapping)
if (_objList == nullptr) {
_objList = (ST_OBJ *)bofAlloc(MAX_OBJS * sizeof(ST_OBJ));
_objList = (StObj *)bofAlloc(MAX_OBJS * sizeof(StObj));
if (_objList != nullptr) {
// Init to nullptr (might not use all slots)
bofMemSet(_objList, 0, MAX_OBJS * sizeof(ST_OBJ));
bofMemSet(_objList, 0, MAX_OBJS * sizeof(StObj));
} else {
reportError(ERR_MEMORY);
}
}
bofMemCopy(getObjList(), &saveBuf->m_stObjListEx[0], sizeof(ST_OBJ) * MAX_OBJS);
bofMemCopy(getObjList(), &saveBuf->m_stObjListEx[0], sizeof(StObj) * MAX_OBJS);
if (saveBuf->m_bUseEx) {
setSaveObjs(true);

View File

@ -66,7 +66,7 @@ bool getCICStatus();
class CBagMasterWin : public CBofWindow, public CBagParseObject {
protected:
static bool _objSaveFl;
static ST_OBJ *_objList;
static StObj *_objList;
static CBagCursor *_cursorList[MAX_CURSORS];
CBagStorageDevWnd *_gameWindow;
@ -137,8 +137,8 @@ public:
bool showQuitDialog(CBofWindow *win, bool saveFl = true);
ErrorCode showCreditsDialog(CBofWindow *win, bool saveFl = true);
void fillSaveBuffer(ST_BAGEL_SAVE *saveBuf);
void doRestore(ST_BAGEL_SAVE *saveBuf);
void fillSaveBuffer(StBagelSave *saveBuf);
void doRestore(StBagelSave *saveBuf);
ErrorCode newGame();
@ -188,7 +188,7 @@ public:
void onKeyHit(uint32 keyCode, uint32 repCount) override;
void onClose() override;
ST_OBJ *getObjList() {
StObj *getObjList() {
return _objList;
}
void setSaveObjs(bool saveFl) {

View File

@ -30,13 +30,13 @@ namespace Bagel {
#define WORLDDIR "$SBARDIR\\WLD\\%s"
void ST_SAVEDGAME_HEADER::synchronize(Common::Serializer &s) {
void StSavegameHeader::synchronize(Common::Serializer &s) {
s.syncBytes((byte *)_szTitle, MAX_SAVETITLE);
s.syncBytes((byte *)m_szUserName, MAX_USERNAME);
s.syncAsUint32LE(m_bUsed);
}
void ST_VAR::synchronize(Common::Serializer &s) {
void StVar::synchronize(Common::Serializer &s) {
s.syncBytes((byte *)m_szName, MAX_VAR_NAME);
s.syncBytes((byte *)m_szValue, MAX_VAR_VALUE);
s.syncAsUint16LE(m_nType);
@ -53,7 +53,7 @@ void ST_VAR::synchronize(Common::Serializer &s) {
s.syncAsByte(m_bUsed);
}
void ST_VAR::clear() {
void StVar::clear() {
Common::fill(m_szName, m_szName + MAX_VAR_NAME, '\0');
Common::fill(m_szValue, m_szValue + MAX_VAR_VALUE, '\0');
@ -68,7 +68,7 @@ void ST_VAR::clear() {
m_bUsed = 0;
}
void ST_OBJ::synchronize(Common::Serializer &s) {
void StObj::synchronize(Common::Serializer &s) {
s.syncBytes((byte *)m_szName, MAX_OBJ_NAME);
s.syncBytes((byte *)m_szSDev, MAX_SDEV_NAME);
s.syncAsUint32LE(m_lState);
@ -85,7 +85,7 @@ void ST_OBJ::synchronize(Common::Serializer &s) {
s.syncAsUint16LE(m_nFlags);
}
void ST_OBJ::clear() {
void StObj::clear() {
Common::fill(m_szName, m_szName + MAX_OBJ_NAME, '\0');
Common::fill(m_szSDev, m_szSDev + MAX_SDEV_NAME, '\0');
@ -99,7 +99,7 @@ void ST_OBJ::clear() {
m_nFlags = 0;
}
void ST_BAGEL_SAVE::synchronize(Common::Serializer &s) {
void StBagelSave::synchronize(Common::Serializer &s) {
for (int i = 0; i < MAX_VARS; ++i)
m_stVarList[i].synchronize(s);
for (int i = 0; i < MAX_OBJS; ++i)
@ -119,7 +119,7 @@ void ST_BAGEL_SAVE::synchronize(Common::Serializer &s) {
s.syncAsUint16LE(m_nFiller);
}
void ST_BAGEL_SAVE::clear() {
void StBagelSave::clear() {
for (int i = 0; i < MAX_VARS; ++i)
m_stVarList[i].clear();
for (int i = 0; i < MAX_OBJS; ++i)
@ -148,11 +148,11 @@ CBagSaveGameFile::CBagSaveGameFile(bool isSaving) {
);
}
ErrorCode CBagSaveGameFile::WriteSavedGame() {
ErrorCode CBagSaveGameFile::writeSavedGame() {
assert(isValidObject(this));
// Populate the save data
ST_BAGEL_SAVE saveData;
StBagelSave saveData;
g_engine->_masterWin->fillSaveBuffer(&saveData);
Common::String str = "./" + Common::String(saveData.m_szScript);
@ -160,7 +160,7 @@ ErrorCode CBagSaveGameFile::WriteSavedGame() {
Common::strcpy_s(saveData.m_szScript, str.c_str());
// Set up header fields
ST_SAVEDGAME_HEADER header;
StSavegameHeader header;
Common::strcpy_s(header._szTitle, "ScummVM Save");
Common::strcpy_s(header.m_szUserName, "ScummVM User");
header.m_bUsed = 1;
@ -170,7 +170,7 @@ ErrorCode CBagSaveGameFile::WriteSavedGame() {
Common::Serializer s(nullptr, &stream);
header.synchronize(s);
stream.writeUint32LE(ST_BAGEL_SAVE::size());
stream.writeUint32LE(StBagelSave::size());
saveData.synchronize(s);
// Add the record
@ -186,7 +186,7 @@ ErrorCode CBagSaveGameFile::readSavedGame(int32 slotNum) {
if (lRecNum != -1) {
int32 lSize = getRecSize(lRecNum);
if (lSize == ST_SAVEDGAME_HEADER::size()) {
if (lSize == StSavegameHeader::size()) {
_errCode = ERR_FREAD;
} else {
byte *pBuf = (byte *)bofAlloc(lSize);
@ -196,10 +196,10 @@ ErrorCode CBagSaveGameFile::readSavedGame(int32 slotNum) {
// Load in the savegame
Common::MemoryReadStream stream(pBuf, lSize);
Common::Serializer s(&stream, nullptr);
ST_SAVEDGAME_HEADER header;
StSavegameHeader header;
header.synchronize(s);
s.skip(4); // Skip save data structure size
ST_BAGEL_SAVE saveData;
StBagelSave saveData;
saveData.synchronize(s);
bofFree(pBuf);
@ -220,7 +220,7 @@ ErrorCode CBagSaveGameFile::readSavedGame(int32 slotNum) {
return _errCode;
}
ErrorCode CBagSaveGameFile::readTitle(int32 lSlot, ST_SAVEDGAME_HEADER *pSavedGame) {
ErrorCode CBagSaveGameFile::readTitle(int32 lSlot, StSavegameHeader *pSavedGame) {
assert(isValidObject(this));
// validate input
@ -236,8 +236,8 @@ ErrorCode CBagSaveGameFile::readTitle(int32 lSlot, ST_SAVEDGAME_HEADER *pSavedGa
if (pBuf != nullptr) {
readRecord(lRecNum, pBuf);
// Fill ST_SAVEDGAME_HEADER structure with this game's saved info
bofMemCopy(pSavedGame, pBuf, sizeof(ST_SAVEDGAME_HEADER));
// Fill StSavegameHeader structure with this game's saved info
bofMemCopy(pSavedGame, pBuf, sizeof(StSavegameHeader));
bofFree(pBuf);
} else {
@ -275,13 +275,13 @@ ErrorCode CBagSaveGameFile::readTitleOnly(int32 lSlot, char *pGameTitle) {
}
int32 CBagSaveGameFile::GetActualNumSaves() {
int32 CBagSaveGameFile::getActualNumSaves() {
assert(isValidObject(this));
int32 lNumSaves = 0;
int32 lNumRecs = GetNumSavedGames();
int32 lNumRecs = getNumSavedGames();
for (int32 i = 0; i < lNumRecs; i++) {
ST_SAVEDGAME_HEADER stGameInfo;
StSavegameHeader stGameInfo;
if (readTitle(i, &stGameInfo) == ERR_NONE) {
if (stGameInfo.m_bUsed) {
lNumSaves++;
@ -294,12 +294,12 @@ int32 CBagSaveGameFile::GetActualNumSaves() {
return(lNumSaves);
}
bool CBagSaveGameFile::AnySavedGames() {
bool CBagSaveGameFile::anySavedGames() {
assert(isValidObject(this));
int32 lNumRecs = GetNumSavedGames();
int32 lNumRecs = getNumSavedGames();
for (int32 i = 0; i < lNumRecs; i++) {
ST_SAVEDGAME_HEADER stGameInfo;
StSavegameHeader stGameInfo;
if (readTitle(i, &stGameInfo) == ERR_NONE) {
if (stGameInfo.m_bUsed) {

View File

@ -31,7 +31,7 @@ namespace Bagel {
#define MAX_SAVETITLE 128
#define MAX_USERNAME 64
struct ST_SAVEDGAME_HEADER {
struct StSavegameHeader {
char _szTitle[MAX_SAVETITLE] = { '\0' };
char m_szUserName[MAX_USERNAME] = { '\0' };
uint32 m_bUsed = 0;
@ -49,7 +49,7 @@ struct ST_SAVEDGAME_HEADER {
#define MAX_VAR_NAME 40
#define MAX_VAR_VALUE 60
struct ST_VAR {
struct StVar {
char m_szName[MAX_VAR_NAME];
char m_szValue[MAX_VAR_VALUE];
uint16 m_nType;
@ -73,7 +73,7 @@ struct ST_VAR {
#define MAX_SDEV_NAME 40
#define MAX_OBJS 1000
struct ST_OBJ {
struct StObj {
char m_szName[MAX_OBJ_NAME];
char m_szSDev[MAX_SDEV_NAME];
uint32 m_lState;
@ -100,10 +100,10 @@ struct ST_OBJ {
/**
* Savegame data structure
*/
struct ST_BAGEL_SAVE {
ST_VAR m_stVarList[MAX_VARS];
ST_OBJ m_stObjList[MAX_OBJS];
ST_OBJ m_stObjListEx[MAX_OBJS];
struct StBagelSave {
StVar m_stVarList[MAX_VARS];
StObj m_stObjList[MAX_OBJS];
StObj m_stObjListEx[MAX_OBJS];
char m_szScript[MAX_FNAME]; // Name of current world file (no path)
uint32 m_nLocType; // TYPE_PAN, TYPE_CLOSUP, etc...
char m_szLocStack[MAX_CLOSEUP_DEPTH][MAX_SDEV_NAME]; // Your storage device stack
@ -128,16 +128,16 @@ class CBagSaveGameFile : public CBofDataFile {
public:
CBagSaveGameFile(bool isSaving);
int32 GetNumSavedGames() const {
int32 getNumSavedGames() const {
return getNumberOfRecs();
}
int32 GetActualNumSaves();
bool AnySavedGames();
int32 getActualNumSaves();
bool anySavedGames();
/**
* Saves a BAGEL game to current save game file
*/
ErrorCode WriteSavedGame();
ErrorCode writeSavedGame();
/**
* Restore a BAGEL saved game
@ -147,7 +147,7 @@ public:
/**
* Reads a BAGEL saved game title
*/
ErrorCode readTitle(int32 lSlot, ST_SAVEDGAME_HEADER *pSavedGame);
ErrorCode readTitle(int32 lSlot, StSavegameHeader *pSavedGame);
ErrorCode readTitleOnly(int32 lSlot, char *pGameTitle);
};

View File

@ -1983,7 +1983,7 @@ void CBagStorageDevManager::SetObjectValue(const CBofString &sObject, const CBof
}
void CBagStorageDevManager::SaveObjList(ST_OBJ *pObjList, int nNumEntries) {
void CBagStorageDevManager::SaveObjList(StObj *pObjList, int nNumEntries) {
assert(isValidObject(this));
assert(pObjList != nullptr);
@ -2030,7 +2030,7 @@ void CBagStorageDevManager::SaveObjList(ST_OBJ *pObjList, int nNumEntries) {
}
void CBagStorageDevManager::RestoreObjList(ST_OBJ *pObjList, int nNumEntries) {
void CBagStorageDevManager::RestoreObjList(StObj *pObjList, int nNumEntries) {
assert(isValidObject(this));
assert(pObjList != nullptr);

View File

@ -581,8 +581,8 @@ public:
bool AddObject(const CBofString &sDstName, const CBofString &sObjName);
bool removeObject(const CBofString &sSrcName, const CBofString &sObjName);
void SaveObjList(ST_OBJ *pObjList, int nNumEntries);
void RestoreObjList(ST_OBJ *pObjList, int nNumEntries);
void SaveObjList(StObj *pObjList, int nNumEntries);
void RestoreObjList(StObj *pObjList, int nNumEntries);
};
extern bool g_allowPaintFl;

View File

@ -90,7 +90,7 @@ bool Console::cmdLoad(int argc, const char **argv) {
delete saveFile;
CBagSaveGameFile saves(false);
const int count = saves.GetNumSavedGames();
const int count = saves.getNumSavedGames();
if (argc == 1) {
char nameBuffer[MAX_SAVETITLE];
@ -120,7 +120,7 @@ bool Console::cmdSave(int argc, const char **argv) {
g_system->getSavefileManager()->removeSavefile("spacebar.sav");
CBagSaveGameFile saves(true);
saves.WriteSavedGame();
saves.writeSavedGame();
saves.close();

View File

@ -44,7 +44,7 @@ private:
CBofText *_pText = nullptr;
CBofListBox *_pListBox = nullptr;
int _nSelectedItem = -1;
ST_BAGEL_SAVE *_pSaveBuf = nullptr;
StBagelSave *_pSaveBuf = nullptr;
int _nBufSize = 0;
bool _bRestored = false;
CBofPalette *_pSavePalette = nullptr;
@ -63,12 +63,12 @@ public:
virtual ErrorCode attach();
virtual ErrorCode detach();
ST_BAGEL_SAVE *getSaveGameBuffer(int &nLength) {
StBagelSave *getSaveGameBuffer(int &nLength) {
nLength = _nBufSize;
return _pSaveBuf;
}
void setSaveGameBuffer(ST_BAGEL_SAVE *pBuf, int nLength) {
void setSaveGameBuffer(StBagelSave *pBuf, int nLength) {
_pSaveBuf = pBuf;
_nBufSize = nLength;
}