(svn r12215) [NoAI] -Codechange: added '::' if a function comes from non-AI-API functions (was inconsistant till now)
[NoAI] -Codechange: removed AIOrder:: if we are in AIOrder class (and so for all other classes)
--- a/src/ai/api/ai_airport.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_airport.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -32,19 +32,19 @@
/* static */ int32 AIAirport::GetAirportWidth(AirportType type)
{
if (type > AT_HELISTATION) return 0;
- return GetAirport(type)->size_x;
+ return ::GetAirport(type)->size_x;
}
/* static */ int32 AIAirport::GetAirportHeight(AirportType type)
{
if (type > AT_HELISTATION) return 0;
- return GetAirport(type)->size_y;
+ return ::GetAirport(type)->size_y;
}
/* static */ int32 AIAirport::GetAirportCoverageRadius(AirportType type)
{
if (type > AT_HELISTATION) return 0;
- return _patches.modified_catchment ? GetAirport(type)->catchment : (uint)CA_UNMODIFIED;
+ return _patches.modified_catchment ? ::GetAirport(type)->catchment : (uint)CA_UNMODIFIED;
}
bool AIAirport::BuildAirport(TileIndex tile, AirportType type)
@@ -69,10 +69,10 @@
TileIndex AIAirport::GetHangarOfAirport(TileIndex tile)
{
- if (!IsTileType(tile, MP_STATION)) return INVALID_TILE;
+ if (!::IsTileType(tile, MP_STATION)) return INVALID_TILE;
- const Station *st = GetStationByTile(tile);
+ const Station *st = ::GetStationByTile(tile);
if (st->owner != _current_player) return INVALID_TILE;
- return ToTileIndexDiff(st->Airport()->airport_depots[0]) + st->xy;
+ return ::ToTileIndexDiff(st->Airport()->airport_depots[0]) + st->xy;
}
--- a/src/ai/api/ai_base.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_base.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -9,7 +9,7 @@
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
* but we pick InteractiveRandomRange if we are a network_server or network-client. */
- if (_networking) return InteractiveRandom();
+ if (_networking) return ::InteractiveRandom();
return ::Random();
}
@@ -17,7 +17,7 @@
{
/* We pick RandomRange if we are in SP (so when saved, we do the same over and over)
* but we pick InteractiveRandomRange if we are a network_server or network-client. */
- if (_networking) return InteractiveRandomRange(max);
+ if (_networking) return ::InteractiveRandomRange(max);
return ::RandomRange(max);
}
--- a/src/ai/api/ai_cargo.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_cargo.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -10,13 +10,13 @@
/* static */ bool AICargo::IsValidCargo(CargoID cargo_type)
{
- return (cargo_type < NUM_CARGO && GetCargo(cargo_type)->IsValid());
+ return (cargo_type < NUM_CARGO && ::GetCargo(cargo_type)->IsValid());
}
char *AICargo::GetCargoLabel(CargoID cargo_type)
{
- if (!this->IsValidCargo(cargo_type)) return NULL;
- const CargoSpec *cargo = GetCargo(cargo_type);
+ if (!IsValidCargo(cargo_type)) return NULL;
+ const CargoSpec *cargo = ::GetCargo(cargo_type);
/* cargo->label is a uint32 packing a 4 character non-terminated string,
* like "PASS", "COAL", "OIL_". New ones can be defined by NewGRFs */
@@ -30,13 +30,13 @@
bool AICargo::IsFreight(CargoID cargo_type)
{
- if (!this->IsValidCargo(cargo_type)) return false;
- const CargoSpec *cargo = GetCargo(cargo_type);
+ if (!IsValidCargo(cargo_type)) return false;
+ const CargoSpec *cargo = ::GetCargo(cargo_type);
return cargo->is_freight;
}
int32 AICargo::GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type)
{
- if (!this->IsValidCargo(cargo_type)) return 0;
- return GetTransportedGoodsIncome(1, distance, days_in_transit, cargo_type);
+ if (!IsValidCargo(cargo_type)) return 0;
+ return ::GetTransportedGoodsIncome(1, distance, days_in_transit, cargo_type);
}
--- a/src/ai/api/ai_company.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_company.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -16,7 +16,7 @@
{
if (company == MY_COMPANY) return (CompanyIndex)((byte)_current_player);
- return (IsValidPlayer((PlayerID)company) && GetPlayer((PlayerID)company)->is_active) ? company : INVALID_COMPANY;
+ return (::IsValidPlayer((PlayerID)company) && ::GetPlayer((PlayerID)company)->is_active) ? company : INVALID_COMPANY;
}
bool AICompany::SetCompanyName(const char *name)
@@ -35,8 +35,8 @@
static const int len = 64;
char *company_name = MallocT<char>(len);
- SetDParam(0, GetPlayer((PlayerID)company)->index);
- GetString(company_name, STR_COMPANY_NAME, &company_name[len - 1]);
+ ::SetDParam(0, GetPlayer((PlayerID)company)->index);
+ ::GetString(company_name, STR_COMPANY_NAME, &company_name[len - 1]);
return company_name;
}
@@ -55,8 +55,8 @@
static const int len = 64;
char *president_name = MallocT<char>(len);
if (company != INVALID_COMPANY) {
- SetDParam(0, GetPlayer((PlayerID)company)->index);
- GetString(president_name, STR_PLAYER_NAME, &president_name[len - 1]);
+ ::SetDParam(0, GetPlayer((PlayerID)company)->index);
+ ::GetString(president_name, STR_PLAYER_NAME, &president_name[len - 1]);
} else {
*president_name = '\0';
}
@@ -69,7 +69,7 @@
company = this->ResolveCompanyIndex(company);
if (company == INVALID_COMPANY) return 0;
- return GetPlayer((PlayerID)company)->cur_economy.company_value;
+ return ::GetPlayer((PlayerID)company)->cur_economy.company_value;
}
int32 AICompany::GetBankBalance(AICompany::CompanyIndex company)
@@ -77,12 +77,12 @@
company = this->ResolveCompanyIndex(company);
if (company == INVALID_COMPANY) return 0;
- return ClampToI32(GetPlayer((PlayerID)company)->player_money);
+ return ::ClampToI32(GetPlayer((PlayerID)company)->player_money);
}
int32 AICompany::GetLoanAmount()
{
- return GetPlayer(_current_player)->current_loan;
+ return ::GetPlayer(_current_player)->current_loan;
}
int32 AICompany::GetMaxLoanAmount()
--- a/src/ai/api/ai_engine.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_engine.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -18,12 +18,12 @@
/* static */ bool AIEngine::IsValidEngine(EngineID engine_id)
{
- return ::IsEngineIndex(engine_id) && HasBit(GetEngine(engine_id)->player_avail, _current_player);
+ return ::IsEngineIndex(engine_id) && HasBit(::GetEngine(engine_id)->player_avail, _current_player);
}
/* static */ char *AIEngine::GetName(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return NULL;
+ if (!IsValidEngine(engine_id)) return NULL;
static const int len = 64;
char *engine_name = MallocT<char>(len);
@@ -35,21 +35,21 @@
/* static */ CargoID AIEngine::GetCargoType(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return 0;
+ if (!IsValidEngine(engine_id)) return 0;
switch (::GetEngine(engine_id)->type) {
case VEH_ROAD: {
- const RoadVehicleInfo *vi = RoadVehInfo(engine_id);
+ const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id);
return vi->cargo_type;
} break;
case VEH_TRAIN: {
- const RailVehicleInfo *vi = RailVehInfo(engine_id);
+ const RailVehicleInfo *vi = ::RailVehInfo(engine_id);
return vi->cargo_type;
} break;
case VEH_SHIP: {
- const ShipVehicleInfo *vi = ShipVehInfo(engine_id);
+ const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id);
return vi->cargo_type;
} break;
@@ -63,26 +63,26 @@
/* static */ uint32 AIEngine::GetCapacity(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return 0;
+ if (!IsValidEngine(engine_id)) return 0;
switch (::GetEngine(engine_id)->type) {
case VEH_ROAD: {
- const RoadVehicleInfo *vi = RoadVehInfo(engine_id);
+ const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id);
return vi->capacity;
} break;
case VEH_TRAIN: {
- const RailVehicleInfo *vi = RailVehInfo(engine_id);
+ const RailVehicleInfo *vi = ::RailVehInfo(engine_id);
return vi->capacity;
} break;
case VEH_SHIP: {
- const ShipVehicleInfo *vi = ShipVehInfo(engine_id);
+ const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id);
return vi->capacity;
} break;
case VEH_AIRCRAFT: {
- const AircraftVehicleInfo *vi = AircraftVehInfo(engine_id);
+ const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id);
return vi->passenger_capacity;
} break;
@@ -92,35 +92,35 @@
/* static */ uint32 AIEngine::GetReliability(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return 0;
+ if (!IsValidEngine(engine_id)) return 0;
return (::GetEngine(engine_id)->reliability * 100 >> 16);
}
/* static */ uint32 AIEngine::GetMaxSpeed(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return 0;
+ if (!IsValidEngine(engine_id)) return 0;
switch (::GetEngine(engine_id)->type) {
case VEH_ROAD: {
- const RoadVehicleInfo *vi = RoadVehInfo(engine_id);
+ const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id);
/* Internal speeds are km/h * 2 */
return vi->max_speed / 2;
} break;
case VEH_TRAIN: {
- const RailVehicleInfo *vi = RailVehInfo(engine_id);
+ const RailVehicleInfo *vi = ::RailVehInfo(engine_id);
return vi->max_speed;
} break;
case VEH_SHIP: {
- const ShipVehicleInfo *vi = ShipVehInfo(engine_id);
+ const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id);
/* Internal speeds are km/h * 2 */
return vi->max_speed / 2;
} break;
case VEH_AIRCRAFT: {
- const AircraftVehicleInfo *vi = AircraftVehInfo(engine_id);
+ const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id);
return vi->max_speed;
} break;
@@ -130,26 +130,26 @@
/* static */ uint32 AIEngine::GetPrice(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return 0;
+ if (!IsValidEngine(engine_id)) return 0;
switch (::GetEngine(engine_id)->type) {
case VEH_ROAD: {
- const RoadVehicleInfo *vi = RoadVehInfo(engine_id);
+ const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id);
return (_price.roadveh_base >> 3) * vi->base_cost >> 5;
} break;
case VEH_TRAIN: {
- const RailVehicleInfo *vi = RailVehInfo(engine_id);
+ const RailVehicleInfo *vi = ::RailVehInfo(engine_id);
return (_price.build_railvehicle >> 3) * vi->base_cost >> 5;
} break;
case VEH_SHIP: {
- const ShipVehicleInfo *vi = ShipVehInfo(engine_id);
+ const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id);
return (_price.ship_base >> 3) * vi->base_cost >> 5;
} break;
case VEH_AIRCRAFT: {
- const AircraftVehicleInfo *vi = AircraftVehInfo(engine_id);
+ const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id);
return (_price.aircraft_base >> 3) * vi->base_cost >> 5;
} break;
@@ -159,14 +159,14 @@
/* static */ uint32 AIEngine::GetMaxAge(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return 0;
+ if (!IsValidEngine(engine_id)) return 0;
return ::GetEngine(engine_id)->lifelength * 366;
}
/* static */ Money AIEngine::GetRunningCost(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return 0;
+ if (!IsValidEngine(engine_id)) return 0;
/* We need to create an instance in order to obtain GetRunningCost.
* This means we temporary allocate a vehicle in the pool, but
@@ -200,7 +200,7 @@
/* static */ AIVehicle::VehicleType AIEngine::GetVehicleType(EngineID engine_id)
{
- if (!AIEngine::IsValidEngine(engine_id)) return AIVehicle::VEHICLE_INVALID;
+ if (!IsValidEngine(engine_id)) return AIVehicle::VEHICLE_INVALID;
switch (::GetEngine(engine_id)->type) {
case VEH_ROAD: return AIVehicle::VEHICLE_ROAD;
--- a/src/ai/api/ai_industry.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_industry.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -25,23 +25,23 @@
char *AIIndustry::GetName(IndustryID industry_id)
{
- if (!this->IsValidIndustry(industry_id)) return NULL;
+ if (!IsValidIndustry(industry_id)) return NULL;
static const int len = 64;
char *industry_name = MallocT<char>(len);
- SetDParam(0, industry_id);
- GetString(industry_name, STR_INDUSTRY, &industry_name[len - 1]);
+ ::SetDParam(0, industry_id);
+ ::GetString(industry_name, STR_INDUSTRY, &industry_name[len - 1]);
return industry_name;
}
/* static */ int32 AIIndustry::GetProduction(IndustryID industry_id, CargoID cargo_id)
{
- if (!AIIndustry::IsValidIndustry(industry_id)) return -1;
+ if (!IsValidIndustry(industry_id)) return -1;
if (!AICargo::IsValidCargo(cargo_id)) return -1;
const Industry *i = ::GetIndustry(industry_id);
- const IndustrySpec *indsp = GetIndustrySpec(i->type);
+ const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
if (indsp->produced_cargo[0] == cargo_id) return i->production_rate[0];
if (indsp->produced_cargo[1] == cargo_id) return i->production_rate[1];
@@ -50,11 +50,11 @@
/* static */ bool AIIndustry::IsCargoAccepted(IndustryID industry_id, CargoID cargo_id)
{
- if (!AIIndustry::IsValidIndustry(industry_id)) return false;
+ if (!IsValidIndustry(industry_id)) return false;
if (!AICargo::IsValidCargo(cargo_id)) return false;
const Industry *i = ::GetIndustry(industry_id);
- const IndustrySpec *indsp = GetIndustrySpec(i->type);
+ const IndustrySpec *indsp = ::GetIndustrySpec(i->type);
if (indsp->accepts_cargo[0] == cargo_id) return true;
if (indsp->accepts_cargo[1] == cargo_id) return true;
@@ -65,6 +65,6 @@
/* static */ TileIndex AIIndustry::GetLocation(IndustryID industry_id)
{
- if (!AIIndustry::IsValidIndustry(industry_id)) return INVALID_TILE;
+ if (!IsValidIndustry(industry_id)) return INVALID_TILE;
return ::GetIndustry(industry_id)->xy;
}
--- a/src/ai/api/ai_order.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_order.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -64,7 +64,7 @@
TileIndex AIOrder::GetOrderDestination(VehicleID vehicle_id, uint32 order_id)
{
- if (!AIOrder::IsValidVehicleOrder(vehicle_id, order_id)) return INVALID_TILE;
+ if (!IsValidVehicleOrder(vehicle_id, order_id)) return INVALID_TILE;
Order *order = ::GetVehicle(vehicle_id)->orders;
for (uint i = 0; i < order_id; i++) order = order->next;
@@ -79,7 +79,7 @@
AIOrder::AIOrderFlags AIOrder::GetOrderFlags(VehicleID vehicle_id, uint32 order_id)
{
- if (!AIOrder::IsValidVehicleOrder(vehicle_id, order_id)) return AIOF_INVALID;
+ if (!IsValidVehicleOrder(vehicle_id, order_id)) return AIOF_INVALID;
Order *order = ::GetVehicle(vehicle_id)->orders;
for (uint i = 0; i < order_id; i++) order = order->next;
@@ -90,14 +90,14 @@
bool AIOrder::AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags)
{
if (!AIVehicle::IsValidVehicle(vehicle_id)) return false;
- return this->InsertOrder(vehicle_id, GetVehicle(vehicle_id)->num_orders, destination, order_flags);
+ return this->InsertOrder(vehicle_id, ::GetVehicle(vehicle_id)->num_orders, destination, order_flags);
}
bool AIOrder::InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrder::AIOrderFlags order_flags)
{
/* IsValidVehicleOrder is not good enough because it does not allow appending. */
if (!AIVehicle::IsValidVehicle(vehicle_id) || order_id > ::GetVehicle(vehicle_id)->num_orders ||
- !this->AreOrderFlagsValid(destination, order_flags)) return false;
+ !AreOrderFlagsValid(destination, order_flags)) return false;
Order order;
order.type = ::GetOrderTypeByTile(destination);
@@ -122,7 +122,7 @@
bool AIOrder::ChangeOrder(VehicleID vehicle_id, uint32 order_id, AIOrder::AIOrderFlags order_flags)
{
if (!IsValidVehicleOrder(vehicle_id, order_id) ||
- !this->AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_id), order_flags)) return false;
+ !AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_id), order_flags)) return false;
for (;;) {
/* Loop as long as there is a difference between the requested and
--- a/src/ai/api/ai_sign.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_sign.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -28,7 +28,7 @@
char *AISign::GetText(SignID sign_id)
{
- if (!AISign::IsValidSign(sign_id)) return NULL;
+ if (!IsValidSign(sign_id)) return NULL;
static const int len = 64;
char *sign_name = MallocT<char>(len);
@@ -40,7 +40,7 @@
TileIndex AISign::GetLocation(SignID sign_id)
{
- if (!AISign::IsValidSign(sign_id)) return INVALID_TILE;
+ if (!IsValidSign(sign_id)) return INVALID_TILE;
const Sign *sign = ::GetSign(sign_id);
return ::TileVirtXY(sign->x, sign->y);
}
--- a/src/ai/api/ai_station.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_station.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -27,26 +27,26 @@
/* static */ char *AIStation::GetName(StationID station_id)
{
- if (!AIStation::IsValidStation(station_id)) return NULL;
+ if (!IsValidStation(station_id)) return NULL;
static const int len = 64;
char *station_name = MallocT<char>(len);
- SetDParam(0, GetStation(station_id)->index);
- GetString(station_name, STR_STATION, &station_name[len - 1]);
+ ::SetDParam(0, GetStation(station_id)->index);
+ ::GetString(station_name, STR_STATION, &station_name[len - 1]);
return station_name;
}
/* static */ TileIndex AIStation::GetLocation(StationID station_id)
{
- if (!AIStation::IsValidStation(station_id)) return INVALID_TILE;
+ if (!IsValidStation(station_id)) return INVALID_TILE;
return ::GetStation(station_id)->xy;
}
/* static */ int32 AIStation::GetCargoWaiting(StationID station_id, CargoID cargo_id)
{
- if (!AIStation::IsValidStation(station_id)) return -1;
+ if (!IsValidStation(station_id)) return -1;
if (!AICargo::IsValidCargo(cargo_id)) return -1;
return ::GetStation(station_id)->goods[cargo_id].cargo.Count();
@@ -54,7 +54,7 @@
/* static */ int32 AIStation::GetCargoRating(StationID station_id, CargoID cargo_id)
{
- if (!AIStation::IsValidStation(station_id)) return -1;
+ if (!IsValidStation(station_id)) return -1;
if (!AICargo::IsValidCargo(cargo_id)) return -1;
return ::GetStation(station_id)->goods[cargo_id].rating * 101 >> 8;
--- a/src/ai/api/ai_tile.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_tile.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -56,7 +56,7 @@
if (tile >= ::MapSize()) return 0;
AcceptedCargo accepts;
- GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED);
+ ::GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED);
return accepts[cargo_type];
}
@@ -66,7 +66,7 @@
if (tile >= ::MapSize()) return 0;
AcceptedCargo produced;
- GetProductionAroundTiles(produced, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED);
+ ::GetProductionAroundTiles(produced, tile, width, height, _patches.modified_catchment ? radius : (uint)CA_UNMODIFIED);
return produced[cargo_type];
}
--- a/src/ai/api/ai_town.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_town.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -26,26 +26,26 @@
char *AITown::GetName(TownID town_id)
{
- if (!AITown::IsValidTown(town_id)) return NULL;
+ if (!IsValidTown(town_id)) return NULL;
static const int len = 64;
char *town_name = MallocT<char>(len);
- SetDParam(0, town_id);
- GetString(town_name, STR_TOWN, &town_name[len - 1]);
+ ::SetDParam(0, town_id);
+ ::GetString(town_name, STR_TOWN, &town_name[len - 1]);
return town_name;
}
int32 AITown::GetPopulation(TownID town_id)
{
- if (!AITown::IsValidTown(town_id)) return 0;
+ if (!IsValidTown(town_id)) return 0;
const Town *t = ::GetTown(town_id);
return t->population;
}
TileIndex AITown::GetLocation(TownID town_id)
{
- if (!AITown::IsValidTown(town_id)) return INVALID_TILE;
+ if (!IsValidTown(town_id)) return INVALID_TILE;
const Town *t = ::GetTown(town_id);
return t->xy;
}
--- a/src/ai/api/ai_vehicle.cpp Fri Feb 22 11:54:33 2008 +0000
+++ b/src/ai/api/ai_vehicle.cpp Fri Feb 22 12:13:41 2008 +0000
@@ -17,7 +17,7 @@
/* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
{
- return ::IsValidVehicleID(vehicle_id) && ::GetVehicle(vehicle_id)->owner == _current_player && GetVehicle(vehicle_id)->IsPrimaryVehicle();
+ return ::IsValidVehicleID(vehicle_id) && ::GetVehicle(vehicle_id)->owner == _current_player && ::GetVehicle(vehicle_id)->IsPrimaryVehicle();
}
VehicleID AIVehicle::BuildVehicle(TileIndex depot, EngineID engine_id)
@@ -41,7 +41,7 @@
VehicleID AIVehicle::CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders)
{
- if (!this->IsValidVehicle(vehicle_id)) return false;
+ if (!IsValidVehicle(vehicle_id)) return false;
/* Reset the internal NewVehicleID in case we are in TestMode */
AIObject::SetNewVehicleID(0);
@@ -52,7 +52,7 @@
bool AIVehicle::RefitVehicle(VehicleID vehicle_id, CargoID cargo)
{
- if (!this->IsValidVehicle(vehicle_id) || !AICargo::IsValidCargo(cargo)) return false;
+ if (!IsValidVehicle(vehicle_id) || !AICargo::IsValidCargo(cargo)) return false;
switch (::GetVehicle(vehicle_id)->type) {
case VEH_ROAD: return this->DoCommand(0, vehicle_id, cargo, CMD_REFIT_ROAD_VEH);
@@ -66,7 +66,7 @@
bool AIVehicle::SellVehicle(VehicleID vehicle_id)
{
- if (!this->IsValidVehicle(vehicle_id)) return false;
+ if (!IsValidVehicle(vehicle_id)) return false;
switch (::GetVehicle(vehicle_id)->type) {
case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_SELL_ROAD_VEH);
@@ -79,7 +79,7 @@
bool AIVehicle::SendVehicleToDepot(VehicleID vehicle_id)
{
- if (!this->IsValidVehicle(vehicle_id)) return false;
+ if (!IsValidVehicle(vehicle_id)) return false;
switch (::GetVehicle(vehicle_id)->type) {
case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_SEND_ROADVEH_TO_DEPOT);
@@ -92,19 +92,19 @@
bool AIVehicle::IsInDepot(VehicleID vehicle_id)
{
- if (!this->IsValidVehicle(vehicle_id)) return false;
+ if (!IsValidVehicle(vehicle_id)) return false;
return ::GetVehicle(vehicle_id)->IsInDepot();
}
bool AIVehicle::IsStoppedInDepot(VehicleID vehicle_id)
{
- if (!this->IsValidVehicle(vehicle_id)) return false;
+ if (!IsValidVehicle(vehicle_id)) return false;
return ::GetVehicle(vehicle_id)->IsStoppedInDepot();
}
bool AIVehicle::StartStopVehicle(VehicleID vehicle_id)
{
- if (!this->IsValidVehicle(vehicle_id)) return false;
+ if (!IsValidVehicle(vehicle_id)) return false;
switch (::GetVehicle(vehicle_id)->type) {
case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_START_STOP_ROADVEH);
@@ -124,7 +124,7 @@
bool AIVehicle::SetName(VehicleID vehicle_id, const char *name)
{
- if (!this->IsValidVehicle(vehicle_id)) return false;
+ if (!IsValidVehicle(vehicle_id)) return false;
if (name == NULL) return false;
_cmd_text = name;
@@ -133,28 +133,28 @@
/* static */ TileIndex AIVehicle::GetLocation(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return INVALID_TILE;
+ if (!IsValidVehicle(vehicle_id)) return INVALID_TILE;
return ::GetVehicle(vehicle_id)->tile;
}
/* static */ EngineID AIVehicle::GetEngineType(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return INVALID_ENGINE;
+ if (!IsValidVehicle(vehicle_id)) return INVALID_ENGINE;
return ::GetVehicle(vehicle_id)->engine_type;
}
/* static */ int32 AIVehicle::GetUnitNumber(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
+ if (!IsValidVehicle(vehicle_id)) return -1;
return ::GetVehicle(vehicle_id)->unitnumber;
}
/* static */ char *AIVehicle::GetName(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return NULL;
+ if (!IsValidVehicle(vehicle_id)) return NULL;
static const int len = 64;
char *vehicle_name = MallocT<char>(len);
@@ -166,51 +166,51 @@
/* static */ int32 AIVehicle::GetAge(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
+ if (!IsValidVehicle(vehicle_id)) return -1;
return ::GetVehicle(vehicle_id)->age;
}
/* static */ int32 AIVehicle::GetMaxAge(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
+ if (!IsValidVehicle(vehicle_id)) return -1;
return ::GetVehicle(vehicle_id)->max_age;
}
/* static */ Money AIVehicle::GetRunningCost(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
+ if (!IsValidVehicle(vehicle_id)) return -1;
return ::GetVehicle(vehicle_id)->GetRunningCost() >> 8;
}
/* static */ int32 AIVehicle::GetAgeLeft(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
+ if (!IsValidVehicle(vehicle_id)) return -1;
return ::GetVehicle(vehicle_id)->max_age - ::GetVehicle(vehicle_id)->age;
}
/* static */ int32 AIVehicle::GetProfitThisYear(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
+ if (!IsValidVehicle(vehicle_id)) return -1;
return ::GetVehicle(vehicle_id)->GetDisplayProfitThisYear();
}
/* static */ int32 AIVehicle::GetProfitLastYear(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return -1;
+ if (!IsValidVehicle(vehicle_id)) return -1;
return ::GetVehicle(vehicle_id)->GetDisplayProfitLastYear();
}
/* static */ AIVehicle::VehicleType AIVehicle::GetVehicleType(VehicleID vehicle_id)
{
- if (!AIVehicle::IsValidVehicle(vehicle_id)) return VEHICLE_INVALID;
+ if (!IsValidVehicle(vehicle_id)) return VEHICLE_INVALID;
- switch (GetVehicle(vehicle_id)->type) {
+ switch (::GetVehicle(vehicle_id)->type) {
case VEH_ROAD: return VEHICLE_ROAD;
case VEH_TRAIN: return VEHICLE_RAIL;
case VEH_SHIP: return VEHICLE_WATER;