DrawnMapFormat: More about polylines
authorWuzzy
Thu, 05 Dec 2019 16:12:25 +0000
changeset 2113 115b171c7e3e
parent 2112 940566498a62
child 2114 cbb1fde40368
DrawnMapFormat: More about polylines
DrawnMapFormat.wiki
--- a/DrawnMapFormat.wiki	Thu Dec 05 15:26:31 2019 +0000
+++ b/DrawnMapFormat.wiki	Thu Dec 05 16:12:25 2019 +0000
@@ -4,26 +4,33 @@
 == 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.
 
-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.
+The raw format is defines as follows:
 
-Drawn map is described by a list of points, which define polylines to draw and format of each polyline.
+A drawn map is described by a sequence of points, which define polylines to draw and format of each polyline.
 
-Point is defined as
+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 || if set, polyline is erasing || *width* (thickness) of line ||
+|| 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 single-point polyline defines a circle.
+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.