summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tags.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-11 20:56:55 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-08-11 20:56:55 +0000
commite9e1be789c12cdbaaaeb048251dae0dc22a320ba (patch)
treef62f547aba1d78f1bcbf4b6d09b5c9a1bbc2913b /crawl-ref/source/tags.cc
parent4c51cdab684e245dd8f050171294dcbc5c471bfe (diff)
downloadcrawl-ref-e9e1be789c12cdbaaaeb048251dae0dc22a320ba.tar.gz
crawl-ref-e9e1be789c12cdbaaaeb048251dae0dc22a320ba.zip
Give Lugonu Banishment and Corruption. I've left the old Bend Space in, because
there needs to be an invocation that can train Invocations, and Banishment is too costly to use for everyday training. Corruption is still a first-cut, needs more work and playtesting: - Terrain modification is one-time only. Creeping modification requires too much savegame magic. - The monsters gated in during the corruption effect are occasionally hostile, but mostly neutral. Neutrals will attack hostile monsters and also pets, but will leave other neutrals and the player alone (in general). A neutral that wants to go somewhere, but finds the player in the way will still take a swing at the player. - Beams are still not fixed to handle neutrals correctly (so neutrals do not target and shoot right yet), will fix soon. Breaks save compatibility. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1990 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tags.cc')
-rw-r--r--crawl-ref/source/tags.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 8972af6cc0..f90f9a6fee 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -334,6 +334,56 @@ void unmarshallCoord(tagHeader &th, coord_def &c)
c.y = unmarshallShort(th);
}
+template <typename marshall, typename grid>
+void run_length_encode(tagHeader &th, marshall m, const grid &g,
+ int width, int height)
+{
+ int last = 0, nlast = 0;
+ for (int y = 0; y < height; ++y)
+ {
+ for (int x = 0; x < width; ++x)
+ {
+ if (!nlast)
+ last = g[x][y];
+ if (last == g[x][y] && nlast < 255)
+ {
+ nlast++;
+ continue;
+ }
+
+ marshallByte(th, nlast);
+ m(th, last);
+
+ last = g[x][y];
+ nlast = 1;
+ }
+ }
+
+ marshallByte(th, nlast);
+ m(th, last);
+}
+
+template <typename unmarshall, typename grid>
+void run_length_decode(tagHeader &th, unmarshall um, grid &g,
+ int width, int height)
+{
+ const int end = width * height;
+ int offset = 0;
+ while (offset < end)
+ {
+ const int run = (unsigned char) unmarshallByte(th);
+ const int value = um(th);
+
+ for (int i = 0; i < run; ++i)
+ {
+ const int y = offset / width;
+ const int x = offset % width;
+ g[x][y] = value;
+ ++offset;
+ }
+ }
+}
+
union float_marshall_kludge
{
// [ds] Does ANSI C guarantee that sizeof(float) == sizeof(long)?
@@ -1350,6 +1400,8 @@ static void tag_construct_level(struct tagHeader &th)
}
}
+ run_length_encode(th, marshallByte, env.grid_colours, GXM, GYM);
+
marshallShort(th, env.cloud_no);
// how many clouds?
@@ -1577,6 +1629,9 @@ static void tag_read_level( struct tagHeader &th, char minorVersion )
}
}
+ env.grid_colours.init(BLACK);
+ run_length_decode(th, unmarshallByte, env.grid_colours, GXM, GYM);
+
env.cloud_no = unmarshallShort(th);
// how many clouds?