Files @ r4681:f719e26018b5
Branch filter:

Location: cpp/openttd-patchpack/source/industry.h - annotation

bjarni
(svn r6586) -Feature: [depot window] added a vehicle list window with all vehicles having a certain depot in their orders
It got one known issue though. The top bar got a plural issue so expect to see stuff like "1 trains" until we figure out why it behaves this way
Added the button to the depot windows. Made the autoreplace button bigger while I was moving some widgets anyway
Made road vehicle depot windows start with one more row to make room for the buttons
r2186:5ee653b1b5e1
r2186:5ee653b1b5e1
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r4328:abeae2374271
r4328:abeae2374271
r4328:abeae2374271
r4328:abeae2374271
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r2630:73464cd368d6
r3344:abc4ac7cb74a
r0:d63b455452f6
r0:d63b455452f6
r3344:abc4ac7cb74a
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r0:d63b455452f6
r3350:3c52d6fd465c
r0:d63b455452f6
r4326:7102aa7f4fb2
r0:d63b455452f6
r919:57ef81f1ba8e
r4330:1186b19da099
r0:d63b455452f6
r0:d63b455452f6
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r3689:445f66c2333d
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1330:62eaa061ec97
r1330:62eaa061ec97
r4346:fa4ac6b6f852
r1330:62eaa061ec97
r4346:fa4ac6b6f852
r1330:62eaa061ec97
r1330:62eaa061ec97
r1330:62eaa061ec97
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r919:57ef81f1ba8e
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4357:4a0463b63644
r4354:95cd3ce6deea
r4354:95cd3ce6deea
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4356:03f88658c85b
r4403:2c2ffbb59c83
r4403:2c2ffbb59c83
r4403:2c2ffbb59c83
r4403:2c2ffbb59c83
r4403:2c2ffbb59c83
r4403:2c2ffbb59c83
r4403:2c2ffbb59c83
r4403:2c2ffbb59c83
r4346:fa4ac6b6f852
r1267:78c35aaf06ff
r1267:78c35aaf06ff
r4277:fd4235a66bc9
r1267:78c35aaf06ff
r919:57ef81f1ba8e
r3496:675e7d4a3bf2
r0:d63b455452f6
r4328:abeae2374271
r0:d63b455452f6
r0:d63b455452f6
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r4344:bff007ae1fd1
r3499:c30aa286c5b5
r4344:bff007ae1fd1
r0:d63b455452f6
r0:d63b455452f6
r3496:675e7d4a3bf2
r3496:675e7d4a3bf2
r3496:675e7d4a3bf2
r3496:675e7d4a3bf2
r3496:675e7d4a3bf2
r3496:675e7d4a3bf2
r2436:963efe8b84cc
/* $Id$ */

#ifndef INDUSTRY_H
#define INDUSTRY_H

#include "pool.h"

typedef byte IndustryGfx;
typedef uint8 IndustryType;

enum {
	INVALID_INDUSTRY = 0xFFFF,
};

struct Industry {
	TileIndex xy;
	byte width; /* swapped order of w/h with town */
	byte height;
	const Town* town;
	CargoID produced_cargo[2];
	uint16 cargo_waiting[2];
	byte production_rate[2];
	CargoID accepts_cargo[3];
	byte prod_level;
	uint16 last_mo_production[2];
	uint16 last_mo_transported[2];
	byte pct_transported[2];
	uint16 total_production[2];
	uint16 total_transported[2];
	uint16 counter;

	byte type;
	byte owner;
	byte color_map;
	Year last_prod_year;
	byte was_cargo_delivered;

	IndustryID index;
};

typedef struct IndustryTileTable {
	TileIndexDiffC ti;
	IndustryGfx gfx;
} IndustryTileTable;

typedef struct IndustrySpec {
	/** Tables with the 'layout' of different composition of GFXes */
	const IndustryTileTable *const *table;
	/** Number of elements in the table */
	byte num_table;
	/** Base cost multiplier*/
	byte cost_multiplier;
	/** Industries this industry cannot be close to */
	IndustryType conflicting[3];
	/** index to a procedure to check for conflicting circumstances */
	byte check_proc;

	CargoID produced_cargo[2];
	byte production_rate[2];
	/** The minimum amount of cargo transported to the stations; if the
	 * waiting cargo is less than this number, no cargo is moved to it*/
	byte minimal_cargo;
	CargoID accepts_cargo[3];

	StringID closure_text;
	StringID production_up_text;
	StringID production_down_text;
} IndustrySpec;

const IndustrySpec *GetIndustrySpec(IndustryType thistype);

extern MemoryPool _industry_pool;

/**
 * Check if an Industry really exists.
 */
static inline bool IsValidIndustry(const Industry *industry)
{
	return industry->xy != 0;
}

/**
 * Get the pointer to the industry with index 'index'
 */
static inline Industry *GetIndustry(uint index)
{
	return (Industry*)GetItemFromPool(&_industry_pool, index);
}

/**
 * Get the current size of the IndustryPool
 */
static inline uint16 GetIndustryPoolSize(void)
{
	return _industry_pool.total_items;
}

VARDEF int _total_industries;

static inline IndustryID GetIndustryArraySize(void)
{
	/* TODO - This isn't the real content of the function, but
	 *  with the new pool-system this will be replaced with one that
	 *  _really_ returns the highest index + 1. Now it just returns
	 *  the next safe value we are sure about everything is below.
	 */
	return _total_industries;
}

/**
 * Return a random valid town.
 */
static inline Industry *GetRandomIndustry(void)
{
	uint num = RandomRange(GetIndustryArraySize());
	uint index = 0;

	if (GetIndustryArraySize() == 0) return NULL;

	while (num > 0) {
		num--;

		index++;
		/* Make sure we have a valid industry */
		while (GetIndustry(index) == NULL) {
			index++;
			if (index == GetIndustryArraySize()) index = 0;
		}
	}

	return GetIndustry(index);
}

void DestroyIndustry(Industry *i);

static inline void DeleteIndustry(Industry *i)
{
	DestroyIndustry(i);
	i->xy = 0;
}

#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL) if (IsValidIndustry(i))
#define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0)

VARDEF const Industry** _industry_sort;
VARDEF bool _industry_sort_dirty;


void DeleteIndustry(Industry *is);
void PlantRandomFarmField(const Industry *i);

enum {
	IT_COAL_MINE           =   0,
	IT_POWER_STATION       =   1,
	IT_SAWMILL             =   2,
	IT_FOREST              =   3,
	IT_OIL_REFINERY        =   4,
	IT_OIL_RIG             =   5,
	IT_FACTORY             =   6,
	IT_PRINTING_WORKS      =   7,
	IT_STEEL_MILL          =   8,
	IT_FARM                =   9,
	IT_COPPER_MINE         =  10,
	IT_OIL_WELL            =  11,
	IT_BANK_TEMP           =  12,
	IT_FOOD_PROCESS        =  13,
	IT_PAPER_MILL          =  14,
	IT_GOLD_MINE           =  15,
	IT_BANK_TROPIC_ARCTIC  =  16,
	IT_DIAMOND_MINE        =  17,
	IT_IRON_MINE           =  18,
	IT_FRUIT_PLANTATION    =  19,
	IT_RUBBER_PLANTATION   =  20,
	IT_WATER_SUPPLY        =  21,
	IT_WATER_TOWER         =  22,
	IT_FACTORY_2           =  23,
	IT_FARM_2              =  24,
	IT_LUMBER_MILL         =  25,
	IT_COTTON_CANDY        =  26,
	IT_CANDY_FACTORY       =  27,
	IT_BATTERY_FARM        =  28,
	IT_COLA_WELLS          =  29,
	IT_TOY_SHOP            =  30,
	IT_TOY_FACTORY         =  31,
	IT_PLASTIC_FOUNTAINS   =  32,
	IT_FIZZY_DRINK_FACTORY =  33,
	IT_BUBBLE_GENERATOR    =  34,
	IT_TOFFEE_QUARRY       =  35,
	IT_SUGAR_MINE          =  36,
	IT_END,
	IT_INVALID             = 255,
};

typedef enum IndustryLifeTypes {
	INDUSTRYLIFE_NOT_CLOSABLE,     ///< Industry can never close
	INDUSTRYLIFE_PRODUCTION,       ///< Industry can close and change of production
	INDUSTRYLIFE_CLOSABLE,         ///< Industry can only close (no production change)
} IndustryLifeType;

#endif /* INDUSTRY_H */