Skip to content

Commit

Permalink
Remove steam_appid.txt requirement.
Browse files Browse the repository at this point in the history
Set the AppId in an environment variable, so the steam_appid.txt file isn't needed anymore.
  • Loading branch information
Gwindalmir committed Oct 12, 2021
1 parent cb8f2d6 commit e2a8919
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 12 deletions.
55 changes: 52 additions & 3 deletions MEWorkshopTool/MEWorkshopTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
<HintPath>Bin64\Steamworks.NET.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
<Reference Include="Microsoft.CSharp">
<Private>false</Private>
</Reference>
<Reference Include="System.Net.Http">
<Private>false</Private>
</Reference>
<Reference Include="VRage">
<HintPath>Bin64\VRage.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -84,9 +88,54 @@
<Import Project="..\WorkshopToolCommon\WorkshopToolCommon.projitems" Label="Shared" />
<Import Project="..\Updater\Updater.projitems" Label="Shared" />
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="set APPID=333950&#xD;&#xA;if NOT exist &quot;$(TargetDir)steam_appid.txt&quot; echo %APPID% &gt; &quot;$(TargetDir)steam_appid.txt&quot;&#xD;&#xA;if NOT exist &quot;$(TargetDir)\Bin64&quot; mklink /j &quot;$(TargetDir)\Bin64&quot; &quot;$(ProjectDir)\Bin64&quot;&#xD;&#xA;powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -Command &quot;&amp; {Compress-Archive -Force -Path $(TargetDir)$(TargetName).exe, $(TargetDir)$(TargetName).exe.config, $(TargetDir)$(TargetName).pdb, $(TargetDir)CommandLine.dll, $(TargetDir)MEWT.config, $(TargetDir).wtignore -DestinationPath $(TargetDir)$(TargetName)-v$(VersionPrefix).zip}&quot;" />
<Exec Command="set APPID=333950&#xD;&#xA;if NOT exist &quot;$(TargetDir)\Bin64&quot; mklink /j &quot;$(TargetDir)\Bin64&quot; &quot;$(ProjectDir)\Bin64&quot;&#xD;&#xA;powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -Command &quot;&amp; {Compress-Archive -Force -Path $(TargetDir)$(TargetName).exe, $(TargetDir)$(TargetName).exe.config, $(TargetDir)$(TargetName).pdb, $(TargetDir)CommandLine.dll, $(TargetDir)MEWT.config, $(TargetDir).wtignore -DestinationPath $(TargetDir)$(TargetName)-v$(VersionPrefix).zip}&quot;" />
</Target>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(SolutionDir)\Tools\LinkBinaries.ps1 333950 $(ProjectDir)\Bin64" />
</Target>
<ItemGroup>
<Reference Update="System">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Core">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Data">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Drawing">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.IO.Compression.FileSystem">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Numerics">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Runtime.Serialization">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Xml">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Xml.Linq">
<Private>false</Private>
</Reference>
</ItemGroup>
</Project>
55 changes: 52 additions & 3 deletions SEWorkshopTool/SEWorkshopTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@
<HintPath>Bin64\Steamworks.NET.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Configuration">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.CSharp">
<Private>false</Private>
</Reference>
<Reference Include="VRage, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Bin64\VRage.dll</HintPath>
Expand Down Expand Up @@ -113,6 +117,51 @@
<Exec Command="powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File $(SolutionDir)\Tools\LinkBinaries.ps1 244850 $(ProjectDir)\Bin64" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="set APPID=244850&#xD;&#xA;if NOT exist &quot;$(TargetDir)steam_appid.txt&quot; echo %APPID% &gt; &quot;$(TargetDir)steam_appid.txt&quot;&#xD;&#xA;if NOT exist &quot;$(TargetDir)\Bin64&quot; mklink /j &quot;$(TargetDir)\Bin64&quot; &quot;$(ProjectDir)\Bin64&quot;&#xD;&#xA;powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -Command &quot;&amp; {Compress-Archive -Force -Path $(TargetDir)$(TargetName).exe, $(TargetDir)$(TargetName).exe.config, $(TargetDir)$(TargetName).pdb, $(TargetDir)CommandLine.dll, $(TargetDir).wtignore, $(TargetDir)steam_appid.txt -DestinationPath $(TargetDir)$(TargetName)-v$(VersionPrefix).zip}&quot;" />
<Exec Command="set APPID=244850&#xD;&#xA;if NOT exist &quot;$(TargetDir)\Bin64&quot; mklink /j &quot;$(TargetDir)\Bin64&quot; &quot;$(ProjectDir)\Bin64&quot;&#xD;&#xA;powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -Command &quot;&amp; {Compress-Archive -Force -Path $(TargetDir)$(TargetName).exe, $(TargetDir)$(TargetName).exe.config, $(TargetDir)$(TargetName).pdb, $(TargetDir)CommandLine.dll, $(TargetDir).wtignore -DestinationPath $(TargetDir)$(TargetName)-v$(VersionPrefix).zip}&quot;" />
</Target>
<ItemGroup>
<Reference Update="System">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Core">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Data">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Drawing">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.IO.Compression.FileSystem">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Numerics">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Runtime.Serialization">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Xml">
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Update="System.Xml.Linq">
<Private>false</Private>
</Reference>
</ItemGroup>
</Project>
13 changes: 7 additions & 6 deletions WorkshopToolCommon/GameBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ static GameBase()
// Make sure the current directory is where the game files are
Directory.SetCurrentDirectory(Path.GetDirectoryName(typeof(FastResourceLock).Assembly.Location));
var root = Path.Combine(Path.GetDirectoryName(typeof(FastResourceLock).Assembly.Location), "..");
#if SE
// Steam API doesn't initialize correctly if it can't find steam_appid.txt
if (!File.Exists("steam_appid.txt"))
Directory.SetCurrentDirectory(root);
#else

#if !SE
AppName = "MEWT";
IsME = true;
AppId = 333950;
#endif
// If the file can't be found, assume it's SE
if (File.Exists("steam_appid.txt"))
Expand All @@ -59,6 +57,9 @@ static GameBase()
AppId = uint.Parse(appid);
}

// Set the AppId in an environment variable, so steam_appid.txt isn't needed anymore.
Environment.SetEnvironmentVariable("SteamAppId", AppId.ToString());

// Override the ExePath, so the game classes can initialize when the exe is outside the game directory
MyFileSystem.ExePath = new FileInfo(Assembly.GetAssembly(typeof(FastResourceLock)).Location).DirectoryName;
}
Expand Down Expand Up @@ -214,7 +215,7 @@ public virtual int InitGame(string[] args)
catch (Exception ex)
{
ProgramBase.CheckForUpdate();
ex.Log("ERROR: An exception occurred intializing game libraries: ");
ex.Log("ERROR: An exception occurred initializing game libraries: ");
return Cleanup(2);
}

Expand Down

0 comments on commit e2a8919

Please sign in to comment.