Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
691 commits
Select commit Hold shift + click to select a range
5e9fa78
Merge branch 'beta' into feature/self-service
AMacro Jun 28, 2025
9782374
Change BlockInput to prevent disabling Manual Service
AMacro Jun 29, 2025
db1d634
Improve culling algorithm
AMacro Jun 29, 2025
8dce628
Implement a generic CullingManager
AMacro Jul 5, 2025
8d8b4b9
Refactor to use Culling Manager
AMacro Jul 7, 2025
7b16d21
Rework PluggableObject workflow
AMacro Jul 7, 2025
716de8d
General cleanup
AMacro Jul 7, 2025
9d2bbf6
Change to StartSnappingTo
AMacro Jul 7, 2025
2b3eb90
Update API documentation
AMacro Jul 13, 2025
e68bc34
Fix update localisation issue
AMacro Jul 13, 2025
2ff90c5
Fix compatibility with B99.6
AMacro Jul 18, 2025
683966b
Fix compatibility with B99.6
AMacro Jul 18, 2025
82eeae7
Ready for release 0.1.12.2
AMacro Jul 18, 2025
80d8f3f
Add API version support
AMacro Jul 19, 2025
ed43ffa
Refactor paint theme system to use uint theme IDs
AMacro Jul 19, 2025
06ee5dc
Fix compatibility with B99.6
AMacro Jul 20, 2025
3960533
Fix faucet positioning
AMacro Jul 29, 2025
8e0f140
Rework PaintThemeLookup
AMacro Jul 29, 2025
67f6d6b
Fix issue with clients clearing cash registers
AMacro Aug 10, 2025
821f6cc
Rework BulkUpdate processing
AMacro Aug 10, 2025
0503475
Fix issue with colliders being optimised out
AMacro Aug 10, 2025
a4ce3b3
Minor clean up of namespace
AMacro Aug 16, 2025
6955748
Refactor CashRegister*Patch
AMacro Aug 23, 2025
6947360
Block ReturnMoneyToPlayerCheck
AMacro Aug 23, 2025
c8a5910
Ignore shop cash registers
AMacro Aug 23, 2025
a9fa369
Add rejection types and fix logging
AMacro Aug 23, 2025
b1400de
Fix resource sync issues
AMacro Aug 23, 2025
d48d5a3
minor clean up
AMacro Aug 23, 2025
292a477
Ready for alpha testing
AMacro Aug 23, 2025
1014c0a
Merge branch 'feature/self-service' into alpha
AMacro Aug 23, 2025
06a9632
Refactor to use BinaryWriter/Reader and move base to MultiplayerAPI
AMacro Aug 23, 2025
3aea969
Expose registration of custom task serialiser and deserialiser
AMacro Aug 23, 2025
721c4a9
Add documentation for TaskNetworkData
AMacro Aug 24, 2025
0fb30e5
Add auto compression to ExternalSerializablePacketWrapper
AMacro Aug 29, 2025
2bf1638
fix possible null reference issues
AMacro Aug 29, 2025
3706c6e
Add ColorSerializer for Unity.Color
AMacro Aug 30, 2025
6e772f8
Add Vector3 and Quaternion serialisation and XML docs
AMacro Aug 30, 2025
4d2f902
Fix incorrect IsHost() in ServerPlayerWrapper
AMacro Aug 30, 2025
9fb28f3
Refactor use of player.Id and peer.id
AMacro Sep 2, 2025
49abc4c
Add PlayerId property to IClient and ClientAPIProvider
AMacro Sep 2, 2025
481facc
Move player connected event to post-authentication
AMacro Sep 6, 2025
3cf7cfd
Merge branch 'beta' into feature/Mod-API
AMacro Sep 6, 2025
a2d518a
Add periodic weather state updates to fix time drift
AMacro Sep 13, 2025
e8cf951
Add time limit and last task support to task sync
AMacro Sep 13, 2025
9e8aaf5
Ensure jobs are loaded prior to taking
AMacro Sep 13, 2025
0349dbe
Implement job task synchronisation
AMacro Sep 14, 2025
271c233
Reorder job time updates in job sync loop
AMacro Sep 14, 2025
7fa28e6
Sync JobManager time in save game data packets
AMacro Sep 14, 2025
894d565
Refactor warehouse machine and cargo state sync
AMacro Sep 14, 2025
6ee1a68
Remove unused GetFromWarehouseMachineController method
AMacro Sep 14, 2025
b05bfea
Add compatibility status for three new mods
AMacro Sep 14, 2025
5806f25
Refactor warehouse machine lookup in cargo state handler
AMacro Sep 14, 2025
8f6ae04
Add mod-controlled ready-block system to client
AMacro Oct 12, 2025
ec5a293
Refactor task networking to use NetworkedTask
AMacro Oct 12, 2025
e42d201
Add WarehouseMachineLookup for improved net ID handling
AMacro Oct 12, 2025
45c5b68
Fix password check in server browser
AMacro Oct 24, 2025
19f8284
Stop sync of TrainCar rotation while railed
AMacro Oct 24, 2025
3c67383
Refactor for future dedicated server
AMacro Oct 24, 2025
bf50aa6
Add excludeSelf option to packet broadcast methods
AMacro Oct 25, 2025
808a9af
Code cleanup and doc improvements
AMacro Oct 25, 2025
b5c5e02
Improve job validation response waiting logic
AMacro Oct 25, 2025
7eaa8da
Update mod compatibility and patch WarehouseMachineController
AMacro Nov 7, 2025
9a164eb
Refactor task network data registration and conversion
AMacro Nov 8, 2025
f045b7a
Improve XML documentation for API interfaces
AMacro Nov 8, 2025
2122c06
Add Car support to NetIdProvider and NetworkedTrainCar
AMacro Nov 8, 2025
d6eabd7
Add script to convert docs for GitHub Wiki
AMacro Nov 8, 2025
f7333d2
Add debug patch checking and bump version to 0.1.12.9
AMacro Nov 9, 2025
9659a22
Merge branch 'feature/Mod-API' into alpha
AMacro Nov 9, 2025
f82239e
Refactor player identification to use PlayerId property
AMacro Nov 9, 2025
a44b1f8
Refactor Fnv1aHash to StringHashing utility class
AMacro Nov 15, 2025
9f1ad26
Add CargoTypeLookup for networked cargo type mapping
AMacro Nov 15, 2025
f42fca9
Refactor cargo type serialization to use net IDs
AMacro Nov 15, 2025
50c3c71
Add support for uint NetId in network API
AMacro Nov 15, 2025
1ad188c
Delay job manager time load until logic controller init
AMacro Nov 15, 2025
bd33346
Fix player rotation handling on vehicles for VR players
AMacro Nov 22, 2025
3cb0590
Fix edge case where car is unintentionally deleted
AMacro Nov 22, 2025
9fd3cc5
Replace GrabHandlerGizmoItem with CustomNonVrGrabAnchor
AMacro Nov 22, 2025
c248555
Add null check in TryGetNetId for CargoType_v2
AMacro Nov 22, 2025
e4af9cb
Skip item anchor offset capture in VR mode
AMacro Nov 22, 2025
6d1db35
Fix issue where pitstop can not be initialised on clients
AMacro Nov 22, 2025
7bc6588
Initialise itemAnchorOffset with default values
AMacro Nov 22, 2025
6a18733
Fix issues with NetworkedPitStopStation in VR
AMacro Nov 22, 2025
7a844fd
Refactor train coal/firebox networking
AMacro Nov 22, 2025
4e7272f
Comment out debug logging in networking and patch files
AMacro Nov 22, 2025
c384f63
Refactor train port and fuse IDs to use uint
AMacro Nov 22, 2025
dc70e3b
Refactor task state update logic to reduce spamming
AMacro Nov 23, 2025
8d27565
Add train control authority request and update system
AMacro Nov 23, 2025
310c4c1
Refactor PaintTheme registration and lookup API
AMacro Nov 29, 2025
7f4f5c8
Improve cargo type registration and logging
AMacro Nov 29, 2025
eaab4cf
Fix VR check logic in item anchor offset capture
AMacro Nov 29, 2025
b33b76b
Add paint theme change validation and syncing
AMacro Nov 29, 2025
1845650
Refactor pit stop interaction packet type to enum
AMacro Nov 29, 2025
23d3c6d
Add mod compatibility and silence cargo type log
AMacro Nov 29, 2025
1b44a8e
Add compatibility for dv_f_spammer mod
AMacro Nov 29, 2025
6b5b4ea
Update to Multiplayer API v1.0.0.0 and mod version 0.1.13.0
AMacro Nov 29, 2025
17033f3
Update .gitattributes for line ending normalization
AMacro Nov 30, 2025
e6fa62f
Add sync for generic switches
AMacro Dec 7, 2025
791ff7e
Optimise TrainCar position updates
AMacro Dec 9, 2025
e49c8e4
Fix issue with cut-out not syncing after repair
AMacro Dec 18, 2025
5a590e7
Additional null checks
AMacro Dec 18, 2025
3788166
Fix pointset traveller spam
AMacro Dec 18, 2025
7fe0529
Fix issues with cash register stealing cash
AMacro Dec 18, 2025
2daa053
Refactor pit stop station networking and add tick to packets
AMacro Dec 18, 2025
293fa60
Ensure player objects are cleaned up
AMacro Dec 18, 2025
3f56920
Ready for release 0.1.13.4
AMacro Dec 18, 2025
5a9d440
Enhance mod requirements in server browser UI
AMacro Dec 24, 2025
345416b
Update build version check to use MenuProvider
AMacro Dec 24, 2025
a7d9d7a
Refactor LobbyServerData 'required mods' to use ModInfo[] instead of …
AMacro Jan 1, 2026
aeccba0
Improve lobby data handling for ModInfo
AMacro Jan 4, 2026
0911be5
Change handling of incompatible mods in compatibility manager
AMacro Jan 4, 2026
0596db9
Publicise `DV.UIFramework.CollapsibleElement`
AMacro Jan 4, 2026
ba46faf
Use collapsible elements for mod details
AMacro Jan 4, 2026
e5775ed
Refactor server details and mods UI in ServerBrowserPane
AMacro Jan 4, 2026
604be52
Improve localisation for server browser and disconnect reasons
AMacro Jan 8, 2026
4bba744
Remove duplicate host details label in server info
AMacro Jan 8, 2026
3a80a19
Fix issue preventing player markers from being hidden
AMacro Jan 8, 2026
0a9bbbf
Ready for release 0.1.13.5
AMacro Jan 8, 2026
06c5110
Remove over the top logging
AMacro Jan 10, 2026
a500a72
Increase max players from 10 to 20
AMacro Feb 28, 2026
5c76d5f
Fix job overview despawn on clients
AMacro Jan 17, 2026
cb55c3c
Add option to show player list in Alt Mouse Mode
AMacro Jan 22, 2026
e7a689e
Fix translation keys in locale.csv
AMacro Jan 23, 2026
1374d87
Fixed issues breaking Mapify
AMacro Jan 26, 2026
c015027
Add new method for detecting scene unloading
AMacro Jan 26, 2026
2396d6e
Refactor job item destruction logic
AMacro Jan 26, 2026
60fa43a
Add detailed logging to client connection process
AMacro Jan 26, 2026
dc68394
Fix host pausing when opening menu and changing windows
AMacro Feb 3, 2026
48e2041
Disable Teleport and Escape while chat open
AMacro Feb 3, 2026
57df99f
Add client compatibility for MessageBox and BetterModUI
AMacro Feb 28, 2026
01894f1
Add ability to hide chat messages from UI
AMacro Mar 7, 2026
7419a25
Fix brake hose disconnecting during high lag
AMacro Mar 7, 2026
14be370
Ready for release 0.1.13.12
AMacro Mar 7, 2026
c8ec7ea
Update README with detailed build and installation instructions
AMacro Mar 8, 2026
30621cf
Revise building instructions with numbered steps
AMacro Mar 8, 2026
2af0ed8
Fix bug where UI coupling can cause desyncs
AMacro Mar 15, 2026
3b891a2
Enable client car spawning
AMacro Jan 10, 2026
5d18c42
Add RPC response system
AMacro Feb 15, 2026
880ef1b
Initial commit for Work Train Functionality
AMacro Feb 14, 2026
1f1058f
Increase CommsRadio RPC timeouts and update text rendering
AMacro Mar 2, 2026
5ca8301
Organise networking data into subnamespaces
AMacro Mar 1, 2026
053a5bb
Start work on player inventory sync
AMacro Mar 15, 2026
1a906c2
Change WorkTrain RPC timeout to use Client.RPC_TImeout
AMacro Mar 15, 2026
5ff8ff5
Ready for pre-release testing
AMacro Mar 15, 2026
38f6cf2
Add an initial charge to the flashlight
AMacro Mar 16, 2026
dce1f51
Additional null checks for NetworkedTrainCar.WaitForInterior()
AMacro Mar 21, 2026
af06434
Initialize lastRemoteValueDict before SetUnits
AMacro Mar 21, 2026
ae8a9cd
Improve logging of SendHoseConnected() failures
AMacro Mar 21, 2026
0c097c5
Feature crewnames (#129)
AMacro Mar 22, 2026
e9beb3d
Reorganise packet subscriptions in NetworkServer
AMacro Jan 10, 2026
39280ce
Enable client car spawning
AMacro Jan 10, 2026
f1a0698
Fix job overview despawn on clients
AMacro Jan 17, 2026
a72aa26
Refactor job item destruction logic
AMacro Jan 26, 2026
8c6772a
Initial commit for Work Train Functionality
AMacro Feb 14, 2026
41fabc5
Refactored sync process for players joining the server
AMacro Mar 2, 2026
97b3e3b
Add debug save export and tidy settings
AMacro Mar 14, 2026
d5187c6
Improve debug logging for IdMonoBehaviours
AMacro Mar 22, 2026
78393c2
Filter outgoing packets by player loading state
AMacro Mar 22, 2026
6efc3fe
Remove playerSpawned param from SendSpawnTrainset
AMacro Mar 22, 2026
58829f7
Change NetworkedStationController netId Generation to use hashes
AMacro Mar 22, 2026
7e3328c
Reorganise client packet subscriptions
AMacro Mar 22, 2026
8a1aadb
Improve client loading progress and timing
AMacro Mar 22, 2026
3fb0ea2
Skip loco restoration popup when player is far from loco
AMacro Mar 28, 2026
2d0ee24
Add transportCars sync for Demonstrators
AMacro Mar 29, 2026
0d783a6
Fix deposited cash check and null-safe player list
AMacro Apr 4, 2026
7f82495
Add sync for restoration parts purchased
AMacro Apr 4, 2026
613818c
Complete loco restoration sync
AMacro Apr 5, 2026
3496417
Send generic switch states on player join
AMacro Apr 5, 2026
2f6b9e0
Add null check in SendHoseConnected
AMacro Apr 12, 2026
c459a56
Add a debug mode to export savegame data at load
AMacro Apr 12, 2026
a87abe2
Fix issues with MU Jank
AMacro Apr 12, 2026
0c56f52
Fix issues with control jank with multiple players in the cab
AMacro Apr 18, 2026
3f48702
Make player list position configurable
AMacro Apr 18, 2026
57c03aa
Ready for Pre-release testing
AMacro Apr 18, 2026
c1379a3
Clean up incorrect logging
AMacro Apr 25, 2026
92e431f
Harden NetworkedTrainCar.Start()
AMacro Apr 25, 2026
2cdbaa2
Add null checks for cleanup handlers
AMacro Apr 25, 2026
3afc388
Improve logging
AMacro Apr 25, 2026
7f0dc4c
Attempt to fix a bug where a newly added playerId clashes with an exi…
AMacro Apr 25, 2026
81e48e3
Add client car spawning, demonstrator sync and fix control jank (#131)
AMacro Apr 25, 2026
16e4b17
Ready for release 0.1.14.0
AMacro Apr 25, 2026
c8d90fb
Merge branch 'beta' into alpha
AMacro May 21, 2026
525ef20
Prevent multiple NetworkedJunctions from being added
AMacro May 31, 2026
5e04a4d
Merge branch 'beta' into alpha
AMacro May 31, 2026
f25152b
mostly working
T3M8029 Jun 27, 2026
38f7c4f
Fix possible race conditions on jobs updating
T3M8029 Jun 29, 2026
bc05977
primitive fix for tc state desync after spawn
T3M8029 Jul 2, 2026
eb06f0b
Ignore non-MP-mod Steam lobby requests
AMacro Jul 5, 2026
0174933
Optimise NetworkedItem lookup cache access
AMacro Jul 12, 2026
1e89018
Tidy networked item caching
AMacro Jul 12, 2026
3a48561
Fix world network component init timing
AMacro Jul 12, 2026
d1b29e8
Allow hosts to disable time advance during fast travel
AMacro Jul 12, 2026
99b378d
Add Linux/macOS post-build script support
AMacro Jul 12, 2026
009b0ac
Block 'Fast Travel with Loco'
AMacro Jul 12, 2026
615ef5a
Disable load button during multiplayer session
AMacro Jul 12, 2026
bfb6194
Fix previous commit
AMacro Jul 12, 2026
8ae76fe
Disable spammy logs
AMacro Jul 12, 2026
2a6470e
Squashed commit of the following:
AMacro Jul 12, 2026
1e83031
Ready for release
AMacro Jul 12, 2026
78f5d5c
Hanlde jobs on client via JobsManager (for RD compatibility) + additi…
T3M8029 Jul 13, 2026
f6cc385
Merge branch 'beta' into PersistentJobsCompat
T3M8029 Jul 13, 2026
3d4ce6d
Improve tracking of players on TrainCars
AMacro Jul 18, 2026
27414fb
Rework Work Train in use checks
AMacro Jul 18, 2026
28c4697
Add player inventory & right-hand item handling
AMacro May 31, 2026
e08b50b
Rework Work Train In Use Checks (#151)
AMacro Jul 19, 2026
6228b9d
Increase pluggable object insertion distance
AMacro Jul 19, 2026
e42b6bb
Merge branch 'beta' into alpha
AMacro Jul 19, 2026
bcc9e55
Fix Clients Unable to Refuel At Service Station (#152)
AMacro Jul 19, 2026
3199b93
Use built-in text input popup
AMacro Jul 19, 2026
e72d2e3
Fix Password Prompt Not Showing Keyboard in VR (#153)
AMacro Jul 19, 2026
4c0add2
Merge branch 'beta' into alpha
AMacro Jul 19, 2026
a150a23
Refactor job validaton
AMacro Jul 19, 2026
1d97204
Merge pull request #154 from AMacro/alpha
AMacro Jul 19, 2026
0cf1db3
Throttle high ping warnings per player
AMacro Jul 19, 2026
996856e
Ready for release
AMacro Jul 19, 2026
9af943f
Merge branch 'AMacro:beta' into PersistentJobsCompat
T3M8029 Jul 21, 2026
aed7a42
Fix car ordering getting out of sync
T3M8029 Jul 22, 2026
bf6e597
Handle null spawn result in loco spawner
AMacro Jul 25, 2026
2274fe3
Fix car visit countdown reset logic
AMacro Jul 26, 2026
3c4a880
Merge pull request #159 from AMacro/fix/CarVisitChecker-Counter-Reset
AMacro Jul 26, 2026
1984214
Merge pull request #158 from AMacro/fix/157-SpawnLocomotives-Null-Exc…
AMacro Jul 26, 2026
771bf72
Ready for release
AMacro Jul 26, 2026
3a73227
Merge branch 'AMacro:beta' into PersistentJobsCompat
T3M8029 Jul 26, 2026
2e834b3
Translated more terms to French
Harfeur Jul 28, 2026
e928ec3
Improve compatibility with SkinManager
AMacro Aug 9, 2026
9dd92e9
Merge pull request #161 from Harfeur/beta
AMacro Aug 9, 2026
5a62733
Fix keybinds active while chat is open
AMacro Aug 10, 2026
f79952c
Merge branch 'beta' into PersistentJobsCompat
AMacro Aug 12, 2026
4f45e97
Refactor Persistent Jobs integration
AMacro Aug 13, 2026
8cec414
Fix unload cleanup for networked objects
AMacro Aug 16, 2026
1227b82
Fix attempts to add NetworkedRailTracks
AMacro Aug 17, 2026
cf35504
Add wind physics controller for player models
AMacro Aug 22, 2026
c232797
Add distance culling for networked players
AMacro Aug 22, 2026
fa1512c
Harden unload-time cleanup
AMacro Aug 22, 2026
c8be3ea
Fix WorkTrain issues and add in-use reasons
AMacro Aug 23, 2026
fb2dd9d
Prevent hoses from disconnecting in a de-sync
AMacro Aug 23, 2026
e4c4c72
Remove unnecessary debug logging
AMacro Aug 29, 2026
e5b6bdf
Add hard sync correction for de-syncs
AMacro Aug 30, 2026
72a837d
Add logging to help track down coupler state sync issues
AMacro Aug 30, 2026
f7f4bdb
Allow Derailed Work Trains To Be Summoned
AMacro Aug 30, 2026
16b66fd
Pass movementPart by readonly reference
AMacro Aug 30, 2026
354bcac
Harden Steam lobby join and invite flow
AMacro Aug 30, 2026
ebaaf7f
Ready for release
AMacro Aug 31, 2026
df752c5
Merge branch 'AMacro:beta' into PersistentJobsCompat
T3M8029 Sep 2, 2026
f2faf62
Align code with project's styling
AMacro Sep 6, 2026
dd35a82
Merge branch 'PersistentJobsCompat' of https://github.com/T3M8029/dv-…
AMacro Sep 6, 2026
3797883
Allow Multiplayer to load before RemoteDispatch
AMacro Sep 6, 2026
01c63d0
Merge pull request #149 from T3M8029/PersistentJobsCompat
AMacro Sep 12, 2026
3784068
Adjust player culling for external camera
AMacro Sep 12, 2026
d142f90
Ready for release
AMacro Sep 13, 2026
1a5aeae
Update releases.json
AMacro Sep 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 9 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
* text=auto eol=lf
# Set default behavior to automatically normalize line endings
* text=auto

# Force CRLF line endings for C# files
*.cs text eol=crlf

# Force CRLF for other common Windows development files (optional)
*.csproj text eol=crlf
*.sln text eol=crlf
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,6 @@ MultiplayerAssets/ProjectSettings/*
!MultiplayerAssets/ProjectSettings/ProjectVersion.txt
# Packages
!MultiplayerAssets/Packages
/Lobby Servers/Rust Server/target
*.pem
/docs
348 changes: 348 additions & 0 deletions Convert-ToGitHubWiki.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,348 @@
param(
[Parameter(Mandatory=$false)]
[string]$InputPath = ".",

[Parameter(Mandatory=$false)]
[string]$OutputPath = "./wiki-output",

[Parameter(Mandatory=$false)]
[switch]$Flatten,

[Parameter(Mandatory=$false)]
[switch]$InPlace
)

<#
.SYNOPSIS
Converts XMLDoc2Markdown output to GitHub Wiki compatible format.

.DESCRIPTION
This script processes markdown files generated by XMLDoc2Markdown and converts them
to be compatible with GitHub Wiki by:
- Removing .md extensions from links
- Removing ./ prefixes from links
- Optionally flattening all files into a single markdown file
- Optionally modifying files in place

.NOTES
Created with assistance from GitHub Copilot

.PARAMETER InputPath
The path to the directory containing the markdown files. Default is current directory.

.PARAMETER OutputPath
The path where converted files will be saved. Default is ./wiki-output.
Ignored if -InPlace is used.

.PARAMETER Flatten
If specified, all markdown files will be combined into a single file.

.PARAMETER InPlace
If specified, modifies files in place instead of creating copies.

.EXAMPLE
.\Convert-ToGitHubWiki.ps1
Converts all markdown files in current directory to wiki-output folder.

.EXAMPLE
.\Convert-ToGitHubWiki.ps1 -InPlace
Modifies all markdown files in place.

.EXAMPLE
.\Convert-ToGitHubWiki.ps1 -Flatten -OutputPath "./wiki.md"
Combines all markdown files into a single wiki.md file.
#>

function Convert-MarkdownLinks {
param(
[string]$Content,
[bool]$UseAnchors = $false
)

if ($UseAnchors) {
# Convert relative links to anchor links for flattened output
# Match patterns like [Text](./path/file.md) or [Text](path/file.md)
$Content = [regex]::Replace($Content, '\[([^\]]+)\]\(\.?/?([^)]+?)(?:\.md)?\)', {
param($match)
$linkText = $match.Groups[1].Value
$linkPath = $match.Groups[2].Value

# Skip external links (http/https)
if ($linkPath -match '^https?://') {
return $match.Value
}

# Convert path to anchor
# Remove path separators and convert to lowercase
$anchor = $linkPath -replace '[/\\]', '-' -replace '[^a-zA-Z0-9\s-]', '' -replace '\s+', '-' -replace '-+', '-'
$anchor = $anchor.ToLower().Trim('-')

return "[$linkText](#$anchor)"
})
} else {
# For GitHub Wiki: Convert links to use only filename (no directory path)
# Match patterns like [Text](./path/to/file.md) or [Text](path/to/file.md#anchor)
$Content = [regex]::Replace($Content, '\[([^\]]+)\]\(\.?/?([^)#]+?)(?:\.md)?(#[^)]+)?\)', {
param($match)
$linkText = $match.Groups[1].Value
$linkPath = $match.Groups[2].Value
$anchor = $match.Groups[3].Value

# Skip external links (http/https)
if ($linkPath -match '^https?://') {
return $match.Value
}

# Extract just the filename from the path (remove directory)
$filename = Split-Path -Path $linkPath -Leaf

# Return with just filename and optional anchor
return "[$linkText]($filename$anchor)"
})
}

return $Content
}

function Get-MarkdownFiles {
param(
[string]$Path,
[string]$ExcludePath = $null,
[switch]$ExcludeIndex
)

$files = Get-ChildItem -Path $Path -Filter "*.md" -Recurse | Where-Object { $_.Name -ne "README.md" }

# Exclude index.md if requested (for flattened output which generates its own TOC)
if ($ExcludeIndex) {
$files = $files | Where-Object { $_.Name -ne "index.md" }
}

# Exclude files in the output directory
if ($ExcludePath) {
$excludeFullPath = (Resolve-Path -Path $ExcludePath -ErrorAction SilentlyContinue)
if ($excludeFullPath) {
$files = $files | Where-Object { !$_.FullName.StartsWith($excludeFullPath) }
}
}

return $files
}

function Flatten-ToSingleFile {
param(
[string]$InputPath,
[string]$OutputFile
)

Write-Host "Flattening markdown files into single document..." -ForegroundColor Cyan

# Get output directory to exclude it from processing
$outputDir = Split-Path -Path $OutputFile -Parent
if ($outputDir) {
$outputDir = Join-Path -Path $InputPath -ChildPath $outputDir
}

$files = Get-MarkdownFiles -Path $InputPath -ExcludePath $outputDir -ExcludeIndex | Sort-Object FullName

$combinedContent = @()

# Build mapping of file paths to their heading anchors (filename -> heading anchor)
$fileToAnchor = @{}

foreach ($file in $files) {
$relativePath = $file.FullName.Substring($InputPath.Length).TrimStart('\', '/')
$content = Get-Content -Path $file.FullName -Raw -Encoding UTF8

# Extract first heading
if ($content -match '^#\s+(.+)') {
$heading = $matches[1].Trim()
$anchor = $heading -replace '[^a-zA-Z0-9\s-]', '' -replace '\s+', '-' -replace '-+', '-'
$anchor = $anchor.ToLower().Trim('-')

# Store mapping: filename (without extension) -> anchor
$filename = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
$fileToAnchor[$filename.ToLower()] = $anchor

# Also store full relative path mapping (with forward slashes, no extension)
$pathWithoutExt = $relativePath -replace '\.md$', '' -replace '\\', '/'
$fileToAnchor[$pathWithoutExt.ToLower()] = $anchor
}
}

# Add table of contents header
$combinedContent += "## Table of Contents"
$combinedContent += ""

# Build hierarchical TOC based on namespace from files
$tocStructure = @{}

foreach ($file in $files) {
$relativePath = $file.FullName.Substring($InputPath.Length).TrimStart('\', '/')
$content = Get-Content -Path $file.FullName -Raw -Encoding UTF8

# Extract first heading and namespace
$heading = $null
$namespace = $null

if ($content -match '^#\s+(.+)') {
$heading = $matches[1].Trim()
}

if ($content -match 'Namespace:\s*([^\r\n]+)') {
$namespace = $matches[1].Trim()
}

if ($heading) {
$anchor = $heading -replace '[^a-zA-Z0-9\s-]', '' -replace '\s+', '-' -replace '-+', '-'
$anchor = $anchor.ToLower().Trim('-')

# Use namespace if available, otherwise use root
$category = if ($namespace) { $namespace } else { '_root' }

if (!$tocStructure.ContainsKey($category)) {
$tocStructure[$category] = @()
}
$tocStructure[$category] += @{ Heading = $heading; Anchor = $anchor }
}
}

# Output TOC with sections
$orderedCategories = $tocStructure.Keys | Sort-Object | Where-Object { $_ -ne '_root' }

# Root items first if any
if ($tocStructure.ContainsKey('_root')) {
foreach ($item in $tocStructure['_root']) {
$combinedContent += "- [$($item.Heading)](#$($item.Anchor))"
}
$combinedContent += ""
}

# Then categorized items
foreach ($category in $orderedCategories) {
$combinedContent += "### $category"
$combinedContent += ""
foreach ($item in $tocStructure[$category]) {
$combinedContent += "- [$($item.Heading)](#$($item.Anchor))"
}
$combinedContent += ""
}

$combinedContent += "---"
$combinedContent += "<br></br>"
$combinedContent += ""

# Add content from each file
foreach ($file in $files) {
$relativePath = $file.FullName.Substring($InputPath.Length).TrimStart('\', '/')
Write-Host " Processing: $relativePath"

$content = Get-Content -Path $file.FullName -Raw -Encoding UTF8

# Convert links by replacing each known path with its anchor
foreach ($path in $fileToAnchor.Keys) {
$anchor = $fileToAnchor[$path]
$escapedPath = [regex]::Escape($path)
# Replace links like [Text](path) with [Text](#anchor)
$content = $content -replace "\]\($escapedPath\)", "](#$anchor)"
# Also handle links with existing fragment anchors - preserve the fragment
# but this is tricky, so for now just do the simple case
}

# Add source file comment
$combinedContent += "<!-- Source: $relativePath -->"
$combinedContent += ""

# Add content
$combinedContent += $content.TrimEnd()
$combinedContent += ""
$combinedContent += "---"
$combinedContent += "<br></br>"
$combinedContent += ""
}

# Ensure output directory exists
if ($outputDir -and !(Test-Path -Path $outputDir)) {
New-Item -Path $outputDir -ItemType Directory -Force | Out-Null
}

# Write combined file
$combinedContent -join "`n" | Set-Content -Path $OutputFile -Encoding UTF8 -NoNewline

Write-Host "Created flattened file: $OutputFile" -ForegroundColor Green
Write-Host "Processed $($files.Count) files" -ForegroundColor Green
}

function Convert-Files {
param(
[string]$InputPath,
[string]$OutputPath,
[bool]$InPlace
)

Write-Host "Converting markdown files for GitHub Wiki..." -ForegroundColor Cyan

$files = Get-MarkdownFiles -Path $InputPath
$count = 0

foreach ($file in $files) {
$relativePath = $file.FullName.Substring($InputPath.Length).TrimStart('\', '/')
Write-Host " Processing: $relativePath"

$content = Get-Content -Path $file.FullName -Raw -Encoding UTF8
$convertedContent = Convert-MarkdownLinks -Content $content

if ($InPlace) {
$outputFile = $file.FullName
} else {
$outputFile = Join-Path -Path $OutputPath -ChildPath $relativePath
$outputDir = Split-Path -Path $outputFile -Parent

if (!(Test-Path -Path $outputDir)) {
New-Item -Path $outputDir -ItemType Directory -Force | Out-Null
}
}

$convertedContent | Set-Content -Path $outputFile -Encoding UTF8 -NoNewline
$count++
}

if ($InPlace) {
Write-Host "Modified $count files in place" -ForegroundColor Green
} else {
Write-Host "Converted $count files to: $OutputPath" -ForegroundColor Green
}
}

# Main execution
try {
# Resolve full path
$InputPath = Resolve-Path -Path $InputPath -ErrorAction Stop

if ($Flatten) {
# Determine output file path
if ($OutputPath -like "*.md") {
$flattenedFile = $OutputPath
} else {
$flattenedFile = Join-Path -Path $OutputPath -ChildPath "API-Documentation.md"
}

Flatten-ToSingleFile -InputPath $InputPath -OutputFile $flattenedFile
} else {
if ($InPlace) {
$confirmation = Read-Host "This will modify files in place. Continue? (y/n)"
if ($confirmation -ne 'y') {
Write-Host "Operation cancelled." -ForegroundColor Yellow
exit
}
}

Convert-Files -InputPath $InputPath -OutputPath $OutputPath -InPlace $InPlace
}

Write-Host "`nConversion complete!" -ForegroundColor Green

} catch {
Write-Host "Error: $_" -ForegroundColor Red
exit 1
}
25 changes: 25 additions & 0 deletions Directory.Build.targets.EXAMPLE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Update DvInstallDir and UnityInstallDir paths to your local install directories
Do not use trailing slashes

If using code signing:
Update SignToolPath to the directory of signtool.exe
Update Cert-Thumb to the thumbprint of your code signing certificate, otherwise leave blank

Save this updated file as 'Directory.Build.targets'

-->
<Project>
<PropertyGroup>
<DvInstallDir>C:\Program Files (x86)\Steam\steamapps\common\Derail Valley</DvInstallDir>
<UnityInstallDir>C:\Program Files\Unity\Hub\Editor\2019.4.40f1\Editor</UnityInstallDir>
<ReferencePath>
$(DvInstallDir)\DerailValley_Data\Managed\;
$(DvInstallDir)\DerailValley_Data\Managed\UnityModManager\;
$(UnityInstallDir)\Data\Managed\
</ReferencePath>
<AssemblySearchPaths>$(AssemblySearchPaths);$(ReferencePath);</AssemblySearchPaths>
<SignToolPath>C:\Program Files (x86)\Microsoft SDKs\ClickOnce\SignTool\</SignToolPath>
<Cert-Thumb>7cf2b8a98a09ffd407ada2e94f200af24a0e68bc</Cert-Thumb>
</PropertyGroup>
</Project>
Loading