Merge lp:~widelands-dev/widelands/bug-1428315 into lp:widelands

Proposed by TiborB
Status: Merged
Merged at revision: 7516
Proposed branch: lp:~widelands-dev/widelands/bug-1428315
Merge into: lp:widelands
Diff against target: 59 lines (+16/-2)
2 files modified
src/logic/ship.cc (+2/-1)
src/logic/trainingsite.cc (+14/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1428315
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+269673@code.launchpad.net

Description of the change

For unknown reasons, a trainingsite sometimes does not drop fully upgraded soldiers and all upgrading can be therefore stuck, f.e. if there is only one slot for soldiers.
Might be a problem of save/load.
Attached savegames does not show an instant when problem happened, so I cannot properly debug it.

Now checking for fully upgraded soldiers are done everytime training cycle ends. Overhead is negligible...

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

little hackish, but works.

review: Approve
Revision history for this message
TiborB (tiborb95) wrote :

that it is :(

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/logic/ship.cc'
--- src/logic/ship.cc 2015-07-29 20:06:11 +0000
+++ src/logic/ship.cc 2015-08-31 19:59:25 +0000
@@ -719,7 +719,8 @@
719 * @note This is supposed to be called only from the scheduling code of @ref Fleet.719 * @note This is supposed to be called only from the scheduling code of @ref Fleet.
720 */720 */
721void Ship::set_destination(Game& game, PortDock& pd) {721void Ship::set_destination(Game& game, PortDock& pd) {
722 molog("set_destination / sending to portdock %u (carrying %" PRIuS " items)\n", pd.serial(), m_items.size());722 molog("set_destination / sending to portdock %u (carrying %" PRIuS " items)\n",
723 pd.serial(), m_items.size());
723 m_destination = &pd;724 m_destination = &pd;
724 send_signal(game, "wakeup");725 send_signal(game, "wakeup");
725}726}
726727
=== modified file 'src/logic/trainingsite.cc'
--- src/logic/trainingsite.cc 2015-05-20 19:17:56 +0000
+++ src/logic/trainingsite.cc 2015-08-31 19:59:25 +0000
@@ -553,19 +553,31 @@
553{553{
554 m_result = result;554 m_result = result;
555 ProductionSite::program_end(game, result);555 ProductionSite::program_end(game, result);
556 // For unknown reasons sometimes there is a fully upgraded soldier
557 // that failed to be send away, so at the end of this function
558 // we test for such soldiers, unless another drop_soldiers
559 // function were run
560 bool leftover_soldiers_check = true;
556561
557 if (m_current_upgrade) {562 if (m_current_upgrade) {
558 if (m_result == Completed) {563 if (m_result == Completed) {
559 drop_unupgradable_soldiers(game);564 drop_unupgradable_soldiers(game);
565 leftover_soldiers_check = false;
560 m_current_upgrade->lastsuccess = true;566 m_current_upgrade->lastsuccess = true;
561 m_current_upgrade->failures = 0;567 m_current_upgrade->failures = 0;
562 }568 }
563 else {569 else {
564 m_current_upgrade->failures++;570 m_current_upgrade->failures++;
565 drop_stalled_soldiers(game);571 drop_stalled_soldiers(game);
572 leftover_soldiers_check = false;
566 }573 }
567 m_current_upgrade = nullptr;574 m_current_upgrade = nullptr;
568 }575 }
576
577 if (leftover_soldiers_check) {
578 drop_unupgradable_soldiers(game);
579 }
580
569 training_done();581 training_done();
570}582}
571583
@@ -595,8 +607,9 @@
595 maxcredit = upgrade.credit;607 maxcredit = upgrade.credit;
596 }608 }
597609
598 if (maxprio == 0)610 if (maxprio == 0) {
599 return program_start(game, "sleep");611 return program_start(game, "sleep");
612 }
600613
601 uint32_t const multiplier = 1 + (10 - maxcredit) / maxprio;614 uint32_t const multiplier = 1 + (10 - maxcredit) / maxprio;
602615

Subscribers

People subscribed via source and target branches

to status/vote changes: