Author: silene
Date: Thu May 21 16:57:28 2009
New Revision: 35784
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35784&view=rev
Log:
Added current location to unit data.
Modified:
trunk/src/unit.cpp
trunk/src/unit.hpp
trunk/src/unit_map.cpp
Modified: trunk/src/unit.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=35784&r1=35783&r2=35784&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Thu May 21 16:57:28 2009
@@ -80,6 +80,7 @@
// Copy constructor
unit::unit(const unit& o):
cfg_(o.cfg_),
+ loc_(o.loc_),
advances_to_(o.advances_to_),
type_(o.type_),
race_(o.race_),
Modified: trunk/src/unit.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.hpp?rev=35784&r1=35783&r2=35784&view=diff
==============================================================================
--- trunk/src/unit.hpp (original)
+++ trunk/src/unit.hpp Thu May 21 16:57:28 2009
@@ -219,6 +219,10 @@
int cost () const { return unit_value_; }
+ const map_location &get_location() const { return loc_; }
+ /** To be called by unit_map only. (For now.) */
+ void set_location(const map_location &loc) { loc_ = loc; }
+
const map_location& get_goto() const { return goto_; }
void set_goto(const map_location& new_goto) { goto_ = new_goto; }
@@ -365,6 +369,7 @@
void set_underlying_id();
config cfg_;
+ map_location loc_;
std::vector<std::string> advances_to_;
std::string type_;
Modified: trunk/src/unit_map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_map.cpp?rev=35784&r1=35783&r2=35784&view=diff
==============================================================================
--- trunk/src/unit_map.cpp (original)
+++ trunk/src/unit_map.cpp Thu May 21 16:57:28 2009
@@ -114,11 +114,13 @@
umap::iterator iter = map_.find(unit_id);
if (!p->first.valid()) {
- ERR_NG << "Trying to add " << p->second.name() <<
- " - " << p->second.id() << " at an invalid location;
Discarding.\n";
- delete p;
- return;
- }
+ ERR_NG << "Trying to add " << p->second.name()
+ << " - " << p->second.id() << " at an invalid location;
Discarding.\n";
+ delete p;
+ return;
+ }
+
+ p->second.set_location(p->first);
if (iter == map_.end()) {
map_[unit_id] = node(true, p);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits