diff options
author | truebrain <truebrain@openttd.org> | 2009-01-16 00:05:26 +0000 |
---|---|---|
committer | truebrain <truebrain@openttd.org> | 2009-01-16 00:05:26 +0000 |
commit | 94dd36d1eceb487616f9f0ea260fbe00d84cc267 (patch) | |
tree | 9e3c6b823cc8e282db94a22336d126affeaaac1c /src/ai | |
parent | 5119132dda807aacb65e2afcce22665e7eedc577 (diff) | |
download | openttd-94dd36d1eceb487616f9f0ea260fbe00d84cc267.tar.xz |
(svn r15101) -Change [API CHANGE]: more consistant naming for consts:
INVALID_TOWN_RATING -> TOWN_RATING_INVALID
INVALID_TRANSPORT -> TRANSPORT_INVALID
INVALID_ORDER -> ORDER_INVALID
INVALID_GROUP -> GROUP_INVALID
GROUP_ALL/DEFAULT -> ALL/DEFAULT_GROUP
VEHICLE_RAIL/ROAD/.. -> VT_RAIL/ROAD/..
MY_COMPANY -> COMPANY_SELF
FIRST/LAST/INVALID_COMPANY -> COMPANY_FIRST/LAST/INVALID
Diffstat (limited to 'src/ai')
-rw-r--r-- | src/ai/ai_instance.cpp | 7 | ||||
-rw-r--r-- | src/ai/api/ai_bridge.cpp | 12 | ||||
-rw-r--r-- | src/ai/api/ai_company.cpp | 24 | ||||
-rw-r--r-- | src/ai/api/ai_company.hpp | 34 | ||||
-rw-r--r-- | src/ai/api/ai_company.hpp.sq | 8 | ||||
-rw-r--r-- | src/ai/api/ai_engine.cpp | 26 | ||||
-rw-r--r-- | src/ai/api/ai_event_types.hpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_gamesettings.cpp | 8 | ||||
-rw-r--r-- | src/ai/api/ai_group.cpp | 14 | ||||
-rw-r--r-- | src/ai/api/ai_group.hpp | 6 | ||||
-rw-r--r-- | src/ai/api/ai_group.hpp.sq | 6 | ||||
-rw-r--r-- | src/ai/api/ai_map.hpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_order.cpp | 14 | ||||
-rw-r--r-- | src/ai/api/ai_order.hpp | 6 | ||||
-rw-r--r-- | src/ai/api/ai_order.hpp.sq | 4 | ||||
-rw-r--r-- | src/ai/api/ai_subsidy.cpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_tile.cpp | 6 | ||||
-rw-r--r-- | src/ai/api/ai_tile.hpp | 4 | ||||
-rw-r--r-- | src/ai/api/ai_tile.hpp.sq | 2 | ||||
-rw-r--r-- | src/ai/api/ai_town.cpp | 6 | ||||
-rw-r--r-- | src/ai/api/ai_town.hpp | 6 | ||||
-rw-r--r-- | src/ai/api/ai_town.hpp.sq | 2 | ||||
-rw-r--r-- | src/ai/api/ai_tunnel.cpp | 8 | ||||
-rw-r--r-- | src/ai/api/ai_tunnel.hpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_vehicle.cpp | 19 | ||||
-rw-r--r-- | src/ai/api/ai_vehicle.hpp | 14 | ||||
-rw-r--r-- | src/ai/api/ai_vehicle.hpp.sq | 9 |
27 files changed, 132 insertions, 121 deletions
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index cfd952505..cc8893c9d 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -10,6 +10,7 @@ #include "../string_func.h" #include "../settings_type.h" #include "../company_base.h" +#include "../vehicle_base.h" #include "../saveload/saveload.h" #include "table/strings.h" @@ -18,14 +19,14 @@ #include "../script/squirrel_helper.hpp" #include "../script/squirrel_class.hpp" #include "../script/squirrel_std.hpp" + +#define DEFINE_SCRIPT_FILES + #include "ai.hpp" -#include "api/ai_controller.hpp" #include "ai_info.hpp" #include "ai_storage.hpp" #include "ai_instance.hpp" -#define DEFINE_SCRIPT_FILES - /* Convert all AI related classes to Squirrel data. * Note: this line a marker in squirrel_export.sh. Do not change! */ #include "api/ai_abstractlist.hpp.sq" diff --git a/src/ai/api/ai_bridge.cpp b/src/ai/api/ai_bridge.cpp index 86eb5f6f1..56fe7061b 100644 --- a/src/ai/api/ai_bridge.cpp +++ b/src/ai/api/ai_bridge.cpp @@ -56,27 +56,27 @@ static void _DoCommandReturnBuildBridge1(class AIInstance *instance) EnforcePrecondition(false, start != end); EnforcePrecondition(false, ::IsValidTile(start) && ::IsValidTile(end)); EnforcePrecondition(false, TileX(start) == TileX(end) || TileY(start) == TileY(end)); - EnforcePrecondition(false, vehicle_type == AIVehicle::VEHICLE_ROAD || vehicle_type == AIVehicle::VEHICLE_RAIL || vehicle_type == AIVehicle::VEHICLE_WATER); - EnforcePrecondition(false, vehicle_type != AIVehicle::VEHICLE_RAIL || AIRail::IsRailTypeAvailable(AIRail::GetCurrentRailType())); + EnforcePrecondition(false, vehicle_type == AIVehicle::VT_ROAD || vehicle_type == AIVehicle::VT_RAIL || vehicle_type == AIVehicle::VT_WATER); + EnforcePrecondition(false, vehicle_type != AIVehicle::VT_RAIL || AIRail::IsRailTypeAvailable(AIRail::GetCurrentRailType())); uint type = 0; switch (vehicle_type) { - case AIVehicle::VEHICLE_ROAD: + case AIVehicle::VT_ROAD: type |= (TRANSPORT_ROAD << 15); type |= (RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()) << 8); break; - case AIVehicle::VEHICLE_RAIL: + case AIVehicle::VT_RAIL: type |= (TRANSPORT_RAIL << 15); type |= (AIRail::GetCurrentRailType() << 8); break; - case AIVehicle::VEHICLE_WATER: + case AIVehicle::VT_WATER: type |= (TRANSPORT_WATER << 15); break; default: NOT_REACHED(); } /* For rail and water we do nothing special */ - if (vehicle_type == AIVehicle::VEHICLE_RAIL || vehicle_type == AIVehicle::VEHICLE_WATER) { + if (vehicle_type == AIVehicle::VT_RAIL || vehicle_type == AIVehicle::VT_WATER) { return AIObject::DoCommand(end, start, type | bridge_id, CMD_BUILD_BRIDGE); } diff --git a/src/ai/api/ai_company.cpp b/src/ai/api/ai_company.cpp index 9a426bd2b..4040ab9c1 100644 --- a/src/ai/api/ai_company.cpp +++ b/src/ai/api/ai_company.cpp @@ -19,14 +19,14 @@ /* static */ AICompany::CompanyID AICompany::ResolveCompanyID(AICompany::CompanyID company) { - if (company == MY_COMPANY) return (CompanyID)((byte)_current_company); + if (company == COMPANY_SELF) return (CompanyID)((byte)_current_company); - return ::IsValidCompanyID((::CompanyID)company) ? company : INVALID_COMPANY; + return ::IsValidCompanyID((::CompanyID)company) ? company : COMPANY_INVALID; } /* static */ bool AICompany::IsMine(AICompany::CompanyID company) { - return ResolveCompanyID(company) == ResolveCompanyID(MY_COMPANY); + return ResolveCompanyID(company) == ResolveCompanyID(COMPANY_SELF); } /* static */ bool AICompany::SetCompanyName(const char *name) @@ -52,7 +52,7 @@ /* static */ const char *AICompany::GetName(AICompany::CompanyID company) { company = ResolveCompanyID(company); - if (company == INVALID_COMPANY) return NULL; + if (company == COMPANY_INVALID) return NULL; static const int len = 64; char *company_name = MallocT<char>(len); @@ -75,7 +75,7 @@ static const int len = 64; char *president_name = MallocT<char>(len); - if (company != INVALID_COMPANY) { + if (company != COMPANY_INVALID) { ::SetDParam(0, company); ::GetString(president_name, STR_PRESIDENT_NAME, &president_name[len - 1]); } else { @@ -88,7 +88,7 @@ /* static */ Money AICompany::GetCompanyValue(AICompany::CompanyID company) { company = ResolveCompanyID(company); - if (company == INVALID_COMPANY) return -1; + if (company == COMPANY_INVALID) return -1; return ::CalculateCompanyValue(::GetCompany((CompanyID)company)); } @@ -96,7 +96,7 @@ /* static */ Money AICompany::GetBankBalance(AICompany::CompanyID company) { company = ResolveCompanyID(company); - if (company == INVALID_COMPANY) return -1; + if (company == COMPANY_INVALID) return -1; return ::GetCompany((CompanyID)company)->money; } @@ -121,7 +121,7 @@ EnforcePrecondition(false, loan >= 0); EnforcePrecondition(false, (loan % GetLoanInterval()) == 0); EnforcePrecondition(false, loan <= GetMaxLoanAmount()); - EnforcePrecondition(false, (loan - GetLoanAmount() + GetBankBalance(MY_COMPANY)) >= 0); + EnforcePrecondition(false, (loan - GetLoanAmount() + GetBankBalance(COMPANY_SELF)) >= 0); if (loan == GetLoanAmount()) return true; @@ -154,7 +154,7 @@ /* static */ TileIndex AICompany::GetCompanyHQ(CompanyID company) { company = ResolveCompanyID(company); - if (company == INVALID_COMPANY) return INVALID_TILE; + if (company == COMPANY_INVALID) return INVALID_TILE; TileIndex loc = ::GetCompany((CompanyID)company)->location_of_HQ; return (loc == 0) ? INVALID_TILE : loc; @@ -168,7 +168,7 @@ /* static */ bool AICompany::GetAutoRenewStatus(CompanyID company) { company = ResolveCompanyID(company); - if (company == INVALID_COMPANY) return false; + if (company == COMPANY_INVALID) return false; return ::GetCompany((CompanyID)company)->engine_renew; } @@ -181,7 +181,7 @@ /* static */ int16 AICompany::GetAutoRenewMonths(CompanyID company) { company = ResolveCompanyID(company); - if (company == INVALID_COMPANY) return 0; + if (company == COMPANY_INVALID) return 0; return ::GetCompany((CompanyID)company)->engine_renew_months; } @@ -194,7 +194,7 @@ /* static */ uint32 AICompany::GetAutoRenewMoney(CompanyID company) { company = ResolveCompanyID(company); - if (company == INVALID_COMPANY) return 0; + if (company == COMPANY_INVALID) return 0; return ::GetCompany((CompanyID)company)->engine_renew_money; } diff --git a/src/ai/api/ai_company.hpp b/src/ai/api/ai_company.hpp index 2497e43b7..bc08e9630 100644 --- a/src/ai/api/ai_company.hpp +++ b/src/ai/api/ai_company.hpp @@ -16,17 +16,21 @@ public: /** Different constants related to CompanyID. */ enum CompanyID { - INVALID_COMPANY = -1, //!< An invalid company. - FIRST_COMPANY = 0, //!< The first available company. - LAST_COMPANY = 7, //!< The last available company. - MY_COMPANY = 8, //!< Constant that gets resolved to the correct company index for your company. + COMPANY_INVALID = -1, //!< An invalid company. + +#ifdef DEFINE_SCRIPT_FILES + COMPANY_FIRST = 0, //!< The first available company. + COMPANY_LAST = ::MAX_COMPANIES, //!< The last available company. +#endif /* DEFINE_SCRIPT_FILES */ + + COMPANY_SELF = 254, //!< Constant that gets resolved to the correct company index for your company. }; /** * Resolved the given company index to the correct index for the company. If - * the company index was MY_COMPANY it will be resolved to the index of + * the company index was COMPANY_SELF it will be resolved to the index of * your company. If the company with the given index does not exist it will - * return INVALID_COMPANY. + * return COMPANY_INVALID. * @param company The company index to resolve. * @return The resolved company index. */ @@ -62,7 +66,7 @@ public: /** * Get the name of the given company. * @param company The company to get the name for. - * @pre ResolveCompanyID(company) != INVALID_COMPANY + * @pre ResolveCompanyID(company) != COMPANY_INVALID * @return The name of the given company. */ static const char *GetName(CompanyID company); @@ -79,7 +83,7 @@ public: /** * Get the name of the president of the given company. * @param company The company to get the president's name for. - * @pre ResolveCompanyID(company) != INVALID_COMPANY + * @pre ResolveCompanyID(company) != COMPANY_INVALID * @return The name of the president of the given company. */ static const char *GetPresidentName(CompanyID company); @@ -130,7 +134,7 @@ public: /** * Gets the current value of the given company. * @param company The company to get the company value of. - * @pre ResolveCompanyID(company) != INVALID_COMPANY + * @pre ResolveCompanyID(company) != COMPANY_INVALID * @return The current value of the given company. */ static Money GetCompanyValue(CompanyID company); @@ -138,7 +142,7 @@ public: /** * Gets the bank balance. In other words, the amount of money the given company can spent. * @param company The company to get the bank balance of. - * @pre ResolveCompanyID(company) != INVALID_COMPANY + * @pre ResolveCompanyID(company) != COMPANY_INVALID * @return The actual bank balance. */ static Money GetBankBalance(CompanyID company); @@ -158,8 +162,8 @@ public: /** * Return the location of a company's HQ. * @param company The company the get the HQ of. - * @pre ResolveCompanyID(company) != INVALID_COMPANY. - * @return The tile of the company's HQ, this tile is the most nothern tile of that HQ, or INVALID_TILE if there is no HQ yet. + * @pre ResolveCompanyID(company) != COMPANY_INVALID. + * @return The tile of the company's HQ, this tile is the most nothern tile of that HQ, or TILE_INVALID if there is no HQ yet. */ static TileIndex GetCompanyHQ(CompanyID company); @@ -173,7 +177,7 @@ public: /** * Return whether autorenew is enabled for a company. * @param company The company to get the autorenew status of. - * @pre ResolveCompanyID(company) != INVALID_COMPANY. + * @pre ResolveCompanyID(company) != COMPANY_INVALID. * @return True if autorenew is enabled. */ static bool GetAutoRenewStatus(CompanyID company); @@ -188,7 +192,7 @@ public: /** * Return the number of months before/after max age to autorenew an engine for a company. * @param company The company to get the autorenew months of. - * @pre ResolveCompanyID(company) != INVALID_COMPANY. + * @pre ResolveCompanyID(company) != COMPANY_INVALID. * @return The months before/after max age of engine. */ static int16 GetAutoRenewMonths(CompanyID company); @@ -203,7 +207,7 @@ public: /** * Return the minimum money needed to autorenew an engine for a company. * @param company The company to get the autorenew money of. - * @pre ResolveCompanyID(company) != INVALID_COMPANY. + * @pre ResolveCompanyID(company) != COMPANY_INVALID. * @return The minimum required money for autorenew to work. */ static uint32 GetAutoRenewMoney(CompanyID company); diff --git a/src/ai/api/ai_company.hpp.sq b/src/ai/api/ai_company.hpp.sq index 0f0bb5ccf..9f5bfe4b5 100644 --- a/src/ai/api/ai_company.hpp.sq +++ b/src/ai/api/ai_company.hpp.sq @@ -21,10 +21,10 @@ void SQAICompany_Register(Squirrel *engine) { SQAICompany.PreRegister(engine); SQAICompany.AddConstructor<void (AICompany::*)(), 1>(engine, "x"); - SQAICompany.DefSQConst(engine, AICompany::INVALID_COMPANY, "INVALID_COMPANY"); - SQAICompany.DefSQConst(engine, AICompany::FIRST_COMPANY, "FIRST_COMPANY"); - SQAICompany.DefSQConst(engine, AICompany::LAST_COMPANY, "LAST_COMPANY"); - SQAICompany.DefSQConst(engine, AICompany::MY_COMPANY, "MY_COMPANY"); + SQAICompany.DefSQConst(engine, AICompany::COMPANY_INVALID, "COMPANY_INVALID"); + SQAICompany.DefSQConst(engine, AICompany::COMPANY_FIRST, "COMPANY_FIRST"); + SQAICompany.DefSQConst(engine, AICompany::COMPANY_LAST, "COMPANY_LAST"); + SQAICompany.DefSQConst(engine, AICompany::COMPANY_SELF, "COMPANY_SELF"); SQAICompany.DefSQStaticMethod(engine, &AICompany::GetClassName, "GetClassName", 1, "x"); SQAICompany.DefSQStaticMethod(engine, &AICompany::ResolveCompanyID, "ResolveCompanyID", 2, "xi"); diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp index c3f3aed3e..443f03482 100644 --- a/src/ai/api/ai_engine.cpp +++ b/src/ai/api/ai_engine.cpp @@ -79,7 +79,7 @@ /* static */ bool AIEngine::CanPullCargo(EngineID engine_id, CargoID cargo_id) { if (!IsValidEngine(engine_id)) return false; - if (GetVehicleType(engine_id) != AIVehicle::VEHICLE_RAIL) return false; + if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return false; if (!AICargo::IsValidCargo(cargo_id)) return false; return (::RailVehInfo(engine_id)->ai_passenger_only != 1) || AICargo::HasCargoClass(cargo_id, AICargo::CC_PASSENGERS); @@ -225,13 +225,13 @@ /* static */ AIVehicle::VehicleType AIEngine::GetVehicleType(EngineID engine_id) { - if (!IsValidEngine(engine_id)) return AIVehicle::VEHICLE_INVALID; + if (!IsValidEngine(engine_id)) return AIVehicle::VT_INVALID; switch (::GetEngine(engine_id)->type) { - case VEH_ROAD: return AIVehicle::VEHICLE_ROAD; - case VEH_TRAIN: return AIVehicle::VEHICLE_RAIL; - case VEH_SHIP: return AIVehicle::VEHICLE_WATER; - case VEH_AIRCRAFT: return AIVehicle::VEHICLE_AIR; + case VEH_ROAD: return AIVehicle::VT_ROAD; + case VEH_TRAIN: return AIVehicle::VT_RAIL; + case VEH_SHIP: return AIVehicle::VT_WATER; + case VEH_AIRCRAFT: return AIVehicle::VT_AIR; default: NOT_REACHED(); } } @@ -239,7 +239,7 @@ /* static */ bool AIEngine::IsWagon(EngineID engine_id) { if (!IsValidEngine(engine_id)) return false; - if (GetVehicleType(engine_id) != AIVehicle::VEHICLE_RAIL) return false; + if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return false; return ::RailVehInfo(engine_id)->power == 0; } @@ -247,7 +247,7 @@ /* static */ bool AIEngine::CanRunOnRail(EngineID engine_id, AIRail::RailType track_rail_type) { if (!IsValidEngine(engine_id)) return false; - if (GetVehicleType(engine_id) != AIVehicle::VEHICLE_RAIL) return false; + if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return false; if (!AIRail::IsRailTypeAvailable(track_rail_type)) return false; return ::IsCompatibleRail((::RailType)::RailVehInfo(engine_id)->railtype, (::RailType)track_rail_type); @@ -256,7 +256,7 @@ /* static */ bool AIEngine::HasPowerOnRail(EngineID engine_id, AIRail::RailType track_rail_type) { if (!IsValidEngine(engine_id)) return false; - if (GetVehicleType(engine_id) != AIVehicle::VEHICLE_RAIL) return false; + if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return false; if (!AIRail::IsRailTypeAvailable(track_rail_type)) return false; return ::HasPowerOnRail((::RailType)::RailVehInfo(engine_id)->railtype, (::RailType)track_rail_type); @@ -265,7 +265,7 @@ /* static */ AIRoad::RoadType AIEngine::GetRoadType(EngineID engine_id) { if (!IsValidEngine(engine_id)) return AIRoad::ROADTYPE_INVALID; - if (GetVehicleType(engine_id) != AIVehicle::VEHICLE_ROAD) return AIRoad::ROADTYPE_INVALID; + if (GetVehicleType(engine_id) != AIVehicle::VT_ROAD) return AIRoad::ROADTYPE_INVALID; return HasBit(::EngInfo(engine_id)->misc_flags, EF_ROAD_TRAM) ? AIRoad::ROADTYPE_TRAM : AIRoad::ROADTYPE_ROAD; } @@ -273,7 +273,7 @@ /* static */ AIRail::RailType AIEngine::GetRailType(EngineID engine_id) { if (!IsValidEngine(engine_id)) return AIRail::RAILTYPE_INVALID; - if (GetVehicleType(engine_id) != AIVehicle::VEHICLE_RAIL) return AIRail::RAILTYPE_INVALID; + if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return AIRail::RAILTYPE_INVALID; return (AIRail::RailType)(uint)::RailVehInfo(engine_id)->railtype; } @@ -281,7 +281,7 @@ /* static */ bool AIEngine::IsArticulated(EngineID engine_id) { if (!IsValidEngine(engine_id)) return false; - if (GetVehicleType(engine_id) != AIVehicle::VEHICLE_ROAD && GetVehicleType(engine_id) != AIVehicle::VEHICLE_RAIL) return false; + if (GetVehicleType(engine_id) != AIVehicle::VT_ROAD && GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return false; return CountArticulatedParts(engine_id, true) != 0; } @@ -289,7 +289,7 @@ /* static */ AIAirport::PlaneType AIEngine::GetPlaneType(EngineID engine_id) { if (!IsValidEngine(engine_id)) return AIAirport::PT_INVALID; - if (GetVehicleType(engine_id) != AIVehicle::VEHICLE_AIR) return AIAirport::PT_INVALID; + if (GetVehicleType(engine_id) != AIVehicle::VT_AIR) return AIAirport::PT_INVALID; return (AIAirport::PlaneType)::AircraftVehInfo(engine_id)->subtype; } diff --git a/src/ai/api/ai_event_types.hpp b/src/ai/api/ai_event_types.hpp index 13c004d97..9c0e8a396 100644 --- a/src/ai/api/ai_event_types.hpp +++ b/src/ai/api/ai_event_types.hpp @@ -400,7 +400,7 @@ public: * Get the CompanyID of the company that has been bought. * @return The CompanyID of the company that has been bought. * @note: The value below is not valid anymore as CompanyID, and - * AICompany::ResolveCompanyID will return INVALID_COMPANY. It's + * AICompany::ResolveCompanyID will return COMPANY_COMPANY. It's * only usefull if you're keeping track of company's yourself. */ AICompany::CompanyID GetOldCompanyID() { return old_owner; } diff --git a/src/ai/api/ai_gamesettings.cpp b/src/ai/api/ai_gamesettings.cpp index 81b187d73..b3b4fb85a 100644 --- a/src/ai/api/ai_gamesettings.cpp +++ b/src/ai/api/ai_gamesettings.cpp @@ -29,10 +29,10 @@ /* static */ bool AIGameSettings::IsDisabledVehicleType(AIVehicle::VehicleType vehicle_type) { switch (vehicle_type) { - case AIVehicle::VEHICLE_RAIL: return _settings_game.ai.ai_disable_veh_train; - case AIVehicle::VEHICLE_ROAD: return _settings_game.ai.ai_disable_veh_roadveh; - case AIVehicle::VEHICLE_WATER: return _settings_game.ai.ai_disable_veh_ship; - case AIVehicle::VEHICLE_AIR: return _settings_game.ai.ai_disable_veh_aircraft; + case AIVehicle::VT_RAIL: return _settings_game.ai.ai_disable_veh_train; + case AIVehicle::VT_ROAD: return _settings_game.ai.ai_disable_veh_roadveh; + case AIVehicle::VT_WATER: return _settings_game.ai.ai_disable_veh_ship; + case AIVehicle::VT_AIR: return _settings_game.ai.ai_disable_veh_aircraft; default: return true; } } diff --git a/src/ai/api/ai_group.cpp b/src/ai/api/ai_group.cpp index a6365450b..5dc676303 100644 --- a/src/ai/api/ai_group.cpp +++ b/src/ai/api/ai_group.cpp @@ -23,7 +23,7 @@ /* static */ AIGroup::GroupID AIGroup::CreateGroup(AIVehicle::VehicleType vehicle_type) { - if (!AIObject::DoCommand(0, (::VehicleType)vehicle_type, 0, CMD_CREATE_GROUP, NULL, &AIInstance::DoCommandReturnGroupID)) return INVALID_GROUP; + if (!AIObject::DoCommand(0, (::VehicleType)vehicle_type, 0, CMD_CREATE_GROUP, NULL, &AIInstance::DoCommandReturnGroupID)) return GROUP_INVALID; /* In case of test-mode, we return GroupID 0 */ return (AIGroup::GroupID)0; @@ -38,7 +38,7 @@ /* static */ AIVehicle::VehicleType AIGroup::GetVehicleType(GroupID group_id) { - if (!IsValidGroup(group_id)) return AIVehicle::VEHICLE_INVALID; + if (!IsValidGroup(group_id)) return AIVehicle::VT_INVALID; return (AIVehicle::VehicleType)((::VehicleType)::GetGroup(group_id)->vehicle_type); } @@ -80,14 +80,14 @@ /* static */ int32 AIGroup::GetNumEngines(GroupID group_id, EngineID engine_id) { - if (!IsValidGroup(group_id) && group_id != DEFAULT_GROUP && group_id != ALL_GROUP) return -1; + if (!IsValidGroup(group_id) && group_id != GROUP_DEFAULT && group_id != GROUP_ALL) return -1; return GetGroupNumEngines(_current_company, group_id, engine_id); } /* static */ bool AIGroup::MoveVehicle(GroupID group_id, VehicleID vehicle_id) { - EnforcePrecondition(false, IsValidGroup(group_id) || group_id == DEFAULT_GROUP); + EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_DEFAULT); EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id)); return AIObject::DoCommand(0, group_id, vehicle_id, CMD_ADD_VEHICLE_GROUP); @@ -107,7 +107,7 @@ /* static */ bool AIGroup::SetAutoReplace(GroupID group_id, EngineID engine_id_old, EngineID engine_id_new) { - EnforcePrecondition(false, IsValidGroup(group_id) || group_id == ALL_GROUP); + EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_ALL); EnforcePrecondition(false, AIEngine::IsValidEngine(engine_id_new)); return AIObject::DoCommand(0, 3 | (group_id << 16), (engine_id_new << 16) | engine_id_old, CMD_SET_AUTOREPLACE); @@ -115,14 +115,14 @@ /* static */ EngineID AIGroup::GetEngineReplacement(GroupID group_id, EngineID engine_id) { - if (!IsValidGroup(group_id) && group_id != ALL_GROUP) return ::INVALID_ENGINE; + if (!IsValidGroup(group_id) && group_id != GROUP_ALL) return ::INVALID_ENGINE; return ::EngineReplacementForCompany(GetCompany(_current_company), engine_id, group_id); } /* static */ bool AIGroup::StopAutoReplace(GroupID group_id, EngineID engine_id) { - EnforcePrecondition(false, IsValidGroup(group_id) || group_id == ALL_GROUP); + EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_ALL); return AIObject::DoCommand(0, 3 | (group_id << 16), (::INVALID_ENGINE << 16) | engine_id, CMD_SET_AUTOREPLACE); } diff --git a/src/ai/api/ai_group.hpp b/src/ai/api/ai_group.hpp index 84569c562..51a4c47aa 100644 --- a/src/ai/api/ai_group.hpp +++ b/src/ai/api/ai_group.hpp @@ -20,9 +20,9 @@ public: */ enum GroupID { /* Values are important, as they represent the internal state of the game (see group_type.h). */ - ALL_GROUP = 0xFFFD, //!< All vehicles are in this group. - DEFAULT_GROUP = 0xFFFE, //!< Vehicles not put in any other group are in this one. - INVALID_GROUP = 0xFFFF, //!< An invalid group id. + GROUP_ALL = 0xFFFD, //!< All vehicles are in this group. + GROUP_DEFAULT = 0xFFFE, //!< Vehicles not put in any other group are in this one. + GROUP_INVALID = 0xFFFF, //!< An invalid group id. }; /** diff --git a/src/ai/api/ai_group.hpp.sq b/src/ai/api/ai_group.hpp.sq index 3556f5cc9..94be736b0 100644 --- a/src/ai/api/ai_group.hpp.sq +++ b/src/ai/api/ai_group.hpp.sq @@ -21,9 +21,9 @@ void SQAIGroup_Register(Squirrel *engine) { SQAIGroup.PreRegister(engine); SQAIGroup.AddConstructor<void (AIGroup::*)(), 1>(engine, "x"); - SQAIGroup.DefSQConst(engine, AIGroup::ALL_GROUP, "ALL_GROUP"); - SQAIGroup.DefSQConst(engine, AIGroup::DEFAULT_GROUP, "DEFAULT_GROUP"); - SQAIGroup.DefSQConst(engine, AIGroup::INVALID_GROUP, "INVALID_GROUP"); + SQAIGroup.DefSQConst(engine, AIGroup::GROUP_ALL, "GROUP_ALL"); + SQAIGroup.DefSQConst(engine, AIGroup::GROUP_DEFAULT, "GROUP_DEFAULT"); + SQAIGroup.DefSQConst(engine, AIGroup::GROUP_INVALID, "GROUP_INVALID"); SQAIGroup.DefSQStaticMethod(engine, &AIGroup::GetClassName, "GetClassName", 1, "x"); SQAIGroup.DefSQStaticMethod(engine, &AIGroup::IsValidGroup, "IsValidGroup", 2, "xi"); diff --git a/src/ai/api/ai_map.hpp b/src/ai/api/ai_map.hpp index dbf3db08f..bf903a37e 100644 --- a/src/ai/api/ai_map.hpp +++ b/src/ai/api/ai_map.hpp @@ -14,7 +14,7 @@ class AIMap : public AIObject { public: #ifdef DEFINE_SCRIPT_FILES enum MapType { - TILE_INVALID = INVALID_TILE, //!< An invalid tile for every function. + TILE_INVALID = INVALID_TILE, //!< Invalid TileIndex. }; #endif /* DEFINE_SCRIPT_FILES */ diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp index f48c5e392..1f30688e4 100644 --- a/src/ai/api/ai_order.cpp +++ b/src/ai/api/ai_order.cpp @@ -45,15 +45,15 @@ static OrderType GetOrderTypeByTile(TileIndex t) /* static */ bool AIOrder::IsValidVehicleOrder(VehicleID vehicle_id, OrderPosition order_position) { - return AIVehicle::IsValidVehicle(vehicle_id) && order_position >= 0 && (order_position < ::GetVehicle(vehicle_id)->GetNumOrders() || order_position == CURRENT_ORDER); + return AIVehicle::IsValidVehicle(vehicle_id) && order_position >= 0 && (order_position < ::GetVehicle(vehicle_id)->GetNumOrders() || order_position == ORDER_CURRENT); } /* static */ AIOrder::OrderPosition AIOrder::ResolveOrderPosition(VehicleID vehicle_id, OrderPosition order_position) { - if (!AIVehicle::IsValidVehicle(vehicle_id)) return INVALID_ORDER; + if (!AIVehicle::IsValidVehicle(vehicle_id)) return ORDER_INVALID; - if (order_position == CURRENT_ORDER) return (AIOrder::OrderPosition)::GetVehicle(vehicle_id)->cur_order_index; - return (order_position >= 0 && order_position < ::GetVehicle(vehicle_id)->GetNumOrders()) ? order_position : INVALID_ORDER; + if (order_position == ORDER_CURRENT) return (AIOrder::OrderPosition)::GetVehicle(vehicle_id)->cur_order_index; + return (order_position >= 0 && order_position < ::GetVehicle(vehicle_id)->GetNumOrders()) ? order_position : ORDER_INVALID; } @@ -87,7 +87,7 @@ static OrderType GetOrderTypeByTile(TileIndex t) const Order *order; const Vehicle *v = ::GetVehicle(vehicle_id); - if (order_position == CURRENT_ORDER) { + if (order_position == ORDER_CURRENT) { order = &v->current_order; } else { order = v->GetFirstOrder(); @@ -110,7 +110,7 @@ static OrderType GetOrderTypeByTile(TileIndex t) if (!IsValidVehicleOrder(vehicle_id, order_position)) return AIOF_INVALID; const Order *order; - if (order_position == CURRENT_ORDER) { + if (order_position == ORDER_CURRENT) { order = &::GetVehicle(vehicle_id)->current_order; } else { order = ::GetVehicle(vehicle_id)->GetFirstOrder(); @@ -144,7 +144,7 @@ static OrderType GetOrderTypeByTile(TileIndex t) /* static */ bool AIOrder::InsertOrder(VehicleID vehicle_id, OrderPosition order_position, TileIndex destination, AIOrder::AIOrderFlags order_flags) { /* IsValidVehicleOrder is not good enough because it does not allow appending. */ - if (order_position == CURRENT_ORDER) order_position = AIOrder::ResolveOrderPosition(vehicle_id, order_position); + if (order_position == ORDER_CURRENT) order_position = AIOrder::ResolveOrderPosition(vehicle_id, order_position); EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id)); EnforcePrecondition(false, order_position >= 0 && order_position <= ::GetVehicle(vehicle_id)->GetNumOrders()); diff --git a/src/ai/api/ai_order.hpp b/src/ai/api/ai_order.hpp index fbda26892..c4e9f99be 100644 --- a/src/ai/api/ai_order.hpp +++ b/src/ai/api/ai_order.hpp @@ -71,8 +71,8 @@ public: /** Different constants related to the OrderPosition */ enum OrderPosition { - CURRENT_ORDER = 0xFF, //!< Constant that gets resolved to the current order. - INVALID_ORDER = -1, //!< An invalid order. + ORDER_CURRENT = 0xFF, //!< Constant that gets resolved to the current order. + ORDER_INVALID = -1, //!< An invalid order. }; /** @@ -88,7 +88,7 @@ public: * Resolves the given order index to the correct index for the given vehicle. * If the order index was CURRENT_ORDER it will be resolved to the index of * the current order (as shown in the order list). If the order with the - * given index does not exist it will return INVALID_ORDER. + * given index does not exist it will return ORDER_INVALID. * @param vehicle_id The vehicle to check the order index for. * @param order_position The order index to resolve. * @pre AIVehicle::IsValidVehicle(vehicle_id). diff --git a/src/ai/api/ai_order.hpp.sq b/src/ai/api/ai_order.hpp.sq index 4128ae029..bb2089dee 100644 --- a/src/ai/api/ai_order.hpp.sq +++ b/src/ai/api/ai_order.hpp.sq @@ -42,8 +42,8 @@ void SQAIOrder_Register(Squirrel *engine) { SQAIOrder.DefSQConst(engine, AIOrder::AIOF_UNLOAD_FLAGS, "AIOF_UNLOAD_FLAGS"); SQAIOrder.DefSQConst(engine, AIOrder::AIOF_LOAD_FLAGS, "AIOF_LOAD_FLAGS"); SQAIOrder.DefSQConst(engine, AIOrder::AIOF_INVALID, "AIOF_INVALID"); - SQAIOrder.DefSQConst(engine, AIOrder::CURRENT_ORDER, "CURRENT_ORDER"); - SQAIOrder.DefSQConst(engine, AIOrder::INVALID_ORDER, "INVALID_ORDER"); + SQAIOrder.DefSQConst(engine, AIOrder::ORDER_CURRENT, "ORDER_CURRENT"); + SQAIOrder.DefSQConst(engine, AIOrder::ORDER_INVALID, "ORDER_INVALID"); AIError::RegisterErrorMap(STR_8831_NO_MORE_SPACE_FOR_ORDERS, AIOrder::ERR_ORDER_TOO_MANY); AIError::RegisterErrorMap(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO, AIOrder::ERR_ORDER_TOO_FAR_AWAY_FROM_PREVIOUS_DESTINATION); diff --git a/src/ai/api/ai_subsidy.cpp b/src/ai/api/ai_subsidy.cpp index 893b65e7d..1d0ec65d1 100644 --- a/src/ai/api/ai_subsidy.cpp +++ b/src/ai/api/ai_subsidy.cpp @@ -25,7 +25,7 @@ /* static */ AICompany::CompanyID AISubsidy::GetAwardedTo(SubsidyID subsidy_id) { - if (!IsAwarded(subsidy_id)) return AICompany::INVALID_COMPANY; + if (!IsAwarded(subsidy_id)) return AICompany::COMPANY_INVALID; return (AICompany::CompanyID)((byte)GetStation(_subsidies[subsidy_id].from)->owner); } diff --git a/src/ai/api/ai_tile.cpp b/src/ai/api/ai_tile.cpp index fd694373f..29305af8a 100644 --- a/src/ai/api/ai_tile.cpp +++ b/src/ai/api/ai_tile.cpp @@ -146,9 +146,9 @@ /* static */ AICompany::CompanyID AITile::GetOwner(TileIndex tile) { - if (!::IsValidTile(tile)) return AICompany::INVALID_COMPANY; - if (::IsTileType(tile, MP_HOUSE)) return AICompany::INVALID_COMPANY; - if (::IsTileType(tile, MP_INDUSTRY)) return AICompany::INVALID_COMPANY; + if (!::IsValidTile(tile)) return AICompany::COMPANY_INVALID; + if (::IsTileType(tile, MP_HOUSE)) return AICompany::COMPANY_INVALID; + if (::IsTileType(tile, MP_INDUSTRY)) return AICompany::COMPANY_INVALID; return AICompany::ResolveCompanyID((AICompany::CompanyID)(byte)::GetTileOwner(tile)); } diff --git a/src/ai/api/ai_tile.hpp b/src/ai/api/ai_tile.hpp index 298de75cb..151771cae 100644 --- a/src/ai/api/ai_tile.hpp +++ b/src/ai/api/ai_tile.hpp @@ -75,7 +75,7 @@ public: TRANSPORT_WATER = 2, //!< Tile with navigable waterways. TRANSPORT_AIR = 3, //!< Tile with airport. - INVALID_TRANSPORT = -1, //!< Tile without any transport type. + TRANSPORT_INVALID = -1, //!< Tile without any transport type. }; /** @@ -222,7 +222,7 @@ public: * Get the owner of the tile. * @param tile The tile to get the owner from. * @pre AIMap::IsValidTile(tile). - * @return The CompanyID of the owner of the tile, or INVALID_COMPANY if + * @return The CompanyID of the owner of the tile, or COMPANY_INVALID if * there is no owner (grass/industry/water tiles, etc.). */ static AICompany::CompanyID GetOwner(TileIndex tile); diff --git a/src/ai/api/ai_tile.hpp.sq b/src/ai/api/ai_tile.hpp.sq index 920dc6543..78a888ca8 100644 --- a/src/ai/api/ai_tile.hpp.sq +++ b/src/ai/api/ai_tile.hpp.sq @@ -54,7 +54,7 @@ void SQAITile_Register(Squirrel *engine) { SQAITile.DefSQConst(engine, AITile::TRANSPORT_ROAD, "TRANSPORT_ROAD"); SQAITile.DefSQConst(engine, AITile::TRANSPORT_WATER, "TRANSPORT_WATER"); SQAITile.DefSQConst(engine, AITile::TRANSPORT_AIR, "TRANSPORT_AIR"); - SQAITile.DefSQConst(engine, AITile::INVALID_TRANSPORT, "INVALID_TRANSPORT"); + SQAITile.DefSQConst(engine, AITile::TRANSPORT_INVALID, "TRANSPORT_INVALID"); AIError::RegisterErrorMap(STR_1003_ALREADY_AT_SEA_LEVEL, AITile::ERR_TILE_TOO_HIGH); AIError::RegisterErrorMap(STR_1003_ALREADY_AT_SEA_LEVEL, AITile::ERR_TILE_TOO_LOW); diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp index 8c8ab9c02..921e5a73e 100644 --- a/src/ai/api/ai_town.cpp +++ b/src/ai/api/ai_town.cpp @@ -139,7 +139,7 @@ /* static */ AICompany::CompanyID AITown::GetExclusiveRightsCompany(TownID town_id) { - if (!IsValidTown(town_id)) return AICompany::INVALID_COMPANY; + if (!IsValidTown(town_id)) return AICompany::COMPANY_INVALID; return (AICompany::CompanyID)(int8)::GetTown(town_id)->exclusivity; } @@ -170,9 +170,9 @@ extern uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t); /* static */ AITown::TownRating AITown::GetRating(TownID town_id, AICompany::CompanyID company_id) { - if (!IsValidTown(town_id)) return INVALID_TOWN_RATING; + if (!IsValidTown(town_id)) return TOWN_RATING_INVALID; AICompany::CompanyID company = AICompany::ResolveCompanyID(company_id); - if (company == AICompany::INVALID_COMPANY) return INVALID_TOWN_RATING; + if (company == AICompany::COMPANY_INVALID) return TOWN_RATING_INVALID; const Town *t = ::GetTown(town_id); if (!HasBit(t->have_ratings, company)) return TOWN_RATING_NONE; diff --git a/src/ai/api/ai_town.hpp b/src/ai/api/ai_town.hpp index 94ba91e17..f9152106f 100644 --- a/src/ai/api/ai_town.hpp +++ b/src/ai/api/ai_town.hpp @@ -81,7 +81,7 @@ public: TOWN_RATING_VERY_GOOD, ///< The company got an very good rating in the town. TOWN_RATING_EXCELLENT, ///< The company got an excellent rating in the town. TOWN_RATING_OUTSTANDING, ///< The company got an outstanding rating in the town. - INVALID_TOWN_RATING = -1, ///< The town rating for invalid towns/companies. + TOWN_RATING_INVALID = -1, ///< The town rating for invalid towns/companies. }; /** @@ -228,7 +228,7 @@ public: * @param town_id The town to check. * @pre IsValidTown(town_id). * @return The company that has the exclusive rights. The value - * AICompany::INVALID_COMPANY means that there are currently no + * AICompany::COMPANY_INVALID means that there are currently no * exclusive rights given out to anyone. */ static AICompany::CompanyID GetExclusiveRightsCompany(TownID town_id); @@ -267,7 +267,7 @@ public: * @param town_id The town to get the rating for. * @param company_id The company to get the rating for. * @pre IsValidTown(town_id). - * @pre AICompany.ResolveCompanyID(company) != AICompany::INVALID_COMPANY. + * @pre AICompany.ResolveCompanyID(company) != AICompany::COMPANY_INVALID. * @return The rating as shown to humans. */ static TownRating GetRating(TownID town_id, AICompany::CompanyID company_id); diff --git a/src/ai/api/ai_town.hpp.sq b/src/ai/api/ai_town.hpp.sq index 664503923..164f0ffa5 100644 --- a/src/ai/api/ai_town.hpp.sq +++ b/src/ai/api/ai_town.hpp.sq @@ -40,7 +40,7 @@ void SQAITown_Register(Squirrel *engine) { SQAITown.DefSQConst(engine, AITown::TOWN_RATING_VERY_GOOD, "TOWN_RATING_VERY_GOOD"); SQAITown.DefSQConst(engine, AITown::TOWN_RATING_EXCELLENT, "TOWN_RATING_EXCELLENT"); SQAITown.DefSQConst(engine, AITown::TOWN_RATING_OUTSTANDING, "TOWN_RATING_OUTSTANDING"); - SQAITown.DefSQConst(engine, AITown::INVALID_TOWN_RATING, "INVALID_TOWN_RATING"); + SQAITown.DefSQConst(engine, AITown::TOWN_RATING_INVALID, "TOWN_RATING_INVALID"); SQAITown.DefSQStaticMethod(engine, &AITown::GetClassName, "GetClassName", 1, "x"); SQAITown.DefSQStaticMethod(engine, &AITown::GetMaxTownID, "GetMaxTownID", 1, "x"); diff --git a/src/ai/api/ai_tunnel.cpp b/src/ai/api/ai_tunnel.cpp index 1991ef89b..6c4c7b216 100644 --- a/src/ai/api/ai_tunnel.cpp +++ b/src/ai/api/ai_tunnel.cpp @@ -60,11 +60,11 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance) /* static */ bool AITunnel::BuildTunnel(AIVehicle::VehicleType vehicle_type, TileIndex start) { EnforcePrecondition(false, ::IsValidTile(start)); - EnforcePrecondition(false, vehicle_type == AIVehicle::VEHICLE_RAIL || vehicle_type == AIVehicle::VEHICLE_ROAD); - EnforcePrecondition(false, vehicle_type != AIVehicle::VEHICLE_RAIL || AIRail::IsRailTypeAvailable(AIRail::GetCurrentRailType())); + EnforcePrecondition(false, vehicle_type == AIVehicle::VT_RAIL || vehicle_type == AIVehicle::VT_ROAD); + EnforcePrecondition(false, vehicle_type != AIVehicle::VT_RAIL || AIRail::IsRailTypeAvailable(AIRail::GetCurrentRailType())); uint type = 0; - if (vehicle_type == AIVehicle::VEHICLE_ROAD) { + if (vehicle_type == AIVehicle::VT_ROAD) { type |= (TRANSPORT_ROAD << 9); type |= RoadTypeToRoadTypes((::RoadType)AIObject::GetRoadType()); } else { @@ -73,7 +73,7 @@ static void _DoCommandReturnBuildTunnel1(class AIInstance *instance) } /* For rail we do nothing special */ - if (vehicle_type == AIVehicle::VEHICLE_RAIL) { + if (vehicle_type == AIVehicle::VT_RAIL) { return AIObject::DoCommand(start, type, 0, CMD_BUILD_TUNNEL); } diff --git a/src/ai/api/ai_tunnel.hpp b/src/ai/api/ai_tunnel.hpp index 625237905..6aa6ea4c0 100644 --- a/src/ai/api/ai_tunnel.hpp +++ b/src/ai/api/ai_tunnel.hpp @@ -50,7 +50,7 @@ public: * @param tile The tile that is an entrance to a tunnel or the tile where you may want to build a tunnel. * @pre AIMap::IsValidTile(tile). * @return The TileIndex that is the other end of the (would be) tunnel, or - * INVALID_TILE if no other end was found (can't build tunnel). + * TILE_INVALID if no other end was found (can't build tunnel). */ static TileIndex GetOtherTunnelEnd(TileIndex tile); diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp index 9532e3caf..7427025af 100644 --- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -7,6 +7,7 @@ #include "ai_cargo.hpp" #include "ai_order.hpp" #include "ai_gamesettings.hpp" +#include "ai_group.hpp" #include "../ai_instance.hpp" #include "../../openttd.h" #include "../../company_func.h" @@ -323,21 +324,21 @@ /* static */ AIVehicle::VehicleType AIVehicle::GetVehicleType(VehicleID vehicle_id) { - if (!IsValidVehicle(vehicle_id)) return VEHICLE_INVALID; + if (!IsValidVehicle(vehicle_id)) return VT_INVALID; switch (::GetVehicle(vehicle_id)->type) { - case VEH_ROAD: return VEHICLE_ROAD; - case VEH_TRAIN: return VEHICLE_RAIL; - case VEH_SHIP: return VEHICLE_WATER; - case VEH_AIRCRAFT: return VEHICLE_AIR; - default: return VEHICLE_INVALID; + case VEH_ROAD: return VT_ROAD; + case VEH_TRAIN: return VT_RAIL; + case VEH_SHIP: return VT_WATER; + case VEH_AIRCRAFT: return VT_AIR; + default: return VT_INVALID; } } /* static */ AIRoad::RoadType AIVehicle::GetRoadType(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return AIRoad::ROADTYPE_INVALID; - if (GetVehicleType(vehicle_id) != VEHICLE_ROAD) return AIRoad::ROADTYPE_INVALID; + if (GetVehicleType(vehicle_id) != VT_ROAD) return AIRoad::ROADTYPE_INVALID; return (AIRoad::RoadType)::GetVehicle(vehicle_id)->u.road.roadtype; } @@ -370,7 +371,7 @@ /* static */ GroupID AIVehicle::GetGroupID(VehicleID vehicle_id) { - if (!IsValidVehicle(vehicle_id)) return ::INVALID_GROUP; + if (!IsValidVehicle(vehicle_id)) return AIGroup::GROUP_INVALID; return ::GetVehicle(vehicle_id)->group_id; } @@ -378,7 +379,7 @@ /* static */ bool AIVehicle::IsArticulated(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return false; - if (GetVehicleType(vehicle_id) != VEHICLE_ROAD && GetVehicleType(vehicle_id) != VEHICLE_RAIL) return false; + if (GetVehicleType(vehicle_id) != VT_ROAD && GetVehicleType(vehicle_id) != VT_RAIL) return false; const Vehicle *v = ::GetVehicle(vehicle_id); switch (v->type) { diff --git a/src/ai/api/ai_vehicle.hpp b/src/ai/api/ai_vehicle.hpp index 84ddb4734..1336e9efe 100644 --- a/src/ai/api/ai_vehicle.hpp +++ b/src/ai/api/ai_vehicle.hpp @@ -68,11 +68,15 @@ public: */ enum VehicleType { /* Order IS important, as it now matches the internal state of the game for vehicle type */ - VEHICLE_RAIL, //!< Rail type vehicle. - VEHICLE_ROAD, //!< Road type vehicle (bus / truck). - VEHICLE_WATER, //!< Water type vehicle. - VEHICLE_AIR, //!< Air type vehicle. - VEHICLE_INVALID = 0xFF, //!< Invalid vehicle type. + VT_RAIL, //!< Rail type vehicle. + VT_ROAD, //!< Road type vehicle (bus / truck). + VT_WATER, //!< Water type vehicle. + VT_AIR, //!< Air type vehicle. + VT_INVALID = 0xFF, //!< Invalid vehicle type. + +#ifdef DEFINE_SCRIPT_FILES + VEHICLE_INVALID = -1, //!< Invalid VehicleID. +#endif /* DEFINE_SCRIPT_FILES */ }; /** diff --git a/src/ai/api/ai_vehicle.hpp.sq b/src/ai/api/ai_vehicle.hpp.sq index 87dce4893..babb85306 100644 --- a/src/ai/api/ai_vehicle.hpp.sq +++ b/src/ai/api/ai_vehicle.hpp.sq @@ -38,10 +38,11 @@ void SQAIVehicle_Register(Squirrel *engine) { SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_NOT_IN_DEPOT, "ERR_VEHICLE_NOT_IN_DEPOT"); SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHICLE_IN_FLIGHT, "ERR_VEHICLE_IN_FLIGHT"); SQAIVehicle.DefSQConst(engine, AIVehicle::ERR_VEHCILE_NO_POWER, "ERR_VEHCILE_NO_POWER"); - SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_RAIL, "VEHICLE_RAIL"); - SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_ROAD, "VEHICLE_ROAD"); - SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_WATER, "VEHICLE_WATER"); - SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_AIR, "VEHICLE_AIR"); + SQAIVehicle.DefSQConst(engine, AIVehicle::VT_RAIL, "VT_RAIL"); + SQAIVehicle.DefSQConst(engine, AIVehicle::VT_ROAD, "VT_ROAD"); + SQAIVehicle.DefSQConst(engine, AIVehicle::VT_WATER, "VT_WATER"); + SQAIVehicle.DefSQConst(engine, AIVehicle::VT_AIR, "VT_AIR"); + SQAIVehicle.DefSQConst(engine, AIVehicle::VT_INVALID, "VT_INVALID"); SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_INVALID, "VEHICLE_INVALID"); SQAIVehicle.DefSQConst(engine, AIVehicle::VS_RUNNING, "VS_RUNNING"); SQAIVehicle.DefSQConst(engine, AIVehicle::VS_STOPPED, "VS_STOPPED"); |