summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/dgn-shoals.cc20
-rw-r--r--crawl-ref/source/directn.cc9
-rw-r--r--crawl-ref/source/dungeon.cc1
-rw-r--r--crawl-ref/source/env.h3
-rw-r--r--crawl-ref/source/tags.cc24
-rw-r--r--crawl-ref/source/tags.h5
6 files changed, 50 insertions, 12 deletions
diff --git a/crawl-ref/source/dgn-shoals.cc b/crawl-ref/source/dgn-shoals.cc
index c4cdf30cca..f3b7e386fd 100644
--- a/crawl-ref/source/dgn-shoals.cc
+++ b/crawl-ref/source/dgn-shoals.cc
@@ -13,7 +13,11 @@
#include <vector>
#include <cmath>
-static int _shoals_heights[GYM][GXM];
+inline short &shoals_heights(const coord_def &c)
+{
+ return (*env.heightmap)(c);
+}
+
static std::vector<coord_def> _shoals_islands;
const int ISLAND_COLLIDE_DIST2 = 5 * 5;
@@ -43,7 +47,7 @@ static double _to_radians(int degrees)
static dungeon_feature_type _shoals_feature_at(const coord_def &c)
{
- const int height = _shoals_heights[c.y][c.x];
+ const int height = shoals_heights(c);
return height >= SHT_STONE ? DNGN_STONE_WALL :
height >= SHT_ROCK? DNGN_ROCK_WALL :
height >= SHT_FLOOR? DNGN_FLOOR :
@@ -53,9 +57,9 @@ static dungeon_feature_type _shoals_feature_at(const coord_def &c)
static void _shoals_init_heights()
{
- for (int y = 0; y < GYM; ++y)
- for (int x = 0; x < GXM; ++x)
- _shoals_heights[y][x] = -17;
+ env.heightmap.reset(new grid_heightmap);
+ for (rectangle_iterator ri(0); ri; ++ri)
+ shoals_heights(*ri) = SHT_SHALLOW_WATER - 3;
}
static double _angle_fuzz()
@@ -94,7 +98,7 @@ static void _shoals_island_center(const coord_def &c, int n_perturb, int radius,
{
for (int i = 0; i < n_perturb; ++i) {
coord_def p = _random_point_from(c, random2(1 + radius));
- _shoals_heights[p.y][p.x] += random_range(bounce_low, bounce_high);
+ shoals_heights(p) += random_range(bounce_low, bounce_high);
}
}
@@ -194,10 +198,10 @@ static void _shoals_smooth_at(const coord_def &c, int radius)
const coord_def off = c - p;
int weight = max_delta - off.abs();
divisor += weight;
- total += _shoals_heights[p.y][p.x] * weight;
+ total += shoals_heights(p) * weight;
}
}
- _shoals_heights[c.y][c.x] = total / divisor;
+ shoals_heights(c) = total / divisor;
}
static void _shoals_smooth()
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc
index 518d21b23c..9807ec54dc 100644
--- a/crawl-ref/source/directn.cc
+++ b/crawl-ref/source/directn.cc
@@ -3468,14 +3468,19 @@ static void _describe_cell(const coord_def& where, bool in_range)
marker = " (" + desc + ")";
}
const std::string traveldest = _stair_destination_description(where);
+ std::string height_desc;
+ if (env.heightmap.get())
+ height_desc = make_stringf(" (height: %d)", (*env.heightmap)(where));
const dungeon_feature_type feat = grd(where);
- mprf(MSGCH_DIAGNOSTICS, "(%d,%d): %s - %s (%d/%s)%s%s", where.x, where.y,
+ mprf(MSGCH_DIAGNOSTICS, "(%d,%d): %s - %s (%d/%s)%s%s%s",
+ where.x, where.y,
stringize_glyph(get_screen_glyph(where)).c_str(),
feature_desc.c_str(),
feat,
dungeon_feature_name(feat),
marker.c_str(),
- traveldest.c_str());
+ traveldest.c_str(),
+ height_desc.c_str());
#else
if (Tutorial.tutorial_left && tutorial_pos_interesting(where.x, where.y))
{
diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc
index 53658c2a58..c5f6a788ca 100644
--- a/crawl-ref/source/dungeon.cc
+++ b/crawl-ref/source/dungeon.cc
@@ -975,6 +975,7 @@ void dgn_reset_level()
// Forget level properties.
env.properties.clear();
+ env.heightmap.reset(NULL);
// Set up containers for storing some level generation info.
env.properties[LEVEL_VAULTS_KEY].new_table();
diff --git a/crawl-ref/source/env.h b/crawl-ref/source/env.h
index 1f3c02f142..aa78f2ac0f 100644
--- a/crawl-ref/source/env.h
+++ b/crawl-ref/source/env.h
@@ -6,6 +6,7 @@
#include "show.h"
#include "trap_def.h"
+typedef FixedArray<short, GXM, GYM> grid_heightmap;
struct crawl_environment
{
public:
@@ -22,6 +23,8 @@ public:
FixedArray< unsigned short, GXM, GYM > cgrid; // cloud grid
FixedArray< unsigned short, GXM, GYM > grid_colours; // colour overrides
+ std::auto_ptr<grid_heightmap> heightmap;
+
// Player-remembered terrain. TODO: move to class player.
FixedArray< map_cell, GXM, GYM > map_knowledge;
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index ab60932b4f..c092062c23 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -61,6 +61,7 @@
#include "artefact.h"
#include "branch.h"
+#include "coordit.h"
#include "describe.h"
#include "dungeon.h"
#include "enum.h"
@@ -1825,6 +1826,15 @@ static void tag_construct_level(writer &th)
env.markers.write(th);
env.properties.write(th);
+
+ // Save heightmap, if present.
+ marshallByte(th, !!env.heightmap.get());
+ if (env.heightmap.get())
+ {
+ grid_heightmap &heightmap(*env.heightmap);
+ for (rectangle_iterator ri(0); ri; ++ri)
+ marshallShort(th, heightmap(*ri));
+ }
}
void marshallItem(writer &th, const item_def &item)
@@ -2217,6 +2227,20 @@ static void tag_read_level( reader &th, char minorVersion )
env.properties.clear();
env.properties.read(th);
+
+ // Restore heightmap
+ env.heightmap.reset(NULL);
+ if (_tag_minor_version >= TAG_MINOR_HEIGHTMAP)
+ {
+ const bool have_heightmap(unmarshallByte(th));
+ if (have_heightmap)
+ {
+ env.heightmap.reset(new grid_heightmap);
+ grid_heightmap &heightmap(*env.heightmap);
+ for (rectangle_iterator ri(0); ri; ++ri)
+ heightmap(*ri) = unmarshallShort(th);
+ }
+ }
}
static void tag_read_level_items(reader &th, char minorVersion)
diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h
index 26ecf81233..e7877dfd6f 100644
--- a/crawl-ref/source/tags.h
+++ b/crawl-ref/source/tags.h
@@ -46,8 +46,9 @@ enum tag_major_version
// Minor version will be reset to zero when major version changes.
enum tag_minor_version
{
- TAG_MINOR_RESET = 0, // Minor tags were reset
- TAG_MINOR_VERSION = 0 // Current version. (Keep equal to max.)
+ TAG_MINOR_RESET = 0, // Minor tags were reset
+ TAG_MINOR_HEIGHTMAP = 1,
+ TAG_MINOR_VERSION = 1 // Current version. (Keep equal to max.)
};
struct enum_info