Changeset - r6091:2faa7d307565
[Not reviewed]
master
1 20 3
peter1138 - 17 years ago 2007-02-20 22:09:21
peter1138@openttd.org
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
24 files changed with 314 insertions and 370 deletions:
0 comments (0 inline, 0 general)
projects/openttd.vcproj
Show inline comments
 
@@ -170,12 +170,15 @@
 
				RelativePath=".\..\src\bmp.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\callback_table.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\cargotype.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\command.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\console.cpp">
 
			</File>
 
			<File
 
@@ -396,12 +399,15 @@
 
				RelativePath=".\..\src\aystar.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\bmp.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\cargotype.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\command.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\console.h">
 
			</File>
 
			<File
 
@@ -846,12 +852,15 @@
 
				RelativePath=".\..\src\table\autorail.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\build_industry.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\cargo_const.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\clear_land.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\elrail_data.h">
 
			</File>
 
			<File
 
@@ -861,15 +870,12 @@
 
				RelativePath=".\..\src\table\genland.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\industry_land.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\landscape_const.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\landscape_sprite.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\namegen.h">
 
			</File>
 
			<File
projects/openttd_vs80.vcproj
Show inline comments
 
@@ -453,12 +453,15 @@
 
				RelativePath=".\..\src\bmp.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\callback_table.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\cargotype.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\command.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\console.cpp">
 
			</File>
 
			<File
 
@@ -679,12 +682,15 @@
 
				RelativePath=".\..\src\aystar.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\bmp.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\cargotype.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\command.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\console.h">
 
			</File>
 
			<File
 
@@ -1129,12 +1135,15 @@
 
				RelativePath=".\..\src\table\autorail.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\build_industry.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\cargo_const.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\clear_land.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\elrail_data.h">
 
			</File>
 
			<File
 
@@ -1144,15 +1153,12 @@
 
				RelativePath=".\..\src\table\genland.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\industry_land.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\landscape_const.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\landscape_sprite.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\table\namegen.h">
 
			</File>
 
			<File
source.list
Show inline comments
 
# Source Files
 
airport.cpp
 
aystar.cpp
 
bmp.cpp
 
callback_table.cpp
 
cargotype.cpp
 
command.cpp
 
console.cpp
 
console_cmds.cpp
 
currency.cpp
 
date.cpp
 
debug.cpp
 
@@ -97,12 +98,13 @@ window.cpp
 
# Header Files
 
aircraft.h
 
airport.h
 
airport_movement.h
 
aystar.h
 
bmp.h
 
cargotype.h
 
command.h
 
console.h
 
currency.h
 
date.h
 
debug.h
 
video/dedicated_v.h
 
@@ -249,18 +251,18 @@ water_cmd.cpp
 
# Tables
 
table/ai_rail.h
 
table/allstrings.h
 
table/animcursors.h
 
table/autorail.h
 
table/build_industry.h
 
table/cargo_const.h
 
table/clear_land.h
 
table/elrail_data.h
 
table/engines.h
 
table/genland.h
 
table/industry_land.h
 
table/landscape_const.h
 
table/landscape_sprite.h
 
table/namegen.h
 
table/palettes.h
 
table/road_land.h
 
table/roadveh.h
 
table/sprites.h
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -21,12 +21,13 @@
 
#include "depot.h"
 
#include "airport.h"
 
#include "vehicle_gui.h"
 
#include "newgrf_engine.h"
 
#include "date.h"
 
#include "strings.h"
 
#include "cargotype.h"
 

	
 

	
 
enum BuildVehicleWidgets {
 
	BUILD_VEHICLE_WIDGET_CLOSEBOX = 0,
 
	BUILD_VEHICLE_WIDGET_CAPTION,
 
	BUILD_VEHICLE_WIDGET_SORT_ASSENDING_DESCENDING,
 
@@ -378,13 +379,13 @@ static int DrawRailWagonPurchaseInfo(int
 
	SetDParam(0, (rvi->base_cost * _price.build_railwagon) >> 8);
 
	DrawString(x, y, STR_PURCHASE_INFO_COST, 0);
 
	y += 10;
 

	
 
	/* Wagon weight - (including cargo) */
 
	SetDParam(0, rvi->weight);
 
	SetDParam(1, (_cargoc.weights[rvi->cargo_type] * rvi->capacity >> 4) + rvi->weight);
 
	SetDParam(1, (GetCargo(rvi->cargo_type)->weight * rvi->capacity >> 4) + rvi->weight);
 
	DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, 0);
 
	y += 10;
 

	
 
	/* Wagon speed limit, displayed if above zero */
 
	if (rvi->max_speed > 0 && _patches.wagon_speed_limits) {
 
		SetDParam(0, rvi->max_speed * 10 / 16);
src/cargotype.cpp
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "macros.h"
 
#include "table/sprites.h"
 
#include "table/strings.h"
 
#include "newgrf_cargo.h"
 
#include "cargotype.h"
 

	
 
#include "table/cargo_const.h"
 

	
 
static CargoSpec _cargo[NUM_CARGO];
 

	
 
static const byte INVALID_CARGO = 0xFF;
 

	
 

	
 
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;
 

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

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

	
 

	
 
const CargoSpec *GetCargo(CargoID c)
 
{
 
	assert(c < lengthof(_cargo));
 
	return &_cargo[c];
 
}
 

	
src/cargotype.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
#ifndef CARGOTYPE_H
 
#define CARGOTYPE_H
 

	
 

	
 
typedef uint32 CargoLabel;
 

	
 

	
 
typedef struct CargoSpec {
 
	uint8 bitnum;
 
	CargoLabel label;
 
	uint32 grfid;
 
	uint8 legend_colour;
 
	uint8 rating_colour;
 
	uint8 weight;
 
	uint16 initial_payment;
 
	uint8 transit_days[2];
 

	
 
	bool is_freight;
 
	uint8 substitutetowngrowth;
 
	uint16 multipliertowngrowth;
 
	uint8 callbackflags;
 

	
 
	StringID name;
 
	StringID name_plural;
 
	StringID units_volume;
 
	StringID quantifier;
 
	StringID abbrev;
 

	
 
	SpriteID sprite;
 

	
 
	uint16 classes;
 
} CargoSpec;
 

	
 

	
 
/* Set up the default cargo types for the given landscape type */
 
void SetupCargoForClimate(LandscapeID l);
 
/* Retrieve cargo details for the given cargo ID */
 
const CargoSpec *GetCargo(CargoID c);
 

	
 
#endif /* CARGOTYPE_H */
src/economy.cpp
Show inline comments
 
@@ -30,12 +30,13 @@
 
#include "aircraft.h"
 
#include "newgrf_engine.h"
 
#include "newgrf_sound.h"
 
#include "newgrf_callbacks.h"
 
#include "unmovable.h"
 
#include "date.h"
 
#include "cargotype.h"
 

	
 
// Score info
 
const ScoreInfo _score_info[] = {
 
	{ SCORE_VEHICLES,        120, 100 },
 
	{ SCORE_STATIONS,         80, 100 },
 
	{ SCORE_MIN_PROFIT,    10000, 100 },
 
@@ -804,13 +805,14 @@ Pair SetupSubsidyDecodeParam(const Subsi
 
{
 
	TileIndex tile;
 
	TileIndex tile2;
 
	Pair tp;
 

	
 
	/* if mode is false, use the singular form */
 
	SetDParam(0, _cargoc.names_s[s->cargo_type] + (mode ? 0 : 32));
 
	const CargoSpec *cs = GetCargo(s->cargo_type);
 
	SetDParam(0, mode ? cs->name_plural : cs->name);
 

	
 
	if (s->age < 12) {
 
		if (s->cargo_type != CT_PASSENGERS && s->cargo_type != CT_MAIL) {
 
			SetDParam(1, STR_INDUSTRY);
 
			SetDParam(2, s->from);
 
			tile = GetIndustry(s->from)->xy;
 
@@ -1084,25 +1086,26 @@ static void Load_SUBS(void)
 
		SlObject(&_subsidies[index], _subsidies_desc);
 
}
 

	
 
int32 GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type)
 
{
 
	CargoID cargo = cargo_type;
 
	const CargoSpec *cs = GetCargo(cargo_type);
 
	byte f;
 

	
 
	/* zero the distance if it's the bank and very short transport. */
 
	if (_opt.landscape == LT_NORMAL && cargo == CT_VALUABLES && dist < 10)
 
		dist = 0;
 

	
 
	f = 255;
 
	if (transit_days > _cargoc.transit_days_1[cargo]) {
 
		transit_days -= _cargoc.transit_days_1[cargo];
 
	if (transit_days > cs->transit_days[0]) {
 
		transit_days -= cs->transit_days[0];
 
		f -= transit_days;
 

	
 
		if (transit_days > _cargoc.transit_days_2[cargo]) {
 
			transit_days -= _cargoc.transit_days_2[cargo];
 
		if (transit_days > cs->transit_days[1]) {
 
			transit_days -= cs->transit_days[1];
 

	
 
			if (f < transit_days) {
 
				f = 0;
 
			} else {
 
				f -= transit_days;
 
			}
src/graph_gui.cpp
Show inline comments
 
@@ -10,14 +10,13 @@
 
#include "gfx.h"
 
#include "player.h"
 
#include "economy.h"
 
#include "variables.h"
 
#include "date.h"
 
#include "helpers.hpp"
 

	
 
const byte _cargo_colours[NUM_CARGO] = {152, 32, 15, 174, 208, 194, 191, 84, 184, 10, 202, 48};
 
#include "cargotype.h"
 

	
 
/* Bitmasks of player and cargo indices that shouldn't be drawn. */
 
static uint _legend_excluded_players;
 
static uint _legend_excluded_cargo;
 

	
 
/************************/
 
@@ -746,19 +745,20 @@ static void CargoPaymentRatesWndProc(Win
 
		for (i = 0; i != NUM_CARGO; i++) {
 
			/* Since the buttons have no text, no images,
 
			 * both the text and the colored box have to be manually painted.
 
			 * clk_dif will move one pixel down and one pixel to the right
 
			 * when the button is clicked */
 
			byte clk_dif = IsWindowWidgetLowered(w, i + 3) ? 1 : 0;
 
			const CargoSpec *cs = GetCargo(i);
 

	
 
			GfxFillRect(x + clk_dif, y + clk_dif, x + 8 + clk_dif, y + 5 + clk_dif, 0);
 
			GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, _cargo_colours[i]);
 
			SetDParam(0, _cargoc.names_s[i]);
 
			GfxFillRect(x + 1 + clk_dif, y + 1 + clk_dif, x + 7 + clk_dif, y + 4 + clk_dif, cs->legend_colour);
 
			SetDParam(0, cs->name != 0 ? cs->name : (StringID)STR_EMPTY);
 
			DrawString(x + 14 + clk_dif, y + clk_dif, STR_7065, 0);
 
			y += 8;
 
			gd.colors[i] = _cargo_colours[i];
 
			gd.colors[i] = cs->legend_colour;
 
			for (j = 0; j != 20; j++) {
 
				gd.cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 6 + 6, i);
 
			}
 
		}
 

	
 
		DrawGraph(&gd);
src/gui.h
Show inline comments
 
@@ -17,13 +17,12 @@ void CcTerraform(bool success, TileIndex
 
void ShowGameOptions(void);
 
void ShowGameDifficulty(void);
 
void ShowPatchesSelection(void);
 
void DrawArrowButtons(int x, int y, int ctab, byte state, bool clickable_left, bool clickable_right);
 

	
 
/* graph_gui.c */
 
extern const byte _cargo_colours[NUM_CARGO];
 
void ShowOperatingProfitGraph(void);
 
void ShowIncomeGraph(void);
 
void ShowDeliveredCargoGraph(void);
 
void ShowPerformanceHistoryGraph(void);
 
void ShowCompanyValueGraph(void);
 
void ShowCargoPaymentRates(void);
src/industry_cmd.cpp
Show inline comments
 
@@ -23,12 +23,13 @@
 
#include "table/industry_land.h"
 
#include "table/build_industry.h"
 
#include "genworld.h"
 
#include "date.h"
 
#include "water_map.h"
 
#include "tree_map.h"
 
#include "cargotype.h"
 

	
 
void ShowIndustryViewWindow(int industry);
 
void BuildOilRig(TileIndex tile);
 

	
 
static byte _industry_sound_ctr;
 
static TileIndex _industry_sound_tile;
 
@@ -1621,13 +1622,13 @@ static void ExtChangeIndustryProduction(
 
				if (new_prod >= indspec->production_rate[j] / 4)
 
					closeit = false;
 

	
 
				mag = abs(percent);
 
				if (mag >= 10) {
 
					SetDParam(2, mag);
 
					SetDParam(0, _cargoc.names_s[i->produced_cargo[j]]);
 
					SetDParam(0, GetCargo(i->produced_cargo[j])->name);
 
					SetDParam(1, i->index);
 
					AddNewsItem(
 
						percent >= 0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN,
 
						NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_TILE, NT_ECONOMY, 0),
 
						i->xy + TileDiffXY(1, 1), 0
 
					);
src/industry_gui.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "command.h"
 
#include "viewport.h"
 
#include "industry.h"
 
#include "town.h"
 
#include "variables.h"
 
#include "helpers.hpp"
 
#include "cargotype.h"
 

	
 
const byte _build_industry_types[4][12] = {
 
	{  1,  2,  4,  6,  8,  0,  3,  5,  9, 11, 18 },
 
	{  1, 14,  4, 13,  7,  0,  3,  9, 11, 15 },
 
	{ 25, 13,  4, 23, 22, 11, 17, 10, 24, 19, 20, 21 },
 
	{ 27, 30, 31, 33, 26, 28, 29, 32, 34, 35, 36 },
 
@@ -300,19 +301,19 @@ static void IndustryViewWndProc(Window *
 
		SetDParam(0, w->window_number);
 
		DrawWindowWidgets(w);
 

	
 
		if (i->accepts_cargo[0] != CT_INVALID) {
 
			StringID str;
 

	
 
			SetDParam(0, _cargoc.names_s[i->accepts_cargo[0]]);
 
			SetDParam(0, GetCargo(i->accepts_cargo[0])->name);
 
			str = STR_4827_REQUIRES;
 
			if (i->accepts_cargo[1] != CT_INVALID) {
 
				SetDParam(1, _cargoc.names_s[i->accepts_cargo[1]]);
 
				SetDParam(1, GetCargo(i->accepts_cargo[1])->name);
 
				str = STR_4828_REQUIRES;
 
				if (i->accepts_cargo[2] != CT_INVALID) {
 
					SetDParam(2, _cargoc.names_s[i->accepts_cargo[2]]);
 
					SetDParam(2, GetCargo(i->accepts_cargo[2])->name);
 
					str = STR_4829_REQUIRES;
 
				}
 
			}
 
			DrawString(2, 107, str, 0);
 
		}
 

	
src/misc.cpp
Show inline comments
 
@@ -13,14 +13,14 @@
 
#include "vehicle.h"
 
#include "saveload.h"
 
#include "engine.h"
 
#include "vehicle_gui.h"
 
#include "variables.h"
 
#include "ai/ai.h"
 
#include "table/landscape_const.h"
 
#include "date.h"
 
#include "cargotype.h"
 

	
 
char _name_array[512][32];
 

	
 
#ifndef MERSENNE_TWISTER
 

	
 
#ifdef RANDOM_DEBUG
 
@@ -234,35 +234,18 @@ void ConvertNameArray(void)
 
	}
 
}
 

	
 
// Calculate constants that depend on the landscape type.
 
void InitializeLandscapeVariables(bool only_constants)
 
{
 
	const CargoTypesValues *lpd;
 
	uint i;
 
	StringID str;
 

	
 
	lpd = &_cargo_types_base_values[_opt.landscape];
 

	
 
	for (i = 0; i != NUM_CARGO; i++) {
 
		_cargoc.sprites[i] = lpd->sprites[i];
 
	if (only_constants) return;
 

	
 
		str = lpd->names[i];
 
		_cargoc.names_s[i] = str;
 
		_cargoc.names_long[i] = (str += 0x40);
 
		_cargoc.names_short[i] = (str += 0x20);
 
		_cargoc.weights[i] = lpd->weights[i];
 

	
 
		if (!only_constants) {
 
			_cargo_payment_rates[i] = lpd->initial_cargo_payment[i];
 
	for (CargoID i = 0; i != NUM_CARGO; i++) {
 
		_cargo_payment_rates[i] = GetCargo(i)->initial_payment;
 
			_cargo_payment_rates_frac[i] = 0;
 
		}
 

	
 
		_cargoc.transit_days_1[i] = lpd->transit_days_table_1[i];
 
		_cargoc.transit_days_2[i] = lpd->transit_days_table_2[i];
 
	}
 
}
 

	
 

	
 

	
 
int FindFirstBit(uint32 value)
 
{
src/misc_gui.cpp
Show inline comments
 
@@ -27,12 +27,13 @@
 
#include "variables.h"
 
#include "vehicle.h"
 
#include "train.h"
 
#include "tgp.h"
 
#include "settings.h"
 
#include "date.h"
 
#include "cargotype.h"
 

	
 
#include "fios.h"
 
/* Variables to display file lists */
 
FiosItem *_fios_list;
 
int _saveload_mode;
 

	
 
@@ -150,16 +151,16 @@ static void Place_LandInfo(TileIndex til
 
				}
 
				found = true;
 

	
 
				/* If the accepted value is less than 8, show it in 1/8:ths */
 
				if (ac[i] < 8) {
 
					SetDParam(0, ac[i]);
 
					SetDParam(1, _cargoc.names_s[i]);
 
					SetDParam(1, GetCargo(i)->name);
 
					p = GetString(p, STR_01D1_8, lastof(_landinfo_data[5]));
 
				} else {
 
					p = GetString(p, _cargoc.names_s[i], lastof(_landinfo_data[5]));
 
					p = GetString(p, GetCargo(i)->name, lastof(_landinfo_data[5]));
 
				}
 
			}
 
		}
 

	
 
		if (!found) _landinfo_data[5][0] = '\0';
 
	}
 
@@ -737,13 +738,13 @@ static void DrawStationCoverageText(cons
 
				first = false;
 
			} else {
 
				/* Add a comma if this is not the first item */
 
				*b++ = ',';
 
				*b++ = ' ';
 
			}
 
			b = InlineString(b, _cargoc.names_s[i]);
 
			b = InlineString(b, GetCargo(i)->name);
 
		}
 
	}
 

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

	
src/newgrf.cpp
Show inline comments
 
@@ -28,12 +28,13 @@
 
#include "currency.h"
 
#include "sound.h"
 
#include "newgrf_config.h"
 
#include "newgrf_sound.h"
 
#include "newgrf_spritegroup.h"
 
#include "helpers.hpp"
 
#include "cargotype.h"
 

	
 
/* TTDPatch extended GRF format codec
 
 * (c) Petr Baudis 2004 (GPL'd)
 
 * Changes by Florian octo Forster are (c) by the OpenTTD development team.
 
 *
 
 * Contains portions of documentation by TTDPatch team.
 
@@ -3516,12 +3517,15 @@ static void ResetNewGRFData(void)
 
	/* Reset NewGRF files */
 
	ResetNewGRF();
 

	
 
	// Add engine type to engine data. This is needed for the refit precalculation.
 
	AddTypeToEngines();
 

	
 
	/* Set up the default cargo types */
 
	SetupCargoForClimate(_opt.landscape);
 

	
 
	/* Reset misc GRF features and train list display variables */
 
	_misc_grf_features = 0;
 
	_traininfo_vehicle_pitch = 0;
 
	_traininfo_vehicle_width = 29;
 
	_have_2cc = false;
 
	_signal_base = 0;
src/newgrf_engine.cpp
Show inline comments
 
@@ -15,49 +15,14 @@
 
#include "newgrf_engine.h"
 
#include "newgrf_station.h"
 
#include "newgrf_spritegroup.h"
 
#include "newgrf_cargo.h"
 
#include "date.h"
 
#include "helpers.hpp"
 

	
 

	
 
#include "cargotype.h"
 

	
 
/* Default cargo classes */
 
static const uint16 _cargo_classes[NUM_GLOBAL_CID] = {
 
	CC_PASSENGERS,
 
	CC_BULK,
 
	CC_MAIL,
 
	CC_LIQUID,
 
	CC_PIECE_GOODS,
 
	CC_EXPRESS,
 
	CC_BULK,
 
	CC_PIECE_GOODS,
 
	CC_BULK,
 
	CC_PIECE_GOODS,
 
	CC_ARMOURED,
 
	CC_PIECE_GOODS,
 
	CC_REFRIGERATED | CC_EXPRESS,
 
	CC_REFRIGERATED | CC_EXPRESS,
 
	CC_BULK,
 
	CC_LIQUID,
 
	CC_LIQUID,
 
	CC_BULK,
 
	CC_PIECE_GOODS,
 
	CC_PIECE_GOODS,
 
	CC_EXPRESS,
 
	CC_BULK,
 
	CC_LIQUID,
 
	CC_BULK,
 
	CC_PIECE_GOODS,
 
	CC_LIQUID,
 
	CC_PIECE_GOODS,
 
	CC_PIECE_GOODS,
 
	CC_NOAVAILABLE,
 
	CC_NOAVAILABLE,
 
	CC_NOAVAILABLE,
 
};
 

	
 
int _traininfo_vehicle_pitch = 0;
 
int _traininfo_vehicle_width = 29;
 

	
 
typedef struct WagonOverride {
 
	byte *train_id;
 
@@ -584,13 +549,13 @@ static uint32 VehicleGetVariable(const R
 

	
 
			for (u = v; u != NULL; u = u->next) {
 
				/* Skip empty engines */
 
				if (u->cargo_cap == 0) continue;
 
				/* Map from climate to global cargo ID */
 
				cargo = _global_cargo_id[_opt.landscape][u->cargo_type];
 
				cargo_classes |= _cargo_classes[cargo];
 
				cargo_classes |= GetCargo(cargo)->classes;
 
				common_cargos[cargo]++;
 
				user_def_data |= RailVehInfo(u->engine_type)->user_def_data;
 
			}
 

	
 
			/* Pick the most common cargo type */
 
			for (cargo = 0; cargo < NUM_GLOBAL_CID; cargo++) {
 
@@ -641,14 +606,15 @@ static uint32 VehicleGetVariable(const R
 
			 * 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.
 
			 */
 
			CargoID cid = _global_cargo_id[_opt.landscape][v->cargo_type];
 
			const CargoSpec *cs = GetCargo(v->cargo_type);
 

	
 
			return (_cargo_classes[cid] << 16) | (_cargoc.weights[v->cargo_type] << 8) | cid;
 
			return (cs->classes << 16) | (cs->weight << 8) | cid;
 
		}
 

	
 
		case 0x48: return GetVehicleTypeInfo(v->engine_type); /* Vehicle Type Info */
 

	
 
		/* Variables which use the parameter */
 
		case 0x60: /* Count consist's engine ID occurance */
src/order_gui.cpp
Show inline comments
 
@@ -19,12 +19,13 @@
 
#include "viewport.h"
 
#include "depot.h"
 
#include "waypoint.h"
 
#include "train.h"
 
#include "water_map.h"
 
#include "vehicle_gui.h"
 
#include "cargotype.h"
 

	
 
enum OrderWindowWidgets {
 
	ORDER_WIDGET_CLOSEBOX = 0,
 
	ORDER_WIDGET_CAPTION,
 
	ORDER_WIDGET_ORDER_LIST,
 
	ORDER_WIDGET_SCROLLBAR,
 
@@ -177,13 +178,13 @@ static void DrawOrdersWindow(Window *w)
 

	
 
					if (order->flags & OF_FULL_LOAD) s++; /* service at */
 

	
 
					SetDParam(1, s);
 
					if (order->refit_cargo < NUM_CARGO) {
 
						SetDParam(3, STR_REFIT_ORDER);
 
						SetDParam(4, _cargoc.names_s[order->refit_cargo]);
 
						SetDParam(4, GetCargo(order->refit_cargo)->name);
 
					} else {
 
						SetDParam(3, STR_EMPTY);
 
					}
 
					break;
 
				}
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -34,12 +34,13 @@
 
#include "newgrf_station.h"
 
#include "yapf/yapf.h"
 
#include "date.h"
 
#include "helpers.hpp"
 
#include "misc/autoptr.hpp"
 
#include "road.h"
 
#include "cargotype.h"
 

	
 
/**
 
 * Called if a new block is added to the station-pool
 
 */
 
static void StationPoolNewBlock(uint start_item)
 
{
 
@@ -358,13 +359,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, _cargoc.names_s[cargo[i]]);
 
		SetDParam(i + 1, GetCargo(cargo[i])->name);
 
	}
 

	
 
	SetDParam(0, st->index);
 
	AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0);
 
}
 

	
src/station_gui.cpp
Show inline comments
 
@@ -17,12 +17,13 @@
 
#include "variables.h"
 
#include "vehicle_gui.h"
 
#include "date.h"
 
#include "vehicle.h"
 
#include "table/sprites.h"
 
#include "helpers.hpp"
 
#include "cargotype.h"
 

	
 
enum StationListWidgets {
 
	STATIONLIST_WIDGET_CLOSEBOX = 0,
 
	STATIONLIST_WIDGET_LIST = 3,
 
	STATIONLIST_WIDGET_TRAIN =6,
 
	STATIONLIST_WIDGET_TRUCK,
 
@@ -54,13 +55,16 @@ static StationSortListingTypeFunction St
 
 * @param x,y X/Y coordinate to draw the box at
 
 * @param type Cargo type
 
 * @param amount Cargo amount
 
 * @param rating ratings data for that particular cargo */
 
static void StationsWndShowStationRating(int x, int y, CargoID type, uint amount, byte rating)
 
{
 
	int colour = _cargo_colours[type];
 
	const CargoSpec *cs = GetCargo(type);
 
	if (cs->bitnum == 0xFF) return;
 

	
 
	int colour = cs->rating_colour;
 
	uint w = (minu(amount, 576) + 5) / 36;
 

	
 
	/* Draw total cargo (limited) on station (fits into 16 pixels) */
 
	if (w != 0) GfxFillRect(x, y, x + w - 1, y + 6, colour);
 

	
 
	/* Draw a one pixel-wide bar of additional cargo meter, useful
 
@@ -70,13 +74,13 @@ static void StationsWndShowStationRating
 
		if (rest != 0) {
 
			w += x;
 
			GfxFillRect(w, y + 6 - rest, w, y + 6, colour);
 
		}
 
	}
 

	
 
	DrawString(x + 1, y, _cargoc.names_short[type], 0x10);
 
	DrawString(x + 1, y, cs->abbrev, 0x10);
 

	
 
	/* Draw green/red ratings bar (fits into 14 pixels) */
 
	y += 8;
 
	GfxFillRect(x + 1, y, x + 14, y, 0xB8);
 
	rating = minu(rating,  224) / 16;
 
	if (rating != 0) GfxFillRect(x + 1, y, x + rating, y, 0xD0);
 
@@ -320,14 +324,17 @@ static void PlayerStationsWndProc(Window
 
			x = 89;
 
			y = 14;
 

	
 
			for (i = 0; i < NUM_CARGO; i++) {
 
				cg_ofst = IsWindowWidgetLowered(w, i + STATIONLIST_WIDGET_CARGOSTART) ? 2 : 1;
 

	
 
				GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, _cargo_colours[i]);
 
				DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, _cargoc.names_short[i], 0x10);
 
				const CargoSpec *cs = GetCargo(i);
 
				if (cs->bitnum != 0xFF) {
 
					GfxFillRect(x + cg_ofst, y + cg_ofst, x + cg_ofst + 10 , y + cg_ofst + 7, cs->rating_colour);
 
					DrawStringCentered(x + 6 + cg_ofst, y + cg_ofst, cs->abbrev, 0x10);
 
				}
 
				x += 14;
 
			}
 

	
 
			x += 6;
 
			cg_ofst = IsWindowWidgetLowered(w, STATIONLIST_WIDGET_NOCARGOWAITING) ? 2 : 1;
 
			DrawStringCentered(x + cg_ofst, y + cg_ofst, STR_ABBREV_NONE, 16);
 
@@ -653,13 +660,13 @@ static void DrawStationViewWindow(Window
 

	
 
		num = (waiting + 5) / 10;
 
		if (num != 0) {
 
			int cur_x = x;
 
			num = min(num, 23);
 
			do {
 
				DrawSprite(_cargoc.sprites[i], PAL_NONE, cur_x, y);
 
				DrawSprite(GetCargo(i)->sprite, PAL_NONE, cur_x, y);
 
				cur_x += 10;
 
			} while (--num);
 
		}
 

	
 
		if ( st->goods[i].enroute_from == station_id) {
 
			if (--pos < 0) {
 
@@ -698,13 +705,13 @@ static void DrawStationViewWindow(Window
 
					first = false;
 
				} else {
 
					/* Add a comma if this is not the first item */
 
					*b++ = ',';
 
					*b++ = ' ';
 
				}
 
				b = InlineString(b, _cargoc.names_s[i]);
 
				b = InlineString(b, GetCargo(i)->name);
 
			}
 
		}
 

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

	
 
@@ -713,13 +720,13 @@ static void DrawStationViewWindow(Window
 
	} else {
 
		DrawString(2, 67, STR_3034_LOCAL_RATING_OF_TRANSPORT, 0);
 

	
 
		y = 77;
 
		for (i = 0; i != NUM_CARGO; i++) {
 
			if (st->goods[i].enroute_from != INVALID_STATION) {
 
				SetDParam(0, _cargoc.names_s[i]);
 
				SetDParam(0, GetCargo(i)->name);
 
				SetDParam(2, st->goods[i].rating * 101 >> 8);
 
				SetDParam(1, STR_3035_APPALLING + (st->goods[i].rating >> 5));
 
				DrawString(8, y, STR_303D, 0);
 
				y += 10;
 
			}
 
		}
src/strings.cpp
Show inline comments
 
@@ -14,18 +14,18 @@
 
#include "news.h"
 
#include "screenshot.h"
 
#include "waypoint.h"
 
#include "industry.h"
 
#include "variables.h"
 
#include "newgrf_text.h"
 
#include "table/landscape_const.h"
 
#include "table/control_codes.h"
 
#include "music.h"
 
#include "date.h"
 
#include "industry.h"
 
#include "helpers.hpp"
 
#include "cargotype.h"
 

	
 
/* for opendir/readdir/closedir */
 
# include "fios.h"
 

	
 
char _userstring[128];
 

	
 
@@ -558,13 +558,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 = _cargo_types_base_values[_opt_ptr->landscape].units_volume[GetInt32(&argv)];
 
				StringID cargo_str = GetCargo(GetInt32(&argv))->units_volume;
 
				switch (cargo_str) {
 
					case STR_TONS: {
 
						int32 args[1];
 
						assert(_opt_ptr->units < lengthof(units));
 
						args[0] = GetInt32(&argv) * units[_opt_ptr->units].w_m >> units[_opt_ptr->units].w_s;
 
						buff = FormatString(buff, GetStringPtr(units[_opt_ptr->units].l_weight), args, modifier >> 24, last);
 
@@ -682,13 +682,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) ? (StringID)STR_8838_N_A : _cargoc.names_long[cargo];
 
				StringID cargo_str = (cargo == CT_INVALID) ? (StringID)STR_8838_N_A : GetCargo(cargo)->quantifier;
 
				buff = GetStringWithArgs(buff, cargo_str, argv++, last);
 
				break;
 
			}
 

	
 
			case SCC_POWER: { // {POWER}
 
				int32 args[1];
src/table/cargo_const.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/* Table of all default cargo types */
 

	
 
#define MK(bt, label, c, e, f, g, h, fr, ks1, ks2, ks3, ks4, ks5, l, m) \
 
          {bt, label, 0, c, c, e, f, {g, h}, fr, 0, 0, 0, ks1, ks2, ks3, ks4, ks5, l, m}
 
static const CargoSpec _default_cargo[] = {
 
	MK(  0, 'PASS', 152,  1, 3185,  0,  24, false,
 
		STR_000F_PASSENGERS,     STR_002F_PASSENGER,      STR_PASSENGERS, STR_QUANTITY_PASSENGERS,   STR_ABBREV_PASSENGERS,
 
		SPR_CARGO_PASSENGER,     CC_PASSENGERS  ),
 

	
 
	MK(  1, 'COAL',  32, 16, 5916,  7, 255, true,
 
		STR_0010_COAL,           STR_0030_COAL,           STR_TONS,       STR_QUANTITY_COAL,         STR_ABBREV_COAL,
 
		SPR_CARGO_COAL,          CC_BULK        ),
 

	
 
	MK(  2, 'MAIL',  15,  4, 4550, 20,  90, false,
 
		STR_0011_MAIL,           STR_0031_MAIL,           STR_BAGS,       STR_QUANTITY_MAIL,         STR_ABBREV_MAIL,
 
		SPR_CARGO_MAIL,          CC_MAIL        ),
 

	
 
	MK(  3, 'OIL_', 174, 16, 4437, 25, 255, true,
 
		STR_0012_OIL,            STR_0032_OIL,            STR_LITERS,     STR_QUANTITY_OIL,          STR_ABBREV_OIL,
 
		SPR_CARGO_OIL,           CC_LIQUID      ),
 

	
 
	MK(  4, 'LVST', 208,  3, 4322,  4,  18, true,
 
		STR_0013_LIVESTOCK,      STR_0033_LIVESTOCK,      STR_ITEMS,      STR_QUANTITY_LIVESTOCK,    STR_ABBREV_LIVESTOCK,
 
		SPR_CARGO_LIVESTOCK,     CC_PIECE_GOODS ),
 

	
 
	MK(  5, 'GOOD', 194,  8, 6144,  5,  28, true,
 
		STR_0014_GOODS,          STR_0034_GOODS,          STR_CRATES,     STR_QUANTITY_GOODS,        STR_ABBREV_GOODS,
 
		SPR_CARGO_GOODS,         CC_EXPRESS     ),
 

	
 
	MK(  6, 'GRAI', 191, 16, 4778,  4,  40, true,
 
		STR_0015_GRAIN,          STR_0035_GRAIN,          STR_TONS,       STR_QUANTITY_GRAIN,        STR_ABBREV_GRAIN,
 
		SPR_CARGO_GRAIN,         CC_BULK        ),
 

	
 
	MK(  6, 'WHEA', 191, 16, 4778,  4,  40, true,
 
		STR_0022_WHEAT,          STR_0042_WHEAT,          STR_TONS,       STR_QUANTITY_WHEAT,        STR_ABBREV_WHEAT,
 
		SPR_CARGO_GRAIN,         CC_BULK        ),
 

	
 
	MK(  6, 'MAIZ', 191,  6, 4778,  4,  40, true,
 
		STR_001B_MAIZE,          STR_003B_MAIZE,          STR_TONS,       STR_QUANTITY_MAIZE,        STR_ABBREV_MAIZE,
 
		SPR_CARGO_GRAIN,         CC_BULK        ),
 

	
 
	MK(  7, 'WOOD',  84, 16, 5005, 15, 255, true,
 
		STR_0016_WOOD,           STR_0036_WOOD,           STR_TONS,       STR_QUANTITY_WOOD,         STR_ABBREV_WOOD,
 
		SPR_CARGO_WOOD,          CC_PIECE_GOODS ),
 

	
 
	MK(  8, 'IORE', 184, 16, 5120,  9, 255, true,
 
		STR_0017_IRON_ORE,       STR_0037_IRON_ORE,       STR_TONS,       STR_QUANTITY_IRON_ORE,     STR_ABBREV_IRON_ORE,
 
		SPR_CARGO_IRON_ORE,      CC_BULK        ),
 

	
 
	MK(  9, 'STEL',  10, 16, 5688,  7, 255, true,
 
		STR_0018_STEEL,          STR_0038_STEEL,          STR_TONS,       STR_QUANTITY_STEEL,        STR_ABBREV_STEEL,
 
		SPR_CARGO_STEEL,         CC_PIECE_GOODS ),
 

	
 
	MK( 10, 'VALU', 202,  2, 7509,  1,  32, true,
 
		STR_0019_VALUABLES,      STR_0039_VALUABLES,      STR_BAGS,       STR_QUANTITY_VALUABLES,    STR_ABBREV_VALUABLES,
 
		SPR_CARGO_VALUES_GOLD,   CC_ARMOURED    ),
 

	
 
	MK( 10, 'GOLD', 202,  8, 7509, 10,  40, true,
 
		STR_0020_GOLD,           STR_0040_GOLD,           STR_BAGS,       STR_QUANTITY_GOLD,         STR_ABBREV_GOLD,
 
		SPR_CARGO_VALUES_GOLD,   CC_ARMOURED    ),
 

	
 
	MK( 10, 'DIAM', 202,  2, 7509, 10, 255, true,
 
		STR_001D_DIAMONDS,       STR_003D_DIAMOND,        STR_BAGS,       STR_QUANTITY_DIAMONDS,     STR_ABBREV_DIAMONDS,
 
		SPR_CARGO_DIAMONDS,      CC_ARMOURED    ),
 

	
 
	MK( 11, 'PAPR',  10, 16, 5688,  7,  60, true,
 
		STR_001F_PAPER,          STR_003F_PAPER,          STR_TONS,       STR_QUANTITY_PAPER,        STR_ABBREV_PAPER,
 
		SPR_CARGO_PAPER,         CC_PIECE_GOODS ),
 

	
 
	MK( 12, 'FOOD',  48, 16, 5688,  0,  30, true,
 
		STR_001E_FOOD,           STR_003E_FOOD,           STR_TONS,       STR_QUANTITY_FOOD,         STR_ABBREV_FOOD,
 
		SPR_CARGO_FOOD,          CC_EXPRESS     | CC_REFRIGERATED),
 

	
 
	MK( 13, 'FRUT', 208,  6, 4322,  0,  15, true,
 
		STR_001C_FRUIT,          STR_003C_FRUIT,          STR_TONS,       STR_QUANTITY_FRUIT,        STR_ABBREV_FRUIT,
 
		SPR_CARGO_FRUIT,         CC_BULK        | CC_REFRIGERATED),
 

	
 
	MK( 14, 'CORE', 184,  6, 5120, 12, 255, true,
 
		STR_001A_COPPER_ORE,     STR_003A_COPPER_ORE,     STR_TONS,       STR_QUANTITY_COPPER_ORE,   STR_ABBREV_COPPER_ORE,
 
		SPR_CARGO_COPPER_ORE,    CC_BULK        ),
 

	
 
	MK( 15, 'WATR',  10,  6, 5688, 20,  80, true,
 
		STR_0021_WATER,          STR_0041_WATER,          STR_LITERS,     STR_QUANTITY_WATER,        STR_ABBREV_WATER,
 
		SPR_CARGO_WATERCOLA,     CC_LIQUID      ),
 

	
 
	MK( 16, 'RUBR',  32,  6, 5916,  2,  20, true,
 
		STR_0023_RUBBER,         STR_0043_RUBBER,         STR_LITERS,     STR_QUANTITY_RUBBER,       STR_ABBREV_RUBBER,
 
		SPR_CARGO_RUBBER,        CC_LIQUID      ),
 

	
 
	MK( 17, 'SUGR',  32, 16, 5916, 20, 255, true,
 
		STR_0024_SUGAR,          STR_0044_SUGAR,          STR_TONS,       STR_QUANTITY_SUGAR,        STR_ABBREV_SUGAR,
 
		SPR_CARGO_SUGAR,         CC_BULK        ),
 

	
 
	MK( 18, 'TOYS', 174,  2, 4437, 25, 255, true,
 
		STR_0025_TOYS,           STR_0045_TOY,            STR_NOTHING,    STR_QUANTITY_TOYS,         STR_ABBREV_TOYS,
 
		SPR_CARGO_TOYS,          CC_PIECE_GOODS ),
 

	
 
	MK( 19, 'BATT', 208,  4, 4322,  2,  30, true,
 
		STR_002B_BATTERIES,      STR_004B_BATTERY,        STR_NOTHING,    STR_QUANTITY_BATTERIES,    STR_ABBREV_BATTERIES,
 
		SPR_CARGO_BATTERIES,     CC_PIECE_GOODS ),
 

	
 
	MK( 20, 'SWET', 194,  5, 6144,  8,  40, true,
 
		STR_0026_CANDY,          STR_0046_CANDY,          STR_TONS,       STR_QUANTITY_SWEETS,       STR_ABBREV_SWEETS,
 
		SPR_CARGO_CANDY,         CC_EXPRESS     ),
 

	
 
	MK( 21, 'TOFF', 191, 16, 4778, 14,  60, true,
 
		STR_002A_TOFFEE,         STR_004A_TOFFEE,         STR_TONS,       STR_QUANTITY_TOFFEE,       STR_ABBREV_TOFFEE,
 
		SPR_CARGO_TOFFEE,        CC_BULK        ),
 

	
 
	MK( 22, 'COLA',  84, 16, 5005,  5,  75, true,
 
		STR_0027_COLA,           STR_0047_COLA,           STR_LITERS,     STR_QUANTITY_COLA,         STR_ABBREV_COLA,
 
		SPR_CARGO_WATERCOLA,     CC_LIQUID      ),
 

	
 
	MK( 23, 'CTCD', 184, 16, 5120, 10,  25, true,
 
		STR_0028_COTTON_CANDY,   STR_0048_COTTON_CANDY,   STR_TONS,       STR_QUANTITY_CANDYFLOSS,   STR_ABBREV_CANDYFLOSS,
 
		SPR_CARGO_COTTONCANDY,   CC_BULK        ),
 

	
 
	MK( 24, 'BUBL',  10,  1, 5688, 20,  80, true,
 
		STR_0029_BUBBLES,        STR_0049_BUBBLE,         STR_NOTHING,    STR_QUANTITY_BUBBLES,      STR_ABBREV_BUBBLES,
 
		SPR_CARGO_BUBBLES,       CC_PIECE_GOODS ),
 

	
 
	MK( 25, 'PLST', 202, 16, 7509, 30, 255, true,
 
		STR_002C_PLASTIC,        STR_004C_PLASTIC,        STR_LITERS,     STR_QUANTITY_PLASTIC,      STR_ABBREV_PLASTIC,
 
		SPR_CARGO_PLASTIC,       CC_LIQUID      ),
 

	
 
	MK( 26, 'FZDR',  48,  2, 5688, 30,  50, true,
 
		STR_002D_FIZZY_DRINKS,   STR_004D_FIZZY_DRINK,    STR_NOTHING,    STR_QUANTITY_FIZZY_DRINKS, STR_ABBREV_FIZZY_DRINKS,
 
		SPR_CARGO_FIZZYDRINK,    CC_PIECE_GOODS ),
 

	
 
};
 

	
 

	
 
/* Table of which cargo types are available in each climate, by default */
 
static const CargoLabel _default_climate_cargo[NUM_LANDSCAPE][12] = {
 
	{ 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'GRAI', 'WOOD', 'IORE', 'STEL', 'VALU', 'VOID', },
 
	{ 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'WHEA', 'WOOD', 'VOID', 'PAPR', 'GOLD', 'FOOD', },
 
	{ 'PASS', 'RUBR', 'MAIL', 'OIL_', 'FRUT', 'GOOD', 'MAIZ', 'WOOD', 'CORE', 'WATR', 'DIAM', 'FOOD', },
 
	{ 'PASS', 'SUGR', 'MAIL', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', },
 
};
 

	
src/table/landscape_const.h
Show inline comments
 
deleted file
src/train_cmd.cpp
Show inline comments
 
@@ -30,12 +30,13 @@
 
#include "newgrf_engine.h"
 
#include "newgrf_sound.h"
 
#include "newgrf_text.h"
 
#include "direction.h"
 
#include "yapf/yapf.h"
 
#include "date.h"
 
#include "cargotype.h"
 

	
 
static bool TrainCheckIfLineEnds(Vehicle *v);
 
static void TrainController(Vehicle *v, bool update_image);
 

	
 
static const byte _vehicle_initial_x_fract[4] = {10, 8, 4,  8};
 
static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10};
 
@@ -103,13 +104,13 @@ static void TrainCargoChanged(Vehicle* v
 
{
 
	Vehicle *u;
 
	uint32 weight = 0;
 

	
 
	for (u = v; u != NULL; u = u->next) {
 
		const RailVehicleInfo *rvi = RailVehInfo(u->engine_type);
 
		uint32 vweight = (_cargoc.weights[u->cargo_type] * u->cargo_count * FreightWagonMult(u->cargo_type)) / 16;
 
		uint32 vweight = (GetCargo(u->cargo_type)->weight * u->cargo_count * FreightWagonMult(u->cargo_type)) / 16;
 

	
 
		// Vehicle weight is not added for articulated parts.
 
		if (!IsArticulatedPart(u)) {
 
			// vehicle weight is the sum of the weight of the vehicle and the weight of its cargo
 
			vweight += rvi->weight;
 

	
src/variables.h
Show inline comments
 
@@ -334,25 +334,12 @@ VARDEF uint16 _cur_resolution[2];
 
VARDEF char _savegame_format[8];
 

	
 
VARDEF char *_config_file;
 
VARDEF char *_highscore_file;
 
VARDEF char *_log_file;
 

	
 
// NOSAVE: These can be recalculated from InitializeLandscapeVariables
 
typedef struct {
 
	StringID names_s[NUM_CARGO];
 
	StringID names_long[NUM_CARGO];
 
	StringID names_short[NUM_CARGO];
 
	byte weights[NUM_CARGO];
 
	SpriteID sprites[NUM_CARGO];
 
	byte transit_days_1[NUM_CARGO];
 
	byte transit_days_2[NUM_CARGO];
 
} CargoConst;
 

	
 
VARDEF CargoConst _cargoc;
 

	
 

	
 
static inline void SetDParamX(uint32 *s, uint n, uint32 v)
 
{
 
	s[n] = v;
 
}
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -25,12 +25,13 @@
 
#include "date.h"
 
#include "ship.h"
 
#include "aircraft.h"
 
#include "roadveh.h"
 
#include "depot.h"
 
#include "helpers.hpp"
 
#include "cargotype.h"
 

	
 
typedef struct Sorting {
 
	Listing aircraft;
 
	Listing roadveh;
 
	Listing ship;
 
	Listing train;
 
@@ -301,13 +302,13 @@ static RefitOption *DrawVehicleRefitWind
 
			selected = &refit[i];
 
			colour = 12;
 
		}
 

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

	
 
			/* If the callback succeeded, draw the cargo suffix */
 
			if (refit[i].value != CALLBACK_FAILED) {
 
				DrawString(last_x + 1, y, GetGRFStringID(GetEngineGRFID(refit[i].engine), 0xD000 + refit[i].value), colour);
 
			}
 
			y += delta;
 
@@ -518,13 +519,13 @@ uint ShowRefitOptionsList(int x, int y, 
 
		}
 

	
 
		/* Add each cargo type to the list */
 
		for (cid = 0; cmask != 0; cmask >>= 1, cid++) {
 
			if (!HASBIT(cmask, 0)) continue;
 

	
 
			b = InlineString(b, _cargoc.names_s[_local_cargo_id_ctype[cid]]);
 
			b = InlineString(b, GetCargo(_local_cargo_id_ctype[cid])->name);
 
			if (cmask > 1) b = strecpy(b, ", ", lastof(_userstring));
 
		}
 
	}
 

	
 
	/* Terminate and display the completed string */
 
	*b = '\0';
0 comments (0 inline, 0 general)