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

Proposed by GunChleoc
Status: Merged
Merged at revision: 7619
Proposed branch: lp:~widelands-dev/widelands/warehouse_worker
Merge into: lp:widelands
Diff against target: 81 lines (+15/-15)
2 files modified
src/logic/warehouse.cc (+14/-14)
src/logic/warehouse.h (+1/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/warehouse_worker
Reviewer Review Type Date Requested Status
TiborB Approve
Review via email: mp+277221@code.launchpad.net

Description of the change

Fixed bug in warehouse where check was done for ware instead of worker.

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

I just opened the bug bug-1515161 - this is probably the same issue ...

Revision history for this message
GunChleoc (gunchleoc) wrote :

Yes, that's the one.

Revision history for this message
TiborB (tiborb95) wrote :

It seems that crash is gone, I left small question in diff

Revision history for this message
GunChleoc (gunchleoc) wrote :

Answered :)

Revision history for this message
TiborB (tiborb95) wrote :

good then, go ahead, this really needs fixing fast

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/warehouse.cc'
2--- src/logic/warehouse.cc 2015-10-18 15:42:01 +0000
3+++ src/logic/warehouse.cc 2015-11-11 09:47:46 +0000
4@@ -858,19 +858,19 @@
5 /// Start a worker of a given type. The worker will
6 /// be assigned a job by the caller.
7 Worker & Warehouse::launch_worker
8- (Game & game, WareIndex ware, const Requirements & req)
9+ (Game & game, WareIndex worker_id, const Requirements & req)
10 {
11 do {
12- if (m_supply->stock_workers(ware)) {
13- uint32_t unincorporated = m_supply->stock_workers(ware);
14+ if (m_supply->stock_workers(worker_id)) {
15+ uint32_t unincorporated = m_supply->stock_workers(worker_id);
16
17 // look if we got one of those in stock
18- if (m_incorporated_workers.count(ware)) {
19+ if (m_incorporated_workers.count(worker_id)) {
20 // On cleanup, it could be that the worker was deleted under
21 // us, so we erase the pointer we had to it and create a new
22 // one.
23- remove_no_longer_existing_workers(game, &m_incorporated_workers[ware]);
24- WorkerList& incorporated_workers = m_incorporated_workers[ware];
25+ remove_no_longer_existing_workers(game, &m_incorporated_workers[worker_id]);
26+ WorkerList& incorporated_workers = m_incorporated_workers[worker_id];
27
28 for (std::vector<Worker *>::iterator worker_iter = incorporated_workers.begin();
29 worker_iter != incorporated_workers.end(); ++worker_iter)
30@@ -883,30 +883,30 @@
31 worker->set_location(this); // back in a economy
32 incorporated_workers.erase(worker_iter);
33
34- m_supply->remove_workers(ware, 1);
35+ m_supply->remove_workers(worker_id, 1);
36 return *worker;
37 }
38 }
39 }
40
41- assert(unincorporated <= m_supply->stock_workers(ware));
42+ assert(unincorporated <= m_supply->stock_workers(worker_id));
43
44 if (unincorporated) {
45 // Create a new one
46 // NOTE: This code lies about the TrainingAttributes of the new worker
47- m_supply->remove_workers(ware, 1);
48- const WorkerDescr & workerdescr = *game.tribes().get_worker_descr(ware);
49+ m_supply->remove_workers(worker_id, 1);
50+ const WorkerDescr & workerdescr = *game.tribes().get_worker_descr(worker_id);
51 return workerdescr.create(game, owner(), this, m_position);
52 }
53 }
54
55- if (can_create_worker(game, ware)) {
56+ if (can_create_worker(game, worker_id)) {
57 // don't want to use an upgraded worker, so create new one.
58- create_worker(game, ware);
59+ create_worker(game, worker_id);
60 } else {
61- ware = game.tribes().get_worker_descr(ware)->becomes();
62+ worker_id = game.tribes().get_worker_descr(worker_id)->becomes();
63 }
64- } while (owner().tribe().has_ware(ware));
65+ } while (owner().tribe().has_worker(worker_id));
66
67 throw wexception
68 ("Warehouse::launch_worker: worker does not actually exist");
69
70=== modified file 'src/logic/warehouse.h'
71--- src/logic/warehouse.h 2015-11-01 10:11:56 +0000
72+++ src/logic/warehouse.h 2015-11-11 09:47:46 +0000
73@@ -173,7 +173,7 @@
74 bool fetch_from_flag(Game &) override;
75
76 uint32_t count_workers(const Game &, WareIndex, const Requirements &);
77- Worker & launch_worker(Game &, WareIndex, const Requirements &);
78+ Worker & launch_worker(Game &, WareIndex worker, const Requirements &);
79
80 // Adds the worker to the inventory. Takes ownership and might delete
81 // 'worker'.

Subscribers

People subscribed via source and target branches

to status/vote changes: