widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #00644
[Merge] lp:~alocritani/widelands/bugfix-920316 into lp:widelands
Angelo Locritani has proposed merging lp:~alocritani/widelands/bugfix-920316 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #920316 in widelands: "[wish] removing 2nd carrier when road is not busy"
https://bugs.launchpad.net/widelands/+bug/920316
For more details, see:
https://code.launchpad.net/~alocritani/widelands/bugfix-920316/+merge/92620
When the busyness of the road becomes lower than 350 the second carrier is released.
Also, m_busyness is now displayed in debug window.
I've tested it and found no problem. Maybe the lower threshold can be discussed, but it seems quite right to me.
--
https://code.launchpad.net/~alocritani/widelands/bugfix-920316/+merge/92620
Your team Widelands Developers is requested to review the proposed merge of lp:~alocritani/widelands/bugfix-920316 into lp:widelands.
=== modified file 'src/economy/road.cc'
--- src/economy/road.cc 2011-11-30 21:38:37 +0000
+++ src/economy/road.cc 2012-02-11 12:55:23 +0000
@@ -608,9 +608,30 @@
// decrement the usage busyness.
if (500 < tdelta) {
m_busyness_last_update = gametime;
- // TODO: If m_busyness drops below a limit, release the donkey.
- if (m_busyness)
+ if (m_busyness) {
--m_busyness;
+
+ // If m_busyness drops below a limit, release the donkey.
+ // remember that every time a ware is waiting at the flag
+ // m_busyness increase by 10 but every time a ware is immediatly
+ // acked by a carrier m_busyness is decreased by 1 only.
+ // so the limit is not so easy to reach
+ if (m_busyness < 350) {
+ Carrier * const second_carrier = m_carrier_slots[1].carrier.get(game);
+ if (second_carrier && second_carrier->top_state().task == &Carrier::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
+ m_carrier_slots[1].carrier = 0;
+ m_carrier_slots[1].carrier_request = 0;
+ m_type = Road_Normal;
+ _mark_map(game);
+ }
+ }
+ }
}
return true;
}
@@ -634,4 +655,10 @@
return false;
}
+void Road::log_general_info(Editor_Game_Base const & egbase)
+{
+ PlayerImmovable::log_general_info(egbase);
+ molog("m_busyness: %i\n", m_busyness);
+}
+
}
=== modified file 'src/economy/road.h'
--- src/economy/road.h 2011-11-30 21:38:37 +0000
+++ src/economy/road.h 2012-02-11 12:55:23 +0000
@@ -97,6 +97,8 @@
virtual void remove_worker(Worker &);
void assign_carrier(Carrier &, uint8_t);
+ void log_general_info(Editor_Game_Base const &);
+
protected:
virtual void init(Editor_Game_Base &);
virtual void cleanup(Editor_Game_Base &);
Follow ups