From 9a308a7dd9f9abb274e2024d41239c587dd7eb77 Mon Sep 17 00:00:00 2001 From: Darshan Shaligram Date: Wed, 13 Jan 2010 21:39:16 +0530 Subject: Move island-building code from dgn-shoals.cc->dgn-height.cc. --- crawl-ref/source/dgn-height.h | 104 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 crawl-ref/source/dgn-height.h (limited to 'crawl-ref/source/dgn-height.h') diff --git a/crawl-ref/source/dgn-height.h b/crawl-ref/source/dgn-height.h new file mode 100644 index 0000000000..1ab5954db4 --- /dev/null +++ b/crawl-ref/source/dgn-height.h @@ -0,0 +1,104 @@ +#ifndef DGN_HEIGHT_H +#define DGN_HEIGHT_H + +#include "AppHdr.h" +#include "externs.h" +#include "env.h" +#include "fixedarray.h" +#include + +// The caller is responsible for ensuring that env.heightmap is set. +static inline short &dgn_height_at(const coord_def &c) +{ + return (*env.heightmap)(c); +} + +typedef FixedArray grid_bool; +typedef FixedArray grid_short; +typedef std::pair int_range; + +const int DGN_UNDEFINED_HEIGHT = -10000; + +int resolve_range(int_range range, int nrolls = 1); + +void dgn_initialise_heightmap(int initial_height = 0); +void dgn_smooth_height_at(coord_def c, int radius = 1, + int max_height = DGN_UNDEFINED_HEIGHT); +void dgn_smooth_heights(int radius = 1, int npasses = 1); + + +void dgn_island_centred_at(const coord_def &c, + // Number of times to raise heights of + // points near c. + int n_points, + + // Radius within which all height + // increments are applied. + int radius, + + // Lower and upper limits to the height + // delta per perturbation. + int_range height_delta_range, + + int border_margin = 6, + + // If make_atoll is set, all points chosen for + // height increment will be close to the specified + // radius from c, thus producing a ragged ring. + bool make_atoll = false); + +struct dgn_island_plan +{ +public: + // Number of squares of border to leave around the level. + int level_border_depth; + + // Number of auxiliary high points for each island. + int_range n_aux_centres; + + // Distance from the island centre where the aux high points are placed. + int_range aux_centre_offset_range; + + // Percentage of island (aux) centres that are built as atolls. + int atoll_roll; + + // The positions of the primary centre of each island. + std::vector islands; + + // The square of the minimum distance that must separate any two + // island centres. This is not intended to prevent island overlap, only + // to prevent too much clumping of islands. + int island_separation_dist2; + + // Number of points near each island centre that will be raised by + // the island builder. + int_range n_island_centre_delta_points; + + // Range of radii for island primary centres. + int_range island_centre_radius_range; + + int_range island_centre_point_height_increment; + + // Number of points near secondary island centres that will be + // raised by the island builder. + int_range n_island_aux_delta_points; + + // Range of radii for island aux centres. + int_range island_aux_radius_range; + + int_range island_aux_point_height_increment; + +public: + static dgn_island_plan shoals_islands(int margin); + static dgn_island_plan snake_chambers(int margin); + +public: + void build(int nislands); + coord_def pick_and_remove_random_island(); + +private: + coord_def pick_island_spot(); + void build_island(); +}; + +#endif -- cgit v1.2.3-54-g00ecf