* Update the vehicle's load_unload_ticks, the time it will wait until it tries to load or unload * again. Adjust for overhang of trains and set it at least to 1. * @param front The vehicle to be updated. * @param st The station the vehicle is loading at. * @param ticks The time it would normally wait, based on cargo loaded and unloaded. */
| 1595 | * @param ticks The time it would normally wait, based on cargo loaded and unloaded. |
| 1596 | */ |
| 1597 | static void UpdateLoadUnloadTicks(Vehicle *front, const Station *st, int ticks) |
| 1598 | { |
| 1599 | if (front->type == VEH_TRAIN && _settings_game.order.station_length_loading_penalty) { |
| 1600 | /* Each platform tile is worth 2 rail vehicles. */ |
| 1601 | int overhang = front->GetGroundVehicleCache()->cached_total_length - st->GetPlatformLength(front->tile) * TILE_SIZE; |
| 1602 | if (overhang > 0) { |
| 1603 | ticks <<= 1; |
| 1604 | ticks += (overhang * ticks) / 8; |
| 1605 | } |
| 1606 | } |
| 1607 | /* Always wait at least 1, otherwise we'll wait 'infinitively' long. */ |
| 1608 | front->load_unload_ticks = std::max(1, ticks); |
| 1609 | } |
| 1610 | |
| 1611 | /** |
| 1612 | * Loads/unload the vehicle if possible. |
no test coverage detected