Hi all,
first I'm new to this mailing list but I'm enjoying BfW for quite a time
now.
Thanks for the work.
So, there was a little something bothering me in the game :
on beginning of turn, when lots of units are healed,
the order in which the healing is displayed appear (for the player) quite
random.
In worst cases, the screen juste goes forth and back
although for examples some units are packed around a healer.
I propose this little patch,
the idea is to sort healed unit according to their position on the map
to minimize map movement.
Of course, there is room for improvement here,
but I wanted to give the idea with concrete material.
Code is based on wesnoth-1.6.5 and compiles just fine on my debian box.
Here's the patch :
diff --git a/actions.cpp b/actions.cpp
index 944fc1b..49d7bfc 100644
--- a/actions.cpp
+++ b/actions.cpp
@@ -36,6 +36,7 @@
#include <boost/scoped_ptr.hpp>
+#include <list>
#define DBG_NG LOG_STREAM(debug, engine)
#define LOG_NG LOG_STREAM(info, engine)
@@ -1672,11 +1673,26 @@ void reset_resting(unit_map& units, unsigned int
side)
}
}
+struct unit_healing_struct {
+ unit *healed;
+ map_location *healed_loc;
+ std::vector<unit_map::iterator> *healers;
+ int healing;
+
+ static
+ bool uhs_compare(struct unit_healing_struct &a,
+ struct unit_healing_struct &b) {
+ return *a.healed_loc < *b.healed_loc;
+ }
+
+};
+
void calculate_healing(game_display& disp, const gamemap& map,
unit_map& units, unsigned int side,
const std::vector<team>& teams, bool update_display)
{
DBG_NG << "beginning of healing calculations\n";
+ 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) {
@@ -1833,7 +1849,13 @@ void calculate_healing(game_display& disp, const
gamemap& map,
&& update_display
&& !(i->second.invisible(i->first,units,teams) &&
teams[disp.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);
@@ -1841,6 +1863,15 @@ void calculate_healing(game_display& disp, const
gamemap& map,
i->second.take_hit(-healing);
disp.invalidate_unit();
}
+
+ // display healing
+ l.sort(unit_healing_struct::uhs_compare);
+ for (std::list<struct unit_healing_struct>::iterator i = l.begin();
+ i != l.end();
+ i++) {
+ unit_display::unit_healing(*i->healed, *i->healed_loc,
*i->healers,
+ i->healing);
+ }
DBG_NG << "end of healing calculations\n";
}
Have a nice day,
BBT
_______________________________________________
Wesnoth-dev mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-dev