author | truebrain |
Sat, 23 Feb 2008 16:21:10 +0000 | |
branch | noai |
changeset 9746 | e4ab7ea8d897 |
parent 9736 | 183b38e0a480 |
child 9804 | 217f77b77400 |
permissions | -rw-r--r-- |
9711
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
2 |
|
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
3 |
/** @file ai_engine.cpp handles the functions of the AIEngine class */ |
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
4 |
|
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
5 |
#include "ai_engine.hpp" |
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
6 |
#include "ai_cargo.hpp" |
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
7 |
#include "../../engine.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
8 |
#include "../../player_func.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "../../strings_func.h" |
9733
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
10 |
#include "../../roadveh.h" |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
11 |
#include "../../train.h" |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
12 |
#include "../../ship.h" |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
13 |
#include "../../aircraft.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
14 |
#include "../../core/alloc_func.hpp" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
15 |
#include "../../economy_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
16 |
#include "../../core/bitmath_func.hpp" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
17 |
#include "table/strings.h" |
9711
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
18 |
|
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
19 |
/* static */ bool AIEngine::IsValidEngine(EngineID engine_id) |
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
20 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
21 |
return ::IsEngineIndex(engine_id) && HasBit(::GetEngine(engine_id)->player_avail, _current_player); |
9711
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
22 |
} |
c8b427215c9d
(svn r11295) [NoAI] -Change [API CHANGE]: put Engine things in AIEngine, and rename functions as such. Most noticable: FindBestXXXVehicle -> FineBestXXXEngine
truelight
parents:
diff
changeset
|
23 |
|
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
24 |
/* static */ char *AIEngine::GetName(EngineID engine_id) |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
25 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
26 |
if (!IsValidEngine(engine_id)) return NULL; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
27 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
28 |
static const int len = 64; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
29 |
char *engine_name = MallocT<char>(len); |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
30 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
31 |
::SetDParam(0, engine_id); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
32 |
::GetString(engine_name, STR_ENGINE_NAME, &engine_name[len - 1]); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
33 |
return engine_name; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
34 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
35 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
36 |
/* static */ CargoID AIEngine::GetCargoType(EngineID engine_id) |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
37 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
38 |
if (!IsValidEngine(engine_id)) return 0; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
39 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
40 |
switch (::GetEngine(engine_id)->type) { |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
41 |
case VEH_ROAD: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
42 |
const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
43 |
return vi->cargo_type; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
44 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
45 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
46 |
case VEH_TRAIN: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
47 |
const RailVehicleInfo *vi = ::RailVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
48 |
return vi->cargo_type; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
49 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
50 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
51 |
case VEH_SHIP: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
52 |
const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
53 |
return vi->cargo_type; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
54 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
55 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
56 |
case VEH_AIRCRAFT: { |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
57 |
return CT_PASSENGERS; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
58 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
59 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
60 |
default: NOT_REACHED(); |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
61 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
62 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
63 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
64 |
/* static */ uint32 AIEngine::GetCapacity(EngineID engine_id) |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
65 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
66 |
if (!IsValidEngine(engine_id)) return 0; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
67 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
68 |
switch (::GetEngine(engine_id)->type) { |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
69 |
case VEH_ROAD: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
70 |
const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
71 |
return vi->capacity; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
72 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
73 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
74 |
case VEH_TRAIN: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
75 |
const RailVehicleInfo *vi = ::RailVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
76 |
return vi->capacity; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
77 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
78 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
79 |
case VEH_SHIP: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
80 |
const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
81 |
return vi->capacity; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
82 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
83 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
84 |
case VEH_AIRCRAFT: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
85 |
const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
86 |
return vi->passenger_capacity; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
87 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
88 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
89 |
default: NOT_REACHED(); |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
90 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
91 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
92 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
93 |
/* static */ uint32 AIEngine::GetReliability(EngineID engine_id) |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
94 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
95 |
if (!IsValidEngine(engine_id)) return 0; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
96 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
97 |
return (::GetEngine(engine_id)->reliability * 100 >> 16); |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
98 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
99 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
100 |
/* static */ uint32 AIEngine::GetMaxSpeed(EngineID engine_id) |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
101 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
102 |
if (!IsValidEngine(engine_id)) return 0; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
103 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
104 |
switch (::GetEngine(engine_id)->type) { |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
105 |
case VEH_ROAD: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
106 |
const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id); |
9734
52d385b38d63
(svn r12213) [NoAI] -Fix: internal speeds for RoadVehicles and Ships are multiplied with 2 (Morloth)
truebrain
parents:
9733
diff
changeset
|
107 |
/* Internal speeds are km/h * 2 */ |
52d385b38d63
(svn r12213) [NoAI] -Fix: internal speeds for RoadVehicles and Ships are multiplied with 2 (Morloth)
truebrain
parents:
9733
diff
changeset
|
108 |
return vi->max_speed / 2; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
109 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
110 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
111 |
case VEH_TRAIN: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
112 |
const RailVehicleInfo *vi = ::RailVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
113 |
return vi->max_speed; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
114 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
115 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
116 |
case VEH_SHIP: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
117 |
const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id); |
9734
52d385b38d63
(svn r12213) [NoAI] -Fix: internal speeds for RoadVehicles and Ships are multiplied with 2 (Morloth)
truebrain
parents:
9733
diff
changeset
|
118 |
/* Internal speeds are km/h * 2 */ |
52d385b38d63
(svn r12213) [NoAI] -Fix: internal speeds for RoadVehicles and Ships are multiplied with 2 (Morloth)
truebrain
parents:
9733
diff
changeset
|
119 |
return vi->max_speed / 2; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
120 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
121 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
122 |
case VEH_AIRCRAFT: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
123 |
const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
124 |
return vi->max_speed; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
125 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
126 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
127 |
default: NOT_REACHED(); |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
128 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
129 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
130 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
131 |
/* static */ uint32 AIEngine::GetPrice(EngineID engine_id) |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
132 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
133 |
if (!IsValidEngine(engine_id)) return 0; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
134 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
135 |
switch (::GetEngine(engine_id)->type) { |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
136 |
case VEH_ROAD: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
137 |
const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
138 |
return (_price.roadveh_base >> 3) * vi->base_cost >> 5; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
139 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
140 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
141 |
case VEH_TRAIN: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
142 |
const RailVehicleInfo *vi = ::RailVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
143 |
return (_price.build_railvehicle >> 3) * vi->base_cost >> 5; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
144 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
145 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
146 |
case VEH_SHIP: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
147 |
const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
148 |
return (_price.ship_base >> 3) * vi->base_cost >> 5; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
149 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
150 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
151 |
case VEH_AIRCRAFT: { |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
152 |
const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id); |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
153 |
return (_price.aircraft_base >> 3) * vi->base_cost >> 5; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
154 |
} break; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
155 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
156 |
default: NOT_REACHED(); |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
157 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
158 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
159 |
|
9733
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
160 |
/* static */ uint32 AIEngine::GetMaxAge(EngineID engine_id) |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
161 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
162 |
if (!IsValidEngine(engine_id)) return 0; |
9733
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
163 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
164 |
return ::GetEngine(engine_id)->lifelength * 366; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
165 |
} |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
166 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
167 |
/* static */ Money AIEngine::GetRunningCost(EngineID engine_id) |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
168 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
169 |
if (!IsValidEngine(engine_id)) return 0; |
9733
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
170 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
171 |
/* We need to create an instance in order to obtain GetRunningCost. |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
172 |
* This means we temporary allocate a vehicle in the pool, but |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
173 |
* there is no other way.. */ |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
174 |
Vehicle *vehicle; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
175 |
switch (::GetEngine(engine_id)->type) { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
176 |
case VEH_ROAD: { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
177 |
vehicle = new RoadVehicle(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
178 |
} break; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
179 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
180 |
case VEH_TRAIN: { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
181 |
vehicle = new Train(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
182 |
} break; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
183 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
184 |
case VEH_SHIP: { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
185 |
vehicle = new Ship(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
186 |
} break; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
187 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
188 |
case VEH_AIRCRAFT: { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
189 |
vehicle = new Aircraft(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
190 |
} break; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
191 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
192 |
default: NOT_REACHED(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
193 |
} |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
194 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
195 |
vehicle->engine_type = engine_id; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
196 |
Money runningCost = vehicle->GetRunningCost(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
197 |
delete vehicle; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
198 |
return runningCost >> 8; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
199 |
} |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
200 |
|
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
201 |
/* static */ AIVehicle::VehicleType AIEngine::GetVehicleType(EngineID engine_id) |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
202 |
{ |
9736
183b38e0a480
(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
truebrain
parents:
9734
diff
changeset
|
203 |
if (!IsValidEngine(engine_id)) return AIVehicle::VEHICLE_INVALID; |
9713
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
204 |
|
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
205 |
switch (::GetEngine(engine_id)->type) { |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
206 |
case VEH_ROAD: return AIVehicle::VEHICLE_ROAD; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
207 |
case VEH_TRAIN: return AIVehicle::VEHICLE_RAIL; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
208 |
case VEH_SHIP: return AIVehicle::VEHICLE_WATER; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
209 |
case VEH_AIRCRAFT: return AIVehicle::VEHICLE_AIR; |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
210 |
default: NOT_REACHED(); |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
211 |
} |
7cd214115969
(svn r11297) [NoAI] -Add: in AIEngine, added: GetName, GetCargoType, GetCapacity, GetReliability, GetMaxSpeed, GetVehicleType, and GetPrice (on request by Kilinich)
truelight
parents:
9711
diff
changeset
|
212 |
} |