author | belugas |
Sat, 09 Jun 2007 02:05:51 +0000 | |
changeset 7331 | 0a7f00fed4e6 |
child 7364 | f72f9b742c34 |
permissions | -rw-r--r-- |
7331
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
1 |
/* $Id$ */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
2 |
|
0a7f00fed4e6
(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 */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
4 |
|
0a7f00fed4e6
(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" |
0a7f00fed4e6
(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" |
0a7f00fed4e6
(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" |
0a7f00fed4e6
(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" |
0a7f00fed4e6
(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" |
0a7f00fed4e6
(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" |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
11 |
#include "newgrf.h" |
0a7f00fed4e6
(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_callbacks.h" |
0a7f00fed4e6
(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_spritegroup.h" |
0a7f00fed4e6
(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_industries.h" |
0a7f00fed4e6
(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_commons.h" |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
16 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
17 |
/* Since the industry IDs defined by the GRF file don't necessarily correlate |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
18 |
* to those used by the game, the IDs used for overriding old industries must be |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
19 |
* translated when the idustry spec is set. */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
20 |
IndustryOverrideManager _industry_mngr(NEW_INDUSTRYOFFSET, NUM_INDUSTRYTYPES, INVALID_INDUSTRYTYPE); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
21 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
22 |
/** |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
23 |
* Finds the distance for the closest tile with water/land given a tile |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
24 |
* @param tile the tile to find the distance too |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
25 |
* @param water whether to find water or land |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
26 |
* @note FAILS when an industry should be seen as water |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
27 |
*/ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
28 |
static uint GetClosestWaterDistance(TileIndex tile, bool water) |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
29 |
{ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
30 |
TileIndex t; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
31 |
uint best_dist; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
32 |
for (t = 1; t < MapSize(); t++) { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
33 |
if (IsTileType(t, MP_WATER) == water) break; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
34 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
35 |
best_dist = DistanceManhattan(tile, t); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
36 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
37 |
for (; t < MapSize(); t++) { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
38 |
uint dist = DistanceManhattan(tile, t); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
39 |
if (dist < best_dist) { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
40 |
if (IsTileType(t, MP_WATER) == water) best_dist = dist; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
41 |
} else { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
42 |
/* When the Y distance between the current row and the 'source' tile |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
43 |
* is larger than the best distance, we've found the best distance */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
44 |
if (TileY(t) - TileY(tile) > best_dist) return best_dist; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
45 |
if (TileX(tile) > TileX(t)) { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
46 |
/* We can safely skip this many tiles; from here all tiles have a |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
47 |
* higher or equal distance than the best distance */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
48 |
t |= MapMaxX(); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
49 |
continue; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
50 |
} else { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
51 |
/* We can safely skip this many tiles; up to here all tiles have a |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
52 |
* higher or equal distance than the best distance */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
53 |
t += best_dist - dist; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
54 |
continue; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
55 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
56 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
57 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
58 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
59 |
return best_dist; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
60 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
61 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
62 |
/** This function implements the industries variables that newGRF defines. |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
63 |
* @param variable that is queried |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
64 |
* @param parameter unused |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
65 |
* @param available will return false if ever the variable asked for does not exist |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
66 |
* @param ind is of course the industry we are inquiring |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
67 |
* @return the value stored in the corresponding variable*/ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
68 |
uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
69 |
{ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
70 |
const Industry *industry = object->u.industry.ind; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
71 |
TileIndex tile = object->u.industry.tile; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
72 |
const IndustrySpec *indspec = GetIndustrySpec(industry->type); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
73 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
74 |
switch (variable) { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
75 |
case 0x40: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
76 |
case 0x41: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
77 |
case 0x42: { // waiting cargo, but only if those two callback flags are set |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
78 |
uint16 callback = indspec->callback_flags; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
79 |
if (callback & (CBM_IND_PRODUCTION_CARGO_ARRIVAL | callback & CBM_IND_PRODUCTION_256_TICKS)) { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
80 |
return max(industry->cargo_waiting[variable - 0x40], (uint16)0x7FFF); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
81 |
} else { |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
82 |
return 0; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
83 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
84 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
85 |
/* TODO: somehow determine whether we're in water or not */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
86 |
case 0x43: return GetClosestWaterDistance(tile, true); // Manhattan distance of closes dry/water tile |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
87 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
88 |
case 0x60: { /* Get industry ID at offset param */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
89 |
/*The parameter of this variable is an offset from the northernmost tile of the industry: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
90 |
* the high nibble contains the Y offset, the low one the X offset; both are unsigned. |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
91 |
* The high word of the return value is currently reserved, and the low word can be: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
92 |
* 00xxh if the tile is an industry tile and was defined in the current GRF with ID xx. |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
93 |
* FFxxh if the tile is an industry tile of an old type, and has the ID xx. |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
94 |
* FFFEh if the tile is an industry tile that was defined in another GRF file |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
95 |
* FFFFh if the tile isn't an industry tile, or doesn't belong to the current industry */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
96 |
return GetIndustry(GetNearbyTile(parameter, tile))->type; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
97 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
98 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
99 |
case 0x61: return 0; // Get random tile bits at offset param |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
100 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
101 |
case 0x62: // Land info of nearby tiles |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
102 |
case 0x63: // Animation stage of nerby tiles |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
103 |
case 0x64: break; // Distance of nearest industry of given type |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
104 |
/* Get town zone and Manhattan distance of closest town */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
105 |
case 0x65: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceManhattan(tile, industry->town->xy), 0xFFFF); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
106 |
/* Get square of Euclidian distance of closes town */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
107 |
case 0x66: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceSquare(tile, industry->town->xy), 0xFFFF); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
108 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
109 |
/* Count of industry, distance of closest instance |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
110 |
* format is rr(reserved) cc(count) dddd(manhattan distance of closest sister) |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
111 |
* A lot more should be done, since it has to check for local id, grf id etc... |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
112 |
* let's just say it is a beginning ;) */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
113 |
case 0x67: return GetIndustryTypeCount(industry->type) << 16 | 0; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
114 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
115 |
/* Industry founder information. |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
116 |
* 0x10 if randomly created or from a map pre-newindustry. |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
117 |
* Else, the company who funded it */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
118 |
case 0xA7: return 0x10; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
119 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
120 |
case 0xB0: // Date when built since 1920 (in days) |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
121 |
case 0xB3: // Construction type |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
122 |
case 0xB4: break; // Date last cargo accepted since 1920 (in days) |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
123 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
124 |
/* Industry structure access*/ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
125 |
case 0x80: return industry->xy; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
126 |
case 0x81: return GB(industry->xy, 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
127 |
/* Pointer to the town the industry is associated with */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
128 |
case 0x82: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
129 |
case 0x83: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
130 |
case 0x84: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
131 |
case 0x85: break; // not supported |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
132 |
case 0x86: return industry->width; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
133 |
case 0x87: return industry->height;// xy dimensions |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
134 |
/* */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
135 |
case 0x88: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
136 |
case 0x89: return indspec->produced_cargo[variable - 0x88]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
137 |
case 0x8A: return industry->cargo_waiting[0]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
138 |
case 0x8B: return GB(industry->cargo_waiting[0], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
139 |
case 0x8C: return industry->cargo_waiting[1]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
140 |
case 0x8D: return GB(industry->cargo_waiting[1], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
141 |
case 0x8E: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
142 |
case 0x8F: return industry->production_rate[variable - 0x8E]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
143 |
case 0x90: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
144 |
case 0x91: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
145 |
case 0x92: return indspec->accepts_cargo[variable - 0x90]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
146 |
case 0x93: return industry->prod_level; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
147 |
/* amount of cargo produced so far THIS month. */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
148 |
case 0x94: return industry->this_month_production[0]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
149 |
case 0x95: return GB(industry->this_month_production[0], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
150 |
case 0x96: return industry->this_month_production[1]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
151 |
case 0x97: return GB(industry->this_month_production[1], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
152 |
/* amount of cargo transported so far THIS month. */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
153 |
case 0x98: return industry->this_month_transported[0]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
154 |
case 0x99: return GB(industry->this_month_transported[0], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
155 |
case 0x9A: return industry->this_month_transported[1]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
156 |
case 0x9B: return GB(industry->this_month_transported[0], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
157 |
/* fraction of cargo transported LAST month. */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
158 |
case 0x9C: |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
159 |
case 0x9D: return industry->last_month_pct_transported[variable - 0x9C]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
160 |
/* amount of cargo produced LAST month. */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
161 |
case 0x9E: return industry->last_month_production[0]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
162 |
case 0x9F: return GB(industry->last_month_production[0], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
163 |
case 0xA0: return industry->last_month_production[1]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
164 |
case 0xA1: return GB(industry->last_month_production[1], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
165 |
/* amount of cargo transported last month. */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
166 |
case 0xA2: return industry->last_month_transported[0]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
167 |
case 0xA3: return GB(industry->last_month_transported[0], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
168 |
case 0xA4: return industry->last_month_transported[1]; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
169 |
case 0xA5: return GB(industry->last_month_transported[0], 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
170 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
171 |
case 0xA6: return industry->type; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
172 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
173 |
case 0xA8: return industry->random_color; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
174 |
case 0xA9: return industry->last_prod_year; // capped? |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
175 |
case 0xAA: return industry->counter; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
176 |
case 0xAB: return GB(industry->counter, 8, 8); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
177 |
case 0xAC: return industry->was_cargo_delivered; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
178 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
179 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
180 |
DEBUG(grf, 1, "Unhandled industry property 0x%X", variable); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
181 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
182 |
*available = false; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
183 |
return (uint32)-1; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
184 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
185 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
186 |
static const SpriteGroup *IndustryResolveReal(const ResolverObject *object, const SpriteGroup *group) |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
187 |
{ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
188 |
/* IndustryTile do not have 'real' groups */ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
189 |
return NULL; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
190 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
191 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
192 |
static void NewIndustryResolver(ResolverObject *res, IndustryType ind_id, TileIndex tile, Industry *indus) |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
193 |
{ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
194 |
res->GetRandomBits = NULL;//IndustryTileGetRandomBits; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
195 |
res->GetTriggers = NULL;//IndustryTileGetTriggers; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
196 |
res->SetTriggers = NULL;//IndustryTileSetTriggers; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
197 |
res->GetVariable = IndustryGetVariable; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
198 |
res->ResolveReal = IndustryResolveReal; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
199 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
200 |
res->u.industry.tile = tile; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
201 |
res->u.industry.ind = indus; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
202 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
203 |
res->callback = 0; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
204 |
res->callback_param1 = 0; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
205 |
res->callback_param2 = 0; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
206 |
res->last_value = 0; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
207 |
res->trigger = 0; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
208 |
res->reseed = 0; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
209 |
} |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
210 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
211 |
uint16 GetIndustryCallback(uint16 callback, uint32 param1, uint32 param2, Industry *industry, TileIndex tile) |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
212 |
{ |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
213 |
ResolverObject object; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
214 |
const SpriteGroup *group; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
215 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
216 |
NewIndustryResolver(&object, industry->type, tile, industry); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
217 |
object.callback = callback; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
218 |
object.callback_param1 = param1; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
219 |
object.callback_param2 = param2; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
220 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
221 |
group = Resolve(GetIndustrySpec(industry->type)->grf_prop.spritegroup, &object); |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
222 |
if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
223 |
|
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
224 |
return group->g.callback.result; |
0a7f00fed4e6
(svn r10074) -Add: Addition of IndustryOverrideManager as well as the basic (and unfinished) support for callbacks for industries
belugas
parents:
diff
changeset
|
225 |
} |