Changeset - r12405:ba094e765533
[Not reviewed]
src/ai/api/ai_cargo.cpp
Show inline comments
 
@@ -11,13 +11,13 @@
 

	
 
/* static */ bool AICargo::IsValidCargo(CargoID cargo_type)
 
{
 
	return (cargo_type < NUM_CARGO && ::GetCargo(cargo_type)->IsValid());
 
	return (cargo_type < NUM_CARGO && ::CargoSpec::Get(cargo_type)->IsValid());
 
}
 

	
 
/* static */ char *AICargo::GetCargoLabel(CargoID cargo_type)
 
{
 
	if (!IsValidCargo(cargo_type)) return NULL;
 
	const CargoSpec *cargo = ::GetCargo(cargo_type);
 
	const CargoSpec *cargo = ::CargoSpec::Get(cargo_type);
 

	
 
	/* cargo->label is a uint32 packing a 4 character non-terminated string,
 
	 * like "PASS", "COAL", "OIL_". New ones can be defined by NewGRFs */
 
@@ -32,7 +32,7 @@
 
/* static */ bool AICargo::IsFreight(CargoID cargo_type)
 
{
 
	if (!IsValidCargo(cargo_type)) return false;
 
	const CargoSpec *cargo = ::GetCargo(cargo_type);
 
	const CargoSpec *cargo = ::CargoSpec::Get(cargo_type);
 
	return cargo->is_freight;
 
}
 

	
 
@@ -46,7 +46,7 @@
 
{
 
	if (!IsValidCargo(cargo_type)) return TE_NONE;
 

	
 
	return (AICargo::TownEffect)GetCargo(cargo_type)->town_effect;
 
	return (AICargo::TownEffect)CargoSpec::Get(cargo_type)->town_effect;
 
}
 

	
 
/* static */ Money AICargo::GetCargoIncome(CargoID cargo_type, uint32 distance, uint32 days_in_transit)
src/ai/api/ai_cargolist.cpp
Show inline comments
 
@@ -11,7 +11,7 @@
 
AICargoList::AICargoList()
 
{
 
	for (byte i = 0; i < NUM_CARGO; i++) {
 
		const CargoSpec *c = ::GetCargo(i);
 
		const CargoSpec *c = ::CargoSpec::Get(i);
 
		if (c->IsValid()) {
 
			this->AddItem(i);
 
		}
src/ai/api/ai_subsidy.cpp
Show inline comments
 
@@ -57,8 +57,8 @@
 
{
 
	if (!IsValidSubsidy(subsidy_id) || IsAwarded(subsidy_id)) return false;
 

	
 
	return GetCargo(GetCargoType(subsidy_id))->town_effect == TE_PASSENGERS ||
 
	       GetCargo(GetCargoType(subsidy_id))->town_effect == TE_MAIL;
 
	return CargoSpec::Get(GetCargoType(subsidy_id))->town_effect == TE_PASSENGERS ||
 
	       CargoSpec::Get(GetCargoType(subsidy_id))->town_effect == TE_MAIL;
 
}
 

	
 
/* static */ int32 AISubsidy::GetSource(SubsidyID subsidy_id)
 
@@ -72,7 +72,7 @@
 
{
 
	if (!IsValidSubsidy(subsidy_id) || IsAwarded(subsidy_id)) return false;
 

	
 
	switch (GetCargo(GetCargoType(subsidy_id))->town_effect) {
 
	switch (CargoSpec::Get(GetCargoType(subsidy_id))->town_effect) {
 
		case TE_PASSENGERS:
 
		case TE_MAIL:
 
		case TE_GOODS:
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -445,7 +445,7 @@ static int DrawRailWagonPurchaseInfo(int
 
	/* Wagon weight - (including cargo) */
 
	uint weight = e->GetDisplayWeight();
 
	SetDParam(0, weight);
 
	uint cargo_weight = (e->CanCarryCargo() ? GetCargo(e->GetDefaultCargoType())->weight * e->GetDisplayDefaultCapacity() >> 4 : 0);
 
	uint cargo_weight = (e->CanCarryCargo() ? CargoSpec::Get(e->GetDefaultCargoType())->weight * e->GetDisplayDefaultCapacity() >> 4 : 0);
 
	SetDParam(1, cargo_weight + weight);
 
	DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
 
	y += FONT_HEIGHT_NORMAL;
 
@@ -821,7 +821,7 @@ struct BuildVehicleWindow : Window {
 

	
 
		/* Collect available cargo types for filtering */
 
		for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
 
			const CargoSpec *cargo = GetCargo(cid);
 
			const CargoSpec *cargo = CargoSpec::Get(cid);
 
			if (!cargo->IsValid()) continue;
 
			if (IsCargoInClass(cid, CC_SPECIAL)) continue; // exclude fake cargo types
 
			this->cargo_filter[filter_items] = cid;
src/cargotype.cpp
Show inline comments
 
@@ -11,7 +11,7 @@
 
#include "table/strings.h"
 
#include "table/cargo_const.h"
 

	
 
CargoSpec _cargo[NUM_CARGO];
 
CargoSpec CargoSpec::cargo[NUM_CARGO];
 

	
 
/* Bitmask of cargo types available */
 
uint32 _cargo_mask;
 
@@ -22,8 +22,8 @@ void SetupCargoForClimate(LandscapeID l)
 
	assert(l < lengthof(_default_climate_cargo));
 

	
 
	/* Reset and disable all cargo types */
 
	memset(_cargo, 0, sizeof(_cargo));
 
	for (CargoID i = 0; i < lengthof(_cargo); i++) _cargo[i].bitnum = INVALID_CARGO;
 
	memset(CargoSpec::cargo, 0, sizeof(CargoSpec::cargo));
 
	for (CargoID i = 0; i < lengthof(CargoSpec::cargo); i++) CargoSpec::Get(i)->bitnum = INVALID_CARGO;
 

	
 
	_cargo_mask = 0;
 

	
 
@@ -33,8 +33,9 @@ void SetupCargoForClimate(LandscapeID l)
 
		/* Bzzt: check if cl is just an index into the cargo table */
 
		if (cl < lengthof(_default_cargo)) {
 
			/* Copy the indexed cargo */
 
			_cargo[i] = _default_cargo[cl];
 
			if (_cargo[i].bitnum != INVALID_CARGO) SetBit(_cargo_mask, i);
 
			CargoSpec *cargo = CargoSpec::Get(i);
 
			*cargo = _default_cargo[cl];
 
			if (cargo->bitnum != INVALID_CARGO) SetBit(_cargo_mask, i);
 
			continue;
 
		}
 

	
 
@@ -42,7 +43,7 @@ void SetupCargoForClimate(LandscapeID l)
 
		 * the label matches */
 
		for (uint j = 0; j < lengthof(_default_cargo); j++) {
 
			if (_default_cargo[j].label == cl) {
 
				_cargo[i] = _default_cargo[j];
 
				*CargoSpec::Get(i) = _default_cargo[j];
 

	
 
				/* Populate the available cargo mask */
 
				SetBit(_cargo_mask, i);
 
@@ -55,9 +56,10 @@ void SetupCargoForClimate(LandscapeID l)
 

	
 
CargoID GetCargoIDByLabel(CargoLabel cl)
 
{
 
	for (CargoID c = 0; c < lengthof(_cargo); c++) {
 
		if (_cargo[c].bitnum == INVALID_CARGO) continue;
 
		if (_cargo[c].label == cl) return c;
 
	for (CargoID c = 0; c < lengthof(CargoSpec::cargo); c++) {
 
		CargoSpec *cargo = CargoSpec::Get(c);
 
		if (cargo->bitnum == INVALID_CARGO) continue;
 
		if (cargo->label == cl) return c;
 
	}
 

	
 
	/* No matching label was found, so it is invalid */
 
@@ -73,8 +75,8 @@ CargoID GetCargoIDByBitnum(uint8 bitnum)
 
{
 
	if (bitnum == INVALID_CARGO) return CT_INVALID;
 

	
 
	for (CargoID c = 0; c < lengthof(_cargo); c++) {
 
		if (_cargo[c].bitnum == bitnum) return c;
 
	for (CargoID c = 0; c < lengthof(CargoSpec::cargo); c++) {
 
		if (CargoSpec::Get(c)->bitnum == bitnum) return c;
 
	}
 

	
 
	/* No matching label was found, so it is invalid */
src/cargotype.h
Show inline comments
 
@@ -54,11 +54,27 @@ struct CargoSpec {
 
	{
 
		return this->bitnum != INVALID_CARGO;
 
	}
 

	
 
	/**
 
	 * Retrieve cargo details for the given cargo ID
 
	 * @param c ID of cargo
 
	 * @pre c is a valid cargo ID
 
	 */
 
	static CargoSpec *Get(CargoID c)
 
	{
 
		assert(c < lengthof(CargoSpec::cargo));
 
		return &CargoSpec::cargo[c];
 
	}
 

	
 
private:
 
	static CargoSpec cargo[NUM_CARGO];
 

	
 
	friend void SetupCargoForClimate(LandscapeID l);
 
	friend CargoID GetCargoIDByLabel(CargoLabel cl);
 
	friend CargoID GetCargoIDByBitnum(uint8 bitnum);
 
};
 

	
 
extern uint32 _cargo_mask;
 
extern CargoSpec _cargo[NUM_CARGO];
 

	
 

	
 
/* Set up the default cargo types for the given landscape type */
 
void SetupCargoForClimate(LandscapeID l);
 
@@ -68,18 +84,9 @@ SpriteID GetCargoSprite(CargoID i);
 
CargoID GetCargoIDByLabel(CargoLabel cl);
 
CargoID GetCargoIDByBitnum(uint8 bitnum);
 

	
 
/* Retrieve cargo details for the given cargo ID */
 
static inline const CargoSpec *GetCargo(CargoID c)
 
static inline bool IsCargoInClass(CargoID c, uint16 cc)
 
{
 
	assert(c < lengthof(_cargo));
 
	return &_cargo[c];
 
	return (CargoSpec::Get(c)->classes & cc) != 0;
 
}
 

	
 

	
 
static inline bool IsCargoInClass(CargoID c, uint16 cc)
 
{
 
	return (GetCargo(c)->classes & cc) != 0;
 
}
 

	
 

	
 
#endif /* CARGOTYPE_H */
src/economy.cpp
Show inline comments
 
@@ -833,7 +833,7 @@ void ResetEconomy()
 
	bool needed = false;
 

	
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		const CargoSpec *cs = GetCargo(c);
 
		const CargoSpec *cs = CargoSpec::Get(c);
 
		if (!cs->IsValid()) continue;
 
		if (_cargo_payment_rates[c] == 0) {
 
			needed = true;
 
@@ -866,7 +866,7 @@ Money GetPriceByIndex(uint8 index)
 

	
 
Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type)
 
{
 
	const CargoSpec *cs = GetCargo(cargo_type);
 
	const CargoSpec *cs = CargoSpec::Get(cargo_type);
 

	
 
	/* Use callback to calculate cargo profit, if available */
 
	if (HasBit(cs->callback_mask, CBM_CARGO_PROFIT_CALC)) {
 
@@ -1089,7 +1089,7 @@ static Money DeliverGoods(int num_pieces
 
	}
 

	
 
	/* Increase town's counter for some special goods types */
 
	const CargoSpec *cs = GetCargo(cargo_type);
 
	const CargoSpec *cs = CargoSpec::Get(cargo_type);
 
	if (cs->town_effect == TE_FOOD) s_to->town->new_act_food += num_pieces;
 
	if (cs->town_effect == TE_WATER) s_to->town->new_act_water += num_pieces;
 

	
src/graph_gui.cpp
Show inline comments
 
@@ -737,7 +737,7 @@ struct PaymentRatesGraphWindow : BaseGra
 
	{
 
		uint num_active = 0;
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			if (GetCargo(c)->IsValid()) num_active++;
 
			if (CargoSpec::Get(c)->IsValid()) num_active++;
 
		}
 

	
 
		/* Resize the window to fit the cargo types */
 
@@ -787,7 +787,7 @@ struct PaymentRatesGraphWindow : BaseGra
 

	
 
		uint i = 0;
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			const CargoSpec *cs = GetCargo(c);
 
			const CargoSpec *cs = CargoSpec::Get(c);
 
			if (!cs->IsValid()) continue;
 

	
 
			/* Only draw labels for widgets that exist. If the widget doesn't
src/industry_cmd.cpp
Show inline comments
 
@@ -2076,7 +2076,7 @@ static void ReportNewsProductionChangeIn
 
		default: NOT_REACHED();
 
	}
 
	SetDParam(2, abs(percent));
 
	SetDParam(0, GetCargo(type)->name);
 
	SetDParam(0, CargoSpec::Get(type)->name);
 
	SetDParam(1, ind->index);
 
	AddIndustryNewsItem(
 
		percent >= 0 ? STR_NEWS_INDUSTRY_PRODUCTION_INCREASE_SMOOTH : STR_NEWS_INDUSTRY_PRODUCTION_DECREASE_SMOOTH,
src/industry_gui.cpp
Show inline comments
 
@@ -261,7 +261,7 @@ public:
 
		for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++) {
 
			if (indsp->accepts_cargo[j] == CT_INVALID) continue;
 
			if (p > 0) str++;
 
			SetDParam(p++, GetCargo(indsp->accepts_cargo[j])->name);
 
			SetDParam(p++, CargoSpec::Get(indsp->accepts_cargo[j])->name);
 
			SetDParam(p++, GetCargoSuffix(j, CST_FUND, NULL, this->selected_type, indsp));
 
		}
 
		DrawString(x_str, right, y_str, str);
 
@@ -275,7 +275,7 @@ public:
 
		for (byte j = 0; j < lengthof(indsp->produced_cargo); j++) {
 
			if (indsp->produced_cargo[j] == CT_INVALID) continue;
 
			if (p > 0) str++;
 
			SetDParam(p++, GetCargo(indsp->produced_cargo[j])->name);
 
			SetDParam(p++, CargoSpec::Get(indsp->produced_cargo[j])->name);
 
			SetDParam(p++, GetCargoSuffix(j + 3, CST_FUND, NULL, this->selected_type, indsp));
 
		}
 
		DrawString(x_str, right, y_str, str);
 
@@ -522,7 +522,7 @@ public:
 
				if (i->accepts_cargo[j] == CT_INVALID) continue;
 
				has_accept = true;
 
				if (p > 0) str++;
 
				SetDParam(p++, GetCargo(i->accepts_cargo[j])->name);
 
				SetDParam(p++, CargoSpec::Get(i->accepts_cargo[j])->name);
 
				SetDParam(p++, GetCargoSuffix(j, CST_VIEW, i, i->type, ind));
 
			}
 
			if (has_accept) {
src/misc.cpp
Show inline comments
 
@@ -133,7 +133,7 @@ void InitializeLandscapeVariables(bool o
 
	if (only_constants) return;
 

	
 
	for (CargoID i = 0; i < NUM_CARGO; i++) {
 
		_cargo_payment_rates[i] = GetCargo(i)->initial_payment;
 
		_cargo_payment_rates[i] = CargoSpec::Get(i)->initial_payment;
 
		_cargo_payment_rates_frac[i] = 0;
 
	}
 
}
src/misc_gui.cpp
Show inline comments
 
@@ -240,10 +240,10 @@ public:
 
				/* If the accepted value is less than 8, show it in 1/8:ths */
 
				if (acceptance[i] < 8) {
 
					SetDParam(0, acceptance[i]);
 
					SetDParam(1, GetCargo(i)->name);
 
					SetDParam(1, CargoSpec::Get(i)->name);
 
					strp = GetString(strp, STR_LAND_AREA_INFORMATION_CARGO_EIGHTS, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
				} else {
 
					strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
					strp = GetString(strp, CargoSpec::Get(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
				}
 
			}
 
		}
 
@@ -834,7 +834,7 @@ static int DrawStationCoverageText(const
 
				*b++ = ',';
 
				*b++ = ' ';
 
			}
 
			b = InlineString(b, GetCargo(i)->name);
 
			b = InlineString(b, CargoSpec::Get(i)->name);
 
		}
 
	}
 

	
src/newgrf.cpp
Show inline comments
 
@@ -1506,7 +1506,7 @@ static ChangeInfoResult TownHouseChangeI
 
				 * climate. This can cause problems when copying the properties
 
				 * of a house that accepts food, where the new house is valid
 
				 * in the temperate climate. */
 
				if (!GetCargo(housespec->accepts_cargo[2])->IsValid()) {
 
				if (!CargoSpec::Get(housespec->accepts_cargo[2])->IsValid()) {
 
					housespec->cargo_acceptance[2] = 0;
 
				}
 

	
 
@@ -1552,7 +1552,7 @@ static ChangeInfoResult TownHouseChangeI
 
						((_settings_game.game_creation.landscape == LT_TOYLAND) ? CT_FIZZY_DRINKS : CT_FOOD);
 

	
 
				/* Make sure the cargo type is valid in this climate. */
 
				if (!GetCargo(cid)->IsValid()) goods = 0;
 
				if (!CargoSpec::Get(cid)->IsValid()) goods = 0;
 

	
 
				housespec->accepts_cargo[2] = cid;
 
				housespec->cargo_acceptance[2] = abs(goods); // but we do need positive value here
 
@@ -1897,7 +1897,7 @@ static ChangeInfoResult CargoChangeInfo(
 
	}
 

	
 
	for (int i = 0; i < numinfo; i++) {
 
		CargoSpec *cs = &_cargo[cid + i];
 
		CargoSpec *cs = CargoSpec::Get(cid + i);
 

	
 
		switch (prop) {
 
			case 0x08: // Bit number of cargo
 
@@ -2995,7 +2995,7 @@ static CargoID TranslateCargo(uint8 feat
 
		}
 

	
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			const CargoSpec *cs = GetCargo(c);
 
			const CargoSpec *cs = CargoSpec::Get(c);
 
			if (!cs->IsValid()) continue;
 

	
 
			if (cs->bitnum == ctype) {
 
@@ -3290,7 +3290,7 @@ static void CargoMapSpriteGroup(byte *bu
 
			continue;
 
		}
 

	
 
		CargoSpec *cs = &_cargo[cid];
 
		CargoSpec *cs = CargoSpec::Get(cid);
 
		cs->grffile = _cur_grffile;
 
		cs->group = _cur_grffile->spritegroups[groupid];
 
	}
 
@@ -5587,7 +5587,7 @@ static void BuildCargoTranslationMap()
 
	memset(_cur_grffile->cargo_map, 0xFF, sizeof(_cur_grffile->cargo_map));
 

	
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		const CargoSpec *cs = GetCargo(c);
 
		const CargoSpec *cs = CargoSpec::Get(c);
 
		if (!cs->IsValid()) continue;
 

	
 
		if (_cur_grffile->cargo_max == 0) {
 
@@ -5699,7 +5699,7 @@ static void CalculateRefitMasks()
 
			} else {
 
				/* No cargo table, so use the cargo bitnum values */
 
				for (CargoID c = 0; c < NUM_CARGO; c++) {
 
					const CargoSpec *cs = GetCargo(c);
 
					const CargoSpec *cs = CargoSpec::Get(c);
 
					if (!cs->IsValid()) continue;
 

	
 
					if (HasBit(ei->refit_mask, cs->bitnum)) SetBit(xor_mask, c);
 
@@ -5710,7 +5710,7 @@ static void CalculateRefitMasks()
 
		if (_gted[engine].cargo_allowed != 0) {
 
			/* Build up the list of cargo types from the set cargo classes. */
 
			for (CargoID i = 0; i < NUM_CARGO; i++) {
 
				const CargoSpec *cs = GetCargo(i);
 
				const CargoSpec *cs = CargoSpec::Get(i);
 
				if (_gted[engine].cargo_allowed    & cs->classes) SetBit(mask,     i);
 
				if (_gted[engine].cargo_disallowed & cs->classes) SetBit(not_mask, i);
 
			}
src/newgrf_cargo.cpp
Show inline comments
 
@@ -122,7 +122,7 @@ CargoID GetCargoTranslation(uint8 cargo,
 
uint8 GetReverseCargoTranslation(CargoID cargo, const GRFFile *grffile)
 
{
 
	/* Note: All grf versions use CargoBit here. Pre-version 7 do NOT use the 'climate dependent' ID. */
 
	const CargoSpec *cs = GetCargo(cargo);
 
	const CargoSpec *cs = CargoSpec::Get(cargo);
 

	
 
	/* If the GRF contains a translation table (and the cargo is in the table)
 
	 * then get the cargo ID for the label */
src/newgrf_engine.cpp
Show inline comments
 
@@ -493,7 +493,7 @@ static uint32 VehicleGetVariable(const R
 
				const Engine *e = Engine::Get(object->u.vehicle.self_type);
 
				CargoID cargo_type = e->GetDefaultCargoType();
 
				if (cargo_type != CT_INVALID) {
 
					const CargoSpec *cs = GetCargo(cargo_type);
 
					const CargoSpec *cs = CargoSpec::Get(cargo_type);
 
					return (cs->classes << 16) | (cs->weight << 8) | GetEngineGRF(e->index)->cargo_map[cargo_type];
 
				} else {
 
					return 0x000000FF;
 
@@ -549,7 +549,7 @@ static uint32 VehicleGetVariable(const R
 
					/* Skip empty engines */
 
					if (u->cargo_cap == 0) continue;
 

	
 
					cargo_classes |= GetCargo(u->cargo_type)->classes;
 
					cargo_classes |= CargoSpec::Get(u->cargo_type)->classes;
 
					common_cargos[u->cargo_type]++;
 
				}
 

	
 
@@ -579,7 +579,7 @@ static uint32 VehicleGetVariable(const R
 
					}
 
				}
 

	
 
				uint8 common_bitnum = (common_cargo_type == CT_INVALID ? 0xFF : GetCargo(common_cargo_type)->bitnum);
 
				uint8 common_bitnum = (common_cargo_type == CT_INVALID ? 0xFF : CargoSpec::Get(common_cargo_type)->bitnum);
 
				v->vcache.cached_var42 = cargo_classes | (common_bitnum << 8) | (common_subtype << 16) | (user_def_data << 24);
 
				SetBit(v->vcache.cache_valid, 2);
 
			}
 
@@ -652,7 +652,7 @@ static uint32 VehicleGetVariable(const R
 
			 * ww - cargo unit weight in 1/16 tons, same as cargo prop. 0F.
 
			 * cccc - the cargo class value of the cargo transported by the vehicle.
 
			 */
 
			const CargoSpec *cs = GetCargo(v->cargo_type);
 
			const CargoSpec *cs = CargoSpec::Get(v->cargo_type);
 

	
 
			return (cs->classes << 16) | (cs->weight << 8) | GetEngineGRF(v->engine_type)->cargo_map[v->cargo_type];
 
		}
src/newgrf_station.cpp
Show inline comments
 
@@ -611,7 +611,7 @@ static const SpriteGroup *ResolveStation
 
	} else {
 
		/* Pick the first cargo that we have waiting */
 
		for (CargoID cargo = 0; cargo < NUM_CARGO; cargo++) {
 
			const CargoSpec *cs = GetCargo(cargo);
 
			const CargoSpec *cs = CargoSpec::Get(cargo);
 
			if (cs->IsValid() && object->u.station.statspec->spritegroup[cargo] != NULL &&
 
					!object->u.station.st->goods[cargo].cargo.Empty()) {
 
				ctype = cargo;
src/order_gui.cpp
Show inline comments
 
@@ -248,7 +248,7 @@ void DrawOrderString(const Vehicle *v, c
 

	
 
			if (!timetable && order->IsRefit()) {
 
				SetDParam(6, (order->GetDepotActionType() & ODATFB_HALT) ? STR_REFIT_STOP_ORDER : STR_REFIT_ORDER);
 
				SetDParam(7, GetCargo(order->GetRefitCargo())->name);
 
				SetDParam(7, CargoSpec::Get(order->GetRefitCargo())->name);
 
			}
 
			break;
 

	
src/saveload/afterload.cpp
Show inline comments
 
@@ -1924,7 +1924,7 @@ bool AfterLoadGame()
 
				const Station *to = Station::GetIfValid(s->to);
 
				if (from != NULL && to != NULL && from->owner == to->owner && Company::IsValidID(from->owner)) continue;
 
			} else {
 
				const CargoSpec *cs = GetCargo(s->cargo_type);
 
				const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
 
				switch (cs->town_effect) {
 
					case TE_PASSENGERS:
 
					case TE_MAIL:
src/station_cmd.cpp
Show inline comments
 
@@ -137,7 +137,7 @@ static bool CMSAMine(TileIndex tile)
 
		/* The industry extracts something non-liquid, i.e. no oil or plastic, so it is a mine.
 
		 * Also the production of passengers and mail is ignored. */
 
		if (ind->produced_cargo[i] != CT_INVALID &&
 
				(GetCargo(ind->produced_cargo[i])->classes & (CC_LIQUID | CC_PASSENGERS | CC_MAIL)) == 0) {
 
				(CargoSpec::Get(ind->produced_cargo[i])->classes & (CC_LIQUID | CC_PASSENGERS | CC_MAIL)) == 0) {
 
			return true;
 
		}
 
	}
 
@@ -182,7 +182,7 @@ static bool CMSAForest(TileIndex tile)
 

	
 
	for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
 
		/* The industry produces wood. */
 
		if (ind->produced_cargo[i] != CT_INVALID && GetCargo(ind->produced_cargo[i])->label == 'WOOD') return true;
 
		if (ind->produced_cargo[i] != CT_INVALID && CargoSpec::Get(ind->produced_cargo[i])->label == 'WOOD') return true;
 
	}
 

	
 
	return false;
 
@@ -411,7 +411,7 @@ static uint GetAcceptanceMask(const Stat
 
static void ShowRejectOrAcceptNews(const Station *st, uint num_items, CargoID *cargo, StringID msg)
 
{
 
	for (uint i = 0; i < num_items; i++) {
 
		SetDParam(i + 1, GetCargo(cargo[i])->name);
 
		SetDParam(i + 1, CargoSpec::Get(cargo[i])->name);
 
	}
 

	
 
	SetDParam(0, st->index);
src/station_gui.cpp
Show inline comments
 
@@ -49,7 +49,7 @@ static void StationsWndShowStationRating
 
	static const uint units_full  = 576; ///< number of units to show station as 'full'
 
	static const uint rating_full = 224; ///< rating needed so it is shown as 'full'
 

	
 
	const CargoSpec *cs = GetCargo(type);
 
	const CargoSpec *cs = CargoSpec::Get(type);
 
	if (!cs->IsValid()) return;
 

	
 
	int colour = cs->rating_colour;
 
@@ -258,7 +258,7 @@ public:
 
		/* Add cargo filter buttons */
 
		uint num_active = 0;
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			if (GetCargo(c)->IsValid()) num_active++;
 
			if (CargoSpec::Get(c)->IsValid()) num_active++;
 
		}
 

	
 
		this->widget_count += num_active;
 
@@ -267,7 +267,7 @@ public:
 

	
 
		uint i = 0;
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			if (!GetCargo(c)->IsValid()) continue;
 
			if (!CargoSpec::Get(c)->IsValid()) continue;
 

	
 
			Widget *wi = &this->widget[SLW_CARGOSTART + i];
 
			wi->type     = WWT_PANEL;
 
@@ -346,7 +346,7 @@ public:
 

	
 
		uint i = 0;
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			const CargoSpec *cs = GetCargo(c);
 
			const CargoSpec *cs = CargoSpec::Get(c);
 
			if (!cs->IsValid()) continue;
 

	
 
			cg_ofst = HasBit(this->cargo_filter, c) ? 2 : 1;
 
@@ -457,7 +457,7 @@ public:
 
			case SLW_CARGOALL: {
 
				uint i = 0;
 
				for (CargoID c = 0; c < NUM_CARGO; c++) {
 
					if (!GetCargo(c)->IsValid()) continue;
 
					if (!CargoSpec::Get(c)->IsValid()) continue;
 
					this->LowerWidget(i + SLW_CARGOSTART);
 
					i++;
 
				}
 
@@ -507,7 +507,7 @@ public:
 
					CargoID c;
 
					int i = 0;
 
					for (c = 0; c < NUM_CARGO; c++) {
 
						if (!GetCargo(c)->IsValid()) continue;
 
						if (!CargoSpec::Get(c)->IsValid()) continue;
 
						if (widget - SLW_CARGOSTART == i) break;
 
						i++;
 
					}
 
@@ -724,7 +724,7 @@ static const NWidgetPart _nested_station
 

	
 
SpriteID GetCargoSprite(CargoID i)
 
{
 
	const CargoSpec *cs = GetCargo(i);
 
	const CargoSpec *cs = CargoSpec::Get(i);
 
	SpriteID sprite;
 

	
 
	if (cs->sprite == 0xFFFF) {
 
@@ -924,7 +924,7 @@ struct StationViewWindow : public Window
 
						*b++ = ',';
 
						*b++ = ' ';
 
					}
 
					b = InlineString(b, GetCargo(i)->name);
 
					b = InlineString(b, CargoSpec::Get(i)->name);
 
				}
 
			}
 

	
 
@@ -945,7 +945,7 @@ struct StationViewWindow : public Window
 
			y += 10;
 

	
 
			for (CargoID i = 0; i < NUM_CARGO; i++) {
 
				const CargoSpec *cs = GetCargo(i);
 
				const CargoSpec *cs = CargoSpec::Get(i);
 
				if (!cs->IsValid()) continue;
 

	
 
				const GoodsEntry *ge = &st->goods[i];
src/strings.cpp
Show inline comments
 
@@ -611,7 +611,7 @@ static char *FormatString(char *buff, co
 
				/* Short description of cargotypes. Layout:
 
				 * 8-bit = cargo type
 
				 * 16-bit = cargo count */
 
				StringID cargo_str = GetCargo(GetInt32(&argv))->units_volume;
 
				StringID cargo_str = CargoSpec::Get(GetInt32(&argv))->units_volume;
 
				switch (cargo_str) {
 
					case STR_TONS: {
 
						int64 args[1];
 
@@ -750,7 +750,7 @@ static char *FormatString(char *buff, co
 
				 *   8bit   - cargo type
 
				 *   16-bit - cargo count */
 
				CargoID cargo = GetInt32(&argv);
 
				StringID cargo_str = (cargo == CT_INVALID) ? STR_CARGO_N_A : GetCargo(cargo)->quantifier;
 
				StringID cargo_str = (cargo == CT_INVALID) ? STR_CARGO_N_A : CargoSpec::Get(cargo)->quantifier;
 
				buff = GetStringWithArgs(buff, cargo_str, argv++, last);
 
				break;
 
			}
src/subsidy.cpp
Show inline comments
 
@@ -57,7 +57,7 @@ Pair SetupSubsidyDecodeParam(const Subsi
 
	NewsReferenceType reftype2 = NR_NONE;
 

	
 
	/* if mode is false, use the singular form */
 
	const CargoSpec *cs = GetCargo(s->cargo_type);
 
	const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
 
	SetDParam(0, mode ? cs->name : cs->name_single);
 

	
 
	if (s->age < 12) {
 
@@ -103,7 +103,7 @@ void DeleteSubsidyWithTown(TownID index)
 
	Subsidy *s;
 
	FOR_ALL_SUBSIDIES(s) {
 
		if (s->age < 12) {
 
			const CargoSpec *cs = GetCargo(s->cargo_type);
 
			const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
 
			if (((cs->town_effect == TE_PASSENGERS || cs->town_effect == TE_MAIL) && (index == s->from || index == s->to)) ||
 
				((cs->town_effect == TE_GOODS || cs->town_effect == TE_FOOD) && index == s->to)) {
 
				s->cargo_type = CT_INVALID;
 
@@ -117,7 +117,7 @@ void DeleteSubsidyWithIndustry(IndustryI
 
	Subsidy *s;
 
	FOR_ALL_SUBSIDIES(s) {
 
		if (s->age < 12) {
 
			const CargoSpec *cs = GetCargo(s->cargo_type);
 
			const CargoSpec *cs = CargoSpec::Get(s->cargo_type);
 
			if (cs->town_effect != TE_PASSENGERS && cs->town_effect != TE_MAIL &&
 
				(index == s->from || (cs->town_effect != TE_GOODS && cs->town_effect != TE_FOOD && index == s->to))) {
 
				s->cargo_type = CT_INVALID;
 
@@ -192,7 +192,7 @@ static void FindSubsidyCargoRoute(FoundR
 
	 * or if the pct transported is already large enough */
 
	if (total == 0 || trans > 42 || cargo == CT_INVALID) return;
 

	
 
	const CargoSpec *cs = GetCargo(cargo);
 
	const CargoSpec *cs = CargoSpec::Get(cargo);
 
	if (cs->town_effect == TE_PASSENGERS) return;
 

	
 
	fr->cargo = cargo;
 
@@ -287,7 +287,7 @@ void SubsidyMonthlyLoop()
 
				s->cargo_type = fr.cargo;
 
				s->from = ((Industry*)fr.from)->index;
 
				{
 
					const CargoSpec *cs = GetCargo(fr.cargo);
 
					const CargoSpec *cs = CargoSpec::Get(fr.cargo);
 
					s->to = (cs->town_effect == TE_GOODS || cs->town_effect == TE_FOOD) ? ((Town*)fr.to)->index : ((Industry*)fr.to)->index;
 
				}
 
	add_subsidy:
 
@@ -326,7 +326,7 @@ bool CheckSubsidised(const Station *from
 
	FOR_ALL_SUBSIDIES(s) {
 
		if (s->cargo_type == cargo_type && s->age < 12) {
 
			/* Check distance from source */
 
			const CargoSpec *cs = GetCargo(cargo_type);
 
			const CargoSpec *cs = CargoSpec::Get(cargo_type);
 
			if (cs->town_effect == TE_PASSENGERS || cs->town_effect == TE_MAIL) {
 
				xy = Town::Get(s->from)->xy;
 
			} else {
src/subsidy_gui.cpp
Show inline comments
 
@@ -78,7 +78,7 @@ struct SubsidyListWindow : Window {
 

	
 
	void HandleClick(const Subsidy *s)
 
	{
 
		TownEffect te = GetCargo(s->cargo_type)->town_effect;
 
		TownEffect te = CargoSpec::Get(s->cargo_type)->town_effect;
 
		TileIndex xy;
 

	
 
		/* determine from coordinate for subsidy and try to scroll to it */
src/town_cmd.cpp
Show inline comments
 
@@ -463,7 +463,7 @@ static void TileLoop_Town(TileIndex tile
 

	
 
			uint moved = MoveGoodsToStation(tile, 1, 1, cargo, amt);
 

	
 
			const CargoSpec *cs = GetCargo(cargo);
 
			const CargoSpec *cs = CargoSpec::Get(cargo);
 
			switch (cs->town_effect) {
 
				case TE_PASSENGERS:
 
					t->new_max_pass += amt;
src/town_gui.cpp
Show inline comments
 
@@ -333,7 +333,7 @@ public:
 
			CargoID first_water_cargo = CT_INVALID;
 
			StringID water_name = STR_CARGO_PLURAL_WATER;
 
			for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
 
				const CargoSpec *cs = GetCargo(cid);
 
				const CargoSpec *cs = CargoSpec::Get(cid);
 
				if (first_food_cargo == CT_INVALID && cs->town_effect == TE_FOOD) {
 
					first_food_cargo = cid;
 
					food_name = cs->name;
src/train_cmd.cpp
Show inline comments
 
@@ -76,7 +76,7 @@ static inline DiagDirection TrainExitDir
 
 */
 
byte FreightWagonMult(CargoID cargo)
 
{
 
	if (!GetCargo(cargo)->is_freight) return 1;
 
	if (!CargoSpec::Get(cargo)->is_freight) return 1;
 
	return _settings_game.vehicle.freight_trains;
 
}
 

	
 
@@ -139,7 +139,7 @@ static void TrainCargoChanged(Train *v)
 
	uint32 weight = 0;
 

	
 
	for (Train *u = v; u != NULL; u = u->Next()) {
 
		uint32 vweight = GetCargo(u->cargo_type)->weight * u->cargo.Count() * FreightWagonMult(u->cargo_type) / 16;
 
		uint32 vweight = CargoSpec::Get(u->cargo_type)->weight * u->cargo.Count() * FreightWagonMult(u->cargo_type) / 16;
 

	
 
		/* Vehicle weight is not added for articulated parts. */
 
		if (!u->IsArticulatedPart()) {
src/vehicle.cpp
Show inline comments
 
@@ -1290,7 +1290,7 @@ const Livery *GetEngineLivery(EngineID e
 
				if (cargo_type == CT_INVALID) cargo_type = e->GetDefaultCargoType();
 
				if (cargo_type == CT_INVALID) cargo_type = CT_GOODS; // The vehicle does not carry anything, let's pick some freight cargo
 
				if (rvi->railveh_type == RAILVEH_WAGON) {
 
					if (!GetCargo(cargo_type)->is_freight) {
 
					if (!CargoSpec::Get(cargo_type)->is_freight) {
 
						if (parent_engine_type == INVALID_ENGINE) {
 
							scheme = LS_PASSENGER_WAGON_STEAM;
 
						} else {
src/vehicle_gui.cpp
Show inline comments
 
@@ -251,7 +251,7 @@ static RefitOption *DrawVehicleRefitWind
 

	
 
		if (i >= pos && i < pos + rows) {
 
			/* Draw the cargo name */
 
			int last_x = DrawString(2, right, y, GetCargo(refit[i].cargo)->name, colour);
 
			int last_x = DrawString(2, right, y, CargoSpec::Get(refit[i].cargo)->name, colour);
 

	
 
			/* If the callback succeeded, draw the cargo suffix */
 
			if (refit[i].value != CALLBACK_FAILED) {
 
@@ -503,7 +503,7 @@ uint ShowRefitOptionsList(int left, int 
 
			if (!first) b = strecpy(b, ", ", lastof(string));
 
			first = false;
 

	
 
			b = InlineString(b, GetCargo(cid)->name);
 
			b = InlineString(b, CargoSpec::Get(cid)->name);
 
		}
 
	}
 

	
0 comments (0 inline, 0 general)