author | belugas |
Wed, 13 Jun 2007 18:35:06 +0000 | |
changeset 6899 | 7edc4e4b1fd8 |
parent 6884 | a931841e9df4 |
child 6919 | 4f62b4f5a81f |
permissions | -rw-r--r-- |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
1 |
/* $Id$ */ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
2 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
3 |
/** @file newgrf_industrytiles.cpp */ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
4 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
6 |
#include "openttd.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
7 |
#include "functions.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
8 |
#include "variables.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
9 |
#include "debug.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
10 |
#include "viewport.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
11 |
#include "landscape.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
12 |
#include "newgrf.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
13 |
#include "industry.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
14 |
#include "newgrf_commons.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
15 |
#include "newgrf_spritegroup.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
16 |
#include "newgrf_callbacks.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
17 |
#include "newgrf_industries.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
18 |
#include "industry_map.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
19 |
#include "clear_map.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
20 |
#include "table/sprites.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
21 |
#include "sprite.h" |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
22 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
23 |
/** |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
24 |
* Based on newhouses equivalent, but adapted for newindustries |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
25 |
* @param parameter from callback. It's in fact a pair of coordinates |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
26 |
* @param tile TileIndex from which the callback was initiated |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
27 |
* @param index of the industry been queried for |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
28 |
* @return a construction of bits obeying the newgrf format |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
29 |
*/ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
30 |
static uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
31 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
32 |
byte tile_type; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
33 |
bool is_same_industry; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
34 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
35 |
tile = GetNearbyTile(parameter, tile); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
36 |
is_same_industry = (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == index); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
37 |
tile_type = GetTerrainType(tile) << 2 | (IsTileType(tile, MP_WATER) ? 1 : 0) << 1 | (is_same_industry ? 1 : 0); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
38 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
39 |
return GetTileType(tile) << 24 | (TileHeight(tile) * 8) << 16 | tile_type << 8 | GetTileSlope(tile, NULL); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
40 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
41 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
42 |
/** This is the position of the tile relative to the northernmost tile of the industry. |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
43 |
* Format: 00yxYYXX |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
44 |
* Variable Content |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
45 |
* x the x offset from the northernmost tile |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
46 |
* XX same, but stored in a byte instead of a nibble |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
47 |
* y the y offset from the northernmost tile |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
48 |
* YY same, but stored in a byte instead of a nibble |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
49 |
* @param tile TileIndex of the tile to evaluate |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
50 |
* @param ind_tile northernmost tile of the industry |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
51 |
*/ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
52 |
static uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
53 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
54 |
byte x = TileX(ind_tile) - TileX(tile); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
55 |
byte y = TileY(ind_tile) - TileY(tile); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
56 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
57 |
return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
58 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
59 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
60 |
static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
61 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
62 |
const Industry *inds = object->u.industry.ind; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
63 |
TileIndex tile = object->u.industry.tile; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
64 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
65 |
if (object->scope == VSG_SCOPE_PARENT) { |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
66 |
return IndustryGetVariable(object, variable, parameter, available); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
67 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
68 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
69 |
switch (variable) { |
6899
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
70 |
/* Construction state of the tile: a value between 0 and 3 */ |
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
71 |
case 0x40 : return (IsTileType(tile, MP_INDUSTRY)) ? GetIndustryConstructionStage(tile) : 0; |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
72 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
73 |
case 0x41 : return GetTerrainType(tile); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
74 |
|
6899
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
75 |
/* Current town zone of the tile in the nearest town */ |
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
76 |
case 0x42 : return GetTownRadiusGroup(ClosestTownFromTile(tile, (uint)-1), tile); |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
77 |
|
6899
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
78 |
/* Relative position */ |
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
79 |
case 0x43 : return GetRelativePosition(tile, inds->xy); |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
80 |
|
6899
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
81 |
/* Animation frame. Like house variable 46 but can contain anything 0..FF. */ |
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
82 |
case 0x44 : return (IsTileType(tile, MP_INDUSTRY)) ? GetIndustryAnimationState(tile) : 0; |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
83 |
|
6899
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
84 |
/* Land info of nearby tiles */ |
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
85 |
case 0x60 : return GetNearbyIndustryTileInformation(parameter, tile, inds->index); |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
86 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
87 |
case 0x61 : {/* Animation stage of nearby tiles */ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
88 |
tile = GetNearbyTile(parameter, tile); |
6899
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
89 |
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == inds) { |
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
90 |
return GetIndustryAnimationState(tile); |
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
91 |
} |
7edc4e4b1fd8
(svn r10146) -Codechange: Silence a compiler warning
belugas
parents:
6884
diff
changeset
|
92 |
return 0xFFFFFFFF; |
6884
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
93 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
94 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
95 |
/* Get industry tile ID at offset */ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
96 |
case 0x62 : return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), tile, inds); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
97 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
98 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
99 |
return 0; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
100 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
101 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
102 |
static const SpriteGroup *IndustryTileResolveReal(const ResolverObject *object, const SpriteGroup *group) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
103 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
104 |
/* IndustryTile do not have 'real' groups. Or do they?? */ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
105 |
return NULL; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
106 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
107 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
108 |
uint32 IndustryTileGetRandomBits(const ResolverObject *object) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
109 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
110 |
const TileIndex tile = object->u.industry.tile; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
111 |
return (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) ? 0 : GetIndustryRandomBits(tile); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
112 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
113 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
114 |
uint32 IndustryTileGetTriggers(const ResolverObject *object) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
115 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
116 |
const TileIndex tile = object->u.industry.tile; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
117 |
return (tile == INVALID_TILE || !IsTileType(tile, MP_INDUSTRY)) ? 0 : GetIndustryTriggers(tile); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
118 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
119 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
120 |
void IndustryTileSetTriggers(const ResolverObject *object, int triggers) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
121 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
122 |
const TileIndex tile = object->u.industry.tile; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
123 |
if (IsTileType(tile, MP_INDUSTRY)) SetIndustryTriggers(tile, triggers); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
124 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
125 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
126 |
static void NewIndustryTileResolver(ResolverObject *res, IndustryGfx gfx, TileIndex tile, Industry *indus) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
127 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
128 |
res->GetRandomBits = IndustryTileGetRandomBits; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
129 |
res->GetTriggers = IndustryTileGetTriggers; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
130 |
res->SetTriggers = IndustryTileSetTriggers; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
131 |
res->GetVariable = IndustryTileGetVariable; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
132 |
res->ResolveReal = IndustryTileResolveReal; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
133 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
134 |
res->u.industry.tile = tile; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
135 |
res->u.industry.ind = indus; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
136 |
res->u.industry.gfx = gfx; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
137 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
138 |
res->callback = 0; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
139 |
res->callback_param1 = 0; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
140 |
res->callback_param2 = 0; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
141 |
res->last_value = 0; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
142 |
res->trigger = 0; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
143 |
res->reseed = 0; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
144 |
} |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
145 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
146 |
uint16 GetIndustryTileCallback(uint16 callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile) |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
147 |
{ |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
148 |
ResolverObject object; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
149 |
const SpriteGroup *group; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
150 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
151 |
NewIndustryTileResolver(&object, gfx_id, tile, industry); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
152 |
object.callback = callback; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
153 |
object.callback_param1 = param1; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
154 |
object.callback_param2 = param2; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
155 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
156 |
group = Resolve(GetIndustryTileSpec(gfx_id)->grf_prop.spritegroup, &object); |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
157 |
if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
158 |
|
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
159 |
return group->g.callback.result; |
a931841e9df4
(svn r10127) -Add: Addition of basic structure for industry tiles callbacks (unfinished).
belugas
parents:
diff
changeset
|
160 |
} |