(svn r12728) [NoAI] -Codechange: always let functions return Money when they return something that can be quantified as money.
--- a/src/ai/api/ai_accounting.cpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_accounting.cpp Tue Apr 15 22:34:49 2008 +0000
@@ -4,7 +4,7 @@
#include "ai_accounting.hpp"
-int32 AIAccounting::GetCosts()
+Money AIAccounting::GetCosts()
{
return this->GetDoCommandCosts();
}
--- a/src/ai/api/ai_accounting.hpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_accounting.hpp Tue Apr 15 22:34:49 2008 +0000
@@ -40,7 +40,7 @@
* Get the current value of the costs.
* @return The current costs.
*/
- int32 GetCosts();
+ Money GetCosts();
/**
* Reset the costs to zero.
@@ -48,7 +48,7 @@
void ResetCosts();
private:
- int32 last_costs;
+ Money last_costs;
};
#endif /* AI_ACCOUNTING_HPP */
--- a/src/ai/api/ai_bridge.cpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_bridge.cpp Tue Apr 15 22:34:49 2008 +0000
@@ -65,7 +65,7 @@
return ::GetBridgeSpec(bridge_id)->speed;
}
-/* static */ int32 AIBridge::GetPrice(BridgeID bridge_id, uint length)
+/* static */ Money AIBridge::GetPrice(BridgeID bridge_id, uint length)
{
if (!IsValidBridge(bridge_id)) return -1;
--- a/src/ai/api/ai_bridge.hpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_bridge.hpp Tue Apr 15 22:34:49 2008 +0000
@@ -78,7 +78,7 @@
* @pre IsValidBridge(bridge_id).
* @return The new cost the bridge has.
*/
- static int32 GetPrice(BridgeID bridge_id, uint length);
+ static Money GetPrice(BridgeID bridge_id, uint length);
/**
* Get the maximum length of a bridge.
--- a/src/ai/api/ai_cargo.cpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_cargo.cpp Tue Apr 15 22:34:49 2008 +0000
@@ -35,7 +35,7 @@
return cargo->is_freight;
}
-/* static */ int32 AICargo::GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit)
+/* static */ Money AICargo::GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit)
{
if (!IsValidCargo(cargo_type)) return -1;
return ::GetTransportedGoodsIncome(1, distance, days_in_transit, cargo_type);
--- a/src/ai/api/ai_cargo.hpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_cargo.hpp Tue Apr 15 22:34:49 2008 +0000
@@ -45,7 +45,7 @@
* @param days_in_transit Amount of (game) days the cargo is in transit.
* @return The amount of money that would be earned by this trip.
*/
- static int32 GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit);
+ static Money GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit);
};
#endif /* AI_CARGO_HPP */
--- a/src/ai/api/ai_company.cpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_company.cpp Tue Apr 15 22:34:49 2008 +0000
@@ -67,7 +67,7 @@
return president_name;
}
-/* static */ int32 AICompany::GetCompanyValue(AICompany::CompanyIndex company)
+/* static */ Money AICompany::GetCompanyValue(AICompany::CompanyIndex company)
{
company = ResolveCompanyIndex(company);
if (company == INVALID_COMPANY) return -1;
@@ -75,25 +75,25 @@
return ::GetPlayer((PlayerID)company)->cur_economy.company_value;
}
-/* static */ int32 AICompany::GetBankBalance(AICompany::CompanyIndex company)
+/* static */ Money AICompany::GetBankBalance(AICompany::CompanyIndex company)
{
company = ResolveCompanyIndex(company);
if (company == INVALID_COMPANY) return -1;
- return ::ClampToI32(GetPlayer((PlayerID)company)->player_money);
+ return ::GetPlayer((PlayerID)company)->player_money;
}
-/* static */ int32 AICompany::GetLoanAmount()
+/* static */ Money AICompany::GetLoanAmount()
{
return ::GetPlayer(_current_player)->current_loan;
}
-/* static */ int32 AICompany::GetMaxLoanAmount()
+/* static */ Money AICompany::GetMaxLoanAmount()
{
return _economy.max_loan;
}
-/* static */ int32 AICompany::GetLoanInterval()
+/* static */ Money AICompany::GetLoanInterval()
{
return LOAN_INTERVAL;
}
--- a/src/ai/api/ai_company.hpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_company.hpp Tue Apr 15 22:34:49 2008 +0000
@@ -92,7 +92,7 @@
* @post The return value is always non-negative.
* @post GetLoanInterval() is always a multiplier of the return value.
*/
- static int32 GetLoanAmount();
+ static Money 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.
*/
- static int32 GetMaxLoanAmount();
+ static Money GetMaxLoanAmount();
/**
* Gets the interval/loan step.
* @return The loan step.
* @post Return value is always positive.
*/
- static int32 GetLoanInterval();
+ static Money GetLoanInterval();
/**
* Gets the current value of the given company.
@@ -115,7 +115,7 @@
* @pre ResolveCompanyIndex(company) != INVALID_COMPANY
* @return The current value of the given company.
*/
- static int32 GetCompanyValue(CompanyIndex company);
+ static Money GetCompanyValue(CompanyIndex company);
/**
* Gets the bank balance. In other words, the amount of money the given company can spent.
@@ -123,7 +123,7 @@
* @pre ResolveCompanyIndex(company) != INVALID_COMPANY
* @return The actual bank balance.
*/
- static int32 GetBankBalance(CompanyIndex company);
+ static Money GetBankBalance(CompanyIndex company);
/**
* Build your company's HQ on the given tile.
--- a/src/ai/api/ai_engine.cpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_engine.cpp Tue Apr 15 22:34:49 2008 +0000
@@ -141,7 +141,7 @@
}
}
-/* static */ int32 AIEngine::GetPrice(EngineID engine_id)
+/* static */ Money AIEngine::GetPrice(EngineID engine_id)
{
if (!IsValidEngine(engine_id)) return -1;
--- a/src/ai/api/ai_engine.hpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_engine.hpp Tue Apr 15 22:34:49 2008 +0000
@@ -85,7 +85,7 @@
* @pre IsValidEngine(engine_id).
* @return The new cost the engine has.
*/
- static int32 GetPrice(EngineID engine_id);
+ static Money GetPrice(EngineID engine_id);
/**
* Get the maximum age of a brand new engine.
--- a/src/ai/api/ai_vehicle.cpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_vehicle.cpp Tue Apr 15 22:34:49 2008 +0000
@@ -200,14 +200,14 @@
return ::GetVehicle(vehicle_id)->GetRunningCost() >> 8;
}
-/* static */ int32 AIVehicle::GetProfitThisYear(VehicleID vehicle_id)
+/* static */ Money AIVehicle::GetProfitThisYear(VehicleID vehicle_id)
{
if (!IsValidVehicle(vehicle_id)) return -1;
return ::GetVehicle(vehicle_id)->GetDisplayProfitThisYear();
}
-/* static */ int32 AIVehicle::GetProfitLastYear(VehicleID vehicle_id)
+/* static */ Money AIVehicle::GetProfitLastYear(VehicleID vehicle_id)
{
if (!IsValidVehicle(vehicle_id)) return -1;
--- a/src/ai/api/ai_vehicle.hpp Tue Apr 15 22:29:00 2008 +0000
+++ b/src/ai/api/ai_vehicle.hpp Tue Apr 15 22:34:49 2008 +0000
@@ -176,7 +176,7 @@
* @pre IsValidVehicle(vehicle_id).
* @return The current profit the vehicle has.
*/
- static int32 GetProfitThisYear(VehicleID vehicle_id);
+ static Money GetProfitThisYear(VehicleID vehicle_id);
/**
* Get the profit of last year of a vehicle.
@@ -184,7 +184,7 @@
* @pre IsValidVehicle(vehicle_id).
* @return The profit the vehicle had last year.
*/
- static int32 GetProfitLastYear(VehicleID vehicle_id);
+ static Money GetProfitLastYear(VehicleID vehicle_id);
/**
* Get the type of vehicle.