mirror of https://github.com/OpenTTD/OpenTTD
(svn r4128) - CodeChange: Add proper semantics for CargoID for such variables instead of using the general byte-type.
parent
76f1609ee1
commit
d5909f901a
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
14
economy.c
14
economy.c
|
@ -908,7 +908,7 @@ void DeleteSubsidyWithStation(uint16 index)
|
|||
|
||||
typedef struct FoundRoute {
|
||||
uint distance;
|
||||
byte cargo;
|
||||
CargoID cargo;
|
||||
void *from;
|
||||
void *to;
|
||||
} FoundRoute;
|
||||
|
@ -934,7 +934,7 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
|
|||
{
|
||||
Industry *i;
|
||||
int trans, total;
|
||||
byte cargo;
|
||||
CargoID cargo;
|
||||
|
||||
fr->distance = (uint)-1;
|
||||
|
||||
|
@ -1102,9 +1102,9 @@ static void Load_SUBS(void)
|
|||
SlObject(&_subsidies[index], _subsidies_desc);
|
||||
}
|
||||
|
||||
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type)
|
||||
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type)
|
||||
{
|
||||
int cargo = cargo_type;
|
||||
CargoID cargo = cargo_type;
|
||||
byte f;
|
||||
|
||||
/* zero the distance if it's the bank and very short transport. */
|
||||
|
@ -1131,7 +1131,7 @@ int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, b
|
|||
return BIGMULSS(dist * f * num_pieces, _cargo_payment_rates[cargo], 21);
|
||||
}
|
||||
|
||||
static void DeliverGoodsToIndustry(TileIndex xy, byte cargo_type, int num_pieces)
|
||||
static void DeliverGoodsToIndustry(TileIndex xy, CargoID cargo_type, int num_pieces)
|
||||
{
|
||||
Industry* best = NULL;
|
||||
Industry* ind;
|
||||
|
@ -1162,7 +1162,7 @@ static void DeliverGoodsToIndustry(TileIndex xy, byte cargo_type, int num_pieces
|
|||
}
|
||||
}
|
||||
|
||||
static bool CheckSubsidised(Station *from, Station *to, byte cargo_type)
|
||||
static bool CheckSubsidised(Station *from, Station *to, CargoID cargo_type)
|
||||
{
|
||||
Subsidy *s;
|
||||
TileIndex xy;
|
||||
|
@ -1230,7 +1230,7 @@ static bool CheckSubsidised(Station *from, Station *to, byte cargo_type)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int32 DeliverGoods(int num_pieces, byte cargo_type, uint16 source, uint16 dest, byte days_in_transit)
|
||||
static int32 DeliverGoods(int num_pieces, CargoID cargo_type, uint16 source, uint16 dest, byte days_in_transit)
|
||||
{
|
||||
bool subsidised;
|
||||
Station *s_from, *s_to;
|
||||
|
|
|
@ -21,7 +21,7 @@ typedef struct {
|
|||
VARDEF Economy _economy;
|
||||
|
||||
typedef struct Subsidy {
|
||||
byte cargo_type;
|
||||
CargoID cargo_type;
|
||||
byte age;
|
||||
uint16 from;
|
||||
uint16 to;
|
||||
|
@ -64,7 +64,7 @@ Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode);
|
|||
void DeleteSubsidyWithIndustry(uint16 index);
|
||||
void DeleteSubsidyWithStation(uint16 index);
|
||||
|
||||
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, byte cargo_type);
|
||||
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type);
|
||||
uint MoveGoodsToStation(TileIndex tile, int w, int h, int type, uint amount);
|
||||
|
||||
#endif /* ECONOMY_H */
|
||||
|
|
6
engine.h
6
engine.h
|
@ -20,7 +20,7 @@ typedef struct RailVehicleInfo {
|
|||
byte running_cost_class;
|
||||
byte engclass; // 0: steam, 1: diesel, 2: electric
|
||||
byte capacity;
|
||||
byte cargo_type;
|
||||
CargoID cargo_type;
|
||||
byte ai_rank;
|
||||
byte callbackmask; // see CallbackMask enum
|
||||
uint16 pow_wag_power;
|
||||
|
@ -36,7 +36,7 @@ typedef struct ShipVehicleInfo {
|
|||
byte image_index;
|
||||
byte base_cost;
|
||||
uint16 max_speed;
|
||||
byte cargo_type;
|
||||
CargoID cargo_type;
|
||||
uint16 capacity;
|
||||
byte running_cost;
|
||||
byte sfx;
|
||||
|
@ -64,7 +64,7 @@ typedef struct RoadVehicleInfo {
|
|||
byte sfx;
|
||||
byte max_speed;
|
||||
byte capacity;
|
||||
byte cargo_type;
|
||||
CargoID cargo_type;
|
||||
byte callbackmask;
|
||||
} RoadVehicleInfo;
|
||||
|
||||
|
|
|
@ -693,7 +693,8 @@ static void CargoPaymentRatesWndProc(Window *w, WindowEvent *e)
|
|||
{
|
||||
switch (e->event) {
|
||||
case WE_PAINT: {
|
||||
int i, j, x, y;
|
||||
int j, x, y;
|
||||
CargoID i;
|
||||
GraphDrawer gd;
|
||||
|
||||
gd.sel = _legend_cargobits;
|
||||
|
|
|
@ -10,10 +10,10 @@ struct Industry {
|
|||
byte width; /* swapped order of w/h with town */
|
||||
byte height;
|
||||
const Town* town;
|
||||
byte produced_cargo[2];
|
||||
CargoID produced_cargo[2];
|
||||
uint16 cargo_waiting[2];
|
||||
byte production_rate[2];
|
||||
byte accepts_cargo[3];
|
||||
CargoID accepts_cargo[3];
|
||||
byte prod_level;
|
||||
uint16 last_mo_production[2];
|
||||
uint16 last_mo_transported[2];
|
||||
|
|
|
@ -82,9 +82,9 @@ typedef struct IndustrySpec {
|
|||
const IndustryTileTable *const *table;
|
||||
byte num_table;
|
||||
byte a,b,c;
|
||||
byte produced_cargo[2];
|
||||
CargoID produced_cargo[2];
|
||||
byte production_rate[2];
|
||||
byte accepts_cargo[3];
|
||||
CargoID accepts_cargo[3];
|
||||
byte check_proc;
|
||||
} IndustrySpec;
|
||||
|
||||
|
@ -858,7 +858,7 @@ static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void GetProducedCargo_Industry(TileIndex tile, byte *b)
|
||||
static void GetProducedCargo_Industry(TileIndex tile, CargoID *b)
|
||||
{
|
||||
const Industry* i = GetIndustryByTile(tile);
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ static const SpriteGroup* ResolveVehicleSpriteGroup(const SpriteGroup *spritegro
|
|||
static const SpriteGroup *GetVehicleSpriteGroup(EngineID engine, const Vehicle *v)
|
||||
{
|
||||
const SpriteGroup *group;
|
||||
byte cargo = GC_PURCHASE;
|
||||
CargoID cargo = GC_PURCHASE;
|
||||
|
||||
if (v != NULL) {
|
||||
cargo = _global_cargo_id[_opt.landscape][v->cargo_type];
|
||||
|
|
|
@ -320,7 +320,7 @@ typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
|
|||
* above.
|
||||
*/
|
||||
typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode);
|
||||
typedef void GetProducedCargoProc(TileIndex tile, byte *b);
|
||||
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
|
||||
typedef void ClickTileProc(TileIndex tile);
|
||||
typedef void AnimateTileProc(TileIndex tile);
|
||||
typedef void TileLoopProc(TileIndex tile);
|
||||
|
|
6
player.h
6
player.h
|
@ -26,7 +26,7 @@ typedef struct AiBuildRec {
|
|||
byte buildcmd_a;
|
||||
byte buildcmd_b;
|
||||
byte direction;
|
||||
byte cargo;
|
||||
CargoID cargo;
|
||||
} AiBuildRec;
|
||||
|
||||
typedef struct PlayerAI {
|
||||
|
@ -39,7 +39,7 @@ typedef struct PlayerAI {
|
|||
byte banned_tile_count;
|
||||
byte railtype_to_use;
|
||||
|
||||
byte cargo_type;
|
||||
CargoID cargo_type;
|
||||
byte num_wagons;
|
||||
byte build_kind;
|
||||
byte num_build_rec;
|
||||
|
@ -111,7 +111,7 @@ typedef struct PlayerAiNew {
|
|||
|
||||
// Route stuff
|
||||
|
||||
byte cargo;
|
||||
CargoID cargo;
|
||||
byte tbt; // train/bus/truck 0/1/2 AI_TRAIN/AI_BUS/AI_TRUCK
|
||||
int new_cost;
|
||||
|
||||
|
|
|
@ -554,7 +554,7 @@ void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile,
|
|||
|
||||
gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc;
|
||||
if (gpc != NULL) {
|
||||
byte cargos[2] = { CT_INVALID, CT_INVALID };
|
||||
CargoID cargos[2] = { CT_INVALID, CT_INVALID };
|
||||
|
||||
gpc(tile, cargos);
|
||||
if (cargos[0] != CT_INVALID) {
|
||||
|
|
|
@ -178,7 +178,7 @@ struct Vehicle {
|
|||
byte vehstatus; // Status
|
||||
uint16 last_station_visited;
|
||||
|
||||
byte cargo_type; // type of cargo this vehicle is carrying
|
||||
CargoID cargo_type; // type of cargo this vehicle is carrying
|
||||
byte cargo_days; // how many days have the pieces been in transit
|
||||
uint16 cargo_source;// source of cargo
|
||||
uint16 cargo_cap; // total capacity
|
||||
|
|
Loading…
Reference in New Issue