Changed savegames function calls from using strings to slot number

This commit is contained in:
MontyTRC89 2021-10-15 05:35:44 +02:00
parent a1162635d3
commit 2ca666d2d6
3 changed files with 19 additions and 10 deletions

View file

@ -619,10 +619,7 @@ GAME_STATUS DoLevel(int index, std::string ambient, bool loadFromSavegame)
// Restore the game?
if (loadFromSavegame)
{
char fileName[255];
ZeroMemory(fileName, 255);
sprintf(fileName, "savegame.%d", g_GameFlow->SelectedSaveGame);
SaveGame::Load(fileName);
SaveGame::Load(g_GameFlow->SelectedSaveGame);
Camera.pos.x = LaraItem->pos.xPos + 256;
Camera.pos.y = LaraItem->pos.yPos + 256;

View file

@ -35,8 +35,12 @@ int SaveGame::LastSaveGame;
SAVEGAME_INFO Savegame;
bool SaveGame::Save(char* fileName)
bool SaveGame::Save(int slot)
{
char fileName[255];
ZeroMemory(fileName, 255);
sprintf(fileName, "savegame.%d", slot);
ITEM_INFO itemToSerialize{};
FlatBufferBuilder fbb{};
@ -442,8 +446,12 @@ bool SaveGame::Save(char* fileName)
return true;
}
bool SaveGame::Load(char* fileName)
bool SaveGame::Load(int slot)
{
char fileName[255];
ZeroMemory(fileName, 255);
sprintf(fileName, "savegame.%d", slot);
std::ifstream file;
file.open(fileName, std::ios_base::app | std::ios_base::binary);
file.seekg(0, std::ios::end);
@ -837,8 +845,12 @@ bool SaveGame::Load(char* fileName)
return true;
}
bool SaveGame::LoadHeader(char* fileName, SaveGameHeader* header)
bool SaveGame::LoadHeader(int slot, SaveGameHeader* header)
{
char fileName[255];
ZeroMemory(fileName, 255);
sprintf(fileName, "savegame.%d", slot);
std::ifstream file;
file.open(fileName, std::ios_base::app | std::ios_base::binary);
file.seekg(0, std::ios::end);

View file

@ -68,7 +68,7 @@ private:
public:
static int LastSaveGame;
static bool Load(char* fileName);
static bool LoadHeader(char* fileName, SaveGameHeader* header);
static bool Save(char* fileName);
static bool Load(int slot);
static bool LoadHeader(int slot, SaveGameHeader* header);
static bool Save(int slot);
};