Author: suokko
Date: Tue Sep 2 22:31:24 2008
New Revision: 29217
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29217&view=rev
Log:
Fixed unit map copying causing double free
Modified:
trunk/src/replay.cpp
trunk/src/unit_map.cpp
Modified: trunk/src/replay.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/replay.cpp?rev=29217&r1=29216&r2=29217&view=diff
==============================================================================
--- trunk/src/replay.cpp (original)
+++ trunk/src/replay.cpp Tue Sep 2 22:31:24 2008
@@ -820,8 +820,6 @@
DBG_REPLAY << "Repaly data at end\n";
}
- ERR_REPLAY << *cfg << "\n";
-
//if we are expecting promotions here
if(advancing_units.empty() == false) {
Modified: trunk/src/unit_map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit_map.cpp?rev=29217&r1=29216&r2=29217&view=diff
==============================================================================
--- trunk/src/unit_map.cpp (original)
+++ trunk/src/unit_map.cpp Tue Sep 2 22:31:24 2008
@@ -48,18 +48,19 @@
*this = that;
}
-unit_map &unit_map::operator =(const unit_map &that)
+unit_map &unit_map::operator=(const unit_map &that)
{
clear();
num_iters_ = 0;
num_invalid_ = 0;
for (umap::const_iterator i = that.map_.begin(); i != that.map_.end();
i++) {
if (i->second.first) {
- add(i->second.second);
+ add(new
std::pair<gamemap::location,unit>(i->second.second->first,
i->second.second->second));
}
}
return *this;
}
+
unit_map::~unit_map()
{
@@ -468,7 +469,8 @@
<< "," << iter->second.second->first.y+1 << ").\n";
}
- DBG_NG << "Adding unit " << p->second.underlying_id() << "\n";
+ DBG_NG << "Adding unit " << p->second.underlying_id()<< " to location:
(" << p->first.x+1 << "," << p->first.y+1
+ << ")\n";
std::pair<lmap::iterator,bool> res =
lmap_.insert(std::pair<gamemap::location,std::string>(p->first, unit_id));
assert(res.second);
@@ -478,7 +480,7 @@
{
if (erase(p->first) != 1)
assert(0);
- DBG_NG << "Replace unit " << p->second.underluig_id() << "\n";
+ DBG_NG << "Replace unit " << p->second.underlying_id() << "\n";
add(p);
}
@@ -486,7 +488,7 @@
{
for (umap::iterator i = map_.begin(); i != map_.end(); ++i) {
if (i->second.first) {
- DBG_NG << "Delete unit " <<
i->second.second.underluig_id() << "\n";
+ DBG_NG << "Delete unit " <<
i->second.second->second.underlying_id() << "\n";
delete(i->second.second);
}
}
@@ -504,7 +506,7 @@
umap::iterator iter = map_.find(i->second);
std::pair<gamemap::location,unit> *res = iter->second.second;
- DBG_NG << "Extract unit " << iter->second << "\n";
+ DBG_NG << "Extract unit " << i->second << "\n";
invalidate(iter);
lmap_.erase(i);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits