widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #09716
[Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands.
Commit message:
Fixed a bug where higher-level workers wouldn't occupy lower-level workers' working position slots in productionsites. Added a test.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1664145 in widelands: "master miners at home bug revival"
https://bugs.launchpad.net/widelands/+bug/1664145
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1664145-miners/+merge/317710
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/warehouse.cc'
--- src/logic/map_objects/tribes/warehouse.cc 2017-02-12 09:10:57 +0000
+++ src/logic/map_objects/tribes/warehouse.cc 2017-02-18 23:36:11 +0000
@@ -742,17 +742,17 @@
* requirements.
*/
Quantity Warehouse::count_workers(const Game& /* game */,
- DescriptionIndex ware,
+ DescriptionIndex worker_id,
const Requirements& req,
Match exact) {
Quantity sum = 0;
do {
- sum += supply_->stock_workers(ware);
+ sum += supply_->stock_workers(worker_id);
// NOTE: This code lies about the TrainingAttributes of non-instantiated workers.
- if (incorporated_workers_.count(ware)) {
- for (Worker* worker : incorporated_workers_[ware]) {
+ if (incorporated_workers_.count(worker_id)) {
+ for (Worker* worker : incorporated_workers_[worker_id]) {
if (!req.check(*worker)) {
// This is one of the workers in our sum.
// But he is too stupid for this job
@@ -761,11 +761,11 @@
}
}
if (exact == Match::kCompatible) {
- ware = owner().tribe().get_worker_descr(ware)->becomes();
+ worker_id = owner().tribe().get_worker_descr(worker_id)->becomes();
} else {
- ware = INVALID_INDEX;
+ worker_id = INVALID_INDEX;
}
- } while (owner().tribe().has_ware(ware));
+ } while (owner().tribe().has_worker(worker_id));
return sum;
}
=== modified file 'src/logic/map_objects/tribes/warehouse.h'
--- src/logic/map_objects/tribes/warehouse.h 2017-01-25 18:55:59 +0000
+++ src/logic/map_objects/tribes/warehouse.h 2017-02-18 23:36:11 +0000
@@ -198,7 +198,7 @@
bool fetch_from_flag(Game&) override;
- Quantity count_workers(const Game&, DescriptionIndex, const Requirements&, Match);
+ Quantity count_workers(const Game&, DescriptionIndex worker, const Requirements&, Match);
Worker& launch_worker(Game&, DescriptionIndex worker, const Requirements&);
// Adds the worker to the inventory. Takes ownership and might delete
=== added file 'test/maps/plain.wmf/scripting/test_upgraded_workers.lua'
--- test/maps/plain.wmf/scripting/test_upgraded_workers.lua 1970-01-01 00:00:00 +0000
+++ test/maps/plain.wmf/scripting/test_upgraded_workers.lua 2017-02-18 23:36:11 +0000
@@ -0,0 +1,29 @@
+run(function()
+ sleep(5000)
+
+ assert_equal(1, #p1:get_buildings("barbarians_headquarters"))
+
+ local hq = p1:get_buildings("barbarians_headquarters")[1]
+
+ hq:set_workers("barbarians_miner_chief", 5)
+ assert_equal(5, hq:get_workers("barbarians_miner_chief"))
+
+ -- This mine needs a miner, a chief miner and a master miner
+ p1:place_road(p1:place_flag(map:get_field(25,22)), "bl", "bl", "bl", "bl")
+ local mine = p1:place_building("barbarians_coalmine_deeper", wl.Game().map:get_field(24, 21), false, true)
+
+ sleep(1000)
+
+ -- 2 of the chief miners should have been requested by the mine now,
+ -- one of them acting as a basic miner
+ assert_equal(3, hq:get_workers("barbarians_miner_chief"))
+
+ hq:set_workers("barbarians_miner_master", 1)
+ sleep(1000)
+
+ -- The master miner has filled the remaining slot
+ hq:set_workers("barbarians_miner_master", 1)
+
+ print("# All Tests passed.")
+ wl.ui.MapView():close()
+end)
Follow ups
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: TiborB, 2017-02-20
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: GunChleoc, 2017-02-20
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: toptopple, 2017-02-20
-
[Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: noreply, 2017-02-19
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: GunChleoc, 2017-02-19
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: TiborB, 2017-02-19
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: GunChleoc, 2017-02-19
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: TiborB, 2017-02-19
-
Re: [Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: toptopple, 2017-02-19
-
[Merge] lp:~widelands-dev/widelands/bug-1664145-miners into lp:widelands
From: bunnybot, 2017-02-19