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

Proposed by cghislai
Status: Merged
Merged at revision: 6721
Proposed branch: lp:~widelands-dev/widelands/bug1212191_bug1212192
Merge into: lp:widelands
Diff against target: 64 lines (+13/-12)
2 files modified
src/logic/production_program.cc (+8/-3)
src/logic/worker.cc (+5/-9)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug1212191_bug1212192
Reviewer Review Type Date Requested Status
Nasenbaer Approve
Review via email: mp+180098@code.launchpad.net

Description of the change

These are small fixes for the attached bugs.
As the worker evict logic changed a bit, i put it for review.

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

Looks good and works fine for me :).

Further it made a yet (at least for me) unknown bug visible - the sleep program changed the statistics of the trainingssites, therefore the statistics where quickly rising up to 100% as soon as no soldiers were left inside a trainingssite.

I added the fix for that bug to the commit containing the branch merge.

Thank you very much for the two bug fixes :)!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/logic/production_program.cc'
2--- src/logic/production_program.cc 2013-08-08 19:55:12 +0000
3+++ src/logic/production_program.cc 2013-08-14 11:24:04 +0000
4@@ -1276,10 +1276,15 @@
5 {
6 SoldierControl & ctrl = dynamic_cast<SoldierControl &>(ps);
7 const std::vector<Soldier *> soldiers = ctrl.presentSoldiers();
8+ if (soldiers.empty()) {
9+ snprintf
10+ (ps.m_result_buffer, sizeof(ps.m_result_buffer),
11+ _("No soldier to train!"));
12+ return ps.program_end(game, Skipped);
13+ }
14+ ps.molog(" Checking soldier (%u) level %d)\n", attribute, level);
15+
16 const std::vector<Soldier *>::const_iterator soldiers_end = soldiers.end();
17-
18- ps.molog(" Checking soldier (%u) level %d)\n", attribute, level);
19-
20 for (std::vector<Soldier *>::const_iterator it = soldiers.begin();; ++it) {
21 if (it == soldiers_end) {
22 snprintf
23
24=== modified file 'src/logic/worker.cc'
25--- src/logic/worker.cc 2013-08-08 19:55:12 +0000
26+++ src/logic/worker.cc 2013-08-14 11:24:04 +0000
27@@ -1699,7 +1699,6 @@
28 push_task(game, taskBuildingwork);
29 State & state = top_state();
30 state.ivar1 = 0;
31- state.ivar2 = 0;
32 }
33
34
35@@ -1708,13 +1707,13 @@
36 // Reset any signals that are not related to location
37 std::string signal = get_signal();
38 signal_handled();
39+ if (signal == "evict") {
40+ return pop_task(game);
41+ }
42
43 if (state.ivar1 == 1)
44 state.ivar1 = (signal == "fail") * 2;
45
46- if (state.ivar2 == 1)
47- return pop_task(game); // evict worker
48-
49 // Return to building, if necessary
50 upcast(Building, building, get_location(game));
51 if (!building)
52@@ -1753,11 +1752,8 @@
53 */
54 void Worker::evict(Game & game)
55 {
56- if (State * state = get_state(taskBuildingwork)) {
57- if (is_evict_allowed()) {
58- state->ivar2 = 1;
59- send_signal(game, "evict");
60- }
61+ if (is_evict_allowed()) {
62+ send_signal(game, "evict");
63 }
64 }
65

Subscribers

People subscribed via source and target branches

to status/vote changes: