← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~borim/widelands/bug590631 into lp:widelands

 

Borim has proposed merging lp:~borim/widelands/bug590631 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #590631 in widelands: "All workers die, when warehouse/hq is destroyed"
  https://bugs.launchpad.net/widelands/+bug/590631

For more details, see:
https://code.launchpad.net/~borim/widelands/bug590631/+merge/91314

fix for bug #590631:
* launch all workers on warehouse destruction
-- 
https://code.launchpad.net/~borim/widelands/bug590631/+merge/91314
Your team Widelands Developers is requested to review the proposed merge of lp:~borim/widelands/bug590631 into lp:widelands.
=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc	2012-01-26 17:29:07 +0000
+++ src/logic/warehouse.cc	2012-02-02 17:07:28 +0000
@@ -553,6 +553,26 @@
 		m_portdock->set_economy(get_economy());
 }
 
+void Warehouse::destroy(Editor_Game_Base & egbase)
+{
+	Game & game = ref_cast<Game, Editor_Game_Base>(egbase);
+
+	const WareList & workers = get_workers();
+
+	for (Ware_Index id = Ware_Index::First(); id < workers.get_nrwareids(); ++id) {
+		const uint32_t stock = workers.stock(id);
+
+		if (stock > 0) {
+			for (uint32_t i = 0; i < stock; ++i) {
+				launch_worker(game, id, Requirements()).start_task_leavebuilding
+					(game, true);
+			}
+		}
+	}
+
+	Building::destroy(egbase);
+}
+
 /// Destroy the warehouse.
 void Warehouse::cleanup(Editor_Game_Base & egbase)
 {

=== modified file 'src/logic/warehouse.h'
--- src/logic/warehouse.h	2012-01-26 17:29:07 +0000
+++ src/logic/warehouse.h	2012-02-02 17:07:28 +0000
@@ -130,6 +130,8 @@
 
 	virtual void cleanup(Editor_Game_Base &);
 
+	virtual void destroy(Editor_Game_Base &);
+
 	virtual void act(Game & game, uint32_t data);
 
 	virtual void set_economy(Economy *);


Follow ups