summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-13 03:59:23 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-04-13 03:59:23 +0000
commit53fa153719a82b238120b85f3e16644c31a67ff4 (patch)
tree0e028464cbe53d6f521621ad1227e162ad03935c /crawl-ref/source
parent2269f51342b63e5b8670da098b71998d4b4dd901 (diff)
downloadcrawl-ref-53fa153719a82b238120b85f3e16644c31a67ff4.tar.gz
crawl-ref-53fa153719a82b238120b85f3e16644c31a67ff4.zip
When searching for multiple ghosts, also check the transit list. Only applies
to Abyssal ghosts at the moment. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1290 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/externs.h1
-rw-r--r--crawl-ref/source/ghost.cc29
-rw-r--r--crawl-ref/source/mtransit.cc6
-rw-r--r--crawl-ref/source/mtransit.h1
4 files changed, 37 insertions, 0 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 88d10a30fa..ce8360b751 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1144,6 +1144,7 @@ public:
private:
static int n_extra_ghosts();
static void find_extra_ghosts(std::vector<ghost_demon> &ghosts, int n);
+ static void find_transiting_ghosts(std::vector<ghost_demon> &gs, int n);
private:
void add_spells();
diff --git a/crawl-ref/source/ghost.cc b/crawl-ref/source/ghost.cc
index 6bcaa281f0..5216cc4352 100644
--- a/crawl-ref/source/ghost.cc
+++ b/crawl-ref/source/ghost.cc
@@ -15,6 +15,7 @@
#include "skills2.h"
#include "stuff.h"
#include "misc.h"
+#include "mtransit.h"
#include "player.h"
#include <vector>
@@ -459,6 +460,31 @@ std::vector<ghost_demon> ghost_demon::find_ghosts()
return (gs);
}
+void ghost_demon::find_transiting_ghosts(
+ std::vector<ghost_demon> &gs, int n)
+{
+ if (n <= 0)
+ return;
+
+ const m_transit_list *mt = get_transit_list(level_id::current());
+ if (mt)
+ {
+ for (m_transit_list::const_iterator i = mt->begin();
+ i != mt->end() && n > 0; ++i)
+ {
+ if (i->mons.type == MONS_PLAYER_GHOST)
+ {
+ const monsters &m = i->mons;
+ if (m.ghost.get())
+ {
+ gs.push_back(*m.ghost);
+ --n;
+ }
+ }
+ }
+ }
+}
+
void ghost_demon::find_extra_ghosts( std::vector<ghost_demon> &gs, int n )
{
for (int i = 0; n > 0 && i < MAX_MONSTERS; ++i)
@@ -473,6 +499,9 @@ void ghost_demon::find_extra_ghosts( std::vector<ghost_demon> &gs, int n )
--n;
}
}
+
+ // Check the transit list for the current level.
+ find_transiting_ghosts(gs, n);
}
int ghost_demon::n_extra_ghosts()
diff --git a/crawl-ref/source/mtransit.cc b/crawl-ref/source/mtransit.cc
index 09a50543e5..5ceb91449b 100644
--- a/crawl-ref/source/mtransit.cc
+++ b/crawl-ref/source/mtransit.cc
@@ -40,6 +40,12 @@ static void cull_lost(m_transit_list &mlist, int how_many)
mlist.erase( mlist.begin() );
}
+m_transit_list *get_transit_list(level_id lid)
+{
+ monsters_in_transit::iterator i = the_lost_ones.find(lid);
+ return (i != the_lost_ones.end()? &i->second : NULL);
+}
+
void add_monster_to_transit(level_id lid, const monsters &m)
{
m_transit_list &mlist = the_lost_ones[lid];
diff --git a/crawl-ref/source/mtransit.h b/crawl-ref/source/mtransit.h
index 3ffc0adfc8..a660d73645 100644
--- a/crawl-ref/source/mtransit.h
+++ b/crawl-ref/source/mtransit.h
@@ -31,6 +31,7 @@ typedef std::map<level_id, m_transit_list> monsters_in_transit;
extern monsters_in_transit the_lost_ones;
+m_transit_list *get_transit_list(level_id where);
void add_monster_to_transit(level_id dest, const monsters &m);
// Places (some of the) monsters eligible to be placed on this level.