17 #include "newgrf_industries.h" |
16 #include "newgrf_industries.h" |
18 #include "newgrf_industrytiles.h" |
17 #include "newgrf_industrytiles.h" |
19 #include "newgrf_text.h" |
18 #include "newgrf_text.h" |
20 #include "industry_map.h" |
19 #include "industry_map.h" |
21 #include "clear_map.h" |
20 #include "clear_map.h" |
|
21 #include "sprite.h" |
|
22 #include "transparency.h" |
|
23 #include "functions.h" |
|
24 #include "town.h" |
|
25 #include "command_func.h" |
|
26 |
22 #include "table/sprites.h" |
27 #include "table/sprites.h" |
23 #include "table/strings.h" |
28 #include "table/strings.h" |
24 #include "sprite.h" |
29 |
25 #include "transparency.h" |
30 static uint32 GetGRFParameter(IndustryGfx indtile_id, byte parameter) |
|
31 { |
|
32 const IndustryTileSpec *indtspec = GetIndustryTileSpec(indtile_id); |
|
33 const GRFFile *file = indtspec->grf_prop.grffile; |
|
34 |
|
35 if (parameter >= file->param_end) return 0; |
|
36 return file->param[parameter]; |
|
37 } |
26 |
38 |
27 /** |
39 /** |
28 * Based on newhouses equivalent, but adapted for newindustries |
40 * Based on newhouses equivalent, but adapted for newindustries |
29 * @param parameter from callback. It's in fact a pair of coordinates |
41 * @param parameter from callback. It's in fact a pair of coordinates |
30 * @param tile TileIndex from which the callback was initiated |
42 * @param tile TileIndex from which the callback was initiated |
99 return 0xFFFFFFFF; |
111 return 0xFFFFFFFF; |
100 } |
112 } |
101 |
113 |
102 /* Get industry tile ID at offset */ |
114 /* Get industry tile ID at offset */ |
103 case 0x62 : return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), inds); |
115 case 0x62 : return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), inds); |
|
116 |
|
117 /* Read GRF parameter */ |
|
118 case 0x7F: return GetGRFParameter(GetIndustryGfx(tile), parameter); |
104 } |
119 } |
105 |
120 |
106 DEBUG(grf, 1, "Unhandled industry tile property 0x%X", variable); |
121 DEBUG(grf, 1, "Unhandled industry tile property 0x%X", variable); |
107 |
122 |
108 *available = false; |
123 *available = false; |
151 |
166 |
152 res->psa = &indus->psa; |
167 res->psa = &indus->psa; |
153 res->u.industry.tile = tile; |
168 res->u.industry.tile = tile; |
154 res->u.industry.ind = indus; |
169 res->u.industry.ind = indus; |
155 res->u.industry.gfx = gfx; |
170 res->u.industry.gfx = gfx; |
|
171 res->u.industry.type = indus->type; |
156 |
172 |
157 res->callback = CBID_NO_CALLBACK; |
173 res->callback = CBID_NO_CALLBACK; |
158 res->callback_param1 = 0; |
174 res->callback_param1 = 0; |
159 res->callback_param2 = 0; |
175 res->callback_param2 = 0; |
160 res->last_value = 0; |
176 res->last_value = 0; |
411 void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger) |
427 void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger) |
412 { |
428 { |
413 DoTriggerIndustryTile(tile, trigger, GetIndustryByTile(tile)); |
429 DoTriggerIndustryTile(tile, trigger, GetIndustryByTile(tile)); |
414 } |
430 } |
415 |
431 |
416 extern void DoTriggerIndustry(Industry *ind, IndustryTileTrigger trigger); |
|
417 |
|
418 void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger) |
432 void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger) |
419 { |
433 { |
420 BEGIN_TILE_LOOP(tile, ind->width, ind->height, ind->xy) |
434 BEGIN_TILE_LOOP(tile, ind->width, ind->height, ind->xy) |
421 if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) { |
435 if (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == ind->index) { |
422 DoTriggerIndustryTile(tile, trigger, ind); |
436 DoTriggerIndustryTile(tile, trigger, ind); |
423 } |
437 } |
424 END_TILE_LOOP(tile, ind->width, ind->height, ind->xy) |
438 END_TILE_LOOP(tile, ind->width, ind->height, ind->xy) |
425 |
439 } |
426 DoTriggerIndustry(ind, trigger); |
|
427 } |
|