diff options
author | Darkvater <Darkvater@openttd.org> | 2006-03-26 22:23:32 +0000 |
---|---|---|
committer | Darkvater <Darkvater@openttd.org> | 2006-03-26 22:23:32 +0000 |
commit | e91fa54a157e73958e2bc7cbf212c8ef7df75d6b (patch) | |
tree | 2a31936844a550db9aea12a9b2645bfd4e7e7fa2 /ai | |
parent | d3a98e09618594016a0d2b7c60e49a64efee3fab (diff) | |
download | openttd-e91fa54a157e73958e2bc7cbf212c8ef7df75d6b.tar.xz |
(svn r4128) - CodeChange: Add proper semantics for CargoID for such variables instead of using the general byte-type.
Diffstat (limited to 'ai')
-rw-r--r-- | ai/default/default.c | 12 | ||||
-rw-r--r-- | ai/trolly/trolly.c | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/ai/default/default.c b/ai/default/default.c index 7b89d0b1f..cb17433e6 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -156,7 +156,7 @@ static EngineID AiChooseTrainToBuild(byte railtype, int32 money, byte flag, Tile return best_veh_index; } -static EngineID AiChooseRoadVehToBuild(byte cargo, int32 money, TileIndex tile) +static EngineID AiChooseRoadVehToBuild(CargoID cargo, int32 money, TileIndex tile) { EngineID best_veh_index = INVALID_ENGINE; int32 best_veh_cost = 0; @@ -431,7 +431,7 @@ static void AiStateDoReplaceVehicle(Player *p) typedef struct FoundRoute { int distance; - byte cargo; + CargoID cargo; void *from; void *to; } FoundRoute; @@ -451,7 +451,7 @@ static Industry *AiFindRandomIndustry(void) static void AiFindSubsidyIndustryRoute(FoundRoute *fr) { uint i; - byte cargo; + CargoID cargo; Subsidy *s; Industry *from, *to_ind; Town *to_tow; @@ -468,7 +468,7 @@ static void AiFindSubsidyIndustryRoute(FoundRoute *fr) // Don't want passengers or mail cargo = s->cargo_type; - if (cargo == 0xFF || cargo == CT_PASSENGERS || cargo == CT_MAIL || s->age > 7) + if (cargo == CT_INVALID || cargo == CT_PASSENGERS || cargo == CT_MAIL || s->age > 7) return; fr->cargo = cargo; @@ -522,7 +522,7 @@ static void AiFindRandomIndustryRoute(FoundRoute *fr) Industry *i,*i2; Town *t; uint32 r; - byte cargo; + CargoID cargo; // initially error fr->distance = -1; @@ -535,7 +535,7 @@ static void AiFindRandomIndustryRoute(FoundRoute *fr) // pick a random produced cargo cargo = i->produced_cargo[0]; - if (r & 1 && i->produced_cargo[1] != 0xFF) cargo = i->produced_cargo[1]; + if (r & 1 && i->produced_cargo[1] != CT_INVALID) cargo = i->produced_cargo[1]; fr->cargo = cargo; diff --git a/ai/trolly/trolly.c b/ai/trolly/trolly.c index 9f00579cb..006e04850 100644 --- a/ai/trolly/trolly.c +++ b/ai/trolly/trolly.c @@ -286,7 +286,7 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type) // No limits on delevering stations! // Or for industry that does not give anything yet - if (i->produced_cargo[0] == 0xFF || i->total_production[0] == 0) return true; + if (i->produced_cargo[0] == CT_INVALID || i->total_production[0] == 0) return true; if (i->total_production[0] - i->total_transported[0] < AI_CHECKCITY_NEEDED_CARGO) return false; @@ -312,7 +312,7 @@ static bool AiNew_Check_City_or_Industry(Player *p, int ic, byte type) // we want to know if this station gets the same good. If so, // we want to know its rating. If it is too high, we are not going // to build there - if (i->produced_cargo[0] == 0xFF) continue; + if (i->produced_cargo[0] == CT_INVALID) continue; // It does not take this cargo if (!st->goods[i->produced_cargo[0]].last_speed) continue; // Is it around our industry @@ -464,9 +464,9 @@ static void AiNew_State_LocateRoute(Player *p) int i; // TODO: in max_cargo, also check other cargo (beside [0]) // First we check if the from_ic produces cargo that this ic accepts - if (GetIndustry(p->ainew.from_ic)->produced_cargo[0] != 0xFF && GetIndustry(p->ainew.from_ic)->total_production[0] != 0) { + if (GetIndustry(p->ainew.from_ic)->produced_cargo[0] != CT_INVALID && GetIndustry(p->ainew.from_ic)->total_production[0] != 0) { for (i=0;i<3;i++) { - if (GetIndustry(p->ainew.temp)->accepts_cargo[i] == 0xFF) break; + if (GetIndustry(p->ainew.temp)->accepts_cargo[i] == CT_INVALID) break; if (GetIndustry(p->ainew.from_ic)->produced_cargo[0] == GetIndustry(p->ainew.temp)->accepts_cargo[i]) { // Found a compatbiel industry max_cargo = GetIndustry(p->ainew.from_ic)->total_production[0] - GetIndustry(p->ainew.from_ic)->total_transported[0]; @@ -477,10 +477,10 @@ static void AiNew_State_LocateRoute(Player *p) } } } - if (!found && GetIndustry(p->ainew.temp)->produced_cargo[0] != 0xFF && GetIndustry(p->ainew.temp)->total_production[0] != 0) { + if (!found && GetIndustry(p->ainew.temp)->produced_cargo[0] != CT_INVALID && GetIndustry(p->ainew.temp)->total_production[0] != 0) { // If not check if the current ic produces cargo that the from_ic accepts for (i=0;i<3;i++) { - if (GetIndustry(p->ainew.from_ic)->accepts_cargo[i] == 0xFF) break; + if (GetIndustry(p->ainew.from_ic)->accepts_cargo[i] == CT_INVALID) break; if (GetIndustry(p->ainew.temp)->produced_cargo[0] == GetIndustry(p->ainew.from_ic)->accepts_cargo[i]) { // Found a compatbiel industry found = true; |