Skip to content

Commit

Permalink
Don't end up calling CreateStatePath when we don't have a ROM loaded
Browse files Browse the repository at this point in the history
Path.Combine will throw due to null state path
  • Loading branch information
CasualPokePlayer committed Jun 17, 2024
1 parent 6cd1521 commit 9094348
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion GSR/StateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void LoadStatePreview()
private void OnStateSlotChanged()
{
osdManager.QueueMessage($"Current state slot set to {GetStateSlot(config.SaveStateSlot)}");
if (!config.HideStatePreviews)
if (!config.HideStatePreviews && !emuManager.RomIsLoaded)
{
LoadStatePreview();
}
Expand All @@ -86,6 +86,11 @@ private string CreateStatePath(int slot)

public void SaveStateSlot(int slot)
{
if (!emuManager.RomIsLoaded)
{
return;
}

var statePath = CreateStatePath(slot);
osdManager.QueueMessage(emuManager.SaveState(statePath)
? $"State {GetStateSlot(slot)} saved"
Expand All @@ -104,6 +109,11 @@ public void SaveStateSlot(int slot)

public void LoadStateSlot(int slot)
{
if (!emuManager.RomIsLoaded)
{
return;
}

var statePath = CreateStatePath(slot);
osdManager.QueueMessage(emuManager.LoadState(statePath)
? $"State {GetStateSlot(slot)} loaded"
Expand Down

0 comments on commit 9094348

Please sign in to comment.