A tweak to the way fog/shroud is cleared during a [teleport] action:

Clear the destination hex before the teleport animation (so it can be
seen), and clear the remaining hexes after the animation (when it
looks like the unit can see them).
This commit is contained in:
J. Tyne 2013-02-05 21:22:34 +00:00
parent 206ea8f6fb
commit 28eef7cfdd
3 changed files with 52 additions and 4 deletions

View File

@ -374,6 +374,45 @@ bool shroud_clearer::clear_unit(const map_location &view_loc, const unit &viewer
}
/**
* Clears shroud (and fog) at the provided location and it immediate neighbors.
* This is an aid for the [teleport] action, allowing the destination to be
* cleared before teleporting, while the unit's full visual range gets cleared
* after.
* The @a viewer is needed for correct firing of sighted events.
*
* @return whether or not information was uncovered (i.e. returns true if the
* locations in question were fogged/shrouded under shared vision/maps).
*/
bool shroud_clearer::clear_dest(const map_location &dest, const unit &viewer)
{
team & viewing_team = (*resources::teams)[viewer.side()-1];
// A pair of dummy variables needed to simplify some logic.
size_t enemies, friends;
// Abort if there is nothing to clear.
if ( !viewing_team.fog_or_shroud() )
return false;
// Clear the destination.
bool cleared_something = clear_loc(viewing_team, dest, viewer, dest, true,
enemies, friends);
// Clear the adjacent hexes (will be seen even if vision is 0, and the
// graphics do not work so well for an isolated cleared hex).
map_location adjacent[6];
get_adjacent_tiles(dest, adjacent);
for ( int i = 0; i != 6; ++i )
cleared_something = clear_loc(viewing_team, adjacent[i], viewer, dest,
true, enemies, friends);
if ( cleared_something )
invalidate_after_clear();
return cleared_something;
}
/**
* Clears the record of sighted events from earlier fog/shroud clearing.
* This should be called if the events are to be ignored and not fired.

View File

@ -74,6 +74,9 @@ public:
bool can_delay = false, bool invalidate = true,
bool instant = false);
/// Clears shroud (and fog) at the provided location and it immediate neighbors.
bool clear_dest(const map_location &dest, const unit &viewer);
/// Erases the record of sighted events from earlier fog/shroud clearing.
void drop_events();

View File

@ -878,9 +878,11 @@ WML_HANDLER_FUNCTION(teleport, event_info, cfg)
const map_location vacant_dst = find_vacant_tile(dst, pathfind::VACANT_ANY, pass_check);
if (!resources::game_map->on_board(vacant_dst)) return;
// Clear the destination hex before the move (so the animation can be seen).
bool clear_shroud = cfg["clear_shroud"].to_bool(true);
actions::shroud_clearer clearer;
if (cfg["clear_shroud"].to_bool(true)) {
clearer.clear_unit(vacant_dst, *u);
if ( clear_shroud ) {
clearer.clear_dest(vacant_dst, *u);
}
map_location src_loc = u->get_location();
@ -897,12 +899,16 @@ WML_HANDLER_FUNCTION(teleport, event_info, cfg)
u = resources::units->find(vacant_dst);
u->set_standing();
if ( clear_shroud ) {
// Now that the unit is visibly in position, clear the shroud.
clearer.clear_unit(vacant_dst, *u);
}
if (resources::game_map->is_village(vacant_dst)) {
actions::get_village(vacant_dst, u->side());
}
resources::screen->invalidate_unit_after_move(src_loc, dst);
resources::screen->invalidate_unit_after_move(src_loc, vacant_dst);
resources::screen->draw();
// Sighted events.