improve healing order, patch by BBT
This commit is contained in:
parent
2f75a1794f
commit
49db3512ee
6 changed files with 67 additions and 6 deletions
|
@ -12,6 +12,7 @@ Version 1.7.7+svn:
|
|||
* Fix storyscreen buttons occasionally disappearing (bug #13779)
|
||||
* Fix not being able to cancel the different version message (bug #14438)
|
||||
* Fix not being able to close corrupted file dialog (bug #13764, #14058)
|
||||
* Improve display order of unit healing (patch #1343)
|
||||
|
||||
Version 1.7.7:
|
||||
* AI:
|
||||
|
|
|
@ -199,6 +199,10 @@
|
|||
comment = "AI"
|
||||
email = "terraninfo_AT_terraninfo.net"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Jean-Baptiste Poittevin (BBT)"
|
||||
email = "babataz_AT_gmail.com"
|
||||
[/entry]
|
||||
[/about]
|
||||
|
||||
[about]
|
||||
|
|
|
@ -13,6 +13,7 @@ Version 1.7.7+svn:
|
|||
|
||||
* User interface:
|
||||
* Fixed storyscreen buttons occasionally disappearing.
|
||||
* Improve display order of unit healing (patch #1343)
|
||||
|
||||
|
||||
Version 1.7.7:
|
||||
|
@ -25,17 +26,17 @@ Version 1.7.7:
|
|||
* New translations: Shavian.
|
||||
* Updated translations: Czech, Dutch, Estonian, Finnish, German, Hungarian,
|
||||
Lithuanian, Russian, Serbian, Slovak, Spanish.
|
||||
|
||||
|
||||
* Multiplayer:
|
||||
* Updated map: The Manzivan Traps
|
||||
|
||||
|
||||
* Units:
|
||||
* Removed Elder Wose and Shock Trooper from random_leader of the default era.
|
||||
* Removed Ancient Wose and Iron Mauler from random_leader of the AoH era.
|
||||
* New animation WML and macros for the Drakes.
|
||||
* Increased the XP required to advance for the Orcish Assassin from 30 to 34.
|
||||
* Changed the cold resistance of the naga line from -20% to 0%.
|
||||
|
||||
|
||||
* User interface:
|
||||
* Add-ons descriptions are displayed according to filtering in
|
||||
the download list.
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <list>
|
||||
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define DBG_NG LOG_STREAM(debug, log_engine)
|
||||
|
@ -1535,11 +1537,22 @@ void reset_resting(unit_map& units, int side)
|
|||
}
|
||||
}
|
||||
|
||||
/* Contains all the data used to display healing */
|
||||
struct unit_healing_struct {
|
||||
unit *healed;
|
||||
map_location *healed_loc;
|
||||
std::vector<unit_map::iterator> *healers;
|
||||
int healing;
|
||||
};
|
||||
|
||||
void calculate_healing(int side, bool update_display)
|
||||
{
|
||||
DBG_NG << "beginning of healing calculations\n";
|
||||
unit_map &units = *resources::units;
|
||||
|
||||
/* list used to display healing after having computed it */
|
||||
std::list<struct unit_healing_struct> l;
|
||||
|
||||
// We look for all allied units, then we see if our healer is near them.
|
||||
for (unit_map::iterator i = units.begin(); i != units.end(); ++i) {
|
||||
|
||||
|
@ -1695,7 +1708,13 @@ void calculate_healing(int side, bool update_display)
|
|||
!(i->second.invisible(i->first, units, *resources::teams) &&
|
||||
(*resources::teams)[resources::screen->viewing_team()].is_enemy(side)))
|
||||
{
|
||||
unit_display::unit_healing(i->second,i->first,healers,healing);
|
||||
struct unit_healing_struct uhs = {
|
||||
&i->second,
|
||||
&i->first,
|
||||
&healers,
|
||||
healing
|
||||
};
|
||||
l.push_front(uhs);
|
||||
}
|
||||
if (healing > 0)
|
||||
i->second.heal(healing);
|
||||
|
@ -1703,6 +1722,42 @@ void calculate_healing(int side, bool update_display)
|
|||
i->second.take_hit(-healing);
|
||||
resources::screen->invalidate_unit();
|
||||
}
|
||||
|
||||
/* display healing with nearest first algorithm */
|
||||
if (!l.empty()) {
|
||||
|
||||
/* the first unit to be healed is chosen arbitrarily */
|
||||
struct unit_healing_struct uhs = l.front();
|
||||
l.pop_front();
|
||||
|
||||
unit_display::unit_healing(*uhs.healed, *uhs.healed_loc,
|
||||
*uhs.healers, uhs.healing);
|
||||
|
||||
/* next unit to be healed is nearest from uhs left in list l */
|
||||
while (!l.empty()) {
|
||||
|
||||
std::list<struct unit_healing_struct>::iterator nearest;
|
||||
int min_d = INT_MAX;
|
||||
|
||||
/* for each unit in l, remember nearest */
|
||||
for (std::list<struct unit_healing_struct>::iterator i = l.begin();
|
||||
i != l.end() ; i++) {
|
||||
//int d = uhs.square_dist(*i);
|
||||
int d = distance_between(*uhs.healed_loc, *i->healed_loc);
|
||||
if (d < min_d) {
|
||||
min_d = d;
|
||||
nearest = i;
|
||||
}
|
||||
}
|
||||
|
||||
uhs = *nearest;
|
||||
l.erase(nearest);
|
||||
|
||||
unit_display::unit_healing(*uhs.healed, *uhs.healed_loc,
|
||||
*uhs.healers, uhs.healing);
|
||||
}
|
||||
}
|
||||
|
||||
DBG_NG << "end of healing calculations\n";
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* @file map.cpp
|
||||
* @file map_location.cpp
|
||||
* Routines related to game-maps, terrain, locations, directions. etc.
|
||||
*/
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ struct map_location {
|
|||
int do_compare(const map_location& a) const {return x == a.x ? y - a.y : x - a.x; }
|
||||
|
||||
// Adds an absolute location to a "delta" location
|
||||
// This is not the mathematically correct behviour, it is neither
|
||||
// This is not the mathematically correct behaviour, it is neither
|
||||
// commutative nor associative. Negative coordinates may give strange
|
||||
// results. It is retained because terain builder code relies in this
|
||||
// broken behaviour. Best avoid.
|
||||
|
|
Loading…
Add table
Reference in a new issue