101 Commits

Author SHA1 Message Date
Rogier
9706084e8d Remove lingering printfs... 2014-05-23 23:29:34 +02:00
Rogier
bacbcfc1e4 Skip comments at end of colors.txt lines as well
(and detect and report incomplete lines as well)
2014-05-23 15:52:15 +02:00
Rogier
f3c25ac729 Fix and improve configuration of tiles location 2014-05-23 13:47:41 +02:00
Rogier
bd2ff09dfb Fix computation of map size with tiles (height could be miscomputed) 2014-05-23 13:47:41 +02:00
Rogier
736e2a8d27 Add command-line options to draw geometrical figures on the map
Supported figures are points, lines, ellipses, rectangles
and text.

The figures' locations can be specified using either world
coordinates, or map coordinates.
2014-05-23 13:47:41 +02:00
Rogier
c00cc13e6a Generalize the parsing of coordinates and geometry strings.
In preparation for future changes.

New geometry and new coordinate syntax has been added as well:

Additional node coordinate formats:
    <block>#[<node>]
    <block>.[<node>]

Additional geometry formats:
    <x1>,<y1>:<x2>,<y2>
    <x>,<y>:<w>x<h>

Also: the old geometry behavior (block granularity and map shrinking)
is now enabled only if the old geometry format is used (for compatibility)
2014-05-23 13:47:40 +02:00
Rogier
64bf53fc8a Close colors file after parsing 2014-05-23 13:47:40 +02:00
Rogier
6544d4de37 Catch block data parsing errors (e.g. caused by a corrupt map block)
Corrupt blocks are reported, and map generation continues. Map
generation aborts only after 100 or more corrupt map blocks.
2014-05-23 13:47:40 +02:00
Rogier
721fbfac52 Obtain database backend type from the world's world.mt file by default 2014-05-23 13:47:40 +02:00
Rogier
2fabf991ab Make sqlite backend optional (enabled by default) 2014-05-22 10:41:48 +02:00
Rogier
d707b882e8 Add redis database backend (port of sfan5's patches)
Patches included/ported:
	2553e44e8dec75d99408b56f469ff4be61c84336
	79d338a90c1a99fce9334bea5d4c296f190373fc
2014-05-22 10:41:48 +02:00
Rogier
3df8be20bb Fix SEGV when top part of the map is empty 2014-05-22 10:41:47 +02:00
Rogier
f36a8b61fb Allow colors with alpha to differ from colors without alpha
(using the same colors.txt file)
2014-05-22 10:41:47 +02:00
Rogier
49cb97598d Fix choice between c++11 unordered_map and c++0x regular (ordered) map 2014-05-22 10:41:47 +02:00
Rogier
ae5c031d5b Remove trailing NULs (if any) in node names from MT node name map 2014-05-22 10:41:12 +02:00
Rogier
1c7b31a5dc When not using a geometry option, *do* generate the smallest possible map 2014-05-22 10:41:12 +02:00
Rogier
21b9ffe0a1 Don't treat empty map blocks as opaque
(empty map blocks are blocks that have no associated block data
 in the database (which should probably not happen), or that are
 not in the database at all, but that are still queried for some
 reason (which is unlikely))
2014-05-22 10:41:11 +02:00
Rogier
d57ce63c46 Move min/max mapblock defines to config.h, and rename them 2014-05-22 10:41:11 +02:00
Rogier
c692d3d652 Improvements to database code & some small optimisations 2014-05-22 10:32:12 +02:00
Rogier
902f3b45d7 Use a common ustring type definition instead of different custom versions 2014-05-22 10:12:03 +02:00
Rogier
5e4ee45575 Move color string parsing to constructor of class Color & add a constructor using an integer
Added formats for Color constructor:
- plain interger (2^24 * alpha + 2^16 * red + 2^8 * green + blue)
- Color string consisting of:
  - '#'
  - 3, 4, 6 or 8 hex digits
2014-05-12 09:26:17 +02:00
Rogier
6ccb2285a1 Fix to verbose geometry messages - report requested geometry with pixel-accurate geometry 2014-04-24 16:58:06 +02:00
Rogier
751f3dc131 Abstraction of tile parameters computation to its own function. 2014-04-16 15:13:51 +02:00
Rogier
06237f5abc Improve layout of verbose geometry messages & tune their verbosity 2014-04-16 15:12:59 +02:00
Rogier
6a26a8ef4b Make the geometry pixel-accurate instead of map-block accurate
When requesting, for instance, a 75x85 map, the mapper will
now create a 75x85 map, instead of an 80x96 (or even 96x108)
map as it did before.

This new behavior is the default when using one of the options
--centergeometry or --cornergeometry.

In addition, both of these options will no longer shrink the
map, to remove rows or columns of empty blocks at the edges.
Previously, this behavior was enabled with --forcegeometry.

An option --geometrymode has been added as well, to tune
the interpretation of the geometry. It supports 4 flags:

- pixel:  the requested geometry is interpreted with pixel
	  granularity. The map is not enlarged to include
	  entire map blocks.

- block:  the requested geometry is interpreted with block
	  granularity. The map is enlarged with at most 15
	  nodes at each of the four edges, so that it
	  includes entire map blocks only.

- fixed:  a map of the requested geometry is created (after
	  adjustmens for 'block' mode). Empty rows or
	  columns at the edges are not removed.

- shrink: Empty rows and columns at the map edges are
	  removed to generate the smallest picture possible.

Lastly, a new geometry syntax has been added, which is more
compatible with known syntax (i.e. X-Windows), and which
allows the offset to be optional. If the offset is omitted,
the picture defaults to be centered around 0,0.

`<width>x<height>[+|-<xoffset>+|-<yoffset>]`

For compatibility, the behavior of the option --geometry
was not changed. If (and only if) used before --geometrymode,
it enables block granularity and shrink.

The old option --forcegeometry is no longer documented,
but still recognised for compatibility.
2014-04-16 15:12:37 +02:00
Rogier
2119a6ae75 Make PixelAttributes more generic
In preparation for other changes
2014-04-16 10:55:58 +02:00
Rogier
13463f2214 Catch option parsing errors & colors.txt errors. 2014-04-14 01:30:17 +02:00
Rogier
ce94029c95 Merge PixelCacheEntry into PixelAttributes 2014-04-14 01:29:58 +02:00
Rogier
8faa2d4a87 Fix/improve handling of colors with alpha channel
Color mixing using alpha channel now spans map blocks.
So for instance, water is partly translucent to great depths.

Water (or other translucent material) now also becomes darker
with depth.
2014-04-10 22:57:37 +02:00
Rogier
7dc3b48a7c Move color structs & functions to own header
To prepare for the map zoom level support
2014-04-10 19:53:35 +02:00
Rogier
1fbcdc281e Fix alpha handling - libgd treats 0xff as transparent and 0x00 as opaque. 2014-04-10 15:29:48 +02:00
Rogier
62f004ae0a Inform the user of libgd and system limitations when applicable.
This is necessary, because libgd may fail, or print some
unintelligible message when these limits are reached.

Known limitations:
- libgd refuses to create images larger than approx INT_MAX (2^31-1)
  pixels (a little over 46300x46300), even on 64-bit systems.
- on a 32-bit system, in practise, the largest size that can be
  generated is a little over 24100x24100 pixels.
2014-04-10 02:19:25 +02:00
Rogier
c1f2df705b Add an option to print progress information while generating the map. 2014-04-10 01:15:58 +02:00
Rogier
db2d27c077 Catch failure of gdImageCreateTrueColor & terminate gracefully. 2014-04-09 18:56:04 +02:00
Rogier
96a9c937ab Really ignore colors.txt lines that failed to parse 2014-04-09 12:47:59 +02:00
Sfan5
a7a45b5a55 Tabs -> spaces 2014-04-09 12:02:21 +02:00
Rogier
84e1fac7d7 Improve parsing of colors file
The colors file is now parsed line by line, which means
that parse failures on one line will not carry over to the next line.

When a line fails to parse, the rest of the file is no longer silently
ignored, but the error is reported, and just the failed line is ignored.
2014-04-09 11:47:18 +02:00
Sfan5
e96c23a8f7 Add alpha transparency ability for blocks 2014-04-09 11:03:54 +02:00
ShadowNinja
dc10bd20b1 Remove embedding of colors.txt in executable 2014-04-09 10:49:46 +02:00
Rogier
f18d5de26a Add the option to divide the map into tiles, rendered with a border in-between.
The net effect of making an image tiled, is that a grid is added
to the image, *without* obscuring part of the image with
grid lines: all pixel information is preserved. The lines
(aka borders) are added in-between the pixels of the image.
As a result, the image dimensions increase, and the image
may look slightly distorted. (a straight slanted line crossing
a tile border, will not look straight at the crossing).

Example:
Picture:
	[                                                  ]
	[ H   H  III     TTTTT  H   H  EEEEE  RRRR   EEEEE ]
	[ H   H   I        T    H   H  E      R   R  E     ]
	[ HHHHH   I        T    HHHHH  EEE    RRRR   EEE   ]
	[ H   H   I        T    H   H  E      R   R  E     ]
	[ H   H  III       T    H   H  EEEEE  R   R  EEEEE ]
	[                                                  ]
Same picture with 10x5 tiles:
	[          |          |          |          |          ]
	[ H   H  II|I     TTTT|T  H   H  |EEEEE  RRR|R   EEEEE ]
	[ H   H   I|        T |   H   H  |E      R  | R  E     ]
	[ HHHHH   I|        T |   HHHHH  |EEE    RRR|R   EEE   ]
	[ H   H   I|        T |   H   H  |E      R  | R  E     ]
	[----------|----------|----------|----------|----------]
	[ H   H  II|I       T |   H   H  |EEEEE  R  | R  EEEEE ]
	[          |          |          |          |          ]
2014-04-08 04:40:09 +02:00
Rogier
fdc73f0374 Fix computation of origin location and player locations (off-by-one) 2014-04-07 19:11:24 +02:00
Rogier
266c1eaaf0 Small improvement to for loop iteration code 2014-03-30 01:42:43 +01:00
Rogier
a2205eb9fb Geometry: w and h are the map dimensions
For a 100x100 map, the w and h parameters would have to be
specified as +99+99. This is not intuitive. Changed this,
so that +100+100 results in a 100x100 map.
2014-03-26 11:51:48 +01:00
Rogier
1c8cb878ab Report area rendered as well (with --verbose) 2014-03-26 09:17:56 +01:00
Rogier
5442db19dc Set default map geometry to the maximum world size (i.e. 4096x4096) 2014-03-26 08:55:20 +01:00
Rogier
10e6a746cd Database performance tweaks
Added the option to bulk load and cache entire world rows at
a time when using sqlite. Caching is implemented in the
database class this time around.
Enabled using --sqlite-cacheworldrow on the command line.

This is essentially re-introduces the database access strategy
that was used originally, but as an option.

Currently, one block is read at a time from the database.
The original behavior was to read and cache one entire world
row at a time, irrespective of whether or not only a (small)
subsection of the world was being mapped.
Under some circumstances, in particular if the entire world is
mapped or a relatively large percentage of it (blocks-wise), the
bulk loading and caching may outperform the one-by-one strategy,
even though it usually loads many more blocks than are actually
needed.

It seems that leveldb won't benefit from any kind of caching or
bulk loading of blocks, so none was implemented.

Leveldb does compile now. Still not tested on a database :-(

Improved the database statistics (printed with --verbose).
2014-03-26 00:23:33 +01:00
Rogier
ecbe59ac82 Optimize database access - load only blocks that are needed 2014-03-24 22:43:32 +01:00
Rogier
440edca394 Report number of 16x16x16 blocks in world and map as well, with --verbose 2014-03-23 20:53:13 +01:00
Rogier
5296f9f9e7 Report world coordinate limits and map heigth and depth limits with --verbose 2014-03-23 20:52:58 +01:00
Rogier
6420eb48fb Add option --forcegeometry to force using the requested geometry
Instead of reducing the map size to the minimum necessary for the
size of the world, a map of the requested size is always generated.
2014-03-23 20:06:35 +01:00