src/ai/api/ai_vehicle.cpp
author truelight
Thu, 12 Jul 2007 15:50:55 +0000
branchnoai
changeset 9637 9f78a12a4f53
parent 9626 79f2b5a0cdd7
child 9654 b836eb5c521f
permissions -rw-r--r--
(svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
     1
/* $Id$ */
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
     2
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
     3
/** @file ai_vehicle.cpp handles the functions of the AIVehicle class */
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
     4
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
     5
#include "ai_vehicle.hpp"
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
     6
#include "ai_cargo.hpp"
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
     7
#include "../../command.h"
9624
b71483f2330f (svn r9915) [NoAI] -Sync with trunk -r9815:9914
glx
parents: 9615
diff changeset
     8
#include "../../vehicle.h"
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
     9
#include "../../depot.h"
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    10
#include "../../engine.h"
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    11
#include "../../player.h"
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    12
9497
f6678533ccba (svn r9369) [NoAI] -Codechange: make some IsValidXXX() function static, so they can be used by the other classes without the need for an instance.
rubidium
parents: 9496
diff changeset
    13
/* static */ bool AIVehicle::IsValidEngine(EngineID engine_id)
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    14
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    15
	return ::IsEngineIndex(engine_id); // TODO: implement 'can I build this engine check'
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    16
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    17
9497
f6678533ccba (svn r9369) [NoAI] -Codechange: make some IsValidXXX() function static, so they can be used by the other classes without the need for an instance.
rubidium
parents: 9496
diff changeset
    18
/* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    19
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    20
	return ::IsValidVehicleID(vehicle_id) && ::GetVehicle(vehicle_id)->owner == _current_player;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    21
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    22
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    23
EngineID AIVehicle::FindBestRoadVehicle(CargoID cargo, uint8 min_reliability)
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    24
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    25
	if (!AICargo::IsValidCargo(cargo) || min_reliability > 100) return INVALID_ENGINE;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    26
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    27
	EngineID best_engine = INVALID_ENGINE;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    28
	EngineID engine_id;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    29
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    30
	FOR_ALL_ENGINEIDS_OF_TYPE(engine_id, VEH_ROAD) {
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    31
		/* Is the vehicle available for this player */
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    32
		if (IsEngineBuildable(engine_id, VEH_ROAD, _current_player) &&
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    33
				GetEngine(engine_id)->reliability * 100 >= min_reliability << 16 &&
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    34
				(RoadVehInfo(engine_id)->cargo_type == cargo || CanRefitTo(engine_id, cargo))) {
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    35
			best_engine = engine_id;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    36
		}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    37
	}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    38
9516
defc90b7898a (svn r9428) [NoAI] -Fix: FindBestRoadVehicle returned always INVALID_ENGINE. It is more useful to return best_engine ;)
truelight
parents: 9497
diff changeset
    39
	return best_engine;
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    40
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    41
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    42
VehicleID AIVehicle::BuildVehicle(TileIndex depot, EngineID engine_id)
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    43
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    44
	if (!this->IsValidEngine(engine_id)) return false;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    45
9560
ff2dde050a4c (svn r9498) [NoAI] -Add: added regression for AITransactionMode()
truelight
parents: 9516
diff changeset
    46
	/* Reset the internal NewVehicleID in case we are in TestMode */
ff2dde050a4c (svn r9498) [NoAI] -Add: added regression for AITransactionMode()
truelight
parents: 9516
diff changeset
    47
	AIObject::SetNewVehicleID(0);
ff2dde050a4c (svn r9498) [NoAI] -Add: added regression for AITransactionMode()
truelight
parents: 9516
diff changeset
    48
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    49
	bool ret;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    50
	switch (::GetEngine(engine_id)->type) {
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    51
		case VEH_ROAD: ret = this->DoCommand(depot, engine_id, 0, CMD_BUILD_ROAD_VEH); break;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    52
		default: NOT_REACHED(); return INVALID_VEHICLE; // TODO: implement trains, ships and aircraft
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    53
	}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    54
9496
05ebee9884b3 (svn r9368) [NoAI] -Fix: store _new_vehicle_id directly after successful handling the command in a per-AI-player-safe piece of memory, so we can restore the value when ever we want later in the process
truelight
parents: 9491
diff changeset
    55
	return ret ? AIObject::GetNewVehicleID() : INVALID_VEHICLE;
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    56
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    57
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    58
VehicleID AIVehicle::CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders)
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    59
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    60
	if (!this->IsValidVehicle(vehicle_id)) return false;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    61
9560
ff2dde050a4c (svn r9498) [NoAI] -Add: added regression for AITransactionMode()
truelight
parents: 9516
diff changeset
    62
	/* Reset the internal NewVehicleID in case we are in TestMode */
ff2dde050a4c (svn r9498) [NoAI] -Add: added regression for AITransactionMode()
truelight
parents: 9516
diff changeset
    63
	AIObject::SetNewVehicleID(0);
ff2dde050a4c (svn r9498) [NoAI] -Add: added regression for AITransactionMode()
truelight
parents: 9516
diff changeset
    64
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    65
	bool ret;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    66
	switch (::GetVehicle(vehicle_id)->type) {
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    67
		case VEH_ROAD: ret = this->DoCommand(depot, vehicle_id, share_orders, CMD_CLONE_VEHICLE); break;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    68
		default: return INVALID_VEHICLE; // TODO: implement trains, ships and aircraft
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    69
	}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    70
9496
05ebee9884b3 (svn r9368) [NoAI] -Fix: store _new_vehicle_id directly after successful handling the command in a per-AI-player-safe piece of memory, so we can restore the value when ever we want later in the process
truelight
parents: 9491
diff changeset
    71
	return ret ? AIObject::GetNewVehicleID() : INVALID_VEHICLE;
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    72
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    73
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    74
bool AIVehicle::RefitVehicle(VehicleID vehicle_id, CargoID cargo)
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    75
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    76
	if (!this->IsValidVehicle(vehicle_id) || !AICargo::IsValidCargo(cargo)) return false;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    77
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    78
	switch (::GetVehicle(vehicle_id)->type) {
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    79
		case VEH_ROAD: return this->DoCommand(0, vehicle_id, cargo, CMD_REFIT_ROAD_VEH);
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    80
		default: return false; // TODO: implement trains, ships and aircraft
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    81
	}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    82
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    83
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    84
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    85
bool AIVehicle::SellVehicle(VehicleID vehicle_id)
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    86
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    87
	if (!this->IsValidVehicle(vehicle_id)) return false;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    88
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    89
	switch (::GetVehicle(vehicle_id)->type) {
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    90
		case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_SELL_ROAD_VEH);
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    91
		default: return false; // TODO: implement trains, ships and aircraft
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    92
	}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    93
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    94
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    95
bool AIVehicle::SendVehicleToDepot(VehicleID vehicle_id)
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    96
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    97
	if (!this->IsValidVehicle(vehicle_id)) return false;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    98
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
    99
	switch (::GetVehicle(vehicle_id)->type) {
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   100
		case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_SEND_ROADVEH_TO_DEPOT);
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   101
		default: return false; // TODO: implement trains, ships and aircraft
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   102
	}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   103
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   104
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   105
bool AIVehicle::StartStopVehicle(VehicleID vehicle_id)
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   106
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   107
	if (!this->IsValidVehicle(vehicle_id)) return false;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   108
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   109
	switch (::GetVehicle(vehicle_id)->type) {
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   110
		case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_START_STOP_ROADVEH);
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   111
		default: return false; // TODO: implement trains, ships and aircraft
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   112
	}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   113
}
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   114
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   115
bool AIVehicle::SkipVehicleOrder(VehicleID vehicle_id)
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   116
{
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   117
	if (!this->IsValidVehicle(vehicle_id)) return false;
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   118
9626
79f2b5a0cdd7 (svn r10118) [NoAI] -Sync with trunk r10015:r10096
glx
parents: 9624
diff changeset
   119
	return this->DoCommand(0, vehicle_id, 0, CMD_SKIP_TO_ORDER);
9491
351239ad524c (svn r9361) [NoAI] -Add: some function to find, build and sell road vehicles.
rubidium
parents:
diff changeset
   120
}
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   121
9637
9f78a12a4f53 (svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
truelight
parents: 9626
diff changeset
   122
/* static */ TileIndex AIVehicle::GetLocation(VehicleID vehicle_id)
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   123
{
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   124
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return INVALID_TILE;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   125
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   126
	return ::GetVehicle(vehicle_id)->tile;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   127
}
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   128
9637
9f78a12a4f53 (svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
truelight
parents: 9626
diff changeset
   129
/* static */ EngineID AIVehicle::GetEngineType(VehicleID vehicle_id)
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   130
{
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   131
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return INVALID_ENGINE;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   132
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   133
	return ::GetVehicle(vehicle_id)->engine_type;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   134
}
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   135
9637
9f78a12a4f53 (svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
truelight
parents: 9626
diff changeset
   136
/* static */ int32 AIVehicle::GetUnitNumber(VehicleID vehicle_id)
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   137
{
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   138
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   139
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   140
	return ::GetVehicle(vehicle_id)->unitnumber;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   141
}
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   142
9637
9f78a12a4f53 (svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
truelight
parents: 9626
diff changeset
   143
/* static */ int32 AIVehicle::GetAge(VehicleID vehicle_id)
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   144
{
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   145
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   146
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   147
	return ::GetVehicle(vehicle_id)->age;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   148
}
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   149
9637
9f78a12a4f53 (svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
truelight
parents: 9626
diff changeset
   150
/* static */ int32 AIVehicle::GetMaxAge(VehicleID vehicle_id)
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   151
{
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   152
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   153
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   154
	return ::GetVehicle(vehicle_id)->max_age;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   155
}
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   156
9637
9f78a12a4f53 (svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
truelight
parents: 9626
diff changeset
   157
/* static */ int32 AIVehicle::GetAgeLeft(VehicleID vehicle_id)
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   158
{
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   159
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   160
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   161
	return ::GetVehicle(vehicle_id)->max_age - ::GetVehicle(vehicle_id)->age;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   162
}
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   163
9637
9f78a12a4f53 (svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
truelight
parents: 9626
diff changeset
   164
/* static */ int32 AIVehicle::GetProfitThisYear(VehicleID vehicle_id)
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   165
{
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   166
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   167
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   168
	return ::GetVehicle(vehicle_id)->profit_this_year;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   169
}
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   170
9637
9f78a12a4f53 (svn r10528) [NoAI] -Codechange: mark in comment static members as such in .cpp files
truelight
parents: 9626
diff changeset
   171
/* static */ int32 AIVehicle::GetProfitLastYear(VehicleID vehicle_id)
9615
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   172
{
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   173
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   174
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   175
	return ::GetVehicle(vehicle_id)->profit_last_year;
f809cdc8e360 (svn r9782) [NoAI] -Add: add information functions to AIVehicle, like the valuators of AIVehicleList
truelight
parents: 9560
diff changeset
   176
}