diff options
32 files changed, 206 insertions, 195 deletions
diff --git a/bin/ai/library/pathfinder/rail/main.nut b/bin/ai/library/pathfinder/rail/main.nut index ad5a6664e..2a9186799 100644 --- a/bin/ai/library/pathfinder/rail/main.nut +++ b/bin/ai/library/pathfinder/rail/main.nut @@ -341,7 +341,7 @@ function Rail::_GetTunnelsBridges(last_node, cur_node, bridge_dir) for (local i = 2; i < this._max_bridge_length; i++) { local bridge_list = AIBridgeList_Length(i + 1); local target = cur_node + i * (cur_node - last_node); - if (!bridge_list.IsEmpty() && AIBridge.BuildBridge(AIVehicle.VEHICLE_RAIL, bridge_list.Begin(), cur_node, target)) { + if (!bridge_list.IsEmpty() && AIBridge.BuildBridge(AIVehicle.VT_RAIL, bridge_list.Begin(), cur_node, target)) { tiles.push([target, bridge_dir]); } } @@ -353,7 +353,7 @@ function Rail::_GetTunnelsBridges(last_node, cur_node, bridge_dir) local tunnel_length = AIMap.DistanceManhattan(cur_node, other_tunnel_end); local prev_tile = cur_node + (cur_node - other_tunnel_end) / tunnel_length; if (AITunnel.GetOtherTunnelEnd(other_tunnel_end) == cur_node && tunnel_length >= 2 && - prev_tile == last_node && tunnel_length < _max_tunnel_length && AITunnel.BuildTunnel(AIVehicle.VEHICLE_RAIL, cur_node)) { + prev_tile == last_node && tunnel_length < _max_tunnel_length && AITunnel.BuildTunnel(AIVehicle.VT_RAIL, cur_node)) { tiles.push([other_tunnel_end, bridge_dir]); } return tiles; diff --git a/bin/ai/library/pathfinder/road/main.nut b/bin/ai/library/pathfinder/road/main.nut index b33722369..9c5564656 100644 --- a/bin/ai/library/pathfinder/road/main.nut +++ b/bin/ai/library/pathfinder/road/main.nut @@ -300,7 +300,7 @@ function Road::_GetTunnelsBridges(last_node, cur_node, bridge_dir) for (local i = 2; i < this._max_bridge_length; i++) { local bridge_list = AIBridgeList_Length(i + 1); local target = cur_node + i * (cur_node - last_node); - if (!bridge_list.IsEmpty() && AIBridge.BuildBridge(AIVehicle.VEHICLE_ROAD, bridge_list.Begin(), cur_node, target)) { + if (!bridge_list.IsEmpty() && AIBridge.BuildBridge(AIVehicle.VT_ROAD, bridge_list.Begin(), cur_node, target)) { tiles.push([target, bridge_dir]); } } @@ -312,7 +312,7 @@ function Road::_GetTunnelsBridges(last_node, cur_node, bridge_dir) local tunnel_length = AIMap.DistanceManhattan(cur_node, other_tunnel_end); local prev_tile = cur_node + (cur_node - other_tunnel_end) / tunnel_length; if (AITunnel.GetOtherTunnelEnd(other_tunnel_end) == cur_node && tunnel_length >= 2 && - prev_tile == last_node && tunnel_length < _max_tunnel_length && AITunnel.BuildTunnel(AIVehicle.VEHICLE_ROAD, cur_node)) { + prev_tile == last_node && tunnel_length < _max_tunnel_length && AITunnel.BuildTunnel(AIVehicle.VT_ROAD, cur_node)) { tiles.push([other_tunnel_end, bridge_dir]); } return tiles; diff --git a/bin/ai/regression/regression.nut b/bin/ai/regression/regression.nut index afd023a34..4d37574b0 100644 --- a/bin/ai/regression/regression.nut +++ b/bin/ai/regression/regression.nut @@ -226,7 +226,7 @@ function Regression::Airport() print(" GetAirportCoverageRadius(" + i + "): " + AIAirport.GetAirportCoverageRadius(i)); } - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" BuildAirport(): " + AIAirport.BuildAirport(32116, 0, true)); print(" IsHangarTile(): " + AIAirport.IsHangarTile(32116)); print(" IsAirportTile(): " + AIAirport.IsAirportTile(32116)); @@ -235,12 +235,12 @@ function Regression::Airport() print(" IsHangarTile(): " + AIAirport.IsHangarTile(32119)); print(" IsAirportTile(): " + AIAirport.IsAirportTile(32119)); print(" GetAirportType(): " + AIAirport.GetAirportType(32119)); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" RemoveAirport(): " + AIAirport.RemoveAirport(32118)); print(" IsHangarTile(): " + AIAirport.IsHangarTile(32119)); print(" IsAirportTile(): " + AIAirport.IsAirportTile(32119)); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" BuildAirport(): " + AIAirport.BuildAirport(32116, 0, true)); } @@ -267,11 +267,11 @@ function Regression::Bridge() print(" RemoveBridge(): " + AIBridge.RemoveBridge(33155)); print(" GetLastErrorString(): " + AIError.GetLastErrorString()); print(" GetOtherBridgeEnd(): " + AIBridge.GetOtherBridgeEnd(33160)); - print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VEHICLE_ROAD, 5, 33160, 33155)); + print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VT_ROAD, 5, 33160, 33155)); print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33160)); print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33155)); print(" GetOtherBridgeEnd(): " + AIBridge.GetOtherBridgeEnd(33160)); - print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VEHICLE_ROAD, 5, 33160, 33155)); + print(" BuildBridge(): " + AIBridge.BuildBridge(AIVehicle.VT_ROAD, 5, 33160, 33155)); print(" GetLastErrorString(): " + AIError.GetLastErrorString()); print(" RemoveBridge(): " + AIBridge.RemoveBridge(33155)); print(" IsBridgeTile(): " + AIBridge.IsBridgeTile(33160)); @@ -401,12 +401,12 @@ function Regression::Company() } } - print(" GetName(): " + AICompany.GetName(AICompany.MY_COMPANY)); - print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.MY_COMPANY)); + print(" GetName(): " + AICompany.GetName(AICompany.COMPANY_SELF)); + print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.COMPANY_SELF)); print(" SetPresidentName(): " + AICompany.SetPresidentName("Regression AI")); - print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.MY_COMPANY)); - print(" GetCompanyValue(): " + AICompany.GetCompanyValue(AICompany.MY_COMPANY)); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.COMPANY_SELF)); + print(" GetCompanyValue(): " + AICompany.GetCompanyValue(AICompany.COMPANY_SELF)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" GetName(): " + AICompany.GetName(240)); print(" GetLoanAmount(): " + AICompany.GetLoanAmount()); print(" GetMaxLoanAmount(): " + AICompany.GetMaxLoanAmount()); @@ -415,34 +415,34 @@ function Regression::Company() print(" SetLoanAmount(100): " + AICompany.SetLoanAmount(100)); print(" SetLoanAmount(10000): " + AICompany.SetLoanAmount(10000)); print(" GetLastErrorString(): " + AIError.GetLastErrorString()); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" GetLoanAmount(): " + AICompany.GetLoanAmount()); print(" SetMinimumLoanAmount(31337): " + AICompany.SetMinimumLoanAmount(31337)); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" GetLoanAmount(): " + AICompany.GetLoanAmount()); print(" SetLoanAmount(10000): " + AICompany.SetLoanAmount(AICompany.GetMaxLoanAmount())); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" GetLoanAmount(): " + AICompany.GetLoanAmount()); - print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.MY_COMPANY)); + print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF)); print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(127, 129))); - print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.MY_COMPANY)); + print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF)); print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(129, 129))); - print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.MY_COMPANY)); + print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF)); print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(129, 128))); print(" GetLastErrorString(): " + AIError.GetLastErrorString()); - print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.MY_COMPANY)); + print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.COMPANY_SELF)); print(" SetAutoRenewStatus(true); " + AICompany.SetAutoRenewStatus(true)); - print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.MY_COMPANY)); + print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.COMPANY_SELF)); print(" SetAutoRenewStatus(true); " + AICompany.SetAutoRenewStatus(true)); print(" SetAutoRenewStatus(false); " + AICompany.SetAutoRenewStatus(false)); - print(" GetAutoRenewMonths(); " + AICompany.GetAutoRenewMonths(AICompany.MY_COMPANY)); + print(" GetAutoRenewMonths(); " + AICompany.GetAutoRenewMonths(AICompany.COMPANY_SELF)); print(" SetAutoRenewMonths(-12); " + AICompany.SetAutoRenewMonths(-12)); - print(" GetAutoRenewMonths(); " + AICompany.GetAutoRenewMonths(AICompany.MY_COMPANY)); + print(" GetAutoRenewMonths(); " + AICompany.GetAutoRenewMonths(AICompany.COMPANY_SELF)); print(" SetAutoRenewMonths(-12); " + AICompany.SetAutoRenewMonths(-12)); print(" SetAutoRenewMonths(6); " + AICompany.SetAutoRenewMonths(6)); - print(" GetAutoRenewMoney(); " + AICompany.GetAutoRenewMoney(AICompany.MY_COMPANY)); + print(" GetAutoRenewMoney(); " + AICompany.GetAutoRenewMoney(AICompany.COMPANY_SELF)); print(" SetAutoRenewMoney(200000); " + AICompany.SetAutoRenewMoney(200000)); - print(" GetAutoRenewMoney(); " + AICompany.GetAutoRenewMoney(AICompany.MY_COMPANY)); + print(" GetAutoRenewMoney(); " + AICompany.GetAutoRenewMoney(AICompany.COMPANY_SELF)); print(" SetAutoRenewMoney(200000); " + AICompany.SetAutoRenewMoney(200000)); print(" SetAutoRenewMoney(100000); " + AICompany.SetAutoRenewMoney(100000)); } @@ -476,7 +476,7 @@ function Regression::Engine() function Regression::EngineList() { - local list = AIEngineList(AIVehicle.VEHICLE_ROAD); + local list = AIEngineList(AIVehicle.VT_ROAD); print(""); print("--EngineList--"); @@ -533,19 +533,19 @@ function Regression::Group() { print (""); print("--Group--"); - print(" SetAutoReplace(): " + AIGroup.SetAutoReplace(AIGroup.ALL_GROUP, 116, 117)); - print(" GetEngineReplacement(): " + AIGroup.GetEngineReplacement(AIGroup.ALL_GROUP, 116)); - print(" GetNumEngines(): " + AIGroup.GetNumEngines(AIGroup.ALL_GROUP, 116)); + print(" SetAutoReplace(): " + AIGroup.SetAutoReplace(AIGroup.GROUP_ALL, 116, 117)); + print(" GetEngineReplacement(): " + AIGroup.GetEngineReplacement(AIGroup.GROUP_ALL, 116)); + print(" GetNumEngines(): " + AIGroup.GetNumEngines(AIGroup.GROUP_ALL, 116)); print(" AIRoad.BuildRoadDepot(): " + AIRoad.BuildRoadDepot(10000, 10001)); local vehicle = AIVehicle.BuildVehicle(10000, 116); print(" AIVehicle.BuildVehicle(): " + vehicle); - print(" GetNumEngines(): " + AIGroup.GetNumEngines(AIGroup.ALL_GROUP, 116)); - local group = AIGroup.CreateGroup(AIVehicle.VEHICLE_ROAD); + print(" GetNumEngines(): " + AIGroup.GetNumEngines(AIGroup.GROUP_ALL, 116)); + local group = AIGroup.CreateGroup(AIVehicle.VT_ROAD); print(" CreateGroup(): " + group); print(" MoveVehicle(): " + AIGroup.MoveVehicle(group, vehicle)); print(" GetNumEngines(): " + AIGroup.GetNumEngines(group, 116)); - print(" GetNumEngines(): " + AIGroup.GetNumEngines(AIGroup.ALL_GROUP, 116)); - print(" GetNumEngines(): " + AIGroup.GetNumEngines(AIGroup.DEFAULT_GROUP, 116)); + print(" GetNumEngines(): " + AIGroup.GetNumEngines(AIGroup.GROUP_ALL, 116)); + print(" GetNumEngines(): " + AIGroup.GetNumEngines(AIGroup.GROUP_DEFAULT, 116)); print(" GetName(): " + AIGroup.GetName(0)); print(" GetName(): " + AIGroup.GetName(1)); print(" AIVehicle.SellVehicle(): " + AIVehicle.SellVehicle(vehicle)); @@ -815,7 +815,7 @@ function Regression::Marine() print(" IsLockTile(): " + AIMarine.IsLockTile(32116)); print(" IsCanalTile(): " + AIMarine.IsCanalTile(32116)); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" BuildWaterDepot(): " + AIMarine.BuildWaterDepot(28479, false)); print(" BuildDock(): " + AIMarine.BuildDock(29253, true)); print(" BuildBuoy(): " + AIMarine.BuildBuoy(28481)); @@ -828,7 +828,7 @@ function Regression::Marine() print(" IsBuoyTile(): " + AIMarine.IsBuoyTile(28481)); print(" IsLockTile(): " + AIMarine.IsLockTile(28487)); print(" IsCanalTile(): " + AIMarine.IsCanalTile(32127)); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" RemoveWaterDepot(): " + AIMarine.RemoveWaterDepot(28479)); print(" RemoveDock(): " + AIMarine.RemoveDock(29253)); @@ -840,7 +840,7 @@ function Regression::Marine() print(" IsBuoyTile(): " + AIMarine.IsBuoyTile(28481)); print(" IsLockTile(): " + AIMarine.IsLockTile(28487)); print(" IsCanalTile(): " + AIMarine.IsCanalTile(32127)); - print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF)); print(" BuildWaterDepot(): " + AIMarine.BuildWaterDepot(28479, false)); print(" BuildDock(): " + AIMarine.BuildDock(29253, true)); @@ -1414,7 +1414,7 @@ function Regression::Town() print(" GetPopulation(): " + AITown.GetPopulation(i)); print(" GetLocation(): " + AITown.GetLocation(i)); print(" GetHouseCount(): " + AITown.GetHouseCount(i)); - print(" GetRating(): " + AITown.GetRating(i, AICompany.MY_COMPANY)); + print(" GetRating(): " + AITown.GetRating(i, AICompany.COMPANY_SELF)); } print(" Valid Towns: " + j); print(" GetTownCount(): " + AITown.GetTownCount()); @@ -1478,7 +1478,7 @@ function Regression::Tunnel() print(" IsTunnelTile(): " + AITunnel.IsTunnelTile(29050)); print(" RemoveTunnel(): " + AITunnel.RemoveTunnel(29050)); print(" GetOtherTunnelEnd(): " + AITunnel.GetOtherTunnelEnd(29050)); - print(" BuildTunnel(): " + AITunnel.BuildTunnel(AIVehicle.VEHICLE_ROAD, 29050)); + print(" BuildTunnel(): " + AITunnel.BuildTunnel(AIVehicle.VT_ROAD, 29050)); print(" GetOtherTunnelEnd(): " + AITunnel.GetOtherTunnelEnd(29050)); print(" IsTunnelTile(): " + AITunnel.IsTunnelTile(29050)); print(" IsTunnelTile(): " + AITunnel.IsTunnelTile(28026)); @@ -1486,8 +1486,8 @@ function Regression::Tunnel() print(" IsTunnelTile(): " + AITunnel.IsTunnelTile(29050)); print(" --Errors--"); - print(" BuildTunnel(): " + AITunnel.BuildTunnel(AIVehicle.VEHICLE_ROAD, 7529)); - print(" BuildTunnel(): " + AITunnel.BuildTunnel(AIVehicle.VEHICLE_ROAD, 8043)); + print(" BuildTunnel(): " + AITunnel.BuildTunnel(AIVehicle.VT_ROAD, 7529)); + print(" BuildTunnel(): " + AITunnel.BuildTunnel(AIVehicle.VT_ROAD, 8043)); print(" GetLastErrorString(): " + AIError.GetLastErrorString()); print(" RemoveTunnel(): " + AITunnel.RemoveTunnel(7529)); } @@ -1503,20 +1503,20 @@ function Regression::Vehicle() print(" IsValidVehicle(12): " + AIVehicle.IsValidVehicle(12)); print(" ISValidVehicle(9999): " + AIVehicle.IsValidVehicle(9999)); - local bank = AICompany.GetBankBalance(AICompany.MY_COMPANY); + local bank = AICompany.GetBankBalance(AICompany.COMPANY_SELF); print(" BuildVehicle(): " + AIVehicle.BuildVehicle(33417, 153)); print(" IsValidVehicle(12): " + AIVehicle.IsValidVehicle(12)); print(" CloneVehicle(): " + AIVehicle.CloneVehicle(33417, 12, true)); - local bank_after = AICompany.GetBankBalance(AICompany.MY_COMPANY); + local bank_after = AICompany.GetBankBalance(AICompany.COMPANY_SELF); print(" --Accounting--"); print(" GetCosts(): " + accounting.GetCosts()); print(" Should be: " + (bank - bank_after)); print(" ResetCosts(): " + accounting.ResetCosts()); - bank = AICompany.GetBankBalance(AICompany.MY_COMPANY); + bank = AICompany.GetBankBalance(AICompany.COMPANY_SELF); print(" SellVehicle(13): " + AIVehicle.SellVehicle(13)); print(" IsInDepot(): " + AIVehicle.IsInDepot(12)); @@ -1528,7 +1528,7 @@ function Regression::Vehicle() print(" IsInDepot(): " + AIVehicle.IsInDepot(12)); print(" IsStoppedInDepot(): " + AIVehicle.IsStoppedInDepot(12)); - bank_after = AICompany.GetBankBalance(AICompany.MY_COMPANY); + bank_after = AICompany.GetBankBalance(AICompany.COMPANY_SELF); print(" --Accounting--"); print(" GetCosts(): " + accounting.GetCosts()); diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/regression.txt index be4521934..be6bcbddb 100644 --- a/bin/ai/regression/regression.txt +++ b/bin/ai/regression/regression.txt @@ -6161,8 +6161,8 @@ GetTileIndex(): 123 GetTileIndex(): 31488 GetTileIndex(): 0 - GetTileIndex(): -1 - GetTileIndex(): -1 + GetTileIndex(): -257 + GetTileIndex(): 2570000 IsValidTile(123): true GetTileX(124): 124 GetTileY(124): 0 @@ -6225,12 +6225,12 @@ Tile 45469 Tile 45468 Tile 45467 - Tile 45211 - Tile 44955 - Tile 44699 - Tile 44443 - Tile 44187 - Tile 43931 + Tile 45466 + Tile 45210 + Tile 44954 + Tile 44698 + Tile 44442 + Tile 44186 Tile 43930 Tile 43929 Tile 43928 @@ -7229,7 +7229,7 @@ GetPopulation(): 180 GetLocation(): 14935 GetHouseCount(): 13 - GetRating(): 0 + GetRating(): 5 Town 12 IsValidTown(): true GetName(): Ginborough @@ -7243,7 +7243,7 @@ GetPopulation(): 310 GetLocation(): 9595 GetHouseCount(): 14 - GetRating(): 0 + GetRating(): 5 Town 14 IsValidTown(): true GetName(): Prundinghall @@ -7278,7 +7278,7 @@ GetPopulation(): 262 GetLocation(): 10574 GetHouseCount(): 13 - GetRating(): 0 + GetRating(): 5 Town 19 IsValidTown(): true GetName(): Mendingston @@ -7299,7 +7299,7 @@ GetPopulation(): 802 GetLocation(): 9634 GetHouseCount(): 27 - GetRating(): 0 + GetRating(): 5 Town 22 IsValidTown(): true GetName(): Naborough @@ -7590,12 +7590,12 @@ GetLocation(): 33417 GetEngineType(): 153 GetUnitNumber(): 1 - GetAge(): 1 + GetAge(): 0 GetMaxAge(): 5490 - GetAgeLeft(): 5489 + GetAgeLeft(): 5490 GetCurrentSpeed(): 4 GetRunningCost(): 14 - GetProfitThisYear(): -1 + GetProfitThisYear(): 0 GetProfitLastYear(): 0 GetCurrentValue(): 466 GetVehicleType(): 1 @@ -7605,7 +7605,7 @@ IsInDepot(): false GetNumWagons(): 1 GetWagonEngineType(): 153 - GetWagonAge(): 1 + GetWagonAge(): 0 GetLength(): 8 GetOwner(): 1 BuildVehicle(): 14 @@ -7663,11 +7663,11 @@ 14 => 1 12 => 1 Age ListDump: - 14 => 1 - 13 => 1 - 12 => 1 17 => 0 16 => 0 + 14 => 0 + 13 => 0 + 12 => 0 MaxAge ListDump: 16 => 10980 14 => 10980 @@ -7676,10 +7676,10 @@ 12 => 5490 AgeLeft ListDump: 16 => 10980 - 14 => 10979 + 14 => 10980 17 => 7320 - 13 => 5489 - 12 => 5489 + 13 => 5490 + 12 => 5490 CurrentSpeed ListDump: 12 => 13 17 => 0 @@ -7697,7 +7697,7 @@ 16 => 0 14 => 0 13 => 0 - 12 => -1 + 12 => 0 ProfitLastYear ListDump: 17 => 0 16 => 0 diff --git a/bin/ai/wrightai/main.nut b/bin/ai/wrightai/main.nut index 53b387b2e..3c10aeca9 100644 --- a/bin/ai/wrightai/main.nut +++ b/bin/ai/wrightai/main.nut @@ -32,7 +32,7 @@ class WrightAI extends AIController { */ function WrightAI::HasMoney(money) { - if (AICompany.GetBankBalance(AICompany.MY_COMPANY) + (AICompany.GetMaxLoanAmount() - AICompany.GetLoanAmount()) > money) return true; + if (AICompany.GetBankBalance(AICompany.COMPANY_SELF) + (AICompany.GetMaxLoanAmount() - AICompany.GetLoanAmount()) > money) return true; return false; } @@ -42,9 +42,9 @@ function WrightAI::HasMoney(money) function WrightAI::GetMoney(money) { if (!this.HasMoney(money)) return; - if (AICompany.GetBankBalance(AICompany.MY_COMPANY) > money) return; + if (AICompany.GetBankBalance(AICompany.COMPANY_SELF) > money) return; - local loan = money - AICompany.GetBankBalance(AICompany.MY_COMPANY) + AICompany.GetLoanInterval() + AICompany.GetLoanAmount(); + local loan = money - AICompany.GetBankBalance(AICompany.COMPANY_SELF) + AICompany.GetLoanInterval() + AICompany.GetLoanAmount(); loan = loan - loan % AICompany.GetLoanInterval(); AILog.Info("Need a loan to get " + money + ": " + loan); AICompany.SetLoanAmount(loan); @@ -109,10 +109,10 @@ function WrightAI::BuildAircraft(tile_1, tile_2) local hangar = AIAirport.GetHangarOfAirport(tile_1); local engine = null; - local engine_list = AIEngineList(AIVehicle.VEHICLE_AIR); + local engine_list = AIEngineList(AIVehicle.VT_AIR); /* When bank balance < 300000, buy cheaper planes */ - local balance = AICompany.GetBankBalance(AICompany.MY_COMPANY); + local balance = AICompany.GetBankBalance(AICompany.COMPANY_SELF); engine_list.Valuate(AIEngine.GetPrice); engine_list.KeepBelowValue(balance < 300000 ? 50000 : (balance < 1000000 ? 300000 : 1000000)); @@ -335,7 +335,7 @@ function WrightAI::Start() i++; } } - this.name = AICompany.GetName(AICompany.MY_COMPANY); + this.name = AICompany.GetName(AICompany.COMPANY_SELF); /* Say hello to the user */ AILog.Info("Welcome to WrightAI. I will be building airports all day long."); AILog.Info(" - Minimum Town Size: " + GetSetting("min_town_size")); 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"); |