Difference between revisions of "Map Merger"

From /tg/station 13 Wiki
Jump to navigation Jump to search
(More improvements)
(Adds link to the Guide to Mapping for Git Hooks.)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
/tg/station uses a tool called the '''Map Merger''' to minimize differences between versions of maps and lay them out in a format known as TGM, developed by Remie. This makes changes easier for maintainers to review and less likely to conflict with changes made by others.
+
: [[Guide to contributing to the game]] > [[Guide to mapping]]
  
There are two ways of running the tool, each requiring some amount of setup. If you have trouble or need help, ask in [[Community|#coderbus]].
+
/tg/station uses a tool called the '''Map Merger''' to make map changes easier for maintainers to review and less likely to conflict with map changes made by others.
  
== Basic Setup ==
+
There are a few ways of running the tool. If you have trouble or need help, ask in [[Community|#coderbus]]. You may find a visual guide [https://hackmd.io/@tgstation/SyVma0dS5#Git-Hooks here].
  
# '''Install Python 3.6''': If you don't already have Python installed, [https://www.python.org/downloads/ download and install] version 3.6 or later.
+
'''Summary''': for best results, open the <code>tools/hooks/</code> folder and double-click <code>Install.bat</code> to install the hooks, which will handle things automatically.
# '''Ensure Python is in your PATH''': For Windows users, ensure that you check the "Add Python 3.6 to PATH" option in the installer. - see [https://file.house/DA6H.png here for example]
 
  
== Use as a Git hook (recommended) ==
+
== TGM format conversion ==
  
# '''Install the hook''': Windows users open the <code>tools/hooks</code> folder and double-click <code>install.bat</code>. Other platforms run <code>tools/hooks/install.sh</code>.
+
The "map merge" operation describes the process of converting a map file written by the DreamMaker map editor to:
 +
# Use a format more amenable to Git's conflict resolution, called "TGM" and originally developed by Remie. The TGM map format is like the standard Dream Maker map format, but arranged differently, meaning Dream Maker is able to open TGM maps.
 +
# Keep the size of the difference between the old version and the new version of the map as small as possible.
 +
This is accomplished by referencing the changed version of the map against the old version stored in the Git history.
  
Once the Git hook is installed, no further manual intervention is needed and the map merger will run automatically any time you commit in Git.
+
=== Use as a Git hook (recommended) ===
  
The dialog box or console output of the commit will show the map merger's log. You can check the git commit log to review changes, or run <code>tools/mapmerge2/precommit.py</code> manually to review changes before committing.
+
# '''Install the hook''': Open the <code>tools/hooks/</code> folder and double-click <code>Install.bat</code>
 +
#* Linux users: run <code>tools/hooks/install.sh</code>
  
== Run manually (not recommended) ==
+
Once complete, the map merger will run '''automatically''' every time you commit in Git. The console log can be reviewed if there are any errors.
  
This is the older method, and is simpler but requires careful manual use each time you want to make changes to the map. First:
+
=== Or: Run manually before committing ===
  
# '''Install dependencies''': For Windows users, run <code>tools/mapmerge2/requirements-install.bat</code>. Non-Windows or advanced users can manually run <code>python -m pip install tools/mapmerge2/requirements.txt</code>.
+
You can also manually run a .bat file just before each time you commit:
  
Each time you want to edit a map, follow these steps:
+
# Ensure you have saved all your changes
 +
# Open the <code>tools/mapmerge2/</code> folder and double-click <code>Run Before Committing.bat</code>
 +
# Commit
  
# '''Prepare maps''': Run <code>tools/mapmerge2/Prepare Maps.bat</code> to save a backup of all maps in their current state.
+
=== If you forgot to map merge ===
# '''Make your changes''': Don't forget to save.
 
# '''Exit DreamMaker''': Optional, but ensures that you don't accidentally undo the map merger's work.
 
# '''Run the map merger''': Run <code>tools/mapmerge2/mapmerge.bat</code> and select the map you edited to merge.
 
  
With this method, leaving the map open in DreamMaker or reviewing it after running the map merger makes it possible to accidentally save and overwrite the merged map with an unmerged map. Close DreamMaker entirely before manually running the map merger or be extra-careful not to overwrite the changes the map merger made.
+
For first-time contributors who committed map edits without map merging, a script is available to automatically commit a fix to your PR branch:
 +
 
 +
# Ensure you have no unsaved changes
 +
# Open the <code>tools/mapmerge2/</code> folder and double-click <code>I Forgot To Map Merge.bat</code>
 +
# Push your branch
 +
 
 +
== Automatic conflict resolver ==
 +
 
 +
We also have a rudimentary conflict resolver to cover some cases that the TGM conversion couldn't prevent.
 +
 
 +
When run, the console output will indicate whether further manual action is needed, including conflicting coordinates.
 +
 
 +
=== Use as a Git hook ===
 +
 
 +
# '''Install the hook''': Open the <code>tools/hooks/</code> folder and double-click <code>Install.bat</code>
 +
#* Linux users: run <code>tools/hooks/install.sh</code>
 +
 
 +
Once complete, the conflict resolver will run '''automatically''' every time you merge in Git.
 +
 
 +
=== Or: Resolve conflicts on an in-progress merge ===
 +
 
 +
If you are using a Git GUI which does not run the hook on merge, you can also run the conflict resolver on an in-progress merge by request:
 +
# Open the <code>tools/mapmerge2/</code> folder and double-click <code>Resolve Map Conflicts.bat</code>
 +
#* Linux users: run <code>tools/hooks/dmm.merge --posthoc</code>
 +
 
 +
Note that to use this, you must merge your updated local master branch into the branch with conflicts so that your Git GUI reports a conflict on the map file.
 +
== Implementation details ==
 +
 
 +
Information on the tool's implementation is stored with [https://github.com/tgstation/tgstation/blob/master/tools/mapmerge2/ the code].
 +
 
 +
 
 +
{{Contribution guides}}

Latest revision as of 03:46, 25 July 2022

Guide to contributing to the game > Guide to mapping

/tg/station uses a tool called the Map Merger to make map changes easier for maintainers to review and less likely to conflict with map changes made by others.

There are a few ways of running the tool. If you have trouble or need help, ask in #coderbus. You may find a visual guide here.

Summary: for best results, open the tools/hooks/ folder and double-click Install.bat to install the hooks, which will handle things automatically.

TGM format conversion

The "map merge" operation describes the process of converting a map file written by the DreamMaker map editor to:

  1. Use a format more amenable to Git's conflict resolution, called "TGM" and originally developed by Remie. The TGM map format is like the standard Dream Maker map format, but arranged differently, meaning Dream Maker is able to open TGM maps.
  2. Keep the size of the difference between the old version and the new version of the map as small as possible.

This is accomplished by referencing the changed version of the map against the old version stored in the Git history.

Use as a Git hook (recommended)

  1. Install the hook: Open the tools/hooks/ folder and double-click Install.bat
    • Linux users: run tools/hooks/install.sh

Once complete, the map merger will run automatically every time you commit in Git. The console log can be reviewed if there are any errors.

Or: Run manually before committing

You can also manually run a .bat file just before each time you commit:

  1. Ensure you have saved all your changes
  2. Open the tools/mapmerge2/ folder and double-click Run Before Committing.bat
  3. Commit

If you forgot to map merge

For first-time contributors who committed map edits without map merging, a script is available to automatically commit a fix to your PR branch:

  1. Ensure you have no unsaved changes
  2. Open the tools/mapmerge2/ folder and double-click I Forgot To Map Merge.bat
  3. Push your branch

Automatic conflict resolver

We also have a rudimentary conflict resolver to cover some cases that the TGM conversion couldn't prevent.

When run, the console output will indicate whether further manual action is needed, including conflicting coordinates.

Use as a Git hook

  1. Install the hook: Open the tools/hooks/ folder and double-click Install.bat
    • Linux users: run tools/hooks/install.sh

Once complete, the conflict resolver will run automatically every time you merge in Git.

Or: Resolve conflicts on an in-progress merge

If you are using a Git GUI which does not run the hook on merge, you can also run the conflict resolver on an in-progress merge by request:

  1. Open the tools/mapmerge2/ folder and double-click Resolve Map Conflicts.bat
    • Linux users: run tools/hooks/dmm.merge --posthoc

Note that to use this, you must merge your updated local master branch into the branch with conflicts so that your Git GUI reports a conflict on the map file.

Implementation details

Information on the tool's implementation is stored with the code.


Hosting Hosting a serverSetting up the databaseWorking with /tg/station as an upstream repository
Contributing Guide to contributing to the gameSetting up gitDownloading the source codeReporting issuesChangelogs
Coding Understanding SS13 codeSS13 for experienced programmersCode docsCoding standardsGetting Your Pull AcceptedBinary flags‎Text FormattingMySQL
Mapping Guide to mappingMap mergerGuide to door access
Spriting Guide to spritingResolving icon conflicts
Wiki Guide to contributing to the wikiWikicodeAutowiki