|
|
/* $Id$ */
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
#include "openttd.h"
|
|
|
#include "roadveh.h"
|
|
|
#include "ship.h"
|
|
|
#include "table/strings.h"
|
|
|
#include "functions.h"
|
|
|
#include "news.h"
|
|
|
#include "player.h"
|
|
|
#include "engine.h"
|
|
|
#include "debug.h"
|
|
|
#include "vehicle_gui.h"
|
|
|
#include "depot.h"
|
|
|
#include "train.h"
|
|
|
#include "aircraft.h"
|
|
|
#include "cargotype.h"
|
|
|
#include "group.h"
|
|
|
#include "order.h"
|
|
|
#include "strings_func.h"
|
|
|
#include "command_func.h"
|
|
|
#include "functions.h"
|
|
|
|
|
|
/*
|
|
|
* move the cargo from one engine to another if possible
|
|
|
*/
|
|
|
static void MoveVehicleCargo(Vehicle *dest, Vehicle *source)
|
|
|
{
|
|
|
Vehicle *v = dest;
|
|
|
|
|
|
do {
|
|
|
do {
|
|
|
if (source->cargo_type != dest->cargo_type)
|
|
|
continue; // cargo not compatible
|
|
|
|
|
|
if (dest->cargo.Count() == dest->cargo_cap)
|
|
|
continue; // the destination vehicle is already full
|
|
|
|
|
|
uint units_moved = min(source->cargo.Count(), dest->cargo_cap - dest->cargo.Count());
|
|
|
source->cargo.MoveTo(&dest->cargo, units_moved);
|
|
|
|
|
|
// copy the age of the cargo
|
|
|
dest->day_counter = source->day_counter;
|
|
|
dest->tick_counter = source->tick_counter;
|
|
|
|
|
|
} while (source->cargo.Count() > 0 && (dest = dest->Next()) != NULL);
|