widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #18005
[Merge] lp:~widelands-dev/widelands/productionsite-inactivity-bug into lp:widelands
Benedikt Straub has proposed merging lp:~widelands-dev/widelands/productionsite-inactivity-bug into lp:widelands.
Commit message:
Fix a bug where a building remains inactive after kicking a worker
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/productionsite-inactivity-bug/+merge/371423
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/productionsite-inactivity-bug into lp:widelands.
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc 2019-08-13 11:12:56 +0000
+++ src/logic/map_objects/tribes/productionsite.cc 2019-08-17 11:14:10 +0000
@@ -776,6 +776,7 @@
Building::log_general_info(egbase);
molog("is_stopped: %u\n", is_stopped_);
+ molog("main_worker: %i\n", main_worker_);
}
void ProductionSite::set_stopped(bool const stopped) {
@@ -796,18 +797,17 @@
}
void ProductionSite::try_start_working(Game& game) {
- if (main_worker_ >= 0) {
- return;
- }
const size_t nr_workers = descr().working_positions().size();
for (uint32_t i = 0; i < nr_workers; ++i) {
- if (Worker* worker = working_positions_[i].worker) {
- // We may start even if can_start_working() returns false, because basic actions
- // like unloading extra wares should take place anyway
- main_worker_ = i;
- worker->reset_tasks(game);
- worker->start_task_buildingwork(game);
- return;
+ if (main_worker_ == static_cast<int>(i) || main_worker_ < 0) {
+ if (Worker* worker = working_positions_[i].worker) {
+ // We may start even if can_start_working() returns false, because basic actions
+ // like unloading extra wares should take place anyway
+ main_worker_ = i;
+ worker->reset_tasks(game);
+ worker->start_task_buildingwork(game);
+ return;
+ }
}
}
}
Follow ups