(svn r25737) -Codechange: move inner workings of RefreshNextHopsStats into separate function

This commit is contained in:
fonsinchen
2013-08-20 21:22:37 +00:00
parent 5c0b766ed9
commit 5e017b8000
2 changed files with 64 additions and 38 deletions

View File

@@ -23,6 +23,8 @@
#include "transport_type.h"
#include "group_type.h"
#include "base_consist.h"
#include <list>
#include <map>
/** Vehicle status bits in #Vehicle::vehstatus. */
enum VehStatus {
@@ -124,15 +126,33 @@ extern void FixOldVehicles();
struct GRFFile;
/**
* Simulated cargo type and capacity for prediction of future links.
*/
struct RefitDesc {
CargoID cargo; ///< Cargo type the vehicle will be carrying.
uint16 capacity; ///< Capacity the vehicle will have.
uint16 remaining; ///< Capacity remaining from before the previous refit.
RefitDesc(CargoID cargo, uint16 capacity, uint16 remaining) :
cargo(cargo), capacity(capacity), remaining(remaining) {}
};
/** %Vehicle data structure. */
struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle, BaseConsist {
private:
typedef std::list<RefitDesc> RefitList;
typedef std::map<CargoID, uint> CapacitiesMap;
Vehicle *next; ///< pointer to the next vehicle in the chain
Vehicle *previous; ///< NOSAVE: pointer to the previous vehicle in the chain
Vehicle *first; ///< NOSAVE: pointer to the first vehicle in the chain
Vehicle *next_shared; ///< pointer to the next vehicle that shares the order
Vehicle *previous_shared; ///< NOSAVE: pointer to the previous vehicle in the shared order chain
void RefreshNextHopsStats(CapacitiesMap &capacities,
RefitList &refit_capacities, const Order *first, const Order *cur,
const Order *next, uint hops, bool was_refit, bool has_cargo);
public:
friend const SaveLoad *GetVehicleDescription(VehicleType vt); ///< So we can use private/protected variables in the saveload code
friend void FixOldVehicles();