DrawnMapFormat.wiki
author Wuzzy
Thu, 05 Dec 2019 16:12:25 +0000
changeset 2113 115b171c7e3e
parent 2112 940566498a62
child 2115 43bd12e66491
permissions -rw-r--r--
DrawnMapFormat: More about polylines

#summary Short description of the file format of hand-drawn maps

= Hand-drawn maps =
== Introduction ==
Hand-drawn maps are maps which are created by the player using the in-game map editor.

== File storage ==
Hand-drawn maps are saved with a file name suffix of “.hwmap”. By default, drawn maps are stored in a directory called “DrawnMaps” in the user directory, but the player could choose any location.

== File format (outdated) ==
*NOTE*: This section is outdated.

The raw format is defines as follows:

A drawn map is described by a sequence of points, which define polylines to draw and format of each polyline.

A point is defined as
|| Big-endian int16 || Big-endian int16 || Byte ||
|| *X* coordinate || *Y* coordinate || *flags* ||

where *flags* are:
|| 8th bit || 7th bit || 6th-1st bits ||
|| if set, this is a first point of polyline (“start” bit) || if set, polyline is erasing || *width* (thickness) of line ||

… where *width* defines `(width * 10) + 6` pixels width line to draw.

Second and further points of polyline have 8th bit of *flags* unset, the content of others are ignored for those.

A polyline begins when a point with the 8th bit in flags was set. Subsequent points will extend the line as long the “start” bit of those is not set. A new line starts when another point appears with the “start” bit being set. A single-point polyline defines a circle.

=== Compression ===

Above description describes the raw data, but the final file will be changed. The raw data is first base64-encoded and then compressed with [https://doc.qt.io/qt-5/qbytearray.html#qCompress Qt's `qCompress` function].

== Sharing hand-drawn maps ==
Hand-drawn maps will be automatically transferred when playing online.

But if you wish you can still share your creations in the [https://www.hedgewars.org/node/2849 Hand-Drawn Maps Submission Thread].