author | belugas |
Thu, 28 Jun 2007 02:14:40 +0000 | |
changeset 7102 | fe01c264132b |
parent 7000 | 603a41cb93f8 |
child 7165 | fb78336b205f |
permissions | -rw-r--r-- |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
1 |
/* $Id$ */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
2 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
3 |
/** @file newgrf_industries.cpp */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
4 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
6 |
#include "openttd.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
7 |
#include "debug.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
8 |
#include "functions.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
9 |
#include "macros.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
10 |
#include "industry.h" |
6868
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
11 |
#include "industry_map.h" |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
12 |
#include "newgrf.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
13 |
#include "newgrf_callbacks.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
14 |
#include "newgrf_spritegroup.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
15 |
#include "newgrf_industries.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
16 |
#include "newgrf_commons.h" |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
17 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
18 |
/* Since the industry IDs defined by the GRF file don't necessarily correlate |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
19 |
* to those used by the game, the IDs used for overriding old industries must be |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
20 |
* translated when the idustry spec is set. */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
21 |
IndustryOverrideManager _industry_mngr(NEW_INDUSTRYOFFSET, NUM_INDUSTRYTYPES, INVALID_INDUSTRYTYPE); |
7000
603a41cb93f8
(svn r10256) -Add: Addition of IndustryTileOverrideManager
belugas
parents:
6884
diff
changeset
|
22 |
IndustryTileOverrideManager _industile_mngr(NEW_INDUSTRYTILEOFFSET, NUM_INDUSTRYTILES, INVALID_INDUSTRYTILE); |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
23 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
24 |
/** |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
25 |
* Finds the distance for the closest tile with water/land given a tile |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
26 |
* @param tile the tile to find the distance too |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
27 |
* @param water whether to find water or land |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
28 |
* @note FAILS when an industry should be seen as water |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
29 |
*/ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
30 |
static uint GetClosestWaterDistance(TileIndex tile, bool water) |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
31 |
{ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
32 |
TileIndex t; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
33 |
uint best_dist; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
34 |
for (t = 1; t < MapSize(); t++) { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
35 |
if (IsTileType(t, MP_WATER) == water) break; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
36 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
37 |
best_dist = DistanceManhattan(tile, t); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
38 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
39 |
for (; t < MapSize(); t++) { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
40 |
uint dist = DistanceManhattan(tile, t); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
41 |
if (dist < best_dist) { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
42 |
if (IsTileType(t, MP_WATER) == water) best_dist = dist; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
43 |
} else { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
44 |
/* When the Y distance between the current row and the 'source' tile |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
45 |
* is larger than the best distance, we've found the best distance */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
46 |
if (TileY(t) - TileY(tile) > best_dist) return best_dist; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
47 |
if (TileX(tile) > TileX(t)) { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
48 |
/* We can safely skip this many tiles; from here all tiles have a |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
49 |
* higher or equal distance than the best distance */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
50 |
t |= MapMaxX(); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
51 |
continue; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
52 |
} else { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
53 |
/* We can safely skip this many tiles; up to here all tiles have a |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
54 |
* higher or equal distance than the best distance */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
55 |
t += best_dist - dist; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
56 |
continue; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
57 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
58 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
59 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
60 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
61 |
return best_dist; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
62 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
63 |
|
6868
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
64 |
/** Make an analysis of a tile and check for its belonging to the same |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
65 |
* industry, and/or the same grf file |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
66 |
* @param new_tile TileIndex of the tile to query |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
67 |
* @param old_tile TileINdex of teh reference tile |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
68 |
* @param i Industry to which old_tile belongs to |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
69 |
* @return value encoded as per NFO specs */ |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
70 |
uint32 GetIndustryIDAtOffset(TileIndex new_tile, TileIndex old_tile, const Industry *i) |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
71 |
{ |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
72 |
if (IsTileType(new_tile, MP_INDUSTRY)) { // Is this an industry tile? |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
73 |
|
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
74 |
if (GetIndustryIndex(new_tile) == i->index) { // Does it belong to the same industry? |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
75 |
IndustryGfx gfx = GetIndustryGfx(new_tile); |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
76 |
const IndustryTileSpec *indtsp = GetIndustryTileSpec(gfx); |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
77 |
const IndustryTileSpec *indold = GetIndustryTileSpec(GetIndustryGfx(old_tile)); |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
78 |
|
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
79 |
if (gfx < NEW_INDUSTRYOFFSET) { // Does it belongs to an old type? |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
80 |
/* It is an old tile. We have to see if it's been overriden */ |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
81 |
if (indtsp->grf_prop.override == INVALID_INDUSTRYTILE) { // has it been overridden? |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
82 |
return 0xFF << 8 | gfx; // no. Tag FF + the gfx id of that tile |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
83 |
} else { // yes. FInd out if it is from the same grf file or not |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
84 |
const IndustryTileSpec *old_tile_ovr = GetIndustryTileSpec(indtsp->grf_prop.override); |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
85 |
|
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
86 |
if (old_tile_ovr->grf_prop.grffile->grfid == indold->grf_prop.grffile->grfid) { |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
87 |
return old_tile_ovr->grf_prop.local_id; // same grf file |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
88 |
} else { |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
89 |
return 0xFFFE; // not the same grf file |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
90 |
} |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
91 |
} |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
92 |
} else { |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
93 |
if (indtsp->grf_prop.spritegroup != NULL) { // tile has a spritegroup ? |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
94 |
if (indtsp->grf_prop.grffile->grfid == indold->grf_prop.grffile->grfid) { // same industry, same grf ? |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
95 |
return indtsp->grf_prop.local_id; |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
96 |
} else { |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
97 |
return 0xFFFE; // Defined in another grf file |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
98 |
} |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
99 |
} else { // tile has no spritegroup |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
100 |
return 0xFF << 8 | indtsp->grf_prop.subst_id; // so just give him the substitute |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
101 |
} |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
102 |
} |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
103 |
} |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
104 |
} |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
105 |
|
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
106 |
return 0xFFFF; // tile is not an industry one or does not belong to the current industry |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
107 |
} |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
108 |
|
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
109 |
/** This function implements the industries variables that newGRF defines. |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
110 |
* @param variable that is queried |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
111 |
* @param parameter unused |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
112 |
* @param available will return false if ever the variable asked for does not exist |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
113 |
* @param ind is of course the industry we are inquiring |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
114 |
* @return the value stored in the corresponding variable*/ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
115 |
uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
116 |
{ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
117 |
const Industry *industry = object->u.industry.ind; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
118 |
TileIndex tile = object->u.industry.tile; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
119 |
const IndustrySpec *indspec = GetIndustrySpec(industry->type); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
120 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
121 |
switch (variable) { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
122 |
case 0x40: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
123 |
case 0x41: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
124 |
case 0x42: { // waiting cargo, but only if those two callback flags are set |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
125 |
uint16 callback = indspec->callback_flags; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
126 |
if (callback & (CBM_IND_PRODUCTION_CARGO_ARRIVAL | callback & CBM_IND_PRODUCTION_256_TICKS)) { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
127 |
return max(industry->cargo_waiting[variable - 0x40], (uint16)0x7FFF); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
128 |
} else { |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
129 |
return 0; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
130 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
131 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
132 |
/* TODO: somehow determine whether we're in water or not */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
133 |
case 0x43: return GetClosestWaterDistance(tile, true); // Manhattan distance of closes dry/water tile |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
134 |
|
6868
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
135 |
/* Get industry ID at offset param */ |
abaf9e30691e
(svn r10108) -Codechange: implement variable 0x60 (Get industry tile ID at offset) for industries.
belugas
parents:
6835
diff
changeset
|
136 |
case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->xy), tile, industry); |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
137 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
138 |
case 0x61: return 0; // Get random tile bits at offset param |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
139 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
140 |
case 0x62: // Land info of nearby tiles |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
141 |
case 0x63: // Animation stage of nerby tiles |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
142 |
case 0x64: break; // Distance of nearest industry of given type |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
143 |
/* Get town zone and Manhattan distance of closest town */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
144 |
case 0x65: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceManhattan(tile, industry->town->xy), 0xFFFF); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
145 |
/* Get square of Euclidian distance of closes town */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
146 |
case 0x66: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceSquare(tile, industry->town->xy), 0xFFFF); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
147 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
148 |
/* Count of industry, distance of closest instance |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
149 |
* format is rr(reserved) cc(count) dddd(manhattan distance of closest sister) |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
150 |
* A lot more should be done, since it has to check for local id, grf id etc... |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
151 |
* let's just say it is a beginning ;) */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
152 |
case 0x67: return GetIndustryTypeCount(industry->type) << 16 | 0; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
153 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
154 |
/* Industry founder information. |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
155 |
* 0x10 if randomly created or from a map pre-newindustry. |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
156 |
* Else, the company who funded it */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
157 |
case 0xA7: return 0x10; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
158 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
159 |
case 0xB0: // Date when built since 1920 (in days) |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
160 |
case 0xB3: // Construction type |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
161 |
case 0xB4: break; // Date last cargo accepted since 1920 (in days) |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
162 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
163 |
/* Industry structure access*/ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
164 |
case 0x80: return industry->xy; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
165 |
case 0x81: return GB(industry->xy, 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
166 |
/* Pointer to the town the industry is associated with */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
167 |
case 0x82: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
168 |
case 0x83: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
169 |
case 0x84: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
170 |
case 0x85: break; // not supported |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
171 |
case 0x86: return industry->width; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
172 |
case 0x87: return industry->height;// xy dimensions |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
173 |
/* */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
174 |
case 0x88: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
175 |
case 0x89: return indspec->produced_cargo[variable - 0x88]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
176 |
case 0x8A: return industry->cargo_waiting[0]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
177 |
case 0x8B: return GB(industry->cargo_waiting[0], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
178 |
case 0x8C: return industry->cargo_waiting[1]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
179 |
case 0x8D: return GB(industry->cargo_waiting[1], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
180 |
case 0x8E: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
181 |
case 0x8F: return industry->production_rate[variable - 0x8E]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
182 |
case 0x90: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
183 |
case 0x91: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
184 |
case 0x92: return indspec->accepts_cargo[variable - 0x90]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
185 |
case 0x93: return industry->prod_level; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
186 |
/* amount of cargo produced so far THIS month. */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
187 |
case 0x94: return industry->this_month_production[0]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
188 |
case 0x95: return GB(industry->this_month_production[0], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
189 |
case 0x96: return industry->this_month_production[1]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
190 |
case 0x97: return GB(industry->this_month_production[1], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
191 |
/* amount of cargo transported so far THIS month. */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
192 |
case 0x98: return industry->this_month_transported[0]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
193 |
case 0x99: return GB(industry->this_month_transported[0], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
194 |
case 0x9A: return industry->this_month_transported[1]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
195 |
case 0x9B: return GB(industry->this_month_transported[0], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
196 |
/* fraction of cargo transported LAST month. */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
197 |
case 0x9C: |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
198 |
case 0x9D: return industry->last_month_pct_transported[variable - 0x9C]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
199 |
/* amount of cargo produced LAST month. */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
200 |
case 0x9E: return industry->last_month_production[0]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
201 |
case 0x9F: return GB(industry->last_month_production[0], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
202 |
case 0xA0: return industry->last_month_production[1]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
203 |
case 0xA1: return GB(industry->last_month_production[1], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
204 |
/* amount of cargo transported last month. */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
205 |
case 0xA2: return industry->last_month_transported[0]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
206 |
case 0xA3: return GB(industry->last_month_transported[0], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
207 |
case 0xA4: return industry->last_month_transported[1]; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
208 |
case 0xA5: return GB(industry->last_month_transported[0], 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
209 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
210 |
case 0xA6: return industry->type; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
211 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
212 |
case 0xA8: return industry->random_color; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
213 |
case 0xA9: return industry->last_prod_year; // capped? |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
214 |
case 0xAA: return industry->counter; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
215 |
case 0xAB: return GB(industry->counter, 8, 8); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
216 |
case 0xAC: return industry->was_cargo_delivered; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
217 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
218 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
219 |
DEBUG(grf, 1, "Unhandled industry property 0x%X", variable); |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
220 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
221 |
*available = false; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
222 |
return (uint32)-1; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
223 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
224 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
225 |
static const SpriteGroup *IndustryResolveReal(const ResolverObject *object, const SpriteGroup *group) |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
226 |
{ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
227 |
/* IndustryTile do not have 'real' groups */ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
228 |
return NULL; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
229 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
230 |
|
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
6868
diff
changeset
|
231 |
static void NewIndustryResolver(ResolverObject *res, TileIndex tile, Industry *indus) |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
232 |
{ |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
6868
diff
changeset
|
233 |
res->GetRandomBits = IndustryTileGetRandomBits; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
6868
diff
changeset
|
234 |
res->GetTriggers = IndustryTileGetTriggers; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
6868
diff
changeset
|
235 |
res->SetTriggers = IndustryTileSetTriggers; |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
236 |
res->GetVariable = IndustryGetVariable; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
237 |
res->ResolveReal = IndustryResolveReal; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
238 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
239 |
res->u.industry.tile = tile; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
240 |
res->u.industry.ind = indus; |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
6868
diff
changeset
|
241 |
res->u.industry.gfx = INVALID_INDUSTRYTILE; |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
242 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
243 |
res->callback = 0; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
244 |
res->callback_param1 = 0; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
245 |
res->callback_param2 = 0; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
246 |
res->last_value = 0; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
247 |
res->trigger = 0; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
248 |
res->reseed = 0; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
249 |
} |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
250 |
|
7102
fe01c264132b
(svn r10369) -Codechange: Add the IndustryType parameter to the GetIndustryCallback function.
belugas
parents:
7000
diff
changeset
|
251 |
uint16 GetIndustryCallback(uint16 callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile) |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
252 |
{ |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
253 |
ResolverObject object; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
254 |
const SpriteGroup *group; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
255 |
|
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
6868
diff
changeset
|
256 |
NewIndustryResolver(&object, tile, industry); |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
257 |
object.callback = callback; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
258 |
object.callback_param1 = param1; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
259 |
object.callback_param2 = param2; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
260 |
|
7102
fe01c264132b
(svn r10369) -Codechange: Add the IndustryType parameter to the GetIndustryCallback function.
belugas
parents:
7000
diff
changeset
|
261 |
group = Resolve(GetIndustrySpec(type)->grf_prop.spritegroup, &object); |
6835
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
262 |
if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
263 |
|
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
264 |
return group->g.callback.result; |
31c89aab2d61
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
265 |
} |