author | belugas |
Fri, 20 Jul 2007 16:50:11 +0000 | |
changeset 7290 | bb6d72d5230a |
parent 7288 | 9059a49c2102 |
child 7291 | 5e5bc8463be7 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
3 |
/** @file industry_cmd.cpp */ |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1881
diff
changeset
|
6 |
#include "openttd.h" |
3144
33e42feae531
(svn r3763) Adapt to the new 'map accessors go in foo_map.h'-scheme
tron
parents:
3094
diff
changeset
|
7 |
#include "clear_map.h" |
4356
ec4e13f21cd0
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
8 |
#include "functions.h" |
3314
6aaeba4b92e8
(svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
3296
diff
changeset
|
9 |
#include "industry_map.h" |
3338
7cff208f0446
(svn r4120) Use the new station functions where appropriate
tron
parents:
3331
diff
changeset
|
10 |
#include "station_map.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
11 |
#include "table/strings.h" |
7266
b16e67e992b4
(svn r10587) -Codechange: move the string/dparam related stuff from variables.h to strings.h
rubidium
parents:
7262
diff
changeset
|
12 |
#include "strings.h" |
2148
542ea702738c
(svn r2658) -Codechange: Use MAKE_TRANSPARENT to display a transparented sprite
celestar
parents:
2140
diff
changeset
|
13 |
#include "table/sprites.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
552
diff
changeset
|
14 |
#include "map.h" |
1209
2e00193652b2
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1202
diff
changeset
|
15 |
#include "tile.h" |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6307
diff
changeset
|
16 |
#include "landscape.h" |
0 | 17 |
#include "viewport.h" |
18 |
#include "command.h" |
|
19 |
#include "industry.h" |
|
20 |
#include "town.h" |
|
21 |
#include "vehicle.h" |
|
22 |
#include "news.h" |
|
23 |
#include "saveload.h" |
|
24 |
#include "economy.h" |
|
337
cbe0c766c947
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
314
diff
changeset
|
25 |
#include "sound.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2150
diff
changeset
|
26 |
#include "variables.h" |
3654
c09872510a61
(svn r4568) CodeChange : Bring definitions and uses of DrawTypesStructures toguether.
belugas
parents:
3645
diff
changeset
|
27 |
#include "table/industry_land.h" |
c09872510a61
(svn r4568) CodeChange : Bring definitions and uses of DrawTypesStructures toguether.
belugas
parents:
3645
diff
changeset
|
28 |
#include "table/build_industry.h" |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
29 |
#include "genworld.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4231
diff
changeset
|
30 |
#include "date.h" |
5056
8fabd0020af7
(svn r7109) -Codechange: use map accessor IsClearWaterTile
belugas
parents:
4976
diff
changeset
|
31 |
#include "water_map.h" |
5909
35595e20c0c4
(svn r8535) -Feature: Allow lumbermill to cut trees only when they are full grown.
belugas
parents:
5884
diff
changeset
|
32 |
#include "tree_map.h" |
6091
c8827d9ae04a
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
5909
diff
changeset
|
33 |
#include "cargotype.h" |
7168
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7165
diff
changeset
|
34 |
#include "newgrf_industries.h" |
6970
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
35 |
#include "newgrf_industrytiles.h" |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
36 |
#include "newgrf_callbacks.h" |
0 | 37 |
|
4403
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
38 |
void ShowIndustryViewWindow(int industry); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
39 |
void BuildOilRig(TileIndex tile); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
40 |
|
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
41 |
static byte _industry_sound_ctr; |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
42 |
static TileIndex _industry_sound_tile; |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
43 |
|
6824
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
44 |
int _total_industries; //general counter |
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
45 |
uint16 _industry_counts[NUM_INDUSTRYTYPES]; // Number of industries per type ingame |
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
46 |
|
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
47 |
const Industry **_industry_sort; |
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
48 |
bool _industry_sort_dirty; |
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
49 |
|
6743
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
50 |
IndustrySpec _industry_specs[NUM_INDUSTRYTYPES]; |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
51 |
IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES]; |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
52 |
|
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
53 |
/** This function initialize the spec arrays of both |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
54 |
* industry and industry tiles. |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
55 |
* It adjusts the enabling of the industry too, based on climate availability. |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
56 |
* This will allow for clearer testings */ |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
57 |
void ResetIndustries() |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
58 |
{ |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
59 |
memset(&_industry_specs, 0, sizeof(_industry_specs)); |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
60 |
memcpy(&_industry_specs, &_origin_industry_specs, sizeof(_origin_industry_specs)); |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
61 |
|
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
62 |
/* once performed, enable only the current climate industries */ |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
63 |
for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) { |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
64 |
_industry_specs[i].enabled = HASBIT(_origin_industry_specs[i].climate_availability, _opt.landscape); |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
65 |
} |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
66 |
|
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
67 |
memset(&_industry_tile_specs, 0, sizeof(_industry_tile_specs)); |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
68 |
memcpy(&_industry_tile_specs, &_origin_industry_tile_specs, sizeof(_origin_industry_tile_specs)); |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
69 |
} |
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
70 |
|
7261
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
71 |
void ResetIndustryCreationProbility(IndustryType type) |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
72 |
{ |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
73 |
assert(type < INVALID_INDUSTRYTYPE); |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
74 |
_industry_specs[type].appear_creation[_opt.landscape] = 0; |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
75 |
} |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
76 |
|
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
77 |
/** |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
78 |
* Called if a new block is added to the industry-pool |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
79 |
*/ |
2817 | 80 |
static void IndustryPoolNewBlock(uint start_item) |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
81 |
{ |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
82 |
Industry *i; |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
83 |
|
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
84 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
85 |
* TODO - This is just a temporary stage, this will be removed. */ |
4976
2e3d5e8ec510
(svn r6979) Use the pool macros for the Industry pool
tron
parents:
4965
diff
changeset
|
86 |
for (i = GetIndustry(start_item); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? GetIndustry(i->index + 1U) : NULL) i->index = start_item++; |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
87 |
} |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
88 |
|
5216
8bd14ee39af2
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
5118
diff
changeset
|
89 |
DEFINE_OLD_POOL(Industry, Industry, IndustryPoolNewBlock, NULL) |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
90 |
|
3499
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
91 |
/** |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
92 |
* Retrieve the type for this industry. Although it is accessed by a tile, |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
93 |
* it will return the general type of industry, and not the sprite index |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
94 |
* as would do GetIndustryGfx. |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
95 |
* @param tile that is queried |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
96 |
* @pre IsTileType(tile, MP_INDUSTRY) |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
97 |
* @return general type for this industry, as defined in industry.h |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
98 |
**/ |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
99 |
IndustryType GetIndustryType(TileIndex tile) |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
100 |
{ |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
101 |
assert(IsTileType(tile, MP_INDUSTRY)); |
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
102 |
|
6639
d9e4445b518d
(svn r9870) -Codechange: Silence two compiler warnings and give proper type to the "type" member of industry struct
belugas
parents:
6636
diff
changeset
|
103 |
const Industry *ind = GetIndustryByTile(tile); |
d9e4445b518d
(svn r9870) -Codechange: Silence two compiler warnings and give proper type to the "type" member of industry struct
belugas
parents:
6636
diff
changeset
|
104 |
return IsValidIndustry(ind) ? ind->type : (IndustryType)IT_INVALID; |
3499
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
105 |
} |
0 | 106 |
|
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
107 |
/** |
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
108 |
* Accessor for array _industry_specs. |
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
109 |
* This will ensure at once : proper access and |
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
110 |
* not allowing modifications of it. |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
111 |
* @param thistype of industry (which is the index in _industry_specs) |
6493
6bbb7ebd6a31
(svn r9676) -Codechange: introduce NUM_INDUSTRYTYPES instead of IT_END.
belugas
parents:
6491
diff
changeset
|
112 |
* @pre thistype < NUM_INDUSTRYTYPES |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
113 |
* @return a pointer to the corresponding industry spec |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
114 |
**/ |
3689
50a3fd4ba752
(svn r4614) CodeChange : Cleanup of industry_cmd (Step-4).
belugas
parents:
3669
diff
changeset
|
115 |
const IndustrySpec *GetIndustrySpec(IndustryType thistype) |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
116 |
{ |
6493
6bbb7ebd6a31
(svn r9676) -Codechange: introduce NUM_INDUSTRYTYPES instead of IT_END.
belugas
parents:
6491
diff
changeset
|
117 |
assert(thistype < NUM_INDUSTRYTYPES); |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
118 |
return &_industry_specs[thistype]; |
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
119 |
} |
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
120 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
121 |
/** |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
122 |
* Accessor for array _industry_tile_specs. |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
123 |
* This will ensure at once : proper access and |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
124 |
* not allowing modifications of it. |
7288
9059a49c2102
(svn r10635) -Codechange: Correct some typos and code beautifying (a little bit)
belugas
parents:
7266
diff
changeset
|
125 |
* @param gfx of industrytile (which is the index in _industry_tile_specs) |
6749
be85c217e87e
(svn r9984) -Codechange: Remove an obsolete structure and a now meaningless enum, in favor of the "real thing"
belugas
parents:
6748
diff
changeset
|
126 |
* @pre gfx < INVALID_INDUSTRYTILE |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
127 |
* @return a pointer to the corresponding industrytile spec |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
128 |
**/ |
6092
53c6b9b18d0b
(svn r8827) -Codechange: Cleanup of industry_cmd (Step-6). Implementation of IndustryTileSPec, the alter ego of IndustrySpec.
belugas
parents:
6091
diff
changeset
|
129 |
const IndustryTileSpec *GetIndustryTileSpec(IndustryGfx gfx) |
53c6b9b18d0b
(svn r8827) -Codechange: Cleanup of industry_cmd (Step-6). Implementation of IndustryTileSPec, the alter ego of IndustrySpec.
belugas
parents:
6091
diff
changeset
|
130 |
{ |
6749
be85c217e87e
(svn r9984) -Codechange: Remove an obsolete structure and a now meaningless enum, in favor of the "real thing"
belugas
parents:
6748
diff
changeset
|
131 |
assert(gfx < INVALID_INDUSTRYTILE); |
6092
53c6b9b18d0b
(svn r8827) -Codechange: Cleanup of industry_cmd (Step-6). Implementation of IndustryTileSPec, the alter ego of IndustrySpec.
belugas
parents:
6091
diff
changeset
|
132 |
return &_industry_tile_specs[gfx]; |
53c6b9b18d0b
(svn r8827) -Codechange: Cleanup of industry_cmd (Step-6). Implementation of IndustryTileSPec, the alter ego of IndustrySpec.
belugas
parents:
6091
diff
changeset
|
133 |
} |
53c6b9b18d0b
(svn r8827) -Codechange: Cleanup of industry_cmd (Step-6). Implementation of IndustryTileSPec, the alter ego of IndustrySpec.
belugas
parents:
6091
diff
changeset
|
134 |
|
4403
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
135 |
void DestroyIndustry(Industry *i) |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
136 |
{ |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
137 |
BEGIN_TILE_LOOP(tile_cur, i->width, i->height, i->xy); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
138 |
if (IsTileType(tile_cur, MP_INDUSTRY)) { |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
139 |
if (GetIndustryIndex(tile_cur) == i->index) { |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
140 |
DoClearSquare(tile_cur); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
141 |
} |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
142 |
} else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) { |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
143 |
DeleteOilRig(tile_cur); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
144 |
} |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
145 |
END_TILE_LOOP(tile_cur, i->width, i->height, i->xy); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
146 |
|
6390
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
147 |
if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_FIELDS) { |
4403
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
148 |
/* Remove the farmland and convert it to regular tiles over time. */ |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
149 |
BEGIN_TILE_LOOP(tile_cur, 42, 42, i->xy - TileDiffXY(21, 21)) { |
4815
d702c4027451
(svn r6739) -Fix (r6001): Crash on removing farmland belonging to a farm. The search would loop
Darkvater
parents:
4607
diff
changeset
|
150 |
tile_cur = TILE_MASK(tile_cur); |
4403
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
151 |
if (IsTileType(tile_cur, MP_CLEAR) && IsClearGround(tile_cur, CLEAR_FIELDS) && |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
152 |
GetIndustryIndexOfField(tile_cur) == i->index) { |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
153 |
SetIndustryIndexOfField(tile_cur, INVALID_INDUSTRY); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
154 |
} |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
155 |
} END_TILE_LOOP(tile_cur, 42, 42, i->xy - TileDiff(21, 21)) |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
156 |
} |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
157 |
|
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
158 |
_industry_sort_dirty = true; |
6824
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
159 |
DecIndustryTypeCount(i->type); |
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
160 |
|
4403
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
161 |
DeleteSubsidyWithIndustry(i->index); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
162 |
DeleteWindowById(WC_INDUSTRY_VIEW, i->index); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
163 |
InvalidateWindow(WC_INDUSTRY_DIRECTORY, 0); |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
164 |
} |
3f503ac2d0f9
(svn r6156) -Codechange: DeleteIndustry removes an industry from the pool
truelight
parents:
4357
diff
changeset
|
165 |
|
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
166 |
static void IndustryDrawSugarMine(const TileInfo *ti) |
0 | 167 |
{ |
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
168 |
const DrawIndustryAnimationStruct *d; |
0 | 169 |
|
3321
4061bfef1830
(svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents:
3320
diff
changeset
|
170 |
if (!IsIndustryCompleted(ti->tile)) return; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
171 |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
172 |
d = &_draw_industry_spec1[GetIndustryAnimationState(ti->tile)]; |
0 | 173 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
174 |
AddChildSpriteScreen(SPR_IT_SUGAR_MINE_SIEVE + d->image_1, PAL_NONE, d->x, 0); |
0 | 175 |
|
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
176 |
if (d->image_2 != 0) { |
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
177 |
AddChildSpriteScreen(SPR_IT_SUGAR_MINE_CLOUDS + d->image_2 - 1, PAL_NONE, 8, 41); |
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
178 |
} |
0 | 179 |
|
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
180 |
if (d->image_3 != 0) { |
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
181 |
AddChildSpriteScreen(SPR_IT_SUGAR_MINE_PILE + d->image_3 - 1, PAL_NONE, |
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
182 |
_drawtile_proc1[d->image_3 - 1].x, _drawtile_proc1[d->image_3 - 1].y); |
2639 | 183 |
} |
0 | 184 |
} |
185 |
||
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
186 |
static void IndustryDrawToffeeQuarry(const TileInfo *ti) |
0 | 187 |
{ |
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
188 |
uint8 x = 0; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
189 |
|
3321
4061bfef1830
(svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents:
3320
diff
changeset
|
190 |
if (IsIndustryCompleted(ti->tile)) { |
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
191 |
x = _industry_anim_offs_toffee[GetIndustryAnimationState(ti->tile)]; |
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
192 |
if (x == 0xFF) |
0 | 193 |
x = 0; |
194 |
} |
|
195 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
196 |
AddChildSpriteScreen(SPR_IT_TOFFEE_QUARRY_SHOVEL, PAL_NONE, 22 - x, 24 + x); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
197 |
AddChildSpriteScreen(SPR_IT_TOFFEE_QUARRY_TOFFEE, PAL_NONE, 6, 14); |
0 | 198 |
} |
199 |
||
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
200 |
static void IndustryDrawBubbleGenerator( const TileInfo *ti) |
0 | 201 |
{ |
3321
4061bfef1830
(svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents:
3320
diff
changeset
|
202 |
if (IsIndustryCompleted(ti->tile)) { |
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
203 |
AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_BUBBLE, PAL_NONE, 5, _industry_anim_offs_bubbles[GetIndustryAnimationState(ti->tile)]); |
2639 | 204 |
} else { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
205 |
AddChildSpriteScreen(SPR_IT_BUBBLE_GENERATOR_SPRING, PAL_NONE, 3, 67); |
0 | 206 |
} |
207 |
} |
|
208 |
||
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
209 |
static void IndustryDrawToyFactory(const TileInfo *ti) |
0 | 210 |
{ |
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
211 |
const DrawIndustryAnimationStruct *d; |
0 | 212 |
|
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
213 |
d = &_industry_anim_offs_toys[GetIndustryAnimationState(ti->tile)]; |
0 | 214 |
|
215 |
if (d->image_1 != 0xFF) { |
|
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
216 |
AddChildSpriteScreen(SPR_IT_TOY_FACTORY_CLAY, PAL_NONE, d->x, 96 + d->image_1); |
0 | 217 |
} |
218 |
||
219 |
if (d->image_2 != 0xFF) { |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
220 |
AddChildSpriteScreen(SPR_IT_TOY_FACTORY_ROBOT, PAL_NONE, 16 - d->image_2 * 2, 100 + d->image_2); |
0 | 221 |
} |
222 |
||
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
223 |
AddChildSpriteScreen(SPR_IT_TOY_FACTORY_STAMP, PAL_NONE, 7, d->image_3); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
224 |
AddChildSpriteScreen(SPR_IT_TOY_FACTORY_STAMP_HOLDER, PAL_NONE, 0, 42); |
0 | 225 |
} |
226 |
||
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
227 |
static void IndustryDrawCoalPlantSparks(const TileInfo *ti) |
0 | 228 |
{ |
3321
4061bfef1830
(svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents:
3320
diff
changeset
|
229 |
if (IsIndustryCompleted(ti->tile)) { |
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
230 |
uint8 image = GetIndustryAnimationState(ti->tile); |
3321
4061bfef1830
(svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents:
3320
diff
changeset
|
231 |
|
0 | 232 |
if (image != 0 && image < 7) { |
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
233 |
AddChildSpriteScreen(image + SPR_IT_POWER_PLANT_TRANSFORMERS, |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
234 |
PAL_NONE, |
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
235 |
_coal_plant_sparks[image - 1].x, |
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
236 |
_coal_plant_sparks[image - 1].y |
0 | 237 |
); |
238 |
} |
|
239 |
} |
|
240 |
} |
|
241 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2360
diff
changeset
|
242 |
typedef void IndustryDrawTileProc(const TileInfo *ti); |
0 | 243 |
static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = { |
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
244 |
IndustryDrawSugarMine, |
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
245 |
IndustryDrawToffeeQuarry, |
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
246 |
IndustryDrawBubbleGenerator, |
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
247 |
IndustryDrawToyFactory, |
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
248 |
IndustryDrawCoalPlantSparks, |
0 | 249 |
}; |
250 |
||
251 |
static void DrawTile_Industry(TileInfo *ti) |
|
252 |
{ |
|
6970
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
253 |
IndustryGfx gfx = GetIndustryGfx(ti->tile); |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
254 |
Industry *ind = GetIndustryByTile(ti->tile); |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
255 |
const IndustryTileSpec *indts = GetIndustryTileSpec(gfx); |
3654
c09872510a61
(svn r4568) CodeChange : Bring definitions and uses of DrawTypesStructures toguether.
belugas
parents:
3645
diff
changeset
|
256 |
const DrawBuildingsTileStruct *dits; |
0 | 257 |
byte z; |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
258 |
SpriteID image; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
259 |
SpriteID pal; |
0 | 260 |
|
6970
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
261 |
/* Retrieve pointer to the draw industry tile struct */ |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
262 |
if (gfx >= NEW_INDUSTRYTILEOFFSET) { |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
263 |
/* Draw the tile using the specialized method of newgrf industrytile. |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
264 |
* DrawNewIndustry will return false if ever the resolver could not |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
265 |
* find any sprite to display. So in this case, we will jump on the |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
266 |
* substitute gfx instead. */ |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
267 |
if (indts->grf_prop.spritegroup != NULL && DrawNewIndustryTile(ti, ind, gfx, indts)) { |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
268 |
return; |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
269 |
} else { |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
270 |
/* No sprite group (or no valid one) found, meaning no graphics associated. |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
271 |
* Use the substitute one instead */ |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
272 |
gfx = indts->grf_prop.subst_id; |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
273 |
/* And point the industrytile spec accordingly */ |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
274 |
indts = GetIndustryTileSpec(indts->grf_prop.subst_id); |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
275 |
} |
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
276 |
} |
0 | 277 |
|
6970
b489d8ec5d4a
(svn r10226) -Codechange: Add support for newindustry tiles drawing.
belugas
parents:
6950
diff
changeset
|
278 |
dits = &_industry_draw_tile_data[gfx << 2 | (indts->anim_state ? |
5436
b3d017be25b4
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5435
diff
changeset
|
279 |
GetIndustryAnimationState(ti->tile) & 3 : |
b3d017be25b4
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5435
diff
changeset
|
280 |
GetIndustryConstructionStage(ti->tile))]; |
0 | 281 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
282 |
image = dits->ground.sprite; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
283 |
if (HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->ground.pal == PAL_NONE) { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
284 |
pal = GENERAL_SPRITE_COLOR(ind->random_color); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
285 |
} else { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
286 |
pal = dits->ground.pal; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
287 |
} |
0 | 288 |
|
289 |
z = ti->z; |
|
290 |
/* Add bricks below the industry? */ |
|
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3585
diff
changeset
|
291 |
if (ti->tileh != SLOPE_FLAT) { |
7035
9af867b5802a
(svn r10299) -Codechange [FS#931]: industry foundations should be drawn as all other foundations, i.e. with DrawFoundation, instead of writing the same functionality itself.
rubidium
parents:
7026
diff
changeset
|
292 |
DrawFoundation(ti, ti->tileh); |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
293 |
z += TILE_HEIGHT; |
0 | 294 |
} |
295 |
||
7035
9af867b5802a
(svn r10299) -Codechange [FS#931]: industry foundations should be drawn as all other foundations, i.e. with DrawFoundation, instead of writing the same functionality itself.
rubidium
parents:
7026
diff
changeset
|
296 |
DrawGroundSprite(image, pal); |
9af867b5802a
(svn r10299) -Codechange [FS#931]: industry foundations should be drawn as all other foundations, i.e. with DrawFoundation, instead of writing the same functionality itself.
rubidium
parents:
7026
diff
changeset
|
297 |
|
0 | 298 |
/* Add industry on top of the ground? */ |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
299 |
image = dits->building.sprite; |
2639 | 300 |
if (image != 0) { |
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6419
diff
changeset
|
301 |
if (HASBIT(_transparent_opt, TO_INDUSTRIES)) { |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
302 |
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT); |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
303 |
pal = PALETTE_TO_TRANSPARENT; |
6910
4e5e2247bf53
(svn r10163) -Fix(r8128): Industries had lost their random recoloring. A test was removed and is now reintroduced in another way.
belugas
parents:
6893
diff
changeset
|
304 |
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR) && dits->building.pal == PAL_NONE) { |
4e5e2247bf53
(svn r10163) -Fix(r8128): Industries had lost their random recoloring. A test was removed and is now reintroduced in another way.
belugas
parents:
6893
diff
changeset
|
305 |
pal = GENERAL_SPRITE_COLOR(ind->random_color); |
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
306 |
} else { |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
307 |
pal = dits->building.pal; |
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
308 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
309 |
|
5668
36b39f4a9032
(svn r8128) -Codechange: Split sprite and palette remap into separate 32 bit values.
peter1138
parents:
5587
diff
changeset
|
310 |
AddSortableSpriteToDraw(image, pal, |
2653
b1945642bf27
(svn r3195) Use bitfields instead of explicit shifting/masking
tron
parents:
2639
diff
changeset
|
311 |
ti->x + dits->subtile_x, |
b1945642bf27
(svn r3195) Use bitfields instead of explicit shifting/masking
tron
parents:
2639
diff
changeset
|
312 |
ti->y + dits->subtile_y, |
b1945642bf27
(svn r3195) Use bitfields instead of explicit shifting/masking
tron
parents:
2639
diff
changeset
|
313 |
dits->width + 1, |
b1945642bf27
(svn r3195) Use bitfields instead of explicit shifting/masking
tron
parents:
2639
diff
changeset
|
314 |
dits->height + 1, |
0 | 315 |
dits->dz, |
316 |
z); |
|
317 |
||
6427
7dc1012757d8
(svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138
parents:
6419
diff
changeset
|
318 |
if (HASBIT(_transparent_opt, TO_INDUSTRIES)) return; |
0 | 319 |
} |
320 |
||
2639 | 321 |
{ |
3654
c09872510a61
(svn r4568) CodeChange : Bring definitions and uses of DrawTypesStructures toguether.
belugas
parents:
3645
diff
changeset
|
322 |
int proc = dits->draw_proc - 1; |
2639 | 323 |
if (proc >= 0) _industry_draw_tile_procs[proc](ti); |
0 | 324 |
} |
325 |
} |
|
326 |
||
4231
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4077
diff
changeset
|
327 |
static uint GetSlopeZ_Industry(TileIndex tile, uint x, uint y) |
2537 | 328 |
{ |
4231
2823b3643862
(svn r5794) Pass the TileIndex plus x and y coordinates into GetSlopeZ_* instead of a TileInfo
tron
parents:
4077
diff
changeset
|
329 |
return GetTileMaxZ(tile); |
0 | 330 |
} |
331 |
||
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3585
diff
changeset
|
332 |
static Slope GetSlopeTileh_Industry(TileIndex tile, Slope tileh) |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2537
diff
changeset
|
333 |
{ |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3585
diff
changeset
|
334 |
return SLOPE_FLAT; |
39 | 335 |
} |
336 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
337 |
static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac) |
0 | 338 |
{ |
7199
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
339 |
IndustryGfx gfx = GetIndustryGfx(tile); |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
340 |
const IndustryTileSpec *itspec = GetIndustryTileSpec(gfx); |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
341 |
|
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
342 |
/* When we have to use a callback, we put our data in the next two variables */ |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
343 |
CargoID raw_accepts_cargo[lengthof(itspec->accepts_cargo)]; |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
344 |
uint8 raw_acceptance[lengthof(itspec->acceptance)]; |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
345 |
|
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
346 |
/* And then these will always point to a same sized array with the required data */ |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
347 |
const CargoID *accepts_cargo = itspec->accepts_cargo; |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
348 |
const uint8 *acceptance = itspec->acceptance; |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
349 |
|
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
350 |
if (HASBIT(itspec->callback_flags, CBM_INDT_ACCEPT_CARGO)) { |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
351 |
uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, GetIndustryByTile(tile), tile); |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
352 |
if (res != CALLBACK_FAILED) { |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
353 |
accepts_cargo = raw_accepts_cargo; |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
354 |
for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_accepts_cargo[i] = GetCargoTranslation(GB(res, i * 5, 5), itspec->grf_prop.grffile); |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
355 |
} |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
356 |
} |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
357 |
|
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
358 |
if (HASBIT(itspec->callback_flags, CBM_INDT_CARGO_ACCEPTANCE)) { |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
359 |
uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, GetIndustryByTile(tile), tile); |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
360 |
if (res != CALLBACK_FAILED) { |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
361 |
acceptance = raw_acceptance; |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
362 |
for (uint i = 0; i < lengthof(itspec->accepts_cargo); i++) raw_acceptance[i] = GB(res, i * 4, 4); |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
363 |
} |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
364 |
} |
0 | 365 |
|
6736
9f55d5e22875
(svn r9969) -Codechange: Cleanup of industries (Step-14). Remove hardcoded-run-time tile acceptance and put in corresponding tile
belugas
parents:
6683
diff
changeset
|
366 |
for (byte i = 0; i < lengthof(itspec->accepts_cargo); i++) { |
7199
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
367 |
CargoID a = accepts_cargo[i]; |
e65a28455ee3
(svn r10477) -Codechange: add some callbacks to customise the acceptance of industries.
rubidium
parents:
7186
diff
changeset
|
368 |
if (a != CT_INVALID) ac[a] = acceptance[i]; |
6736
9f55d5e22875
(svn r9969) -Codechange: Cleanup of industries (Step-14). Remove hardcoded-run-time tile acceptance and put in corresponding tile
belugas
parents:
6683
diff
changeset
|
369 |
} |
0 | 370 |
} |
371 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
372 |
static void GetTileDesc_Industry(TileIndex tile, TileDesc *td) |
0 | 373 |
{ |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
374 |
const Industry *i = GetIndustryByTile(tile); |
0 | 375 |
|
376 |
td->owner = i->owner; |
|
4942
7fb6c39eb421
(svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents:
4924
diff
changeset
|
377 |
td->str = GetIndustrySpec(i->type)->name; |
3321
4061bfef1830
(svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents:
3320
diff
changeset
|
378 |
if (!IsIndustryCompleted(tile)) { |
534
306bc86eb23e
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
507
diff
changeset
|
379 |
SetDParamX(td->dparam, 0, td->str); |
0 | 380 |
td->str = STR_2058_UNDER_CONSTRUCTION; |
381 |
} |
|
382 |
} |
|
383 |
||
6943
1914f26aee04
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
6910
diff
changeset
|
384 |
static CommandCost ClearTile_Industry(TileIndex tile, byte flags) |
0 | 385 |
{ |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
386 |
Industry *i = GetIndustryByTile(tile); |
6390
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
387 |
const IndustrySpec *indspec = GetIndustrySpec(i->type); |
0 | 388 |
|
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4403
diff
changeset
|
389 |
/* water can destroy industries |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4403
diff
changeset
|
390 |
* in editor you can bulldoze industries |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4403
diff
changeset
|
391 |
* with magic_bulldozer cheat you can destroy industries |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4403
diff
changeset
|
392 |
* (area around OILRIG is water, so water shouldn't flood it |
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4403
diff
changeset
|
393 |
*/ |
149
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
131
diff
changeset
|
394 |
if ((_current_player != OWNER_WATER && _game_mode != GM_EDITOR && |
5f7d4b21df01
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater
parents:
131
diff
changeset
|
395 |
!_cheats.magic_bulldozer.value) || |
6390
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
396 |
(_current_player == OWNER_WATER && (indspec->behaviour & INDUSTRYBEH_BUILT_ONWATER))) { |
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
397 |
SetDParam(0, indspec->name); |
0 | 398 |
return_cmd_error(STR_4800_IN_THE_WAY); |
399 |
} |
|
400 |
||
2639 | 401 |
if (flags & DC_EXEC) DeleteIndustry(i); |
6950
14ecb0acdfb4
(svn r10205) -Codechange: refactor returning of cost, so it can be more easily modified.
rubidium
parents:
6943
diff
changeset
|
402 |
return CommandCost(); |
0 | 403 |
} |
404 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
405 |
static void TransportIndustryGoods(TileIndex tile) |
0 | 406 |
{ |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
407 |
Industry *i = GetIndustryByTile(tile); |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
408 |
const IndustrySpec *indspec = GetIndustrySpec(i->type); |
0 | 409 |
uint cw, am; |
410 |
||
7165
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
411 |
cw = min(i->produced_cargo_waiting[0], 255); |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
412 |
if (cw > indspec->minimal_cargo/* && i->produced_cargo[0] != 0xFF*/) { |
7165
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
413 |
i->produced_cargo_waiting[0] -= cw; |
0 | 414 |
|
415 |
/* fluctuating economy? */ |
|
2639 | 416 |
if (_economy.fluct <= 0) cw = (cw + 1) / 2; |
0 | 417 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
418 |
i->this_month_production[0] += cw; |
0 | 419 |
|
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
420 |
am = MoveGoodsToStation(i->xy, i->width, i->height, indspec->produced_cargo[0], cw); |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
421 |
i->this_month_transported[0] += am; |
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
422 |
if (am != 0 && !StartStopIndustryTileAnimation(i, IAT_INDUSTRY_DISTRIBUTES_CARGO)) { |
6305
185ebf766d4e
(svn r9162) -Codechange: Cleanup of industry_cmd (Step-8). Gather tile animation data into IndustryTileSpec array
belugas
parents:
6283
diff
changeset
|
423 |
uint newgfx = GetIndustryTileSpec(GetIndustryGfx(tile))->anim_production; |
3331 | 424 |
|
6743
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
425 |
if (newgfx != INDUSTRYTILE_NOANIM) { |
3495
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
426 |
ResetIndustryConstructionStage(tile); |
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
427 |
SetIndustryCompleted(tile, true); |
3331 | 428 |
SetIndustryGfx(tile, newgfx); |
429 |
MarkTileDirtyByTile(tile); |
|
430 |
} |
|
0 | 431 |
} |
432 |
} |
|
433 |
||
7165
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
434 |
cw = min(i->produced_cargo_waiting[1], 255); |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
435 |
if (cw > indspec->minimal_cargo) { |
7165
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
436 |
i->produced_cargo_waiting[1] -= cw; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
437 |
|
2639 | 438 |
if (_economy.fluct <= 0) cw = (cw + 1) / 2; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
439 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
440 |
i->this_month_production[1] += cw; |
0 | 441 |
|
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
442 |
am = MoveGoodsToStation(i->xy, i->width, i->height, indspec->produced_cargo[1], cw); |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
443 |
i->this_month_transported[1] += am; |
0 | 444 |
} |
445 |
} |
|
446 |
||
447 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
448 |
static void AnimateTile_Industry(TileIndex tile) |
0 | 449 |
{ |
3331 | 450 |
byte m; |
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
451 |
IndustryGfx gfx = GetIndustryGfx(tile); |
0 | 452 |
|
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
453 |
if (GetIndustryTileSpec(gfx)->animation_info != 0xFFFF) { |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
454 |
AnimateNewIndustryTile(tile); |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
455 |
return; |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
456 |
} |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
457 |
|
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
458 |
switch (gfx) { |
3545
b08ce1bbb589
(svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents:
3538
diff
changeset
|
459 |
case GFX_SUGAR_MINE_SIEVE: |
0 | 460 |
if ((_tick_counter & 1) == 0) { |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
461 |
m = GetIndustryAnimationState(tile) + 1; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
462 |
|
2952 | 463 |
switch (m & 7) { |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4403
diff
changeset
|
464 |
case 2: SndPlayTileFx(SND_2D_RIP_2, tile); break; |
541 | 465 |
case 6: SndPlayTileFx(SND_29_RIP, tile); break; |
0 | 466 |
} |
467 |
||
468 |
if (m >= 96) { |
|
469 |
m = 0; |
|
470 |
DeleteAnimatedTile(tile); |
|
471 |
} |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
472 |
SetIndustryAnimationState(tile, m); |
0 | 473 |
|
474 |
MarkTileDirtyByTile(tile); |
|
475 |
} |
|
476 |
break; |
|
477 |
||
3545
b08ce1bbb589
(svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents:
3538
diff
changeset
|
478 |
case GFX_TOFFEE_QUARY: |
0 | 479 |
if ((_tick_counter & 3) == 0) { |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
480 |
m = GetIndustryAnimationState(tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
481 |
|
6519
3207d8852fb9
(svn r9705) -Codechange: Merge some data arrays together, making a bit more logical units.
belugas
parents:
6493
diff
changeset
|
482 |
if (_industry_anim_offs_toffee[m] == 0xFF) { |
541 | 483 |
SndPlayTileFx(SND_30_CARTOON_SOUND, tile); |
0 | 484 |
} |
485 |
||
486 |
if (++m >= 70) { |
|
487 |
m = 0; |
|
488 |
DeleteAnimatedTile(tile); |
|
489 |
} |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
490 |
SetIndustryAnimationState(tile, m); |
0 | 491 |
|
492 |
MarkTileDirtyByTile(tile); |
|
493 |
} |
|
494 |
break; |
|
495 |
||
3545
b08ce1bbb589
(svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents:
3538
diff
changeset
|
496 |
case GFX_BUBBLE_CATCHER: |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
497 |
if ((_tick_counter & 1) == 0) { |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
498 |
m = GetIndustryAnimationState(tile); |
0 | 499 |
|
500 |
if (++m >= 40) { |
|
501 |
m = 0; |
|
502 |
DeleteAnimatedTile(tile); |
|
503 |
} |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
504 |
SetIndustryAnimationState(tile, m); |
0 | 505 |
|
506 |
MarkTileDirtyByTile(tile); |
|
507 |
} |
|
508 |
break; |
|
509 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
510 |
/* Sparks on a coal plant */ |
3545
b08ce1bbb589
(svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents:
3538
diff
changeset
|
511 |
case GFX_POWERPLANT_SPARKS: |
0 | 512 |
if ((_tick_counter & 3) == 0) { |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
513 |
m = GetIndustryAnimationState(tile); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
514 |
if (m == 6) { |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
515 |
SetIndustryAnimationState(tile, 0); |
0 | 516 |
DeleteAnimatedTile(tile); |
517 |
} else { |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
518 |
SetIndustryAnimationState(tile, m + 1); |
0 | 519 |
MarkTileDirtyByTile(tile); |
520 |
} |
|
521 |
} |
|
522 |
break; |
|
523 |
||
3545
b08ce1bbb589
(svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents:
3538
diff
changeset
|
524 |
case GFX_TOY_FACTORY: |
0 | 525 |
if ((_tick_counter & 1) == 0) { |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
526 |
m = GetIndustryAnimationState(tile) + 1; |
0 | 527 |
|
6468
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
528 |
switch (m) { |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
529 |
case 1: SndPlayTileFx(SND_2C_MACHINERY, tile); break; |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
530 |
case 23: SndPlayTileFx(SND_2B_COMEDY_HIT, tile); break; |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
531 |
case 28: SndPlayTileFx(SND_2A_EXTRACT_AND_POP, tile); break; |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
532 |
default: |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
533 |
if (m >= 50) { |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
534 |
int n = GetIndustryAnimationLoop(tile) + 1; |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
535 |
m = 0; |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
536 |
if (n >= 8) { |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
537 |
n = 0; |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
538 |
DeleteAnimatedTile(tile); |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
539 |
} |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
540 |
SetIndustryAnimationLoop(tile, n); |
ab54a3aeeacd
(svn r9644) -Codechange: if else cascade into a switch case
belugas
parents:
6467
diff
changeset
|
541 |
} |
0 | 542 |
} |
543 |
||
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
544 |
SetIndustryAnimationState(tile, m); |
0 | 545 |
MarkTileDirtyByTile(tile); |
546 |
} |
|
547 |
break; |
|
548 |
||
5434
4739ee9714f5
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents:
5319
diff
changeset
|
549 |
case GFX_PLASTIC_FOUNTAIN_ANIMATED_1: case GFX_PLASTIC_FOUNTAIN_ANIMATED_2: |
4739ee9714f5
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents:
5319
diff
changeset
|
550 |
case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4: |
4739ee9714f5
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents:
5319
diff
changeset
|
551 |
case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6: |
4739ee9714f5
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents:
5319
diff
changeset
|
552 |
case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8: |
0 | 553 |
if ((_tick_counter & 3) == 0) { |
3499
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
554 |
IndustryGfx gfx = GetIndustryGfx(tile); |
0 | 555 |
|
3331 | 556 |
gfx = (gfx < 155) ? gfx + 1 : 148; |
557 |
SetIndustryGfx(tile, gfx); |
|
0 | 558 |
MarkTileDirtyByTile(tile); |
559 |
} |
|
560 |
break; |
|
561 |
||
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
562 |
case GFX_OILWELL_ANIMATED_1: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
563 |
case GFX_OILWELL_ANIMATED_2: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
564 |
case GFX_OILWELL_ANIMATED_3: |
0 | 565 |
if ((_tick_counter & 7) == 0) { |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6468
diff
changeset
|
566 |
bool b = CHANCE16(1, 7); |
3499
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
567 |
IndustryGfx gfx = GetIndustryGfx(tile); |
3331 | 568 |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
569 |
m = GetIndustryAnimationState(tile) + 1; |
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
570 |
if (m == 4 && (m = 0, ++gfx) == GFX_OILWELL_ANIMATED_3 + 1 && (gfx = GFX_OILWELL_ANIMATED_1, b)) { |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
571 |
SetIndustryGfx(tile, GFX_OILWELL_NOT_ANIMATED); |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
572 |
SetIndustryConstructionStage(tile, 3); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
573 |
DeleteAnimatedTile(tile); |
0 | 574 |
} else { |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
575 |
SetIndustryAnimationState(tile, m); |
3331 | 576 |
SetIndustryGfx(tile, gfx); |
0 | 577 |
MarkTileDirtyByTile(tile); |
578 |
} |
|
579 |
} |
|
580 |
break; |
|
581 |
||
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
582 |
case GFX_COAL_MINE_TOWER_ANIMATED: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
583 |
case GFX_COPPER_MINE_TOWER_ANIMATED: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
584 |
case GFX_GOLD_MINE_TOWER_ANIMATED: { |
0 | 585 |
int state = _tick_counter & 0x7FF; |
586 |
||
587 |
if ((state -= 0x400) < 0) |
|
588 |
return; |
|
589 |
||
590 |
if (state < 0x1A0) { |
|
591 |
if (state < 0x20 || state >= 0x180) { |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
592 |
m = GetIndustryAnimationState(tile); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
593 |
if (!(m & 0x40)) { |
5436
b3d017be25b4
(svn r7642) -Codechange: unify all the different locations where the animation state is stored into a single location.
rubidium
parents:
5435
diff
changeset
|
594 |
SetIndustryAnimationState(tile, m | 0x40); |
541 | 595 |
SndPlayTileFx(SND_0B_MINING_MACHINERY, tile); |
0 | 596 |
} |
597 |
if (state & 7) |
|
598 |
return; |
|
599 |
} else { |
|
600 |
if (state & 3) |
|
601 |
return; |
|
602 |
} |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
603 |
m = (GetIndustryAnimationState(tile) + 1) | 0x40; |
0 | 604 |
if (m > 0xC2) m = 0xC0; |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
605 |
SetIndustryAnimationState(tile, m); |
0 | 606 |
MarkTileDirtyByTile(tile); |
607 |
} else if (state >= 0x200 && state < 0x3A0) { |
|
608 |
int i; |
|
609 |
i = (state < 0x220 || state >= 0x380) ? 7 : 3; |
|
610 |
if (state & i) |
|
611 |
return; |
|
612 |
||
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
613 |
m = (GetIndustryAnimationState(tile) & 0xBF) - 1; |
0 | 614 |
if (m < 0x80) m = 0x82; |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
615 |
SetIndustryAnimationState(tile, m); |
0 | 616 |
MarkTileDirtyByTile(tile); |
617 |
} |
|
618 |
} break; |
|
619 |
} |
|
620 |
} |
|
621 |
||
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
622 |
static void CreateIndustryEffectSmoke(TileIndex tile) |
0 | 623 |
{ |
3773
0019b5f70ea9
(svn r4765) Add GetTileMaxZ(), which returns the height of the highest corner of a tile, and use it to simplify the code in a few places
tron
parents:
3689
diff
changeset
|
624 |
uint x = TileX(tile) * TILE_SIZE; |
0019b5f70ea9
(svn r4765) Add GetTileMaxZ(), which returns the height of the highest corner of a tile, and use it to simplify the code in a few places
tron
parents:
3689
diff
changeset
|
625 |
uint y = TileY(tile) * TILE_SIZE; |
0019b5f70ea9
(svn r4765) Add GetTileMaxZ(), which returns the height of the highest corner of a tile, and use it to simplify the code in a few places
tron
parents:
3689
diff
changeset
|
626 |
uint z = GetTileMaxZ(tile); |
3094 | 627 |
|
3773
0019b5f70ea9
(svn r4765) Add GetTileMaxZ(), which returns the height of the highest corner of a tile, and use it to simplify the code in a few places
tron
parents:
3689
diff
changeset
|
628 |
CreateEffectVehicle(x + 15, y + 14, z + 59, EV_CHIMNEY_SMOKE); |
0 | 629 |
} |
630 |
||
3495
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
631 |
static void MakeIndustryTileBigger(TileIndex tile) |
0 | 632 |
{ |
3495
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
633 |
byte cnt = GetIndustryConstructionCounter(tile) + 1; |
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
634 |
byte stage; |
0 | 635 |
|
3495
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
636 |
if (cnt != 4) { |
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
637 |
SetIndustryConstructionCounter(tile, cnt); |
0 | 638 |
return; |
639 |
} |
|
640 |
||
3495
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
641 |
stage = GetIndustryConstructionStage(tile) + 1; |
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
642 |
SetIndustryConstructionCounter(tile, 0); |
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
643 |
SetIndustryConstructionStage(tile, stage); |
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
644 |
StartStopIndustryTileAnimation(tile, IAT_CONSTRUCTION_STATE_CHANGE); |
3495
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
645 |
if (stage == 3) { |
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
646 |
SetIndustryCompleted(tile, true); |
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
647 |
} |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
648 |
|
0 | 649 |
MarkTileDirtyByTile(tile); |
650 |
||
3321
4061bfef1830
(svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents:
3320
diff
changeset
|
651 |
if (!IsIndustryCompleted(tile)) return; |
0 | 652 |
|
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
653 |
IndustryGfx gfx = GetIndustryGfx(tile); |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
654 |
if (gfx >= NEW_INDUSTRYTILEOFFSET) { |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
655 |
/* New industry */ |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
656 |
const IndustryTileSpec *its = GetIndustryTileSpec(gfx); |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
657 |
if (its->animation_info != 0xFFFF) AddAnimatedTile(tile); |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
658 |
return; |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
659 |
} |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
660 |
|
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
661 |
switch (gfx) { |
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
662 |
case GFX_POWERPLANT_CHIMNEY: |
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
663 |
CreateIndustryEffectSmoke(tile); |
0 | 664 |
break; |
665 |
||
4607
323a239feef7
(svn r6459) - Fix (r6433): An enum mixup caused oilrigs to not have a station part. Thanks to Znuff for pointing out.
peter1138
parents:
4587
diff
changeset
|
666 |
case GFX_OILRIG_1: |
323a239feef7
(svn r6459) - Fix (r6433): An enum mixup caused oilrigs to not have a station part. Thanks to Znuff for pointing out.
peter1138
parents:
4587
diff
changeset
|
667 |
if (GetIndustryGfx(tile + TileDiffXY(0, 1)) == GFX_OILRIG_1) BuildOilRig(tile); |
0 | 668 |
break; |
669 |
||
3545
b08ce1bbb589
(svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents:
3538
diff
changeset
|
670 |
case GFX_TOY_FACTORY: |
b08ce1bbb589
(svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents:
3538
diff
changeset
|
671 |
case GFX_BUBBLE_CATCHER: |
b08ce1bbb589
(svn r4411) CodeChange : Define and use some Gfx for both stations and industries. More are still to come
belugas
parents:
3538
diff
changeset
|
672 |
case GFX_TOFFEE_QUARY: |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
673 |
SetIndustryAnimationState(tile, 0); |
3538
750c4ea83357
(svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents:
3499
diff
changeset
|
674 |
SetIndustryAnimationLoop(tile, 0); |
0 | 675 |
break; |
676 |
||
5434
4739ee9714f5
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents:
5319
diff
changeset
|
677 |
case GFX_PLASTIC_FOUNTAIN_ANIMATED_1: case GFX_PLASTIC_FOUNTAIN_ANIMATED_2: |
4739ee9714f5
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents:
5319
diff
changeset
|
678 |
case GFX_PLASTIC_FOUNTAIN_ANIMATED_3: case GFX_PLASTIC_FOUNTAIN_ANIMATED_4: |
4739ee9714f5
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents:
5319
diff
changeset
|
679 |
case GFX_PLASTIC_FOUNTAIN_ANIMATED_5: case GFX_PLASTIC_FOUNTAIN_ANIMATED_6: |
4739ee9714f5
(svn r7640) -Codechange: move a table from industry_cmd.c to table/industry_land
rubidium
parents:
5319
diff
changeset
|
680 |
case GFX_PLASTIC_FOUNTAIN_ANIMATED_7: case GFX_PLASTIC_FOUNTAIN_ANIMATED_8: |
0 | 681 |
AddAnimatedTile(tile); |
682 |
break; |
|
683 |
} |
|
684 |
} |
|
685 |
||
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
686 |
static void TileLoopIndustry_BubbleGenerator(TileIndex tile) |
0 | 687 |
{ |
688 |
int dir; |
|
689 |
Vehicle *v; |
|
690 |
static const int8 _tileloop_ind_case_161[12] = { |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
691 |
11, 0, -4, -14, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
692 |
-4, -10, -4, 1, |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
693 |
49, 59, 60, 65, |
0 | 694 |
}; |
695 |
||
541 | 696 |
SndPlayTileFx(SND_2E_EXTRACT_AND_POP, tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
697 |
|
0 | 698 |
dir = Random() & 3; |
699 |
||
700 |
v = CreateEffectVehicleAbove( |
|
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3418
diff
changeset
|
701 |
TileX(tile) * TILE_SIZE + _tileloop_ind_case_161[dir + 0], |
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3418
diff
changeset
|
702 |
TileY(tile) * TILE_SIZE + _tileloop_ind_case_161[dir + 4], |
0 | 703 |
_tileloop_ind_case_161[dir + 8], |
1359
52782e5cf7c9
(svn r1863) Give the effect vehicle type enums more descriptive names and use the enum as parameter type for CreateEffectVehicle*()
tron
parents:
1335
diff
changeset
|
704 |
EV_BUBBLE |
0 | 705 |
); |
706 |
||
2639 | 707 |
if (v != NULL) v->u.special.unk2 = dir; |
0 | 708 |
} |
709 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
710 |
static void TileLoop_Industry(TileIndex tile) |
0 | 711 |
{ |
3499
92f95849788c
(svn r4350) CodeChange : Add and use accessors [G|S]etIndustrype. Define and use IndustryGfx type instead of uint
belugas
parents:
3496
diff
changeset
|
712 |
IndustryGfx newgfx; |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
713 |
IndustryGfx gfx; |
0 | 714 |
|
3321
4061bfef1830
(svn r4087) Add IsIndustryCompleted() to check if a industry tile is fully built
tron
parents:
3320
diff
changeset
|
715 |
if (!IsIndustryCompleted(tile)) { |
3495
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
716 |
MakeIndustryTileBigger(tile); |
0 | 717 |
return; |
718 |
} |
|
719 |
||
2639 | 720 |
if (_game_mode == GM_EDITOR) return; |
0 | 721 |
|
722 |
TransportIndustryGoods(tile); |
|
723 |
||
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
724 |
if (StartStopIndustryTileAnimation(tile, IAT_TILELOOP)) return; |
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
725 |
|
6305
185ebf766d4e
(svn r9162) -Codechange: Cleanup of industry_cmd (Step-8). Gather tile animation data into IndustryTileSpec array
belugas
parents:
6283
diff
changeset
|
726 |
newgfx = GetIndustryTileSpec(GetIndustryGfx(tile))->anim_next; |
6743
e84a3b89d46b
(svn r9976) -Codechange: Declare a writable array of specs for industry and industry tiles.
belugas
parents:
6736
diff
changeset
|
727 |
if (newgfx != INDUSTRYTILE_NOANIM) { |
3495
6672c181ace4
(svn r4346) CodeChange : Add and Use Accessors to Industry's Stage and Counter construction. Removed last direct map access from Disaster_cmd.c as well. Based on work from Rubidium in tfc_newmap
belugas
parents:
3494
diff
changeset
|
728 |
ResetIndustryConstructionStage(tile); |
3331 | 729 |
SetIndustryGfx(tile, newgfx); |
0 | 730 |
MarkTileDirtyByTile(tile); |
731 |
return; |
|
732 |
} |
|
733 |
||
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
734 |
gfx = GetIndustryGfx(tile); |
0 | 735 |
|
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
736 |
switch (gfx) { |
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
737 |
case GFX_OILRIG_1: // coast line at oilrigs |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
738 |
case GFX_OILRIG_2: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
739 |
case GFX_OILRIG_3: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
740 |
case GFX_OILRIG_4: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
741 |
case GFX_OILRIG_5: |
43
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
742 |
TileLoop_Water(tile); |
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
743 |
break; |
3b93861c5478
(svn r44) Fix: Coast line near edge of map and near oilrigs (Dribbel)
dominik
parents:
39
diff
changeset
|
744 |
|
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
745 |
case GFX_COAL_MINE_TOWER_NOT_ANIMATED: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
746 |
case GFX_COPPER_MINE_TOWER_NOT_ANIMATED: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
747 |
case GFX_GOLD_MINE_TOWER_NOT_ANIMATED: |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
748 |
if (!(_tick_counter & 0x400) && CHANCE16(1, 2)) { |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
749 |
switch (gfx) { |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
750 |
case GFX_COAL_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COAL_MINE_TOWER_ANIMATED; break; |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
751 |
case GFX_COPPER_MINE_TOWER_NOT_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_ANIMATED; break; |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
752 |
case GFX_GOLD_MINE_TOWER_NOT_ANIMATED: gfx = GFX_GOLD_MINE_TOWER_ANIMATED; break; |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
753 |
} |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
754 |
SetIndustryGfx(tile, gfx); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
755 |
SetIndustryAnimationState(tile, 0x80); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
756 |
AddAnimatedTile(tile); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
757 |
} |
0 | 758 |
break; |
759 |
||
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
760 |
case GFX_OILWELL_NOT_ANIMATED: |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
761 |
if (CHANCE16(1, 6)) { |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
762 |
SetIndustryGfx(tile, GFX_OILWELL_ANIMATED_1); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
763 |
SetIndustryAnimationState(tile, 0); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
764 |
AddAnimatedTile(tile); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
765 |
} |
0 | 766 |
break; |
767 |
||
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
768 |
case GFX_COAL_MINE_TOWER_ANIMATED: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
769 |
case GFX_COPPER_MINE_TOWER_ANIMATED: |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
770 |
case GFX_GOLD_MINE_TOWER_ANIMATED: |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
771 |
if (!(_tick_counter & 0x400)) { |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
772 |
switch (gfx) { |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
773 |
case GFX_COAL_MINE_TOWER_ANIMATED: gfx = GFX_COAL_MINE_TOWER_NOT_ANIMATED; break; |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
774 |
case GFX_COPPER_MINE_TOWER_ANIMATED: gfx = GFX_COPPER_MINE_TOWER_NOT_ANIMATED; break; |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
775 |
case GFX_GOLD_MINE_TOWER_ANIMATED: gfx = GFX_GOLD_MINE_TOWER_NOT_ANIMATED; break; |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
776 |
} |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
777 |
SetIndustryGfx(tile, gfx); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
778 |
SetIndustryCompleted(tile, true); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
779 |
SetIndustryConstructionStage(tile, 3); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
780 |
DeleteAnimatedTile(tile); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
781 |
} |
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
782 |
break; |
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
783 |
|
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
784 |
case GFX_POWERPLANT_SPARKS: |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6468
diff
changeset
|
785 |
if (CHANCE16(1, 3)) { |
541 | 786 |
SndPlayTileFx(SND_0C_ELECTRIC_SPARK, tile); |
0 | 787 |
AddAnimatedTile(tile); |
788 |
} |
|
789 |
break; |
|
790 |
||
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
791 |
case GFX_COPPER_MINE_CHIMNEY: |
3421
7968a4b5ff0a
(svn r4246) -Codechange. Replaced about 100 occurences of '16' by TILE_SIZE
celestar
parents:
3418
diff
changeset
|
792 |
CreateEffectVehicleAbove(TileX(tile) * TILE_SIZE + 6, TileY(tile) * TILE_SIZE + 6, 43, EV_SMOKE); |
2639 | 793 |
break; |
0 | 794 |
|
795 |
||
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
796 |
case GFX_TOY_FACTORY: { |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
797 |
Industry *i = GetIndustryByTile(tile); |
0 | 798 |
if (i->was_cargo_delivered) { |
799 |
i->was_cargo_delivered = false; |
|
3538
750c4ea83357
(svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents:
3499
diff
changeset
|
800 |
SetIndustryAnimationLoop(tile, 0); |
0 | 801 |
AddAnimatedTile(tile); |
802 |
} |
|
803 |
} |
|
804 |
break; |
|
805 |
||
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
806 |
case GFX_BUBBLE_GENERATOR: |
3290
235df477f3ee
(svn r4004) -CodeChange : Renaming sprites and functions
belugas
parents:
3282
diff
changeset
|
807 |
TileLoopIndustry_BubbleGenerator(tile); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
808 |
break; |
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
809 |
|
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
810 |
case GFX_TOFFEE_QUARY: |
0 | 811 |
AddAnimatedTile(tile); |
812 |
break; |
|
813 |
||
4583
af31ba5db77d
(svn r6433) -Codechange: replace some magic numbers (industry gfx indices) by enums.
rubidium
parents:
4434
diff
changeset
|
814 |
case GFX_SUGAR_MINE_SIEVE: |
2639 | 815 |
if (CHANCE16(1, 3)) AddAnimatedTile(tile); |
0 | 816 |
break; |
817 |
} |
|
818 |
} |
|
819 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
820 |
static void ClickTile_Industry(TileIndex tile) |
0 | 821 |
{ |
3314
6aaeba4b92e8
(svn r4077) Add GetIndustry{Index,ByTile}() to get the industry index resp. the industry from a tile
tron
parents:
3296
diff
changeset
|
822 |
ShowIndustryViewWindow(GetIndustryIndex(tile)); |
0 | 823 |
} |
824 |
||
6683
b88ae30866ce
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents:
6656
diff
changeset
|
825 |
static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode) |
0 | 826 |
{ |
827 |
return 0; |
|
828 |
} |
|
829 |
||
3344
fc86351d4641
(svn r4128) - CodeChange: Add proper semantics for CargoID for such variables instead of using the general byte-type.
Darkvater
parents:
3338
diff
changeset
|
830 |
static void GetProducedCargo_Industry(TileIndex tile, CargoID *b) |
0 | 831 |
{ |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
832 |
const IndustrySpec *i = GetIndustrySpec(GetIndustryByTile(tile)->type); |
2630 | 833 |
|
0 | 834 |
b[0] = i->produced_cargo[0]; |
835 |
b[1] = i->produced_cargo[1]; |
|
836 |
} |
|
837 |
||
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2360
diff
changeset
|
838 |
static void ChangeTileOwner_Industry(TileIndex tile, PlayerID old_player, PlayerID new_player) |
0 | 839 |
{ |
7186
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
840 |
/* If the founder merges, the industry was created by the merged company */ |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
841 |
Industry *i = GetIndustryByTile(tile); |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
842 |
if (i->founder == old_player) i->founder = (new_player == PLAYER_SPECTATOR) ? OWNER_NONE : new_player; |
0 | 843 |
} |
844 |
||
845 |
static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6}; |
|
846 |
||
1048 | 847 |
static bool IsBadFarmFieldTile(TileIndex tile) |
0 | 848 |
{ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
849 |
switch (GetTileType(tile)) { |
5684
b764bfdb935d
(svn r8145) -Featurette: Allow for Tropic Farm to plant fields after producing cargo, like its counterpart in temperate climate.
belugas
parents:
5668
diff
changeset
|
850 |
case MP_CLEAR: return IsClearGround(tile, CLEAR_FIELDS) || IsClearGround(tile, CLEAR_SNOW) || IsClearGround(tile, CLEAR_DESERT); |
2955
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
851 |
case MP_TREES: return false; |
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
852 |
default: return true; |
0 | 853 |
} |
854 |
} |
|
855 |
||
1048 | 856 |
static bool IsBadFarmFieldTile2(TileIndex tile) |
0 | 857 |
{ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1209
diff
changeset
|
858 |
switch (GetTileType(tile)) { |
5684
b764bfdb935d
(svn r8145) -Featurette: Allow for Tropic Farm to plant fields after producing cargo, like its counterpart in temperate climate.
belugas
parents:
5668
diff
changeset
|
859 |
case MP_CLEAR: return IsClearGround(tile, CLEAR_SNOW) || IsClearGround(tile, CLEAR_DESERT); |
2955
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
860 |
case MP_TREES: return false; |
24de69e236d2
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
2952
diff
changeset
|
861 |
default: return true; |
0 | 862 |
} |
863 |
} |
|
864 |
||
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
865 |
static void SetupFarmFieldFence(TileIndex tile, int size, byte type, Axis direction) |
0 | 866 |
{ |
867 |
do { |
|
868 |
tile = TILE_MASK(tile); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
869 |
|
1035
812f837ee03f
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
1019
diff
changeset
|
870 |
if (IsTileType(tile, MP_CLEAR) || IsTileType(tile, MP_TREES)) { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
871 |
byte or_ = type; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
872 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
873 |
if (or_ == 1 && CHANCE16(1, 7)) or_ = 2; |
0 | 874 |
|
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
875 |
if (direction == AXIS_X) { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
876 |
SetFenceSE(tile, or_); |
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
877 |
} else { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
878 |
SetFenceSW(tile, or_); |
0 | 879 |
} |
880 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
881 |
|
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
882 |
tile += (direction == AXIS_X ? TileDiffXY(1, 0) : TileDiffXY(0, 1)); |
0 | 883 |
} while (--size); |
884 |
} |
|
885 |
||
4330
cf31daa8b321
(svn r6005) -Cleanup: introduce IndustryID and use it
rubidium
parents:
4329
diff
changeset
|
886 |
static void PlantFarmField(TileIndex tile, IndustryID industry) |
0 | 887 |
{ |
888 |
uint size_x, size_y; |
|
889 |
uint32 r; |
|
2133 | 890 |
uint count; |
2979
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
891 |
uint counter; |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
892 |
uint field_type; |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
893 |
int type; |
0 | 894 |
|
6357
f0f5e7d1713c
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6343
diff
changeset
|
895 |
if (_opt.landscape == LT_ARCTIC) { |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6307
diff
changeset
|
896 |
if (GetTileZ(tile) + TILE_HEIGHT * 2 >= GetSnowLine()) |
0 | 897 |
return; |
898 |
} |
|
899 |
||
900 |
/* determine field size */ |
|
901 |
r = (Random() & 0x303) + 0x404; |
|
6357
f0f5e7d1713c
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6343
diff
changeset
|
902 |
if (_opt.landscape == LT_ARCTIC) r += 0x404; |
2150
f710b959b1c4
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2148
diff
changeset
|
903 |
size_x = GB(r, 0, 8); |
f710b959b1c4
(svn r2660) Get rid of some more shifting/anding/casting
tron
parents:
2148
diff
changeset
|
904 |
size_y = GB(r, 8, 8); |
0 | 905 |
|
906 |
/* offset tile to match size */ |
|
1981 | 907 |
tile -= TileDiffXY(size_x / 2, size_y / 2); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
908 |
|
0 | 909 |
/* check the amount of bad tiles */ |
910 |
count = 0; |
|
911 |
BEGIN_TILE_LOOP(cur_tile, size_x, size_y, tile) |
|
912 |
cur_tile = TILE_MASK(cur_tile); |
|
913 |
count += IsBadFarmFieldTile(cur_tile); |
|
914 |
END_TILE_LOOP(cur_tile, size_x, size_y, tile) |
|
2133 | 915 |
if (count * 2 >= size_x * size_y) return; |
0 | 916 |
|
917 |
/* determine type of field */ |
|
918 |
r = Random(); |
|
2979
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
919 |
counter = GB(r, 5, 3); |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
920 |
field_type = GB(r, 8, 8) * 9 >> 8; |
0 | 921 |
|
922 |
/* make field */ |
|
923 |
BEGIN_TILE_LOOP(cur_tile, size_x, size_y, tile) |
|
924 |
cur_tile = TILE_MASK(cur_tile); |
|
925 |
if (!IsBadFarmFieldTile2(cur_tile)) { |
|
4328
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
926 |
MakeField(cur_tile, field_type, industry); |
2979
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
927 |
SetClearCounter(cur_tile, counter); |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
928 |
MarkTileDirtyByTile(cur_tile); |
0 | 929 |
} |
930 |
END_TILE_LOOP(cur_tile, size_x, size_y, tile) |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
931 |
|
0 | 932 |
type = 3; |
6357
f0f5e7d1713c
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6343
diff
changeset
|
933 |
if (_opt.landscape != LT_ARCTIC && _opt.landscape != LT_TROPIC) { |
0 | 934 |
type = _plantfarmfield_type[Random() & 0xF]; |
935 |
} |
|
936 |
||
3157
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
937 |
SetupFarmFieldFence(tile - TileDiffXY(1, 0), size_y, type, AXIS_Y); |
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
938 |
SetupFarmFieldFence(tile - TileDiffXY(0, 1), size_x, type, AXIS_X); |
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
939 |
SetupFarmFieldFence(tile + TileDiffXY(size_x - 1, 0), size_y, type, AXIS_Y); |
3f35e2d9c8e3
(svn r3783) Replace further ints and magic numbers by Direction, DiagDirection and friends
tron
parents:
3144
diff
changeset
|
940 |
SetupFarmFieldFence(tile + TileDiffXY(0, size_y - 1), size_x, type, AXIS_X); |
0 | 941 |
} |
942 |
||
4328
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
943 |
void PlantRandomFarmField(const Industry *i) |
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
944 |
{ |
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
945 |
int x = i->width / 2 + Random() % 31 - 16; |
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
946 |
int y = i->height / 2 + Random() % 31 - 16; |
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
947 |
|
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
948 |
TileIndex tile = TileAddWrap(i->xy, x, y); |
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
949 |
|
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
950 |
if (tile != INVALID_TILE) PlantFarmField(tile, i->index); |
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
951 |
} |
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
952 |
|
5118
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
953 |
/** |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
954 |
* Search callback function for ChopLumberMillTrees |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
955 |
* @param tile to test |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
956 |
* @param data that is passed by the caller. In this case, nothing |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
957 |
* @return the result of the test |
5118
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
958 |
*/ |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
959 |
static bool SearchLumberMillTrees(TileIndex tile, uint32 data) |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
960 |
{ |
5909
35595e20c0c4
(svn r8535) -Feature: Allow lumbermill to cut trees only when they are full grown.
belugas
parents:
5884
diff
changeset
|
961 |
if (IsTileType(tile, MP_TREES) && GetTreeGrowth(tile) > 2) { ///< 3 and up means all fully grown trees |
5118
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
962 |
PlayerID old_player = _current_player; |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
963 |
/* found a tree */ |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
964 |
|
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
965 |
_current_player = OWNER_NONE; |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
966 |
_industry_sound_ctr = 1; |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
967 |
_industry_sound_tile = tile; |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
968 |
SndPlayTileFx(SND_38_CHAINSAW, tile); |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
969 |
|
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
970 |
DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
971 |
|
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
972 |
_current_player = old_player; |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
973 |
return true; |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
974 |
} |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
975 |
return false; |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
976 |
} |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
977 |
|
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
978 |
/** |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
979 |
* Perform a circular search around the Lumber Mill in order to find trees to cut |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
980 |
* @param i industry |
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
981 |
*/ |
0 | 982 |
static void ChopLumberMillTrees(Industry *i) |
983 |
{ |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
984 |
TileIndex tile = i->xy; |
2639 | 985 |
|
5118
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
986 |
if (!IsIndustryCompleted(tile)) return; ///< Can't proceed if not completed |
0 | 987 |
|
5118
9640617e1abb
(svn r7198) -Codechange: Implement a circular tile search function.
belugas
parents:
5056
diff
changeset
|
988 |
if (CircularTileSearch(tile, 40, SearchLumberMillTrees, 0)) ///< 40x40 tiles to search |
7165
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
989 |
i->produced_cargo_waiting[0] = min(0xffff, i->produced_cargo_waiting[0] + 45); ///< Found a tree, add according value to waiting cargo |
0 | 990 |
} |
991 |
||
992 |
static void ProduceIndustryGoods(Industry *i) |
|
993 |
{ |
|
994 |
uint32 r; |
|
995 |
uint num; |
|
6655
3d46f5ba9b6e
(svn r9886) -Codechange: Cleanup of industries (Step-13). Include the sounds table into the industry's spec.
belugas
parents:
6639
diff
changeset
|
996 |
const IndustrySpec *indsp = GetIndustrySpec(i->type); |
0 | 997 |
|
998 |
/* play a sound? */ |
|
999 |
if ((i->counter & 0x3F) == 0) { |
|
6655
3d46f5ba9b6e
(svn r9886) -Codechange: Cleanup of industries (Step-13). Include the sounds table into the industry's spec.
belugas
parents:
6639
diff
changeset
|
1000 |
if (CHANCE16R(1, 14, r) && (num = indsp->number_of_sounds) != 0) { |
0 | 1001 |
SndPlayTileFx( |
6655
3d46f5ba9b6e
(svn r9886) -Codechange: Cleanup of industries (Step-13). Include the sounds table into the industry's spec.
belugas
parents:
6639
diff
changeset
|
1002 |
(SoundFx)(indsp->random_sounds[((r >> 16) * num) >> 16]), |
0 | 1003 |
i->xy); |
1004 |
} |
|
1005 |
} |
|
1006 |
||
1007 |
i->counter--; |
|
1008 |
||
1009 |
/* produce some cargo */ |
|
1010 |
if ((i->counter & 0xFF) == 0) { |
|
7168
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7165
diff
changeset
|
1011 |
if (HASBIT(indsp->callback_flags, CBM_IND_PRODUCTION_256_TICKS)) IndustryProductionCallback(i, 1); |
25e07ccb4a3d
(svn r10442) -Codechange: implement the industry production callback.
rubidium
parents:
7165
diff
changeset
|
1012 |
|
6655
3d46f5ba9b6e
(svn r9886) -Codechange: Cleanup of industries (Step-13). Include the sounds table into the industry's spec.
belugas
parents:
6639
diff
changeset
|
1013 |
IndustyBehaviour indbehav = indsp->behaviour; |
7165
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
1014 |
i->produced_cargo_waiting[0] = min(0xffff, i->produced_cargo_waiting[0] + i->production_rate[0]); |
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
1015 |
i->produced_cargo_waiting[1] = min(0xffff, i->produced_cargo_waiting[1] + i->production_rate[1]); |
0 | 1016 |
|
7205
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1017 |
if ((indbehav & INDUSTRYBEH_PLANT_FIELDS) != 0) { |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1018 |
bool plant; |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1019 |
if (HASBIT(indsp->callback_flags, CBM_IND_SPECIAL_EFFECT)) { |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1020 |
plant = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, Random(), 0, i, i->type, i->xy) != 0); |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1021 |
} else { |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1022 |
plant = CHANCE16(1, 8); |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1023 |
} |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1024 |
|
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1025 |
if (plant) PlantRandomFarmField(i); |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1026 |
} |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1027 |
if ((indbehav & INDUSTRYBEH_CUT_TREES) != 0) { |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1028 |
bool cut = ((i->counter & 0x1FF) == 0); |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1029 |
if (HASBIT(indsp->callback_flags, CBM_IND_SPECIAL_EFFECT)) { |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1030 |
cut = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, 0, 1, i, i->type, i->xy) != 0); |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1031 |
} |
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1032 |
|
0a6d45455ae5
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
rubidium
parents:
7203
diff
changeset
|
1033 |
if (cut) ChopLumberMillTrees(i); |
2639 | 1034 |
} |
0 | 1035 |
} |
1036 |
} |
|
1037 |
||
6247 | 1038 |
void OnTick_Industry() |
0 | 1039 |
{ |
1040 |
Industry *i; |
|
1041 |
||
1042 |
if (_industry_sound_ctr != 0) { |
|
1043 |
_industry_sound_ctr++; |
|
1044 |
||
1045 |
if (_industry_sound_ctr == 75) { |
|
541 | 1046 |
SndPlayTileFx(SND_37_BALLOON_SQUEAK, _industry_sound_tile); |
0 | 1047 |
} else if (_industry_sound_ctr == 160) { |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1048 |
_industry_sound_ctr = 0; |
541 | 1049 |
SndPlayTileFx(SND_36_CARTOON_CRASH, _industry_sound_tile); |
0 | 1050 |
} |
1051 |
} |
|
1052 |
||
2639 | 1053 |
if (_game_mode == GM_EDITOR) return; |
0 | 1054 |
|
830
36c1366367e4
(svn r1301) -Codechange: _industries finally has FOR_ALL_INDUSTRIES too
truelight
parents:
817
diff
changeset
|
1055 |
FOR_ALL_INDUSTRIES(i) { |
7229
a5f262f6df1b
(svn r10508) -Codechange: allow customizable animation schemes for industries.
rubidium
parents:
7227
diff
changeset
|
1056 |
StartStopIndustryTileAnimation(i, IAT_INDUSTRY_TICK); |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1057 |
ProduceIndustryGoods(i); |
0 | 1058 |
} |
1059 |
} |
|
1060 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1061 |
static bool CheckNewIndustry_NULL(TileIndex tile) |
0 | 1062 |
{ |
1063 |
return true; |
|
1064 |
} |
|
1065 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1066 |
static bool CheckNewIndustry_Forest(TileIndex tile) |
0 | 1067 |
{ |
6357
f0f5e7d1713c
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6343
diff
changeset
|
1068 |
if (_opt.landscape == LT_ARCTIC) { |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6307
diff
changeset
|
1069 |
if (GetTileZ(tile) < HighestSnowLine() + TILE_HEIGHT * 2U) { |
0 | 1070 |
_error_message = STR_4831_FOREST_CAN_ONLY_BE_PLANTED; |
1071 |
return false; |
|
1072 |
} |
|
1073 |
} |
|
1074 |
return true; |
|
1075 |
} |
|
1076 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1077 |
static bool CheckNewIndustry_OilRefinery(TileIndex tile) |
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1078 |
{ |
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1079 |
if (_game_mode == GM_EDITOR) return true; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1080 |
if (DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _patches.oil_refinery_limit) return true; |
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1081 |
|
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1082 |
_error_message = STR_483B_CAN_ONLY_BE_POSITIONED; |
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1083 |
return false; |
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1084 |
} |
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1085 |
|
7
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
0
diff
changeset
|
1086 |
extern bool _ignore_restrictions; |
f2e623faa778
(svn r8) Fix: Automatic oil refinery generation in editor
dominik
parents:
0
diff
changeset
|
1087 |
|
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1088 |
static bool CheckNewIndustry_OilRig(TileIndex tile) |
0 | 1089 |
{ |
2639 | 1090 |
if (_game_mode == GM_EDITOR && _ignore_restrictions) return true; |
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1091 |
if (TileHeight(tile) == 0 && |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1092 |
DistanceFromEdge(TILE_ADDXY(tile, 1, 1)) < _patches.oil_refinery_limit) return true; |
0 | 1093 |
|
1094 |
_error_message = STR_483B_CAN_ONLY_BE_POSITIONED; |
|
1095 |
return false; |
|
1096 |
} |
|
1097 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1098 |
static bool CheckNewIndustry_Farm(TileIndex tile) |
0 | 1099 |
{ |
6357
f0f5e7d1713c
(svn r9400) -Codechange: Use some more representative enum names for landscape types.
belugas
parents:
6343
diff
changeset
|
1100 |
if (_opt.landscape == LT_ARCTIC) { |
6343
76d17f784c13
(svn r9371) -Feature: Add support for variable snow lines in the arctic climate, supplied
maedhros
parents:
6307
diff
changeset
|
1101 |
if (GetTileZ(tile) + TILE_HEIGHT * 2 >= HighestSnowLine()) { |
0 | 1102 |
_error_message = STR_0239_SITE_UNSUITABLE; |
1103 |
return false; |
|
1104 |
} |
|
1105 |
} |
|
1106 |
return true; |
|
1107 |
} |
|
1108 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1109 |
static bool CheckNewIndustry_Plantation(TileIndex tile) |
0 | 1110 |
{ |
3379
50b253bb9819
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3344
diff
changeset
|
1111 |
if (GetTropicZone(tile) == TROPICZONE_DESERT) { |
0 | 1112 |
_error_message = STR_0239_SITE_UNSUITABLE; |
1113 |
return false; |
|
1114 |
} |
|
1115 |
||
1116 |
return true; |
|
1117 |
} |
|
1118 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1119 |
static bool CheckNewIndustry_Water(TileIndex tile) |
0 | 1120 |
{ |
3379
50b253bb9819
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3344
diff
changeset
|
1121 |
if (GetTropicZone(tile) != TROPICZONE_DESERT) { |
0 | 1122 |
_error_message = STR_0318_CAN_ONLY_BE_BUILT_IN_DESERT; |
1123 |
return false; |
|
1124 |
} |
|
1125 |
||
1126 |
return true; |
|
1127 |
} |
|
1128 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1129 |
static bool CheckNewIndustry_Lumbermill(TileIndex tile) |
0 | 1130 |
{ |
3379
50b253bb9819
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3344
diff
changeset
|
1131 |
if (GetTropicZone(tile) != TROPICZONE_RAINFOREST) { |
0 | 1132 |
_error_message = STR_0317_CAN_ONLY_BE_BUILT_IN_RAINFOREST; |
1133 |
return false; |
|
1134 |
} |
|
1135 |
return true; |
|
1136 |
} |
|
1137 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1138 |
static bool CheckNewIndustry_BubbleGen(TileIndex tile) |
0 | 1139 |
{ |
3645
7f950533d510
(svn r4554) Replace magic numbers by TILE_{HEIGHT,SIZE}
tron
parents:
3636
diff
changeset
|
1140 |
return GetTileZ(tile) <= TILE_HEIGHT * 4; |
0 | 1141 |
} |
1142 |
||
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1143 |
typedef bool CheckNewIndustryProc(TileIndex tile); |
3663
548dfb4ad4cc
(svn r4578) CodeChange : Cleanup of industry_cmd (Step-2).
belugas
parents:
3662
diff
changeset
|
1144 |
static CheckNewIndustryProc * const _check_new_industry_procs[CHECK_END] = { |
0 | 1145 |
CheckNewIndustry_NULL, |
1146 |
CheckNewIndustry_Forest, |
|
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1147 |
CheckNewIndustry_OilRefinery, |
0 | 1148 |
CheckNewIndustry_Farm, |
1149 |
CheckNewIndustry_Plantation, |
|
1150 |
CheckNewIndustry_Water, |
|
1151 |
CheckNewIndustry_Lumbermill, |
|
1152 |
CheckNewIndustry_BubbleGen, |
|
3877
0a298def0202
(svn r4920) Remove parameters, which get only used in certain functions, by splitting those functions.
tron
parents:
3773
diff
changeset
|
1153 |
CheckNewIndustry_OilRig |
0 | 1154 |
}; |
1155 |
||
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
1156 |
static bool CheckSuitableIndustryPos(TileIndex tile) |
0 | 1157 |
{ |
926
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
919
diff
changeset
|
1158 |
uint x = TileX(tile); |
a6d140a6a4de
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
919
diff
changeset
|
1159 |
uint y = TileY(tile); |
0 | 1160 |
|
2639 | 1161 |
if (x < 2 || y < 2 || x > MapMaxX() - 3 || y > MapMaxY() - 3) { |
0 | 1162 |
_error_message = STR_0239_SITE_UNSUITABLE; |
1163 |
return false; |
|
1164 |
} |
|
1165 |
||
1166 |
return true; |
|
1167 |
} |
|
1168 |
||
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
1169 |
static const Town *CheckMultipleIndustryInTown(TileIndex tile, int type) |
0 | 1170 |
{ |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
1171 |
const Town *t; |
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
1172 |
const Industry *i; |
0 | 1173 |
|
1174 |
t = ClosestTownFromTile(tile, (uint)-1); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1175 |
|
2639 | 1176 |
if (_patches.multiple_industry_per_town) return t; |
0 | 1177 |
|
830
36c1366367e4
(svn r1301) -Codechange: _industries finally has FOR_ALL_INDUSTRIES too
truelight
parents:
817
diff
changeset
|
1178 |
FOR_ALL_INDUSTRIES(i) { |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1179 |
if (i->type == (byte)type && |
0 | 1180 |
i->town == t) { |
1181 |
_error_message = STR_0287_ONLY_ONE_ALLOWED_PER_TOWN; |
|
1182 |
return NULL; |
|
1183 |
} |
|
1184 |
} |
|
1185 |
||
1186 |
return t; |
|
1187 |
} |
|
1188 |
||
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1189 |
static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, int type, bool *custom_shape_check = NULL) |
0 | 1190 |
{ |
1191 |
_error_message = STR_0239_SITE_UNSUITABLE; |
|
1192 |
||
1193 |
do { |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
1194 |
TileIndex cur_tile = tile + ToTileIndexDiff(it->ti); |
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
1195 |
|
0 | 1196 |
if (!IsValidTile(cur_tile)) { |
3440 | 1197 |
if (it->gfx == 0xff) continue; |
0 | 1198 |
return false; |
1199 |
} |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1200 |
|
3440 | 1201 |
if (it->gfx == 0xFF) { |
3296
34064bbe27a5
(svn r4027) Remove another call to FindLandscapeHeightByTile()
tron
parents:
3291
diff
changeset
|
1202 |
if (!IsTileType(cur_tile, MP_WATER) || |
3636
a36cc46e754d
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3585
diff
changeset
|
1203 |
GetTileSlope(cur_tile, NULL) != SLOPE_FLAT) { |
3296
34064bbe27a5
(svn r4027) Remove another call to FindLandscapeHeightByTile()
tron
parents:
3291
diff
changeset
|
1204 |
return false; |
34064bbe27a5
(svn r4027) Remove another call to FindLandscapeHeightByTile()
tron
parents:
3291
diff
changeset
|
1205 |
} |
0 | 1206 |
} else { |
2639 | 1207 |
if (!EnsureNoVehicle(cur_tile)) return false; |
6893
ccfe9df6410f
(svn r10140) -Fix [FS#867]: an industry could overbuild a bridge.
rubidium
parents:
6859
diff
changeset
|
1208 |
if (MayHaveBridgeAbove(cur_tile) && IsBridgeAbove(cur_tile)) return false; |
ccfe9df6410f
(svn r10140) -Fix [FS#867]: an industry could overbuild a bridge.
rubidium
parents:
6859
diff
changeset
|
1209 |
|
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1210 |
const IndustryTileSpec *its = GetIndustryTileSpec(it->gfx); |
6390
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
1211 |
IndustyBehaviour ind_behav = GetIndustrySpec(type)->behaviour; |
0 | 1212 |
|
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1213 |
if (HASBIT(its->callback_flags, CBM_INDT_SHAPE_CHECK)) { |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1214 |
if (custom_shape_check != NULL) *custom_shape_check = true; |
7216
2bb13ff061b1
(svn r10494) -Fix (r10490): possible null dereference in some exotic newgrfs.
rubidium
parents:
7212
diff
changeset
|
1215 |
if (!PerformIndustryTileSlopeCheck(cur_tile, its, type, it->gfx)) return false; |
0 | 1216 |
} else { |
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1217 |
if (ind_behav & INDUSTRYBEH_BUILT_ONWATER) { |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1218 |
/* As soon as the tile is not water, bail out. |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1219 |
* But that does not mean the search is over. You have |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1220 |
* to make sure every tile of the industry will be only water*/ |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1221 |
if (!IsClearWaterTile(cur_tile)) return false; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1222 |
} else { |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1223 |
Slope tileh; |
3296
34064bbe27a5
(svn r4027) Remove another call to FindLandscapeHeightByTile()
tron
parents:
3291
diff
changeset
|
1224 |
|
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1225 |
if (IsClearWaterTile(cur_tile)) return false; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1226 |
|
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1227 |
tileh = GetTileSlope(cur_tile, NULL); |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1228 |
if (IsSteepSlope(tileh)) return false; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1229 |
|
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1230 |
if (_patches.land_generator != LG_TERRAGENESIS || !_generating_world) { |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1231 |
/* It is almost impossible to have a fully flat land in TG, so what we |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1232 |
* do is that we check if we can make the land flat later on. See |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1233 |
* CheckIfCanLevelIndustryPlatform(). */ |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1234 |
if (tileh != SLOPE_FLAT) { |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1235 |
Slope t; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1236 |
byte bits = its->slopes_refused; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1237 |
|
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1238 |
if (bits & 0x10) return false; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1239 |
|
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1240 |
t = ComplementSlope(tileh); |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1241 |
|
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1242 |
if (bits & 1 && (t & SLOPE_NW)) return false; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1243 |
if (bits & 2 && (t & SLOPE_NE)) return false; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1244 |
if (bits & 4 && (t & SLOPE_SW)) return false; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1245 |
if (bits & 8 && (t & SLOPE_SE)) return false; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1246 |
} |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1247 |
} |
0 | 1248 |
} |
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1249 |
} |
0 | 1250 |
|
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1251 |
if (ind_behav & INDUSTRYBEH_ONLY_INTOWN) { |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1252 |
if (!IsTileType(cur_tile, MP_HOUSE)) { |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1253 |
_error_message = STR_029D_CAN_ONLY_BE_BUILT_IN_TOWNS; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1254 |
return false; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1255 |
} |
7227
76ebda957d0e
(svn r10506) -Fix: the (manual) building of banks was always rejected.
rubidium
parents:
7216
diff
changeset
|
1256 |
if (CmdFailed(DoCommand(cur_tile, 0, 0, 0, CMD_LANDSCAPE_CLEAR))) return false; |
76ebda957d0e
(svn r10506) -Fix: the (manual) building of banks was always rejected.
rubidium
parents:
7216
diff
changeset
|
1257 |
} else if ((ind_behav & INDUSTRYBEH_ONLY_NEARTOWN) == 0 || !IsTileType(cur_tile, MP_HOUSE)) { |
76ebda957d0e
(svn r10506) -Fix: the (manual) building of banks was always rejected.
rubidium
parents:
7216
diff
changeset
|
1258 |
if (CmdFailed(DoCommand(cur_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) return false; |
0 | 1259 |
} |
1260 |
} |
|
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
1261 |
} while ((++it)->ti.x != -0x80); |
0 | 1262 |
|
1263 |
return true; |
|
1264 |
} |
|
1265 |
||
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1266 |
static bool CheckIfIndustryIsAllowed(TileIndex tile, int type, const Town *t) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1267 |
{ |
6390
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
1268 |
if ((GetIndustrySpec(type)->behaviour & INDUSTRYBEH_TOWN1200_MORE) && t->population < 1200) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1269 |
_error_message = STR_029D_CAN_ONLY_BE_BUILT_IN_TOWNS; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1270 |
return false; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1271 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1272 |
|
6390
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
1273 |
if ((GetIndustrySpec(type)->behaviour & INDUSTRYBEH_ONLY_NEARTOWN) && DistanceMax(t->xy, tile) > 9) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1274 |
_error_message = STR_0239_SITE_UNSUITABLE; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1275 |
return false; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1276 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1277 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1278 |
return true; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1279 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1280 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1281 |
static bool CheckCanTerraformSurroundingTiles(TileIndex tile, uint height, int internal) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1282 |
{ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1283 |
int size_x, size_y; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1284 |
uint curh; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1285 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1286 |
size_x = 2; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1287 |
size_y = 2; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1288 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1289 |
/* Check if we don't leave the map */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1290 |
if (TileX(tile) == 0 || TileY(tile) == 0 || GetTileType(tile) == MP_VOID) return false; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1291 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1292 |
tile += TileDiffXY(-1, -1); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1293 |
BEGIN_TILE_LOOP(tile_walk, size_x, size_y, tile) { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1294 |
curh = TileHeight(tile_walk); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1295 |
/* Is the tile clear? */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1296 |
if ((GetTileType(tile_walk) != MP_CLEAR) && (GetTileType(tile_walk) != MP_TREES)) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1297 |
return false; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1298 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1299 |
/* Don't allow too big of a change if this is the sub-tile check */ |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1300 |
if (internal != 0 && delta(curh, height) > 1) return false; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1301 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1302 |
/* Different height, so the surrounding tiles of this tile |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1303 |
* has to be correct too (in level, or almost in level) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1304 |
* else you get a chain-reaction of terraforming. */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1305 |
if (internal == 0 && curh != height) { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1306 |
if (!CheckCanTerraformSurroundingTiles(tile_walk + TileDiffXY(-1, -1), height, internal + 1)) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1307 |
return false; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1308 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1309 |
} END_TILE_LOOP(tile_walk, size_x, size_y, tile); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1310 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1311 |
return true; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1312 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1313 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1314 |
/** |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1315 |
* This function tries to flatten out the land below an industry, without |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1316 |
* damaging the surroundings too much. |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1317 |
*/ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1318 |
static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, uint32 flags, const IndustryTileTable* it, int type) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1319 |
{ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1320 |
const int MKEND = -0x80; // used for last element in an IndustryTileTable (see build_industry.h) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1321 |
int max_x = 0; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1322 |
int max_y = 0; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1323 |
TileIndex cur_tile; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1324 |
uint size_x, size_y; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1325 |
uint h, curh; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1326 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1327 |
/* Finds dimensions of largest variant of this industry */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1328 |
do { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1329 |
if (it->ti.x > max_x) max_x = it->ti.x; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1330 |
if (it->ti.y > max_y) max_y = it->ti.y; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1331 |
} while ((++it)->ti.x != MKEND); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1332 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1333 |
/* Remember level height */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1334 |
h = TileHeight(tile); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1335 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1336 |
/* Check that all tiles in area and surrounding are clear |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1337 |
* this determines that there are no obstructing items */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1338 |
cur_tile = tile + TileDiffXY(-1, -1); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1339 |
size_x = max_x + 4; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1340 |
size_y = max_y + 4; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1341 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1342 |
/* Check if we don't leave the map */ |
4313
fc428e434474
(svn r5966) -Fix: prevent that the industry placement's terraforming checks can leave the map on the southern side
rubidium
parents:
4301
diff
changeset
|
1343 |
if (TileX(cur_tile) == 0 || TileY(cur_tile) == 0 || TileX(cur_tile) + size_x >= MapMaxX() || TileY(cur_tile) + size_y >= MapMaxY()) return false; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1344 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1345 |
BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1346 |
curh = TileHeight(tile_walk); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1347 |
if (curh != h) { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1348 |
/* This tile needs terraforming. Check if we can do that without |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1349 |
* damaging the surroundings too much. */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1350 |
if (!CheckCanTerraformSurroundingTiles(tile_walk, h, 0)) return false; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1351 |
/* This is not 100% correct check, but the best we can do without modifying the map. |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1352 |
* What is missing, is if the difference in height is more than 1.. */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1353 |
if (CmdFailed(DoCommand(tile_walk, 8, (curh > h) ? 0 : 1, flags & ~DC_EXEC, CMD_TERRAFORM_LAND))) return false; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1354 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1355 |
} END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1356 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1357 |
if (flags & DC_EXEC) { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1358 |
/* Terraform the land under the industry */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1359 |
BEGIN_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1360 |
curh = TileHeight(tile_walk); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1361 |
while (curh != h) { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1362 |
/* We give the terraforming for free here, because we can't calculate |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1363 |
* exact cost in the test-round, and as we all know, that will cause |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1364 |
* a nice assert if they don't match ;) */ |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1365 |
DoCommand(tile_walk, 8, (curh > h) ? 0 : 1, flags, CMD_TERRAFORM_LAND); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1366 |
curh += (curh > h) ? -1 : 1; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1367 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1368 |
} END_TILE_LOOP(tile_walk, size_x, size_y, cur_tile) |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1369 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1370 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1371 |
return true; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1372 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1373 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1374 |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
1375 |
static bool CheckIfTooCloseToIndustry(TileIndex tile, int type) |
0 | 1376 |
{ |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1377 |
const IndustrySpec *indspec = GetIndustrySpec(type); |
3662
d9683fb55b45
(svn r4577) CodeChange : Cleanup of industry_cmd (Step-1).
belugas
parents:
3661
diff
changeset
|
1378 |
const Industry *i; |
0 | 1379 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1380 |
/* accepting industries won't be close, not even with patch */ |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1381 |
if (_patches.same_industry_close && indspec->accepts_cargo[0] == CT_INVALID) |
0 | 1382 |
return true; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1383 |
|
830
36c1366367e4
(svn r1301) -Codechange: _industries finally has FOR_ALL_INDUSTRIES too
truelight
parents:
817
diff
changeset
|
1384 |
FOR_ALL_INDUSTRIES(i) { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1385 |
/* check if an industry that accepts the same goods is nearby */ |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1386 |
if (DistanceMax(tile, i->xy) <= 14 && |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1387 |
indspec->accepts_cargo[0] != CT_INVALID && |
6859
24e98db499c9
(svn r10099) -Fix(r9867, FS860): Use the specs of the to-be-created industry instead of the scanned industry
belugas
parents:
6839
diff
changeset
|
1388 |
indspec->accepts_cargo[0] == GetIndustrySpec(i->type)->accepts_cargo[0] && ( |
2639 | 1389 |
_game_mode != GM_EDITOR || |
1390 |
!_patches.same_industry_close || |
|
1391 |
!_patches.multiple_industry_per_town |
|
1392 |
)) { |
|
1393 |
_error_message = STR_INDUSTRY_TOO_CLOSE; |
|
1394 |
return false; |
|
1395 |
} |
|
0 | 1396 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1397 |
/* check "not close to" field. */ |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1398 |
if ((i->type == indspec->conflicting[0] || i->type == indspec->conflicting[1] || i->type == indspec->conflicting[2]) && |
1245
3822f77cbc53
(svn r1749) Move the functions which calculate distances to map.[ch] and give the more meaningful names
tron
parents:
1214
diff
changeset
|
1399 |
DistanceMax(tile, i->xy) <= 14) { |
0 | 1400 |
_error_message = STR_INDUSTRY_TOO_CLOSE; |
1401 |
return false; |
|
1402 |
} |
|
1403 |
} |
|
1404 |
return true; |
|
1405 |
} |
|
1406 |
||
6247 | 1407 |
static Industry *AllocateIndustry() |
0 | 1408 |
{ |
1409 |
Industry *i; |
|
1410 |
||
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1411 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1412 |
* TODO - This is just a temporary stage, this will be removed. */ |
4976
2e3d5e8ec510
(svn r6979) Use the pool macros for the Industry pool
tron
parents:
4965
diff
changeset
|
1413 |
for (i = GetIndustry(0); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? GetIndustry(i->index + 1U) : NULL) { |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1414 |
IndustryID index = i->index; |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
1415 |
|
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1416 |
if (IsValidIndustry(i)) continue; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
909
diff
changeset
|
1417 |
|
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1418 |
memset(i, 0, sizeof(*i)); |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1419 |
i->index = index; |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1420 |
|
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1421 |
return i; |
0 | 1422 |
} |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
1423 |
|
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
1424 |
/* Check if we can add a block to the pool */ |
4976
2e3d5e8ec510
(svn r6979) Use the pool macros for the Industry pool
tron
parents:
4965
diff
changeset
|
1425 |
return AddBlockToPool(&_Industry_pool) ? AllocateIndustry() : NULL; |
0 | 1426 |
} |
1427 |
||
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1428 |
static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, const Town *t, Owner owner) |
0 | 1429 |
{ |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1430 |
const IndustrySpec *indspec = GetIndustrySpec(type); |
0 | 1431 |
uint32 r; |
1432 |
int j; |
|
1433 |
||
1434 |
i->xy = tile; |
|
1435 |
i->width = i->height = 0; |
|
1436 |
i->type = type; |
|
6824
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
1437 |
IncIndustryTypeCount(type); |
0 | 1438 |
|
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1439 |
i->production_rate[0] = indspec->production_rate[0]; |
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1440 |
i->production_rate[1] = indspec->production_rate[1]; |
0 | 1441 |
|
1442 |
if (_patches.smooth_economy) { |
|
1443 |
i->production_rate[0] = min((RandomRange(256) + 128) * i->production_rate[0] >> 8 , 255); |
|
1444 |
i->production_rate[1] = min((RandomRange(256) + 128) * i->production_rate[1] >> 8 , 255); |
|
1445 |
} |
|
1446 |
||
1447 |
i->town = t; |
|
1448 |
i->owner = owner; |
|
1449 |
||
2484
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
tron
parents:
2469
diff
changeset
|
1450 |
r = Random(); |
4942
7fb6c39eb421
(svn r6930) -Codechange: Move industry name into IndustrySpec
belugas
parents:
4924
diff
changeset
|
1451 |
i->random_color = GB(r, 8, 4); |
2492
b4785c8f3700
(svn r3018) -Fix: Fixed industry colour issue introduced in r3010.
peter1138
parents:
2484
diff
changeset
|
1452 |
i->counter = GB(r, 0, 12); |
7165
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
1453 |
i->produced_cargo_waiting[0] = 0; |
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
1454 |
i->produced_cargo_waiting[1] = 0; |
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
1455 |
i->incoming_cargo_waiting[0] = 0; |
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
1456 |
i->incoming_cargo_waiting[1] = 0; |
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
1457 |
i->incoming_cargo_waiting[2] = 0; |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1458 |
i->this_month_production[0] = 0; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1459 |
i->this_month_production[1] = 0; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1460 |
i->this_month_transported[0] = 0; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1461 |
i->this_month_transported[1] = 0; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1462 |
i->last_month_pct_transported[0] = 0; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1463 |
i->last_month_pct_transported[1] = 0; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1464 |
i->last_month_transported[0] = 0; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1465 |
i->last_month_transported[1] = 0; |
0 | 1466 |
i->was_cargo_delivered = false; |
4329
0e6e689f66e7
(svn r6002) -Cleanup: remove the now redundant BASE_YEAR constant.
rubidium
parents:
4328
diff
changeset
|
1467 |
i->last_prod_year = _cur_year; |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1468 |
i->last_month_production[0] = i->production_rate[0] * 8; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1469 |
i->last_month_production[1] = i->production_rate[1] * 8; |
7186
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
1470 |
i->founder = _current_player; |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
1471 |
i->construction_date = _date; |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
1472 |
i->construction_type = (_game_mode == GM_EDITOR) ? ICT_SCENARIO_EDITOR : |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
1473 |
(_generating_world ? ICT_MAP_GENERATION : ICT_NORMAL_GAMEPLAY); |
0 | 1474 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1475 |
if (!_generating_world) i->last_month_production[0] = i->last_month_production[1] = 0; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1476 |
|
0 | 1477 |
i->prod_level = 0x10; |
1478 |
||
1479 |
do { |
|
1977
37bbebf94434
(svn r2483) Replace almost 500 "uint tile" (and variants) with "TileIndex tile"
tron
parents:
1891
diff
changeset
|
1480 |
TileIndex cur_tile = tile + ToTileIndexDiff(it->ti); |
0 | 1481 |
|
3440 | 1482 |
if (it->gfx != 0xFF) { |
0 | 1483 |
byte size; |
1484 |
||
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
1485 |
size = it->ti.x; |
0 | 1486 |
if (size > i->width) i->width = size; |
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
1487 |
size = it->ti.y; |
0 | 1488 |
if (size > i->height)i->height = size; |
1489 |
||
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
1490 |
DoCommand(cur_tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
0 | 1491 |
|
3440 | 1492 |
MakeIndustry(cur_tile, i->index, it->gfx); |
5435
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
1493 |
if (_generating_world) { |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
1494 |
SetIndustryConstructionCounter(cur_tile, 3); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
1495 |
SetIndustryConstructionStage(cur_tile, 2); |
ffb0c3620c6e
(svn r7641) -Codechange: remove the last direct map accesses from industry_cmd.
rubidium
parents:
5434
diff
changeset
|
1496 |
} |
0 | 1497 |
} |
909
65cdb609b7a6
(svn r1396) Introduce TileIndexDiffC - the compile time version of TileIndexDiff
tron
parents:
889
diff
changeset
|
1498 |
} while ((++it)->ti.x != -0x80); |
0 | 1499 |
|
1500 |
i->width++; |
|
1501 |
i->height++; |
|
1502 |
||
6390
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
1503 |
if (GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_PLANT_ON_BUILT) { |
4328
1b3940c35724
(svn r6001) -Feature: when removing a farm, his farmland is removed too (over time) (based on peter1138's patch, FS#82)
truelight
parents:
4326
diff
changeset
|
1504 |
for (j = 0; j != 50; j++) PlantRandomFarmField(i); |
0 | 1505 |
} |
1506 |
_industry_sort_dirty = true; |
|
1507 |
InvalidateWindow(WC_INDUSTRY_DIRECTORY, 0); |
|
1508 |
} |
|
1509 |
||
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1510 |
/** Helper function for Build/Fund an industry |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1511 |
* @param tile tile where industry is built |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1512 |
* @param type of industry to build |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1513 |
* @param flags of operations to conduct |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1514 |
* @param indspec pointer to industry specifications |
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1515 |
* @param itspec_index the index of the itsepc to build/fund |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1516 |
* @return the pointer of the newly created industry, or NULL if it failed |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1517 |
*/ |
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1518 |
static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, uint32 flags, const IndustrySpec *indspec, uint itspec_index) |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1519 |
{ |
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1520 |
const IndustryTileTable *it = indspec->table[itspec_index]; |
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1521 |
bool custom_shape_check = false; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1522 |
|
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1523 |
if (!CheckIfIndustryTilesAreFree(tile, it, type, &custom_shape_check)) return NULL; |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1524 |
|
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1525 |
if (HASBIT(GetIndustrySpec(type)->callback_flags, CBM_IND_LOCATION)) { |
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1526 |
if (!CheckIfCallBackAllowsCreation(tile, type, itspec_index)) return NULL; |
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1527 |
} else { |
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1528 |
if (!_check_new_industry_procs[indspec->check_proc](tile)) return NULL; |
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1529 |
} |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1530 |
|
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1531 |
if (!custom_shape_check && _patches.land_generator == LG_TERRAGENESIS && _generating_world && !CheckIfCanLevelIndustryPlatform(tile, 0, it, type)) return NULL; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1532 |
if (!CheckIfTooCloseToIndustry(tile, type)) return NULL; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1533 |
|
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1534 |
const Town *t = CheckMultipleIndustryInTown(tile, type); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1535 |
if (t == NULL) return NULL; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1536 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1537 |
if (!CheckIfIndustryIsAllowed(tile, type, t)) return NULL; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1538 |
if (!CheckSuitableIndustryPos(tile)) return NULL; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1539 |
|
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1540 |
Industry *i = AllocateIndustry(); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1541 |
if (i == NULL) return NULL; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1542 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1543 |
if (flags & DC_EXEC) { |
7212
5d99296fb545
(svn r10490) -Codechange: add support for industries on non-flat surfaces.
rubidium
parents:
7207
diff
changeset
|
1544 |
if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_EXEC, it, type); |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1545 |
DoCreateNewIndustry(i, tile, type, it, t, OWNER_NONE); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1546 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1547 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1548 |
return i; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1549 |
} |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1550 |
|
1786
7cfd46c3fcc4
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1603
diff
changeset
|
1551 |
/** Build/Fund an industry |
3491
35d747bb5e82
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3447
diff
changeset
|
1552 |
* @param tile tile where industry is built |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1553 |
* @param flags of operations to conduct |
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1554 |
* @param p1 industry type see build_industry.h and see industry.h |
1786
7cfd46c3fcc4
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1603
diff
changeset
|
1555 |
* @param p2 unused |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1556 |
* @return index of the newly create industry, or CMD_ERROR if it failed |
1786
7cfd46c3fcc4
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1603
diff
changeset
|
1557 |
*/ |
6943
1914f26aee04
(svn r10197) -Codechange: replace int32 with CommandCost where appropriate.
rubidium
parents:
6910
diff
changeset
|
1558 |
CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 1559 |
{ |
1560 |
int num; |
|
1561 |
const IndustryTileTable * const *itt; |
|
1562 |
const IndustryTileTable *it; |
|
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1563 |
const IndustrySpec *indspec; |
0 | 1564 |
|
1565 |
SET_EXPENSES_TYPE(EXPENSES_OTHER); |
|
1566 |
||
4965
a09db997a1f3
(svn r6965) -CodeChange : Add a climate bitmask member to IndutrySpec.
belugas
parents:
4942
diff
changeset
|
1567 |
indspec = GetIndustrySpec(p1); |
2639 | 1568 |
|
4965
a09db997a1f3
(svn r6965) -CodeChange : Add a climate bitmask member to IndutrySpec.
belugas
parents:
4942
diff
changeset
|
1569 |
/* Check if the to-be built/founded industry is available for this climate. */ |
6748
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1570 |
if (!indspec->enabled) { |
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1571 |
return CMD_ERROR; |
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1572 |
} |
0 | 1573 |
|
2638
0811adaec525
(svn r3180) Replace some magic numbers by symbolic names
tron
parents:
2637
diff
changeset
|
1574 |
/* If the patch for raw-material industries is not on, you cannot build raw-material industries. |
7185
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1575 |
* Raw material industries are industries that do not accept cargo (at least for now) */ |
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1576 |
if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 0 && indspec->IsRawIndustry()) { |
2638
0811adaec525
(svn r3180) Replace some magic numbers by symbolic names
tron
parents:
2637
diff
changeset
|
1577 |
return CMD_ERROR; |
0811adaec525
(svn r3180) Replace some magic numbers by symbolic names
tron
parents:
2637
diff
changeset
|
1578 |
} |
0 | 1579 |
|
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1580 |
if (_game_mode != GM_EDITOR && _patches.raw_industry_construction == 2 && indspec->IsRawIndustry()) { |
7177
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1581 |
if (flags & DC_EXEC) { |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1582 |
/* Prospecting has a chance to fail, however we cannot guarantee that something can |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1583 |
* be built on the map, so the chance gets lower when the map is fuller, but there |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1584 |
* is nothing we can really do about that. */ |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1585 |
if (Random() <= indspec->prospecting_chance) { |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1586 |
for (int i = 0; i < 5000; i++) { |
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1587 |
uint tilespec_index = RandomRange(indspec->num_table); |
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1588 |
const Industry *ind = CreateNewIndustryHelper(RandomTile(), p1, flags, indspec, tilespec_index); |
7203
39f68ddb39cc
(svn r10481) -Codechange: Show a news message with the new industry when primary industry prospecting succeeds.
maedhros
parents:
7199
diff
changeset
|
1589 |
if (ind != NULL) { |
39f68ddb39cc
(svn r10481) -Codechange: Show a news message with the new industry when primary industry prospecting succeeds.
maedhros
parents:
7199
diff
changeset
|
1590 |
SetDParam(0, indspec->name); |
39f68ddb39cc
(svn r10481) -Codechange: Show a news message with the new industry when primary industry prospecting succeeds.
maedhros
parents:
7199
diff
changeset
|
1591 |
SetDParam(1, ind->town->index); |
39f68ddb39cc
(svn r10481) -Codechange: Show a news message with the new industry when primary industry prospecting succeeds.
maedhros
parents:
7199
diff
changeset
|
1592 |
AddNewsItem(indspec->new_industry_text, |
39f68ddb39cc
(svn r10481) -Codechange: Show a news message with the new industry when primary industry prospecting succeeds.
maedhros
parents:
7199
diff
changeset
|
1593 |
NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0); |
39f68ddb39cc
(svn r10481) -Codechange: Show a news message with the new industry when primary industry prospecting succeeds.
maedhros
parents:
7199
diff
changeset
|
1594 |
break; |
39f68ddb39cc
(svn r10481) -Codechange: Show a news message with the new industry when primary industry prospecting succeeds.
maedhros
parents:
7199
diff
changeset
|
1595 |
} |
7177
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1596 |
} |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1597 |
} |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1598 |
} |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1599 |
} else { |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1600 |
num = indspec->num_table; |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1601 |
itt = indspec->table; |
0 | 1602 |
|
1603 |
||
7177
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1604 |
do { |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1605 |
if (--num < 0) return_cmd_error(STR_0239_SITE_UNSUITABLE); |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1606 |
} while (!CheckIfIndustryTilesAreFree(tile, it = itt[num], p1)); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1607 |
|
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1608 |
if (CreateNewIndustryHelper(tile, p1, flags, indspec, num) == NULL) return CMD_ERROR; |
7177
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1609 |
} |
f9796d5be926
(svn r10451) -Add: support for "prospecting" raw industries, i.e. you pay an amount of money and then it might (with a given chance) build a raw industry somewhere on the map.
rubidium
parents:
7168
diff
changeset
|
1610 |
|
7185
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1611 |
return CommandCost(indspec->GetConstructionCost()); |
0 | 1612 |
} |
1613 |
||
1614 |
||
3538
750c4ea83357
(svn r4399) CodeChange : Add and make use of [G|S]etIndustryAnimationLoop accessors.
belugas
parents:
3499
diff
changeset
|
1615 |
Industry *CreateNewIndustry(TileIndex tile, IndustryType type) |
0 | 1616 |
{ |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1617 |
const IndustrySpec *indspec = GetIndustrySpec(type); |
0 | 1618 |
|
7207
277c6c315403
(svn r10485) -Codechange: add a callback mechanism to determine whether building an industry is allowed at a given location.
rubidium
parents:
7205
diff
changeset
|
1619 |
return CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, RandomRange(indspec->num_table)); |
0 | 1620 |
} |
1621 |
||
6976
1f3da800b6c2
(svn r10232) -Fix(r1): _numof_industry_table never was composed of 12 entries. Only 11.
belugas
parents:
6970
diff
changeset
|
1622 |
static const byte _numof_industry_table[5][11] = { |
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1623 |
/* difficulty settings for number of industries */ |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1624 |
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //none |
6560
24106d85dcf5
(svn r9762) -Feature: Two new difficulty settings : Very low number of towns and very low number of industries
belugas
parents:
6519
diff
changeset
|
1625 |
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, //very low |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1626 |
{0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5}, //low |
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1627 |
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, //normal |
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1628 |
{0, 2, 3, 4, 6, 7, 8, 9, 10, 10, 10}, //high |
0 | 1629 |
}; |
1630 |
||
6442
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1631 |
/** This function is the one who really do the creation work |
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1632 |
* of random industries during game creation |
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1633 |
* @param type IndustryType of the desired industry |
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1634 |
* @param amount of industries that need to be built */ |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1635 |
static void PlaceInitialIndustry(IndustryType type, int amount) |
0 | 1636 |
{ |
2072
66d208875eda
(svn r2582) Fix: Prevent generating unrealistically many Oil refineries on large maps. They are always placed next to the borderline, so the perimeter is used instead of area to scale the number of those industries.
ludde
parents:
2070
diff
changeset
|
1637 |
int num = _numof_industry_table[_opt.diff.number_industries][amount]; |
6757
385cb1bf2ba9
(svn r9992) -Codechange: Remove some hardcoded references to Industry IDs.
belugas
parents:
6749
diff
changeset
|
1638 |
const IndustrySpec *ind_spc = GetIndustrySpec(type); |
2072
66d208875eda
(svn r2582) Fix: Prevent generating unrealistically many Oil refineries on large maps. They are always placed next to the borderline, so the perimeter is used instead of area to scale the number of those industries.
ludde
parents:
2070
diff
changeset
|
1639 |
|
6442
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1640 |
/* These are always placed next to the coastline, so we scale by the perimeter instead. */ |
6757
385cb1bf2ba9
(svn r9992) -Codechange: Remove some hardcoded references to Industry IDs.
belugas
parents:
6749
diff
changeset
|
1641 |
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num); |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
61
diff
changeset
|
1642 |
|
2639 | 1643 |
if (_opt.diff.number_industries != 0) { |
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2493
diff
changeset
|
1644 |
PlayerID old_player = _current_player; |
266
b914f2b7da78
(svn r272) -Fix: industries are once again generated on a new map
darkvater
parents:
201
diff
changeset
|
1645 |
_current_player = OWNER_NONE; |
61
cd2827156f2a
(svn r62) - Added "None" as option for number of industries in difficulty settings
orudge
parents:
43
diff
changeset
|
1646 |
assert(num > 0); |
0 | 1647 |
|
1648 |
do { |
|
2639 | 1649 |
uint i; |
1650 |
||
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1651 |
IncreaseGeneratingWorldProgress(GWP_INDUSTRY); |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1652 |
|
2639 | 1653 |
for (i = 0; i < 2000; i++) { |
1654 |
if (CreateNewIndustry(RandomTile(), type) != NULL) break; |
|
1655 |
} |
|
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
61
diff
changeset
|
1656 |
} while (--num); |
266
b914f2b7da78
(svn r272) -Fix: industries are once again generated on a new map
darkvater
parents:
201
diff
changeset
|
1657 |
|
267 | 1658 |
_current_player = old_player; |
61
cd2827156f2a
(svn r62) - Added "None" as option for number of industries in difficulty settings
orudge
parents:
43
diff
changeset
|
1659 |
} |
0 | 1660 |
} |
1661 |
||
6442
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1662 |
/** This function will create ramdon industries during game creation. |
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1663 |
* It will scale the amount of industries by map size as well as difficulty level */ |
6247 | 1664 |
void GenerateIndustries() |
0 | 1665 |
{ |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1666 |
uint i = 0; |
6442
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1667 |
uint8 chance; |
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1668 |
IndustryType it; |
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1669 |
const IndustrySpec *ind_spc; |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1670 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1671 |
/* Find the total amount of industries */ |
7261
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1672 |
if (_opt.diff.number_industries > 0) { |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1673 |
for (it = IT_COAL_MINE; it < NUM_INDUSTRYTYPES; it++) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1674 |
|
7261
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1675 |
ind_spc = GetIndustrySpec(it); |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1676 |
|
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1677 |
if (!CheckIfCallBackAllowsAvailability(it, IACT_MAPGENERATION)) { |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1678 |
ResetIndustryCreationProbility(it); |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1679 |
} |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1680 |
|
6748
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1681 |
chance = ind_spc->appear_creation[_opt.landscape]; |
7262 | 1682 |
if (ind_spc->enabled && chance > 0) { |
6748
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1683 |
/* once the chance of appearance is determind, it have to be scaled by |
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1684 |
* the difficulty level. The "chance" in question is more an index into |
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1685 |
* the _numof_industry_table,in fact */ |
7261
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1686 |
int num = (chance < 11) ? chance : _numof_industry_table[_opt.diff.number_industries][chance]; |
6442
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1687 |
|
6748
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1688 |
/* These are always placed next to the coastline, so we scale by the perimeter instead. */ |
6757
385cb1bf2ba9
(svn r9992) -Codechange: Remove some hardcoded references to Industry IDs.
belugas
parents:
6749
diff
changeset
|
1689 |
num = (ind_spc->check_proc == CHECK_REFINERY || ind_spc->check_proc == CHECK_OIL_RIG) ? ScaleByMapSize1D(num) : ScaleByMapSize(num); |
6748
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1690 |
i += num; |
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1691 |
} |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1692 |
} |
6442
1bab3df59b91
(svn r9579) -Codechange: Cleanup of industry_cmd (Step-11). Use industry's spec appear_creation during random map creation.
belugas
parents:
6438
diff
changeset
|
1693 |
} |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1694 |
|
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
1695 |
SetGeneratingWorldProgress(GWP_INDUSTRY, i); |
0 | 1696 |
|
7261
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1697 |
if (_opt.diff.number_industries > 0) { |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1698 |
for (it = IT_COAL_MINE; it < NUM_INDUSTRYTYPES; it++) { |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1699 |
/* Once the number of industries has been determined, let's really create them. |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1700 |
* The test for chance allows us to try create industries that are available only |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1701 |
* for this landscape. |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1702 |
* @todo : Do we really have to pass chance as un-scaled value, since we've already |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1703 |
* processed that scaling above? No, don't think so. Will find a way. */ |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1704 |
ind_spc = GetIndustrySpec(it); |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1705 |
if (ind_spc->enabled) { |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1706 |
chance = ind_spc->appear_creation[_opt.landscape]; |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1707 |
if (chance > 0) PlaceInitialIndustry(it, chance); |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1708 |
} |
6748
7579278d958f
(svn r9983) -Codechange: Use the "enabled" property of the industry spec.
belugas
parents:
6743
diff
changeset
|
1709 |
} |
7261
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1710 |
} |
0 | 1711 |
} |
1712 |
||
7288
9059a49c2102
(svn r10635) -Codechange: Correct some typos and code beautifying (a little bit)
belugas
parents:
7266
diff
changeset
|
1713 |
/** Change industry production or do closure |
9059a49c2102
(svn r10635) -Codechange: Correct some typos and code beautifying (a little bit)
belugas
parents:
7266
diff
changeset
|
1714 |
* @param i Industry for which changes are performed |
9059a49c2102
(svn r10635) -Codechange: Correct some typos and code beautifying (a little bit)
belugas
parents:
7266
diff
changeset
|
1715 |
*/ |
0 | 1716 |
static void ExtChangeIndustryProduction(Industry *i) |
1717 |
{ |
|
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1718 |
bool closeit = true; |
0 | 1719 |
int j; |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1720 |
const IndustrySpec *indspec = GetIndustrySpec(i->type); |
0 | 1721 |
|
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1722 |
if (indspec->life_type == INDUSTRYLIFE_BLACK_HOLE) return; |
7082
2576eb09cd29
(svn r10347) -Fix [FS#948]: industries with a very low production could never recover when using smooth economy.
rubidium
parents:
7075
diff
changeset
|
1723 |
|
7145
0bb6d7c2de2f
(svn r10419) -Fix (r10418): do not compare bitmasks with HASBIT. Thanks to Maedhros for spotting this.
rubidium
parents:
7144
diff
changeset
|
1724 |
if ((indspec->life_type & (INDUSTRYLIFE_ORGANIC | INDUSTRYLIFE_EXTRACTIVE)) != 0) { |
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1725 |
for (j = 0; j < 2 && indspec->produced_cargo[j] != CT_INVALID; j++){ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1726 |
uint32 r = Random(); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1727 |
int old_prod, new_prod, percent; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1728 |
int mag; |
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1729 |
|
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1730 |
new_prod = old_prod = i->production_rate[j]; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1731 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1732 |
if (CHANCE16I(20, 1024, r)) new_prod -= max(((RandomRange(50) + 10) * old_prod) >> 8, 1U); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1733 |
/* Chance of increasing becomes better when more is transported */ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1734 |
if (CHANCE16I(20 + (i->last_month_pct_transported[j] * 20 >> 8), 1024, r >> 16) && |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1735 |
((indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) == 0 || _opt.landscape != LT_TEMPERATE)) { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1736 |
new_prod += max(((RandomRange(50) + 10) * old_prod) >> 8, 1U); |
0 | 1737 |
} |
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1738 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1739 |
new_prod = clamp(new_prod, 1, 255); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1740 |
/* Do not stop closing the industry when it has the lowest possible production rate */ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1741 |
if (new_prod == old_prod && old_prod > 1) { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1742 |
closeit = false; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1743 |
continue; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1744 |
} |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1745 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1746 |
percent = (old_prod == 0) ? 100 : (new_prod * 100 / old_prod - 100); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1747 |
i->production_rate[j] = new_prod; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1748 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1749 |
/* Close the industry when it has the lowest possible production rate */ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1750 |
if (new_prod > 1) closeit = false; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1751 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1752 |
mag = abs(percent); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1753 |
if (mag >= 10) { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1754 |
SetDParam(2, mag); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1755 |
SetDParam(0, GetCargo(indspec->produced_cargo[j])->name); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1756 |
SetDParam(1, i->index); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1757 |
AddNewsItem( |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1758 |
percent >= 0 ? STR_INDUSTRY_PROD_GOUP : STR_INDUSTRY_PROD_GODOWN, |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1759 |
NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_ECONOMY, 0), |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1760 |
i->xy + TileDiffXY(1, 1), 0 |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1761 |
); |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1762 |
} |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1763 |
} |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1764 |
} |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1765 |
|
7145
0bb6d7c2de2f
(svn r10419) -Fix (r10418): do not compare bitmasks with HASBIT. Thanks to Maedhros for spotting this.
rubidium
parents:
7144
diff
changeset
|
1766 |
if ((indspec->life_type & INDUSTRYLIFE_PROCESSING) != 0) { |
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1767 |
if ((byte)(_cur_year - i->last_prod_year) < 5 || !CHANCE16(1, 180)) closeit = false; |
0 | 1768 |
} |
1769 |
||
3496
0959ead7c2af
(svn r4347) CodeChange : Renamed IndustryType to IndustryLifeType. Cleanup step toward bringing accessors [G|S]etIndustrype
belugas
parents:
3495
diff
changeset
|
1770 |
/* If industry will be closed down, show this */ |
0 | 1771 |
if (closeit) { |
1772 |
i->prod_level = 0; |
|
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2061
diff
changeset
|
1773 |
SetDParam(0, i->index); |
2639 | 1774 |
AddNewsItem( |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1775 |
indspec->closure_text, |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6468
diff
changeset
|
1776 |
NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), |
2639 | 1777 |
i->xy + TileDiffXY(1, 1), 0 |
1778 |
); |
|
0 | 1779 |
} |
1780 |
} |
|
1781 |
||
1782 |
||
1783 |
static void UpdateIndustryStatistics(Industry *i) |
|
1784 |
{ |
|
1785 |
byte pct; |
|
6467 | 1786 |
bool refresh = false; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
1787 |
const IndustrySpec *indsp = GetIndustrySpec(i->type); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1788 |
|
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
1789 |
for (byte j = 0; j < lengthof(indsp->produced_cargo); j++) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
1790 |
if (indsp->produced_cargo[j] != CT_INVALID) { |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
1791 |
pct = 0; |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1792 |
if (i->this_month_production[j] != 0) { |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
1793 |
i->last_prod_year = _cur_year; |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1794 |
pct = min(i->this_month_transported[j] * 256 / i->this_month_production[j], 255); |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
1795 |
} |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1796 |
i->last_month_pct_transported[j] = pct; |
0 | 1797 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1798 |
i->last_month_production[j] = i->this_month_production[j]; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1799 |
i->this_month_production[j] = 0; |
0 | 1800 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1801 |
i->last_month_transported[j] = i->this_month_transported[j]; |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
1802 |
i->this_month_transported[j] = 0; |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
1803 |
refresh = true; |
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
1804 |
} |
0 | 1805 |
} |
1806 |
||
6467 | 1807 |
if (refresh) |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
909
diff
changeset
|
1808 |
InvalidateWindow(WC_INDUSTRY_VIEW, i->index); |
0 | 1809 |
|
2639 | 1810 |
if (i->prod_level == 0) { |
0 | 1811 |
DeleteIndustry(i); |
2639 | 1812 |
} else if (_patches.smooth_economy) { |
0 | 1813 |
ExtChangeIndustryProduction(i); |
2639 | 1814 |
} |
0 | 1815 |
} |
1816 |
||
6431
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1817 |
/** Simple helper that will collect data for the generation of industries */ |
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1818 |
struct ProbabilityHelper { |
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1819 |
uint16 prob; ///< probability |
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1820 |
IndustryType ind; ///< industry id correcponding |
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1821 |
}; |
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1822 |
|
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1823 |
/** |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1824 |
* Try to create a random industry, during gameplay |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1825 |
*/ |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1826 |
static void MaybeNewIndustry(void) |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1827 |
{ |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1828 |
Industry *ind; //will receive the industry's creation pointer |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1829 |
IndustryType rndtype, j; // Loop controlers |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1830 |
const IndustrySpec *ind_spc; |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1831 |
uint num = 0; |
6493
6bbb7ebd6a31
(svn r9676) -Codechange: introduce NUM_INDUSTRYTYPES instead of IT_END.
belugas
parents:
6491
diff
changeset
|
1832 |
ProbabilityHelper cumulative_probs[NUM_INDUSTRYTYPES]; // probability collector |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1833 |
uint16 probability_max = 0; |
0 | 1834 |
|
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1835 |
/* Generate a list of all possible industries that can be built. */ |
6493
6bbb7ebd6a31
(svn r9676) -Codechange: introduce NUM_INDUSTRYTYPES instead of IT_END.
belugas
parents:
6491
diff
changeset
|
1836 |
for (j = 0; j < NUM_INDUSTRYTYPES; j++) { |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1837 |
byte chance = GetIndustrySpec(j)->appear_ingame[_opt.landscape]; |
0 | 1838 |
|
7261
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1839 |
/* If there is no Callback CBID_INDUSTRY_AVAILABLE or if this one did anot failed, |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1840 |
* and if appearing chance for this landscape is above 0, this industry can be chosen */ |
a39e79710d5a
(svn r10573) -Codechange: Use function CheckIfCallBackAllowsAvailability for random map generation as well as for ingame random industry creation
belugas
parents:
7229
diff
changeset
|
1841 |
if (CheckIfCallBackAllowsAvailability(j, IACT_RANDOMCREATION) && chance != 0) { |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1842 |
probability_max += chance; |
6431
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1843 |
/* adds the result for this industry */ |
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1844 |
cumulative_probs[num].ind = j; |
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1845 |
cumulative_probs[num++].prob = probability_max; |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1846 |
} |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1847 |
} |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1848 |
|
6431
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1849 |
/* Find a random type, with maximum being what has been evaluate above*/ |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1850 |
rndtype = RandomRange(probability_max); |
6493
6bbb7ebd6a31
(svn r9676) -Codechange: introduce NUM_INDUSTRYTYPES instead of IT_END.
belugas
parents:
6491
diff
changeset
|
1851 |
for (j = 0; j < NUM_INDUSTRYTYPES; j++) { |
6431
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1852 |
/* and choose the index of the industry that matches as close as possible this random type */ |
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1853 |
if (cumulative_probs[j].prob >= rndtype) break; |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1854 |
} |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1855 |
|
6431
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1856 |
ind_spc = GetIndustrySpec(cumulative_probs[j].ind); |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1857 |
/* Check if it is allowed */ |
6390
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
1858 |
if ((ind_spc->behaviour & INDUSTRYBEH_BEFORE_1950) && _cur_year > 1950) return; |
802629b3c7f1
(svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas
parents:
6357
diff
changeset
|
1859 |
if ((ind_spc->behaviour & INDUSTRYBEH_AFTER_1960) && _cur_year < 1960) return; |
0 | 1860 |
|
6431
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1861 |
/* try to create 2000 times this industry */ |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1862 |
num = 2000; |
2639 | 1863 |
for (;;) { |
6431
137965651de7
(svn r9567) -Fix(9555, FS#718): The industry ID been collected was just an index in a out of phase array. Now, ensure that the ID will really be an IndustryType
belugas
parents:
6427
diff
changeset
|
1864 |
ind = CreateNewIndustry(RandomTile(), cumulative_probs[j].ind); |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1865 |
if (ind != NULL) break; |
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1866 |
if (--num == 0) return; |
0 | 1867 |
} |
1868 |
||
6266
fd42b0893130
(svn r9075) -Codechange: Cleanup of industry_cmd (Step-7). Small step that is. The new industry messages do not need a series of tests. Only one property to use.
belugas
parents:
6247
diff
changeset
|
1869 |
SetDParam(0, ind_spc->name); |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1870 |
SetDParam(1, ind->town->index); |
6266
fd42b0893130
(svn r9075) -Codechange: Cleanup of industry_cmd (Step-7). Small step that is. The new industry messages do not need a series of tests. Only one property to use.
belugas
parents:
6247
diff
changeset
|
1871 |
AddNewsItem(ind_spc->new_industry_text, |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6468
diff
changeset
|
1872 |
NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, NT_OPENCLOSE, 0), ind->xy, 0); |
0 | 1873 |
} |
1874 |
||
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1875 |
static void ChangeIndustryProduction(Industry *i) |
0 | 1876 |
{ |
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1877 |
StringID str = STR_NULL; |
0 | 1878 |
int type = i->type; |
3669
753648f181a0
(svn r4584) CodeChange : Cleanup of industry_cmd (Step-3).
belugas
parents:
3663
diff
changeset
|
1879 |
const IndustrySpec *indspec = GetIndustrySpec(type); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
159
diff
changeset
|
1880 |
|
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1881 |
if (indspec->life_type == INDUSTRYLIFE_BLACK_HOLE) return; |
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1882 |
|
7151
3b57351634a8
(svn r10425) -Fix (r10418): do not compare bitmasks with HASBIT. Strike two. Forgotten code :)
belugas
parents:
7145
diff
changeset
|
1883 |
if ((indspec->life_type & (INDUSTRYLIFE_ORGANIC | INDUSTRYLIFE_EXTRACTIVE)) != 0) { |
3b57351634a8
(svn r10425) -Fix (r10418): do not compare bitmasks with HASBIT. Strike two. Forgotten code :)
belugas
parents:
7145
diff
changeset
|
1884 |
bool only_decrease = false; |
3b57351634a8
(svn r10425) -Fix (r10418): do not compare bitmasks with HASBIT. Strike two. Forgotten code :)
belugas
parents:
7145
diff
changeset
|
1885 |
|
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1886 |
/* decrease or increase */ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1887 |
if ((indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _opt.landscape == LT_TEMPERATE) |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1888 |
only_decrease = true; |
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1889 |
|
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1890 |
if (only_decrease || CHANCE16(1, 3)) { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1891 |
/* If you transport > 60%, 66% chance we increase, else 33% chance we increase */ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1892 |
if (!only_decrease && (i->last_month_pct_transported[0] > 153) != CHANCE16(1, 3)) { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1893 |
/* Increase production */ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1894 |
if (i->prod_level != 0x80) { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1895 |
byte b; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1896 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1897 |
i->prod_level <<= 1; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1898 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1899 |
b = i->production_rate[0] * 2; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1900 |
if (i->production_rate[0] >= 128) |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1901 |
b = 0xFF; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1902 |
i->production_rate[0] = b; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1903 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1904 |
b = i->production_rate[1] * 2; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1905 |
if (i->production_rate[1] >= 128) |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1906 |
b = 0xFF; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1907 |
i->production_rate[1] = b; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1908 |
|
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1909 |
str = indspec->production_up_text; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1910 |
} |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1911 |
} else { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1912 |
/* Decrease production */ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1913 |
if (i->prod_level == 4) { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1914 |
i->prod_level = 0; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1915 |
str = indspec->closure_text; |
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1916 |
} else { |
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1917 |
i->prod_level >>= 1; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1918 |
i->production_rate[0] = (i->production_rate[0] + 1) >> 1; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1919 |
i->production_rate[1] = (i->production_rate[1] + 1) >> 1; |
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1920 |
|
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1921 |
str = indspec->production_down_text; |
0 | 1922 |
} |
1923 |
} |
|
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1924 |
} |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1925 |
} |
7151
3b57351634a8
(svn r10425) -Fix (r10418): do not compare bitmasks with HASBIT. Strike two. Forgotten code :)
belugas
parents:
7145
diff
changeset
|
1926 |
if (indspec->life_type & INDUSTRYLIFE_PROCESSING) { |
7144
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1927 |
/* maybe close */ |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1928 |
if ( (byte)(_cur_year - i->last_prod_year) >= 5 && CHANCE16(1, 2)) { |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1929 |
i->prod_level = 0; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1930 |
str = indspec->closure_text; |
8e73641511f3
(svn r10418) -Codechange: implement/resurrect the industry production flags.
rubidium
parents:
7132
diff
changeset
|
1931 |
} |
1320
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1932 |
} |
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1933 |
|
44a8658d88c0
(svn r1824) -Codechange: made ChangeIndustryProduction a bit more readable
truelight
parents:
1287
diff
changeset
|
1934 |
if (str != STR_NULL) { |
2070
47b1f29d4671
(svn r2580) Change: Added {INDUSTRY} command for printing industry names instead of the old {TOWN} {STRING} way.
ludde
parents:
2061
diff
changeset
|
1935 |
SetDParam(0, i->index); |
6491
00dc414c909d
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6468
diff
changeset
|
1936 |
AddNewsItem(str, NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_TILE, str == indspec->closure_text ? NT_OPENCLOSE : NT_ECONOMY, 0), i->xy + TileDiffXY(1, 1), 0); |
0 | 1937 |
} |
1938 |
} |
|
1939 |
||
6247 | 1940 |
void IndustryMonthlyLoop() |
0 | 1941 |
{ |
1942 |
Industry *i; |
|
2498
3ed05caa4449
(svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents:
2493
diff
changeset
|
1943 |
PlayerID old_player = _current_player; |
266
b914f2b7da78
(svn r272) -Fix: industries are once again generated on a new map
darkvater
parents:
201
diff
changeset
|
1944 |
_current_player = OWNER_NONE; |
0 | 1945 |
|
830
36c1366367e4
(svn r1301) -Codechange: _industries finally has FOR_ALL_INDUSTRIES too
truelight
parents:
817
diff
changeset
|
1946 |
FOR_ALL_INDUSTRIES(i) { |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
1947 |
UpdateIndustryStatistics(i); |
0 | 1948 |
} |
1949 |
||
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
1950 |
/* 3% chance that we start a new industry */ |
6433 | 1951 |
if (CHANCE16(3, 100)) { |
6419
d2e19c0fb769
(svn r9555) -Codechange: Cleanup of industry_cmd (Step-9). Use in-game appearing chances for industry creation.
belugas
parents:
6390
diff
changeset
|
1952 |
MaybeNewIndustry(); |
5247
1f982de55b88
(svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents:
5216
diff
changeset
|
1953 |
} else if (!_patches.smooth_economy) { |
4356
ec4e13f21cd0
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
1954 |
i = GetRandomIndustry(); |
ec4e13f21cd0
(svn r6057) -Codechange: made a function GetRandomXXX, that _always_ returns a valid XXX, unless there are none to pick from. Then NULL is returned.
truelight
parents:
4354
diff
changeset
|
1955 |
if (i != NULL) ChangeIndustryProduction(i); |
0 | 1956 |
} |
266
b914f2b7da78
(svn r272) -Fix: industries are once again generated on a new map
darkvater
parents:
201
diff
changeset
|
1957 |
|
b914f2b7da78
(svn r272) -Fix: industries are once again generated on a new map
darkvater
parents:
201
diff
changeset
|
1958 |
_current_player = old_player; |
b914f2b7da78
(svn r272) -Fix: industries are once again generated on a new map
darkvater
parents:
201
diff
changeset
|
1959 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
1960 |
/* production-change */ |
0 | 1961 |
_industry_sort_dirty = true; |
1962 |
InvalidateWindow(WC_INDUSTRY_DIRECTORY, 0); |
|
1963 |
} |
|
1964 |
||
1965 |
||
6247 | 1966 |
void InitializeIndustries() |
0 | 1967 |
{ |
4976
2e3d5e8ec510
(svn r6979) Use the pool macros for the Industry pool
tron
parents:
4965
diff
changeset
|
1968 |
CleanPool(&_Industry_pool); |
2e3d5e8ec510
(svn r6979) Use the pool macros for the Industry pool
tron
parents:
4965
diff
changeset
|
1969 |
AddBlockToPool(&_Industry_pool); |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
909
diff
changeset
|
1970 |
|
6839
2cc0a04fa761
(svn r10078) -Codechange: Centralize all industry counts data and access
belugas
parents:
6824
diff
changeset
|
1971 |
ResetIndustryCounts(); |
0 | 1972 |
_industry_sort_dirty = true; |
4587
859ab734e211
(svn r6437) -Fix: reset the location of the last sound as that location can be outside the map when you are loading another (smaller) map. Thanks to MeusH for noticing.
rubidium
parents:
4583
diff
changeset
|
1973 |
_industry_sound_tile = 0; |
0 | 1974 |
} |
1975 |
||
7185
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1976 |
bool IndustrySpec::IsRawIndustry() const |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1977 |
{ |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1978 |
/* Lumber mills are extractive/organic, but can always be built like a non-raw industry */ |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1979 |
return (this->life_type & (INDUSTRYLIFE_EXTRACTIVE | INDUSTRYLIFE_ORGANIC)) != 0 && |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1980 |
(this->behaviour & INDUSTRYBEH_CUT_TREES) == 0; |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1981 |
} |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1982 |
|
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1983 |
Money IndustrySpec::GetConstructionCost() const |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1984 |
{ |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1985 |
return (_price.build_industry * |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1986 |
(_patches.raw_industry_construction == 1 && this->IsRawIndustry() ? |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1987 |
this->raw_industry_cost_multiplier : |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1988 |
this->cost_multiplier |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1989 |
)) >> 8; |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1990 |
} |
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1991 |
|
1b6b21b69c2d
(svn r10459) -Codechange: add helper functions to determine whether an industry is a primary industry and how much it costs to build such an industry.
rubidium
parents:
7177
diff
changeset
|
1992 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
1993 |
extern const TileTypeProcs _tile_type_industry_procs = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
1994 |
DrawTile_Industry, /* draw_tile_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
1995 |
GetSlopeZ_Industry, /* get_slope_z_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
1996 |
ClearTile_Industry, /* clear_tile_proc */ |
4434
a08cb4b5c179
(svn r6204) -Cleanup: replace non-indentation with spaces; like '}<TAB>else {' -> '} else {', tabs between code and comment, etc.
rubidium
parents:
4403
diff
changeset
|
1997 |
GetAcceptedCargo_Industry, /* get_accepted_cargo_proc */ |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
1998 |
GetTileDesc_Industry, /* get_tile_desc_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
1999 |
GetTileTrackStatus_Industry, /* get_tile_track_status_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
2000 |
ClickTile_Industry, /* click_tile_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
2001 |
AnimateTile_Industry, /* animate_tile_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
2002 |
TileLoop_Industry, /* tile_loop_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
2003 |
ChangeTileOwner_Industry, /* change_tile_owner_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
2004 |
GetProducedCargo_Industry, /* get_produced_cargo_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
2005 |
NULL, /* vehicle_enter_tile_proc */ |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4330
diff
changeset
|
2006 |
GetSlopeTileh_Industry, /* get_slope_tileh_proc */ |
0 | 2007 |
}; |
2008 |
||
1881
435d39bd6ee0
(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents:
1800
diff
changeset
|
2009 |
static const SaveLoad _industry_desc[] = { |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2010 |
SLE_CONDVAR(Industry, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2011 |
SLE_CONDVAR(Industry, xy, SLE_UINT32, 6, SL_MAX_VERSION), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2012 |
SLE_VAR(Industry, width, SLE_UINT8), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2013 |
SLE_VAR(Industry, height, SLE_UINT8), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2014 |
SLE_REF(Industry, town, REF_TOWN), |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
2015 |
SLE_CONDNULL( 2, 2, 60), ///< used to be industry's produced_cargo |
7165
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
2016 |
SLE_CONDARR(Industry, incoming_cargo_waiting, SLE_UINT16, 3, 70, SL_MAX_VERSION), |
fb78336b205f
(svn r10439) -Codechange: initial steps for customized industry productions.
rubidium
parents:
7151
diff
changeset
|
2017 |
SLE_ARR(Industry, produced_cargo_waiting, SLE_UINT16, 2), |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2018 |
SLE_ARR(Industry, production_rate, SLE_UINT8, 2), |
6636
fec086b5c340
(svn r9867) -Codechange: Remove data duplication. The exact same values can be found in the industry spec, so take it from there instead.
belugas
parents:
6560
diff
changeset
|
2019 |
SLE_CONDNULL( 3, 2, 60), ///< used to be industry's accepts_cargo |
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2020 |
SLE_VAR(Industry, prod_level, SLE_UINT8), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2021 |
SLE_ARR(Industry, this_month_production, SLE_UINT16, 2), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2022 |
SLE_ARR(Industry, this_month_transported, SLE_UINT16, 2), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2023 |
SLE_ARR(Industry, last_month_pct_transported, SLE_UINT8, 2), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2024 |
SLE_ARR(Industry, last_month_production, SLE_UINT16, 2), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2025 |
SLE_ARR(Industry, last_month_transported, SLE_UINT16, 2), |
0 | 2026 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2027 |
SLE_VAR(Industry, counter, SLE_UINT16), |
0 | 2028 |
|
6819
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2029 |
SLE_VAR(Industry, type, SLE_UINT8), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2030 |
SLE_VAR(Industry, owner, SLE_UINT8), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2031 |
SLE_VAR(Industry, random_color, SLE_UINT8), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2032 |
SLE_CONDVAR(Industry, last_prod_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2033 |
SLE_CONDVAR(Industry, last_prod_year, SLE_INT32, 31, SL_MAX_VERSION), |
f986f54e2660
(svn r10058) -Codechange: give some industry variable sensible names (like not telling "last_mo_production" when it is the production of the current month).
rubidium
parents:
6815
diff
changeset
|
2034 |
SLE_VAR(Industry, was_cargo_delivered, SLE_UINT8), |
0 | 2035 |
|
7186
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
2036 |
SLE_CONDVAR(Industry, owner, SLE_UINT8, 70, SL_MAX_VERSION), |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
2037 |
SLE_CONDVAR(Industry, construction_date, SLE_INT32, 70, SL_MAX_VERSION), |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
2038 |
SLE_CONDVAR(Industry, construction_type, SLE_UINT8, 70, SL_MAX_VERSION), |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
2039 |
SLE_CONDVAR(Industry, last_cargo_accepted_at, SLE_INT32, 70, SL_MAX_VERSION), |
818eba1f20d5
(svn r10460) -Codechange: add some more variables needed for newindustries regarding to the creation of the industries.
rubidium
parents:
7185
diff
changeset
|
2040 |
|
6201
bee01dc45e39
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6092
diff
changeset
|
2041 |
/* reserve extra space in savegame here. (currently 32 bytes) */ |
3222
6de22e06a1e9
(svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents:
3173
diff
changeset
|
2042 |
SLE_CONDNULL(32, 2, SL_MAX_VERSION), |
0 | 2043 |
|
2044 |
SLE_END() |
|
2045 |
}; |
|
2046 |
||
6247 | 2047 |
static void Save_INDY() |
0 | 2048 |
{ |
2049 |
Industry *ind; |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
909
diff
changeset
|
2050 |
|
7288
9059a49c2102
(svn r10635) -Codechange: Correct some typos and code beautifying (a little bit)
belugas
parents:
7266
diff
changeset
|
2051 |
/* Write the industries */ |
830
36c1366367e4
(svn r1301) -Codechange: _industries finally has FOR_ALL_INDUSTRIES too
truelight
parents:
817
diff
changeset
|
2052 |
FOR_ALL_INDUSTRIES(ind) { |
4346
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
2053 |
SlSetArrayIndex(ind->index); |
66105d4f6e83
(svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents:
4344
diff
changeset
|
2054 |
SlObject(ind, _industry_desc); |
0 | 2055 |
} |
2056 |
} |
|
2057 |
||
7290
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2058 |
/* Save and load the mapping between the industry/tile id on the map, and the grf file |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2059 |
* it came from. */ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2060 |
static const SaveLoad _industries_id_mapping_desc[] = { |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2061 |
SLE_VAR(EntityIDMapping, grfid, SLE_UINT32), |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2062 |
SLE_VAR(EntityIDMapping, entity_id, SLE_UINT8), |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2063 |
SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8), |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2064 |
SLE_END() |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2065 |
}; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2066 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2067 |
static void Save_IIDS() |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2068 |
{ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2069 |
uint i; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2070 |
uint j = _industry_mngr.GetMaxMapping(); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2071 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2072 |
for (i = 0; i < j; i++) { |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2073 |
SlSetArrayIndex(i); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2074 |
SlObject(&_industry_mngr.mapping_ID[i], _industries_id_mapping_desc); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2075 |
} |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2076 |
} |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2077 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2078 |
static void Save_TIDS() |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2079 |
{ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2080 |
uint i; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2081 |
uint j = _industile_mngr.GetMaxMapping(); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2082 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2083 |
for (i = 0; i < j; i++) { |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2084 |
SlSetArrayIndex(i); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2085 |
SlObject(&_industile_mngr.mapping_ID[i], _industries_id_mapping_desc); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2086 |
} |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2087 |
} |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2088 |
|
6247 | 2089 |
static void Load_INDY() |
0 | 2090 |
{ |
2091 |
int index; |
|
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
2092 |
|
6839
2cc0a04fa761
(svn r10078) -Codechange: Centralize all industry counts data and access
belugas
parents:
6824
diff
changeset
|
2093 |
ResetIndustryCounts(); |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
2094 |
|
0 | 2095 |
while ((index = SlIterateArray()) != -1) { |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
2096 |
Industry *i; |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
909
diff
changeset
|
2097 |
|
4976
2e3d5e8ec510
(svn r6979) Use the pool macros for the Industry pool
tron
parents:
4965
diff
changeset
|
2098 |
if (!AddBlockIfNeeded(&_Industry_pool, index)) |
1267
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
2099 |
error("Industries: failed loading savegame: too many industries"); |
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
2100 |
|
ba42a505ab8a
(svn r1771) -Add: Industries are now dynamic (up to 64k industries). Generating
truelight
parents:
1247
diff
changeset
|
2101 |
i = GetIndustry(index); |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
909
diff
changeset
|
2102 |
SlObject(i, _industry_desc); |
6824
b37cba5bf2ca
(svn r10063) -Codechange: Change VARDEF for extern
belugas
parents:
6819
diff
changeset
|
2103 |
IncIndustryTypeCount(i->type); |
0 | 2104 |
} |
2105 |
} |
|
2106 |
||
7290
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2107 |
static void Load_IIDS() |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2108 |
{ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2109 |
int index; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2110 |
uint max_id; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2111 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2112 |
/* clear the current mapping stored. |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2113 |
* This will create the manager if ever it is not yet done */ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2114 |
_industry_mngr.ResetMapping(); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2115 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2116 |
/* get boundary for the temporary map loader NUM_INDUSTRYTYPES? */ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2117 |
max_id = _industry_mngr.GetMaxMapping(); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2118 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2119 |
while ((index = SlIterateArray()) != -1) { |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2120 |
if ((uint)index >= max_id) break; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2121 |
SlObject(&_industry_mngr.mapping_ID[index], _industries_id_mapping_desc); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2122 |
} |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2123 |
} |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2124 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2125 |
static void Load_TIDS() |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2126 |
{ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2127 |
int index; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2128 |
uint max_id; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2129 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2130 |
/* clear the current mapping stored. |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2131 |
* This will create the manager if ever it is not yet done */ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2132 |
_industile_mngr.ResetMapping(); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2133 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2134 |
/* get boundary for the temporary map loader NUM_INDUSTILES? */ |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2135 |
max_id = _industile_mngr.>GetMaxMapping(); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2136 |
|
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2137 |
while ((index = SlIterateArray()) != -1) { |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2138 |
if ((uint)index >= max_id) break; |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2139 |
SlObject(&_industile_mngr.mapping_ID[index], _industries_id_mapping_desc); |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2140 |
} |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2141 |
} |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2142 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
2143 |
extern const ChunkHandler _industry_chunk_handlers[] = { |
7290
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2144 |
{ 'INDY', Save_INDY, Load_INDY, CH_ARRAY}, |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2145 |
{ 'IIDS', Save_IIDS, Load_IIDS, CH_ARRAY}, |
bb6d72d5230a
(svn r10638) -Codechange: Save the mapping of the industries and tiles, making them persistent.
belugas
parents:
7288
diff
changeset
|
2146 |
{ 'TIDS', Save_TIDS, Load_TIDS, CH_ARRAY | CH_LAST}, |
0 | 2147 |
}; |