feat: command-line Workshop upload
Tools/workshop-upload.ps1 updates the Workshop item through the running Steam client: no password, no game window, no dev mode. A small tool (Tools/WorkshopUpload) uses the Steamworks.NET build and steam_api64.dll that ship with RimWorld. Dry run by default; -Publish refuses unless the shipped files are committed and pushed and the last test run passed after the last build. The change note is every CHANGELOG entry newer than Tools/workshop-published.txt. docs/workshop-description.txt is the new Workshop description (BBCode).
This commit is contained in:
parent
1e4ad68432
commit
a9f25f4b2e
|
|
@ -5,3 +5,5 @@ Source/**/obj/
|
||||||
Tests/**/1.7/
|
Tests/**/1.7/
|
||||||
Tests/**/bin/
|
Tests/**/bin/
|
||||||
Tests/**/obj/
|
Tests/**/obj/
|
||||||
|
Tools/**/bin/
|
||||||
|
Tools/**/obj/
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
12
README.md
12
README.md
|
|
@ -44,6 +44,18 @@ RimWorld 1.7 no longer runs on Unity/Mono. It runs on .NET 10 (CoreCLR) with Lud
|
||||||
- In game, the Harmony mod swaps in a Waylith method-body backend (`HarmonyMod.RuntimeIL.dll`). Check `Player.log` for `[Blax Slaves] N patches applied` and Harmony's `runtime-body provider` line.
|
- In game, the Harmony mod swaps in a Waylith method-body backend (`HarmonyMod.RuntimeIL.dll`). Check `Player.log` for `[Blax Slaves] N patches applied` and Harmony's `runtime-body provider` line.
|
||||||
- Patches are applied from a `[StaticConstructorOnStartup]` class, one class at a time, so one broken target can't disable the rest.
|
- Patches are applied from a `[StaticConstructorOnStartup]` class, one class at a time, so one broken target can't disable the rest.
|
||||||
|
|
||||||
|
### Workshop upload
|
||||||
|
|
||||||
|
`Tools/workshop-upload.ps1` updates the Workshop item from the command line. A small tool (`Tools/WorkshopUpload`) uses the Steamworks.NET build and `steam_api64.dll` that ship with RimWorld and attaches to the running, logged-in Steam client as RimWorld, so it needs no password, no game window and no dev mode.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\Tools\workshop-upload.ps1 # dry run: stage, check the item and ownership
|
||||||
|
.\Tools\workshop-upload.ps1 -Publish # upload
|
||||||
|
.\Tools\workshop-upload.ps1 -Publish -DescriptionFile docs\workshop-description.txt # also replace the description
|
||||||
|
```
|
||||||
|
|
||||||
|
It stages only what players need (About, 1.7, Defs, Patches, Languages) in `%TEMP%`, sets the tags the game would (Mod plus the supported versions), and writes every CHANGELOG.md entry since the version in `Tools/workshop-published.txt` as the change note. `-Publish` refuses unless the shipped files are committed and pushed, the top CHANGELOG entry matches `modVersion`, and the last test run passed after the last build. It leaves the title and preview alone; the game's uploader resets the title from About.xml and never updates the description. The in-game route still works: `Tools/workshop-stage.ps1` swaps the junction for a clean copy, upload from Mods > Blax Slaves > More actions (dev mode), then `workshop-stage.ps1 -Done`.
|
||||||
|
|
||||||
### Tests
|
### Tests
|
||||||
|
|
||||||
`Tests/BlaxSlavesTests` is a separate test mod. `Tests/run-tests.ps1` builds both projects, links the test mod into the game's Mods folder for the run, and starts RimWorld headless (`-headless -quicktest -blaxslavestests`, no window) with its own save data folder in `%TEMP%\BlaxSlavesTest`, so your mod list, saves and settings stay untouched. The suite runs in a quick-test colony, saves and reloads the game, runs the persistence tests, writes `BlaxSlavesTestResults.txt` and quits. It takes about a minute and needs Steam running.
|
`Tests/BlaxSlavesTests` is a separate test mod. `Tests/run-tests.ps1` builds both projects, links the test mod into the game's Mods folder for the run, and starts RimWorld headless (`-headless -quicktest -blaxslavestests`, no window) with its own save data folder in `%TEMP%\BlaxSlavesTest`, so your mod list, saves and settings stay untouched. The suite runs in a quick-test colony, saves and reloads the game, runs the persistence tests, writes `BlaxSlavesTestResults.txt` and quits. It takes about a minute and needs Steam running.
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,265 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using Steamworks;
|
||||||
|
|
||||||
|
// Updates an existing RimWorld Steam Workshop item through the running, logged-in Steam client.
|
||||||
|
// No password: SteamAPI attaches to the client as RimWorld (app 294100), like the game does.
|
||||||
|
// Without --publish it only reads the item and checks that this Steam account owns it.
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
private const uint RimWorldAppId = 294100;
|
||||||
|
private const int MaxTextBytes = 8000; // Steam's limit for a description (k_cchPublishedDocumentDescriptionMax)
|
||||||
|
|
||||||
|
private static int Main(string[] args)
|
||||||
|
{
|
||||||
|
Options o;
|
||||||
|
try { o = Options.Parse(args); }
|
||||||
|
catch (ArgumentException e)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(e.Message);
|
||||||
|
Console.Error.WriteLine(Options.Usage);
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.Content != null && !CheckContent(o.Content)) return 65;
|
||||||
|
string note = o.NoteFile != null ? File.ReadAllText(o.NoteFile, Encoding.UTF8).Trim() : null;
|
||||||
|
string description = o.DescriptionFile != null ? File.ReadAllText(o.DescriptionFile, Encoding.UTF8).Trim() : null;
|
||||||
|
if (description != null && Encoding.UTF8.GetByteCount(description) > MaxTextBytes)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"The description is over Steam's {MaxTextBytes}-byte limit.");
|
||||||
|
return 65;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SteamAPI.Init looks for steam_appid.txt in the working directory; the env var covers other callers.
|
||||||
|
Directory.SetCurrentDirectory(AppContext.BaseDirectory);
|
||||||
|
Environment.SetEnvironmentVariable("SteamAppId", RimWorldAppId.ToString());
|
||||||
|
if (!Packsize.Test() || !DllCheck.Test())
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("Steamworks.NET and steam_api64.dll don't match. Rebuild the tool against the current RimWorld install.");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
// Never call SteamAPI.RestartAppIfNecessary here: it would make Steam launch RimWorld.
|
||||||
|
if (!SteamAPI.Init())
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("SteamAPI.Init failed. Is Steam running and logged in, under the same Windows user, not as administrator?");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return Run(o, note, description);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
SteamAPI.Shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int Run(Options o, string note, string description)
|
||||||
|
{
|
||||||
|
var item = new PublishedFileId_t(o.Item);
|
||||||
|
Console.WriteLine($"Steam account: {SteamFriends.GetPersonaName()}");
|
||||||
|
|
||||||
|
if (!QueryDetails(item, o.Timeout, out SteamUGCDetails_t d)) return 3;
|
||||||
|
Console.WriteLine($"Item {o.Item}: \"{d.m_rgchTitle}\"");
|
||||||
|
Console.WriteLine($" updated {DateTimeOffset.FromUnixTimeSeconds(d.m_rtimeUpdated).ToLocalTime():yyyy-MM-dd HH:mm}");
|
||||||
|
Console.WriteLine($" tags {d.m_rgchTags}");
|
||||||
|
Console.WriteLine($" size {d.m_nFileSize / 1024.0:N0} KB");
|
||||||
|
Console.WriteLine($" visible {d.m_eVisibility.ToString().Replace("k_ERemoteStoragePublishedFileVisibility", "")}");
|
||||||
|
if (d.m_bBanned) Console.WriteLine(" BANNED on Steam");
|
||||||
|
if (d.m_nConsumerAppID.m_AppId != RimWorldAppId)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"The item belongs to app {d.m_nConsumerAppID.m_AppId}, not RimWorld.");
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
if (d.m_ulSteamIDOwner != SteamUser.GetSteamID().m_SteamID)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("This Steam account doesn't own the item.");
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
Console.WriteLine(" owner this account");
|
||||||
|
|
||||||
|
if (!o.Publish)
|
||||||
|
{
|
||||||
|
Console.WriteLine();
|
||||||
|
Console.WriteLine("Dry run: nothing was uploaded.");
|
||||||
|
if (o.Content != null) Console.WriteLine($" would upload {o.Content}");
|
||||||
|
if (o.Tags != null) Console.WriteLine($" would tag {string.Join(", ", o.Tags)}");
|
||||||
|
if (description != null) Console.WriteLine($" would replace the description ({Encoding.UTF8.GetByteCount(description)} bytes)");
|
||||||
|
if (note != null) Console.WriteLine(" change note:\n" + Indent(note));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.Content == null || note == null)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("--publish needs --content and --note-file.");
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
return Submit(item, o, note, description);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int Submit(PublishedFileId_t item, Options o, string note, string description)
|
||||||
|
{
|
||||||
|
UGCUpdateHandle_t h = SteamUGC.StartItemUpdate(new AppId_t(RimWorldAppId), item);
|
||||||
|
if (!SteamUGC.SetItemContent(h, o.Content)) return Fail("SetItemContent refused the content folder.");
|
||||||
|
if (o.Tags != null && !SteamUGC.SetItemTags(h, o.Tags)) return Fail("SetItemTags refused the tags.");
|
||||||
|
if (description != null && !SteamUGC.SetItemDescription(h, description)) return Fail("SetItemDescription refused the text.");
|
||||||
|
|
||||||
|
bool got = false, ioFailure = false;
|
||||||
|
SubmitItemUpdateResult_t result = default;
|
||||||
|
var call = CallResult<SubmitItemUpdateResult_t>.Create((r, io) => { result = r; ioFailure = io; got = true; });
|
||||||
|
call.Set(SteamUGC.SubmitItemUpdate(h, note));
|
||||||
|
|
||||||
|
Console.WriteLine("Uploading...");
|
||||||
|
EItemUpdateStatus last = EItemUpdateStatus.k_EItemUpdateStatusInvalid;
|
||||||
|
bool finished = Pump(() => got, o.Timeout, () =>
|
||||||
|
{
|
||||||
|
EItemUpdateStatus s = SteamUGC.GetItemUpdateProgress(h, out ulong done, out ulong total);
|
||||||
|
if (s != last && s != EItemUpdateStatus.k_EItemUpdateStatusInvalid)
|
||||||
|
{
|
||||||
|
Console.WriteLine($" {s.ToString().Replace("k_EItemUpdateStatus", "")}" + (total > 0 ? $" {done / 1024}/{total / 1024} KB" : ""));
|
||||||
|
last = s;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
GC.KeepAlive(call);
|
||||||
|
if (!finished)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("No answer from Steam in time. Steam may still finish the upload; check the item page before retrying.");
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
if (ioFailure) return Fail("Steam reported an IO failure.");
|
||||||
|
if (result.m_eResult != EResult.k_EResultOK) return Fail($"Steam refused the update: {result.m_eResult}. {Hint(result.m_eResult)}");
|
||||||
|
|
||||||
|
Console.WriteLine($"Done: https://steamcommunity.com/sharedfiles/filedetails/?id={o.Item}");
|
||||||
|
if (result.m_bUserNeedsToAcceptWorkshopLegalAgreement)
|
||||||
|
Console.WriteLine("Steam hides the item until you accept the Workshop legal agreement: https://steamcommunity.com/sharedfiles/workshoplegalagreement");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool QueryDetails(PublishedFileId_t item, TimeSpan timeout, out SteamUGCDetails_t details)
|
||||||
|
{
|
||||||
|
details = default;
|
||||||
|
UGCQueryHandle_t q = SteamUGC.CreateQueryUGCDetailsRequest(new[] { item }, 1);
|
||||||
|
bool got = false, ioFailure = false;
|
||||||
|
SteamUGCQueryCompleted_t done = default;
|
||||||
|
var call = CallResult<SteamUGCQueryCompleted_t>.Create((r, io) => { done = r; ioFailure = io; got = true; });
|
||||||
|
call.Set(SteamUGC.SendQueryUGCRequest(q));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Pump(() => got, timeout)) { Console.Error.WriteLine("No answer from Steam for the item query."); return false; }
|
||||||
|
if (ioFailure || done.m_eResult != EResult.k_EResultOK || done.m_unNumResultsReturned < 1)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"The item query failed: {(ioFailure ? "IO failure" : done.m_eResult.ToString())}.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!SteamUGC.GetQueryUGCResult(q, 0, out details) || details.m_eResult != EResult.k_EResultOK)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"Steam has no item {item}: {details.m_eResult}.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
GC.KeepAlive(call);
|
||||||
|
SteamUGC.ReleaseQueryUGCRequest(q);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool Pump(Func<bool> done, TimeSpan timeout, Action eachTick = null)
|
||||||
|
{
|
||||||
|
var sw = Stopwatch.StartNew();
|
||||||
|
while (!done())
|
||||||
|
{
|
||||||
|
SteamAPI.RunCallbacks();
|
||||||
|
eachTick?.Invoke();
|
||||||
|
if (sw.Elapsed > timeout) return false;
|
||||||
|
Thread.Sleep(100);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool CheckContent(string dir)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(dir)) { Console.Error.WriteLine($"No content folder at {dir}."); return false; }
|
||||||
|
if (!File.Exists(Path.Combine(dir, "About", "About.xml"))) { Console.Error.WriteLine($"{dir} has no About\\About.xml."); return false; }
|
||||||
|
string[] devOnly = { ".git", "Source", "Tests", "obj", "bin" };
|
||||||
|
var found = Directory.GetDirectories(dir, "*", SearchOption.AllDirectories)
|
||||||
|
.Where(p => devOnly.Contains(Path.GetFileName(p), StringComparer.OrdinalIgnoreCase)).ToList();
|
||||||
|
if (found.Count > 0)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("The content folder holds development folders that players don't need:\n" + Indent(string.Join("\n", found)));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var files = Directory.GetFiles(dir, "*", SearchOption.AllDirectories);
|
||||||
|
Console.WriteLine($"Content: {dir} ({files.Length} files, {files.Sum(f => new FileInfo(f).Length) / 1024.0:N0} KB)");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string Hint(EResult r) => r switch
|
||||||
|
{
|
||||||
|
EResult.k_EResultAccessDenied => "The account needs a RimWorld license.",
|
||||||
|
EResult.k_EResultFileNotFound => "Steam couldn't read the content folder or the preview.",
|
||||||
|
EResult.k_EResultLimitExceeded => "The preview is over 1 MB, or the Steam Cloud quota is full.",
|
||||||
|
EResult.k_EResultLockingFailed => "Steam couldn't lock the item; try again in a minute.",
|
||||||
|
EResult.k_EResultInvalidParam => "Steam rejected a field; check the tags and the content path.",
|
||||||
|
_ => "",
|
||||||
|
};
|
||||||
|
|
||||||
|
private static int Fail(string message)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(message);
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string Indent(string text) => string.Join("\n", text.Split('\n').Select(l => " " + l.TrimEnd('\r')));
|
||||||
|
|
||||||
|
private sealed class Options
|
||||||
|
{
|
||||||
|
public const string Usage =
|
||||||
|
"Usage: WorkshopUpload --item <publishedFileId> [--content <dir>] [--note-file <file>] [--tags Mod,1.7]\n" +
|
||||||
|
" [--description-file <file>] [--timeout <seconds>] [--publish]\n" +
|
||||||
|
"Without --publish it only reads the item and checks ownership.";
|
||||||
|
|
||||||
|
public ulong Item;
|
||||||
|
public string Content, NoteFile, DescriptionFile;
|
||||||
|
public List<string> Tags;
|
||||||
|
public TimeSpan Timeout = TimeSpan.FromMinutes(15);
|
||||||
|
public bool Publish;
|
||||||
|
|
||||||
|
public static Options Parse(string[] args)
|
||||||
|
{
|
||||||
|
var o = new Options();
|
||||||
|
for (int i = 0; i < args.Length; i++)
|
||||||
|
{
|
||||||
|
string Next() => i + 1 < args.Length ? args[++i] : throw new ArgumentException($"{args[i]} needs a value.");
|
||||||
|
switch (args[i])
|
||||||
|
{
|
||||||
|
case "--item":
|
||||||
|
if (!ulong.TryParse(Next(), out o.Item)) throw new ArgumentException("--item must be a number.");
|
||||||
|
break;
|
||||||
|
case "--content": o.Content = Path.GetFullPath(Next()); break;
|
||||||
|
case "--note-file": o.NoteFile = ExistingFile(Next()); break;
|
||||||
|
case "--description-file": o.DescriptionFile = ExistingFile(Next()); break;
|
||||||
|
case "--tags": o.Tags = Next().Split(',').Select(t => t.Trim()).Where(t => t.Length > 0).ToList(); break;
|
||||||
|
case "--timeout": o.Timeout = TimeSpan.FromSeconds(int.Parse(Next())); break;
|
||||||
|
case "--publish": o.Publish = true; break;
|
||||||
|
default: throw new ArgumentException($"Unknown argument {args[i]}.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (o.Item == 0) throw new ArgumentException("--item is required.");
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ExistingFile(string path)
|
||||||
|
{
|
||||||
|
string full = Path.GetFullPath(path);
|
||||||
|
if (!File.Exists(full)) throw new ArgumentException($"No file at {full}.");
|
||||||
|
return full;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Command-line Steam Workshop updater for RimWorld mods. It uses the Steamworks.NET build and the
|
||||||
|
steam_api64.dll that ship with RimWorld 1.7, and attaches to the running Steam client as app 294100.
|
||||||
|
Run it through Tools\workshop-upload.ps1.
|
||||||
|
-->
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<Nullable>disable</Nullable>
|
||||||
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
|
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||||
|
<RimWorldDir Condition="'$(RimWorldDir)' == ''">E:\SteamLibrary\steamapps\common\RimWorld</RimWorldDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="com.rlabrecque.steamworks.net">
|
||||||
|
<HintPath>$(RimWorldDir)\com.rlabrecque.steamworks.net.dll</HintPath>
|
||||||
|
<Private>true</Private>
|
||||||
|
</Reference>
|
||||||
|
<None Include="$(RimWorldDir)\steam_api64.dll" Link="steam_api64.dll" CopyToOutputDirectory="PreserveNewest" Visible="false" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!-- SteamAPI.Init reads the app id from steam_appid.txt in the working directory. -->
|
||||||
|
<Target Name="WriteSteamAppId" AfterTargets="Build">
|
||||||
|
<WriteLinesToFile File="$(OutDir)steam_appid.txt" Lines="294100" Overwrite="true" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
</Project>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
1.0.0
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
<#
|
||||||
|
Updates the Steam Workshop item from the command line, through the running Steam client: no password,
|
||||||
|
no game window, no dev mode. RimWorld may stay open.
|
||||||
|
|
||||||
|
.\Tools\workshop-upload.ps1 dry run: builds, stages a clean copy, checks the item and
|
||||||
|
that this Steam account owns it. Uploads nothing.
|
||||||
|
.\Tools\workshop-upload.ps1 -Publish uploads the staged copy. The change note is the CHANGELOG.md
|
||||||
|
entry for the version in About.xml.
|
||||||
|
-DescriptionFile docs\workshop-description.txt also replaces the Workshop description (BBCode)
|
||||||
|
|
||||||
|
-Publish refuses unless the shipped files are committed and pushed, the top CHANGELOG.md entry matches
|
||||||
|
About.xml's modVersion, and the last Tests\run-tests.ps1 run passed after the last build.
|
||||||
|
-SkipChecks skips those checks. The in-game button (Tools\workshop-stage.ps1) still works as a fallback.
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[string]$RimWorldDir = 'E:\SteamLibrary\steamapps\common\RimWorld',
|
||||||
|
[switch]$Publish,
|
||||||
|
[string]$DescriptionFile,
|
||||||
|
[string]$TestResults = (Join-Path $env:TEMP 'BlaxSlavesTest\BlaxSlavesTestResults.txt'),
|
||||||
|
[switch]$SkipChecks
|
||||||
|
)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$repo = Split-Path -Parent $PSScriptRoot
|
||||||
|
$ship = 'About', '1.7', 'Defs', 'Patches', 'Languages', 'Textures', 'Sounds'
|
||||||
|
$toolProj = Join-Path $PSScriptRoot 'WorkshopUpload\WorkshopUpload.csproj'
|
||||||
|
$toolExe = Join-Path $PSScriptRoot 'WorkshopUpload\bin\Release\WorkshopUpload.exe'
|
||||||
|
|
||||||
|
$itemId = (Get-Content -LiteralPath (Join-Path $repo 'About\PublishedFileId.txt') -Raw).Trim()
|
||||||
|
$about = [xml](Get-Content -LiteralPath (Join-Path $repo 'About\About.xml') -Raw -Encoding UTF8)
|
||||||
|
$packageId = $about.ModMetaData.packageId.Trim()
|
||||||
|
$modVersion = "$($about.ModMetaData.modVersion)".Trim()
|
||||||
|
# Same tags the in-game uploader sets: "Mod" plus Major.Minor of every supported version.
|
||||||
|
$tags = @('Mod') + @($about.ModMetaData.supportedVersions.li | ForEach-Object { $v = [version]"$_".Trim(); "$($v.Major).$($v.Minor)" })
|
||||||
|
|
||||||
|
# Change note: every CHANGELOG.md entry newer than the last version published from here
|
||||||
|
# (Tools\workshop-published.txt, written after each successful -Publish).
|
||||||
|
$publishedFile = Join-Path $PSScriptRoot 'workshop-published.txt'
|
||||||
|
$lastPublished = if (Test-Path $publishedFile) { [version](Get-Content -LiteralPath $publishedFile -Raw).Trim() } else { [version]'0.0' }
|
||||||
|
$sections = [ordered]@{}
|
||||||
|
$current = $null
|
||||||
|
foreach ($line in Get-Content -LiteralPath (Join-Path $repo 'CHANGELOG.md') -Encoding UTF8) {
|
||||||
|
if ($line -match '^##\s+(.+)$') { $current = $Matches[1].Trim(); $sections[$current] = New-Object System.Collections.ArrayList; continue }
|
||||||
|
if ($current -and $line.Trim()) { [void]$sections[$current].Add($line.TrimEnd()) }
|
||||||
|
}
|
||||||
|
if ($sections.Count -eq 0) { throw 'CHANGELOG.md has no "## <version>" entry.' }
|
||||||
|
$topVersion = @($sections.Keys)[0]
|
||||||
|
$noteLines = @()
|
||||||
|
foreach ($v in $sections.Keys) {
|
||||||
|
if ([version]$v -le $lastPublished) { break }
|
||||||
|
if ($noteLines) { $noteLines += '' }
|
||||||
|
$noteLines += @("$($about.ModMetaData.name) $v") + $sections[$v]
|
||||||
|
}
|
||||||
|
if (-not $noteLines) { $noteLines = @("$($about.ModMetaData.name) $topVersion") + $sections[$topVersion] }
|
||||||
|
$note = ($noteLines -join "`n").Trim()
|
||||||
|
|
||||||
|
foreach ($proj in Get-ChildItem (Join-Path $repo 'Source\*\*.csproj')) {
|
||||||
|
& dotnet build $proj.FullName -c Release -nologo -v q "-p:RimWorldDir=$RimWorldDir"
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw "build failed: $($proj.Name)" }
|
||||||
|
}
|
||||||
|
& dotnet build $toolProj -c Release -nologo -v q "-p:RimWorldDir=$RimWorldDir"
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw 'build failed: WorkshopUpload' }
|
||||||
|
|
||||||
|
if ($Publish -and -not $SkipChecks) {
|
||||||
|
$problems = @()
|
||||||
|
if ($topVersion -ne $modVersion) { $problems += "CHANGELOG.md's top entry is $topVersion, About.xml says $modVersion." }
|
||||||
|
$dirty = & git -C $repo status --porcelain -- $ship
|
||||||
|
if ($dirty) { $problems += "Uncommitted changes in shipped files:`n$($dirty -join "`n")" }
|
||||||
|
$ahead = & git -C $repo rev-list --count '@{u}..HEAD' 2>$null
|
||||||
|
if ($LASTEXITCODE -ne 0) { $problems += 'The branch has no upstream to compare with.' }
|
||||||
|
elseif ([int]$ahead -gt 0) { $problems += "$ahead commit(s) not pushed yet, so the Workshop would ship code the repo doesn't show." }
|
||||||
|
$dll = Get-ChildItem (Join-Path $repo '1.7\Assemblies\*.dll') | Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
||||||
|
if (-not (Test-Path $TestResults)) { $problems += "No test results at $TestResults. Run .\Tests\run-tests.ps1 first." }
|
||||||
|
else {
|
||||||
|
$res = Get-Item $TestResults
|
||||||
|
$lines = Get-Content -LiteralPath $TestResults -Encoding UTF8
|
||||||
|
if (-not ($lines -match '^END$') -or ($lines -match '^FAIL ')) { $problems += 'The last test run failed or did not finish.' }
|
||||||
|
elseif ($dll -and $res.LastWriteTime -lt $dll.LastWriteTime) { $problems += "The last test run ($($res.LastWriteTime)) is older than the build ($($dll.LastWriteTime)). Run .\Tests\run-tests.ps1 again." }
|
||||||
|
}
|
||||||
|
if ($problems) { throw ("Not publishing:`n- " + ($problems -join "`n- ")) }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean copy outside the repo: only what players need, no PDBs. TEMP has no spaces in its path.
|
||||||
|
$root = Join-Path $env:TEMP 'BlaxWorkshopUpload'
|
||||||
|
$stage = Join-Path $root $packageId
|
||||||
|
if (Test-Path $stage) { Remove-Item $stage -Recurse -Force }
|
||||||
|
New-Item -ItemType Directory $stage -Force | Out-Null
|
||||||
|
foreach ($name in $ship) {
|
||||||
|
$src = Join-Path $repo $name
|
||||||
|
if (Test-Path $src) { Copy-Item $src (Join-Path $stage $name) -Recurse }
|
||||||
|
}
|
||||||
|
Get-ChildItem $stage -Recurse -File -Filter *.pdb | Remove-Item
|
||||||
|
$noteFile = Join-Path $root "$packageId.note.txt"
|
||||||
|
[IO.File]::WriteAllText($noteFile, $note, (New-Object Text.UTF8Encoding $false))
|
||||||
|
|
||||||
|
$toolArgs = @('--item', $itemId, '--content', $stage, '--note-file', $noteFile, '--tags', ($tags -join ','))
|
||||||
|
if ($DescriptionFile) { $toolArgs += @('--description-file', (Resolve-Path $DescriptionFile).Path) }
|
||||||
|
if ($Publish) { $toolArgs += '--publish' }
|
||||||
|
|
||||||
|
# steam_api writes status lines to stderr; under 'Stop' PowerShell 5.1 would turn them into errors.
|
||||||
|
$ErrorActionPreference = 'Continue'
|
||||||
|
Push-Location (Split-Path $toolExe)
|
||||||
|
try {
|
||||||
|
& $toolExe @toolArgs 2>&1 | ForEach-Object { "$_" } | Where-Object { $_ -notmatch '^(Setting breakpad|SteamInternal_)' }
|
||||||
|
$code = $LASTEXITCODE
|
||||||
|
}
|
||||||
|
finally { Pop-Location }
|
||||||
|
if ($Publish -and $code -eq 0) {
|
||||||
|
[IO.File]::WriteAllText($publishedFile, "$topVersion`n")
|
||||||
|
Write-Host "Recorded $topVersion in Tools\workshop-published.txt. Commit it."
|
||||||
|
}
|
||||||
|
exit $code
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
Slavery as an everyday part of the rim. Needs [url=https://steamcommunity.com/sharedfiles/filedetails/?id=2009463077]Harmony[/url], and Ideology for slaves. RimWorld 1.7.
|
||||||
|
|
||||||
|
[h2]Trade[/h2]
|
||||||
|
[list]
|
||||||
|
[*][b]Buy as slave or colonist.[/b] In the trade window, click "Joins as slave / Joins as colonist" on a pawn the trader sells. The price updates (a slave costs 60% of a colonist, as in vanilla). A setting picks what new stock starts as: the vanilla roll, always slave or always colonist.
|
||||||
|
[*][b]Every trader buys captives,[/b] visitor groups and the Empire's caravans included. Optionally, factions whose ideoligion rejects slavery refuse, except to ransom their own people.
|
||||||
|
[*][b]Price sliders[/b] for buying slaves and selling captives (vanilla 60% each), capped so buy-low-sell-high doesn't pay.
|
||||||
|
[*][b]Slavers are common.[/b] Slaver caravans and orbital slave ships show up twice as often, bring more slaves and keep coming when your colony grows. Other caravans and orbital traders may have a slave or two, and settlements keep selling slaves however big your colony is.
|
||||||
|
[*][b]Request a slaver caravan[/b] from allied outlanders and tribes at the comms console. Vanilla hides slavers from that list.
|
||||||
|
[/list]
|
||||||
|
|
||||||
|
[h2]Slaves[/h2]
|
||||||
|
[list]
|
||||||
|
[*][b]Branding.[/b] A surgery burns your colony's mark into a slave. Branded slaves lose suppression 15% slower. Rebrand a slave who carries another owner's mark.
|
||||||
|
[*][b]Trader slaves come branded.[/b] About a third of the slaves you buy carry a previous owner's brand.
|
||||||
|
[*][b]Branded runaways come back.[/b] A non-hostile faction that finds one returns them after 3 to 10 days. Hostile factions keep them.
|
||||||
|
[*][b]Harming slaves doesn't upset colonists.[/b] Executing, harvesting, selling, banishing or butchering a slave gives free colonists no bad thoughts. Kind pawns and pacifists still mind, and family still grieves.
|
||||||
|
[*][b]Time as a slave[/b] in the Records tab and the slave tab.
|
||||||
|
[/list]
|
||||||
|
|
||||||
|
Every feature has its own switch or number in the mod settings.
|
||||||
|
|
||||||
|
[h2]Replaces[/h2]
|
||||||
|
Blax Slaves does what these mods do, so you can unsubscribe them. The Compat tab in the settings lists the ones you have active.
|
||||||
|
[list]
|
||||||
|
[*]Trade as Slave or Colonist (while it's active, Blax Slaves' own button stands down)
|
||||||
|
[*]Everybody Buys Slaves
|
||||||
|
[*][SYR] More Slaves (can stay: its extra slaves stack on top)
|
||||||
|
[/list]
|
||||||
|
|
||||||
|
[h2]Compatibility[/h2]
|
||||||
|
[list]
|
||||||
|
[*]War Crimes Expanded 2 torture and Harvest Organs Post Mortem autopsies count as slave harm.
|
||||||
|
[*]Hospitality visitor groups never keep a runaway who is due to be returned.
|
||||||
|
[*]Multiplayer: not supported.
|
||||||
|
[/list]
|
||||||
|
|
||||||
|
Load after Harmony. Source and issues: [url=https://forgejo.blax.at/blax-software/rimworld-blax-slaves]forgejo.blax.at/blax-software/rimworld-blax-slaves[/url]
|
||||||
Loading…
Reference in New Issue