summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-07-20 23:26:32 -0400
committerNeil Moore <neil@s-z.org>2014-07-20 23:39:04 -0400
commit63bc4b8c3764250f17a47085a1798413fdf7d587 (patch)
treef211134f38741d77a396e3c9219d12c123b82dc1
parent035fa3e61758175e9a971d315aba5141a682ac67 (diff)
downloadcrawl-ref-63bc4b8c3764250f17a47085a1798413fdf7d587.tar.gz
crawl-ref-63bc4b8c3764250f17a47085a1798413fdf7d587.zip
Save old colour in terrain-change markers (#8806)
It is still possible to lose the colour if the cell is permanently reverted to its original type: for example, using Tomb on coloured floor then digging out.
-rw-r--r--crawl-ref/source/mapmark.cc14
-rw-r--r--crawl-ref/source/mapmark.h3
-rw-r--r--crawl-ref/source/tag-version.h1
-rw-r--r--crawl-ref/source/terrain.cc22
-rw-r--r--crawl-ref/source/terrain.h3
5 files changed, 32 insertions, 11 deletions
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index aec021857b..892b9744a2 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -776,9 +776,10 @@ string map_door_seal_marker::debug_describe() const
map_terrain_change_marker::map_terrain_change_marker (const coord_def& p,
dungeon_feature_type oldfeat, dungeon_feature_type newfeat,
- int dur, terrain_change_type ctype, int mnum)
+ int dur, terrain_change_type ctype, int mnum, int oldcol)
: map_marker(MAT_TERRAIN_CHANGE, p), duration(dur), mon_num(mnum),
- old_feature(oldfeat), new_feature(newfeat), change_type(ctype)
+ old_feature(oldfeat), new_feature(newfeat), change_type(ctype),
+ colour(oldcol)
{
}
@@ -790,6 +791,7 @@ void map_terrain_change_marker::write(writer &out) const
marshallUByte(out, new_feature);
marshallUByte(out, change_type);
marshallShort(out, mon_num);
+ marshallUByte(out, colour);
}
void map_terrain_change_marker::read(reader &in)
@@ -801,6 +803,12 @@ void map_terrain_change_marker::read(reader &in)
new_feature = static_cast<dungeon_feature_type>(unmarshallUByte(in));
change_type = static_cast<terrain_change_type>(unmarshallUByte(in));
mon_num = unmarshallShort(in);
+#if TAG_MAJOR_VERSION == 34
+ if (in.getMinorVersion() < TAG_MINOR_SAVE_TERRAIN_COLOUR)
+ colour = BLACK;
+ else
+#endif
+ colour = unmarshallUByte(in);
}
map_marker *map_terrain_change_marker::read(reader &in, map_marker_type)
@@ -814,7 +822,7 @@ map_marker *map_terrain_change_marker::clone() const
{
map_terrain_change_marker *mark =
new map_terrain_change_marker(pos, old_feature, new_feature, duration,
- change_type, mon_num);
+ change_type, mon_num, colour);
return mark;
}
diff --git a/crawl-ref/source/mapmark.h b/crawl-ref/source/mapmark.h
index 4632b4cef2..d02d0718c8 100644
--- a/crawl-ref/source/mapmark.h
+++ b/crawl-ref/source/mapmark.h
@@ -196,7 +196,7 @@ public:
dungeon_feature_type oldfeat = DNGN_FLOOR,
dungeon_feature_type newfeat = DNGN_FLOOR,
int dur = 0, terrain_change_type type = TERRAIN_CHANGE_GENERIC,
- int mnum = 0);
+ int mnum = 0, int oldcol = BLACK);
void write (writer &) const;
void read (reader &);
@@ -211,6 +211,7 @@ public:
dungeon_feature_type old_feature;
dungeon_feature_type new_feature;
terrain_change_type change_type;
+ int colour;
};
class map_cloud_spreader_marker : public map_marker
diff --git a/crawl-ref/source/tag-version.h b/crawl-ref/source/tag-version.h
index 95128fe337..8d34fecc06 100644
--- a/crawl-ref/source/tag-version.h
+++ b/crawl-ref/source/tag-version.h
@@ -111,6 +111,7 @@ enum tag_minor_version
TAG_MINOR_SLAYRING_PLUSES, // Combine Acc/Dam on rings of slaying and artefacts.
TAG_MINOR_MERGE_EW, // Combine enchant weapons scrolls.
TAG_MINOR_WEAPON_PLUSES, // Combine to-hit/to-dam enchantment on weapons.
+ TAG_MINOR_SAVE_TERRAIN_COLOUR, // Save colour in terrain-change markers.
#endif
NUM_TAG_MINORS,
TAG_MINOR_VERSION = NUM_TAG_MINORS - 1
diff --git a/crawl-ref/source/terrain.cc b/crawl-ref/source/terrain.cc
index 2236bd8cf5..eb91c6e0f7 100644
--- a/crawl-ref/source/terrain.cc
+++ b/crawl-ref/source/terrain.cc
@@ -1001,7 +1001,8 @@ void dungeon_terrain_changed(const coord_def &pos,
dungeon_feature_type nfeat,
bool affect_player,
bool preserve_features,
- bool preserve_items)
+ bool preserve_items,
+ int colour)
{
if (grd(pos) == nfeat)
return;
@@ -1016,7 +1017,7 @@ void dungeon_terrain_changed(const coord_def &pos,
unnotice_feature(level_pos(level_id::current(), pos));
grd(pos) = nfeat;
- env.grid_colours(pos) = BLACK;
+ env.grid_colours(pos) = colour;
// Reset feature tile
env.tile_flv(pos).feat = 0;
env.tile_flv(pos).feat_idx = 0;
@@ -1804,10 +1805,10 @@ void temp_change_terrain(coord_def pos, dungeon_feature_type newfeat, int dur,
if (grd(pos) == newfeat && newfeat == old_feat)
return;
+ int col = env.grid_colours(pos);
map_terrain_change_marker *marker =
- new map_terrain_change_marker(pos, old_feat, newfeat, dur, type);
- if (mon)
- marker->mon_num = mon->mid;
+ new map_terrain_change_marker(pos, old_feat, newfeat, dur, type,
+ mon ? mon->mid : 0, col);
env.markers.add(marker);
env.markers.clear_need_activate();
dungeon_terrain_changed(pos, newfeat, true, false, true);
@@ -1860,6 +1861,7 @@ bool revert_terrain_change(coord_def pos, terrain_change_type ctype)
{
vector<map_marker*> markers = env.markers.get_markers_at(pos);
dungeon_feature_type newfeat = DNGN_UNSEEN;
+ int colour = BLACK;
for (int i = 0, size = markers.size(); i < size; ++i)
{
@@ -1870,12 +1872,20 @@ bool revert_terrain_change(coord_def pos, terrain_change_type ctype)
if (marker->change_type == ctype)
{
+ if (marker->colour != BLACK)
+ colour = marker->colour;
if (!newfeat)
newfeat = marker->old_feature;
env.markers.remove(marker);
}
else
+ {
+ // If we had an old colour, give it to the other marker.
+ if (colour != BLACK)
+ marker->colour = colour;
+ colour = BLACK;
newfeat = marker->new_feature;
+ }
}
}
@@ -1885,7 +1895,7 @@ bool revert_terrain_change(coord_def pos, terrain_change_type ctype)
if (newfeat != DNGN_UNSEEN)
{
- dungeon_terrain_changed(pos, newfeat, true, false, true);
+ dungeon_terrain_changed(pos, newfeat, true, false, true, colour);
return true;
}
else
diff --git a/crawl-ref/source/terrain.h b/crawl-ref/source/terrain.h
index a6fcf969b5..9a142df35e 100644
--- a/crawl-ref/source/terrain.h
+++ b/crawl-ref/source/terrain.h
@@ -91,7 +91,8 @@ void dungeon_terrain_changed(const coord_def &pos,
dungeon_feature_type feat = DNGN_UNSEEN,
bool affect_player = true,
bool preserve_features = false,
- bool preserve_items = false);
+ bool preserve_items = false,
+ int colour = BLACK);
// Moves everything on the level at src to dst.
void dgn_move_entities_at(coord_def src,