23 #include "newgrf.h" |
23 #include "newgrf.h" |
24 #include "newgrf_commons.h" |
24 #include "newgrf_commons.h" |
25 #include "newgrf_industries.h" |
25 #include "newgrf_industries.h" |
26 #include "newgrf_industrytiles.h" |
26 #include "newgrf_industrytiles.h" |
27 #include "newgrf_callbacks.h" |
27 #include "newgrf_callbacks.h" |
28 #include "misc/autoptr.hpp" |
|
29 #include "autoslope.h" |
28 #include "autoslope.h" |
30 #include "transparency.h" |
29 #include "transparency.h" |
31 #include "water.h" |
30 #include "water.h" |
32 #include "strings_func.h" |
31 #include "strings_func.h" |
33 #include "tile_cmd.h" |
32 #include "tile_cmd.h" |
1023 cut = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, 0, 1, i, i->type, i->xy) != 0); |
1022 cut = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, 0, 1, i, i->type, i->xy) != 0); |
1024 } |
1023 } |
1025 |
1024 |
1026 if (cut) ChopLumberMillTrees(i); |
1025 if (cut) ChopLumberMillTrees(i); |
1027 } |
1026 } |
|
1027 |
|
1028 TriggerIndustry(i, INDUSTRY_TRIGGER_INDUSTRY_TICK); |
|
1029 StartStopIndustryTileAnimation(i, IAT_INDUSTRY_TICK); |
1028 } |
1030 } |
1029 } |
1031 } |
1030 |
1032 |
1031 void OnTick_Industry() |
1033 void OnTick_Industry() |
1032 { |
1034 { |
1044 } |
1046 } |
1045 |
1047 |
1046 if (_game_mode == GM_EDITOR) return; |
1048 if (_game_mode == GM_EDITOR) return; |
1047 |
1049 |
1048 FOR_ALL_INDUSTRIES(i) { |
1050 FOR_ALL_INDUSTRIES(i) { |
1049 TriggerIndustry(i, INDUSTRY_TRIGGER_INDUSTRY_TICK); |
|
1050 StartStopIndustryTileAnimation(i, IAT_INDUSTRY_TICK); |
|
1051 ProduceIndustryGoods(i); |
1051 ProduceIndustryGoods(i); |
1052 } |
1052 } |
1053 } |
1053 } |
1054 |
1054 |
1055 static bool CheckNewIndustry_NULL(TileIndex tile) |
1055 static bool CheckNewIndustry_NULL(TileIndex tile) |
1581 if (t == NULL) return NULL; |
1581 if (t == NULL) return NULL; |
1582 |
1582 |
1583 if (!CheckIfIndustryIsAllowed(tile, type, t)) return NULL; |
1583 if (!CheckIfIndustryIsAllowed(tile, type, t)) return NULL; |
1584 if (!CheckSuitableIndustryPos(tile)) return NULL; |
1584 if (!CheckSuitableIndustryPos(tile)) return NULL; |
1585 |
1585 |
1586 Industry *i = new Industry(tile); |
1586 if (!Industry::CanAllocateItem()) return NULL; |
1587 if (i == NULL) return NULL; |
|
1588 AutoPtrT<Industry> i_auto_delete = i; |
|
1589 |
1587 |
1590 if (flags & DC_EXEC) { |
1588 if (flags & DC_EXEC) { |
|
1589 Industry *i = new Industry(tile); |
1591 if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_EXEC, it, type); |
1590 if (!custom_shape_check) CheckIfCanLevelIndustryPlatform(tile, DC_EXEC, it, type); |
1592 DoCreateNewIndustry(i, tile, type, it, itspec_index, t, OWNER_NONE); |
1591 DoCreateNewIndustry(i, tile, type, it, itspec_index, t, OWNER_NONE); |
1593 i_auto_delete.Detach(); |
1592 |
1594 } |
1593 return i; |
1595 |
1594 } |
1596 return i; |
1595 |
|
1596 /* We need to return a non-NULL pointer to tell we have created an industry. |
|
1597 * However, we haven't created a real one (no DC_EXEC), so return a fake one. */ |
|
1598 return GetIndustry(0); |
1597 } |
1599 } |
1598 |
1600 |
1599 /** Build/Fund an industry |
1601 /** Build/Fund an industry |
1600 * @param tile tile where industry is built |
1602 * @param tile tile where industry is built |
1601 * @param flags of operations to conduct |
1603 * @param flags of operations to conduct |