[Commits] [wesnoth/wesnoth] b64c40: fixup inefficient invisibility calculation for uni...

GitHub noreply at github.com
Wed Jul 2 22:35:00 UTC 2014


  Branch: refs/heads/1.12
  Home:   https://github.com/wesnoth/wesnoth
  Commit: b64c4041371318f48c0031c6797558b6e7f3807f
      https://github.com/wesnoth/wesnoth/commit/b64c4041371318f48c0031c6797558b6e7f3807f
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-07-02 (Wed, 02 Jul 2014)

  Changed paths:
    M src/unit.cpp

  Log Message:
  -----------
  fixup inefficient invisibility calculation for units

Units have a function with signature
bool unit::invisible(const map_location & loc, bool see_all)

which determines whether the unit, if it is invisible, would be
revealed if it were moved to map_location & loc.

The implementation of this function was needlessly inefficient, it
requires us to loop through the entire unit_map (all of the units)
to determine if any of them could ambush the unit.

However, in the course of this check, it filters out any units
whose location is not adjacent to the target location.

This function is called constantly whenever the display is updated
or the minimap is drawn, or when a unit is moved.

The improved implementation does not loop over all units, instead
it gets the list of (6) map locations which could be adjacent and
have a unit, and then queries for a unit at each of those
locations.


  Commit: 5d17951f825577bef5c270586bd720102ec8ef33
      https://github.com/wesnoth/wesnoth/commit/5d17951f825577bef5c270586bd720102ec8ef33
  Author: Chris Beck <render787 at gmail.com>
  Date:   2014-07-02 (Wed, 02 Jul 2014)

  Changed paths:
    M changelog

  Log Message:
  -----------
  update changelog


Compare: https://github.com/wesnoth/wesnoth/compare/fb12e0243ac3...5d17951f8255


More information about the Commits mailing list