src/station_cmd.cpp
changeset 7922 a7e266f966d9
parent 7891 aef0c16244d7
child 7928 63e18de69e50
equal deleted inserted replaced
7921:3437fdd5c0a8 7922:a7e266f966d9
   669 	const StationRect *r = &st->rect;
   669 	const StationRect *r = &st->rect;
   670 
   670 
   671 	if (r->IsEmpty()) return; /* no tiles belong to this station */
   671 	if (r->IsEmpty()) return; /* no tiles belong to this station */
   672 
   672 
   673 	/* clamp sign coord to be inside the station rect */
   673 	/* clamp sign coord to be inside the station rect */
   674 	st->xy = TileXY(clampu(TileX(st->xy), r->left, r->right), clampu(TileY(st->xy), r->top, r->bottom));
   674 	st->xy = TileXY(ClampU(TileX(st->xy), r->left, r->right), ClampU(TileY(st->xy), r->top, r->bottom));
   675 	UpdateStationVirtCoordDirty(st);
   675 	UpdateStationVirtCoordDirty(st);
   676 }
   676 }
   677 
   677 
   678 /** This is called right after a station was deleted.
   678 /** This is called right after a station was deleted.
   679  * It checks if the whole station is free of substations, and if so, the station will be
   679  * It checks if the whole station is free of substations, and if so, the station will be
  2485 
  2485 
  2486 			{
  2486 			{
  2487 				int or_ = ge->rating; // old rating
  2487 				int or_ = ge->rating; // old rating
  2488 
  2488 
  2489 				/* only modify rating in steps of -2, -1, 0, 1 or 2 */
  2489 				/* only modify rating in steps of -2, -1, 0, 1 or 2 */
  2490 				ge->rating = rating = or_ + clamp(clamp(rating, 0, 255) - or_, -2, 2);
  2490 				ge->rating = rating = or_ + Clamp(Clamp(rating, 0, 255) - or_, -2, 2);
  2491 
  2491 
  2492 				/* if rating is <= 64 and more than 200 items waiting,
  2492 				/* if rating is <= 64 and more than 200 items waiting,
  2493 				 * remove some random amount of goods from the station */
  2493 				 * remove some random amount of goods from the station */
  2494 				if (rating <= 64 && waiting >= 200) {
  2494 				if (rating <= 64 && waiting >= 200) {
  2495 					int dec = Random() & 0x1F;
  2495 					int dec = Random() & 0x1F;
  2575 				DistanceManhattan(tile, st->xy) <= radius) {
  2575 				DistanceManhattan(tile, st->xy) <= radius) {
  2576 			for (CargoID i = 0; i < NUM_CARGO; i++) {
  2576 			for (CargoID i = 0; i < NUM_CARGO; i++) {
  2577 				GoodsEntry* ge = &st->goods[i];
  2577 				GoodsEntry* ge = &st->goods[i];
  2578 
  2578 
  2579 				if (ge->acceptance_pickup != 0) {
  2579 				if (ge->acceptance_pickup != 0) {
  2580 					ge->rating = clamp(ge->rating + amount, 0, 255);
  2580 					ge->rating = Clamp(ge->rating + amount, 0, 255);
  2581 				}
  2581 				}
  2582 			}
  2582 			}
  2583 		}
  2583 		}
  2584 	}
  2584 	}
  2585 }
  2585 }