summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-21 14:32:27 +0000
committerrubidium <rubidium@openttd.org>2007-06-21 14:32:27 +0000
commitf806b46cc967202db3d2fbf3384d0f037c13ed8a (patch)
tree4d9bfa9de886f7ff167c4fa02326f5cd302e8cce /src/ai
parent06fded123a346d556ceb2f4585429046ddf8f1b9 (diff)
downloadopenttd-f806b46cc967202db3d2fbf3384d0f037c13ed8a.tar.xz
(svn r10246) -Fix (r10297): some forgotten money conversions and truncation issues. Thanks to benc for providing the patch.
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/default/default.cpp22
-rw-r--r--src/ai/trolly/trolly.cpp3
2 files changed, 12 insertions, 13 deletions
diff --git a/src/ai/default/default.cpp b/src/ai/default/default.cpp
index a5bc10514..d0b5e7fba 100644
--- a/src/ai/default/default.cpp
+++ b/src/ai/default/default.cpp
@@ -132,7 +132,7 @@ static void AiStateVehLoop(Player *p)
p->ai.state_counter = 0;
}
-static EngineID AiChooseTrainToBuild(RailType railtype, int32 money, byte flag, TileIndex tile)
+static EngineID AiChooseTrainToBuild(RailType railtype, Money money, byte flag, TileIndex tile)
{
EngineID best_veh_index = INVALID_ENGINE;
byte best_veh_score = 0;
@@ -161,7 +161,7 @@ static EngineID AiChooseTrainToBuild(RailType railtype, int32 money, byte flag,
return best_veh_index;
}
-static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex tile)
+static EngineID AiChooseRoadVehToBuild(CargoID cargo, Money money, TileIndex tile)
{
EngineID best_veh_index = INVALID_ENGINE;
int32 best_veh_rating = 0;
@@ -199,10 +199,10 @@ static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex til
return best_veh_index;
}
-static EngineID AiChooseAircraftToBuild(int32 money, byte flag)
+static EngineID AiChooseAircraftToBuild(Money money, byte flag)
{
EngineID best_veh_index = INVALID_ENGINE;
- int32 best_veh_cost = 0;
+ Money best_veh_cost = 0;
EngineID i;
for (i = AIRCRAFT_ENGINES_INDEX; i != AIRCRAFT_ENGINES_INDEX + NUM_AIRCRAFT_ENGINES; i++) {
@@ -225,9 +225,9 @@ static EngineID AiChooseAircraftToBuild(int32 money, byte flag)
return best_veh_index;
}
-static int32 AiGetBasePrice(const Player* p)
+static Money AiGetBasePrice(const Player* p)
{
- int32 base = _price.station_value;
+ Money base = _price.station_value;
// adjust base price when more expensive vehicles are available
switch (p->ai.railtype_to_use) {
@@ -242,7 +242,7 @@ static int32 AiGetBasePrice(const Player* p)
}
#if 0
-static EngineID AiChooseShipToBuild(byte cargo, int32 money)
+static EngineID AiChooseShipToBuild(byte cargo, Money money)
{
// XXX: not done
return INVALID_ENGINE;
@@ -251,13 +251,13 @@ static EngineID AiChooseShipToBuild(byte cargo, int32 money)
static EngineID AiChooseRoadVehToReplaceWith(const Player* p, const Vehicle* v)
{
- int32 avail_money = p->player_money + v->value;
+ Money avail_money = p->player_money + v->value;
return AiChooseRoadVehToBuild(v->cargo_type, avail_money, v->tile);
}
static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v)
{
- int32 avail_money = p->player_money + v->value;
+ Money avail_money = p->player_money + v->value;
return AiChooseAircraftToBuild(
avail_money, AircraftVehInfo(v->engine_type)->subtype & AIR_CTOL
);
@@ -265,7 +265,7 @@ static EngineID AiChooseAircraftToReplaceWith(const Player* p, const Vehicle* v)
static EngineID AiChooseTrainToReplaceWith(const Player* p, const Vehicle* v)
{
- int32 avail_money = p->player_money + v->value;
+ Money avail_money = p->player_money + v->value;
const Vehicle* u = v;
int num = 0;
@@ -3901,7 +3901,7 @@ static void AiHandleTakeover(Player *p)
static void AiAdjustLoan(const Player* p)
{
- int32 base = AiGetBasePrice(p);
+ Money base = AiGetBasePrice(p);
if (p->player_money > base * 1400) {
// Decrease loan
diff --git a/src/ai/trolly/trolly.cpp b/src/ai/trolly/trolly.cpp
index fb0263d41..1f540ceed 100644
--- a/src/ai/trolly/trolly.cpp
+++ b/src/ai/trolly/trolly.cpp
@@ -97,7 +97,6 @@ static void AiNew_State_Nothing(Player *p)
// - Build HQ
static void AiNew_State_WakeUp(Player *p)
{
- int32 money;
int c;
assert(p->ainew.state == AI_STATE_WAKE_UP);
// First, check if we have a HQ
@@ -111,7 +110,7 @@ static void AiNew_State_WakeUp(Player *p)
return;
}
- money = p->player_money - AI_MINIMUM_MONEY;
+ Money money = p->player_money - AI_MINIMUM_MONEY;
// Let's pick an action!
if (p->ainew.action == AI_ACTION_NONE) {