Changeset - r11996:57a5615c0893
[Not reviewed]
master
0 3 0
smatz - 15 years ago 2009-05-23 19:43:09
smatz@openttd.org
(svn r16407) -Fix [FS#2913]: set CargoPacket::source to INVALID_STATION when source station is deleted
3 files changed with 23 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -1016,9 +1016,7 @@ static void DeliverGoodsToIndustry(const
 
 */
 
static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID source, StationID dest, TileIndex source_tile, byte days_in_transit, SmallIndustryList *industry_set)
 
{
 
	bool subsidised;
 
	Station *s_from, *s_to;
 
	Money profit;
 
	bool subsidised = false;
 

	
 
	assert(num_pieces > 0);
 

	
 
@@ -1029,12 +1027,14 @@ static Money DeliverGoods(int num_pieces
 
		SetBit(c->cargo_types, cargo_type);
 
	}
 

	
 
	/* Get station pointers. */
 
	s_from = Station::Get(source);
 
	s_to = Station::Get(dest);
 
	const Station *s_to = Station::Get(dest);
 

	
 
	/* Check if a subsidy applies. */
 
	subsidised = CheckSubsidised(s_from, s_to, cargo_type);
 
	if (source != INVALID_STATION) {
 
		const Station *s_from = Station::Get(source);
 

	
 
		/* Check if a subsidy applies. */
 
		subsidised = CheckSubsidised(s_from, s_to, cargo_type);
 
	}
 

	
 
	/* Increase town's counter for some special goods types */
 
	const CargoSpec *cs = GetCargo(cargo_type);
 
@@ -1045,7 +1045,7 @@ static Money DeliverGoods(int num_pieces
 
	DeliverGoodsToIndustry(s_to, cargo_type, num_pieces, industry_set);
 

	
 
	/* Determine profit */
 
	profit = GetTransportedGoodsIncome(num_pieces, DistanceManhattan(source_tile, s_to->xy), days_in_transit, cargo_type);
 
	Money profit = GetTransportedGoodsIncome(num_pieces, DistanceManhattan(source_tile, s_to->xy), days_in_transit, cargo_type);
 

	
 
	/* Modify profit if a subsidy is in effect */
 
	if (subsidised) {
src/saveload/afterload.cpp
Show inline comments
 
@@ -1275,6 +1275,14 @@ bool AfterLoadGame()
 
		}
 
	}
 

	
 
	if (CheckSavegameVersion(120)) {
 
		/* CargoPacket's source should be either INVALID_STATION or a valid station */
 
		CargoPacket *cp;
 
		FOR_ALL_CARGOPACKETS(cp) {
 
			if (!Station::IsValidID(cp->source)) cp->source = INVALID_STATION;
 
		}
 
	}
 

	
 
	/* Buoys do now store the owner of the previous water tile, which can never
 
	 * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */
 
	if (CheckSavegameVersion(46)) {
src/station.cpp
Show inline comments
 
@@ -101,6 +101,12 @@ Station::~Station()
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		goods[c].cargo.Truncate(0);
 
	}
 

	
 
	CargoPacket *cp;
 
	FOR_ALL_CARGOPACKETS(cp) {
 
		/* Don't allow cargo packets with invalid source station */
 
		if (cp->source == this->index) cp->source = INVALID_STATION;
 
	}
 
}
 

	
 

	
0 comments (0 inline, 0 general)