equal
deleted
inserted
replaced
8 #include "../../vehicle.h" |
8 #include "../../vehicle.h" |
9 #include "../../depot.h" |
9 #include "../../depot.h" |
10 #include "../../engine.h" |
10 #include "../../engine.h" |
11 #include "../../player.h" |
11 #include "../../player.h" |
12 #include "../../aircraft.h" |
12 #include "../../aircraft.h" |
|
13 #include "../../strings.h" |
|
14 #include "table/strings.h" |
13 |
15 |
14 /* static */ bool AIVehicle::IsValidEngine(EngineID engine_id) |
16 /* static */ bool AIVehicle::IsValidEngine(EngineID engine_id) |
15 { |
17 { |
16 return ::IsEngineIndex(engine_id); // TODO: implement 'can I build this engine check' |
18 return ::IsEngineIndex(engine_id); // TODO: implement 'can I build this engine check' |
17 } |
19 } |
187 if (!this->IsValidVehicle(vehicle_id)) return false; |
189 if (!this->IsValidVehicle(vehicle_id)) return false; |
188 |
190 |
189 return this->DoCommand(0, vehicle_id, 0, CMD_SKIP_TO_ORDER); |
191 return this->DoCommand(0, vehicle_id, 0, CMD_SKIP_TO_ORDER); |
190 } |
192 } |
191 |
193 |
|
194 bool AIVehicle::SetName(VehicleID vehicle_id, const char *name) |
|
195 { |
|
196 if (!this->IsValidVehicle(vehicle_id)) return false; |
|
197 if (name == NULL) return false; |
|
198 |
|
199 _cmd_text = name; |
|
200 return this->DoCommand(0, vehicle_id, 0, CMD_NAME_VEHICLE); |
|
201 } |
|
202 |
192 /* static */ TileIndex AIVehicle::GetLocation(VehicleID vehicle_id) |
203 /* static */ TileIndex AIVehicle::GetLocation(VehicleID vehicle_id) |
193 { |
204 { |
194 if (!AIVehicle::IsValidVehicle(vehicle_id)) return INVALID_TILE; |
205 if (!AIVehicle::IsValidVehicle(vehicle_id)) return INVALID_TILE; |
195 |
206 |
196 return ::GetVehicle(vehicle_id)->tile; |
207 return ::GetVehicle(vehicle_id)->tile; |
206 /* static */ int32 AIVehicle::GetUnitNumber(VehicleID vehicle_id) |
217 /* static */ int32 AIVehicle::GetUnitNumber(VehicleID vehicle_id) |
207 { |
218 { |
208 if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1; |
219 if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1; |
209 |
220 |
210 return ::GetVehicle(vehicle_id)->unitnumber; |
221 return ::GetVehicle(vehicle_id)->unitnumber; |
|
222 } |
|
223 |
|
224 /* static */ char *AIVehicle::GetName(VehicleID vehicle_id) |
|
225 { |
|
226 if (!AIVehicle::IsValidVehicle(vehicle_id)) return NULL; |
|
227 |
|
228 static const int len = 64; |
|
229 char *vehicle_name = MallocT<char>(len); |
|
230 |
|
231 SetDParam(0, ::GetVehicle(vehicle_id)->unitnumber); |
|
232 GetString(vehicle_name, ::GetVehicle(vehicle_id)->string_id, &vehicle_name[len - 1]); |
|
233 return vehicle_name; |
211 } |
234 } |
212 |
235 |
213 /* static */ int32 AIVehicle::GetAge(VehicleID vehicle_id) |
236 /* static */ int32 AIVehicle::GetAge(VehicleID vehicle_id) |
214 { |
237 { |
215 if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1; |
238 if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1; |