Skip to content

Commit

Permalink
Fix random crash error
Browse files Browse the repository at this point in the history
  • Loading branch information
VanillaCold committed Jul 12, 2023
1 parent 50e64b6 commit ac0e6c4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 3 additions & 5 deletions Spore - Multiple Save Files/SwapSaveCheat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ void SwapSaveCheat::ParseLine(const ArgScript::Line& line)
auto arguments = line.GetArguments(1);
int ID = mpFormatParser->ParseInt(arguments[0]);

string16 directory;

directory.assign_convert(to_string(ID));
directory = u"Games/Game" + directory;
if (GameModeManager.GetActiveModeID() == GameModeIDs::kGGEMode)
{
Resource::Paths::CreateSaveAreaDirectoryDatabase(Resource::PathID::AppData, directory.c_str(), saveDatabase, Resource::SaveAreaID::GamesGame0);
hasSwapped = true;
timer = 2;
timer = 5;
GameModeManager.SetActiveMode(GameModeIDs::kGameCell);
}
else
Expand All @@ -45,9 +42,10 @@ void SwapSaveCheat::Update()
{
if (hasSwapped)
{
timer --;
timer -= 1/GameTimeManager.GetSpeed();
if (timer == 0)
{
Resource::Paths::CreateSaveAreaDirectoryDatabase(Resource::PathID::AppData, directory.c_str(), saveDatabase, Resource::SaveAreaID::GamesGame0);
hasSwapped = false;
GameModeManager.SetActiveMode(GameModeIDs::kGGEMode);
}
Expand Down
3 changes: 2 additions & 1 deletion Spore - Multiple Save Files/SwapSaveCheat.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ class SwapSaveCheat
// Called when the cheat is invoked
void ParseLine(const ArgScript::Line& line) override;
bool hasSwapped;
int timer;
float timer;

static DatabaseDirectoryFilesPtr saveDatabase;

void Update() override;

virtual int AddRef() override;
virtual int Release() override;
string16 directory;

// Returns a string containing the description. If mode != DescriptionMode::Basic, return a more elaborated description
const char* GetDescription(ArgScript::DescriptionMode mode) const override;
Expand Down
1 change: 1 addition & 0 deletions Spore - Multiple Save Files/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static_detour(SetSaveDetour, Resource::Database* (Resource::SaveAreaID))
{
return SwapSaveCheat::saveDatabase.get();
}

return original_function(area);
}
};
Expand Down

0 comments on commit ac0e6c4

Please sign in to comment.