Skip to content

Commit dbfbf13

Browse files
committed
Common: Show warning if Steam set wrong data paths, fixes #26
1 parent 3caadb5 commit dbfbf13

1 file changed

Lines changed: 57 additions & 11 deletions

File tree

ModAPI.Common/SporePath.cs

Lines changed: 57 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,31 +105,77 @@ public static bool SporeIsInstalledOnSteam()
105105
return result != null && ((int)result != 0);
106106
}
107107

108+
/// <summary>
109+
/// Returns true if the game is installed such that all data folders share the same parent folder.
110+
/// Usually this doesn't matter, but as of early 2026, Steam may install multiple copies of the game due to differing app IDs. This can result in mods being installed to the wrong copy, so this function checks if this is the case.
111+
/// </summary>
112+
private static bool IsDataDirsSameParent()
113+
{
114+
// Get the data paths
115+
var sporeDataPath = GetDataPath(Game.Spore);
116+
var ccDataPath = GetDataPath(Game.CreepyAndCute); // null if not installed
117+
var gaDataPath = GetDataPath(Game.GalacticAdventures);
118+
119+
// Get parent folder of each data path
120+
var sporeParent = sporeDataPath != null ? Directory.GetParent(sporeDataPath).FullName : null;
121+
var ccParent = ccDataPath != null ? Directory.GetParent(ccDataPath).FullName : null;
122+
var gaParent = gaDataPath != null ? Directory.GetParent(gaDataPath).FullName : null;
123+
124+
// Make sure Spore and GA share the same parent folder
125+
if (sporeParent != gaParent)
126+
{
127+
return false;
128+
}
129+
130+
// If CC is installed, it should also share the same parent
131+
if (ccParent != null && sporeParent != ccParent)
132+
{
133+
return false;
134+
}
135+
136+
return true;
137+
}
138+
108139
/// <summary>
109140
/// Returns true if Spore and GA are properly installed.
110141
/// If either game is not properly installed, returns false, and optionally shows an error message to the user. If the game is installed from Steam but hasn't been launched to complete the installation, shows a specific error message about launching the game on Steam.
111142
/// </summary>
112143
/// <returns></returns>
113144
public static bool IsGameInstalled(bool showMessageWhenFalse)
114145
{
115-
if (IsInstalled(Game.Spore) && IsInstalled(Game.GalacticAdventures))
146+
// Make sure data dirs are present for Spore and GA
147+
if (!IsInstalled(Game.Spore) || !IsInstalled(Game.GalacticAdventures))
116148
{
117-
return true;
149+
if (showMessageWhenFalse)
150+
{
151+
// Steam doesn't run the install script to create the registry keys until the game is launched from Steam for the first time
152+
if (SporeIsInstalledOnSteam())
153+
{
154+
SupportInfo.ShowInfo(CommonStrings.SteamDownloadedButNotLaunched, CommonStrings.SteamDownloadedButNotLaunchedTitle, true, false);
155+
}
156+
else
157+
{
158+
SupportInfo.ShowError(CommonStrings.GameNotFound, CommonStrings.GameNotFoundTitle, false, false);
159+
}
160+
}
161+
return false;
118162
}
119163

120-
if (showMessageWhenFalse)
164+
// For Steam only, check that all data dirs are in the same parent folder
165+
// As of early 2026, Steam may install multiple copies of the game due to differing app IDs. This can result in mods being installed to the wrong copy.
166+
// The "current" copy (Spore vs C&C vs GA) used is the most recent one launched from Steam. If we detect mixed folders, it means that non-GA has been launched, and the user should be told to launch GA to force everything to use GA's copy of the data.
167+
// Prior to early 2026, Steam only installed one copy, and they were all in the same folder, so this check will still pass.
168+
// NOTE: This may need to be changed in the future, if Steam changes anything again.
169+
if (SporeIsInstalledOnSteam() && !IsDataDirsSameParent())
121170
{
122-
// Steam doesn't run the install script to create the registry keys until the game is launched from Steam for the first time
123-
if (SporeIsInstalledOnSteam())
124-
{
125-
SupportInfo.ShowInfo(CommonStrings.SteamDownloadedButNotLaunched, CommonStrings.SteamDownloadedButNotLaunchedTitle, true, false);
126-
}
127-
else
171+
if (showMessageWhenFalse)
128172
{
129-
SupportInfo.ShowError(CommonStrings.GameNotFound, CommonStrings.GameNotFoundTitle, false, false);
173+
SupportInfo.ShowWarning(CommonStrings.SteamDownloadedButNotLaunched, CommonStrings.SteamDownloadedButNotLaunchedTitle);
130174
}
175+
return false;
131176
}
132-
return false;
177+
178+
return true;
133179
}
134180

135181
/// <summary>

0 commit comments

Comments
 (0)