# HG changeset patch # User truebrain # Date 1203683417 0 # Node ID ee408edf3851b275348d9fc0fe115b7c90f51a0a # Parent 183b38e0a480b68b634a94746d35944705dd98ac (svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth) diff -r 183b38e0a480 -r ee408edf3851 bin/ai/regression/regression.nut --- a/bin/ai/regression/regression.nut Fri Feb 22 12:13:41 2008 +0000 +++ b/bin/ai/regression/regression.nut Fri Feb 22 12:30:17 2008 +0000 @@ -31,146 +31,136 @@ function Regression::Base() { - local base = AIBase(); - print(""); print("--AIBase--"); - print(" Rand(): " + base.Rand()); - print(" Rand(): " + base.Rand()); - print(" Rand(): " + base.Rand()); - print(" RandRange(0): " + base.RandRange(0)); - print(" RandRange(0): " + base.RandRange(0)); - print(" RandRange(0): " + base.RandRange(0)); - print(" RandRange(1): " + base.RandRange(1)); - print(" RandRange(1): " + base.RandRange(1)); - print(" RandRange(1): " + base.RandRange(1)); - print(" RandRange(2): " + base.RandRange(2)); - print(" RandRange(2): " + base.RandRange(2)); - print(" RandRange(2): " + base.RandRange(2)); - print(" RandRange(9): " + base.RandRange(9)); - print(" RandRange(9): " + base.RandRange(9)); - print(" RandRange(9): " + base.RandRange(9)); - print(" Chance(1, 2): " + base.Chance(1, 2)); - print(" Chance(1, 2): " + base.Chance(1, 2)); - print(" Chance(1, 2): " + base.Chance(1, 2)); + print(" Rand(): " + AIBase.Rand()); + print(" Rand(): " + AIBase.Rand()); + print(" Rand(): " + AIBase.Rand()); + print(" RandRange(0): " + AIBase.RandRange(0)); + print(" RandRange(0): " + AIBase.RandRange(0)); + print(" RandRange(0): " + AIBase.RandRange(0)); + print(" RandRange(1): " + AIBase.RandRange(1)); + print(" RandRange(1): " + AIBase.RandRange(1)); + print(" RandRange(1): " + AIBase.RandRange(1)); + print(" RandRange(2): " + AIBase.RandRange(2)); + print(" RandRange(2): " + AIBase.RandRange(2)); + print(" RandRange(2): " + AIBase.RandRange(2)); + print(" RandRange(9): " + AIBase.RandRange(9)); + print(" RandRange(9): " + AIBase.RandRange(9)); + print(" RandRange(9): " + AIBase.RandRange(9)); + print(" Chance(1, 2): " + AIBase.Chance(1, 2)); + print(" Chance(1, 2): " + AIBase.Chance(1, 2)); + print(" Chance(1, 2): " + AIBase.Chance(1, 2)); } function Regression::Airport() { - local airport = AIAirport(); - local company = AICompany(); - print(""); print("--AIAirport--"); - print(" IsHangarTile(): " + airport.IsHangarTile(32116)); - print(" IsAirportTile(): " + airport.IsAirportTile(32116)); - print(" GetHangarOfAirport(): " + airport.GetHangarOfAirport(32116)); + print(" IsHangarTile(): " + AIAirport.IsHangarTile(32116)); + print(" IsAirportTile(): " + AIAirport.IsAirportTile(32116)); + print(" GetHangarOfAirport(): " + AIAirport.GetHangarOfAirport(32116)); for (local i = -1; i < 10; i++) { - print(" AiportAvailable(" + i + "): " + airport.AiportAvailable(i)); - print(" GetAirportWidth(" + i + "): " + airport.GetAirportWidth(i)); - print(" GetAirportHeight(" + i + "): " + airport.GetAirportHeight(i)); - print(" GetAirportCoverageRadius(" + i + "): " + airport.GetAirportCoverageRadius(i)); + print(" AiportAvailable(" + i + "): " + AIAirport.AiportAvailable(i)); + print(" GetAirportWidth(" + i + "): " + AIAirport.GetAirportWidth(i)); + print(" GetAirportHeight(" + i + "): " + AIAirport.GetAirportHeight(i)); + print(" GetAirportCoverageRadius(" + i + "): " + AIAirport.GetAirportCoverageRadius(i)); } - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); - print(" BuildAirport(): " + airport.BuildAirport(32116, 0)); - print(" IsHangarTile(): " + airport.IsHangarTile(32116)); - print(" IsAirportTile(): " + airport.IsAirportTile(32116)); - print(" GetHangarOfAirport(): " + airport.GetHangarOfAirport(32116)); - print(" IsHangarTile(): " + airport.IsHangarTile(32119)); - print(" IsAirportTile(): " + airport.IsAirportTile(32119)); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" BuildAirport(): " + AIAirport.BuildAirport(32116, 0)); + print(" IsHangarTile(): " + AIAirport.IsHangarTile(32116)); + print(" IsAirportTile(): " + AIAirport.IsAirportTile(32116)); + print(" GetHangarOfAirport(): " + AIAirport.GetHangarOfAirport(32116)); + print(" IsHangarTile(): " + AIAirport.IsHangarTile(32119)); + print(" IsAirportTile(): " + AIAirport.IsAirportTile(32119)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); - print(" RemoveAirport(): " + airport.RemoveAirport(32118)); - print(" IsHangarTile(): " + airport.IsHangarTile(32119)); - print(" IsAirportTile(): " + airport.IsAirportTile(32119)); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); - print(" BuildAirport(): " + airport.BuildAirport(32116, 0)); + print(" RemoveAirport(): " + AIAirport.RemoveAirport(32118)); + print(" IsHangarTile(): " + AIAirport.IsHangarTile(32119)); + print(" IsAirportTile(): " + AIAirport.IsAirportTile(32119)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" BuildAirport(): " + AIAirport.BuildAirport(32116, 0)); } function Regression::Cargo() { - local cargo = AICargo(); - print(""); print("--AICargo--"); for (local i = -1; i < 15; i++) { print(" Cargo " + i); - print(" IsValidCargo(): " + cargo.IsValidCargo(i)); - print(" GetCargoLabel(): '" + cargo.GetCargoLabel(i)+ "'"); - print(" IsFreight(): " + cargo.IsFreight(i)); - print(" GetCargoIncome(0, 0): " + cargo.GetCargoIncome(0, 0, i)); - print(" GetCargoIncome(10, 10): " + cargo.GetCargoIncome(10, 10, i)); - print(" GetCargoIncome(100, 10): " + cargo.GetCargoIncome(100, 10, i)); - print(" GetCargoIncome(10, 100): " + cargo.GetCargoIncome(10, 100, i)); + print(" IsValidCargo(): " + AICargo.IsValidCargo(i)); + print(" GetCargoLabel(): '" + AICargo.GetCargoLabel(i)+ "'"); + print(" IsFreight(): " + AICargo.IsFreight(i)); + print(" GetCargoIncome(0, 0): " + AICargo.GetCargoIncome(0, 0, i)); + print(" GetCargoIncome(10, 10): " + AICargo.GetCargoIncome(10, 10, i)); + print(" GetCargoIncome(100, 10): " + AICargo.GetCargoIncome(100, 10, i)); + print(" GetCargoIncome(10, 100): " + AICargo.GetCargoIncome(10, 100, i)); } } function Regression::Company() { - local company = AICompany(); - print(""); print("--Company--"); /* Test AIXXXMode() in scopes */ { local test = AITestMode(); - print(" SetCompanyName(): " + company.SetCompanyName("Regression")); - print(" SetCompanyName(): " + company.SetCompanyName("Regression")); + print(" SetCompanyName(): " + AICompany.SetCompanyName("Regression")); + print(" SetCompanyName(): " + AICompany.SetCompanyName("Regression")); { local exec = AIExecMode(); - print(" SetCompanyName(): " + company.SetCompanyName("Regression")); - print(" SetCompanyName(): " + company.SetCompanyName("Regression")); + print(" SetCompanyName(): " + AICompany.SetCompanyName("Regression")); + print(" SetCompanyName(): " + AICompany.SetCompanyName("Regression")); } } - print(" GetCompanyName(): " + company.GetCompanyName(AICompany.MY_COMPANY)); - print(" GetPresidentName(): " + company.GetPresidentName(AICompany.MY_COMPANY)); - print(" SetPresidentName(): " + company.SetPresidentName("Regression AI")); - print(" GetPresidentName(): " + company.GetPresidentName(AICompany.MY_COMPANY)); - print(" GetCompanyValue(): " + company.GetCompanyValue(AICompany.MY_COMPANY)); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); - print(" GetCompanyName(): " + company.GetCompanyName(240)); - print(" GetLoanAmount(): " + company.GetLoanAmount()); - print(" GetMaxLoanAmount(): " + company.GetMaxLoanAmount()); - print(" GetLoanInterval(): " + company.GetLoanInterval()); - print(" SetLoanAmount(1): " + company.SetLoanAmount(1)); - print(" SetLoanAmount(100): " + company.SetLoanAmount(100)); - print(" SetLoanAmount(10000): " + company.SetLoanAmount(10000)); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); - print(" GetLoanAmount(): " + company.GetLoanAmount()); - print(" SetMinimumLoanAmount(31337): " + company.SetMinimumLoanAmount(31337)); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); - print(" GetLoanAmount(): " + company.GetLoanAmount()); - print(" SetLoanAmount(10000): " + company.SetLoanAmount(company.GetMaxLoanAmount())); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); - print(" GetLoanAmount(): " + company.GetLoanAmount()); + print(" GetCompanyName(): " + AICompany.GetCompanyName(AICompany.MY_COMPANY)); + print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.MY_COMPANY)); + 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(" GetCompanyName(): " + AICompany.GetCompanyName(240)); + print(" GetLoanAmount(): " + AICompany.GetLoanAmount()); + print(" GetMaxLoanAmount(): " + AICompany.GetMaxLoanAmount()); + print(" GetLoanInterval(): " + AICompany.GetLoanInterval()); + print(" SetLoanAmount(1): " + AICompany.SetLoanAmount(1)); + print(" SetLoanAmount(100): " + AICompany.SetLoanAmount(100)); + print(" SetLoanAmount(10000): " + AICompany.SetLoanAmount(10000)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetLoanAmount(): " + AICompany.GetLoanAmount()); + print(" SetMinimumLoanAmount(31337): " + AICompany.SetMinimumLoanAmount(31337)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetLoanAmount(): " + AICompany.GetLoanAmount()); + print(" SetLoanAmount(10000): " + AICompany.SetLoanAmount(AICompany.GetMaxLoanAmount())); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetLoanAmount(): " + AICompany.GetLoanAmount()); } function Regression::Engine() { - local engine = AIEngine(); local j = 0; print(""); print("--Engine--"); for (local i = -1; i < 257; i++) { - if (engine.IsValidEngine(i)) j++; + if (AIEngine.IsValidEngine(i)) j++; print(" Engine " + i); - print(" IsValidEngine(): " + engine.IsValidEngine(i)); - print(" GetName(): " + engine.GetName(i)); - print(" GetCargoType(): " + engine.GetCargoType(i)); - print(" GetCapacity(): " + engine.GetCapacity(i)); - print(" GetReliability(): " + engine.GetReliability(i)); - print(" GetMaxSpeed(): " + engine.GetMaxSpeed(i)); - print(" GetPrice(): " + engine.GetPrice(i)); - print(" GetMaxAge(): " + engine.GetMaxAge(i)); - print(" GetRunningCost(): " + engine.GetRunningCost(i)); - print(" GetName(): " + engine.GetName(i)); - print(" GetVehicleType(): " + engine.GetVehicleType(i)); + print(" IsValidEngine(): " + AIEngine.IsValidEngine(i)); + print(" GetName(): " + AIEngine.GetName(i)); + print(" GetCargoType(): " + AIEngine.GetCargoType(i)); + print(" GetCapacity(): " + AIEngine.GetCapacity(i)); + print(" GetReliability(): " + AIEngine.GetReliability(i)); + print(" GetMaxSpeed(): " + AIEngine.GetMaxSpeed(i)); + print(" GetPrice(): " + AIEngine.GetPrice(i)); + print(" GetMaxAge(): " + AIEngine.GetMaxAge(i)); + print(" GetRunningCost(): " + AIEngine.GetRunningCost(i)); + print(" GetName(): " + AIEngine.GetName(i)); + print(" GetVehicleType(): " + AIEngine.GetVehicleType(i)); } print(" Valid Engines: " + j); } @@ -252,24 +242,23 @@ function Regression::Industry() { - local industry = AIIndustry(); local j = 0; print(""); print("--Industry--"); - print(" GetMaxIndustryID(): " + industry.GetMaxIndustryID()); - print(" GetIndustryCount(): " + industry.GetIndustryCount()); - for (local i = -1; i < industry.GetMaxIndustryID() + 1; i++) { - if (industry.IsValidIndustry(i)) j++; + print(" GetMaxIndustryID(): " + AIIndustry.GetMaxIndustryID()); + print(" GetIndustryCount(): " + AIIndustry.GetIndustryCount()); + for (local i = -1; i < AIIndustry.GetMaxIndustryID() + 1; i++) { + if (AIIndustry.IsValidIndustry(i)) j++; print(" Industry " + i); - print(" IsValidIndustry(): " + industry.IsValidIndustry(i)); - print(" GetName(): " + industry.GetName(i)); - print(" GetLocation(): " + industry.GetLocation(i)); - print(" GetProduction(): " + industry.GetProduction(i, 1)); - print(" IsCargoAccepted(): " + industry.IsCargoAccepted(i, 1)); + print(" IsValidIndustry(): " + AIIndustry.IsValidIndustry(i)); + print(" GetName(): " + AIIndustry.GetName(i)); + print(" GetLocation(): " + AIIndustry.GetLocation(i)); + print(" GetProduction(): " + AIIndustry.GetProduction(i, 1)); + print(" IsCargoAccepted(): " + AIIndustry.IsCargoAccepted(i, 1)); } print(" Valid Industries: " + j); - print(" GetIndustryCount(): " + industry.GetIndustryCount()); + print(" GetIndustryCount(): " + AIIndustry.GetIndustryCount()); } function Regression::IndustryList() @@ -382,104 +371,97 @@ function Regression::Map() { - local map = AIMap(); - print(""); print("--Map--"); - print(" GetMapSize(): " + map.GetMapSize()); - print(" GetMapSizeX(): " + map.GetMapSizeX()); - print(" GetMapSizeY(): " + map.GetMapSizeY()); - print(" GetTileX(123): " + map.GetTileX(123)); - print(" GetTileY(123): " + map.GetTileY(123)); - print(" GetTileIndex(): " + map.GetTileIndex(123, 0)); - print(" GetTileIndex(): " + map.GetTileIndex(0, 123)); - print(" GetTileIndex(): " + map.GetTileIndex(0, 0)); - print(" GetTileIndex(): " + map.GetTileIndex(-1, -1)); - print(" GetTileIndex(): " + map.GetTileIndex(10000, 10000)); - print(" IsValidTile(123): " + map.IsValidTile(123)); - print(" GetTileX(124): " + map.GetTileX(124)); - print(" GetTileY(124): " + map.GetTileY(124)); - print(" IsValidTile(124): " + map.IsValidTile(124)); - print(" IsValidTile(0): " + map.IsValidTile(0)); - print(" IsValidTile(-1): " + map.IsValidTile(-1)); - print(" IsValidTile(): " + map.IsValidTile(map.GetMapSize())); - print(" IsValidTile(): " + map.IsValidTile(map.GetMapSize() - 1)); - print(" DemolishTile(): " + map.DemolishTile(19592)); - print(" DemolishTile(): " + map.DemolishTile(19335)); + print(" GetMapSize(): " + AIMap.GetMapSize()); + print(" GetMapSizeX(): " + AIMap.GetMapSizeX()); + print(" GetMapSizeY(): " + AIMap.GetMapSizeY()); + print(" GetTileX(123): " + AIMap.GetTileX(123)); + print(" GetTileY(123): " + AIMap.GetTileY(123)); + print(" GetTileIndex(): " + AIMap.GetTileIndex(123, 0)); + print(" GetTileIndex(): " + AIMap.GetTileIndex(0, 123)); + print(" GetTileIndex(): " + AIMap.GetTileIndex(0, 0)); + print(" GetTileIndex(): " + AIMap.GetTileIndex(-1, -1)); + print(" GetTileIndex(): " + AIMap.GetTileIndex(10000, 10000)); + print(" IsValidTile(123): " + AIMap.IsValidTile(123)); + print(" GetTileX(124): " + AIMap.GetTileX(124)); + print(" GetTileY(124): " + AIMap.GetTileY(124)); + print(" IsValidTile(124): " + AIMap.IsValidTile(124)); + print(" IsValidTile(0): " + AIMap.IsValidTile(0)); + print(" IsValidTile(-1): " + AIMap.IsValidTile(-1)); + print(" IsValidTile(): " + AIMap.IsValidTile(AIMap.GetMapSize())); + print(" IsValidTile(): " + AIMap.IsValidTile(AIMap.GetMapSize() - 1)); + print(" DemolishTile(): " + AIMap.DemolishTile(19592)); + print(" DemolishTile(): " + AIMap.DemolishTile(19335)); print(" Distance"); - print(" DistanceManhattan(): " + map.DistanceManhattan(1, 10000)); - print(" DistanceMax(): " + map.DistanceMax(1, 10000)); - print(" DistanceSquare(): " + map.DistanceSquare(1, 10000)); - print(" DistanceFromEdge(): " + map.DistanceFromEdge(10000)); + print(" DistanceManhattan(): " + AIMap.DistanceManhattan(1, 10000)); + print(" DistanceMax(): " + AIMap.DistanceMax(1, 10000)); + print(" DistanceSquare(): " + AIMap.DistanceSquare(1, 10000)); + print(" DistanceFromEdge(): " + AIMap.DistanceFromEdge(10000)); } function Regression::Marine() { - local marine = AIMarine(); - local company = AICompany(); - print(""); print("--AIMarine--"); - print(" IsWaterDepotTile(): " + marine.IsWaterDepotTile(32116)); - print(" IsDockTile(): " + marine.IsDockTile(32116)); - print(" IsBuoyTile(): " + marine.IsBuoyTile(32116)); - print(" IsLockTile(): " + marine.IsLockTile(32116)); - print(" IsCanalTile(): " + marine.IsCanalTile(32116)); + print(" IsWaterDepotTile(): " + AIMarine.IsWaterDepotTile(32116)); + print(" IsDockTile(): " + AIMarine.IsDockTile(32116)); + print(" IsBuoyTile(): " + AIMarine.IsBuoyTile(32116)); + print(" IsLockTile(): " + AIMarine.IsLockTile(32116)); + print(" IsCanalTile(): " + AIMarine.IsCanalTile(32116)); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); - print(" BuildWaterDepot(): " + marine.BuildWaterDepot(28479, false)); - print(" BuildDock(): " + marine.BuildDock(29253)); - print(" BuildBuoy(): " + marine.BuildBuoy(28481)); - print(" BuildLock(): " + marine.BuildLock(28487)); - print(" BuildCanal(): " + marine.BuildCanal(32127)); - print(" IsWaterDepotTile(): " + marine.IsWaterDepotTile(28479)); - print(" IsDockTile(): " + marine.IsDockTile(29253)); - print(" IsBuoyTile(): " + marine.IsBuoyTile(28481)); - print(" IsLockTile(): " + marine.IsLockTile(28487)); - print(" IsCanalTile(): " + marine.IsCanalTile(32127)); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); + print(" BuildWaterDepot(): " + AIMarine.BuildWaterDepot(28479, false)); + print(" BuildDock(): " + AIMarine.BuildDock(29253)); + print(" BuildBuoy(): " + AIMarine.BuildBuoy(28481)); + print(" BuildLock(): " + AIMarine.BuildLock(28487)); + print(" BuildCanal(): " + AIMarine.BuildCanal(32127)); + print(" IsWaterDepotTile(): " + AIMarine.IsWaterDepotTile(28479)); + print(" IsDockTile(): " + AIMarine.IsDockTile(29253)); + print(" IsBuoyTile(): " + AIMarine.IsBuoyTile(28481)); + print(" IsLockTile(): " + AIMarine.IsLockTile(28487)); + print(" IsCanalTile(): " + AIMarine.IsCanalTile(32127)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); - print(" RemoveWaterDepot(): " + marine.RemoveWaterDepot(28479)); - print(" RemoveDock(): " + marine.RemoveDock(29253)); - print(" RemoveBuoy(): " + marine.RemoveBuoy(28481)); - print(" RemoveLock(): " + marine.RemoveLock(28487)); - print(" RemoveCanal(): " + marine.RemoveCanal(32127)); - print(" IsWaterDepotTile(): " + marine.IsWaterDepotTile(28479)); - print(" IsDockTile(): " + marine.IsDockTile(29253)); - print(" IsBuoyTile(): " + marine.IsBuoyTile(28481)); - print(" IsLockTile(): " + marine.IsLockTile(28487)); - print(" IsCanalTile(): " + marine.IsCanalTile(32127)); - print(" GetBankBalance(): " + company.GetBankBalance(AICompany.MY_COMPANY)); + print(" RemoveWaterDepot(): " + AIMarine.RemoveWaterDepot(28479)); + print(" RemoveDock(): " + AIMarine.RemoveDock(29253)); + print(" RemoveBuoy(): " + AIMarine.RemoveBuoy(28481)); + print(" RemoveLock(): " + AIMarine.RemoveLock(28487)); + print(" RemoveCanal(): " + AIMarine.RemoveCanal(32127)); + print(" IsWaterDepotTile(): " + AIMarine.IsWaterDepotTile(28479)); + print(" IsDockTile(): " + AIMarine.IsDockTile(29253)); + print(" IsBuoyTile(): " + AIMarine.IsBuoyTile(28481)); + print(" IsLockTile(): " + AIMarine.IsLockTile(28487)); + print(" IsCanalTile(): " + AIMarine.IsCanalTile(32127)); + print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.MY_COMPANY)); - print(" BuildWaterDepot(): " + marine.BuildWaterDepot(28479, false)); - print(" BuildDock(): " + marine.BuildDock(29253)); + print(" BuildWaterDepot(): " + AIMarine.BuildWaterDepot(28479, false)); + print(" BuildDock(): " + AIMarine.BuildDock(29253)); } function Regression::Order() { - local order = AIOrder(); - print(""); print("--Order--"); - print(" GetNumberOfOrders(): " + order.GetNumberOfOrders(11)); - print(" GetOrderDestination(): " + order.GetOrderDestination(11, 1)); - print(" AreOrderFlagsValid(): " + order.AreOrderFlagsValid(33416, AIOrder.AIOF_TRANSFER)); - print(" IsValidVehicleOrder(): " + order.IsValidVehicleOrder(11, 1)); - print(" GetOrderFlags(): " + order.GetOrderFlags(11, 1)); - print(" AppendOrder(): " + order.AppendOrder(11, 33416, AIOrder.AIOF_TRANSFER)); - print(" InsertOrder(): " + order.InsertOrder(11, 0, 33416, AIOrder.AIOF_TRANSFER)); - print(" GetNumberOfOrders(): " + order.GetNumberOfOrders(11)); - print(" IsValidVehicleOrder(): " + order.IsValidVehicleOrder(11, 1)); - print(" RemoveOrder(): " + order.RemoveOrder(11, 0)); - print(" ChangeOrder(): " + order.ChangeOrder(11, 0, AIOrder.AIOF_FULL_LOAD)); - print(" GetOrderDestination(): " + order.GetOrderDestination(11, 0)); - print(" CopyOrders(): " + order.CopyOrders(11, 1)); - print(" CopyOrders(): " + order.CopyOrders(12, 11)); - print(" ShareOrders(): " + order.ShareOrders(12, 1)); - print(" ShareOrders(): " + order.ShareOrders(12, 11)); - print(" UnshareOrders(): " + order.UnshareOrders(12)); - print(" AppendOrder(): " + order.AppendOrder(11, 33421, AIOrder.AIOF_NONE)); + print(" GetNumberOfOrders(): " + AIOrder.GetNumberOfOrders(11)); + print(" GetOrderDestination(): " + AIOrder.GetOrderDestination(11, 1)); + print(" AreOrderFlagsValid(): " + AIOrder.AreOrderFlagsValid(33416, AIOrder.AIOF_TRANSFER)); + print(" IsValidVehicleOrder(): " + AIOrder.IsValidVehicleOrder(11, 1)); + print(" GetOrderFlags(): " + AIOrder.GetOrderFlags(11, 1)); + print(" AppendOrder(): " + AIOrder.AppendOrder(11, 33416, AIOrder.AIOF_TRANSFER)); + print(" InsertOrder(): " + AIOrder.InsertOrder(11, 0, 33416, AIOrder.AIOF_TRANSFER)); + print(" GetNumberOfOrders(): " + AIOrder.GetNumberOfOrders(11)); + print(" IsValidVehicleOrder(): " + AIOrder.IsValidVehicleOrder(11, 1)); + print(" RemoveOrder(): " + AIOrder.RemoveOrder(11, 0)); + print(" ChangeOrder(): " + AIOrder.ChangeOrder(11, 0, AIOrder.AIOF_FULL_LOAD)); + print(" GetOrderDestination(): " + AIOrder.GetOrderDestination(11, 0)); + print(" CopyOrders(): " + AIOrder.CopyOrders(11, 1)); + print(" CopyOrders(): " + AIOrder.CopyOrders(12, 11)); + print(" ShareOrders(): " + AIOrder.ShareOrders(12, 1)); + print(" ShareOrders(): " + AIOrder.ShareOrders(12, 11)); + print(" UnshareOrders(): " + AIOrder.UnshareOrders(12)); + print(" AppendOrder(): " + AIOrder.AppendOrder(11, 33421, AIOrder.AIOF_NONE)); local list = AIVehicleStationList(11); @@ -545,119 +527,113 @@ print(" BuildRoute(): " + pf.BuildRoute(ret)); pf.FreeRoute(ret); - local road = AIRoad(); - print(" IsRoadTile(): " + road.IsRoadTile(33425)); - print(" IsRoadTile(): " + road.IsRoadTile(33480 + 256 * 5)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33425)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33480 + 256 * 5)); } function Regression::Road() { - local road = AIRoad(); - print(""); print("--Road--"); print(" Road"); - print(" IsRoadTile(): " + road.IsRoadTile(33411)); - print(" BuildRoad(): " + road.BuildRoad(0, 1)); - print(" BuildRoad(): " + road.BuildRoad(33411, 33411)); - print(" BuildRoad(): " + road.BuildRoad(33411, 33414)); - print(" AreRoadTilesConnected(): " + road.AreRoadTilesConnected(33412, 33413)); - print(" IsRoadTile(): " + road.IsRoadTile(33411)); - print(" GetNeighbourRoadCount(): " + road.GetNeighbourRoadCount(33412)); - print(" RemoveRoad(): " + road.RemoveRoad(33411, 33411)); - print(" RemoveRoad(): " + road.RemoveRoad(33411, 33412)); - print(" RemoveRoad(): " + road.RemoveRoad(19590, 19590)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33411)); + print(" BuildRoad(): " + AIRoad.BuildRoad(0, 1)); + print(" BuildRoad(): " + AIRoad.BuildRoad(33411, 33411)); + print(" BuildRoad(): " + AIRoad.BuildRoad(33411, 33414)); + print(" AreRoadTilesConnected(): " + AIRoad.AreRoadTilesConnected(33412, 33413)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33411)); + print(" GetNeighbourRoadCount(): " + AIRoad.GetNeighbourRoadCount(33412)); + print(" RemoveRoad(): " + AIRoad.RemoveRoad(33411, 33411)); + print(" RemoveRoad(): " + AIRoad.RemoveRoad(33411, 33412)); + print(" RemoveRoad(): " + AIRoad.RemoveRoad(19590, 19590)); print(" Depot"); - print(" IsRoadTile(): " + road.IsRoadTile(33411)); - print(" BuildRoadDepot(): " + road.BuildRoadDepot(0, 1)); - print(" BuildRoadDepot(): " + road.BuildRoadDepot(33411, 33411)); - print(" BuildRoadDepot(): " + road.BuildRoadDepot(33411, 33414)); - print(" BuildRoadDepot(): " + road.BuildRoadDepot(33411, 33412)); - print(" IsRoadTile(): " + road.IsRoadTile(33411)); - print(" GetRoadDepotFrontTile(): " + road.GetRoadDepotFrontTile(33411)); - print(" IsRoadDepotTile(): " + road.IsRoadDepotTile(33411)); - print(" RemoveRoadDepot(): " + road.RemoveRoadDepot(33411)); - print(" RemoveRoadDepot(): " + road.RemoveRoadDepot(33411)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33411)); + print(" BuildRoadDepot(): " + AIRoad.BuildRoadDepot(0, 1)); + print(" BuildRoadDepot(): " + AIRoad.BuildRoadDepot(33411, 33411)); + print(" BuildRoadDepot(): " + AIRoad.BuildRoadDepot(33411, 33414)); + print(" BuildRoadDepot(): " + AIRoad.BuildRoadDepot(33411, 33412)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33411)); + print(" GetRoadDepotFrontTile(): " + AIRoad.GetRoadDepotFrontTile(33411)); + print(" IsRoadDepotTile(): " + AIRoad.IsRoadDepotTile(33411)); + print(" RemoveRoadDepot(): " + AIRoad.RemoveRoadDepot(33411)); + print(" RemoveRoadDepot(): " + AIRoad.RemoveRoadDepot(33411)); print(" Station"); - print(" IsRoadTile(): " + road.IsRoadTile(33411)); - print(" BuildRoadStation(): " + road.BuildRoadStation(0, 1, false, false)); - print(" BuildRoadStation(): " + road.BuildRoadStation(33411, 33411, false, false)); - print(" BuildRoadStation(): " + road.BuildRoadStation(33411, 33414, false, false)); - print(" BuildRoadStation(): " + road.BuildRoadStation(33411, 33412, false, false)); - print(" IsRoadTile(): " + road.IsRoadTile(33411)); - print(" GetDriveThroughBackTile(): " + road.GetDriveThroughBackTile(33411)); - print(" GetRoadStationFrontTile(): " + road.GetRoadStationFrontTile(33411)); - print(" IsRoadStationTile(): " + road.IsRoadStationTile(33411)); - print(" IsDriveThroughRoadStationTile: " + road.IsDriveThroughRoadStationTile(33411)); - print(" RemoveRoadStation(): " + road.RemoveRoadStation(33411)); - print(" RemoveRoadStation(): " + road.RemoveRoadStation(33411)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33411)); + print(" BuildRoadStation(): " + AIRoad.BuildRoadStation(0, 1, false, false)); + print(" BuildRoadStation(): " + AIRoad.BuildRoadStation(33411, 33411, false, false)); + print(" BuildRoadStation(): " + AIRoad.BuildRoadStation(33411, 33414, false, false)); + print(" BuildRoadStation(): " + AIRoad.BuildRoadStation(33411, 33412, false, false)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33411)); + print(" GetDriveThroughBackTile(): " + AIRoad.GetDriveThroughBackTile(33411)); + print(" GetRoadStationFrontTile(): " + AIRoad.GetRoadStationFrontTile(33411)); + print(" IsRoadStationTile(): " + AIRoad.IsRoadStationTile(33411)); + print(" IsDriveThroughRoadStationTile: " + AIRoad.IsDriveThroughRoadStationTile(33411)); + print(" RemoveRoadStation(): " + AIRoad.RemoveRoadStation(33411)); + print(" RemoveRoadStation(): " + AIRoad.RemoveRoadStation(33411)); print(" Station Types"); - print(" BuildRoadStation(bus): " + road.BuildRoadStation(33411, 33410, false, false)); - print(" BuildRoadStation(truck): " + road.BuildRoadStation(33421, 33422, true, false)); - print(" BuildRoadStation(truck): " + road.BuildRoadStation(33412, 33413, true, false)); - print(" BuildRoadStation(bus): " + road.BuildRoadStation(33411 + 256, 33411, false, false)); - print(" BuildRoadStation(truck): " + road.BuildRoadStation(33412 + 256, 33412 + 256 + 256, true, false)); - print(" BuildRoadStation(bus-drive): " + road.BuildRoadStation(33413, 33412, false, true)); - print(" BuildRoadStation(truck-drive): " + road.BuildRoadStation(33414, 33413, true, true)); - print(" BuildRoadStation(bus-drive): " + road.BuildRoadStation(33415, 33414, false, true)); - print(" BuildRoadStation(truck-drive): " + road.BuildRoadStation(33416, 33415, true, true)); - print(" BuildRoadDepot(): " + road.BuildRoadDepot(33417, 33418)); - print(" GetRoadStationFrontTile(): " + road.GetRoadStationFrontTile(33411 + 256)); - print(" GetRoadStationFrontTile(): " + road.GetRoadStationFrontTile(33412 + 256)); - print(" IsDriveThroughRoadStationTile: " + road.IsDriveThroughRoadStationTile(33415)); - print(" GetDriveThroughBackTile(): " + road.GetDriveThroughBackTile(33415)); - print(" GetRoadStationFrontTile(): " + road.GetRoadStationFrontTile(33415)); - print(" IsRoadTile(): " + road.IsRoadTile(33415)); + print(" BuildRoadStation(bus): " + AIRoad.BuildRoadStation(33411, 33410, false, false)); + print(" BuildRoadStation(truck): " + AIRoad.BuildRoadStation(33421, 33422, true, false)); + print(" BuildRoadStation(truck): " + AIRoad.BuildRoadStation(33412, 33413, true, false)); + print(" BuildRoadStation(bus): " + AIRoad.BuildRoadStation(33411 + 256, 33411, false, false)); + print(" BuildRoadStation(truck): " + AIRoad.BuildRoadStation(33412 + 256, 33412 + 256 + 256, true, false)); + print(" BuildRoadStation(bus-drive): " + AIRoad.BuildRoadStation(33413, 33412, false, true)); + print(" BuildRoadStation(truck-drive): " + AIRoad.BuildRoadStation(33414, 33413, true, true)); + print(" BuildRoadStation(bus-drive): " + AIRoad.BuildRoadStation(33415, 33414, false, true)); + print(" BuildRoadStation(truck-drive): " + AIRoad.BuildRoadStation(33416, 33415, true, true)); + print(" BuildRoadDepot(): " + AIRoad.BuildRoadDepot(33417, 33418)); + print(" GetRoadStationFrontTile(): " + AIRoad.GetRoadStationFrontTile(33411 + 256)); + print(" GetRoadStationFrontTile(): " + AIRoad.GetRoadStationFrontTile(33412 + 256)); + print(" IsDriveThroughRoadStationTile: " + AIRoad.IsDriveThroughRoadStationTile(33415)); + print(" GetDriveThroughBackTile(): " + AIRoad.GetDriveThroughBackTile(33415)); + print(" GetRoadStationFrontTile(): " + AIRoad.GetRoadStationFrontTile(33415)); + print(" IsRoadTile(): " + AIRoad.IsRoadTile(33415)); } function Regression::Sign() { - local sign = AISign(); local j = 0; print(""); print("--Sign--"); - print(" BuildSign(33410, 'Some Sign'): " + sign.BuildSign(33410, "Some Sign")); - local sign_id = sign.BuildSign(33409, "Some other Sign"); - print(" BuildSign(33409, 'Some other Sign'): " + sign_id); - print(" RemoveSign(" + sign_id + "): " + sign.RemoveSign(sign_id)); + print(" BuildSign(33410, 'Some Sign'): " + AISign.BuildSign(33410, "Some Sign")); + local AISign_id = AISign.BuildSign(33409, "Some other Sign"); + print(" BuildSign(33409, 'Some other Sign'): " + AISign_id); + print(" RemoveSign(" + AISign_id + "): " + AISign.RemoveSign(AISign_id)); print(""); - print(" GetMaxSignID(): " + sign.GetMaxSignID()); - print(" GetSignCount(): " + sign.GetSignCount()); - for (local i = -1; i < sign.GetMaxSignID() + 1; i++) { - if (sign.IsValidSign(i)) j++; + print(" GetMaxSignID(): " + AISign.GetMaxSignID()); + print(" GetSignCount(): " + AISign.GetSignCount()); + for (local i = -1; i < AISign.GetMaxSignID() + 1; i++) { + if (AISign.IsValidSign(i)) j++; print(" Sign " + i); - print(" IsValidSign(): " + sign.IsValidSign(i)); - print(" GetText(): " + sign.GetText(i)); - print(" GetLocation(): " + sign.GetLocation(i)); + print(" IsValidSign(): " + AISign.IsValidSign(i)); + print(" GetText(): " + AISign.GetText(i)); + print(" GetLocation(): " + AISign.GetLocation(i)); } print(" Valid Signs: " + j); - print(" GetSignCount(): " + sign.GetSignCount()); + print(" GetSignCount(): " + AISign.GetSignCount()); } function Regression::Station() { - local station = AIStation(); - print(""); print("--Station--"); - print(" IsValidStation(0): " + station.IsValidStation(0)); - print(" IsValidStation(1000): " + station.IsValidStation(1000)); - print(" GetName(0): " + station.GetName(0)); - print(" GetLocation(1): " + station.GetLocation(1)); - print(" GetLocation(1000): " + station.GetLocation(1000)); - print(" GetStationID(33411): " + station.GetStationID(33411)); - print(" GetStationID(34411): " + station.GetStationID(34411)); - print(" GetCargoWaiting(0, 0): " + station.GetCargoWaiting(0, 0)); - print(" GetCargoWaiting(1000, 0): " + station.GetCargoWaiting(1000, 0)); - print(" GetCargoWaiting(0, 1000): " + station.GetCargoWaiting(0, 1000)); + print(" IsValidStation(0): " + AIStation.IsValidStation(0)); + print(" IsValidStation(1000): " + AIStation.IsValidStation(1000)); + print(" GetName(0): " + AIStation.GetName(0)); + print(" GetLocation(1): " + AIStation.GetLocation(1)); + print(" GetLocation(1000): " + AIStation.GetLocation(1000)); + print(" GetStationID(33411): " + AIStation.GetStationID(33411)); + print(" GetStationID(34411): " + AIStation.GetStationID(34411)); + print(" GetCargoWaiting(0, 0): " + AIStation.GetCargoWaiting(0, 0)); + print(" GetCargoWaiting(1000, 0): " + AIStation.GetCargoWaiting(1000, 0)); + print(" GetCargoWaiting(0, 1000): " + AIStation.GetCargoWaiting(0, 1000)); - print(" GetCoverageRadius(bus): " + station.GetCoverageRadius(AIStation.STATION_BUS_STOP)); - print(" GetCoverageRadius(truck): " + station.GetCoverageRadius(AIStation.STATION_TRUCK_STOP)); - print(" GetCoverageRadius(train): " + station.GetCoverageRadius(AIStation.STATION_TRAIN)); + print(" GetCoverageRadius(bus): " + AIStation.GetCoverageRadius(AIStation.STATION_BUS_STOP)); + print(" GetCoverageRadius(truck): " + AIStation.GetCoverageRadius(AIStation.STATION_TRUCK_STOP)); + print(" GetCoverageRadius(train): " + AIStation.GetCoverageRadius(AIStation.STATION_TRAIN)); local list = AIStationList(AIStation.STATION_BUS_STOP + AIStation.STATION_TRUCK_STOP); @@ -773,23 +749,22 @@ function Regression::Town() { - local town = AITown(); local j = 0; print(""); print("--Town--"); - print(" GetMaxTownID(): " + town.GetMaxTownID()); - print(" GetTownCount(): " + town.GetTownCount()); - for (local i = -1; i < town.GetMaxTownID() + 1; i++) { - if (town.IsValidTown(i)) j++; + print(" GetMaxTownID(): " + AITown.GetMaxTownID()); + print(" GetTownCount(): " + AITown.GetTownCount()); + for (local i = -1; i < AITown.GetMaxTownID() + 1; i++) { + if (AITown.IsValidTown(i)) j++; print(" Town " + i); - print(" IsValidTown(): " + town.IsValidTown(i)); - print(" GetName(): " + town.GetName(i)); - print(" GetPopulation(): " + town.GetPopulation(i)); - print(" GetLocation(): " + town.GetLocation(i)); + print(" IsValidTown(): " + AITown.IsValidTown(i)); + print(" GetName(): " + AITown.GetName(i)); + print(" GetPopulation(): " + AITown.GetPopulation(i)); + print(" GetLocation(): " + AITown.GetLocation(i)); } print(" Valid Towns: " + j); - print(" GetTownCount(): " + town.GetTownCount()); + print(" GetTownCount(): " + AITown.GetTownCount()); } function Regression::TownList() @@ -827,87 +802,85 @@ function Regression::Vehicle() { local accounting = AIAccounting(); - local company = AICompany(); - local vehicle = AIVehicle(); print(""); print("--Vehicle--"); - print(" IsValidVehicle(-1): " + vehicle.IsValidVehicle(-1)); - print(" IsValidVehicle(0): " + vehicle.IsValidVehicle(0)); - print(" IsValidVehicle(11): " + vehicle.IsValidVehicle(11)); - print(" ISValidVehicle(9999): " + vehicle.IsValidVehicle(9999)); + print(" IsValidVehicle(-1): " + AIVehicle.IsValidVehicle(-1)); + print(" IsValidVehicle(0): " + AIVehicle.IsValidVehicle(0)); + print(" IsValidVehicle(11): " + AIVehicle.IsValidVehicle(11)); + print(" ISValidVehicle(9999): " + AIVehicle.IsValidVehicle(9999)); - local bank = company.GetBankBalance(AICompany.MY_COMPANY); + local bank = AICompany.GetBankBalance(AICompany.MY_COMPANY); { local transaction = AITransactionMode(); - print(" BuildVehicle(): " + vehicle.BuildVehicle(33417, 153)); - print(" IsValidVehicle(11): " + vehicle.IsValidVehicle(11)); + print(" BuildVehicle(): " + AIVehicle.BuildVehicle(33417, 153)); + print(" IsValidVehicle(11): " + AIVehicle.IsValidVehicle(11)); print(" --Transaction--"); print(" GetCosts(): " + transaction.GetCosts()); print(" Execute(): " + transaction.Execute()); - print(" IsValidVehicle(11): " + vehicle.IsValidVehicle(11)); + print(" IsValidVehicle(11): " + AIVehicle.IsValidVehicle(11)); } - print(" CloneVehicle(): " + vehicle.CloneVehicle(33417, 11, true)); + print(" CloneVehicle(): " + AIVehicle.CloneVehicle(33417, 11, true)); - local bank_after = company.GetBankBalance(AICompany.MY_COMPANY); + local bank_after = AICompany.GetBankBalance(AICompany.MY_COMPANY); print(" --Accounting--"); print(" GetCosts(): " + accounting.GetCosts()); print(" Should be: " + (bank - bank_after)); print(" ResetCosts(): " + accounting.ResetCosts()); - bank = company.GetBankBalance(AICompany.MY_COMPANY); + bank = AICompany.GetBankBalance(AICompany.MY_COMPANY); - print(" SellVehicle(12): " + vehicle.SellVehicle(12)); - print(" IsInDepot(): " + vehicle.IsInDepot(11)); - print(" IsStoppedInDepot(): " + vehicle.IsStoppedInDepot(11)); - print(" StartStopVehicle(): " + vehicle.StartStopVehicle(11)); - print(" IsInDepot(): " + vehicle.IsInDepot(11)); - print(" IsStoppedInDepot(): " + vehicle.IsStoppedInDepot(11)); - print(" SendVehicleToDepot(): " + vehicle.SendVehicleToDepot(11)); - print(" IsInDepot(): " + vehicle.IsInDepot(11)); - print(" IsStoppedInDepot(): " + vehicle.IsStoppedInDepot(11)); + print(" SellVehicle(12): " + AIVehicle.SellVehicle(12)); + print(" IsInDepot(): " + AIVehicle.IsInDepot(11)); + print(" IsStoppedInDepot(): " + AIVehicle.IsStoppedInDepot(11)); + print(" StartStopVehicle(): " + AIVehicle.StartStopVehicle(11)); + print(" IsInDepot(): " + AIVehicle.IsInDepot(11)); + print(" IsStoppedInDepot(): " + AIVehicle.IsStoppedInDepot(11)); + print(" SendVehicleToDepot(): " + AIVehicle.SendVehicleToDepot(11)); + print(" IsInDepot(): " + AIVehicle.IsInDepot(11)); + print(" IsStoppedInDepot(): " + AIVehicle.IsStoppedInDepot(11)); - bank_after = company.GetBankBalance(AICompany.MY_COMPANY); + bank_after = AICompany.GetBankBalance(AICompany.MY_COMPANY); print(" --Accounting--"); print(" GetCosts(): " + accounting.GetCosts()); print(" Should be: " + (bank - bank_after)); - print(" GetName(): " + vehicle.GetName(11)); - print(" SetName(): " + vehicle.SetName(11, "MyVehicleName")); - print(" GetName(): " + vehicle.GetName(11)); - print(" CloneVehicle(): " + vehicle.CloneVehicle(33417, 11, true)); + print(" GetName(): " + AIVehicle.GetName(11)); + print(" SetName(): " + AIVehicle.SetName(11, "MyVehicleName")); + print(" GetName(): " + AIVehicle.GetName(11)); + print(" CloneVehicle(): " + AIVehicle.CloneVehicle(33417, 11, true)); print(" --VehicleData--"); - print(" GetLocation(): " + vehicle.GetLocation(11)); - print(" GetEngineType(): " + vehicle.GetEngineType(11)); - print(" GetUnitNumber(): " + vehicle.GetUnitNumber(11)); - print(" GetAge(): " + vehicle.GetAge(11)); - print(" GetMaxAge(): " + vehicle.GetMaxAge(11)); - print(" GetAgeLeft(): " + vehicle.GetAgeLeft(11)); - print(" GetRunningCost(): " + vehicle.GetRunningCost(11)); - print(" GetProfitThisYear(): " + vehicle.GetProfitThisYear(11)); - print(" GetProfitLastYear(): " + vehicle.GetProfitLastYear(11)); - print(" GetVehicleType(): " + vehicle.GetVehicleType(11)); - print(" IsInDepot(): " + vehicle.IsInDepot(11)); - print(" IsStoppedInDepot(): " + vehicle.IsStoppedInDepot(11)); + print(" GetLocation(): " + AIVehicle.GetLocation(11)); + print(" GetEngineType(): " + AIVehicle.GetEngineType(11)); + print(" GetUnitNumber(): " + AIVehicle.GetUnitNumber(11)); + print(" GetAge(): " + AIVehicle.GetAge(11)); + print(" GetMaxAge(): " + AIVehicle.GetMaxAge(11)); + print(" GetAgeLeft(): " + AIVehicle.GetAgeLeft(11)); + print(" GetRunningCost(): " + AIVehicle.GetRunningCost(11)); + print(" GetProfitThisYear(): " + AIVehicle.GetProfitThisYear(11)); + print(" GetProfitLastYear(): " + AIVehicle.GetProfitLastYear(11)); + print(" GetVehicleType(): " + AIVehicle.GetVehicleType(11)); + print(" IsInDepot(): " + AIVehicle.IsInDepot(11)); + print(" IsStoppedInDepot(): " + AIVehicle.IsStoppedInDepot(11)); - print(" BuildVehicle(): " + vehicle.BuildVehicle(32119, 219)); - print(" IsValidVehicle(13): " + vehicle.IsValidVehicle(13)); - print(" IsInDepot(13): " + vehicle.IsInDepot(13)); - print(" IsStoppedInDepot(13): " + vehicle.IsStoppedInDepot(13)); - print(" IsValidVehicle(14): " + vehicle.IsValidVehicle(14)); - print(" IsInDepot(14): " + vehicle.IsInDepot(14)); - print(" IsStoppedInDepot(14): " + vehicle.IsStoppedInDepot(14)); + print(" BuildVehicle(): " + AIVehicle.BuildVehicle(32119, 219)); + print(" IsValidVehicle(13): " + AIVehicle.IsValidVehicle(13)); + print(" IsInDepot(13): " + AIVehicle.IsInDepot(13)); + print(" IsStoppedInDepot(13): " + AIVehicle.IsStoppedInDepot(13)); + print(" IsValidVehicle(14): " + AIVehicle.IsValidVehicle(14)); + print(" IsInDepot(14): " + AIVehicle.IsInDepot(14)); + print(" IsStoppedInDepot(14): " + AIVehicle.IsStoppedInDepot(14)); - print(" BuildVehicle(): " + vehicle.BuildVehicle(28479, 204)); - print(" IsValidVehicle(15): " + vehicle.IsValidVehicle(15)); - print(" IsInDepot(15): " + vehicle.IsInDepot(15)); - print(" IsStoppedInDepot(15): " + vehicle.IsStoppedInDepot(15)); + print(" BuildVehicle(): " + AIVehicle.BuildVehicle(28479, 204)); + print(" IsValidVehicle(15): " + AIVehicle.IsValidVehicle(15)); + print(" IsInDepot(15): " + AIVehicle.IsInDepot(15)); + print(" IsStoppedInDepot(15): " + AIVehicle.IsStoppedInDepot(15)); local list = AIVehicleList(); diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_airport.cpp --- a/src/ai/api/ai_airport.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_airport.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -47,16 +47,16 @@ return _patches.modified_catchment ? ::GetAirport(type)->catchment : (uint)CA_UNMODIFIED; } -bool AIAirport::BuildAirport(TileIndex tile, AirportType type) +/* static */ bool AIAirport::BuildAirport(TileIndex tile, AirportType type) { /* Outside of the map */ if (tile >= ::MapSize()) return false; if (type > AT_HELISTATION) return 0; - return this->DoCommand(tile, type, 0, CMD_BUILD_AIRPORT); + return AIObject::DoCommand(tile, type, 0, CMD_BUILD_AIRPORT); } -bool AIAirport::RemoveAirport(TileIndex tile) +/* static */ bool AIAirport::RemoveAirport(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -64,10 +64,10 @@ /* Not a airport tile */ if (!IsAirportTile(tile) && !IsHangarTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); } -TileIndex AIAirport::GetHangarOfAirport(TileIndex tile) +/* static */ TileIndex AIAirport::GetHangarOfAirport(TileIndex tile) { if (!::IsTileType(tile, MP_STATION)) return INVALID_TILE; diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_airport.hpp --- a/src/ai/api/ai_airport.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_airport.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -83,7 +83,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the airport has been/can be build or not. */ - bool BuildAirport(TileIndex tile, AirportType type); + static bool BuildAirport(TileIndex tile, AirportType type); /** * Removes a airport. @@ -91,7 +91,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the airport has been/can be removed or not. */ - bool RemoveAirport(TileIndex tile); + static bool RemoveAirport(TileIndex tile); /** * Get the first hanger tile of the airport. @@ -99,7 +99,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return the first hanger tile of the airport. */ - TileIndex GetHangarOfAirport(TileIndex tile); + static TileIndex GetHangarOfAirport(TileIndex tile); }; #endif /* AI_AIRPORT_HPP */ diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_airport.hpp.sq --- a/src/ai/api/ai_airport.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_airport.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -35,10 +35,9 @@ SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportWidth, "GetAirportWidth", 2, "xi"); SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportHeight, "GetAirportHeight", 2, "xi"); SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetAirportCoverageRadius, "GetAirportCoverageRadius", 2, "xi"); - - SQAIAirport.DefSQMethod(engine, &AIAirport::BuildAirport, "BuildAirport", 3, "xii"); - SQAIAirport.DefSQMethod(engine, &AIAirport::RemoveAirport, "RemoveAirport", 2, "xi"); - SQAIAirport.DefSQMethod(engine, &AIAirport::GetHangarOfAirport, "GetHangarOfAirport", 2, "xi"); + SQAIAirport.DefSQStaticMethod(engine, &AIAirport::BuildAirport, "BuildAirport", 3, "xii"); + SQAIAirport.DefSQStaticMethod(engine, &AIAirport::RemoveAirport, "RemoveAirport", 2, "xi"); + SQAIAirport.DefSQStaticMethod(engine, &AIAirport::GetHangarOfAirport, "GetHangarOfAirport", 2, "xi"); SQAIAirport.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_base.cpp --- a/src/ai/api/ai_base.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_base.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -23,5 +23,5 @@ /* static */ bool AIBase::Chance(uint out, uint max) { - return (uint16)AIBase::Rand() <= (uint16)((65536 * out) / max); + return (uint16)Rand() <= (uint16)((65536 * out) / max); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_cargo.cpp --- a/src/ai/api/ai_cargo.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_cargo.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -13,7 +13,7 @@ return (cargo_type < NUM_CARGO && ::GetCargo(cargo_type)->IsValid()); } -char *AICargo::GetCargoLabel(CargoID cargo_type) +/* static */ char *AICargo::GetCargoLabel(CargoID cargo_type) { if (!IsValidCargo(cargo_type)) return NULL; const CargoSpec *cargo = ::GetCargo(cargo_type); @@ -28,14 +28,14 @@ return cargo_label; } -bool AICargo::IsFreight(CargoID cargo_type) +/* static */ bool AICargo::IsFreight(CargoID cargo_type) { if (!IsValidCargo(cargo_type)) return false; const CargoSpec *cargo = ::GetCargo(cargo_type); return cargo->is_freight; } -int32 AICargo::GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type) +/* static */ int32 AICargo::GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type) { if (!IsValidCargo(cargo_type)) return 0; return ::GetTransportedGoodsIncome(1, distance, days_in_transit, cargo_type); diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_cargo.hpp --- a/src/ai/api/ai_cargo.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_cargo.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -30,14 +30,14 @@ * @return the cargo label. * @note the returned cargo label must be free'd (C++ only). */ - char *GetCargoLabel(CargoID cargo_type); + static char *GetCargoLabel(CargoID cargo_type); /** * Checks whether the give cargo is a freight or not. * @param cargo_type is this cargo freight or not? * @return true if and only if the cargo is freight. */ - bool IsFreight(CargoID cargo_type); + static bool IsFreight(CargoID cargo_type); /** * Get the income for transporting a piece of cargo over the @@ -47,7 +47,7 @@ * @param cargo_type the cargo to transport. * @return the amount of money that would be earned by this trip. */ - int32 GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type); + static int32 GetCargoIncome(uint32 distance, uint32 days_in_transit, CargoID cargo_type); }; #endif /* AI_CARGO_HPP */ diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_cargo.hpp.sq --- a/src/ai/api/ai_cargo.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_cargo.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -14,12 +14,11 @@ SQAICargo.PreRegister(engine); SQAICargo.AddConstructor(engine, "x"); - SQAICargo.DefSQStaticMethod(engine, &AICargo::GetClassName, "GetClassName", 1, "x"); - SQAICargo.DefSQStaticMethod(engine, &AICargo::IsValidCargo, "IsValidCargo", 2, "xi"); - - SQAICargo.DefSQMethod(engine, &AICargo::GetCargoLabel, "GetCargoLabel", 2, "xi"); - SQAICargo.DefSQMethod(engine, &AICargo::IsFreight, "IsFreight", 2, "xi"); - SQAICargo.DefSQMethod(engine, &AICargo::GetCargoIncome, "GetCargoIncome", 4, "xiii"); + SQAICargo.DefSQStaticMethod(engine, &AICargo::GetClassName, "GetClassName", 1, "x"); + SQAICargo.DefSQStaticMethod(engine, &AICargo::IsValidCargo, "IsValidCargo", 2, "xi"); + SQAICargo.DefSQStaticMethod(engine, &AICargo::GetCargoLabel, "GetCargoLabel", 2, "xi"); + SQAICargo.DefSQStaticMethod(engine, &AICargo::IsFreight, "IsFreight", 2, "xi"); + SQAICargo.DefSQStaticMethod(engine, &AICargo::GetCargoIncome, "GetCargoIncome", 4, "xiii"); SQAICargo.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_company.cpp --- a/src/ai/api/ai_company.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_company.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -12,24 +12,24 @@ #include "../../core/alloc_func.hpp" #include "table/strings.h" -AICompany::CompanyIndex AICompany::ResolveCompanyIndex(AICompany::CompanyIndex company) +/* static */ AICompany::CompanyIndex AICompany::ResolveCompanyIndex(AICompany::CompanyIndex company) { if (company == MY_COMPANY) return (CompanyIndex)((byte)_current_player); return (::IsValidPlayer((PlayerID)company) && ::GetPlayer((PlayerID)company)->is_active) ? company : INVALID_COMPANY; } -bool AICompany::SetCompanyName(const char *name) +/* static */ bool AICompany::SetCompanyName(const char *name) { if (name == NULL) return false; _cmd_text = name; - return this->DoCommand(0, 0, 0, CMD_CHANGE_COMPANY_NAME); + return AIObject::DoCommand(0, 0, 0, CMD_CHANGE_COMPANY_NAME); } -char *AICompany::GetCompanyName(AICompany::CompanyIndex company) +/* static */ char *AICompany::GetCompanyName(AICompany::CompanyIndex company) { - company = this->ResolveCompanyIndex(company); + company = ResolveCompanyIndex(company); if (company == INVALID_COMPANY) return NULL; static const int len = 64; @@ -40,17 +40,17 @@ return company_name; } -bool AICompany::SetPresidentName(const char *name) +/* static */ bool AICompany::SetPresidentName(const char *name) { if (name == NULL) return false; _cmd_text = name; - return this->DoCommand(0, 0, 0, CMD_CHANGE_PRESIDENT_NAME); + return AIObject::DoCommand(0, 0, 0, CMD_CHANGE_PRESIDENT_NAME); } -char *AICompany::GetPresidentName(AICompany::CompanyIndex company) +/* static */ char *AICompany::GetPresidentName(AICompany::CompanyIndex company) { - company = this->ResolveCompanyIndex(company); + company = ResolveCompanyIndex(company); static const int len = 64; char *president_name = MallocT(len); @@ -64,63 +64,63 @@ return president_name; } -int32 AICompany::GetCompanyValue(AICompany::CompanyIndex company) +/* static */ int32 AICompany::GetCompanyValue(AICompany::CompanyIndex company) { - company = this->ResolveCompanyIndex(company); + company = ResolveCompanyIndex(company); if (company == INVALID_COMPANY) return 0; return ::GetPlayer((PlayerID)company)->cur_economy.company_value; } -int32 AICompany::GetBankBalance(AICompany::CompanyIndex company) +/* static */ int32 AICompany::GetBankBalance(AICompany::CompanyIndex company) { - company = this->ResolveCompanyIndex(company); + company = ResolveCompanyIndex(company); if (company == INVALID_COMPANY) return 0; return ::ClampToI32(GetPlayer((PlayerID)company)->player_money); } -int32 AICompany::GetLoanAmount() +/* static */ int32 AICompany::GetLoanAmount() { return ::GetPlayer(_current_player)->current_loan; } -int32 AICompany::GetMaxLoanAmount() +/* static */ int32 AICompany::GetMaxLoanAmount() { return _economy.max_loan; } -int32 AICompany::GetLoanInterval() +/* static */ int32 AICompany::GetLoanInterval() { return LOAN_INTERVAL; } -bool AICompany::SetLoanAmount(int32 loan) +/* static */ bool AICompany::SetLoanAmount(int32 loan) { if (loan < 0 || - (loan % this->GetLoanInterval()) != 0 || - loan > this->GetMaxLoanAmount() || - (loan - this->GetLoanAmount() + this->GetBankBalance(MY_COMPANY)) < 0) { + (loan % GetLoanInterval()) != 0 || + loan > GetMaxLoanAmount() || + (loan - GetLoanAmount() + GetBankBalance(MY_COMPANY)) < 0) { return false; } - if (loan == this->GetLoanAmount()) return true; + if (loan == GetLoanAmount()) return true; - return this->DoCommand(0, - abs(loan - this->GetLoanAmount()), 2, - (loan > this->GetLoanAmount()) ? CMD_INCREASE_LOAN : CMD_DECREASE_LOAN); + return AIObject::DoCommand(0, + abs(loan - GetLoanAmount()), 2, + (loan > GetLoanAmount()) ? CMD_INCREASE_LOAN : CMD_DECREASE_LOAN); } -bool AICompany::SetMinimumLoanAmount(int32 loan) +/* static */ bool AICompany::SetMinimumLoanAmount(int32 loan) { if (loan < 0) return false; - int32 over_interval = loan % this->GetLoanInterval(); - if (over_interval != 0) loan += this->GetLoanInterval() - over_interval; + int32 over_interval = loan % GetLoanInterval(); + if (over_interval != 0) loan += GetLoanInterval() - over_interval; - if (loan > this->GetMaxLoanAmount()) return false; + if (loan > GetMaxLoanAmount()) return false; - this->SetLoanAmount(loan); + SetLoanAmount(loan); - return this->GetLoanAmount() == loan; + return GetLoanAmount() == loan; } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_company.hpp --- a/src/ai/api/ai_company.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_company.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -34,7 +34,7 @@ * @param company the company index to resolve. * @return the resolved company index. */ - CompanyIndex ResolveCompanyIndex(CompanyIndex company); + static CompanyIndex ResolveCompanyIndex(CompanyIndex company); /** * Set the name of your company. @@ -42,7 +42,7 @@ * @pre name != NULL * @return true if the name was changed. */ - bool SetCompanyName(const char *name); + static bool SetCompanyName(const char *name); /** * Get the name of the given company. @@ -51,7 +51,7 @@ * @return the name of the given company. * @note the returned company name must be free'd (C++ only). */ - char *GetCompanyName(CompanyIndex company); + static char *GetCompanyName(CompanyIndex company); /** * Set the name of your president. @@ -59,7 +59,7 @@ * @pre name != NULL * @return true if the name was changed. */ - bool SetPresidentName(const char *name); + static bool SetPresidentName(const char *name); /** * Get the name of the president of the given company. @@ -68,7 +68,7 @@ * @return the name of the president of the given company. * @note the returned president name must be free'd (C++ only). */ - char *GetPresidentName(CompanyIndex company); + static char *GetPresidentName(CompanyIndex company); /** * Gets the current value of the given company. @@ -76,7 +76,7 @@ * @pre ResolveCompanyIndex(company) != INVALID_COMPANY * @return the current value of the given company. */ - int32 GetCompanyValue(CompanyIndex company); + static int32 GetCompanyValue(CompanyIndex company); /** * Gets the bank balance. In other words, the amount of money the given company can spent. @@ -84,7 +84,7 @@ * @pre ResolveCompanyIndex(company) != INVALID_COMPANY * @return the actual bank balance. */ - int32 GetBankBalance(CompanyIndex company); + static int32 GetBankBalance(CompanyIndex company); /** * Gets the amount your company have loaned. @@ -92,7 +92,7 @@ * @post the return value is always non-negative. * @post GetLoanInterval() is always a multiplier of the return value. */ - int32 GetLoanAmount(); + static int32 GetLoanAmount(); /** * Gets the maximum amount your company can loan. @@ -100,14 +100,14 @@ * @post the return value is always non-negative. * @post GetLoanInterval() is always a multiplier of the return value. */ - int32 GetMaxLoanAmount(); + static int32 GetMaxLoanAmount(); /** * Gets the interval/loan step. * @return the loan step. * @post return value is always positive. */ - int32 GetLoanInterval(); + static int32 GetLoanInterval(); /** * Sets the amount to loan. @@ -118,7 +118,7 @@ * @pre loan - GetLoanAmount() + GetBankBalance() must be non-negative. * @return true if the loan could be set to your requested amount. */ - bool SetLoanAmount(int32 loan); + static bool SetLoanAmount(int32 loan); /** * Sets the minimum amount to loan, i.e. the given amount of loan rounded up. @@ -127,7 +127,7 @@ * @pre loan must be below GetMaxLoan(). * @return true if we could allocate a minimum of "loan" loan. */ - bool SetMinimumLoanAmount(int32 loan); + static bool SetMinimumLoanAmount(int32 loan); }; DECLARE_POSTFIX_INCREMENT(AICompany::CompanyIndex); diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_company.hpp.sq --- a/src/ai/api/ai_company.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_company.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -23,20 +23,19 @@ SQAICompany.DefSQConst(engine, AICompany::MY_COMPANY, "MY_COMPANY"); SQAICompany.DefSQConst(engine, AICompany::INVALID_COMPANY, "INVALID_COMPANY"); - SQAICompany.DefSQStaticMethod(engine, &AICompany::GetClassName, "GetClassName", 1, "x"); - - SQAICompany.DefSQMethod(engine, &AICompany::ResolveCompanyIndex, "ResolveCompanyIndex", 2, "xi"); - SQAICompany.DefSQMethod(engine, &AICompany::SetCompanyName, "SetCompanyName", 2, "xs"); - SQAICompany.DefSQMethod(engine, &AICompany::GetCompanyName, "GetCompanyName", 2, "xi"); - SQAICompany.DefSQMethod(engine, &AICompany::SetPresidentName, "SetPresidentName", 2, "xs"); - SQAICompany.DefSQMethod(engine, &AICompany::GetPresidentName, "GetPresidentName", 2, "xi"); - SQAICompany.DefSQMethod(engine, &AICompany::GetCompanyValue, "GetCompanyValue", 2, "xi"); - SQAICompany.DefSQMethod(engine, &AICompany::GetBankBalance, "GetBankBalance", 2, "xi"); - SQAICompany.DefSQMethod(engine, &AICompany::GetLoanAmount, "GetLoanAmount", 1, "x"); - SQAICompany.DefSQMethod(engine, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount", 1, "x"); - SQAICompany.DefSQMethod(engine, &AICompany::GetLoanInterval, "GetLoanInterval", 1, "x"); - SQAICompany.DefSQMethod(engine, &AICompany::SetLoanAmount, "SetLoanAmount", 2, "xi"); - SQAICompany.DefSQMethod(engine, &AICompany::SetMinimumLoanAmount, "SetMinimumLoanAmount", 2, "xi"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::GetClassName, "GetClassName", 1, "x"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::ResolveCompanyIndex, "ResolveCompanyIndex", 2, "xi"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::SetCompanyName, "SetCompanyName", 2, "xs"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::GetCompanyName, "GetCompanyName", 2, "xi"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::SetPresidentName, "SetPresidentName", 2, "xs"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::GetPresidentName, "GetPresidentName", 2, "xi"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::GetCompanyValue, "GetCompanyValue", 2, "xi"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::GetBankBalance, "GetBankBalance", 2, "xi"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::GetLoanAmount, "GetLoanAmount", 1, "x"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount", 1, "x"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::GetLoanInterval, "GetLoanInterval", 1, "x"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::SetLoanAmount, "SetLoanAmount", 2, "xi"); + SQAICompany.DefSQStaticMethod(engine, &AICompany::SetMinimumLoanAmount, "SetMinimumLoanAmount", 2, "xi"); SQAICompany.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_industry.cpp --- a/src/ai/api/ai_industry.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_industry.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -8,12 +8,12 @@ #include "../../strings_func.h" #include "table/strings.h" -IndustryID AIIndustry::GetMaxIndustryID() +/* static */ IndustryID AIIndustry::GetMaxIndustryID() { return ::GetMaxIndustryIndex(); } -int32 AIIndustry::GetIndustryCount() +/* static */ int32 AIIndustry::GetIndustryCount() { return ::GetNumIndustries(); } @@ -23,7 +23,7 @@ return ::IsValidIndustryID(industry_id); } -char *AIIndustry::GetName(IndustryID industry_id) +/* static */ char *AIIndustry::GetName(IndustryID industry_id) { if (!IsValidIndustry(industry_id)) return NULL; static const int len = 64; diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_industry.hpp --- a/src/ai/api/ai_industry.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_industry.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -24,7 +24,7 @@ * @return the maximum industry index. * @post return value is always non-negative. */ - IndustryID GetMaxIndustryID(); + static IndustryID GetMaxIndustryID(); /** * Gets the number of industries. This is different than GetMaxIndustryID() @@ -32,7 +32,7 @@ * @return the number of industries. * @post return value is always non-negative. */ - int32 GetIndustryCount(); + static int32 GetIndustryCount(); /** * Checks whether the given industry index is valid. @@ -48,7 +48,7 @@ * @return the name of the industry. * @note the returned name must be free'd (C++ only). */ - char *GetName(IndustryID industry_id); + static char *GetName(IndustryID industry_id); /** * Gets the production of a cargo of the industry. diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_industry.hpp.sq --- a/src/ai/api/ai_industry.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_industry.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -14,15 +14,14 @@ SQAIIndustry.PreRegister(engine); SQAIIndustry.AddConstructor(engine, "x"); - SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetClassName, "GetClassName", 1, "x"); - SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::IsValidIndustry, "IsValidIndustry", 2, "xi"); - SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetProduction, "GetProduction", 3, "xii"); - SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::IsCargoAccepted, "IsCargoAccepted", 3, "xii"); - SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetLocation, "GetLocation", 2, "xi"); - - SQAIIndustry.DefSQMethod(engine, &AIIndustry::GetMaxIndustryID, "GetMaxIndustryID", 1, "x"); - SQAIIndustry.DefSQMethod(engine, &AIIndustry::GetIndustryCount, "GetIndustryCount", 1, "x"); - SQAIIndustry.DefSQMethod(engine, &AIIndustry::GetName, "GetName", 2, "xi"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetClassName, "GetClassName", 1, "x"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetMaxIndustryID, "GetMaxIndustryID", 1, "x"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetIndustryCount, "GetIndustryCount", 1, "x"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::IsValidIndustry, "IsValidIndustry", 2, "xi"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetName, "GetName", 2, "xi"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetProduction, "GetProduction", 3, "xii"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::IsCargoAccepted, "IsCargoAccepted", 3, "xii"); + SQAIIndustry.DefSQStaticMethod(engine, &AIIndustry::GetLocation, "GetLocation", 2, "xi"); SQAIIndustry.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_map.cpp --- a/src/ai/api/ai_map.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_map.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -61,7 +61,7 @@ return ::DistanceFromEdge(t); } -bool AIMap::DemolishTile(TileIndex t) +/* static */ bool AIMap::DemolishTile(TileIndex t) { - return this->DoCommand(t, 0, 0, CMD_LANDSCAPE_CLEAR); + return AIObject::DoCommand(t, 0, 0, CMD_LANDSCAPE_CLEAR); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_map.hpp --- a/src/ai/api/ai_map.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_map.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -122,7 +122,7 @@ * @pre t has to be valid (use IsValidTile(t)). * @return true if and only if the destruction succeeded */ - bool DemolishTile(TileIndex t); + static bool DemolishTile(TileIndex t); }; #endif /* AI_MAP_HPP */ diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_map.hpp.sq --- a/src/ai/api/ai_map.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_map.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -26,8 +26,7 @@ SQAIMap.DefSQStaticMethod(engine, &AIMap::DistanceMax, "DistanceMax", 3, "xii"); SQAIMap.DefSQStaticMethod(engine, &AIMap::DistanceSquare, "DistanceSquare", 3, "xii"); SQAIMap.DefSQStaticMethod(engine, &AIMap::DistanceFromEdge, "DistanceFromEdge", 2, "xi"); - - SQAIMap.DefSQMethod(engine, &AIMap::DemolishTile, "DemolishTile", 2, "xi"); + SQAIMap.DefSQStaticMethod(engine, &AIMap::DemolishTile, "DemolishTile", 2, "xi"); SQAIMap.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_marine.cpp --- a/src/ai/api/ai_marine.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_marine.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -47,47 +47,47 @@ return ::IsTileType(tile, MP_WATER) && ::IsCanal(tile); } -bool AIMarine::BuildWaterDepot(TileIndex tile, bool vertical) -{ - /* Outside of the map */ - if (tile >= ::MapSize()) return false; - - return this->DoCommand(tile, vertical, 0, CMD_BUILD_SHIP_DEPOT, false); -} - -bool AIMarine::BuildDock(TileIndex tile) +/* static */ bool AIMarine::BuildWaterDepot(TileIndex tile, bool vertical) { /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, 1, 0, CMD_BUILD_DOCK, false); + return AIObject::DoCommand(tile, vertical, 0, CMD_BUILD_SHIP_DEPOT, false); } -bool AIMarine::BuildBuoy(TileIndex tile) +/* static */ bool AIMarine::BuildDock(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, 0, 0, CMD_BUILD_BUOY, false); + return AIObject::DoCommand(tile, 1, 0, CMD_BUILD_DOCK, false); } -bool AIMarine::BuildLock(TileIndex tile) +/* static */ bool AIMarine::BuildBuoy(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, 0, 0, CMD_BUILD_LOCK, false); + return AIObject::DoCommand(tile, 0, 0, CMD_BUILD_BUOY, false); } -bool AIMarine::BuildCanal(TileIndex tile) +/* static */ bool AIMarine::BuildLock(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, tile, 0, CMD_BUILD_CANAL, false); + return AIObject::DoCommand(tile, 0, 0, CMD_BUILD_LOCK, false); } -bool AIMarine::RemoveWaterDepot(TileIndex tile) +/* static */ bool AIMarine::BuildCanal(TileIndex tile) +{ + /* Outside of the map */ + if (tile >= ::MapSize()) return false; + + return AIObject::DoCommand(tile, tile, 0, CMD_BUILD_CANAL, false); +} + +/* static */ bool AIMarine::RemoveWaterDepot(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -95,10 +95,10 @@ /* Not a water depot tile */ if (!IsWaterDepotTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); + return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } -bool AIMarine::RemoveDock(TileIndex tile) +/* static */ bool AIMarine::RemoveDock(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -106,10 +106,10 @@ /* Not a dock tile */ if (!IsDockTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); + return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } -bool AIMarine::RemoveBuoy(TileIndex tile) +/* static */ bool AIMarine::RemoveBuoy(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -117,10 +117,10 @@ /* Not a buoy tile */ if (!IsBuoyTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); + return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } -bool AIMarine::RemoveLock(TileIndex tile) +/* static */ bool AIMarine::RemoveLock(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -128,10 +128,10 @@ /* Not a lock tile */ if (!IsLockTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); + return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } -bool AIMarine::RemoveCanal(TileIndex tile) +/* static */ bool AIMarine::RemoveCanal(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -139,5 +139,5 @@ /* Not a canal tile */ if (!IsCanalTile(tile)) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); + return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR, false); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_marine.hpp --- a/src/ai/api/ai_marine.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_marine.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -64,7 +64,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the water depot has been/can be build or not. */ - bool BuildWaterDepot(TileIndex tile, bool vertical); + static bool BuildWaterDepot(TileIndex tile, bool vertical); /** * Builds a dock where tile is the tile still on land. @@ -72,7 +72,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the dock has been/can be build or not. */ - bool BuildDock(TileIndex tile); + static bool BuildDock(TileIndex tile); /** * Builds a buoy on tile. @@ -80,7 +80,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the buoy has been/can be build or not. */ - bool BuildBuoy(TileIndex tile); + static bool BuildBuoy(TileIndex tile); /** * Builds a lock on tile. @@ -88,7 +88,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the lock has been/can be build or not. */ - bool BuildLock(TileIndex tile); + static bool BuildLock(TileIndex tile); /** * Builds a canal on tile. @@ -96,7 +96,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the canal has been/can be build or not. */ - bool BuildCanal(TileIndex tile); + static bool BuildCanal(TileIndex tile); /** * Removes a water depot. @@ -104,7 +104,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the water depot has been/can be removed or not. */ - bool RemoveWaterDepot(TileIndex tile); + static bool RemoveWaterDepot(TileIndex tile); /** * Removes a dock. @@ -112,7 +112,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the dock has been/can be removed or not. */ - bool RemoveDock(TileIndex tile); + static bool RemoveDock(TileIndex tile); /** * Removes a buoy. @@ -120,7 +120,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the buoy has been/can be removed or not. */ - bool RemoveBuoy(TileIndex tile); + static bool RemoveBuoy(TileIndex tile); /** * Removes a lock. @@ -128,7 +128,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the lock has been/can be removed or not. */ - bool RemoveLock(TileIndex tile); + static bool RemoveLock(TileIndex tile); /** * Removes a canal. @@ -136,7 +136,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return whether the canal has been/can be removed or not. */ - bool RemoveCanal(TileIndex tile); + static bool RemoveCanal(TileIndex tile); }; #endif /* AI_MARINE_HPP */ diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_marine.hpp.sq --- a/src/ai/api/ai_marine.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_marine.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -20,17 +20,16 @@ SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsBuoyTile, "IsBuoyTile", 2, "xi"); SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsLockTile, "IsLockTile", 2, "xi"); SQAIMarine.DefSQStaticMethod(engine, &AIMarine::IsCanalTile, "IsCanalTile", 2, "xi"); - - SQAIMarine.DefSQMethod(engine, &AIMarine::BuildWaterDepot, "BuildWaterDepot", 3, "xib"); - SQAIMarine.DefSQMethod(engine, &AIMarine::BuildDock, "BuildDock", 2, "xi"); - SQAIMarine.DefSQMethod(engine, &AIMarine::BuildBuoy, "BuildBuoy", 2, "xi"); - SQAIMarine.DefSQMethod(engine, &AIMarine::BuildLock, "BuildLock", 2, "xi"); - SQAIMarine.DefSQMethod(engine, &AIMarine::BuildCanal, "BuildCanal", 2, "xi"); - SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveWaterDepot, "RemoveWaterDepot", 2, "xi"); - SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveDock, "RemoveDock", 2, "xi"); - SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveBuoy, "RemoveBuoy", 2, "xi"); - SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveLock, "RemoveLock", 2, "xi"); - SQAIMarine.DefSQMethod(engine, &AIMarine::RemoveCanal, "RemoveCanal", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildWaterDepot, "BuildWaterDepot", 3, "xib"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildDock, "BuildDock", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildBuoy, "BuildBuoy", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildLock, "BuildLock", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::BuildCanal, "BuildCanal", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveWaterDepot, "RemoveWaterDepot", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveDock, "RemoveDock", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveBuoy, "RemoveBuoy", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveLock, "RemoveLock", 2, "xi"); + SQAIMarine.DefSQStaticMethod(engine, &AIMarine::RemoveCanal, "RemoveCanal", 2, "xi"); SQAIMarine.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_order.cpp --- a/src/ai/api/ai_order.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_order.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -57,12 +57,12 @@ } } -int32 AIOrder::GetNumberOfOrders(VehicleID vehicle_id) +/* static */ int32 AIOrder::GetNumberOfOrders(VehicleID vehicle_id) { return AIVehicle::IsValidVehicle(vehicle_id) ? ::GetVehicle(vehicle_id)->num_orders : -1; } -TileIndex AIOrder::GetOrderDestination(VehicleID vehicle_id, uint32 order_id) +/* static */ TileIndex AIOrder::GetOrderDestination(VehicleID vehicle_id, uint32 order_id) { if (!IsValidVehicleOrder(vehicle_id, order_id)) return INVALID_TILE; @@ -77,7 +77,7 @@ } } -AIOrder::AIOrderFlags AIOrder::GetOrderFlags(VehicleID vehicle_id, uint32 order_id) +/* static */ AIOrder::AIOrderFlags AIOrder::GetOrderFlags(VehicleID vehicle_id, uint32 order_id) { if (!IsValidVehicleOrder(vehicle_id, order_id)) return AIOF_INVALID; @@ -87,13 +87,13 @@ return (AIOrder::AIOrderFlags)order->flags; } -bool AIOrder::AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags) +/* static */ bool AIOrder::AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags) { if (!AIVehicle::IsValidVehicle(vehicle_id)) return false; - return this->InsertOrder(vehicle_id, ::GetVehicle(vehicle_id)->num_orders, destination, order_flags); + return InsertOrder(vehicle_id, ::GetVehicle(vehicle_id)->num_orders, destination, order_flags); } -bool AIOrder::InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrder::AIOrderFlags order_flags) +/* static */ bool AIOrder::InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrder::AIOrderFlags order_flags) { /* IsValidVehicleOrder is not good enough because it does not allow appending. */ if (!AIVehicle::IsValidVehicle(vehicle_id) || order_id > ::GetVehicle(vehicle_id)->num_orders || @@ -109,17 +109,17 @@ default: NOT_REACHED(); return false; } - return this->DoCommand(0, vehicle_id | (order_id << 16), PackOrder(&order), CMD_INSERT_ORDER); + return AIObject::DoCommand(0, vehicle_id | (order_id << 16), PackOrder(&order), CMD_INSERT_ORDER); } -bool AIOrder::RemoveOrder(VehicleID vehicle_id, uint32 order_id) +/* static */ bool AIOrder::RemoveOrder(VehicleID vehicle_id, uint32 order_id) { if (!IsValidVehicleOrder(vehicle_id, order_id)) return false; - return this->DoCommand(0, vehicle_id, order_id, CMD_DELETE_ORDER); + return AIObject::DoCommand(0, vehicle_id, order_id, CMD_DELETE_ORDER); } -bool AIOrder::ChangeOrder(VehicleID vehicle_id, uint32 order_id, AIOrder::AIOrderFlags order_flags) +/* static */ bool AIOrder::ChangeOrder(VehicleID vehicle_id, uint32 order_id, AIOrder::AIOrderFlags order_flags) { if (!IsValidVehicleOrder(vehicle_id, order_id) || !AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_id), order_flags)) return false; @@ -127,40 +127,40 @@ for (;;) { /* Loop as long as there is a difference between the requested and * the current orders of the vehicle. */ - AIOrderFlags current = this->GetOrderFlags(vehicle_id, order_id); + AIOrderFlags current = GetOrderFlags(vehicle_id, order_id); AIOrderFlags diff = current ^ order_flags; if (diff == 0) return true; - bool res = this->DoCommand(0, vehicle_id | (order_id << 16), FIND_FIRST_BIT(diff), CMD_MODIFY_ORDER); + bool res = AIObject::DoCommand(0, vehicle_id | (order_id << 16), FIND_FIRST_BIT(diff), CMD_MODIFY_ORDER); if (!res) return false; } } -bool AIOrder::MoveOrder(VehicleID vehicle_id, uint32 order_id_move, uint32 order_id_target) +/* static */ bool AIOrder::MoveOrder(VehicleID vehicle_id, uint32 order_id_move, uint32 order_id_target) { if (!IsValidVehicleOrder(vehicle_id, order_id_move) || !IsValidVehicleOrder(vehicle_id, order_id_target)) return false; - return this->DoCommand(0, vehicle_id, order_id_move | (order_id_target << 16), CMD_MOVE_ORDER); + return AIObject::DoCommand(0, vehicle_id, order_id_move | (order_id_target << 16), CMD_MOVE_ORDER); } -bool AIOrder::CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id) +/* static */ bool AIOrder::CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id) { if (!AIVehicle::IsValidVehicle(vehicle_id) || !AIVehicle::IsValidVehicle(main_vehicle_id)) return false; - return this->DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_COPY, CMD_CLONE_ORDER); + return AIObject::DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_COPY, CMD_CLONE_ORDER); } -bool AIOrder::ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id) +/* static */ bool AIOrder::ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id) { if (!AIVehicle::IsValidVehicle(vehicle_id) || !AIVehicle::IsValidVehicle(main_vehicle_id)) return false; - return this->DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_SHARE, CMD_CLONE_ORDER); + return AIObject::DoCommand(0, vehicle_id | (main_vehicle_id << 16), CO_SHARE, CMD_CLONE_ORDER); } -bool AIOrder::UnshareOrders(VehicleID vehicle_id) +/* static */ bool AIOrder::UnshareOrders(VehicleID vehicle_id) { if (!AIVehicle::IsValidVehicle(vehicle_id)) return false; - return this->DoCommand(0, vehicle_id, CO_UNSHARE, CMD_CLONE_ORDER); + return AIObject::DoCommand(0, vehicle_id, CO_UNSHARE, CMD_CLONE_ORDER); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_order.hpp --- a/src/ai/api/ai_order.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_order.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -65,7 +65,7 @@ * @return the number of orders for the given vehicle or a negative * value when the vehicle does not exist. */ - int32 GetNumberOfOrders(VehicleID vehicle_id); + static int32 GetNumberOfOrders(VehicleID vehicle_id); /** * Gets the destination of the given order for the given vehicle. @@ -74,7 +74,7 @@ * @pre IsValidVehicleOrder(vehicle_id, order_id). * @return the destination tile of the order. */ - TileIndex GetOrderDestination(VehicleID vehicle_id, uint32 order_id); + static TileIndex GetOrderDestination(VehicleID vehicle_id, uint32 order_id); /** * Gets the AIOrderFlags of the given order for the given vehicle. @@ -83,7 +83,7 @@ * @pre IsValidVehicleOrder(vehicle_id, order_id). * @return the AIOrderFlags of the order. */ - AIOrderFlags GetOrderFlags(VehicleID vehicle_id, uint32 order_id); + static AIOrderFlags GetOrderFlags(VehicleID vehicle_id, uint32 order_id); /** * Appends an order to the end of the vehicle's order list. @@ -94,7 +94,7 @@ * @pre AreOrderFlagsValid(destination, order_flags). * @return true if and only if the order was appended. */ - bool AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags); + static bool AppendOrder(VehicleID vehicle_id, TileIndex destination, AIOrderFlags order_flags); /** * Inserts an order before the given order_id into the vehicle's order list. @@ -106,7 +106,7 @@ * @pre AreOrderFlagsValid(destination, order_flags). * @return true if and only if the order was inserted. */ - bool InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrderFlags order_flags); + static bool InsertOrder(VehicleID vehicle_id, uint32 order_id, TileIndex destination, AIOrderFlags order_flags); /** * Removes an order from the vehicle's order list. @@ -115,7 +115,7 @@ * @pre AIVehicle::IsValidVehicleOrder(vehicle_id, order_id). * @return true if and only if the order was removed. */ - bool RemoveOrder(VehicleID vehicle_id, uint32 order_id); + static bool RemoveOrder(VehicleID vehicle_id, uint32 order_id); /** * Changes the order flags of the given order. @@ -126,7 +126,7 @@ * @pre AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_id), order_flags). * @return true if and only if the order was changed. */ - bool ChangeOrder(VehicleID vehicle_id, uint32 order_id, AIOrderFlags order_flags); + static bool ChangeOrder(VehicleID vehicle_id, uint32 order_id, AIOrderFlags order_flags); /** * Move an order inside the orderlist @@ -141,7 +141,7 @@ * to a higher place (e.g. from 7 to 9) the target will be moved * downwards (e.g. 8). */ - bool MoveOrder(VehicleID vehicle_id, uint32 order_id_move, uint32 order_id_target); + static bool MoveOrder(VehicleID vehicle_id, uint32 order_id_move, uint32 order_id_target); /** * Copies the orders from another vehicle. The orders of the main @@ -152,7 +152,7 @@ * @pre AIVehicle::IsValidVehicle(main_vehicle_id). * @return true if and only if the copying succeeded. */ - bool CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); + static bool CopyOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); /** * Shares the orders between two vehicles. The orders of the main @@ -163,7 +163,7 @@ * @pre AIVehicle::IsValidVehicle(main_vehicle_id). * @return true if and only if the sharing succeeded. */ - bool ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); + static bool ShareOrders(VehicleID vehicle_id, VehicleID main_vehicle_id); /** * Removes the given vehicle from a shared orders list. @@ -171,7 +171,7 @@ * @pre AIVehicle::IsValidVehicle(vehicle_id). * @return true if and only if the unsharing succeeded. */ - bool UnshareOrders(VehicleID vehicle_id); + static bool UnshareOrders(VehicleID vehicle_id); }; DECLARE_ENUM_AS_BIT_SET(AIOrder::AIOrderFlags); diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_order.hpp.sq --- a/src/ai/api/ai_order.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_order.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -29,18 +29,17 @@ SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetClassName, "GetClassName", 1, "x"); SQAIOrder.DefSQStaticMethod(engine, &AIOrder::IsValidVehicleOrder, "IsValidVehicleOrder", 3, "xii"); SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AreOrderFlagsValid, "AreOrderFlagsValid", 3, "xii"); - - SQAIOrder.DefSQMethod(engine, &AIOrder::GetNumberOfOrders, "GetNumberOfOrders", 2, "xi"); - SQAIOrder.DefSQMethod(engine, &AIOrder::GetOrderDestination, "GetOrderDestination", 3, "xii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::GetOrderFlags, "GetOrderFlags", 3, "xii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::AppendOrder, "AppendOrder", 4, "xiii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::InsertOrder, "InsertOrder", 5, "xiiii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder", 3, "xii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, "xiii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::MoveOrder, "MoveOrder", 4, "xiii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, "xii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::ShareOrders, "ShareOrders", 3, "xii"); - SQAIOrder.DefSQMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders", 2, "xi"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetNumberOfOrders, "GetNumberOfOrders", 2, "xi"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderDestination, "GetOrderDestination", 3, "xii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::GetOrderFlags, "GetOrderFlags", 3, "xii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::AppendOrder, "AppendOrder", 4, "xiii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::InsertOrder, "InsertOrder", 5, "xiiii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::RemoveOrder, "RemoveOrder", 3, "xii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ChangeOrder, "ChangeOrder", 4, "xiii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::MoveOrder, "MoveOrder", 4, "xiii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::CopyOrders, "CopyOrders", 3, "xii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::ShareOrders, "ShareOrders", 3, "xii"); + SQAIOrder.DefSQStaticMethod(engine, &AIOrder::UnshareOrders, "UnshareOrders", 2, "xi"); SQAIOrder.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_road.cpp --- a/src/ai/api/ai_road.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_road.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -6,16 +6,16 @@ #include "../../road_map.h" #include "../../station_map.h" -bool AIRoad::IsRoadTile(TileIndex tile) +/* static */ bool AIRoad::IsRoadTile(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; return (::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) != ROAD_TILE_DEPOT) || - this->IsDriveThroughRoadStationTile(tile); + IsDriveThroughRoadStationTile(tile); } -bool AIRoad::IsRoadDepotTile(TileIndex tile) +/* static */ bool AIRoad::IsRoadDepotTile(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -23,7 +23,7 @@ return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) == ROAD_TILE_DEPOT; } -bool AIRoad::IsRoadStationTile(TileIndex tile) +/* static */ bool AIRoad::IsRoadStationTile(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -31,7 +31,7 @@ return ::IsRoadStopTile(tile); } -bool AIRoad::IsDriveThroughRoadStationTile(TileIndex tile) +/* static */ bool AIRoad::IsDriveThroughRoadStationTile(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -39,7 +39,7 @@ return ::IsDriveThroughStopTile(tile); } -bool AIRoad::AreRoadTilesConnected(TileIndex t1, TileIndex t2) +/* static */ bool AIRoad::AreRoadTilesConnected(TileIndex t1, TileIndex t2) { /* Outside of the map */ if (t1 >= ::MapSize() || t2 >= ::MapSize()) return false; @@ -56,7 +56,7 @@ return HasBit(r1, dir_1) && HasBit(r2, dir_2); } -int32 AIRoad::GetNeighbourRoadCount(TileIndex tile) +/* static */ int32 AIRoad::GetNeighbourRoadCount(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -71,28 +71,28 @@ return neighbour; } -TileIndex AIRoad::GetRoadDepotFrontTile(TileIndex depot) +/* static */ TileIndex AIRoad::GetRoadDepotFrontTile(TileIndex depot) { - if (!this->IsRoadDepotTile(depot)) return INVALID_TILE; + if (!IsRoadDepotTile(depot)) return INVALID_TILE; return depot + ::TileOffsByDiagDir(::GetRoadDepotDirection(depot)); } -TileIndex AIRoad::GetRoadStationFrontTile(TileIndex station) +/* static */ TileIndex AIRoad::GetRoadStationFrontTile(TileIndex station) { - if (!this->IsRoadStationTile(station)) return INVALID_TILE; + if (!IsRoadStationTile(station)) return INVALID_TILE; return station + ::TileOffsByDiagDir(::GetRoadStopDir(station)); } -TileIndex AIRoad::GetDriveThroughBackTile(TileIndex station) +/* static */ TileIndex AIRoad::GetDriveThroughBackTile(TileIndex station) { - if (!this->IsDriveThroughRoadStationTile(station)) return INVALID_TILE; + if (!IsDriveThroughRoadStationTile(station)) return INVALID_TILE; return station + ::TileOffsByDiagDir(::ReverseDiagDir(::GetRoadStopDir(station))); } -bool AIRoad::BuildRoad(TileIndex start, TileIndex end) +/* static */ bool AIRoad::BuildRoad(TileIndex start, TileIndex end) { /* Outside of the map */ if (start >= ::MapSize() || end >= ::MapSize() || start == end) return false; @@ -100,10 +100,10 @@ if (TileX(start) != TileX(end) && TileY(start) != TileY(end)) return false; - return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_BUILD_LONG_ROAD); + return AIObject::DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_BUILD_LONG_ROAD); } -bool AIRoad::BuildRoadFull(TileIndex start, TileIndex end) +/* static */ bool AIRoad::BuildRoadFull(TileIndex start, TileIndex end) { /* Outside of the map */ if (start >= ::MapSize() || end >= ::MapSize() || start == end) return false; @@ -111,20 +111,20 @@ if (TileX(start) != TileX(end) && TileY(start) != TileY(end)) return false; - return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_BUILD_LONG_ROAD); + return AIObject::DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_BUILD_LONG_ROAD); } -bool AIRoad::BuildRoadDepot(TileIndex tile, TileIndex front) +/* static */ bool AIRoad::BuildRoadDepot(TileIndex tile, TileIndex front) { /* Outside of the map */ if (tile >= ::MapSize() || tile == front) return false; uint entrance_dir = (TileX(tile) == TileX(front)) ? (TileY(tile) < TileY(front) ? 1 : 3) : (TileX(tile) < TileX(front) ? 2 : 0); - return this->DoCommand(tile, entrance_dir, ROADTYPE_ROAD << 2, CMD_BUILD_ROAD_DEPOT); + return AIObject::DoCommand(tile, entrance_dir, ROADTYPE_ROAD << 2, CMD_BUILD_ROAD_DEPOT); } -bool AIRoad::BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through) +/* static */ bool AIRoad::BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through) { /* Outside of the map */ if (tile >= ::MapSize() || tile == front) return false; @@ -136,21 +136,10 @@ entrance_dir = (TileX(tile) == TileX(front)) ? (TileY(tile) < TileY(front) ? 1 : 3) : (TileX(tile) < TileX(front) ? 2 : 0); } - return this->DoCommand(tile, entrance_dir, (drive_through ? 2 : 0) | (truck ? 1 : 0) | (ROADTYPES_ROAD << 2), CMD_BUILD_ROAD_STOP); + return AIObject::DoCommand(tile, entrance_dir, (drive_through ? 2 : 0) | (truck ? 1 : 0) | (ROADTYPES_ROAD << 2), CMD_BUILD_ROAD_STOP); } -bool AIRoad::RemoveRoad(TileIndex start, TileIndex end) -{ - /* Outside of the map */ - if (start >= ::MapSize() || end >= ::MapSize()) return false; - /* Not on one line */ - if (TileX(start) != TileX(end) && - TileY(start) != TileY(end)) return false; - - return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_REMOVE_LONG_ROAD); -} - -bool AIRoad::RemoveRoadFull(TileIndex start, TileIndex end) +/* static */ bool AIRoad::RemoveRoad(TileIndex start, TileIndex end) { /* Outside of the map */ if (start >= ::MapSize() || end >= ::MapSize()) return false; @@ -158,10 +147,21 @@ if (TileX(start) != TileX(end) && TileY(start) != TileY(end)) return false; - return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_REMOVE_LONG_ROAD); + return AIObject::DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_REMOVE_LONG_ROAD); } -bool AIRoad::RemoveRoadDepot(TileIndex tile) +/* static */ bool AIRoad::RemoveRoadFull(TileIndex start, TileIndex end) +{ + /* Outside of the map */ + if (start >= ::MapSize() || end >= ::MapSize()) return false; + /* Not on one line */ + if (TileX(start) != TileX(end) && + TileY(start) != TileY(end)) return false; + + return AIObject::DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_REMOVE_LONG_ROAD); +} + +/* static */ bool AIRoad::RemoveRoadDepot(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -169,10 +169,10 @@ /* Not a road depot tile */ if (!IsTileType(tile, MP_ROAD) || GetRoadTileType(tile) != ROAD_TILE_DEPOT) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); } -bool AIRoad::RemoveRoadStation(TileIndex tile) +/* static */ bool AIRoad::RemoveRoadStation(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -180,5 +180,5 @@ /* Not a road station tile */ if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile)) return false; - return this->DoCommand(tile, 0, GetRoadStopType(tile), CMD_REMOVE_ROAD_STOP); + return AIObject::DoCommand(tile, 0, GetRoadStopType(tile), CMD_REMOVE_ROAD_STOP); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_road.hpp --- a/src/ai/api/ai_road.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_road.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -35,7 +35,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return true if and only if the tile has road. */ - bool IsRoadTile(TileIndex tile); + static bool IsRoadTile(TileIndex tile); /** * Checks whether the given tile is actually a tile with a road depot. @@ -43,7 +43,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return true if and only if the tile has a road depot. */ - bool IsRoadDepotTile(TileIndex tile); + static bool IsRoadDepotTile(TileIndex tile); /** * Checks whether the given tile is actually a tile with a road station. @@ -51,7 +51,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return true if and only if the tile has a road station. */ - bool IsRoadStationTile(TileIndex tile); + static bool IsRoadStationTile(TileIndex tile); /** * Checks whether the given tile is actually a tile with a drive through @@ -60,7 +60,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return true if and only if the tile has a drive through road station. */ - bool IsDriveThroughRoadStationTile(TileIndex tile); + static bool IsDriveThroughRoadStationTile(TileIndex tile); /** * Checks whether the given tiles are directly connected, i.e. whether @@ -73,7 +73,7 @@ * @pre t1 and t2 are directly neighbouring tiles. * @return true if and only if a road vehicle can go from t1 to t2. */ - bool AreRoadTilesConnected(TileIndex t1, TileIndex t2); + static bool AreRoadTilesConnected(TileIndex t1, TileIndex t2); /** * Count how many neighbours are road. @@ -89,7 +89,7 @@ * @pre IsRoadDepotTile(depot). * @return the tile in front of the depot. */ - TileIndex GetRoadDepotFrontTile(TileIndex depot); + static TileIndex GetRoadDepotFrontTile(TileIndex depot); /** * Gets the tile in front of a road station. @@ -97,7 +97,7 @@ * @pre IsRoadStationTile(station). * @return the tile in front of the road station. */ - TileIndex GetRoadStationFrontTile(TileIndex station); + static TileIndex GetRoadStationFrontTile(TileIndex station); /** * Gets the tile at the back of a drive through road station. @@ -107,7 +107,7 @@ * @pre IsDriveThroughRoadStationTile(station). * @return the tile at the back of the drive through road station. */ - TileIndex GetDriveThroughBackTile(TileIndex station); + static TileIndex GetDriveThroughBackTile(TileIndex station); /** * Builds a road from the center of tile start to the @@ -122,7 +122,7 @@ * AIMap::GetTileY(start) == AIMap::GetTileY(end). * @return whether the road has been/can be build or not. */ - bool BuildRoad(TileIndex start, TileIndex end); + static bool BuildRoad(TileIndex start, TileIndex end); /** * Builds a road from the edge of tile start to the @@ -137,7 +137,7 @@ * AIMap::GetTileY(start) == AIMap::GetTileY(end). * @return whether the road has been/can be build or not. */ - bool BuildRoadFull(TileIndex start, TileIndex end); + static bool BuildRoadFull(TileIndex start, TileIndex end); /** * Builds a road depot. @@ -148,7 +148,7 @@ * @pre tile is not equal to front * @return whether the road depot has been/can be build or not. */ - bool BuildRoadDepot(TileIndex tile, TileIndex front); + static bool BuildRoadDepot(TileIndex tile, TileIndex front); /** * Builds a road bus or truck station. @@ -162,7 +162,7 @@ * @pre tile is not equal to front * @return whether the station has been/can be build or not. */ - bool BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through); + static bool BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through); /** * Removes a road from the center of tile start to the @@ -176,7 +176,7 @@ * AIMap::GetTileY(start) == AIMap::GetTileY(end). * @return whether the road has been/can be removed or not. */ - bool RemoveRoad(TileIndex start, TileIndex end); + static bool RemoveRoad(TileIndex start, TileIndex end); /** * Removes a road from the edge of tile start to the @@ -190,7 +190,7 @@ * AIMap::GetTileY(start) == AIMap::GetTileY(end). * @return whether the road has been/can be removed or not. */ - bool RemoveRoadFull(TileIndex start, TileIndex end); + static bool RemoveRoadFull(TileIndex start, TileIndex end); /** * Removes a road depot. @@ -199,7 +199,7 @@ * @pre tile is a road depot. * @return whether the road depot has been/can be removed or not. */ - bool RemoveRoadDepot(TileIndex tile); + static bool RemoveRoadDepot(TileIndex tile); /** * Removes a road bus or truck station. @@ -208,7 +208,7 @@ * @pre tile is a road station. * @return whether the station has been/can be removed or not. */ - bool RemoveRoadStation(TileIndex tile); + static bool RemoveRoadStation(TileIndex tile); }; #endif /* AI_ROAD_HPP */ diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_road.hpp.sq --- a/src/ai/api/ai_road.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_road.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -14,25 +14,24 @@ SQAIRoad.PreRegister(engine); SQAIRoad.AddConstructor(engine, "x"); - SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetClassName, "GetClassName", 1, "x"); - SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetNeighbourRoadCount, "GetNeighbourRoadCount", 2, "xi"); - - SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadTile, "IsRoadTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadDepotTile, "IsRoadDepotTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadStationTile, "IsRoadStationTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::IsDriveThroughRoadStationTile, "IsDriveThroughRoadStationTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::AreRoadTilesConnected, "AreRoadTilesConnected", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::GetRoadDepotFrontTile, "GetRoadDepotFrontTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::GetRoadStationFrontTile, "GetRoadStationFrontTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::GetDriveThroughBackTile, "GetDriveThroughBackTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoad, "BuildRoad", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadFull, "BuildRoadFull", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadDepot, "BuildRoadDepot", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadStation, "BuildRoadStation", 5, "xiibb"); - SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoad, "RemoveRoad", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadFull, "RemoveRoadFull", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadStation, "RemoveRoadStation", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetClassName, "GetClassName", 1, "x"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::IsRoadTile, "IsRoadTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::IsRoadDepotTile, "IsRoadDepotTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::IsRoadStationTile, "IsRoadStationTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::IsDriveThroughRoadStationTile, "IsDriveThroughRoadStationTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::AreRoadTilesConnected, "AreRoadTilesConnected", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetNeighbourRoadCount, "GetNeighbourRoadCount", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetRoadDepotFrontTile, "GetRoadDepotFrontTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetRoadStationFrontTile, "GetRoadStationFrontTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetDriveThroughBackTile, "GetDriveThroughBackTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::BuildRoad, "BuildRoad", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::BuildRoadFull, "BuildRoadFull", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::BuildRoadDepot, "BuildRoadDepot", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::BuildRoadStation, "BuildRoadStation", 5, "xiibb"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::RemoveRoad, "RemoveRoad", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::RemoveRoadFull, "RemoveRoadFull", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::RemoveRoadStation, "RemoveRoadStation", 2, "xi"); SQAIRoad.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_sign.cpp --- a/src/ai/api/ai_sign.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_sign.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -11,12 +11,12 @@ #include "../../strings_func.h" #include "../../map_func.h" -SignID AISign::GetMaxSignID() +/* static */ SignID AISign::GetMaxSignID() { return ::GetMaxSignIndex(); } -int32 AISign::GetSignCount() +/* static */ int32 AISign::GetSignCount() { return ::GetNumSigns(); } @@ -26,7 +26,7 @@ return ::IsValidSignID(sign_id); } -char *AISign::GetText(SignID sign_id) +/* static */ char *AISign::GetText(SignID sign_id) { if (!IsValidSign(sign_id)) return NULL; static const int len = 64; @@ -38,34 +38,34 @@ return sign_name; } -TileIndex AISign::GetLocation(SignID sign_id) +/* static */ TileIndex AISign::GetLocation(SignID sign_id) { if (!IsValidSign(sign_id)) return INVALID_TILE; const Sign *sign = ::GetSign(sign_id); return ::TileVirtXY(sign->x, sign->y); } -bool AISign::RemoveSign(SignID sign_id) +/* static */ bool AISign::RemoveSign(SignID sign_id) { _cmd_text = ""; - return this->DoCommand(0, sign_id, 0, CMD_RENAME_SIGN); + return AIObject::DoCommand(0, sign_id, 0, CMD_RENAME_SIGN); } -SignID AISign::BuildSign(TileIndex location, const char *text) +/* static */ SignID AISign::BuildSign(TileIndex location, const char *text) { if (!::IsValidTile(location)) return INVALID_SIGN; /* Reset the internal NewSignID in case we are in TestMode */ AIObject::SetNewSignID(0); - bool ret = this->DoCommand(location, 0, 0, CMD_PLACE_SIGN); + bool ret = AIObject::DoCommand(location, 0, 0, CMD_PLACE_SIGN); if (!ret) return INVALID_SIGN; SignID new_sign_id = AIObject::GetNewSignID(); _cmd_text = text; - ret = this->DoCommand(0, new_sign_id, 0, CMD_RENAME_SIGN); + ret = AIObject::DoCommand(0, new_sign_id, 0, CMD_RENAME_SIGN); if (!ret) { - this->RemoveSign(new_sign_id); + RemoveSign(new_sign_id); return INVALID_SIGN; } return new_sign_id; diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_sign.hpp --- a/src/ai/api/ai_sign.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_sign.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -22,7 +22,7 @@ * @return the maximum sign index. * @post return value is always non-negative. */ - SignID GetMaxSignID(); + static SignID GetMaxSignID(); /** * Gets the number of signs. This is different than GetMaxSignID() @@ -30,7 +30,7 @@ * @return the number of signs. * @post return value is always non-negative. */ - int32 GetSignCount(); + static int32 GetSignCount(); /** * Checks whether the given sign index is valid. @@ -46,7 +46,7 @@ * @return the text on the sign. * @note the returned name must be free'd (C++ only). */ - char *GetText(SignID sign_id); + static char *GetText(SignID sign_id); /** * Gets the location of the sign. @@ -55,7 +55,7 @@ * @return the location of the sign. * @post return value is always positive and below AIMap::GetMapSize(). */ - TileIndex GetLocation(SignID sign_id); + static TileIndex GetLocation(SignID sign_id); /** * Removes a sign from the map. @@ -63,7 +63,7 @@ * @pre sign_id has to be valid (use IsValidSign()). * @return true if and only if the sign has been removed. */ - bool RemoveSign(SignID sign_id); + static bool RemoveSign(SignID sign_id); /** * Builds a sign on the map. @@ -75,7 +75,7 @@ * In test-mode it returns 0 if successful, or any other value to indicate * failure. */ - SignID BuildSign(TileIndex location, const char *text); + static SignID BuildSign(TileIndex location, const char *text); }; #endif /* AI_SIGN_HPP */ diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_sign.hpp.sq --- a/src/ai/api/ai_sign.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_sign.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -15,14 +15,13 @@ SQAISign.AddConstructor(engine, "x"); SQAISign.DefSQStaticMethod(engine, &AISign::GetClassName, "GetClassName", 1, "x"); + SQAISign.DefSQStaticMethod(engine, &AISign::GetMaxSignID, "GetMaxSignID", 1, "x"); + SQAISign.DefSQStaticMethod(engine, &AISign::GetSignCount, "GetSignCount", 1, "x"); SQAISign.DefSQStaticMethod(engine, &AISign::IsValidSign, "IsValidSign", 2, "xi"); - - SQAISign.DefSQMethod(engine, &AISign::GetMaxSignID, "GetMaxSignID", 1, "x"); - SQAISign.DefSQMethod(engine, &AISign::GetSignCount, "GetSignCount", 1, "x"); - SQAISign.DefSQMethod(engine, &AISign::GetText, "GetText", 2, "xi"); - SQAISign.DefSQMethod(engine, &AISign::GetLocation, "GetLocation", 2, "xi"); - SQAISign.DefSQMethod(engine, &AISign::RemoveSign, "RemoveSign", 2, "xi"); - SQAISign.DefSQMethod(engine, &AISign::BuildSign, "BuildSign", 3, "xis"); + SQAISign.DefSQStaticMethod(engine, &AISign::GetText, "GetText", 2, "xi"); + SQAISign.DefSQStaticMethod(engine, &AISign::GetLocation, "GetLocation", 2, "xi"); + SQAISign.DefSQStaticMethod(engine, &AISign::RemoveSign, "RemoveSign", 2, "xi"); + SQAISign.DefSQStaticMethod(engine, &AISign::BuildSign, "BuildSign", 3, "xis"); SQAISign.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_tile.cpp --- a/src/ai/api/ai_tile.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_tile.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -10,7 +10,7 @@ #include "../../command_type.h" #include "../../settings_type.h" -bool AITile::IsBuildable(TileIndex tile) +/* static */ bool AITile::IsBuildable(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -26,7 +26,7 @@ } } -bool AITile::IsWater(TileIndex tile) +/* static */ bool AITile::IsWater(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -34,7 +34,7 @@ return ::GetTileType(tile) == MP_WATER; } -int32 AITile::GetSlope(TileIndex tile) +/* static */ int32 AITile::GetSlope(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return 0; @@ -42,7 +42,7 @@ return ::GetTileSlope(tile, NULL); } -int32 AITile::GetHeight(TileIndex tile) +/* static */ int32 AITile::GetHeight(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return 0; @@ -50,7 +50,7 @@ return ::TileHeight(tile); } -int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius) +/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius) { /* Outside of the map */ if (tile >= ::MapSize()) return 0; @@ -60,7 +60,7 @@ return accepts[cargo_type]; } -int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius) +/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius) { /* Outside of the map */ if (tile >= ::MapSize()) return 0; @@ -70,18 +70,18 @@ return produced[cargo_type]; } -bool AITile::RaiseTile(TileIndex tile, int32 slope) +/* static */ bool AITile::RaiseTile(TileIndex tile, int32 slope) { /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, slope, 1, CMD_TERRAFORM_LAND); + return AIObject::DoCommand(tile, slope, 1, CMD_TERRAFORM_LAND); } -bool AITile::LowerTile(TileIndex tile, int32 slope) +/* static */ bool AITile::LowerTile(TileIndex tile, int32 slope) { /* Outside of the map */ if (tile >= ::MapSize()) return false; - return this->DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND); + return AIObject::DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_tile.hpp --- a/src/ai/api/ai_tile.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_tile.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -118,7 +118,7 @@ * @param slope corners to raise (SLOPE_xxx). * @return 0 means failed, 1 means success. */ - bool RaiseTile(TileIndex tile, int32 slope); + static bool RaiseTile(TileIndex tile, int32 slope); /** * Lower the given corners of the tile. The corners can be combined, @@ -128,7 +128,7 @@ * @param slope corners to lower (SLOPE_xxx). * @return 0 means failed, 1 means success. */ - bool LowerTile(TileIndex tile, int32 slope); + static bool LowerTile(TileIndex tile, int32 slope); }; diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_tile.hpp.sq --- a/src/ai/api/ai_tile.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_tile.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -47,9 +47,8 @@ SQAITile.DefSQStaticMethod(engine, &AITile::GetHeight, "GetHeight", 2, "xi"); SQAITile.DefSQStaticMethod(engine, &AITile::GetCargoAcceptance, "GetCargoAcceptance", 6, "xiiiii"); SQAITile.DefSQStaticMethod(engine, &AITile::GetCargoProduction, "GetCargoProduction", 6, "xiiiii"); - - SQAITile.DefSQMethod(engine, &AITile::RaiseTile, "RaiseTile", 3, "xii"); - SQAITile.DefSQMethod(engine, &AITile::LowerTile, "LowerTile", 3, "xii"); + SQAITile.DefSQStaticMethod(engine, &AITile::RaiseTile, "RaiseTile", 3, "xii"); + SQAITile.DefSQStaticMethod(engine, &AITile::LowerTile, "LowerTile", 3, "xii"); SQAITile.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_town.cpp --- a/src/ai/api/ai_town.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_town.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -9,12 +9,12 @@ #include "../../core/alloc_func.hpp" #include "table/strings.h" -TownID AITown::GetMaxTownID() +/* static */ TownID AITown::GetMaxTownID() { return ::GetMaxTownIndex(); } -int32 AITown::GetTownCount() +/* static */ int32 AITown::GetTownCount() { return ::GetNumTowns(); } @@ -24,7 +24,7 @@ return ::IsValidTownID(town_id); } -char *AITown::GetName(TownID town_id) +/* static */ char *AITown::GetName(TownID town_id) { if (!IsValidTown(town_id)) return NULL; static const int len = 64; @@ -36,14 +36,14 @@ return town_name; } -int32 AITown::GetPopulation(TownID town_id) +/* static */ int32 AITown::GetPopulation(TownID town_id) { if (!IsValidTown(town_id)) return 0; const Town *t = ::GetTown(town_id); return t->population; } -TileIndex AITown::GetLocation(TownID town_id) +/* static */ TileIndex AITown::GetLocation(TownID town_id) { if (!IsValidTown(town_id)) return INVALID_TILE; const Town *t = ::GetTown(town_id); diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_town.hpp --- a/src/ai/api/ai_town.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_town.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -23,7 +23,7 @@ * @return the maximum town index. * @post return value is always non-negative. */ - TownID GetMaxTownID(); + static TownID GetMaxTownID(); /** * Gets the number of towns. This is different than GetMaxTownID() @@ -31,7 +31,7 @@ * @return the number of towns. * @post return value is always non-negative. */ - int32 GetTownCount(); + static int32 GetTownCount(); /** * Checks whether the given town index is valid. diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_town.hpp.sq --- a/src/ai/api/ai_town.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_town.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -15,13 +15,12 @@ SQAITown.AddConstructor(engine, "x"); SQAITown.DefSQStaticMethod(engine, &AITown::GetClassName, "GetClassName", 1, "x"); + SQAITown.DefSQStaticMethod(engine, &AITown::GetMaxTownID, "GetMaxTownID", 1, "x"); + SQAITown.DefSQStaticMethod(engine, &AITown::GetTownCount, "GetTownCount", 1, "x"); SQAITown.DefSQStaticMethod(engine, &AITown::IsValidTown, "IsValidTown", 2, "xi"); SQAITown.DefSQStaticMethod(engine, &AITown::GetName, "GetName", 2, "xi"); SQAITown.DefSQStaticMethod(engine, &AITown::GetPopulation, "GetPopulation", 2, "xi"); SQAITown.DefSQStaticMethod(engine, &AITown::GetLocation, "GetLocation", 2, "xi"); - SQAITown.DefSQMethod(engine, &AITown::GetMaxTownID, "GetMaxTownID", 1, "x"); - SQAITown.DefSQMethod(engine, &AITown::GetTownCount, "GetTownCount", 1, "x"); - SQAITown.PostRegister(engine); } diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_vehicle.cpp --- a/src/ai/api/ai_vehicle.cpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_vehicle.cpp Fri Feb 22 12:30:17 2008 +0000 @@ -13,6 +13,8 @@ #include "../../aircraft.h" #include "../../strings_func.h" #include "../../core/alloc_func.hpp" +#include "../../command_type.h" +#include "../../command_func.h" #include "table/strings.h" /* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id) @@ -20,7 +22,7 @@ return ::IsValidVehicleID(vehicle_id) && ::GetVehicle(vehicle_id)->owner == _current_player && ::GetVehicle(vehicle_id)->IsPrimaryVehicle(); } -VehicleID AIVehicle::BuildVehicle(TileIndex depot, EngineID engine_id) +/* static */ VehicleID AIVehicle::BuildVehicle(TileIndex depot, EngineID engine_id) { if (!AIEngine::IsValidEngine(engine_id)) return false; @@ -29,106 +31,106 @@ bool ret; switch (::GetEngine(engine_id)->type) { - case VEH_ROAD: ret = this->DoCommand(depot, engine_id, 0, CMD_BUILD_ROAD_VEH); break; - case VEH_TRAIN: ret = this->DoCommand(depot, engine_id, 0, CMD_BUILD_RAIL_VEHICLE); break; - case VEH_SHIP: ret = this->DoCommand(depot, engine_id, 0, CMD_BUILD_SHIP); break; - case VEH_AIRCRAFT: ret = this->DoCommand(depot, engine_id, 0, CMD_BUILD_AIRCRAFT); break; + case VEH_ROAD: ret = AIObject::DoCommand(depot, engine_id, 0, CMD_BUILD_ROAD_VEH); break; + case VEH_TRAIN: ret = AIObject::DoCommand(depot, engine_id, 0, CMD_BUILD_RAIL_VEHICLE); break; + case VEH_SHIP: ret = AIObject::DoCommand(depot, engine_id, 0, CMD_BUILD_SHIP); break; + case VEH_AIRCRAFT: ret = AIObject::DoCommand(depot, engine_id, 0, CMD_BUILD_AIRCRAFT); break; default: NOT_REACHED(); return INVALID_VEHICLE; } return ret ? AIObject::GetNewVehicleID() : INVALID_VEHICLE; } -VehicleID AIVehicle::CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders) +/* static */ VehicleID AIVehicle::CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders) { if (!IsValidVehicle(vehicle_id)) return false; /* Reset the internal NewVehicleID in case we are in TestMode */ AIObject::SetNewVehicleID(0); - bool ret = this->DoCommand(depot, vehicle_id, share_orders, CMD_CLONE_VEHICLE); + bool ret = AIObject::DoCommand(depot, vehicle_id, share_orders, CMD_CLONE_VEHICLE); return ret ? AIObject::GetNewVehicleID() : INVALID_VEHICLE; } -bool AIVehicle::RefitVehicle(VehicleID vehicle_id, CargoID cargo) +/* static */ bool AIVehicle::RefitVehicle(VehicleID vehicle_id, CargoID cargo) { if (!IsValidVehicle(vehicle_id) || !AICargo::IsValidCargo(cargo)) return false; switch (::GetVehicle(vehicle_id)->type) { - case VEH_ROAD: return this->DoCommand(0, vehicle_id, cargo, CMD_REFIT_ROAD_VEH); - case VEH_TRAIN: return this->DoCommand(0, vehicle_id, cargo, CMD_REFIT_RAIL_VEHICLE); - case VEH_SHIP: return this->DoCommand(0, vehicle_id, cargo, CMD_REFIT_SHIP); - case VEH_AIRCRAFT: return this->DoCommand(0, vehicle_id, cargo, CMD_REFIT_AIRCRAFT); + case VEH_ROAD: return AIObject::DoCommand(0, vehicle_id, cargo, CMD_REFIT_ROAD_VEH); + case VEH_TRAIN: return AIObject::DoCommand(0, vehicle_id, cargo, CMD_REFIT_RAIL_VEHICLE); + case VEH_SHIP: return AIObject::DoCommand(0, vehicle_id, cargo, CMD_REFIT_SHIP); + case VEH_AIRCRAFT: return AIObject::DoCommand(0, vehicle_id, cargo, CMD_REFIT_AIRCRAFT); default: return false; } } -bool AIVehicle::SellVehicle(VehicleID vehicle_id) +/* static */ bool AIVehicle::SellVehicle(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return false; switch (::GetVehicle(vehicle_id)->type) { - case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_SELL_ROAD_VEH); - case VEH_TRAIN: return this->DoCommand(0, vehicle_id, 0, CMD_SELL_RAIL_WAGON); - case VEH_SHIP: return this->DoCommand(0, vehicle_id, 0, CMD_SELL_SHIP); - case VEH_AIRCRAFT: return this->DoCommand(0, vehicle_id, 0, CMD_SELL_AIRCRAFT); + case VEH_ROAD: return AIObject::DoCommand(0, vehicle_id, 0, CMD_SELL_ROAD_VEH); + case VEH_TRAIN: return AIObject::DoCommand(0, vehicle_id, 0, CMD_SELL_RAIL_WAGON); + case VEH_SHIP: return AIObject::DoCommand(0, vehicle_id, 0, CMD_SELL_SHIP); + case VEH_AIRCRAFT: return AIObject::DoCommand(0, vehicle_id, 0, CMD_SELL_AIRCRAFT); default: return false; } } -bool AIVehicle::SendVehicleToDepot(VehicleID vehicle_id) +/* static */ bool AIVehicle::SendVehicleToDepot(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return false; switch (::GetVehicle(vehicle_id)->type) { - case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_SEND_ROADVEH_TO_DEPOT); - case VEH_TRAIN: return this->DoCommand(0, vehicle_id, 0, CMD_SEND_TRAIN_TO_DEPOT); - case VEH_SHIP: return this->DoCommand(0, vehicle_id, 0, CMD_SEND_SHIP_TO_DEPOT); - case VEH_AIRCRAFT: return this->DoCommand(0, vehicle_id, 0, CMD_SEND_AIRCRAFT_TO_HANGAR); + case VEH_ROAD: return AIObject::DoCommand(0, vehicle_id, 0, CMD_SEND_ROADVEH_TO_DEPOT); + case VEH_TRAIN: return AIObject::DoCommand(0, vehicle_id, 0, CMD_SEND_TRAIN_TO_DEPOT); + case VEH_SHIP: return AIObject::DoCommand(0, vehicle_id, 0, CMD_SEND_SHIP_TO_DEPOT); + case VEH_AIRCRAFT: return AIObject::DoCommand(0, vehicle_id, 0, CMD_SEND_AIRCRAFT_TO_HANGAR); default: return false; } } -bool AIVehicle::IsInDepot(VehicleID vehicle_id) +/* static */ bool AIVehicle::IsInDepot(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return false; return ::GetVehicle(vehicle_id)->IsInDepot(); } -bool AIVehicle::IsStoppedInDepot(VehicleID vehicle_id) +/* static */ bool AIVehicle::IsStoppedInDepot(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return false; return ::GetVehicle(vehicle_id)->IsStoppedInDepot(); } -bool AIVehicle::StartStopVehicle(VehicleID vehicle_id) +/* static */ bool AIVehicle::StartStopVehicle(VehicleID vehicle_id) { if (!IsValidVehicle(vehicle_id)) return false; switch (::GetVehicle(vehicle_id)->type) { - case VEH_ROAD: return this->DoCommand(0, vehicle_id, 0, CMD_START_STOP_ROADVEH); - case VEH_TRAIN: return this->DoCommand(0, vehicle_id, 0, CMD_START_STOP_TRAIN); - case VEH_SHIP: return this->DoCommand(0, vehicle_id, 0, CMD_START_STOP_SHIP); - case VEH_AIRCRAFT: return this->DoCommand(0, vehicle_id, 0, CMD_START_STOP_AIRCRAFT); + case VEH_ROAD: return AIObject::DoCommand(0, vehicle_id, 0, CMD_START_STOP_ROADVEH); + case VEH_TRAIN: return AIObject::DoCommand(0, vehicle_id, 0, CMD_START_STOP_TRAIN); + case VEH_SHIP: return AIObject::DoCommand(0, vehicle_id, 0, CMD_START_STOP_SHIP); + case VEH_AIRCRAFT: return AIObject::DoCommand(0, vehicle_id, 0, CMD_START_STOP_AIRCRAFT); default: return false; } } -bool AIVehicle::SkipToVehicleOrder(VehicleID vehicle_id, uint32 order_id) +/* static */ bool AIVehicle::SkipToVehicleOrder(VehicleID vehicle_id, uint32 order_id) { if (!AIOrder::IsValidVehicleOrder(vehicle_id, order_id)) return false; - return this->DoCommand(0, vehicle_id, order_id, CMD_SKIP_TO_ORDER); + return AIObject::DoCommand(0, vehicle_id, order_id, CMD_SKIP_TO_ORDER); } -bool AIVehicle::SetName(VehicleID vehicle_id, const char *name) +/* static */ bool AIVehicle::SetName(VehicleID vehicle_id, const char *name) { if (!IsValidVehicle(vehicle_id)) return false; if (name == NULL) return false; _cmd_text = name; - return this->DoCommand(0, vehicle_id, 0, CMD_NAME_VEHICLE); + return AIObject::DoCommand(0, vehicle_id, 0, CMD_NAME_VEHICLE); } /* static */ TileIndex AIVehicle::GetLocation(VehicleID vehicle_id) @@ -218,3 +220,4 @@ default: return VEHICLE_INVALID; } } + diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_vehicle.hpp --- a/src/ai/api/ai_vehicle.hpp Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_vehicle.hpp Fri Feb 22 12:30:17 2008 +0000 @@ -52,7 +52,7 @@ * as the vehicle isn't really built yet. Build it for real first before * assigning orders. */ - VehicleID BuildVehicle(TileIndex depot, EngineID engine_id); + static VehicleID BuildVehicle(TileIndex depot, EngineID engine_id); /** * Clones a vehicle at the given depot, copying or cloning it's orders. @@ -65,7 +65,7 @@ * it failed. Check the return value using IsValidVehicle. In test-mode * 0 is returned if it was successful; any other value indicates failure. */ - VehicleID CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders); + static VehicleID CloneVehicle(TileIndex depot, VehicleID vehicle_id, bool share_orders); /** * Refits a vehicle to the given cargo type @@ -77,7 +77,7 @@ * @pre the vehicle must be stopped in the depot * @return true if and only if the refit succeeded. */ - bool RefitVehicle(VehicleID vehicle_id, CargoID cargo); + static bool RefitVehicle(VehicleID vehicle_id, CargoID cargo); /** * Sells the given vehicle. @@ -87,7 +87,7 @@ * @pre the vehicle must be stopped in the depot * @return true if and only if the vehicle has been sold. */ - bool SellVehicle(VehicleID vehicle_id); + static bool SellVehicle(VehicleID vehicle_id); /** * Sends the given vehicle to a depot. @@ -95,7 +95,7 @@ * @pre IsValidVehicle(vehicle_id). * @return true if and only if the vehicle has been sent to a depot. */ - bool SendVehicleToDepot(VehicleID vehicle_id); + static bool SendVehicleToDepot(VehicleID vehicle_id); /** * Check if a vehicle is in a depot. @@ -103,7 +103,7 @@ * @pre isValidVehicle(vehicle_id). * @return true if and only if the vehicle is in a depot. */ - bool IsInDepot(VehicleID vehicle_id); + static bool IsInDepot(VehicleID vehicle_id); /** * Check if a vehicle is in a depot and stopped. @@ -111,7 +111,7 @@ * @pre isValidVehicle(vehicle_id). * @return true if and only if the vehicle is in a depot and stopped. */ - bool IsStoppedInDepot(VehicleID vehicle_id); + static bool IsStoppedInDepot(VehicleID vehicle_id); /** * Starts or stops the given vehicle depending on the current state. @@ -119,7 +119,7 @@ * @pre IsValidVehicle(vehicle_id). * @return true if and only if the vehicle has been started or stopped. */ - bool StartStopVehicle(VehicleID vehicle_id); + static bool StartStopVehicle(VehicleID vehicle_id); /** * Skips the current order of the given vehicle. @@ -128,7 +128,7 @@ * @pre IsValidVehicleOrder(vehicle_id, order_id). * @return true if and only if the order has been skipped. */ - bool SkipToVehicleOrder(VehicleID vehicle_id, uint32 order_id); + static bool SkipToVehicleOrder(VehicleID vehicle_id, uint32 order_id); /** * Set the name of a vehicle. @@ -139,7 +139,7 @@ * @pre You have to own the vehicle. * @return true if and only if the name was changed. */ - bool SetName(VehicleID vehicle_id, const char *name); + static bool SetName(VehicleID vehicle_id, const char *name); /** * Get the current location of a vehicle. @@ -234,6 +234,7 @@ * @return the vehicle type. */ static AIVehicle::VehicleType GetVehicleType(VehicleID vehicle_id); + }; #endif /* AI_VEHICLE_HPP */ diff -r 183b38e0a480 -r ee408edf3851 src/ai/api/ai_vehicle.hpp.sq --- a/src/ai/api/ai_vehicle.hpp.sq Fri Feb 22 12:13:41 2008 +0000 +++ b/src/ai/api/ai_vehicle.hpp.sq Fri Feb 22 12:30:17 2008 +0000 @@ -24,30 +24,29 @@ SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_AIR, "VEHICLE_AIR"); SQAIVehicle.DefSQConst(engine, AIVehicle::VEHICLE_INVALID, "VEHICLE_INVALID"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetClassName, "GetClassName", 1, "x"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsValidVehicle, "IsValidVehicle", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetLocation, "GetLocation", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetEngineType, "GetEngineType", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetUnitNumber, "GetUnitNumber", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetName, "GetName", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAge, "GetAge", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetMaxAge, "GetMaxAge", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAgeLeft, "GetAgeLeft", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetRunningCost, "GetRunningCost", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitThisYear, "GetProfitThisYear", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitLastYear, "GetProfitLastYear", 2, "xi"); - SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetVehicleType, "GetVehicleType", 2, "xi"); - - SQAIVehicle.DefSQMethod(engine, &AIVehicle::BuildVehicle, "BuildVehicle", 3, "xii"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::CloneVehicle, "CloneVehicle", 4, "xiib"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::RefitVehicle, "RefitVehicle", 3, "xii"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::SellVehicle, "SellVehicle", 2, "xi"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::SendVehicleToDepot, "SendVehicleToDepot", 2, "xi"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::IsInDepot, "IsInDepot", 2, "xi"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::IsStoppedInDepot, "IsStoppedInDepot", 2, "xi"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::StartStopVehicle, "StartStopVehicle", 2, "xi"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::SkipToVehicleOrder, "SkipToVehicleOrder", 3, "xii"); - SQAIVehicle.DefSQMethod(engine, &AIVehicle::SetName, "SetName", 3, "xis"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetClassName, "GetClassName", 1, "x"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsValidVehicle, "IsValidVehicle", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::BuildVehicle, "BuildVehicle", 3, "xii"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::CloneVehicle, "CloneVehicle", 4, "xiib"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::RefitVehicle, "RefitVehicle", 3, "xii"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SellVehicle, "SellVehicle", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SendVehicleToDepot, "SendVehicleToDepot", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsInDepot, "IsInDepot", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::IsStoppedInDepot, "IsStoppedInDepot", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::StartStopVehicle, "StartStopVehicle", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SkipToVehicleOrder, "SkipToVehicleOrder", 3, "xii"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::SetName, "SetName", 3, "xis"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetLocation, "GetLocation", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetEngineType, "GetEngineType", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetUnitNumber, "GetUnitNumber", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetName, "GetName", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAge, "GetAge", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetMaxAge, "GetMaxAge", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetAgeLeft, "GetAgeLeft", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetRunningCost, "GetRunningCost", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitThisYear, "GetProfitThisYear", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetProfitLastYear, "GetProfitLastYear", 2, "xi"); + SQAIVehicle.DefSQStaticMethod(engine, &AIVehicle::GetVehicleType, "GetVehicleType", 2, "xi"); SQAIVehicle.PostRegister(engine); }