← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug1170086 into lp:widelands

 

cghislai has proposed merging lp:~widelands-dev/widelands/bug1170086 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1170086 in widelands: "Imperial sentry returns more wares when dismantled than it needed"
  https://bugs.launchpad.net/widelands/+bug/1170086

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug1170086/+merge/176406

Introduce new buildcost sections:
[buildcost] [return_on_dismantle] for buildable buildings
[enhancement_cost] [return_on_dismantle_on_enhanced] for enhanced buildings

This is used to calculate buildcosts and returned wares.
A vector of former building descs is kept in the Building class to easily track down the various enhancement performed.
The map loader has been updated so this vector is correctly initialized. The linked bug behaviour will be observed when loading a game saved in the old format, as we can't figure out if building was built as enhancement or directly.

I tested the compatibility save games, all worked fine. I tested saves made with the trunk version and loaded with this branch version, with construction sites, dismantle sites and various enhancements.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug1170086/+merge/176406
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug1170086 into lp:widelands.
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc	2013-07-21 08:25:22 +0000
+++ src/logic/building.cc	2013-07-23 14:58:30 +0000
@@ -145,8 +145,19 @@
 		}
 
 		// Get costs
-		Section & buildcost_s = prof.get_safe_section("buildcost");
-		m_buildcost.parse(m_tribe, buildcost_s);
+		if (m_buildable) {
+			Section & buildcost_s = prof.get_safe_section("buildcost");
+			m_buildcost.parse(m_tribe, buildcost_s);
+			Section & returnsect_s = prof.get_safe_section("return_on_dismantle");
+			m_return_dismantle.parse(m_tribe, returnsect_s);
+		}
+
+		if (m_enhanced_building) {
+			Section & en_buildcost_s = prof.get_safe_section("enhancement_cost");
+			m_enhance_cost.parse(m_tribe, en_buildcost_s);
+			Section & en_returnsect_s = prof.get_safe_section("return_on_dismantle_on_enhanced");
+			m_return_enhanced.parse(m_tribe, en_returnsect_s);
+		}
 	} else if (m_global) {
 		//  get build icon for global buildings (for statistics window)
 		m_buildicon_fname  = directory;
@@ -174,13 +185,16 @@
 	 Player               &       owner,
 	 Coords                 const pos,
 	 bool                   const construct,
-	 Building_Descr const * const old,
-	 bool                         loading)
+	 bool                         loading,
+	 Building::FormerBuildings const former_buildings)
 	const
 {
-	Building & b = construct ? create_constructionsite(old) : create_object();
+	Building & b = construct ? create_constructionsite() : create_object();
 	b.m_position = pos;
 	b.set_owner(&owner);
+	BOOST_FOREACH(const Building_Descr * descr, former_buildings) {
+		b.m_old_buildings.push_back(descr);
+	}
 	if (loading) {
 		b.Building::init(egbase);
 		return b;
@@ -229,12 +243,9 @@
 /*
 ===============
 Create a construction site for this type of building
-
-if old != 0 this is an enhancement from an older building
 ===============
 */
-Building & Building_Descr::create_constructionsite
-	(Building_Descr const * const old) const
+Building & Building_Descr::create_constructionsite() const
 {
 	Building_Descr const * const descr =
 		m_tribe.get_building_descr
@@ -242,8 +253,6 @@
 	ConstructionSite & csite =
 		ref_cast<ConstructionSite, Map_Object>(descr->create_object());
 	csite.set_building(*this);
-	if (old)
-		csite.set_previous_building(old);
 
 	return csite;
 }

=== modified file 'src/logic/building.h'
--- src/logic/building.h	2013-07-19 16:13:42 +0000
+++ src/logic/building.h	2013-07-23 14:58:30 +0000
@@ -68,7 +68,26 @@
 	bool is_destructible() const {return m_destructible;}
 	bool is_enhanced    () const {return m_enhanced_building;}
 	bool global() const {return m_global;}
+
+	/**
+	 * The build cost for direct construction
+	 */
 	const Buildcost & buildcost() const throw () {return m_buildcost;}
+
+	/**
+	 * Returned wares for dismantling
+	 */
+	const Buildcost & returned_wares() const throw () {return m_return_dismantle;}
+
+	/**
+	 * The build cost for enhancing a previous building
+	 */
+	const Buildcost & enhancement_cost() const throw () {return m_enhance_cost;}
+
+	/**
+	 * The returned wares for a enhaced building
+	 */
+	const Buildcost & returned_wares_enhanced() const throw () {return m_return_enhanced;}
 	const Image* get_buildicon() const {return m_buildicon;}
 	int32_t get_size() const throw () {return m_size;}
 	bool get_ismine() const {return m_mine;}
@@ -82,20 +101,22 @@
 		m_enhancements.insert(i);
 	}
 
+	typedef std::vector<const Building_Descr*> FormerBuildings;
+
 	/// Create a building of this type in the game. Calls init, which does
 	/// different things for different types of buildings (such as conquering
 	/// land and requesting things). Therefore this must not be used to allocate
 	/// a building during savegame loading. (It would cause many bugs.)
 	///
 	/// Does not perform any sanity checks.
-	/// If old != 0 this is an enhancing.
+	/// If former_buildings is not empty this is an enhancing.
 	Building & create
 		(Editor_Game_Base &,
 		 Player &,
 		 Coords,
 		 bool                   construct,
-		 Building_Descr const * old = 0,
-		 bool                   loading = false)
+		 bool                   loading = false,
+		 FormerBuildings former_buildings = FormerBuildings())
 		const;
 #ifdef WRITE_GAME_DATA_AS_HTML
 	void writeHTML(::FileWrite &) const;
@@ -115,13 +136,16 @@
 
 protected:
 	virtual Building & create_object() const = 0;
-	Building & create_constructionsite(Building_Descr const * old) const;
+	Building & create_constructionsite() const;
 
 private:
 	const Tribe_Descr & m_tribe;
 	bool          m_buildable;       // the player can build this himself
 	bool          m_destructible;    // the player can destruct this himself
 	Buildcost     m_buildcost;
+	Buildcost     m_return_dismantle; // Returned wares on dismantle
+	Buildcost     m_enhance_cost;     // cost for enhancing
+	Buildcost     m_return_enhanced;   // Returned ware for dismantling an enhanced building
 	const Image*     m_buildicon;       // if buildable: picture in the build dialog
 	std::string   m_buildicon_fname; // filename for this icon
 	int32_t       m_size;            // size of the building
@@ -211,6 +235,19 @@
 		return descr().enhancements();
 	}
 
+	typedef std::vector<const Building_Descr*> FormerBuildings;
+
+	/**
+	 * The former buildings vector keeps track of all former buildings
+	 * that have been enhanced up to the current one. The current building
+	 * descr will be in the last position. For construction sites, it is
+	 * empty except if a former building is being enhanced. For a dismantle
+	 * site, the last item will be the one being dismantled.
+	 */
+	const FormerBuildings get_former_buildings() {
+		return m_old_buildings;
+	}
+
 	virtual void log_general_info(const Editor_Game_Base &);
 
 	//  Use on training sites only.
@@ -233,7 +270,6 @@
 		 const std::string & description,
 		 uint32_t throttle_time = 0,
 		 uint32_t throttle_radius = 0);
-
 protected:
 	void start_animation(Editor_Game_Base &, uint32_t anim);
 
@@ -273,6 +309,9 @@
 
 	// Signals connected for the option window
 	std::vector<boost::signals::connection> options_window_connections;
+
+	// The former buildings descrs, with the current one in last position.
+	FormerBuildings m_old_buildings;
 };
 
 }

=== modified file 'src/logic/constructionsite.cc'
--- src/logic/constructionsite.cc	2013-07-21 14:36:52 +0000
+++ src/logic/constructionsite.cc	2013-07-23 14:58:30 +0000
@@ -74,7 +74,6 @@
 
 ConstructionSite::ConstructionSite(const ConstructionSite_Descr & cs_descr) :
 Partially_Finished_Building (cs_descr),
-m_prev_building  (0),
 m_fetchfromflag  (0),
 m_builder_idle   (false)
 {}
@@ -122,20 +121,6 @@
 }
 
 /*
- * Set previous building
- * That is the building that was here before, we're
- * an enhancement
- */
-void ConstructionSite::set_previous_building
-	(Building_Descr const * const previous_building_descr)
-{
-	assert(!m_prev_building);
-
-	m_prev_building = previous_building_descr;
-	m_info.was = previous_building_descr;
-}
-
-/*
 ===============
 Initialize the construction site by starting orders
 ===============
@@ -144,13 +129,21 @@
 {
 	Partially_Finished_Building::init(egbase);
 
+	const std::map<Ware_Index, uint8_t> * buildcost;
+	if (!m_old_buildings.empty()) {
+		// Enhancement
+		m_info.was = m_old_buildings.back();
+		buildcost = &m_building->enhancement_cost();
+	} else {
+		buildcost = &m_building->buildcost();
+	}
+
 	//  TODO figure out whether planing is necessary
 
 	//  initialize the wares queues
-	const std::map<Ware_Index, uint8_t> & buildcost = m_building->buildcost();
-	size_t const buildcost_size = buildcost.size();
+	size_t const buildcost_size = buildcost->size();
 	m_wares.resize(buildcost_size);
-	std::map<Ware_Index, uint8_t>::const_iterator it = buildcost.begin();
+	std::map<Ware_Index, uint8_t>::const_iterator it = buildcost->begin();
 
 	for (size_t i = 0; i < buildcost_size; ++i, ++it) {
 		WaresQueue & wq =
@@ -176,8 +169,9 @@
 
 	if (m_work_steps <= m_work_completed) {
 		// Put the real building in place
+		m_old_buildings.push_back(m_building);
 		Building & b =
-			m_building->create(egbase, owner(), m_position, false);
+			m_building->create(egbase, owner(), m_position, false, false, m_old_buildings);
 		if (Worker * const builder = m_builder.get(egbase)) {
 			builder->reset_tasks(ref_cast<Game, Editor_Game_Base>(egbase));
 			builder->set_location(&b);
@@ -204,7 +198,7 @@
 	if (m_work_completed >= m_work_steps)
 		return false; // completed, so don't burn
 
-	return m_work_completed or m_prev_building;
+	return m_work_completed or !m_old_buildings.empty();
 }
 
 /*
@@ -392,14 +386,15 @@
 	if (cur_frame) //  not the first pic
 		//  draw the prev pic from top to where next image will be drawing
 		dst.drawanimrect(pos, anim, tanim - FRAME_LENGTH, get_owner(), Rect(Point(0, 0), w, h - lines));
-	else if (m_prev_building) {
+	else if (!m_old_buildings.empty()) {
+		const Building_Descr* prev_building = m_old_buildings.back();
 		//  Is the first picture but there was another building here before,
 		//  get its most fitting picture and draw it instead.
 		uint32_t a;
 		try {
-			a = m_prev_building->get_animation("unoccupied");
+			a = prev_building->get_animation("unoccupied");
 		} catch (Map_Object_Descr::Animation_Nonexistent &) {
-			a = m_prev_building->get_animation("idle");
+			a = prev_building->get_animation("idle");
 		}
 		uint32_t wa, ha;
 		g_gr->get_animation_size(a, tanim, wa, ha);

=== modified file 'src/logic/constructionsite.h'
--- src/logic/constructionsite.h	2013-07-14 10:38:26 +0000
+++ src/logic/constructionsite.h	2013-07-23 14:58:30 +0000
@@ -77,7 +77,6 @@
 	virtual WaresQueue & waresqueue(Ware_Index);
 
 	virtual void set_building(const Building_Descr &);
-	void set_previous_building(const Building_Descr * const);
 	const Building_Descr & building() const throw () {return *m_building;}
 
 	virtual void init   (Editor_Game_Base &);
@@ -99,8 +98,6 @@
 	virtual void draw(const Editor_Game_Base &, RenderTarget &, const FCoords&, const Point&);
 
 private:
-	const Building_Descr * m_prev_building; // Building standing here earlier
-
 	int32_t  m_fetchfromflag;  // # of items to fetch from flag
 
 	bool     m_builder_idle;   // used to determine whether the builder is idle

=== modified file 'src/logic/dismantlesite.cc'
--- src/logic/dismantlesite.cc	2013-07-18 06:31:11 +0000
+++ src/logic/dismantlesite.cc	2013-07-23 14:58:30 +0000
@@ -18,6 +18,7 @@
  */
 
 #include <cstdio>
+#include <boost/foreach.hpp>
 
 #include "upcast.h"
 #include "wexception.h"
@@ -65,11 +66,15 @@
 
 DismantleSite::DismantleSite
 	(const DismantleSite_Descr & gdescr, Editor_Game_Base & egbase, Coords const c,
-	 Player & plr, const Building_Descr & bdscr, bool loading)
+	 Player & plr, bool loading, Building::FormerBuildings & former_buildings)
 :
 Partially_Finished_Building(gdescr)
 {
-	set_building(bdscr);
+	assert(!former_buildings.empty());
+	BOOST_FOREACH(const Building_Descr* old_descr, former_buildings) {
+		m_old_buildings.push_back(old_descr);
+	}
+	set_building(*m_old_buildings.back());
 
 	m_position = c;
 	set_owner(&plr);
@@ -105,7 +110,7 @@
 	Partially_Finished_Building::init(egbase);
 
 	std::map<Ware_Index, uint8_t> wares;
-	count_returned_wares(*m_building, wares);
+	count_returned_wares(this, wares);
 
 	std::map<Ware_Index, uint8_t>::const_iterator it = wares.begin();
 	m_wares.resize(wares.size());
@@ -125,35 +130,23 @@
 ===============
 */
 void DismantleSite::count_returned_wares
-	(const Widelands::Building_Descr & building,
+	(Building* building,
 	 std::map<Ware_Index, uint8_t>   & res)
 {
-	const Tribe_Descr & t = building.tribe();
-	Building_Descr const * bd = &building;
-	Building_Index bd_idx = t.building_index(bd->name());
+	BOOST_FOREACH(const Building_Descr* former_descr, building->get_former_buildings()) {
+		const std::map<Ware_Index, uint8_t> * return_wares;
+		if (former_descr != building->get_former_buildings().front()) {
+			return_wares = & former_descr->returned_wares_enhanced();
+		} else {
+			return_wares = & former_descr->returned_wares();
+		}
+		assert(return_wares != nullptr);
 
-	bool done = false;
-	while (not done) {
-		const std::map<Ware_Index, uint8_t> & buildcost = bd->buildcost();
-		for (std::map<Ware_Index, uint8_t>::const_iterator i = buildcost.begin(); i != buildcost.end(); ++i)
+		std::map<Ware_Index, uint8_t>::const_iterator i;
+		for (i = return_wares->begin(); i != return_wares->end(); ++i) {
 			res[i->first] += i->second;
-
-		// Find the (first) predecessor of this building
-		for (Building_Index i = Building_Index::First(); i < t.get_nrbuildings(); ++i) {
-			Building_Descr const * ob = t.get_building_descr(i);
-			if (ob->enhancements().count(bd_idx)) {
-				done = false;
-				bd = ob;
-				bd_idx = i;
-				break;
-			} else
-				done = true;
 		}
 	}
-
-	for (std::map<Ware_Index, uint8_t>::iterator it = res.begin(); it != res.end(); ++it) {
-		it->second = (it->second + RATIO_RETURNED_WARES - 1) / RATIO_RETURNED_WARES;
-	}
 }
 
 

=== modified file 'src/logic/dismantlesite.h'
--- src/logic/dismantlesite.h	2013-07-14 10:38:26 +0000
+++ src/logic/dismantlesite.h	2013-07-23 14:58:30 +0000
@@ -55,7 +55,6 @@
 	friend struct Map_Buildingdata_Data_Packet;
 
 	static const uint32_t DISMANTLESITE_STEP_TIME = 45000;
-	static const uint8_t RATIO_RETURNED_WARES = 2;  // you get half the wares back
 
 	MO_DESCR(DismantleSite_Descr);
 
@@ -63,7 +62,7 @@
 	DismantleSite(const DismantleSite_Descr & descr);
 	DismantleSite
 		(const DismantleSite_Descr & descr, Editor_Game_Base &,
-		 Coords const, Player &, const Building_Descr &, bool);
+		 Coords const, Player &, bool, Building::FormerBuildings & former_buildings);
 
 	char const * type_name() const throw () {return "dismantlesite";}
 	virtual std::string get_statistics_string();
@@ -73,7 +72,7 @@
 
 	virtual bool get_building_work(Game &, Worker &, bool success);
 
-	static void count_returned_wares(const Building_Descr & building, std::map<Ware_Index, uint8_t> & res);
+	static void count_returned_wares(Building* building, std::map<Ware_Index, uint8_t> & res);
 
 protected:
 	virtual uint32_t build_step_time() const {return DISMANTLESITE_STEP_TIME;}

=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc	2013-02-10 19:36:24 +0000
+++ src/logic/editor_game_base.cc	2013-07-23 14:58:30 +0000
@@ -297,11 +297,14 @@
  * \li idx is the building type index.
  */
 Building & Editor_Game_Base::warp_building
-	(Coords const c, Player_Number const owner, Building_Index const idx)
+	(Coords const c, Player_Number const owner, Building_Index const idx,
+		Building::FormerBuildings former_buildings)
 {
 	Player & plr = player(owner);
 	const Tribe_Descr & tribe = plr.tribe();
-	return tribe.get_building_descr(idx)->create(*this, plr, c, false, 0, true);
+	return 
+		tribe.get_building_descr(idx)->create
+			(*this, plr, c, false, true, former_buildings);
 }
 
 
@@ -312,13 +315,14 @@
  */
 Building & Editor_Game_Base::warp_constructionsite
 	(Coords const c, Player_Number const owner,
-	 Building_Index idx, Building_Index old_id, bool loading)
+	 Building_Index idx, bool loading,
+	 Building::FormerBuildings former_buildings)
 {
 	Player            & plr   = player(owner);
 	const Tribe_Descr & tribe = plr.tribe();
 	return
 		tribe.get_building_descr(idx)->create
-			(*this, plr, c, true, old_id ? tribe.get_building_descr(old_id) : 0, loading);
+			(*this, plr, c, true, loading, former_buildings);
 }
 
 /**
@@ -326,7 +330,7 @@
  */
 Building & Editor_Game_Base::warp_dismantlesite
 	(Coords const c, Player_Number const owner,
-	 Building_Index idx, bool loading)
+	 bool loading, Building::FormerBuildings former_buildings)
 {
 	Player            & plr   = player(owner);
 	const Tribe_Descr & tribe = plr.tribe();
@@ -339,7 +343,7 @@
 
 	return
 		*new DismantleSite
-			(*ds_descr, *this, c, *get_player(owner), *tribe.get_building_descr(idx), loading);
+			(*ds_descr, *this, c, *get_player(owner), loading, former_buildings);
 }
 
 

=== modified file 'src/logic/editor_game_base.h'
--- src/logic/editor_game_base.h	2013-07-08 03:59:31 +0000
+++ src/logic/editor_game_base.h	2013-07-23 14:58:30 +0000
@@ -106,12 +106,15 @@
 	void set_road(FCoords, uint8_t direction, uint8_t roadtype);
 
 	// warping stuff. instantly creating map_objects
-	Building & warp_building(Coords, Player_Number, Building_Index);
+	Building & warp_building
+		(Coords, Player_Number, Building_Index,
+		Building::FormerBuildings former_buildings = Building::FormerBuildings());
 	Building & warp_constructionsite
-		(Coords, Player_Number, Building_Index,
-		 Building_Index oldid = Building_Index::Null(), bool loading = false);
+		(Coords, Player_Number, Building_Index, bool loading = false,
+		 Building::FormerBuildings former_buildings = Building::FormerBuildings());
 	Building & warp_dismantlesite
-		(Coords, Player_Number, Building_Index, bool loading = false);
+		(Coords, Player_Number, bool loading = false,
+		Building::FormerBuildings former_buildings = Building::FormerBuildings());
 	Bob & create_bob(Coords, const Bob::Descr &, Player * owner = 0);
 	Bob & create_bob
 		(Coords, Bob::Descr::Index, Tribe_Descr const * const = 0, Player * owner = 0);

=== modified file 'src/logic/player.cc'
--- src/logic/player.cc	2013-07-15 05:18:12 +0000
+++ src/logic/player.cc	2013-07-23 14:58:30 +0000
@@ -638,8 +638,7 @@
 		 and
 		 (!index_of_new_building or building->descr().enhancements().count(index_of_new_building)))
 	{
-		Building_Index const index_of_old_building =
-			tribe().building_index(building->name().c_str());
+		Building::FormerBuildings former_buildings = building->get_former_buildings();
 		const Coords position = building->get_position();
 
 		//  Get workers and soldiers
@@ -653,11 +652,11 @@
 		if (index_of_new_building)
 			building =
 				&egbase().warp_constructionsite
-					(position, m_plnum, index_of_new_building, index_of_old_building);
+					(position, m_plnum, index_of_new_building, false, former_buildings);
 		else
 			building =
 				&egbase().warp_dismantlesite
-					(position, m_plnum, index_of_old_building);
+					(position, m_plnum, false, former_buildings);
 		//  Hereafter building points to the new building.
 
 		// Reassign the workers and soldiers.

=== modified file 'src/map_io/widelands_map_building_data_packet.cc'
--- src/map_io/widelands_map_building_data_packet.cc	2013-02-10 19:36:24 +0000
+++ src/map_io/widelands_map_building_data_packet.cc	2013-07-23 14:58:30 +0000
@@ -75,7 +75,7 @@
 						//  Get the tribe and the building index.
 						if (Player * const player = egbase.get_safe_player(p)) {
 							const Tribe_Descr & tribe = player->tribe();
-							Building_Index const index = tribe.building_index(name);
+							const Building_Index index = tribe.building_index(name);
 							if (not index)
 								throw game_data_error
 									("tribe %s does not define building type \"%s\"",
@@ -84,13 +84,17 @@
 							//  Now, create this Building, take extra special care for
 							//  constructionsites. All data is read later.
 							Building * building;
-							if (special_type == 1) // Constructionsite
+							if (special_type == 1) { // Constructionsite
 								  building = &egbase.warp_constructionsite
-									  	(c, p, index, Building_Index::Null(), true);
-							else if (special_type == 2) // DismantleSite
-								  building = &egbase.warp_dismantlesite (c, p, index, true);
-							else
+									  	(c, p, index, true);
+							} else if (special_type == 2) {// DismantleSite
+								Building::FormerBuildings formers;
+								const Building_Descr* former_desc = tribe.get_building_descr(index);
+								formers.push_back(former_desc);
+								  building = &egbase.warp_dismantlesite (c, p, true, formers);
+							} else {
 								  building = &egbase.warp_building(c, p, index);
+							}
 
 							mol.register_object<Building> (serial, *building);
 

=== modified file 'src/map_io/widelands_map_buildingdata_data_packet.cc'
--- src/map_io/widelands_map_buildingdata_data_packet.cc	2013-07-21 08:07:18 +0000
+++ src/map_io/widelands_map_buildingdata_data_packet.cc	2013-07-23 14:58:30 +0000
@@ -46,15 +46,18 @@
 #include "upcast.h"
 
 #include <map>
+#include <boost/foreach.hpp>
 
 namespace Widelands {
 
 // Versions
-#define CURRENT_PACKET_VERSION 2
+// Since V3: m_old_buildings vector
+#define CURRENT_PACKET_VERSION 3
 
 // Subversions
 #define CURRENT_DISMANTLESITE_PACKET_VERSION    1
-#define CURRENT_CONSTRUCTIONSITE_PACKET_VERSION 2
+// Since V3: m_prev_building not written
+#define CURRENT_CONSTRUCTIONSITE_PACKET_VERSION 3
 #define CURRENT_PARTIALLYFB_PACKET_VERSION      1
 #define CURRENT_WAREHOUSE_PACKET_VERSION        6
 #define CURRENT_MILITARYSITE_PACKET_VERSION     4
@@ -142,12 +145,23 @@
 							throw game_data_error
 								("leave allow item (%u): %s", leaver_serial, e.what());
 						}
-					else
+					else {
 						building.m_leave_allow = 0;
-
+					}
+					if (packet_version >= 3) {
+						// For former versions, the former buildings vector
+						// will be built after other data are loaded, see below.
+						// read_formerbuildings_v2()
+						while (fr.Unsigned8()) {
+							const Building_Descr* former_descr =
+								building.descr().tribe().get_building_descr
+								(building.descr().tribe().safe_building_index(fr.CString()));
+							building.m_old_buildings.push_back(former_descr);
+						}
+					}
 					if (fr.Unsigned8()) {
 						if (upcast(ProductionSite, productionsite, &building))
-							if (dynamic_cast<MilitarySite const *>(productionsite))
+							if (dynamic_cast<MilitarySite const *>(productionsite)) {
 								log
 									("WARNING: Found a stopped %s at (%i, %i) in the "
 									 "savegame. Militarysites are not stoppable. "
@@ -155,8 +169,9 @@
 									 building.descname().c_str(),
 									 building.get_position().x,
 									 building.get_position().y);
-							else
+							} else {
 								productionsite->set_stopped(true);
+							}
 						else
 							log
 								("WARNING: Found a stopped %s at (%i, %i) in the "
@@ -170,48 +185,53 @@
 					//  Set economy now, some stuff below will count on this.
 					building.set_economy(building.m_flag->get_economy());
 
-					if (upcast(ConstructionSite, constructionsite, &building))
+					if (upcast(ConstructionSite, constructionsite, &building)) {
 						read_constructionsite
 							(*constructionsite,
 							 fr,
 							 ref_cast<Game, Editor_Game_Base>(egbase),
 							 mol);
-					else if (upcast(DismantleSite, dms, &building))
+					} else if (upcast(DismantleSite, dms, &building)) {
 						read_dismantlesite
 							(*dms,
 							 fr,
 							 ref_cast<Game, Editor_Game_Base>(egbase),
 							 mol);
-					else if (upcast(Warehouse, warehouse, &building))
+					} else if (upcast(Warehouse, warehouse, &building)) {
 						read_warehouse
 							(*warehouse,
 							 fr,
 							 ref_cast<Game, Editor_Game_Base>(egbase),
 							 mol);
-					else if (upcast(ProductionSite, productionsite, &building)) {
-						if (upcast(MilitarySite, militarysite, productionsite))
+					} else if (upcast(ProductionSite, productionsite, &building)) {
+						if (upcast(MilitarySite, militarysite, productionsite)) {
 							read_militarysite
 								(*militarysite,
 								 fr,
 								 ref_cast<Game, Editor_Game_Base>(egbase),
 								 mol);
-						else if (upcast(TrainingSite, trainingsite, productionsite))
+						} else if (upcast(TrainingSite, trainingsite, productionsite)) {
 							read_trainingsite
 								(*trainingsite,
 								 fr,
 								 ref_cast<Game, Editor_Game_Base>(egbase),
 								 mol);
-						else
+						} else {
 							read_productionsite
 								(*productionsite,
 								 fr,
 								 ref_cast<Game, Editor_Game_Base>(egbase),
 								 mol);
-					} else
+						}
+					} else {
 						//  type of building is not one of (or derived from)
 						//  {ConstructionSite, Warehouse, ProductionSite}
 						assert(false);
-
+					}
+					if (packet_version < 3) {
+						read_formerbuildings_v2
+							(building, fr, ref_cast<Game, Editor_Game_Base>(egbase), mol);
+					}
 
 					mol.mark_object_as_loaded(building);
 				} catch (const _wexception & e) {
@@ -226,6 +246,43 @@
 	}
 }
 
+void Map_Buildingdata_Data_Packet::read_formerbuildings_v2
+	(Building& b, FileRead&, Game&, Map_Map_Object_Loader&)
+{
+	// add the current building - not for csite or dismantle
+	if (is_a(ProductionSite, &b)) {
+		assert(b.m_old_buildings.empty());
+		b.m_old_buildings.push_back(&b.descr());
+	} else if (is_a(Warehouse, &b)) {
+		assert(b.m_old_buildings.empty());
+		b.m_old_buildings.push_back(&b.descr());
+	} else if (upcast(DismantleSite, dsite, &b)) {
+		b.m_old_buildings.push_back(dsite->m_building);
+	} else if (is_a(ConstructionSite, &b)) {
+		return;
+	}
+
+	// iterate through all buildings to find first predecessor
+	bool done = false;
+	const Tribe_Descr & t = b.descr().tribe();
+	while (not done) {
+		const Building_Descr * oldest = b.m_old_buildings.front();
+		if (!oldest->is_enhanced()) {
+			done = true;
+			break;
+		}
+		const Building_Index & oldest_idx = t.building_index(oldest->name());
+		for (Building_Index i = Building_Index::First(); i < t.get_nrbuildings(); ++i) {
+			Building_Descr const * ob = t.get_building_descr(i);
+			if (ob->enhancements().count(oldest_idx)) {
+				b.m_old_buildings.insert(b.m_old_buildings.begin(), ob);
+				break;
+			}
+		}
+	}
+}
+
+
 void Map_Buildingdata_Data_Packet::read_partially_finished_building
 	(Partially_Finished_Building  & pfb,
 	 FileRead              & fr,
@@ -298,7 +355,7 @@
 		if (packet_version == 1)
 			return read_constructionsite_v1(constructionsite, fr, game, mol);
 
-		if (packet_version == CURRENT_CONSTRUCTIONSITE_PACKET_VERSION) {
+		if (packet_version >= 2) {
 			read_partially_finished_building(constructionsite, fr, game, mol);
 
 			const Tribe_Descr & tribe = constructionsite.tribe();
@@ -308,12 +365,14 @@
 					(*cur)->set_callback
 						(ConstructionSite::wares_queue_callback, &constructionsite);
 
-			if (fr.Unsigned8()) {
-				constructionsite.m_prev_building =
-					tribe.get_building_descr
-					(tribe.safe_building_index(fr.CString()));
-			} else
-				constructionsite.m_prev_building = 0;
+			if (packet_version <= 2) {
+				if (fr.Unsigned8()) {
+					const Building_Descr* former_descr =
+						tribe.get_building_descr
+						(tribe.safe_building_index(fr.CString()));
+					constructionsite.m_old_buildings.push_back(former_descr);
+				}
+			}
 
 			constructionsite.m_fetchfromflag  = fr.  Signed32();
 		} else
@@ -334,11 +393,11 @@
 	constructionsite.m_building =
 		tribe.get_building_descr(tribe.safe_building_index(fr.CString()));
 	if (fr.Unsigned8()) {
-		constructionsite.m_prev_building =
+		const Building_Descr * former_descr =
 			tribe.get_building_descr
 			(tribe.safe_building_index(fr.CString()));
-	} else
-		constructionsite.m_prev_building = 0;
+		constructionsite.m_old_buildings.push_back(former_descr);
+	}
 
 	delete constructionsite.m_builder_request;
 	if (fr.Unsigned8()) {
@@ -1251,8 +1310,16 @@
 			{
 				assert(mos.is_object_known(*o));
 				fw.Unsigned32(mos.get_object_file_index(*o));
-			} else
+			} else {
 				fw.Unsigned32(0);
+			}
+			{
+				BOOST_FOREACH(const Building_Descr* former_descr, building->m_old_buildings) {
+					fw.Unsigned8(1);
+					fw.String(former_descr->name());
+				}
+				fw.Unsigned8(0);
+			}
 			{
 				bool is_stopped = false;
 				if (upcast(ProductionSite const, productionsite, building))
@@ -1356,12 +1423,6 @@
 
 	write_partially_finished_building(constructionsite, fw, game, mos);
 
-	if (constructionsite.m_prev_building) {
-		fw.Unsigned8(1);
-		fw.String(constructionsite.m_prev_building->name());
-	} else
-		fw.Unsigned8(0);
-
 	fw.Signed32(constructionsite.m_fetchfromflag);
 }
 

=== modified file 'src/map_io/widelands_map_buildingdata_data_packet.h'
--- src/map_io/widelands_map_buildingdata_data_packet.h	2013-02-10 19:36:24 +0000
+++ src/map_io/widelands_map_buildingdata_data_packet.h	2013-07-23 14:58:30 +0000
@@ -34,6 +34,7 @@
 class TrainingSite;
 class ProductionSite;
 class Warehouse;
+class Building;
 
 /*
  * This cares for the data of buildings
@@ -62,6 +63,8 @@
 		(TrainingSite           &, FileRead  &, Game &, Map_Map_Object_Loader &);
 	virtual void read_productionsite
 		(ProductionSite         &, FileRead  &, Game &, Map_Map_Object_Loader &);
+	virtual void read_formerbuildings_v2
+		(Building               &, FileRead  &, Game &, Map_Map_Object_Loader &);
 
 	virtual void write_constructionsite
 		(const ConstructionSite &, FileWrite &, Game &, Map_Map_Object_Saver  &);

=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc	2013-07-21 14:39:24 +0000
+++ src/wui/buildingwindow.cc	2013-07-23 14:58:30 +0000
@@ -266,7 +266,8 @@
 							 g_gr->images().get("pics/but4.png"),
 							 building_descr.get_buildicon(),
 							 std::string(buffer) + "<br><font size=11>" + _("Construction costs:") + "</font><br>" +
-								 waremap_to_richtext(tribe, building_descr.buildcost())); //  button id = building id
+								 waremap_to_richtext(tribe, building_descr.enhancement_cost()));
+					//  button id = building id
 					enhancebtn->sigclicked.connect
 						(boost::bind
 							(&Building_Window::act_enhance,
@@ -297,7 +298,7 @@
 
 		if (m_capscache & Widelands::Building::PCap_Dismantle) {
 			std::map<Widelands::Ware_Index, uint8_t> wares;
-			Widelands::DismantleSite::count_returned_wares(m_building.descr(), wares);
+			Widelands::DismantleSite::count_returned_wares(&m_building, wares);
 			UI::Button * dismantlebtn =
 				new UI::Button
 					(capsbuttons, "dismantle", 0, 0, 34, 34,

=== modified file 'tribes/atlanteans/armoursmithy/conf'
--- tribes/atlanteans/armoursmithy/conf	2011-09-12 17:29:32 +0000
+++ tribes/atlanteans/armoursmithy/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,11 @@
 planks=2
 quartz=1
 
+[return_on_dismantle]
+stone=1
+planks=1
+quartz=1
+
 [working positions]
 armoursmith=1
 

=== modified file 'tribes/atlanteans/bakery/conf'
--- tribes/atlanteans/bakery/conf	2011-10-02 20:13:30 +0000
+++ tribes/atlanteans/bakery/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 planks=2
 stone=3
 
+[return_on_dismantle]
+planks=1
+stone=2
+
 [working positions]
 baker=1
 

=== modified file 'tribes/atlanteans/blackroot_farm/conf'
--- tribes/atlanteans/blackroot_farm/conf	2011-02-06 18:28:59 +0000
+++ tribes/atlanteans/blackroot_farm/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,11 @@
 stone=2
 trunk=4
 
+[return_on_dismantle]
+planks=1
+stone=2
+trunk=1
+
 [aihints]
 space_consumer=true
 build_material=false

=== modified file 'tribes/atlanteans/burners_house/conf'
--- tribes/atlanteans/burners_house/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/burners_house/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 stone=3
 planks=1
 
+[return_on_dismantle]
+trunk=2
+stone=2
+
 [working positions]
 burner=1
 

=== modified file 'tribes/atlanteans/castle/conf'
--- tribes/atlanteans/castle/conf	2013-06-11 16:37:44 +0000
+++ tribes/atlanteans/castle/conf	2013-07-23 14:58:30 +0000
@@ -12,6 +12,11 @@
 diamond=1
 quartz=1
 
+[return_on_dismantle]
+planks=2
+stone=5
+trunk=2
+
 [idle]
 pics=castle_i_??.png
 hotspot=91 91

=== modified file 'tribes/atlanteans/coalmine/conf'
--- tribes/atlanteans/coalmine/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/coalmine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 planks=4
 spidercloth=1
 
+[return_on_dismantle]
+trunk=3
+planks=2
+
 [working positions]
 miner=3
 

=== modified file 'tribes/atlanteans/crystalmine/conf'
--- tribes/atlanteans/crystalmine/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/crystalmine/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,10 @@
 planks=4
 spidercloth=1
 
+[return_on_dismantle]
+trunk=3
+planks=2
+
 [working positions]
 miner=3
 

=== modified file 'tribes/atlanteans/dungeon/conf'
--- tribes/atlanteans/dungeon/conf	2013-04-25 07:11:20 +0000
+++ tribes/atlanteans/dungeon/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,14 @@
 gold=2
 trunk=4
 
+[return_on_dismantle]
+planks=1
+stone=3
+diamond=1
+quartz=1
+gold=1
+trunk=1
+
 [working positions]
 trainer=1
 

=== modified file 'tribes/atlanteans/farm/conf'
--- tribes/atlanteans/farm/conf	2013-03-02 20:35:18 +0000
+++ tribes/atlanteans/farm/conf	2013-07-23 14:58:30 +0000
@@ -7,6 +7,11 @@
 planks=2
 spidercloth=1
 
+[return_on_dismantle]
+trunk=1
+stone=1
+planks=1
+
 [working positions]
 farmer=1
 

=== modified file 'tribes/atlanteans/fish_breeders_house/conf'
--- tribes/atlanteans/fish_breeders_house/conf	2010-01-01 12:32:23 +0000
+++ tribes/atlanteans/fish_breeders_house/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,9 @@
 planks=1
 stone=1
 
+[return_on_dismantle]
+stone=1
+
 [working positions]
 fish_breeder=1
 

=== modified file 'tribes/atlanteans/fishers_house/conf'
--- tribes/atlanteans/fishers_house/conf	2011-09-12 17:29:32 +0000
+++ tribes/atlanteans/fishers_house/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,9 @@
 trunk=1
 planks=2
 
+[return_on_dismantle]
+planks=1
+
 [working positions]
 fisher=1
 

=== modified file 'tribes/atlanteans/foresters_house/conf'
--- tribes/atlanteans/foresters_house/conf	2010-06-23 20:06:13 +0000
+++ tribes/atlanteans/foresters_house/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,10 @@
 planks=1
 stone=1
 
+[return_on_dismantle]
+stone=1
+trunk=1
+
 [working positions]
 forester=1
 

=== modified file 'tribes/atlanteans/goldmine/conf'
--- tribes/atlanteans/goldmine/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/goldmine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 planks=4
 spidercloth=1
 
+[return_on_dismantle]
+trunk=3
+planks=2
+
 [working positions]
 miner=3
 

=== modified file 'tribes/atlanteans/goldweaver/conf'
--- tribes/atlanteans/goldweaver/conf	2011-09-12 17:29:32 +0000
+++ tribes/atlanteans/goldweaver/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 stone=1
 planks=1
 
+[return_on_dismantle]
+trunk=1
+stone=1
+
 [working positions]
 carrier=1
 

=== modified file 'tribes/atlanteans/guardhall/conf'
--- tribes/atlanteans/guardhall/conf	2013-06-11 16:37:44 +0000
+++ tribes/atlanteans/guardhall/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,11 @@
 stone=4
 diamond=1
 
+[return_on_dismantle]
+trunk=1
+planks=1
+stone=3
+
 [idle]
 pics=guardhall_i_??.png
 hotspot=58 72

=== modified file 'tribes/atlanteans/guardhouse/conf'
--- tribes/atlanteans/guardhouse/conf	2013-06-11 16:37:44 +0000
+++ tribes/atlanteans/guardhouse/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,9 @@
 planks=1
 stone=1
 
+[return_on_dismantle]
+stone=1
+
 [idle]
 pics=guardhouse_i_??.png
 hotspot=33 41

=== modified file 'tribes/atlanteans/high_tower/conf'
--- tribes/atlanteans/high_tower/conf	2013-06-11 16:37:44 +0000
+++ tribes/atlanteans/high_tower/conf	2013-07-23 14:58:30 +0000
@@ -7,11 +7,14 @@
 enhanced_building=yes
 prefer_heroes=true
 
-[buildcost]
+[enhancement_cost]
 trunk=1
 planks=1
 stone=2
 
+[return_on_dismantle_on_enhanced]
+stone=1
+
 [idle]
 pics=high_tower_i_??.png
 hotspot=50 73

=== modified file 'tribes/atlanteans/horsefarm/conf'
--- tribes/atlanteans/horsefarm/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/horsefarm/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,10 @@
 stone=2
 planks=1
 
+[return_on_dismantle]
+trunk=1
+stone=2
+
 [working positions]
 horsebreeder=1
 

=== modified file 'tribes/atlanteans/hunters_house/conf'
--- tribes/atlanteans/hunters_house/conf	2010-01-01 12:32:23 +0000
+++ tribes/atlanteans/hunters_house/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,9 @@
 planks=1
 stone=1
 
+[return_on_dismantle]
+stone=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/atlanteans/ironmine/conf'
--- tribes/atlanteans/ironmine/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/ironmine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 planks=4
 spidercloth=1
 
+[return_on_dismantle]
+trunk=2
+planks=2
+
 [working positions]
 miner=3
 

=== modified file 'tribes/atlanteans/labyrinth/conf'
--- tribes/atlanteans/labyrinth/conf	2013-04-25 07:11:20 +0000
+++ tribes/atlanteans/labyrinth/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,14 @@
 diamond=2
 quartz=2
 
+[return_on_dismantle]
+trunk=1
+stone=3
+planks=2
+spidercloth=2
+diamond=1
+quartz=1
+
 [working positions]
 carrier=1
 

=== modified file 'tribes/atlanteans/mill/conf'
--- tribes/atlanteans/mill/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/mill/conf	2013-07-23 14:58:30 +0000
@@ -7,6 +7,11 @@
 stone=3
 planks=2
 
+[return_on_dismantle]
+trunk=1
+stone=2
+planks=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/atlanteans/port/conf'
--- tribes/atlanteans/port/conf	2012-03-14 21:36:03 +0000
+++ tribes/atlanteans/port/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,13 @@
 spidercloth=3
 gold=2
 
+[return_on_dismantle]
+trunk=1
+planks=1
+stone=2
+spidercloth=1
+gold=1
+
 [build]
 pics=port_b_??.png  # 4 frames
 hotspot=74 70

=== modified file 'tribes/atlanteans/quarry/conf'
--- tribes/atlanteans/quarry/conf	2009-12-31 18:15:29 +0000
+++ tribes/atlanteans/quarry/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,9 @@
 trunk=2
 planks=1
 
+[return_on_dismantle]
+trunk=1
+
 [working positions]
 stonecutter=1
 

=== modified file 'tribes/atlanteans/sawmill/conf'
--- tribes/atlanteans/sawmill/conf	2013-03-02 20:35:18 +0000
+++ tribes/atlanteans/sawmill/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,10 @@
 trunk=2
 stone=3
 
+[return_on_dismantle]
+trunk=1
+stone=2
+
 [working positions]
 sawyer=1
 

=== modified file 'tribes/atlanteans/scouts_house/conf'
--- tribes/atlanteans/scouts_house/conf	2011-09-12 17:29:32 +0000
+++ tribes/atlanteans/scouts_house/conf	2013-07-23 14:58:30 +0000
@@ -4,6 +4,9 @@
 trunk=2
 stone=1
 
+[return_on_dismantle]
+trunk=1
+
 [working positions]
 scout=1
 

=== modified file 'tribes/atlanteans/shipyard/conf'
--- tribes/atlanteans/shipyard/conf	2012-02-20 15:54:26 +0000
+++ tribes/atlanteans/shipyard/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,12 @@
 stone=3
 spidercloth=2
 
+[return_on_dismantle]
+trunk=1
+planks=1
+stone=2
+spidercloth=1
+
 [working positions]
 shipwright=1
 

=== modified file 'tribes/atlanteans/small_tower/conf'
--- tribes/atlanteans/small_tower/conf	2013-06-11 16:37:44 +0000
+++ tribes/atlanteans/small_tower/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,10 @@
 planks=2
 stone=2
 
+[return_on_dismantle]
+planks=1
+stone=1
+
 [idle]
 pics=small_tower_i_??.png
 hotspot=42 65

=== modified file 'tribes/atlanteans/smelting_works/conf'
--- tribes/atlanteans/smelting_works/conf	2011-09-12 17:29:32 +0000
+++ tribes/atlanteans/smelting_works/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,9 @@
 planks=1
 spidercloth=1
 
+[return_on_dismantle]
+stone=3
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/atlanteans/smokery/conf'
--- tribes/atlanteans/smokery/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/smokery/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,9 @@
 planks=1
 spidercloth=1
 
+[return_on_dismantle]
+stone=3
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/atlanteans/spiderfarm/conf'
--- tribes/atlanteans/spiderfarm/conf	2013-07-13 17:51:09 +0000
+++ tribes/atlanteans/spiderfarm/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 stone=2
 planks=2
 
+[return_on_dismantle]
+stone=1
+planks=1
+
 [working positions]
 spiderbreeder=1
 

=== modified file 'tribes/atlanteans/toolsmithy/conf'
--- tribes/atlanteans/toolsmithy/conf	2012-02-15 21:25:34 +0000
+++ tribes/atlanteans/toolsmithy/conf	2013-07-23 14:58:30 +0000
@@ -18,6 +18,10 @@
 planks=2
 spidercloth=1
 
+[return_on_dismantle]
+stone=1
+planks=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/atlanteans/tower/conf'
--- tribes/atlanteans/tower/conf	2013-06-11 16:37:44 +0000
+++ tribes/atlanteans/tower/conf	2013-07-23 14:58:30 +0000
@@ -12,6 +12,11 @@
 stone=4
 spidercloth=1
 
+[return_on_dismantle]
+trunk=1
+planks=1
+stone=3
+
 [idle]
 pics=tower_i_??.png
 hotspot=55 60

=== modified file 'tribes/atlanteans/warehouse/conf'
--- tribes/atlanteans/warehouse/conf	2012-03-14 21:36:03 +0000
+++ tribes/atlanteans/warehouse/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,12 @@
 quartz=1
 spidercloth=1
 
+[return_on_dismantle]
+trunk=1
+planks=1
+stone=1
+quartz=1
+
 [idle]
 pics=warehouse_i_??.png  # ???
 hotspot=58 62

=== modified file 'tribes/atlanteans/weaponsmithy/conf'
--- tribes/atlanteans/weaponsmithy/conf	2013-03-02 20:35:18 +0000
+++ tribes/atlanteans/weaponsmithy/conf	2013-07-23 14:58:30 +0000
@@ -15,6 +15,11 @@
 spidercloth=1
 quartz=1
 
+[return_on_dismantle]
+trunk=1
+stone=1
+planks=1
+
 [working positions]
 weaponsmith=1
 

=== modified file 'tribes/atlanteans/weaving-mill/conf'
--- tribes/atlanteans/weaving-mill/conf	2010-03-29 18:52:07 +0000
+++ tribes/atlanteans/weaving-mill/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,11 @@
 stone=4
 planks=2
 
+[return_on_dismantle]
+trunk=1
+stone=3
+planks=1
+
 [working positions]
 weaver=1
 

=== modified file 'tribes/atlanteans/well/conf'
--- tribes/atlanteans/well/conf	2011-09-12 17:29:32 +0000
+++ tribes/atlanteans/well/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 stone=1
 planks=1
 
+[return_on_dismantle]
+trunk=1
+stone=1
+
 [working positions]
 carrier=1
 

=== modified file 'tribes/atlanteans/woodcutters_house/conf'
--- tribes/atlanteans/woodcutters_house/conf	2009-12-31 18:15:29 +0000
+++ tribes/atlanteans/woodcutters_house/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,10 @@
 trunk=2
 planks=1
 
+[return_on_dismantle]
+trunk=1
+planks=1
+
 [working positions]
 woodcutter=1
 

=== modified file 'tribes/barbarians/axefactory/conf'
--- tribes/barbarians/axefactory/conf	2013-03-02 20:35:18 +0000
+++ tribes/barbarians/axefactory/conf	2013-07-23 14:58:30 +0000
@@ -9,13 +9,18 @@
 [aihints]
 build_material=false
 
-[buildcost]
+[enhancement_cost]
 trunk=1
 blackwood=1
 raw_stone=2
 grout=1
 thatchreed=1
 
+[return_on_dismantle_on_enhanced]
+blackwood=1
+raw_stone=1
+grout=1
+
 [working positions]
 blacksmith=1
 

=== modified file 'tribes/barbarians/bakery/conf'
--- tribes/barbarians/bakery/conf	2013-07-13 17:51:09 +0000
+++ tribes/barbarians/bakery/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,11 @@
 raw_stone=2
 thatchreed=2
 
+[return_on_dismantle]
+trunk=1
+blackwood=1
+raw_stone=2
+
 [working positions]
 baker=1
 

=== modified file 'tribes/barbarians/barrier/conf'
--- tribes/barbarians/barrier/conf	2013-06-11 16:37:44 +0000
+++ tribes/barbarians/barrier/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,10 @@
 blackwood=5
 grout=2
 
+[return_on_dismantle]
+blackwood=2
+grout=1
+
 [idle]
 pics=barrier_i_??.png
 hotspot=44 62

=== modified file 'tribes/barbarians/battlearena/conf'
--- tribes/barbarians/battlearena/conf	2013-04-28 04:37:49 +0000
+++ tribes/barbarians/battlearena/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,13 @@
 gold=4
 thatchreed=3
 
+[return_on_dismantle]
+trunk=3
+raw_stone=3
+grout=3
+gold=2
+thatchreed=1
+
 [working positions]
 trainer=1
 

=== modified file 'tribes/barbarians/big_inn/conf'
--- tribes/barbarians/big_inn/conf	2010-04-09 03:31:34 +0000
+++ tribes/barbarians/big_inn/conf	2013-07-23 14:58:30 +0000
@@ -5,11 +5,14 @@
 output=snack
 output=meal
 
-[buildcost]
+[enhancement_cost]
 trunk=1
 grout=3
 thatchreed=2
 
+[return_on_dismantle_on_enhanced]
+grout=2
+
 [working positions]
 innkeeper=2
 

=== modified file 'tribes/barbarians/brewery/conf'
--- tribes/barbarians/brewery/conf	2013-07-13 17:51:09 +0000
+++ tribes/barbarians/brewery/conf	2013-07-23 14:58:30 +0000
@@ -3,11 +3,15 @@
 enhanced_building=yes
 output=strongbeer
 
-[buildcost]
+[enhancement_cost]
 trunk=3
 raw_stone=1
 thatchreed=1
 
+[return_on_dismantle_on_enhanced]
+trunk=1
+raw_stone=1
+
 [working positions]
 master-brewer=1
 brewer=1

=== modified file 'tribes/barbarians/burners_house/conf'
--- tribes/barbarians/burners_house/conf	2013-07-13 17:51:09 +0000
+++ tribes/barbarians/burners_house/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 grout=2
 thatchreed=2
 
+[return_on_dismantle]
+trunk=2
+grout=1
+
 [working positions]
 burner=1
 

=== modified file 'tribes/barbarians/cattlefarm/conf'
--- tribes/barbarians/cattlefarm/conf	2013-07-13 17:51:09 +0000
+++ tribes/barbarians/cattlefarm/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,10 @@
 raw_stone=2
 blackwood=1
 
+[return_on_dismantle]
+raw_stone=1
+blackwood=1
+
 [working positions]
 cattlebreeder=1
 

=== modified file 'tribes/barbarians/citadel/conf'
--- tribes/barbarians/citadel/conf	2013-06-11 16:37:44 +0000
+++ tribes/barbarians/citadel/conf	2013-07-23 14:58:30 +0000
@@ -6,12 +6,18 @@
 enhanced_building=yes
 prefer_heroes=true
 
-[buildcost]
+[enhancement_cost]
 blackwood=9
 trunk=5
 raw_stone=4
 grout=2
 
+[return_on_dismantle_on_enhanced]
+blackwood=4
+trunk=2
+raw_stone=3
+grout=1
+
 [build]
 pics=citadel_b_??.png
 hotspot=102 102

=== modified file 'tribes/barbarians/coalmine/conf'
--- tribes/barbarians/coalmine/conf	2011-09-02 12:36:04 +0000
+++ tribes/barbarians/coalmine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 trunk=4
 raw_stone=2
 
+[return_on_dismantle]
+trunk=2
+raw_stone=1
+
 [working positions]
 miner=1
 

=== modified file 'tribes/barbarians/deep_coalmine/conf'
--- tribes/barbarians/deep_coalmine/conf	2011-09-02 12:36:04 +0000
+++ tribes/barbarians/deep_coalmine/conf	2013-07-23 14:58:30 +0000
@@ -4,10 +4,14 @@
 output=coal
 enhancement=deeper_coalmine
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 raw_stone=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+raw_stone=1
+
 [working positions]
 chief-miner=1
 miner=1

=== modified file 'tribes/barbarians/deep_goldmine/conf'
--- tribes/barbarians/deep_goldmine/conf	2011-09-02 12:36:04 +0000
+++ tribes/barbarians/deep_goldmine/conf	2013-07-23 14:58:30 +0000
@@ -4,10 +4,14 @@
 output=goldstone
 enhancement=deeper_goldmine
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 raw_stone=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+raw_stone=1
+
 [working positions]
 chief-miner=1
 miner=1

=== modified file 'tribes/barbarians/deep_oremine/conf'
--- tribes/barbarians/deep_oremine/conf	2011-09-02 12:36:04 +0000
+++ tribes/barbarians/deep_oremine/conf	2013-07-23 14:58:30 +0000
@@ -4,10 +4,14 @@
 output=ironore
 enhancement=deeper_oremine
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 raw_stone=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+raw_stone=1
+
 [working positions]
 chief-miner=1
 miner=1

=== modified file 'tribes/barbarians/deeper_coalmine/conf'
--- tribes/barbarians/deeper_coalmine/conf	2012-02-15 21:25:34 +0000
+++ tribes/barbarians/deeper_coalmine/conf	2013-07-23 14:58:30 +0000
@@ -3,10 +3,14 @@
 enhanced_building=yes
 output=coal
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 raw_stone=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+raw_stone=1
+
 [working positions]
 master-miner=1
 chief-miner=1

=== modified file 'tribes/barbarians/deeper_goldmine/conf'
--- tribes/barbarians/deeper_goldmine/conf	2012-02-15 21:25:34 +0000
+++ tribes/barbarians/deeper_goldmine/conf	2013-07-23 14:58:30 +0000
@@ -3,10 +3,14 @@
 enhanced_building=yes
 output=goldstone
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 raw_stone=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+raw_stone=1
+
 [working positions]
 master-miner=1
 chief-miner=1

=== modified file 'tribes/barbarians/deeper_oremine/conf'
--- tribes/barbarians/deeper_oremine/conf	2011-09-02 12:36:04 +0000
+++ tribes/barbarians/deeper_oremine/conf	2013-07-23 14:58:30 +0000
@@ -3,10 +3,14 @@
 enhanced_building=yes
 output=ironore
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 raw_stone=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+raw_stone=1
+
 [working positions]
 master-miner=1
 chief-miner=1

=== modified file 'tribes/barbarians/donjon/conf'
--- tribes/barbarians/donjon/conf	2013-06-11 16:37:44 +0000
+++ tribes/barbarians/donjon/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,10 @@
 trunk=1
 raw_stone=4
 
+[return_on_dismantle]
+blackwood=3
+raw_stone=3
+
 [build]
 pics=donjon_b_??.png
 hotspot=48 84

=== modified file 'tribes/barbarians/farm/conf'
--- tribes/barbarians/farm/conf	2013-03-02 20:35:18 +0000
+++ tribes/barbarians/farm/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,11 @@
 blackwood=1
 raw_stone=3
 
+[return_on_dismantle]
+trunk=1
+blackwood=1
+raw_stone=2
+
 [working positions]
 farmer=1
 

=== modified file 'tribes/barbarians/fernery/conf'
--- tribes/barbarians/fernery/conf	2011-09-12 17:29:32 +0000
+++ tribes/barbarians/fernery/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,10 @@
 trunk=5
 raw_stone=2
 
+[return_on_dismantle]
+trunk=2
+raw_stone=1
+
 [working positions]
 ferner=1
 

=== modified file 'tribes/barbarians/fishers_hut/conf'
--- tribes/barbarians/fishers_hut/conf	2011-09-12 17:29:32 +0000
+++ tribes/barbarians/fishers_hut/conf	2013-07-23 14:58:30 +0000
@@ -4,6 +4,9 @@
 [buildcost]
 trunk=4
 
+[return_on_dismantle]
+trunk=2
+
 [working positions]
 fisher=1
 

=== modified file 'tribes/barbarians/fortress/conf'
--- tribes/barbarians/fortress/conf	2013-06-11 16:37:44 +0000
+++ tribes/barbarians/fortress/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,12 @@
 raw_stone=4
 grout=2
 
+[return_on_dismantle]
+blackwood=4
+trunk=2
+raw_stone=2
+grout=1
+
 [build]
 pics=fortress_b_??.png
 hotspot=103 80

=== modified file 'tribes/barbarians/gamekeepers_hut/conf'
--- tribes/barbarians/gamekeepers_hut/conf	2011-09-12 17:29:32 +0000
+++ tribes/barbarians/gamekeepers_hut/conf	2013-07-23 14:58:30 +0000
@@ -4,6 +4,10 @@
 trunk=4
 raw_stone=1
 
+[return_on_dismantle]
+trunk=1
+raw_stone=1
+
 [working positions]
 gamekeeper=1
 

=== modified file 'tribes/barbarians/goldmine/conf'
--- tribes/barbarians/goldmine/conf	2011-09-02 12:36:04 +0000
+++ tribes/barbarians/goldmine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 trunk=4
 raw_stone=2
 
+[return_on_dismantle]
+trunk=2
+raw_stone=1
+
 [working positions]
 miner=1
 

=== modified file 'tribes/barbarians/granitemine/conf'
--- tribes/barbarians/granitemine/conf	2011-10-03 15:51:56 +0000
+++ tribes/barbarians/granitemine/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,10 @@
 trunk=4
 raw_stone=2
 
+[return_on_dismantle]
+trunk=2
+raw_stone=1
+
 [working positions]
 miner=1
 

=== modified file 'tribes/barbarians/hardener/conf'
--- tribes/barbarians/hardener/conf	2010-04-09 03:31:34 +0000
+++ tribes/barbarians/hardener/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,10 @@
 trunk=3
 raw_stone=1
 
+[return_on_dismantle]
+trunk=1
+raw_stone=1
+
 [working positions] #  like lumberjack
 lumberjack=1
 

=== modified file 'tribes/barbarians/helmsmithy/conf'
--- tribes/barbarians/helmsmithy/conf	2011-10-03 15:51:56 +0000
+++ tribes/barbarians/helmsmithy/conf	2013-07-23 14:58:30 +0000
@@ -13,6 +13,12 @@
 grout=2
 thatchreed=3
 
+[return_on_dismantle]
+trunk=1
+raw_stone=2
+grout=1
+thatchreed=1
+
 [working positions]
 helmsmith=1
 

=== modified file 'tribes/barbarians/hunters_hut/conf'
--- tribes/barbarians/hunters_hut/conf	2011-09-12 17:29:32 +0000
+++ tribes/barbarians/hunters_hut/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,10 @@
 trunk=4
 raw_stone=1
 
+[return_on_dismantle]
+trunk=1
+raw_stone=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/barbarians/inn/conf'
--- tribes/barbarians/inn/conf	2009-04-11 17:14:21 +0000
+++ tribes/barbarians/inn/conf	2013-07-23 14:58:30 +0000
@@ -5,11 +5,15 @@
 output=ration
 output=snack
 
-[buildcost]
+[enhancement_cost]
 trunk=2
 grout=2
 thatchreed=1
 
+[return_on_dismantle_on_enhanced]
+trunk=1
+grout=1
+
 [working positions]
 innkeeper=1
 

=== modified file 'tribes/barbarians/lime_kiln/conf'
--- tribes/barbarians/lime_kiln/conf	2011-09-12 17:29:32 +0000
+++ tribes/barbarians/lime_kiln/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 raw_stone=2
 blackwood=1
 
+[return_on_dismantle]
+trunk=2
+raw_stone=1
+
 [working positions]
 lime-burner=1
 

=== modified file 'tribes/barbarians/lumberjacks_hut/conf'
--- tribes/barbarians/lumberjacks_hut/conf	2012-02-15 21:25:34 +0000
+++ tribes/barbarians/lumberjacks_hut/conf	2013-07-23 14:58:30 +0000
@@ -4,6 +4,9 @@
 [buildcost]
 trunk=3
 
+[return_on_dismantle]
+trunk=2
+
 [working positions]
 lumberjack=1
 

=== modified file 'tribes/barbarians/metalworks/conf'
--- tribes/barbarians/metalworks/conf	2013-03-02 20:35:18 +0000
+++ tribes/barbarians/metalworks/conf	2013-07-23 14:58:30 +0000
@@ -18,6 +18,11 @@
 grout=1
 thatchreed=1
 
+[return_on_dismantle]
+blackwood=1
+raw_stone=1
+grout=1
+
 [working positions]
 blacksmith=1
 

=== modified file 'tribes/barbarians/micro-brewery/conf'
--- tribes/barbarians/micro-brewery/conf	2010-08-01 14:35:38 +0000
+++ tribes/barbarians/micro-brewery/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,11 @@
 raw_stone=3
 thatchreed=2
 
+[return_on_dismantle]
+trunk=1
+blackwood=1
+raw_stone=2
+
 [working positions]
 brewer=1
 

=== modified file 'tribes/barbarians/oremine/conf'
--- tribes/barbarians/oremine/conf	2011-09-02 12:36:04 +0000
+++ tribes/barbarians/oremine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 trunk=4
 raw_stone=2
 
+[return_on_dismantle]
+trunk=2
+raw_stone=1
+
 [working positions]
 miner=1
 

=== modified file 'tribes/barbarians/port/conf'
--- tribes/barbarians/port/conf	2012-03-14 21:36:03 +0000
+++ tribes/barbarians/port/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,15 @@
 thatchreed=4
 gold=2
 
+[return_on_dismantle]
+trunk=1
+blackwood=2
+raw_stone=3
+grout=1
+iron=1
+thatchreed=1
+gold=1
+
 [build]
 pics=port_b_??.png  # 4 frames
 hotspot=67 80

=== modified file 'tribes/barbarians/quarry/conf'
--- tribes/barbarians/quarry/conf	2010-08-01 14:35:38 +0000
+++ tribes/barbarians/quarry/conf	2013-07-23 14:58:30 +0000
@@ -4,6 +4,9 @@
 [buildcost]
 trunk=4
 
+[return_on_dismantle]
+trunk=2
+
 [working positions]
 stonemason=1
 
@@ -20,8 +23,8 @@
 
 [idle]
 pics=b_quarry_i_??.png  # ???
-hotspot=45 40
+hotspot=45 40
 
 [build]
 pics=b_quarry_b_??.png  # ???
-hotspot=44 36
+hotspot=44 36

=== modified file 'tribes/barbarians/rangers_hut/conf'
--- tribes/barbarians/rangers_hut/conf	2010-08-01 14:35:38 +0000
+++ tribes/barbarians/rangers_hut/conf	2013-07-23 14:58:30 +0000
@@ -3,6 +3,9 @@
 [buildcost]
 trunk=4
 
+[return_on_dismantle]
+trunk=3
+
 [working positions]
 ranger=1
 

=== modified file 'tribes/barbarians/scouts_hut/conf'
--- tribes/barbarians/scouts_hut/conf	2010-08-01 14:35:38 +0000
+++ tribes/barbarians/scouts_hut/conf	2013-07-23 14:58:30 +0000
@@ -4,6 +4,10 @@
 trunk=2
 raw_stone=1
 
+[return_on_dismantle]
+trunk=1
+raw_stone=1
+
 [inputs]
 ration=2
 

=== modified file 'tribes/barbarians/sentry/conf'
--- tribes/barbarians/sentry/conf	2013-06-11 16:37:44 +0000
+++ tribes/barbarians/sentry/conf	2013-07-23 14:58:30 +0000
@@ -7,6 +7,9 @@
 [buildcost]
 blackwood=2
 
+[return_on_dismantle]
+blackwood=1
+
 [idle]
 pics=sentry_i_??.png
 hotspot=39 40

=== modified file 'tribes/barbarians/shipyard/conf'
--- tribes/barbarians/shipyard/conf	2012-03-01 16:15:56 +0000
+++ tribes/barbarians/shipyard/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,11 @@
 raw_stone=3
 cloth=2
 
+[return_on_dismantle]
+trunk=1
+blackwood=1
+raw_stone=2
+
 [working positions]
 shipwright=1
 

=== modified file 'tribes/barbarians/smelting_works/conf'
--- tribes/barbarians/smelting_works/conf	2010-11-21 11:44:22 +0000
+++ tribes/barbarians/smelting_works/conf	2013-07-23 14:58:30 +0000
@@ -12,6 +12,11 @@
 grout=1
 thatchreed=2
 
+[return_on_dismantle]
+trunk=1
+blackwood=1
+raw_stone=1
+
 [working positions]
 smelter=1
 

=== modified file 'tribes/barbarians/tavern/conf'
--- tribes/barbarians/tavern/conf	2010-01-01 12:32:23 +0000
+++ tribes/barbarians/tavern/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,11 @@
 raw_stone=1
 thatchreed=1
 
+[return_on_dismantle]
+trunk=1
+blackwood=1
+raw_stone=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/barbarians/trainingscamp/conf'
--- tribes/barbarians/trainingscamp/conf	2013-04-25 07:11:20 +0000
+++ tribes/barbarians/trainingscamp/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,12 @@
 gold=4
 thatchreed=3
 
+[return_on_dismantle]
+trunk=3
+raw_stone=2
+grout=2
+gold=2
+
 [working positions]
 trainer=1
 

=== modified file 'tribes/barbarians/warehouse/conf'
--- tribes/barbarians/warehouse/conf	2012-03-14 21:36:03 +0000
+++ tribes/barbarians/warehouse/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,12 @@
 grout=3
 thatchreed=1
 
+[return_on_dismantle]
+trunk=1
+blackwood=1
+raw_stone=1
+grout=1
+
 [idle]
 pics=warehouse_i_??.png  # ???
 hotspot=58 75

=== modified file 'tribes/barbarians/warmill/conf'
--- tribes/barbarians/warmill/conf	2013-03-02 20:35:18 +0000
+++ tribes/barbarians/warmill/conf	2013-07-23 14:58:30 +0000
@@ -11,13 +11,18 @@
 [aihints]
 build_material=false
 
-[buildcost]
+[enhancement_cost]
 trunk=1
 blackwood=1
 raw_stone=2
 grout=1
 thatchreed=1
 
+[return_on_dismantle_on_enhanced]
+blackwood=1
+raw_stone=1
+grout=1
+
 [working positions]
 master-blacksmith=1
 blacksmith=1

=== modified file 'tribes/barbarians/weaving-mill/conf'
--- tribes/barbarians/weaving-mill/conf	2013-07-13 17:51:09 +0000
+++ tribes/barbarians/weaving-mill/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 raw_stone=2
 thatchreed=2
 
+[return_on_dismantle]
+trunk=2
+raw_stone=2
+
 [working positions]
 weaver=1
 

=== modified file 'tribes/barbarians/well/conf'
--- tribes/barbarians/well/conf	2011-02-20 15:10:35 +0000
+++ tribes/barbarians/well/conf	2013-07-23 14:58:30 +0000
@@ -4,6 +4,9 @@
 [buildcost]
 trunk=4
 
+[return_on_dismantle]
+trunk=2
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/empire/arena/conf'
--- tribes/empire/arena/conf	2013-04-25 07:11:20 +0000
+++ tribes/empire/arena/conf	2013-07-23 14:58:30 +0000
@@ -3,6 +3,21 @@
 soldier_capacity=8
 trainer_patience=8
 
+[buildcost]
+trunk=2
+stone=4
+marble=5
+wood=5
+marblecolumn=2
+
+[return_on_dismantle]
+trunk=1
+stone=3
+marble=3
+wood=2
+marblecolumn=1
+
+
 [working positions]
 carrier=1
 
@@ -37,13 +52,6 @@
 fish=6
 meat=6
 
-[buildcost]
-trunk=2
-stone=4
-marble=5
-wood=5
-marblecolumn=2
-
 [idle]
 pics=arena_i_??.png  # ???
 hotspot=81 82

=== modified file 'tribes/empire/armoursmithy/conf'
--- tribes/empire/armoursmithy/conf	2011-10-03 15:51:56 +0000
+++ tribes/empire/armoursmithy/conf	2013-07-23 14:58:30 +0000
@@ -13,6 +13,11 @@
 marble=2
 marblecolumn=3
 
+[return_on_dismantle]
+stone=1
+marble=1
+marblecolumn=2
+
 [working positions]
 armoursmith=1
 

=== modified file 'tribes/empire/bakery/conf'
--- tribes/empire/bakery/conf	2011-10-03 15:51:56 +0000
+++ tribes/empire/bakery/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 wood=2
 stone=3
 
+[return_on_dismantle]
+wood=1
+stone=2
+
 [working positions]
 baker=1
 

=== modified file 'tribes/empire/barracks/conf'
--- tribes/empire/barracks/conf	2013-06-11 16:37:44 +0000
+++ tribes/empire/barracks/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,9 @@
 trunk=1
 wood=2
 
+[return_on_dismantle]
+wood=1
+
 [idle]
 pics=barracks_i_??.png
 hotspot=37 58

=== modified file 'tribes/empire/barrier/conf'
--- tribes/empire/barrier/conf	2013-06-11 16:37:44 +0000
+++ tribes/empire/barrier/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,21 @@
 stone=2
 marble=1
 
+[return_on_dismantle]
+trunk=1
+wood=1
+stone=1
+
+[enhancement_cost]
+trunk=1
+wood=2
+stone=1
+marble=1
+
+[return_on_dismantle_on_enhanced]
+wood=1
+stone=1
+
 [idle]
 pics=barrier_i_??.png
 hotspot=49 77

=== modified file 'tribes/empire/brewery/conf'
--- tribes/empire/brewery/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/brewery/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 wood=2
 stone=2
 
+[return_on_dismantle]
+wood=1
+stone=1
+
 [working positions]
 brewer=1
 

=== modified file 'tribes/empire/burners_house/conf'
--- tribes/empire/burners_house/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/burners_house/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,11 @@
 stone=2
 marble=2
 
+[return_on_dismantle]
+trunk=1
+stone=1
+marble=1
+
 [working positions]
 burner=1
 

=== modified file 'tribes/empire/castle/conf'
--- tribes/empire/castle/conf	2013-06-11 16:37:44 +0000
+++ tribes/empire/castle/conf	2013-07-23 14:58:30 +0000
@@ -6,12 +6,18 @@
 enhanced_building=yes
 prefer_heroes=true
 
-[buildcost]
+[enhancement_cost]
 wood=5
 marblecolumn=4
 marble=4
 stone=2
 
+[return_on_dismantle_on_enhanced]
+wood=2
+marblecolumn=2
+marble=3
+stone=1
+
 [idle]
 pics=castle_i_??.png
 hotspot=94 106

=== modified file 'tribes/empire/coalmine/conf'
--- tribes/empire/coalmine/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/coalmine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 trunk=4
 wood=2
 
+[return_on_dismantle]
+trunk=2
+wood=1
+
 [working positions]
 miner=1
 

=== modified file 'tribes/empire/colosseum/conf'
--- tribes/empire/colosseum/conf	2013-04-25 07:11:20 +0000
+++ tribes/empire/colosseum/conf	2013-07-23 14:58:30 +0000
@@ -4,7 +4,7 @@
 soldier_capacity=8
 trainer_patience=9
 
-[buildcost]
+[enhancement_cost]
 wood=2
 stone=4
 marble=4
@@ -12,6 +12,13 @@
 gold=4
 marblecolumn=4
 
+[return_on_dismantle_on_enhanced]
+wood=1
+stone=2
+marble=2
+gold=2
+marblecolumn=2
+
 [working positions]
 carrier=1
 

=== modified file 'tribes/empire/deep_coalmine/conf'
--- tribes/empire/deep_coalmine/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/deep_coalmine/conf	2013-07-23 14:58:30 +0000
@@ -3,10 +3,14 @@
 enhanced_building=yes
 output=coal
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 wood=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+wood=1
+
 [working positions]
 master-miner=1
 miner=1

=== modified file 'tribes/empire/deep_goldmine/conf'
--- tribes/empire/deep_goldmine/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/deep_goldmine/conf	2013-07-23 14:58:30 +0000
@@ -3,10 +3,14 @@
 enhanced_building=yes
 output=goldstone
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 wood=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+wood=1
+
 [working positions]
 master-miner=1
 miner=1

=== modified file 'tribes/empire/deep_marblemine/conf'
--- tribes/empire/deep_marblemine/conf	2011-09-02 12:36:04 +0000
+++ tribes/empire/deep_marblemine/conf	2013-07-23 14:58:30 +0000
@@ -4,10 +4,14 @@
 output=marble
 output=stone
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 wood=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+wood=1
+
 [working positions]
 master-miner=1
 miner=1

=== modified file 'tribes/empire/deep_oremine/conf'
--- tribes/empire/deep_oremine/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/deep_oremine/conf	2013-07-23 14:58:30 +0000
@@ -3,10 +3,14 @@
 enhanced_building=yes
 output=ironore
 
-[buildcost]
+[enhancement_cost]
 trunk=4
 wood=2
 
+[return_on_dismantle_on_enhanced]
+trunk=2
+wood=1
+
 [working positions]
 master-miner=1
 miner=1

=== modified file 'tribes/empire/donkeyfarm/conf'
--- tribes/empire/donkeyfarm/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/donkeyfarm/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,10 @@
 stone=2
 wood=1
 
+[return_on_dismantle]
+trunk=1
+stone=2
+
 [working positions]
 donkeybreeder=1
 

=== modified file 'tribes/empire/farm/conf'
--- tribes/empire/farm/conf	2013-03-02 20:35:18 +0000
+++ tribes/empire/farm/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,12 @@
 marble=2
 marblecolumn=2
 
+[return_on_dismantle]
+wood=1
+stone=1
+marble=1
+marblecolumn=1
+
 [working positions]
 farmer=1
 

=== modified file 'tribes/empire/fishers_house/conf'
--- tribes/empire/fishers_house/conf	2011-09-12 17:29:32 +0000
+++ tribes/empire/fishers_house/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,9 @@
 wood=1
 stone=1
 
+[return_on_dismantle]
+stone=1
+
 [working positions]
 fisher=1
 

=== modified file 'tribes/empire/foresters_house/conf'
--- tribes/empire/foresters_house/conf	2011-09-12 17:29:32 +0000
+++ tribes/empire/foresters_house/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,10 @@
 wood=1
 stone=1
 
+[return_on_dismantle]
+wood=1
+stone=1
+
 [working positions]
 forester=1
 

=== modified file 'tribes/empire/fortress/conf'
--- tribes/empire/fortress/conf	2013-06-11 16:37:44 +0000
+++ tribes/empire/fortress/conf	2013-07-23 14:58:30 +0000
@@ -12,6 +12,13 @@
 marble=2
 marblecolumn=2
 
+[return_on_dismantle]
+wood=2
+trunk=1
+stone=5
+marble=1
+marblecolumn=1
+
 [idle]
 pics=fortress_i_??.png
 hotspot=90 105

=== modified file 'tribes/empire/goldmine/conf'
--- tribes/empire/goldmine/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/goldmine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 trunk=4
 wood=2
 
+[return_on_dismantle]
+trunk=2
+wood=1
+
 [working positions]
 miner=1
 

=== modified file 'tribes/empire/hunters_house/conf'
--- tribes/empire/hunters_house/conf	2010-08-01 14:35:38 +0000
+++ tribes/empire/hunters_house/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,9 @@
 wood=1
 stone=1
 
+[return_on_dismantle]
+stone=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/empire/inn/conf'
--- tribes/empire/inn/conf	2012-06-02 09:01:54 +0000
+++ tribes/empire/inn/conf	2013-07-23 14:58:30 +0000
@@ -4,11 +4,15 @@
 output=ration
 output=meal
 
-[buildcost]
+[enhancement_cost]
 wood=2
 marble=2
 marblecolumn=1
 
+[return_on_dismantle_on_enhanced]
+wood=1
+marble=2
+
 [working positions]
 innkeeper=1
 

=== modified file 'tribes/empire/lumberjacks_house/conf'
--- tribes/empire/lumberjacks_house/conf	2010-08-01 14:35:38 +0000
+++ tribes/empire/lumberjacks_house/conf	2013-07-23 14:58:30 +0000
@@ -5,6 +5,10 @@
 trunk=2
 wood=1
 
+[return_on_dismantle]
+trunk=1
+wood=1
+
 [working positions]
 lumberjack=1
 

=== modified file 'tribes/empire/marblemine/conf'
--- tribes/empire/marblemine/conf	2011-09-02 12:36:04 +0000
+++ tribes/empire/marblemine/conf	2013-07-23 14:58:30 +0000
@@ -7,6 +7,10 @@
 trunk=4
 wood=2
 
+[return_on_dismantle]
+trunk=2
+wood=1
+
 [working positions]
 miner=1
 

=== modified file 'tribes/empire/mill/conf'
--- tribes/empire/mill/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/mill/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,11 @@
 stone=3
 marble=1
 
+[return_on_dismantle]
+trunk=1
+stone=2
+marble=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/empire/oremine/conf'
--- tribes/empire/oremine/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/oremine/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 trunk=4
 wood=2
 
+[return_on_dismantle]
+trunk=2
+wood=1
+
 [working positions]
 miner=1
 

=== modified file 'tribes/empire/outpost/conf'
--- tribes/empire/outpost/conf	2013-06-11 16:37:44 +0000
+++ tribes/empire/outpost/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,10 @@
 stone=1
 marble=1
 
+[return_on_dismantle]
+stone=1
+marble=1
+
 [idle]
 pics=outpost_i_??.png
 hotspot=57 77

=== modified file 'tribes/empire/piggery/conf'
--- tribes/empire/piggery/conf	2013-07-13 17:51:09 +0000
+++ tribes/empire/piggery/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,11 @@
 stone=2
 marblecolumn=2
 
+[return_on_dismantle]
+trunk=1
+stone=1
+marble=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/empire/port/conf'
--- tribes/empire/port/conf	2012-03-14 21:36:03 +0000
+++ tribes/empire/port/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,14 @@
 cloth=3
 gold=2
 
+[return_on_dismantle]
+trunk=1
+wood=1
+stone=2
+marble=2
+cloth=1
+gold=1
+
 [build]
 pics=port_b_??.png  # 4 frames
 hotspot=74 96

=== modified file 'tribes/empire/quarry/conf'
--- tribes/empire/quarry/conf	2011-09-12 17:29:32 +0000
+++ tribes/empire/quarry/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,9 @@
 trunk=2
 wood=1
 
+[return_on_dismantle]
+trunk=1
+
 [working positions]
 stonemason=1
 

=== modified file 'tribes/empire/sawmill/conf'
--- tribes/empire/sawmill/conf	2013-03-02 20:35:18 +0000
+++ tribes/empire/sawmill/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 stone=1
 wood=1
 
+[return_on_dismantle]
+trunk=1
+stone=1
+
 [working positions]
 carpenter=1
 

=== modified file 'tribes/empire/scouts_house/conf'
--- tribes/empire/scouts_house/conf	2011-09-12 17:29:32 +0000
+++ tribes/empire/scouts_house/conf	2013-07-23 14:58:30 +0000
@@ -4,6 +4,9 @@
 trunk=2
 stone=1
 
+[return_on_dismantle]
+trunk=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/empire/sentry/conf'
--- tribes/empire/sentry/conf	2013-06-11 16:37:44 +0000
+++ tribes/empire/sentry/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,17 @@
 trunk=1
 stone=1
 
+[return_on_dismantle]
+stone=1
+wood=1
+
+[enhancement_cost]
+wood=1
+stone=1
+
+[return_on_dismantle_on_enhanced]
+stone=1
+
 [idle]
 pics=sentry_i_??.png
 hotspot=37 60

=== modified file 'tribes/empire/sheepfarm/conf'
--- tribes/empire/sheepfarm/conf	2013-03-02 20:35:18 +0000
+++ tribes/empire/sheepfarm/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,10 @@
 stone=2
 wood=2
 
+[return_on_dismantle]
+trunk=1
+stone=2
+
 [working positions]
 shepherd=1
 

=== modified file 'tribes/empire/shipyard/conf'
--- tribes/empire/shipyard/conf	2012-03-01 22:35:05 +0000
+++ tribes/empire/shipyard/conf	2013-07-23 14:58:30 +0000
@@ -9,6 +9,11 @@
 stone=3
 cloth=2
 
+[return_on_dismantle]
+trunk=1
+stone=2
+cloth=1
+
 [working positions]
 shipwright=1
 

=== modified file 'tribes/empire/smelting_works/conf'
--- tribes/empire/smelting_works/conf	2011-10-03 15:51:56 +0000
+++ tribes/empire/smelting_works/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,10 @@
 stone=4
 marble=2
 
+[return_on_dismantle]
+stone=3
+marble=1
+
 [working positions]
 smelter=1
 

=== modified file 'tribes/empire/stonemasons_house/conf'
--- tribes/empire/stonemasons_house/conf	2013-03-02 20:35:18 +0000
+++ tribes/empire/stonemasons_house/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,10 @@
 stone=1
 marble=3 # someone who works on marble should like marble
 
+[return_on_dismantle]
+stone=1
+marble=2
+
 [working positions] #  like quarry
 stonemason=1
 

=== modified file 'tribes/empire/tavern/conf'
--- tribes/empire/tavern/conf	2012-03-15 16:04:17 +0000
+++ tribes/empire/tavern/conf	2013-07-23 14:58:30 +0000
@@ -7,6 +7,11 @@
 stone=2
 marble=1
 
+[return_on_dismantle]
+wood=1
+stone=1
+marble=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/empire/toolsmithy/conf'
--- tribes/empire/toolsmithy/conf	2013-03-02 20:35:18 +0000
+++ tribes/empire/toolsmithy/conf	2013-07-23 14:58:30 +0000
@@ -18,6 +18,10 @@
 marble=2
 marblecolumn=1
 
+[return_on_dismantle]
+stone=1
+marble=2
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/empire/tower/conf'
--- tribes/empire/tower/conf	2013-06-11 16:37:44 +0000
+++ tribes/empire/tower/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,11 @@
 stone=4
 marblecolumn=2
 
+[return_on_dismantle]
+wood=1
+stone=2
+marblecolumn=1
+
 [idle]
 pics=tower_i_??.png
 hotspot=53 81

=== modified file 'tribes/empire/trainingscamp/conf'
--- tribes/empire/trainingscamp/conf	2013-04-25 07:11:20 +0000
+++ tribes/empire/trainingscamp/conf	2013-07-23 14:58:30 +0000
@@ -11,6 +11,13 @@
 marblecolumn=3
 cloth=2
 
+[return_on_dismantle]
+stone=3
+wood=2
+marble=3
+gold=2
+marblecolumn=1
+
 [working positions]
 trainer=1
 

=== modified file 'tribes/empire/vineyard/conf'
--- tribes/empire/vineyard/conf	2011-09-12 17:29:32 +0000
+++ tribes/empire/vineyard/conf	2013-07-23 14:58:30 +0000
@@ -12,6 +12,10 @@
 marble=2
 marblecolumn=2
 
+[return_on_dismantle]
+wood=1
+marble=2
+
 [working positions]
 vinefarmer=1
 

=== modified file 'tribes/empire/warehouse/conf'
--- tribes/empire/warehouse/conf	2012-03-14 21:36:03 +0000
+++ tribes/empire/warehouse/conf	2013-07-23 14:58:30 +0000
@@ -8,6 +8,12 @@
 marble=3
 marblecolumn=2
 
+[return_on_dismantle]
+wood=1
+stone=2
+marble=2
+marblecolumn=1
+
 [idle]
 pics=warehouse_i_??.png  # ???
 hotspot=58 55

=== modified file 'tribes/empire/weaponsmithy/conf'
--- tribes/empire/weaponsmithy/conf	2013-03-02 20:35:18 +0000
+++ tribes/empire/weaponsmithy/conf	2013-07-23 14:58:30 +0000
@@ -14,6 +14,12 @@
 marble=2
 marblecolumn=3
 
+[return_on_dismantle]
+trunk=1
+stone=1
+marble=2
+marblecolumn=1
+
 [working positions]
 weaponsmith=1
 

=== modified file 'tribes/empire/weaving-mill/conf'
--- tribes/empire/weaving-mill/conf	2011-10-03 15:51:56 +0000
+++ tribes/empire/weaving-mill/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 stone=4
 marble=1
 
+[return_on_dismantle]
+trunk=1
+stone=3
+
 [working positions]
 weaver=1
 

=== modified file 'tribes/empire/well/conf'
--- tribes/empire/well/conf	2011-09-12 17:29:32 +0000
+++ tribes/empire/well/conf	2013-07-23 14:58:30 +0000
@@ -6,6 +6,10 @@
 stone=1
 marble=1
 
+[return_on_dismantle]
+trunk=1
+marble=1
+
 [aihints]
 build_material=false
 

=== modified file 'tribes/empire/winery/conf'
--- tribes/empire/winery/conf	2010-08-01 14:35:38 +0000
+++ tribes/empire/winery/conf	2013-07-23 14:58:30 +0000
@@ -10,6 +10,11 @@
 marble=2
 marblecolumn=1
 
+[return_on_dismantle]
+stone=1
+marble=1
+marblecolumn=1
+
 [working positions] #  like brewery
 brewer=1
 


Follow ups