Merge lp:~widelands-dev/widelands/bug-1624216-horsepocalypse into lp:widelands

Proposed by GunChleoc
Status: Merged
Approved by: GunChleoc
Approved revision: no longer in the source branch.
Merged at revision: 8202
Proposed branch: lp:~widelands-dev/widelands/bug-1624216-horsepocalypse
Merge into: lp:widelands
Diff against target: 46 lines (+11/-11)
1 file modified
src/logic/map_objects/tribes/warehouse.cc (+11/-11)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1624216-horsepocalypse
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+310221@code.launchpad.net

Commit message

When a warehouse is destroyed, limit maximum number of fleeing units per unit type to 500.

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

Continuous integration builds have changed state:

Travis build 1581. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/174007207.
Appveyor build 1419. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1624216_horsepocalypse-1419.

Revision history for this message
Klaus Halfmann (klaus-halfmann) wrote :

Code looks good to me, no Idea if that inline comment will help.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Looks like your inline comment wasn't saved :(

Revision history for this message
xxx-deleted (janosch-peters-deactivatedaccount) wrote :

It could be coded a bit more elegantly(see my comments), but apart from that it LGTM. However, I did not test it because I dont know a straight forward way to get a warehous with 500+ workers.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks for the review, the code looks much better now :)

There is a savegame attached to the bug that you can use for testing - attack the headquarters to the north.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

HTTP Error 500: Internal Server Error

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1607. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/175655541.
Appveyor build 1445. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1624216_horsepocalypse-1445.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

('The read operation timed out',)

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1607. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/175655541.
Appveyor build 1445. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1624216_horsepocalypse-1445.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

('The read operation timed out',)

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 1607. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/175655541.
Appveyor build 1445. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1624216_horsepocalypse-1445.

Revision history for this message
Notabilis (notabilis27) wrote :

Assuming this branch waits for a tester: Code looks good to me and testing the provided savegame with trunk and this branch it seems to work as planned.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks!

@bunnybot merge

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/map_objects/tribes/warehouse.cc'
2--- src/logic/map_objects/tribes/warehouse.cc 2016-11-25 09:37:24 +0000
3+++ src/logic/map_objects/tribes/warehouse.cc 2016-12-04 13:14:16 +0000
4@@ -53,6 +53,7 @@
5 namespace {
6
7 static const uint32_t WORKER_WITHOUT_COST_SPAWN_INTERVAL = 2500;
8+constexpr int kFleeingUnitsCap = 500;
9
10 // Goes through the list and removes all workers that are no longer in the
11 // game.
12@@ -529,24 +530,23 @@
13 portdock_ = nullptr;
14 }
15
16- // This will empty the stock and launch all workers including incorporated
17- // ones.
18+ // This will launch all workers including incorporated ones up to kFleeingUnitsCap and then empty
19+ // the stock.
20 if (upcast(Game, game, &egbase)) {
21 const WareList& workers = get_workers();
22 for (DescriptionIndex id = 0; id < workers.get_nrwareids(); ++id) {
23- const uint32_t stock = workers.stock(id);
24- // Separate behaviour for the case of loading the game
25- // (which does save/destroy/reload) and simply destroying ingame
26+ // If the game is running, have the workers flee the warehouse.
27 if (game->is_loaded()) {
28- // This game is really running
29- for (uint32_t i = 0; i < stock; ++i) {
30+ // We have kFleeingUnitsCap to make sure that we won't flood the map with carriers etc.
31+ Quantity stock = workers.stock(id);
32+ for (Quantity i = 0; i < stock && i < kFleeingUnitsCap; ++i) {
33 launch_worker(*game, id, Requirements()).start_task_leavebuilding(*game, true);
34 }
35- assert(!incorporated_workers_.count(id) || incorporated_workers_[id].empty());
36- } else {
37- // We are in the load-game sequence...
38- remove_workers(id, stock);
39 }
40+ // Make sure that all workers are gone
41+ remove_workers(id, workers.stock(id));
42+ assert(!game->is_loaded() ||
43+ (!incorporated_workers_.count(id) || incorporated_workers_[id].empty()));
44 }
45 }
46 incorporated_workers_.clear();

Subscribers

People subscribed via source and target branches

to status/vote changes: