author | truebrain |
Wed, 26 Mar 2008 15:17:40 +0000 | |
branch | noai |
changeset 9823 | 0b7f816cf46f |
parent 9809 | 9b21c21052fa |
child 9833 | 89a64246458f |
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" |
9809
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
14 |
#include "../../cargotype.h" |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
15 |
#include "../../vehicle_func.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
16 |
#include "../../core/alloc_func.hpp" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
17 |
#include "../../economy_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
18 |
#include "../../core/bitmath_func.hpp" |
9804
217f77b77400
(svn r12310) [NoAI] -Fix: make MaxSpeed for Aircrafts return the value divided by plane_speed (which in regression is now set to 1/2th)
truebrain
parents:
9736
diff
changeset
|
19 |
#include "../../settings_type.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
20 |
#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
|
21 |
|
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 |
/* 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
|
23 |
{ |
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
|
24 |
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
|
25 |
} |
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
|
26 |
|
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 |
/* 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
|
28 |
{ |
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
|
29 |
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
|
30 |
|
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
|
31 |
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
|
32 |
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
|
33 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
34 |
::SetDParam(0, engine_id); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
35 |
::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
|
36 |
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
|
37 |
} |
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
|
38 |
|
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 |
/* 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
|
40 |
{ |
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
|
41 |
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
|
42 |
|
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 |
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
|
44 |
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
|
45 |
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
|
46 |
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
|
47 |
} 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
|
48 |
|
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 |
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
|
50 |
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
|
51 |
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
|
52 |
} 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
|
53 |
|
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 |
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
|
55 |
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
|
56 |
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
|
57 |
} 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
|
58 |
|
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 |
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
|
60 |
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
|
61 |
} 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
|
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 |
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
|
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
|
65 |
} |
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
|
66 |
|
9809
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
67 |
/* static */ bool AIEngine::CanRefitCargo(EngineID engine_id, CargoID cargo_id) |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
68 |
{ |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
69 |
if (!IsValidEngine(engine_id)) return false; |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
70 |
if (!AICargo::IsValidCargo(cargo_id)) return false; |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
71 |
|
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
72 |
if (GetCargoType(engine_id) == cargo_id) return true; |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
73 |
if (cargo_id == CT_MAIL && ::GetEngine(engine_id)->type == VEH_AIRCRAFT) return true; |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
74 |
return ::CanRefitTo(engine_id, cargo_id); |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
75 |
} |
9b21c21052fa
(svn r12325) [NoAI] -Add: added AIEngine:CanRefitCargo()
truebrain
parents:
9804
diff
changeset
|
76 |
|
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
|
77 |
/* 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
|
78 |
{ |
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
|
79 |
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
|
80 |
|
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 |
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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
} 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
|
86 |
|
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 |
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
|
88 |
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
|
89 |
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
|
90 |
} 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
|
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 |
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
|
93 |
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
|
94 |
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
|
95 |
} 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
|
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 |
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
|
98 |
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
|
99 |
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
|
100 |
} 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
|
101 |
|
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
|
102 |
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
|
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 |
} |
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 |
|
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
|
106 |
/* 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
|
107 |
{ |
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
|
108 |
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
|
109 |
|
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 |
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
|
111 |
} |
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
|
112 |
|
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 |
/* 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
|
114 |
{ |
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
|
115 |
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
|
116 |
|
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
|
117 |
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
|
118 |
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
|
119 |
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
|
120 |
/* 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
|
121 |
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
|
122 |
} 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
|
123 |
|
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 |
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
|
125 |
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
|
126 |
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
|
127 |
} 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
|
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 |
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
|
130 |
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
|
131 |
/* 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
|
132 |
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
|
133 |
} 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
|
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 |
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
|
136 |
const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id); |
9804
217f77b77400
(svn r12310) [NoAI] -Fix: make MaxSpeed for Aircrafts return the value divided by plane_speed (which in regression is now set to 1/2th)
truebrain
parents:
9736
diff
changeset
|
137 |
return vi->max_speed / _patches.plane_speed; |
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 |
} 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
|
139 |
|
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 |
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
|
141 |
} |
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
|
142 |
} |
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 |
|
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 |
/* 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
|
145 |
{ |
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
|
146 |
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
|
147 |
|
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 |
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
|
149 |
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
|
150 |
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
|
151 |
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
|
152 |
} 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
|
153 |
|
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 |
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
|
155 |
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
|
156 |
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
|
157 |
} 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
|
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 |
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
|
160 |
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
|
161 |
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
|
162 |
} 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
|
163 |
|
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
|
164 |
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
|
165 |
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
|
166 |
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
|
167 |
} 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
|
168 |
|
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
|
169 |
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
|
170 |
} |
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
|
171 |
} |
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
|
172 |
|
9733
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
173 |
/* 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
|
174 |
{ |
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
|
175 |
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
|
176 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
177 |
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
|
178 |
} |
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 |
/* 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
|
181 |
{ |
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
|
182 |
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
|
183 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
184 |
/* 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
|
185 |
* 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
|
186 |
* there is no other way.. */ |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
187 |
Vehicle *vehicle; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
188 |
switch (::GetEngine(engine_id)->type) { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
189 |
case VEH_ROAD: { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
190 |
vehicle = new RoadVehicle(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
191 |
} break; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
192 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
193 |
case VEH_TRAIN: { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
194 |
vehicle = new Train(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
195 |
} break; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
196 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
197 |
case VEH_SHIP: { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
198 |
vehicle = new Ship(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
199 |
} break; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
200 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
201 |
case VEH_AIRCRAFT: { |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
202 |
vehicle = new Aircraft(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
203 |
} break; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
204 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
205 |
default: NOT_REACHED(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
206 |
} |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
207 |
|
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
208 |
vehicle->engine_type = engine_id; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
209 |
Money runningCost = vehicle->GetRunningCost(); |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
210 |
delete vehicle; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
211 |
return runningCost >> 8; |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
212 |
} |
49e424cd4edd
(svn r12212) [NoAI] -Add: added AIEngine::GetMaxAge, AIEngine::GetRunningCost and AIVehicle::GetRunningCost (Morloth)
truebrain
parents:
9724
diff
changeset
|
213 |
|
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
|
214 |
/* 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
|
215 |
{ |
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
|
216 |
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
|
217 |
|
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
|
218 |
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
|
219 |
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
|
220 |
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
|
221 |
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
|
222 |
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
|
223 |
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
|
224 |
} |
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
|
225 |
} |