Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
BTW what Bunnybot will pick up on is the commit message rather than the description. The description will still be accessible via this merge request though. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Description fixed. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/road_promotions into lp:widelands has been updated. Description changed to: This is supposed to improve how roads get promoted and demoted under all possible scenarios, without surprises or other negative side-effects (basically without oscillation phenomenon). More specifically: - Busy roads should now get promoted much sooner than before (but not sooner than 1 minute of game time) and proportionally to their actual need for promotion (highly-busy roads should get promoted sooner than moderately-busy roads). - Virtual multi-segment roads should now have their segments promoted much much sooner than before and proportionally to their actual need for promotion (busy crossroads should affect that need). - Half-busy promoted roads (i.e. second carrier still needed from time to time) should no more get demoted. - Fully-idle roads should now get demoted after specific time (not sooner than 2.5 minutes of game time) and proportionally to their previous busyness (previously moderately-busy roads should get demoted sooner than previously highly-busy roads), no longer needing to get triggered by more wares. For more details, see: https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/road_promotions into lp:widelands has been updated. Status: Needs review => Merged For more details, see: https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
@bunnybot merge -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/road_promotions into lp:widelands has been updated. Commit message changed to: Improved algorithm for promotion and demotion of roads For more details, see: https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
ypopezios: I will test this now, but please change the description what this is about. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3631. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/401054339. Appveyor build 3430. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3430. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
That has been waiting for testers (and especially those who doubted every step of its development). Since no other testers appeared, I'd be happy to have this merged, thus forcing everyone to indirectly test it. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Review: Approve Code still LGTM - I am merging trunk again, which should get rid of the Travis failure. If you're happy with the state of this branch, it can go in. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3586. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/388281937. Appveyor build 3389. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3389. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3583. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/388095680. Appveyor build 3386. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3386. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3548. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/384126645. Appveyor build 3352. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3352. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Review: Resubmit Somebody should review my changes and do a final test to make sure that nothing broke, then this can go in. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3523. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/379601518. Appveyor build 3328. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3328. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3491. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/377445598. Appveyor build 3296. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3296. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3480. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/376061073. Appveyor build 3285. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3285. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3473. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/375597592. Appveyor build 3278. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3278. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3450. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/374329080. Appveyor build 3255. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3255. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3430. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/373542929. Appveyor build 3235. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3235. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
That makes sense. I usually add "NOCOM" to the string, which I can then also grep for. It also helps me locate the strings in the output. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
I know, but when cleaning the mess after myself I can just search for "printf" :) and remove them -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
@Tibor: Please use log() instead of printf(). printf() is not secure ;) Thanks for picking this up from the forum! -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3416. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/371761130. Appveyor build 3222. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3222. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/road_promotions. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Review: Needs Information see inline comment Diff comments: > === modified file 'src/economy/road.cc' > --- src/economy/road.cc 2018-04-07 16:59:00 + > +++ src/economy/road.cc 2018-04-25 19:41:13 + > @@ -543,68 +543,73 @@ > * \return true if a carrier has been sent on its way, false otherwise. > */ > bool Road::notify_ware(Game& game, FlagId const flagid) { > - uint32_t const gametime = game.get_gametime(); > - assert(busyness_last_update_ <= gametime); > - uint32_t const tdelta = gametime - busyness_last_update_; > - > - // Iterate over all carriers and try to find one which takes the ware. > - for (CarrierSlot& slot : carrier_slots_) { > - if (Carrier* const carrier = slot.carrier.get(game)) > - if (carrier->notify_ware(game, flagid)) { > - // notify_ware returns false if the carrier > currently can not take > - // the ware. If we get here, the carrier took > the ware. So we > - // decrement the usage busyness. > - if (500 < tdelta) { > - busyness_last_update_ = gametime; > - if (busyness_) { > - --busyness_; > - > - // If busyness_ drops below a > limit, release the donkey. > - // remember that every time a > ware is waiting at the flag > - // busyness_ increase by 10 but > every time a ware is immediatly > - // acked by a carrier busyness_ > is decreased by 1 only. > - // so the limit is not so easy > to reach > - if (busyness_ < 350) { > - Carrier* const > second_carrier = carrier_slots_[1].carrier.get(game); > - if (second_carrier && > second_carrier->top_state().task == ::taskRoad) { > - > second_carrier->send_signal(game, "cancel"); > - // this signal > is not handled in any special way > - // so it simply > pop the task off the stack > - // the string > "cancel" has been used to make clear > - // the final > goal we want to achieve > - // ie: > cancelling current task > - > carrier_slots_[1].carrier = nullptr; > - > carrier_slots_[1].carrier_request = nullptr; > - type_ = > RoadType::kNormal; > - mark_map(game); > - } > - } > - } > - } > - return true; > - } > - } > - > - // If we get here, no carrier took the ware. So we check if we should > - // increment the usage counter. busyness_last_update_ prevents that the > - // counter is incremented too often. > - if (100 < tdelta) { > - busyness_last_update_ = gametime; > - if (500 < (busyness_ += 10)) { > - type_ = RoadType::kBusy; > - mark_map(game); > - for (CarrierSlot& slot : carrier_slots_) { > - if (!slot.carrier.get(game) && > !slot.carrier_request && slot.carrier_type != 1) { > - request_carrier(slot); > - } > - } > - } > - } > - return false; > +uint32_t const gametime = game.get_gametime(); > + assert(last_wallet_check_ <= gametime); > + const int16_t animal_price = 600; > + const int16_t max_wallet = 2.5 * animal_price; > + > + const uint8_t carriers_count = (carrier_slots_[1].carrier == nullptr) ? > 1 : 2; > + printf ("DEBUG Carriers count: %d\n", carriers_count); > + > + // Iterate over all carriers and try to find one which takes the ware. > + for (CarrierSlot& slot : carrier_slots_) { > +if (Carrier* const carrier = slot.carrier.get(game)) { > + if (carrier->notify_ware(game, flagid)) { > +// notify_ware returns false if the carrier currently can not take > +// the ware. If we get
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
Continuous integration builds have changed state: Travis build 3410. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/370745495. Appveyor build 3216. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_road_promotions-3216. -- https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/road_promotions into lp:widelands. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/road_promotions into lp:widelands
TiborB has proposed merging lp:~widelands-dev/widelands/road_promotions into lp:widelands. Requested reviews: Widelands Developers (widelands-dev) For more details, see: https://code.launchpad.net/~widelands-dev/widelands/road_promotions/+merge/344182 This is only formal request to get windows binary for testing!!! -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/road_promotions into lp:widelands. === modified file 'src/economy/road.cc' --- src/economy/road.cc 2018-04-07 16:59:00 + +++ src/economy/road.cc 2018-04-24 19:52:00 + @@ -50,8 +50,8 @@ */ Road::Road() : PlayerImmovable(g_road_descr), - busyness_(0), - busyness_last_update_(0), + wallet_(0), + last_wallet_check_(0), type_(0), idle_index_(0) { flags_[0] = flags_[1] = nullptr; @@ -543,68 +543,74 @@ * \return true if a carrier has been sent on its way, false otherwise. */ bool Road::notify_ware(Game& game, FlagId const flagid) { - uint32_t const gametime = game.get_gametime(); - assert(busyness_last_update_ <= gametime); - uint32_t const tdelta = gametime - busyness_last_update_; - - // Iterate over all carriers and try to find one which takes the ware. - for (CarrierSlot& slot : carrier_slots_) { - if (Carrier* const carrier = slot.carrier.get(game)) - if (carrier->notify_ware(game, flagid)) { -// notify_ware returns false if the carrier currently can not take -// the ware. If we get here, the carrier took the ware. So we -// decrement the usage busyness. -if (500 < tdelta) { - busyness_last_update_ = gametime; - if (busyness_) { - --busyness_; - - // If busyness_ drops below a limit, release the donkey. - // remember that every time a ware is waiting at the flag - // busyness_ increase by 10 but every time a ware is immediatly - // acked by a carrier busyness_ is decreased by 1 only. - // so the limit is not so easy to reach - if (busyness_ < 350) { - Carrier* const second_carrier = carrier_slots_[1].carrier.get(game); - if (second_carrier && second_carrier->top_state().task == ::taskRoad) { -second_carrier->send_signal(game, "cancel"); -// this signal is not handled in any special way -// so it simply pop the task off the stack -// the string "cancel" has been used to make clear -// the final goal we want to achieve -// ie: cancelling current task -carrier_slots_[1].carrier = nullptr; -carrier_slots_[1].carrier_request = nullptr; -type_ = RoadType::kNormal; -mark_map(game); - } - } - } -} -return true; - } - } - - // If we get here, no carrier took the ware. So we check if we should - // increment the usage counter. busyness_last_update_ prevents that the - // counter is incremented too often. - if (100 < tdelta) { - busyness_last_update_ = gametime; - if (500 < (busyness_ += 10)) { - type_ = RoadType::kBusy; - mark_map(game); - for (CarrierSlot& slot : carrier_slots_) { -if (!slot.carrier.get(game) && !slot.carrier_request && slot.carrier_type != 1) { - request_carrier(slot); -} - } - } - } - return false; +uint32_t const gametime = game.get_gametime(); + assert(last_wallet_check_ <= gametime); + const int16_t some_factor = 2; + const int16_t animal_price = 2; + const int16_t max_wallet = 500; + + const uint8_t carriers_count = (carrier_slots_[1].carrier == nullptr) ? 1 : 2; + printf ("DEBUG Carriers count: %d\n", carriers_count); + + // Iterate over all carriers and try to find one which takes the ware. + for (CarrierSlot& slot : carrier_slots_) { +if (Carrier* const carrier = slot.carrier.get(game)) { + if (carrier->notify_ware(game, flagid)) { +// notify_ware returns false if the carrier currently can not take +// the ware. If we get here, the carrier took the ware. +wallet_ -= carriers_count * (gametime - last_wallet_check_); +last_wallet_check_ = gametime; +wallet_ += some_factor * (flags_[flagid]->current_wares() + path_.get_nsteps()); +if (wallet_ < 0) { + wallet_ = 0; + if (type_ == RoadType::kBusy) { +// beginning of code for demotion +// should be moved in a function +Carrier* const second_carrier = carrier_slots_[1].carrier.get(game); +if (second_carrier && second_carrier->top_state().task == ::taskRoad) { + second_carrier->send_signal(game, "cancel"); + // this signal is not handled in any special way + // so it simply pop the task off the stack + // the string "cancel" has been used to make clear + // the final goal we want to achieve + // ie: cancelling current task +