industry.h
author Darkvater
Sat, 02 Apr 2005 23:05:09 +0000
changeset 1632 10c391e108b7
parent 1330 5d76a0522a11
child 2186 db48cf29b983
permissions -rw-r--r--
(svn r2136) - Fix: [ 1174313 ] terrain hotkeys nonfunctional in scenario editor (D,Q,W,E,R,T,Y,U fltr)
- Fix: 'L' no longer opens ingame terraform bar in scenario editor bar, but the land generator one
- Feature: [ 1095110 ] Create Lake and draggable Create Desert tools (initial implementation GoneWacko), also added sticky buttons to land generator and town generator
- CodeChange: moved around some of the draggable tools, demystifying them
- CodeChange: change CmdBuildCanal to allow for XANDY dragging not only X or Y (only scenario editor)
- CodeChange: add some more enums to sprites.
- TODO: merge most of the ingame and scenario editor land terraform code. This can only be done after OnClickButton function is changed so it also includes the backreference to the widget being clicked, postponed to after 0.4.0
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     1
#ifndef INDUSTRY_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     2
#define INDUSTRY_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
1267
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
     4
#include "pool.h"
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
     5
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
struct Industry {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
	TileIndex xy;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
	byte width; /* swapped order of w/h with town */
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
	byte height;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
	Town *town;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    11
	byte produced_cargo[2];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
	uint16 cargo_waiting[2];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    13
	byte production_rate[2];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    14
	byte accepts_cargo[3];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
	byte prod_level;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    16
	uint16 last_mo_production[2];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    17
	uint16 last_mo_transported[2];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    18
	byte pct_transported[2];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    19
	uint16 total_production[2];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    20
	uint16 total_transported[2];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
	uint16 counter;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    23
	byte type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    24
	byte owner;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    25
	byte color_map;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    26
	byte last_prod_year;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
	byte was_cargo_delivered;
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 830
diff changeset
    28
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 830
diff changeset
    29
	uint16 index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
1267
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    32
extern MemoryPool _industry_pool;
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 830
diff changeset
    33
1267
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    34
/**
1330
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1267
diff changeset
    35
 * Check if an Industry really exists.
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1267
diff changeset
    36
 */
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1267
diff changeset
    37
static inline bool IsValidIndustry(Industry* industry)
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1267
diff changeset
    38
{
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1267
diff changeset
    39
	return industry->xy != 0; /* XXX: Replace by INVALID_TILE someday */
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1267
diff changeset
    40
}
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1267
diff changeset
    41
5d76a0522a11 (svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents: 1267
diff changeset
    42
/**
1267
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    43
 * Get the pointer to the industry with index 'index'
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    44
 */
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    45
static inline Industry *GetIndustry(uint index)
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    46
{
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    47
	return (Industry*)GetItemFromPool(&_industry_pool, index);
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    48
}
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    49
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    50
/**
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    51
 * Get the current size of the IndustryPool
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    52
 */
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    53
static inline uint16 GetIndustryPoolSize(void)
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    54
{
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    55
	return _industry_pool.total_items;
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    56
}
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    57
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    58
#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1 < GetIndustryPoolSize()) ? GetIndustry(i->index + 1) : NULL)
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    59
#define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0)
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    60
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    61
VARDEF int _total_industries; // For the AI: the amount of industries active
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 830
diff changeset
    62
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 830
diff changeset
    63
VARDEF uint16 *_industry_sort;
1267
ba42a505ab8a (svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents: 1220
diff changeset
    64
VARDEF bool _industry_sort_dirty;
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 830
diff changeset
    65
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
void DeleteIndustry(Industry *is);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
enum {
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
	IT_COAL_MINE = 0,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	IT_POWER_STATION = 1,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	IT_SAWMILL = 2,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
	IT_FOREST = 3,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    73
	IT_OIL_REFINERY = 4,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
	IT_OIL_RIG = 5,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
	IT_FACTORY = 6,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
	IT_PRINTING_WORKS = 7,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
	IT_STEEL_MILL = 8,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
	IT_FARM = 9,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
	IT_COPPER_MINE = 10,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	IT_OIL_WELL = 11,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
	IT_BANK = 12,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	IT_FOOD_PROCESS = 13,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
	IT_PAPER_MILL = 14,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	IT_GOLD_MINE = 15,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	IT_BANK_2 = 16,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	IT_DIAMOND_MINE = 17,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	IT_IRON_MINE = 18,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	IT_FRUIT_PLANTATION = 19,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
	IT_RUBBER_PLANTATION = 20,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	IT_WATER_SUPPLY = 21,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	IT_WATER_TOWER = 22,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	IT_FACTORY_2 = 23,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	IT_FARM_2 = 24,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	IT_LUMBER_MILL = 25,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    95
	IT_COTTON_CANDY = 26,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	IT_CANDY_FACTORY = 27,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    97
	IT_BATTERY_FARM = 28,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	IT_COLA_WELLS = 29,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
	IT_TOY_SHOP = 30,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
	IT_TOY_FACTORY = 31,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	IT_PLASTIC_FOUNTAINS = 32,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	IT_FIZZY_DRINK_FACTORY = 33,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	IT_BUBBLE_GENERATOR = 34,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
	IT_TOFFEE_QUARRY = 35,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
	IT_SUGAR_MINE = 36,
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
#endif