Merge lp:~widelands-dev/widelands/warehouse_fix into lp:widelands

Proposed by cghislai
Status: Merged
Merged at revision: 6690
Proposed branch: lp:~widelands-dev/widelands/warehouse_fix
Merge into: lp:widelands
Diff against target: 105 lines (+39/-6)
4 files modified
src/logic/player.cc (+7/-1)
src/logic/warehouse.cc (+21/-5)
src/logic/warehouse.h (+6/-0)
src/wui/warehousewindow.cc (+5/-0)
To merge this branch: bzr merge lp:~widelands-dev/widelands/warehouse_fix
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+177279@code.launchpad.net

Description of the change

Two fixes for warehouses.
- Correctly reassign all incorporated workers to the dismantlingsite when dismantling. Previously, this was not done and workers started to become fugitive.
- Hide the carrier button in the option window. This will prevent infinite creation of carrier if one decide to empty them.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

I am slightly confused. Why does it say this is merged? Trunk does definitely not contain the new code. Could it be that you branched and merged your different branches from each other instead from trunk?

however, the code looks fine. Just a nit

upcast(Warehouse, wh, building);
if (wh)

can be written as

if (upcast(Warehouse, wh, building))

review: Approve
Revision history for this message
SirVer (sirver) wrote :

Charly, could you comment on what went wrong here?

Revision history for this message
cghislai (charlyghislain) wrote :

Yes I think this is it. For small changes, like here, I once tried to push them in a branch, then revert locally to trunk, and commit locally other changes that would be pushed elsewhere. So I didn't have to recompile the whole codebase to test them.

Weird stuff happened, I will avoid working that way in the future.

Revision history for this message
SirVer (sirver) wrote :

i strongly suggest using ccache (http://ccache.samba.org/). I also use this (but without the repoalias plugin) which makes bzr better for me: http://www.taoeffect.com/blog/2009/06/using-bazaar-like-git-repoalias-plugin/.

 What about these changes here? Can you get them into trunk manually somehow?

Revision history for this message
cghislai (charlyghislain) wrote :

Thanks for pointing me to ccache, I will try that. Otherwise I already use bzr kindof like git, with a shared repo, but I should try the method of that guy.

Concerning this branch I will make a patch and apply to trunk

Revision history for this message
SirVer (sirver) wrote :

I did not see a commit message for this. Have you done this already?

Revision history for this message
cghislai (charlyghislain) wrote :

yes it is in r6711

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/player.cc'
2--- src/logic/player.cc 2013-07-26 20:19:36 +0000
3+++ src/logic/player.cc 2013-07-28 09:14:26 +0000
4@@ -642,7 +642,13 @@
5 // Get workers and soldiers
6 // Make copies of the vectors, because the originals are destroyed with
7 // the building.
8- const std::vector<Worker *> workers = building->get_workers();
9+ std::vector<Worker *> workers;
10+ upcast(Warehouse, wh, building);
11+ if (wh) {
12+ workers = wh->get_incorporated_workers();
13+ } else {
14+ workers = building->get_workers();
15+ }
16
17 building->remove(egbase()); // no fire or stuff
18 // Hereafter the old building does not exist and building is a dangling
19
20=== modified file 'src/logic/warehouse.cc'
21--- src/logic/warehouse.cc 2013-07-26 20:19:36 +0000
22+++ src/logic/warehouse.cc 2013-07-28 09:14:26 +0000
23@@ -542,14 +542,14 @@
24
25 const WareList & workers = get_workers();
26
27+ // This will empty the stock and launch all workers
28+ // including incorporated ones
29 for (Ware_Index id = Ware_Index::First(); id < workers.get_nrwareids(); ++id) {
30 const uint32_t stock = workers.stock(id);
31
32- if (stock > 0) {
33- for (uint32_t i = 0; i < stock; ++i) {
34- launch_worker(game, id, Requirements()).start_task_leavebuilding
35- (game, true);
36- }
37+ for (uint32_t i = 0; i < stock; ++i) {
38+ launch_worker(game, id, Requirements()).start_task_leavebuilding
39+ (game, true);
40 }
41 }
42
43@@ -747,6 +747,19 @@
44 return m_supply->get_workers();
45 }
46
47+PlayerImmovable::Workers Warehouse::get_incorporated_workers()
48+{
49+ PlayerImmovable::Workers all_workers;
50+ container_iterate(IncorporatedWorkers, m_incorporated_workers, cpair) {
51+ WorkerList & clist = cpair->second;
52+ container_iterate(WorkerList, clist, w) {
53+ all_workers.push_back(*w.current);
54+ }
55+ }
56+ return all_workers;
57+}
58+
59+
60 /// Magically create wares in this warehouse. Updates the economy accordingly.
61 void Warehouse::insert_wares(Ware_Index const id, uint32_t const count)
62 {
63@@ -902,6 +915,9 @@
64 // FIXME And even such workers should be removed and only a small record
65 // FIXME with the experience (and possibly other data that must survive)
66 // FIXME may be kept.
67+ // FIXME When this is done, the get_incorporated_workers method above must
68+ // FIXME be reworked so that workers are recreated, and rescheduled for
69+ // FIXME incorporation.
70 if (dynamic_cast<Carrier const *>(&w)) {
71 w.remove(egbase);
72 return;
73
74=== modified file 'src/logic/warehouse.h'
75--- src/logic/warehouse.h 2013-07-26 20:19:36 +0000
76+++ src/logic/warehouse.h 2013-07-28 09:14:26 +0000
77@@ -140,6 +140,12 @@
78 const WareList & get_wares() const;
79 const WareList & get_workers() const;
80
81+ /**
82+ * Returns a vector of all incorporated workers. These are the workers
83+ * that are still present in the game, not just a stock figure.
84+ */
85+ Workers get_incorporated_workers();
86+
87 void insert_wares (Ware_Index, uint32_t count);
88 void remove_wares (Ware_Index, uint32_t count);
89 void insert_workers(Ware_Index, uint32_t count);
90
91=== modified file 'src/wui/warehousewindow.cc'
92--- src/wui/warehousewindow.cc 2013-07-26 20:19:36 +0000
93+++ src/wui/warehousewindow.cc 2013-07-28 09:14:26 +0000
94@@ -64,6 +64,11 @@
95 {
96 set_inner_size(width, 0);
97 add_warelist(type == Widelands::wwWORKER ? m_warehouse.get_workers() : m_warehouse.get_wares());
98+ if (type == Widelands::wwWORKER) {
99+ Widelands::Ware_Index carrier_index =
100+ m_warehouse.descr().tribe().worker_index("carrier");
101+ hide_ware(carrier_index);
102+ }
103 }
104
105 void WarehouseWaresDisplay::draw_ware(RenderTarget & dst, Widelands::Ware_Index ware)

Subscribers

People subscribed via source and target branches

to status/vote changes: