diff options
author | Shmuale Mark <shm.mark@gmail.com> | 2014-06-19 16:05:04 -0400 |
---|---|---|
committer | Shmuale Mark <shm.mark@gmail.com> | 2014-06-22 10:03:45 -0400 |
commit | 465957cba490a2a9d5444a64523572a90cfb837f (patch) | |
tree | 536c94ce0702e60217120aa2bb27325aff1b8f2d /crawl-ref/source/main.cc | |
parent | 393eda0d444702a7eda580e6c363bbdcaba8d54e (diff) | |
download | crawl-ref-465957cba490a2a9d5444a64523572a90cfb837f.tar.gz crawl-ref-465957cba490a2a9d5444a64523572a90cfb837f.zip |
The great mon-stuff migration.
A good deal of functions move to the two new files, mon-poly and
mon-message. Of the others, some go to where they are used, some to
mon-util, and a few are made member methods of monster.
This probably breaks Xcode compilation, and I'm not able to test
the changes I made to MSVC that will (hopefully) keep it working.
Diffstat (limited to 'crawl-ref/source/main.cc')
-rw-r--r-- | crawl-ref/source/main.cc | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc index 3a42f1f31c..feb5f8a0ed 100644 --- a/crawl-ref/source/main.cc +++ b/crawl-ref/source/main.cc @@ -93,7 +93,7 @@ #include "mon-act.h" #include "mon-abil.h" #include "mon-cast.h" -#include "mon-stuff.h" +#include "mon-place.h" #include "mon-transit.h" #include "mon-util.h" #include "mutation.h" @@ -3036,6 +3036,38 @@ static void _move_player(int move_x, int move_y) _move_player(coord_def(move_x, move_y)); } +// Swap monster to this location. Player is swapped elsewhere. +static bool _swap_places(monster* mons, const coord_def &loc) +{ + ASSERT(map_bounds(loc)); + ASSERT(monster_habitable_grid(mons, grd(loc))); + + if (monster_at(loc)) + { + if (mons->type == MONS_WANDERING_MUSHROOM + && monster_at(loc)->type == MONS_TOADSTOOL) + { + monster_swaps_places(mons, loc - mons->pos()); + return true; + } + else + { + mpr("Something prevents you from swapping places."); + return false; + } + } + + mpr("You swap places."); + + mgrd(mons->pos()) = NON_MONSTER; + + mons->moveto(loc); + + mgrd(mons->pos()) = mons->mindex(); + + return true; +} + static void _move_player(coord_def move) { ASSERT(!crawl_state.game_is_arena() && !crawl_state.arena_suspended); @@ -3363,7 +3395,7 @@ static void _move_player(coord_def move) } if (swap) - swap_places(targ_monst, mon_swap_dest); + _swap_places(targ_monst, mon_swap_dest); else if (you.duration[DUR_COLOUR_SMOKE_TRAIL]) { check_place_cloud(CLOUD_MAGIC_TRAIL, you.pos(), |