Changeset - r12405:ba094e765533
[Not reviewed]
src/ai/api/ai_cargo.cpp
Show inline comments
 
@@ -8,19 +8,19 @@
 
#include "../../core/alloc_func.hpp"
 
#include "../../core/bitmath_func.hpp"
 
#include "../../newgrf_cargo.h"
 

	
 
/* 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 */
 
	char *cargo_label = MallocT<char>(sizeof(cargo->label) + 1);
 
	for (uint i = 0; i < sizeof(cargo->label); i++) {
 
		cargo_label[i] = GB(cargo->label, (uint8)(sizeof(cargo->label) - i - 1) * 8, 8);
 
@@ -29,13 +29,13 @@
 
	return cargo_label;
 
}
 

	
 
/* 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;
 
}
 

	
 
/* static */ bool AICargo::HasCargoClass(CargoID cargo_type, CargoClass cargo_class)
 
{
 
	if (!IsValidCargo(cargo_type)) return false;
 
@@ -43,13 +43,13 @@
 
}
 

	
 
/* static */ AICargo::TownEffect AICargo::GetTownEffect(CargoID cargo_type)
 
{
 
	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)
 
{
 
	if (!IsValidCargo(cargo_type)) return -1;
 
	return ::GetTransportedGoodsIncome(1, distance, Clamp(days_in_transit * 2 / 5, 0, 255), cargo_type);
src/ai/api/ai_cargolist.cpp
Show inline comments
 
@@ -8,13 +8,13 @@
 
#include "../../tile_type.h"
 
#include "../../industry.h"
 

	
 
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
 
@@ -54,14 +54,14 @@
 
}
 

	
 
/* static */ bool AISubsidy::SourceIsTown(SubsidyID subsidy_id)
 
{
 
	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)
 
{
 
	if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
 

	
 
@@ -69,13 +69,13 @@
 
}
 

	
 
/* static */ bool AISubsidy::DestinationIsTown(SubsidyID subsidy_id)
 
{
 
	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:
 
		case TE_FOOD:
 
			return true;
 
		default:
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -442,13 +442,13 @@ static int DrawRailWagonPurchaseInfo(int
 
	DrawString(left, right, y, STR_PURCHASE_INFO_COST);
 
	y += FONT_HEIGHT_NORMAL;
 

	
 
	/* 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;
 

	
 
	/* Wagon speed limit, displayed if above zero */
 
	if (_settings_game.vehicle.wagon_speed_limits) {
 
@@ -818,13 +818,13 @@ struct BuildVehicleWindow : Window {
 
			this->cargo_filter_texts[filter_items] = STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE;
 
			filter_items++;
 
		}
 

	
 
		/* 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;
 
			this->cargo_filter_texts[filter_items] = cargo->name;
 
			filter_items++;
 
		}
src/cargotype.cpp
Show inline comments
 
@@ -8,59 +8,61 @@
 
#include "core/bitmath_func.hpp"
 

	
 
#include "table/sprites.h"
 
#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;
 

	
 

	
 
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;
 

	
 
	for (CargoID i = 0; i < lengthof(_default_climate_cargo[l]); i++) {
 
		CargoLabel cl = _default_climate_cargo[l][i];
 

	
 
		/* 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;
 
		}
 

	
 
		/* Loop through each of the default cargo types to see if
 
		 * 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);
 
				break;
 
			}
 
		}
 
	}
 
}
 

	
 

	
 
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 */
 
	return CT_INVALID;
 
}
 

	
 
@@ -70,14 +72,14 @@ CargoID GetCargoIDByLabel(CargoLabel cl)
 
 * @return First CargoID with the given bitnum, or CT_INVALID if not found.
 
 */
 
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 */
 
	return CT_INVALID;
 
}
 

	
src/cargotype.h
Show inline comments
 
@@ -51,35 +51,42 @@ struct CargoSpec {
 
	const struct SpriteGroup *group;
 

	
 
	bool IsValid() const
 
	{
 
		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);
 
/* Get the cargo icon for a given cargo ID */
 
SpriteID GetCargoSprite(CargoID i);
 
/* Get the cargo ID with the cargo label */
 
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
 
@@ -830,13 +830,13 @@ void StartupEconomy()
 
void ResetEconomy()
 
{
 
	/* Test if resetting the economy is needed. */
 
	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;
 
			break;
 
		}
 
	}
 
@@ -863,13 +863,13 @@ Money GetPriceByIndex(uint8 index)
 

	
 
	return ((Money*)&_price)[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)) {
 
		uint32 var18 = min(dist, 0xFFFF) | (min(num_pieces, 0xFF) << 16) | (transit_days << 24);
 
		uint16 callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs);
 
		if (callback != CALLBACK_FAILED) {
 
@@ -1086,13 +1086,13 @@ static Money DeliverGoods(int num_pieces
 

	
 
		/* Check if a subsidy applies. */
 
		subsidised = CheckSubsidised(s_from, s_to, cargo_type, company->index);
 
	}
 

	
 
	/* 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;
 

	
 
	/* Give the goods to the industry. */
 
	DeliverGoodsToIndustry(s_to, cargo_type, num_pieces);
 

	
src/graph_gui.cpp
Show inline comments
 
@@ -734,13 +734,13 @@ enum CargoPaymentRatesWidgets {
 
struct PaymentRatesGraphWindow : BaseGraphWindow {
 
	PaymentRatesGraphWindow(const WindowDesc *desc, WindowNumber window_number) :
 
			BaseGraphWindow(desc, window_number, 2, 24, 200, false, STR_CURRCOMPACT)
 
	{
 
		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 */
 
		ResizeWindow(this, 0, max(num_active, 12U) * 8);
 

	
 
		/* Add widgets for each cargo type */
 
@@ -784,13 +784,13 @@ struct PaymentRatesGraphWindow : BaseGra
 

	
 
		int x = 495;
 
		int y = 24;
 

	
 
		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
 
			 * exist then the local company has used the climate cheat or
 
			 * changed the NewGRF configuration with this window open. */
 
			if (i + CPW_CARGO_FIRST < this->widget_count) {
src/industry_cmd.cpp
Show inline comments
 
@@ -2073,13 +2073,13 @@ static void ReportNewsProductionChangeIn
 
		case 0: ns = NS_INDUSTRY_NOBODY;  break;
 
		case 1: ns = NS_INDUSTRY_OTHER;   break;
 
		case 2: ns = NS_INDUSTRY_COMPANY; break;
 
		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,
 
		ns,
 
		ind->index
 
	);
src/industry_gui.cpp
Show inline comments
 
@@ -258,13 +258,13 @@ public:
 
		byte p = 0;
 
		SetDParam(0, STR_JUST_NOTHING);
 
		SetDParam(1, STR_EMPTY);
 
		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);
 
		y_str += 11;
 

	
 
		/* Draw the produced cargos, if any. Otherwhise, will print "Nothing" */
 
@@ -272,13 +272,13 @@ public:
 
		p = 0;
 
		SetDParam(0, STR_JUST_NOTHING);
 
		SetDParam(1, STR_EMPTY);
 
		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);
 
		y_str += 11;
 

	
 
		/* Get the additional purchase info text, if it has not already been */
 
@@ -519,13 +519,13 @@ public:
 
			StringID str = STR_INDUSTRY_VIEW_REQUIRES_CARGO;
 
			byte p = 0;
 
			for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 
				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) {
 
				DrawString(2, this->widget[IVW_INFO].right, y, str);
 
				y += 10;
 
			}
src/misc.cpp
Show inline comments
 
@@ -130,10 +130,10 @@ void InitializeGame(uint size_x, uint si
 
/* Calculate constants that depend on the landscape type. */
 
void InitializeLandscapeVariables(bool only_constants)
 
{
 
	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
 
@@ -237,16 +237,16 @@ public:
 
				}
 
				found = true;
 

	
 
				/* 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]));
 
				}
 
			}
 
		}
 
		if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0';
 

	
 
		if (found) line_nr += 2;
 
@@ -831,13 +831,13 @@ static int DrawStationCoverageText(const
 
				first = false;
 
			} else {
 
				/* Add a comma if this is not the first item */
 
				*b++ = ',';
 
				*b++ = ' ';
 
			}
 
			b = InlineString(b, GetCargo(i)->name);
 
			b = InlineString(b, CargoSpec::Get(i)->name);
 
		}
 
	}
 

	
 
	/* If first is still true then no cargo is accepted */
 
	if (first) b = InlineString(b, STR_JUST_NOTHING);
 

	
src/newgrf.cpp
Show inline comments
 
@@ -1503,13 +1503,13 @@ static ChangeInfoResult TownHouseChangeI
 
				housespec->random_colour[3] = 0x06;
 

	
 
				/* Make sure that the third cargo type is valid in this
 
				 * 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;
 
				}
 

	
 
				/**
 
				 * New houses do not (currently) expect to have a default start
 
				 * date before 1930, as this breaks the build date stuff.
 
@@ -1549,13 +1549,13 @@ static ChangeInfoResult TownHouseChangeI
 
				/* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance.
 
				 * Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */
 
				CargoID cid = (goods >= 0) ? ((_settings_game.game_creation.landscape == LT_TOYLAND) ? CT_CANDY : CT_GOODS) :
 
						((_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
 
			} break;
 

	
 
			case 0x10: // Local authority rating decrease on removal
 
@@ -1894,13 +1894,13 @@ static ChangeInfoResult CargoChangeInfo(
 
	if (cid + numinfo > NUM_CARGO) {
 
		grfmsg(2, "CargoChangeInfo: Cargo type %d out of range (max %d)", cid + numinfo, NUM_CARGO - 1);
 
		return CIR_INVALID_ID;
 
	}
 

	
 
	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
 
				cs->bitnum = grf_load_byte(&buf);
 
				if (cs->IsValid()) {
 
					cs->grffile = _cur_grffile;
 
@@ -2992,13 +2992,13 @@ static CargoID TranslateCargo(uint8 feat
 
		if (ctype >= 32) {
 
			grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype);
 
			return CT_INVALID;
 
		}
 

	
 
		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) {
 
				grfmsg(6, "TranslateCargo: Cargo bitnum %d mapped to cargo type %d.", ctype, c);
 
				return c;
 
			}
 
@@ -3287,13 +3287,13 @@ static void CargoMapSpriteGroup(byte *bu
 

	
 
		if (cid >= NUM_CARGO) {
 
			grfmsg(1, "CargoMapSpriteGroup: Cargo ID %d out of range, skipping", cid);
 
			continue;
 
		}
 

	
 
		CargoSpec *cs = &_cargo[cid];
 
		CargoSpec *cs = CargoSpec::Get(cid);
 
		cs->grffile = _cur_grffile;
 
		cs->group = _cur_grffile->spritegroups[groupid];
 
	}
 
}
 

	
 

	
 
@@ -5584,13 +5584,13 @@ static void ResetNewGRFData()
 

	
 
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) {
 
			/* Default translation table, so just a straight mapping to bitnum */
 
			_cur_grffile->cargo_map[c] = cs->bitnum;
 
		} else {
 
@@ -5696,24 +5696,24 @@ static void CalculateRefitMasks()
 

	
 
					SetBit(xor_mask, c);
 
				}
 
			} 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);
 
				}
 
			}
 
		}
 

	
 
		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);
 
			}
 
		} else if (xor_mask == 0) {
 
			/* Don't apply default refit mask to wagons or engines with no capacity */
 
			if (e->type != VEH_TRAIN || (e->u.rail.capacity != 0 && e->u.rail.railveh_type != RAILVEH_WAGON)) {
src/newgrf_cargo.cpp
Show inline comments
 
@@ -119,13 +119,13 @@ CargoID GetCargoTranslation(uint8 cargo,
 
	return CT_INVALID;
 
}
 

	
 
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 */
 
	for (uint i = 0; i < grffile->cargo_max; i++) {
 
		if (cs->label == grffile->cargo_list[i]) return i;
 
	}
src/newgrf_engine.cpp
Show inline comments
 
@@ -490,13 +490,13 @@ static uint32 VehicleGetVariable(const R
 
			case 0x43: return _current_company | (LiveryHelper(object->u.vehicle.self_type, NULL) << 24); // Owner information
 
			case 0x46: return 0;               // Motion counter
 
			case 0x47: { // Vehicle cargo info
 
				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;
 
				}
 
			}
 
			case 0x48: return Engine::Get(object->u.vehicle.self_type)->flags; // Vehicle Type Info
 
@@ -546,13 +546,13 @@ static uint32 VehicleGetVariable(const R
 
				for (u = v; u != NULL; u = u->Next()) {
 
					if (v->type == VEH_TRAIN) user_def_data |= Train::From(u)->tcache.user_def_data;
 

	
 
					/* 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]++;
 
				}
 

	
 
				/* Pick the most common cargo type */
 
				uint common_cargo_best_amount = 0;
 
				for (CargoID cargo = 0; cargo < NUM_CARGO; cargo++) {
 
@@ -576,13 +576,13 @@ static uint32 VehicleGetVariable(const R
 
					if (common_subtypes[i] > common_subtype_best_amount) {
 
						common_subtype_best_amount = common_subtypes[i];
 
						common_subtype = i;
 
					}
 
				}
 

	
 
				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);
 
			}
 
			return v->vcache.cached_var42;
 

	
 
		case 0x43: // Company information
 
@@ -649,13 +649,13 @@ static uint32 VehicleGetVariable(const R
 
			/* Format: ccccwwtt
 
			 * tt - the cargo type transported by the vehicle,
 
			 *     translated if a translation table has been installed.
 
			 * 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];
 
		}
 

	
 
		case 0x48: return Engine::Get(v->engine_type)->flags; // Vehicle Type Info
 
		case 0x49: return v->build_year;
src/newgrf_station.cpp
Show inline comments
 
@@ -608,13 +608,13 @@ static const SpriteGroup *ResolveStation
 
	if (object->u.station.st == NULL) {
 
		/* No station, so we are in a purchase list */
 
		ctype = CT_PURCHASE;
 
	} 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;
 
				break;
 
			}
 
		}
src/order_gui.cpp
Show inline comments
 
@@ -245,13 +245,13 @@ void DrawOrderString(const Vehicle *v, c
 
			if (!timetable && (order->GetDepotActionType() & ODATFB_HALT)) {
 
				SetDParam(6, STR_STOP_ORDER);
 
			}
 

	
 
			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;
 

	
 
		case OT_GOTO_WAYPOINT:
 
			if (v->type == VEH_TRAIN) {
 
				SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT);
src/saveload/afterload.cpp
Show inline comments
 
@@ -1921,13 +1921,13 @@ bool AfterLoadGame()
 
			if (s->age >= 12) {
 
				/* Station -> Station */
 
				const Station *from = Station::GetIfValid(s->from);
 
				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:
 
						/* Town -> Town */
 
						if (Town::IsValidID(s->from) && Town::IsValidID(s->to)) continue;
 
						break;
src/station_cmd.cpp
Show inline comments
 
@@ -134,13 +134,13 @@ static bool CMSAMine(TileIndex tile)
 
	if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_EXTRACTIVE) == 0) return false;
 

	
 
	for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
 
		/* 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;
 
		}
 
	}
 

	
 
	return false;
 
}
 
@@ -179,13 +179,13 @@ static bool CMSAForest(TileIndex tile)
 

	
 
	/* No extractive industry */
 
	if ((GetIndustrySpec(ind->type)->life_type & INDUSTRYLIFE_ORGANIC) == 0) return false;
 

	
 
	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;
 
}
 

	
 
#define M(x) ((x) - STR_SV_STNAME)
 
@@ -408,13 +408,13 @@ static uint GetAcceptanceMask(const Stat
 
/** Items contains the two cargo names that are to be accepted or rejected.
 
 * msg is the string id of the message to display.
 
 */
 
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);
 
	AddNewsItem(msg, NS_ACCEPTANCE, NR_STATION, st->index);
 
}
 

	
src/station_gui.cpp
Show inline comments
 
@@ -46,13 +46,13 @@
 
 */
 
static void StationsWndShowStationRating(int left, int right, int y, CargoID type, uint amount, byte rating)
 
{
 
	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;
 
	uint w = (minu(amount, units_full) + 5) / 36;
 

	
 
	/* Draw total cargo (limited) on station (fits into 16 pixels) */
 
@@ -255,22 +255,22 @@ public:
 
		this->resize.step_height = 10;
 
		this->resize.height = this->height - 10 * 7; // minimum if 5 in the list
 

	
 
		/* 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;
 
		this->widget = ReallocT(this->widget, this->widget_count + 1);
 
		this->widget[this->widget_count].type = WWT_LAST;
 

	
 
		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;
 
			wi->display_flags = RESIZE_NONE;
 
			wi->colour   = COLOUR_GREY;
 
			wi->left     = 89 + i * 14;
 
@@ -343,13 +343,13 @@ public:
 
		int x = 89;
 
		int y = 14;
 
		int xb = 2; ///< offset from left of widget
 

	
 
		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;
 
			GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour);
 
			DrawString(x + cg_ofst, x + 12 + cg_ofst, y + cg_ofst, cs->abbrev, TC_BLACK, SA_CENTER);
 
			x += 14;
 
@@ -454,13 +454,13 @@ public:
 
				this->SetDirty();
 
				break;
 

	
 
			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++;
 
				}
 
				this->LowerWidget(SLW_NOCARGOWAITING);
 
				this->LowerWidget(SLW_CARGOALL);
 

	
 
@@ -504,13 +504,13 @@ public:
 
			default:
 
				if (widget >= SLW_CARGOSTART) { // change cargo_filter
 
					/* Determine the selected cargo type */
 
					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++;
 
					}
 

	
 
					if (_ctrl_pressed) {
 
						ToggleBit(this->cargo_filter, c);
 
@@ -721,13 +721,13 @@ static const NWidgetPart _nested_station
 
		NWidget(WWT_RESIZEBOX, COLOUR_GREY, SVW_RESIZE),
 
	EndContainer(),
 
};
 

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

	
 
	if (cs->sprite == 0xFFFF) {
 
		/* A value of 0xFFFF indicates we should draw a custom icon */
 
		sprite = GetCustomCargoSprite(cs);
 
	} else {
 
@@ -921,13 +921,13 @@ struct StationViewWindow : public Window
 
						first = false;
 
					} else {
 
						/* Add a comma if this is not the first item */
 
						*b++ = ',';
 
						*b++ = ' ';
 
					}
 
					b = InlineString(b, GetCargo(i)->name);
 
					b = InlineString(b, CargoSpec::Get(i)->name);
 
				}
 
			}
 

	
 
			/* If first is still true then no cargo is accepted */
 
			if (first) b = InlineString(b, STR_JUST_NOTHING);
 

	
 
@@ -942,13 +942,13 @@ struct StationViewWindow : public Window
 
			y = this->widget[SVW_RATINGLIST].top + 1;
 

	
 
			DrawString(this->widget[SVW_ACCEPTLIST].left + 2, this->widget[SVW_ACCEPTLIST].right - 2, y, STR_STATION_VIEW_CARGO_RATINGS_TITLE);
 
			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];
 
				if (!HasBit(ge->acceptance_pickup, GoodsEntry::PICKUP)) continue;
 

	
 
				SetDParam(0, cs->name);
src/strings.cpp
Show inline comments
 
@@ -608,13 +608,13 @@ static char *FormatString(char *buff, co
 
				break;
 

	
 
			case SCC_CARGO_SHORT: { // {SHORTCARGO}
 
				/* 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];
 
						assert(_settings_game.locale.units < lengthof(units));
 
						args[0] = GetInt32(&argv) * units[_settings_game.locale.units].w_m >> units[_settings_game.locale.units].w_s;
 
						buff = FormatString(buff, GetStringPtr(units[_settings_game.locale.units].l_weight), args, modifier >> 24, last);
 
@@ -747,13 +747,13 @@ static char *FormatString(char *buff, co
 

	
 
			case SCC_CARGO: { // {CARGO}
 
				/* Layout now is:
 
				 *   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;
 
			}
 

	
 
			case SCC_POWER: { // {POWER}
 
				int64 args[1];
src/subsidy.cpp
Show inline comments
 
@@ -54,13 +54,13 @@ void InitializeSubsidies()
 
Pair SetupSubsidyDecodeParam(const Subsidy *s, bool mode)
 
{
 
	NewsReferenceType reftype1 = NR_NONE;
 
	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) {
 
		if (cs->town_effect != TE_PASSENGERS && cs->town_effect != TE_MAIL) {
 
			SetDParam(1, STR_INDUSTRY);
 
			SetDParam(2, s->from);
 
@@ -100,13 +100,13 @@ Pair SetupSubsidyDecodeParam(const Subsi
 

	
 
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;
 
			}
 
		}
 
	}
 
@@ -114,13 +114,13 @@ void DeleteSubsidyWithTown(TownID index)
 

	
 
void DeleteSubsidyWithIndustry(IndustryID 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 || (cs->town_effect != TE_GOODS && cs->town_effect != TE_FOOD && index == s->to))) {
 
				s->cargo_type = CT_INVALID;
 
			}
 
		}
 
	}
 
@@ -189,13 +189,13 @@ static void FindSubsidyCargoRoute(FoundR
 

	
 
	/* Quit if no production in this industry
 
	 * or if the cargo type is passengers
 
	 * 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;
 

	
 
	if (cs->town_effect == TE_GOODS || cs->town_effect == TE_FOOD) {
 
		/*  The destination is a town */
 
@@ -284,13 +284,13 @@ void SubsidyMonthlyLoop()
 
			}
 
			FindSubsidyCargoRoute(&fr);
 
			if (fr.distance <= 70) {
 
				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:
 
				if (!CheckSubsidyDuplicate(s)) {
 
					s->age = 0;
 
					Pair reftype = SetupSubsidyDecodeParam(s, 0);
 
@@ -323,13 +323,13 @@ bool CheckSubsidised(const Station *from
 
	}
 

	
 
	/* check if there's a new subsidy that applies.. */
 
	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 {
 
				xy = Industry::Get(s->from)->xy;
 
			}
 
			if (DistanceMax(xy, from->xy) > 9) continue;
src/subsidy_gui.cpp
Show inline comments
 
@@ -75,13 +75,13 @@ 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 */
 
		uint offs = s->from;
 
		if (s->age >= 12) {
 
			xy = Station::Get(offs)->xy;
src/town_cmd.cpp
Show inline comments
 
@@ -460,13 +460,13 @@ static void TileLoop_Town(TileIndex tile
 

	
 
			uint amt = GB(callback, 0, 8);
 
			if (amt == 0) continue;
 

	
 
			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;
 
					t->new_act_pass += moved;
 
					break;
 

	
src/town_gui.cpp
Show inline comments
 
@@ -330,13 +330,13 @@ public:
 

	
 
			CargoID first_food_cargo = CT_INVALID;
 
			StringID food_name = STR_CARGO_PLURAL_FOOD;
 
			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;
 
				}
 
				if (first_water_cargo == CT_INVALID && cs->town_effect == TE_WATER) {
 
					first_water_cargo = cid;
src/train_cmd.cpp
Show inline comments
 
@@ -73,13 +73,13 @@ static inline DiagDirection TrainExitDir
 
/** Return the cargo weight multiplier to use for a rail vehicle
 
 * @param cargo Cargo type to get multiplier for
 
 * @return Cargo weight multiplier
 
 */
 
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;
 
}
 

	
 

	
 
/**
 
 * Recalculates the cached total power of a train. Should be called when the consist is changed
 
@@ -136,13 +136,13 @@ void TrainPowerChanged(Train *v)
 
 */
 
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()) {
 
			/* vehicle weight is the sum of the weight of the vehicle and the weight of its cargo */
 
			vweight += GetVehicleProperty(u, 0x16, RailVehInfo(u->engine_type)->weight);
 
		}
src/vehicle.cpp
Show inline comments
 
@@ -1287,13 +1287,13 @@ const Livery *GetEngineLivery(EngineID e
 
					/* Note: Luckily cargo_type is not needed for engines */
 
				}
 

	
 
				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 {
 
							switch (RailVehInfo(parent_engine_type)->engclass) {
 
								default: NOT_REACHED();
 
								case EC_STEAM:    scheme = LS_PASSENGER_WAGON_STEAM;    break;
src/vehicle_gui.cpp
Show inline comments
 
@@ -248,13 +248,13 @@ static RefitOption *DrawVehicleRefitWind
 
			selected = &refit[i];
 
			colour = TC_WHITE;
 
		}
 

	
 
		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) {
 
				DrawString(last_x + 1, right, y, GetGRFStringID(GetEngineGRFID(refit[i].engine), 0xD000 + refit[i].value), colour);
 
			}
 
			y += delta;
 
@@ -500,13 +500,13 @@ uint ShowRefitOptionsList(int left, int 
 

	
 
			if (b >= lastof(string) - (2 + 2 * 4)) break; // ", " and two calls to Utf8Encode()
 

	
 
			if (!first) b = strecpy(b, ", ", lastof(string));
 
			first = false;
 

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

	
 
	/* Terminate and display the completed string */
 
	*b = '\0';
 

	
0 comments (0 inline, 0 general)