src/ai/api/ai_event_types.cpp
author truebrain
Thu, 24 Apr 2008 23:39:18 +0000
branchnoai
changeset 10339 ce6cd68d9eb8
parent 10297 433b21fd002c
child 10715 6bdf79ffb022
permissions -rw-r--r--
(svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
-Note: this is perfectly safe; when a type changes, any sane compiler starts complaining about redefining the typedef to an other type
9820
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9682
diff changeset
     1
/* $Id$ */
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9682
diff changeset
     2
9833
89a64246458f (svn r12496) [NoAI] -Documentation: give the .cpp files a nice uniform format too
truebrain
parents: 9820
diff changeset
     3
/** @file ai_event_types.cpp Implementation of all EventTypes. */
9820
8c116d4c6033 (svn r12423) [NoAI] -Change: bring a little more uniformness into the first few lines of the API related files (add missing /* $Id$ */ and such).
rubidium
parents: 9682
diff changeset
     4
9682
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff changeset
     5
#include "ai_event_types.hpp"
10339
ce6cd68d9eb8 (svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
truebrain
parents: 10297
diff changeset
     6
#include "../../openttd.h"
ce6cd68d9eb8 (svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
truebrain
parents: 10297
diff changeset
     7
#include "../../core/alloc_func.hpp"
10297
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
     8
#include "../../strings_func.h"
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
     9
#include "../../roadveh.h"
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    10
#include "../../train.h"
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    11
#include "../../ship.h"
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    12
#include "../../aircraft.h"
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    13
#include "../../settings_type.h"
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    14
#include "../../articulated_vehicles.h"
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    15
#include "table/strings.h"
9682
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff changeset
    16
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff changeset
    17
bool AIEventVehicleCrash::CloneCrashedVehicle(TileIndex depot)
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff changeset
    18
{
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff changeset
    19
	return false;
d031eb183733 (svn r10631) [NoAI] -Add: AIEvent, to take care of events; for now it only reports when vehicles are crashed
truelight
parents:
diff changeset
    20
}
10297
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    21
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    22
char *AIEventEnginePreview::GetName()
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    23
{
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    24
	static const int len = 64;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    25
	char *engine_name = MallocT<char>(len);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    26
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    27
	::SetDParam(0, engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    28
	::GetString(engine_name, STR_ENGINE_NAME, &engine_name[len - 1]);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    29
	return engine_name;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    30
}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    31
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    32
CargoID AIEventEnginePreview::GetCargoType()
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    33
{
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    34
	switch (::GetEngine(engine)->type) {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    35
		case VEH_ROAD: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    36
			const RoadVehicleInfo *vi = ::RoadVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    37
			return vi->cargo_type;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    38
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    39
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    40
		case VEH_TRAIN: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    41
			const RailVehicleInfo *vi = ::RailVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    42
			return vi->cargo_type;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    43
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    44
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    45
		case VEH_SHIP: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    46
			const ShipVehicleInfo *vi = ::ShipVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    47
			return vi->cargo_type;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    48
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    49
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    50
		case VEH_AIRCRAFT: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    51
			return CT_PASSENGERS;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    52
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    53
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    54
		default: NOT_REACHED();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    55
	}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    56
}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    57
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    58
int32 AIEventEnginePreview::GetCapacity()
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    59
{
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    60
	switch (::GetEngine(engine)->type) {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    61
		case VEH_ROAD:
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    62
		case VEH_TRAIN: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    63
			uint16 *capacities = GetCapacityOfArticulatedParts(engine, ::GetEngine(engine)->type);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    64
			for (CargoID c = 0; c < NUM_CARGO; c++) {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    65
				if (capacities[c] == 0) continue;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    66
				return capacities[c];
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    67
			}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    68
			return -1;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    69
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    70
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    71
		case VEH_SHIP: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    72
			const ShipVehicleInfo *vi = ::ShipVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    73
			return vi->capacity;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    74
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    75
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    76
		case VEH_AIRCRAFT: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    77
			const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    78
			return vi->passenger_capacity;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    79
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    80
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    81
		default: NOT_REACHED();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    82
	}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    83
}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    84
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    85
int32 AIEventEnginePreview::GetMaxSpeed()
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    86
{
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    87
	switch (::GetEngine(engine)->type) {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    88
		case VEH_ROAD: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    89
			const RoadVehicleInfo *vi = ::RoadVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    90
			/* Internal speeds are km/h * 2 */
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    91
			return vi->max_speed / 2;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    92
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    93
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    94
		case VEH_TRAIN: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    95
			const RailVehicleInfo *vi = ::RailVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    96
			return vi->max_speed;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    97
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    98
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
    99
		case VEH_SHIP: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   100
			const ShipVehicleInfo *vi = ::ShipVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   101
			/* Internal speeds are km/h * 2 */
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   102
			return vi->max_speed / 2;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   103
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   104
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   105
		case VEH_AIRCRAFT: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   106
			const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   107
			return vi->max_speed / _patches.plane_speed;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   108
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   109
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   110
		default: NOT_REACHED();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   111
	}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   112
}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   113
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   114
Money AIEventEnginePreview::GetPrice()
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   115
{
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   116
	switch (::GetEngine(engine)->type) {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   117
		case VEH_ROAD: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   118
			const RoadVehicleInfo *vi = ::RoadVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   119
			return (_price.roadveh_base >> 3) * vi->base_cost >> 5;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   120
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   121
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   122
		case VEH_TRAIN: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   123
			const RailVehicleInfo *vi = ::RailVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   124
			return (_price.build_railvehicle >> 3) * vi->base_cost >> 5;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   125
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   126
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   127
		case VEH_SHIP: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   128
			const ShipVehicleInfo *vi = ::ShipVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   129
			return (_price.ship_base >> 3) * vi->base_cost >> 5;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   130
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   131
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   132
		case VEH_AIRCRAFT: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   133
			const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   134
			return (_price.aircraft_base >> 3) * vi->base_cost >> 5;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   135
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   136
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   137
		default: NOT_REACHED();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   138
	}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   139
}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   140
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   141
Money AIEventEnginePreview::GetRunningCost()
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   142
{
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   143
	/* We need to create an instance in order to obtain GetRunningCost.
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   144
	 *  This means we temporary allocate a vehicle in the pool, but
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   145
	 *  there is no other way.. */
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   146
	Vehicle *vehicle;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   147
	switch (::GetEngine(engine)->type) {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   148
		case VEH_ROAD: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   149
			vehicle = new RoadVehicle();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   150
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   151
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   152
		case VEH_TRAIN: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   153
			vehicle = new Train();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   154
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   155
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   156
		case VEH_SHIP: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   157
			vehicle = new Ship();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   158
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   159
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   160
		case VEH_AIRCRAFT: {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   161
			vehicle = new Aircraft();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   162
		} break;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   163
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   164
		default: NOT_REACHED();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   165
	}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   166
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   167
	vehicle->engine_type = engine;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   168
	Money runningCost = vehicle->GetRunningCost();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   169
	delete vehicle;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   170
	return runningCost >> 8;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   171
}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   172
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   173
AIVehicle::VehicleType AIEventEnginePreview::GetVehicleType()
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   174
{
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   175
	switch (::GetEngine(engine)->type) {
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   176
		case VEH_ROAD:     return AIVehicle::VEHICLE_ROAD;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   177
		case VEH_TRAIN:    return AIVehicle::VEHICLE_RAIL;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   178
		case VEH_SHIP:     return AIVehicle::VEHICLE_WATER;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   179
		case VEH_AIRCRAFT: return AIVehicle::VEHICLE_AIR;
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   180
		default: NOT_REACHED();
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   181
	}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   182
}
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   183
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   184
bool AIEventEnginePreview::AcceptPreview()
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   185
{
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   186
	return AIObject::DoCommand(0, engine, 0, CMD_WANT_ENGINE_PREVIEW);
433b21fd002c (svn r12838) [NoAI] -Add: added AIEventEnginePreview, which tells you when you have been chosen for testing an engine, and allows you to accept it
glx
parents: 9833
diff changeset
   187
}