Changeset - r24084:526c33970f42
[Not reviewed]
master
0 1 0
Niels Martin Hansen - 4 years ago 2020-02-06 15:27:58
nielsm@indvikleren.dk
Fix d84b67e5: Station rating effects affecting too large area
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -3837,49 +3837,49 @@ void OnTick_Station()
 
			/* Stop processing this station if it was deleted */
 
			if (!StationHandleBigTick(st)) continue;
 
			TriggerStationAnimation(st, st->xy, SAT_250_TICKS);
 
			if (Station::IsExpected(st)) AirportAnimationTrigger(Station::From(st), AAT_STATION_250_TICKS);
 
		}
 
	}
 
}
 

	
 
/** Monthly loop for stations. */
 
void StationMonthlyLoop()
 
{
 
	for (Station *st : Station::Iterate()) {
 
		for (CargoID i = 0; i < NUM_CARGO; i++) {
 
			GoodsEntry *ge = &st->goods[i];
 
			SB(ge->status, GoodsEntry::GES_LAST_MONTH, 1, GB(ge->status, GoodsEntry::GES_CURRENT_MONTH, 1));
 
			ClrBit(ge->status, GoodsEntry::GES_CURRENT_MONTH);
 
		}
 
	}
 
}
 

	
 

	
 
void ModifyStationRatingAround(TileIndex tile, Owner owner, int amount, uint radius)
 
{
 
	ForAllStationsRadius(tile, radius, [&](Station *st) {
 
		if (st->owner == owner) {
 
		if (st->owner == owner && DistanceManhattan(tile, st->xy) <= radius) {
 
			for (CargoID i = 0; i < NUM_CARGO; i++) {
 
				GoodsEntry *ge = &st->goods[i];
 

	
 
				if (ge->status != 0) {
 
					ge->rating = Clamp(ge->rating + amount, 0, 255);
 
				}
 
			}
 
		}
 
	});
 
}
 

	
 
static uint UpdateStationWaiting(Station *st, CargoID type, uint amount, SourceType source_type, SourceID source_id)
 
{
 
	/* We can't allocate a CargoPacket? Then don't do anything
 
	 * at all; i.e. just discard the incoming cargo. */
 
	if (!CargoPacket::CanAllocateItem()) return 0;
 

	
 
	GoodsEntry &ge = st->goods[type];
 
	amount += ge.amount_fract;
 
	ge.amount_fract = GB(amount, 0, 8);
 

	
 
	amount >>= 8;
 
	/* No new "real" cargo item yet. */
 
	if (amount == 0) return 0;
0 comments (0 inline, 0 general)