Partition

A Partition is a LuteMod song that can be played in Mordhau, created by LuteBot

Your partitions are located at `%localappdata%\Mordhau\Saved\SaveGames`

###### Sharing

These partitions can be distributed to others if necessary, but they cannot be edited or converted back to a MIDI

It is encouraged to instead share the MIDI file with Track Filtering saved into it (and also share the MIDI to the Guild Library, so that anyone can use it)

But it can sometimes be useful to share your entire playlist at once, without having someone load and save their partitions one by one

1. Open the SaveGames folder; there is a button to do this in the '`LuteMod Partitions`' menu of LuteMod, labeled '`Open Sav Folder`', or navigate to `%localappdata%\Mordhau\Saved\SaveGames`
2. Select all files in this folder, and zip them, using your favorite application, or
	* In Windows, Ctrl+A to select all, right click one of them, mouse over '`Send To...`', and choose '`Compressed (zipped) Folder`'
3. Share the zipped file, along with a link to the import instructions

###### Import

You must install LuteMod and Initialize it prior to importing partitions. You will also need LuteBot

1. Extract the zip file to a new folder
2. Run LuteBot as administrator (not always necessary, but should avoid problems)
3. If it isn't already, open the '`Lutemod Partitions`' menu at the top of the LuteBot window
4. Select the '`Import Partitions`' button
5. Navigate to the folder where you extracted the zip file
6. Select all files and confirm

Note that you will not be able to edit any settings on these files, retrieve the MIDI to edit it, or play the songs in LuteBot. You should ask for the MIDI files instead, which if saved with LuteBot, should contain all the correct settings

### Implementation

Each partition is made up of a variable amount of .sav files depending on the number of notes it contains, named `Partition_Name[0].sav`, `Partition_Name[1].sav`, etc.

These partitions are created by wrapping specifically-sized chunks of data in Mordhau sav files, and padding if necessary to preserve the save file's size, which must match the size that is encoded in the binary data for the save file it was based on(approx 7kb)

* Note that the length of the file reported in something like Notepad++ is a length in UTF characters, not bytes - so the reported length is incorrect, and some sav files may appear to have longer or shorter lengths according to Notepad++
* With this in mind, it is advised to never edit .sav files 'by hand'. If you keep the 'length' the same, it might work sometimes, but isn't reliable
* If edited incorrectly (and sometimes even when edited correctly), may cause the Corrupt Partition Bug

This is why LuteMod requires Initialization: Each user's PC may generate slightly different sav files depending on their hardware, and so their Mordhau must create the one we use as a template for adding partitions, because UE might reject one created on a different system (source?)

The partitions contain a list of `tick;note;track` for each note in the source MIDI whose channel was enabled in LuteBot's Track Filtering, and a tempo at the beginning, padded with `@` symbols to maintain sav file size, and `|` as borders between notes

The track is used for LuteBot Instrument data

* As of LuteBot 3.2.10, each LuteBot Instrument's settings are saved into the track corresponding with their index in the Instruments list, so that Mordhau Lute is in track 0, and Mordhau Flute is in track 1. This may change in future updates
* FLuteMod\_1.3 is hardcoded to play only track 0 on the Lute, and only track 1 on the Flute. This may change in future updates
* The track was previously used to setup LuteMod Bands for server-side play, but this functionality was deprecated after Mordhau patch 23 (source?) due to undocumented changes in the engine. We now have documentation, so this may change in future updates

LuteMod then uses blueprints inside Unreal Engine to load the sav files, extract the strings, parse them, and play them on time (skipping when there are too many notes)

###### PartitionIndex

The PartitionIndex is used as a collection of filenames that are saved as partitions. LuteMod loads this file to determine the names to display, as well as which .sav files should be loaded when a given song is selected

LuteBot should automatically add songs to this file each time you save a partition, and will create more files if necessary, sometimes resulting in the Oversized PartitionIndex Bug. It is best to keep song names short to fit as many song as you can before encountering this issue

Like partitions, this file should never be edited by hand, and has all the same constraints and volatility. May very rarely develop the Corrupt Partition Bug