Changeset - r20866:f9e853acc34a
[Not reviewed]
master
0 2 0
fonsinchen - 11 years ago 2013-10-23 19:04:06
fonsinchen@openttd.org
(svn r25910) -Fix: Guard against empty FlowStats in a few more places.
2 files changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/cargopacket.cpp
Show inline comments
 
@@ -478,7 +478,7 @@ bool VehicleCargoList::Stage(bool accept
 
				FlowStat new_shares = flow_it->second;
 
				new_shares.ChangeShare(current_station, INT_MIN);
 
				StationIDStack excluded = next_station;
 
				while (!excluded.IsEmpty()) {
 
				while (!excluded.IsEmpty() && !new_shares.GetShares()->empty()) {
 
					new_shares.ChangeShare(excluded.Pop(), INT_MIN);
 
				}
 
				if (new_shares.GetShares()->empty()) {
src/station_cmd.cpp
Show inline comments
 
@@ -4228,6 +4228,7 @@ void FlowStat::ChangeShare(StationID st,
 
 */
 
void FlowStat::RestrictShare(StationID st)
 
{
 
	assert(!this->shares.empty());
 
	uint flow = 0;
 
	uint last_share = 0;
 
	SharesMap new_shares;
 
@@ -4248,6 +4249,7 @@ void FlowStat::RestrictShare(StationID s
 
	if (flow == 0) return;
 
	new_shares[last_share + flow] = st;
 
	this->shares.swap(new_shares);
 
	assert(!this->shares.empty());
 
}
 

	
 
/**
 
@@ -4257,6 +4259,7 @@ void FlowStat::RestrictShare(StationID s
 
 */
 
void FlowStat::ReleaseShare(StationID st)
 
{
 
	assert(!this->shares.empty());
 
	uint flow = 0;
 
	uint next_share = 0;
 
	bool found = false;
 
@@ -4283,6 +4286,7 @@ void FlowStat::ReleaseShare(StationID st
 
		}
 
	}
 
	this->shares.swap(new_shares);
 
	assert(!this->shares.empty());
 
}
 

	
 
/**
0 comments (0 inline, 0 general)