Files
Bubberstation/tools/mapmerge2
san7890 3156a0414e [MDB Ignore] Manifest Destiny - The Final Tile Flattening (#74169)
Alt Title: The End Of The 12 Month War
## About The Pull Request

### Hey! Listen! This PR _will_ cause a merge conflict with your PR!
Please ensure that you have the knowledge on how to handle merge
conflicts, found here:
https://hackmd.io/@tgstation/ry4-gbKH5#Assured-Merge-Conflict-Resolution

Supercedes #74023 entirely.

Port of the tooling introduced in
https://github.com/BeeStation/BeeStation-Hornet/pull/7970 (we already
had everything else), modified to meet /tg/'s requisites and culling
anything that was not entirely relevant (that I could see). It's not the
end of the world if I missed something tbh. Some aspects were commented
out since they may be relevant to downstreams who port this PR or to
enable (what I see to be) un-necessary warnings.

This is a culmination of a year's efforts, starting with _Red Rover,
Four Corners_ (#65290) and later _Opposing Corners_ (#65455). If you
don't understand why this PR exists or why it's necessary, I recommend
reading both of those.

Since then, several mappers (both in their own mapping as well as
tailored PRs) have worked on "flattening" out these tile turfs, however
I've continually wanted a function that would mass automate it (outlined
here https://tgstation13.org/phpBB/viewtopic.php?t=31872 - This
functionality might still be useful if added to UpdatePaths or another
type of script thereof, but I no longer have reason to keep the bounty
up).

It's finally here! Yippie! A new python file, courtesy of itsmeow at
BeeStation. Very awesome. As previously mentioned, a lot of alterations
had to be made for our mapping desires, but the results are quite
agreeable. There's a few assertions that this file makes that I had to
address:

* We have "colorless" tile decals. These are transparent, so they don't
do anything. By default, bee would make these "white tiles", but we have
no such thing. I decided to just add a maplint and an UpdatePaths to
guard against this silliness (only Delta and Tram) had it.
* For some reason, it labels already-converted decals with the default
direction as an error state. I might touch this up in the coming hours,
but for now I surpressed the error due to how many false warnings it was
spitting out.

There's a few ways this tool can be improved, but I lack the knowledge
on how to do so:
* Make it so that we can run the map merger to fix the keys of the map
in the `update_map` function, rather than run the fixer-upper python
file. We can live without this to be honest. It's actually slightly good
because it forces you to look at all of the MapMerge Warnings, and you
can ascertain any potential errors without it silently passing you by
and hitting the repository (or at least those that we haven't linted for
yet).
* Be able to pass in any regex to "flatten" anything. That's way out of
scope for what I want to do here though.

## How do you use this tool?

I made a readme.
363852cb17/tools/MapTileAggregator/readme.md
### Mapping March
oh hey it's pretty neat that this PR came out in mapping march, what a
nice qol for mappers as the month enters the home stretch. ckey is
san7890

## Why It's Good For The Game

slimmer DMM files, better mapping practices. cool new tool. so nice.
## Changelog
Nothing that really affects players, but a short summary for all those
reading this PR:

* All "corner" turf decals are flattened, and there's now a tool that we
store that you can re-run to keep stuff flat in case you like mapping
one way and want to fix it at the end.
* We (should) now lint against useless uncolored turf decals since that
was completely garbo as far as our codebase is concerned.
* UpdatePaths for fixing up uncolored turf decals, yippie!


If you want to review this PR, may I suggest the file filter. You don't
need to look at any of the DMM files I already did:

![image](https://user-images.githubusercontent.com/34697715/226787961-ab82cad4-5d6d-4788-a7bd-5071aac825c4.png)

---------

Co-authored-by: Zephyr <12817816+ZephyrTFA@users.noreply.github.com>
2023-03-24 19:53:45 +00:00
..

Map Merger

The Map Merger is a collection of scripts that keep this repository's maps in a format which is easier to track in Git and less likely to cause merge conflicts. When merge conflicts do occur, it can sometimes resolve them.

For detailed troubleshooting instructions and other tips, visit the Map Merger wiki article.

Installation

To install the Git hooks, open the tools/hooks/ folder and double-click Install.bat. Linux users run tools/hooks/install.sh.

Manual Use

If using a Git GUI which is not compatible with the hooks:

  • Before committing, double-click Run Before Committing.bat
  • When a merge has map conflicts, double-click Resolve Map Conflicts.bat

The console will show whether the operation succeeded.

For more details, see the Map Merger wiki article.

What Map Merging Is

The "map merge" operation describes the process of rewriting a map file written by the DreamMaker map editor to A) use a format more amenable to Git's conflict resolution and B) differ in the least amount textually from the previous version of the map while maintaining all the actual changes. It requires an old version of the map to use as a reference and a new version of the map which contains the desired changes.

Map Merge 2 adds multi-Z support, automatic handling of key overflow, better merge conflict prevention, and a real merge conflict resolver.

Code Structure

Frontend scripts are meant to be run directly. They obey the environment variables TGM to set whether files are saved in TGM (1) or DMM (0) format, and MAPROOT to determine where maps are kept. By default, TGM is used and the map root is autodetected. Each script may either prompt for the desired map or be run with command-line parameters indicating which maps to act on. The scripts include:

  • convert.py for converting maps to and from the TGM format. Used by tgm2dmm.bat and dmm2tgm.bat.
  • mapmerge.py for running the map merge on map backups saved by Prepare Maps.bat. Used by mapmerge.bat

Implementation modules:

  • dmm.py includes the map reader and writer.
  • mapmerge.py includes the implementation of the map merge operation.
  • frontend.py includes the common code for the frontend scripts.

precommit.py is run by the Git hooks if installed, and merges the new version of any map saved in the index (git added) with the old version stored in Git when run.