diff options
author | rubidium <rubidium@openttd.org> | 2007-07-08 19:54:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-07-08 19:54:51 +0000 |
commit | 70d6fdeca0e975432c42b1e8ff0f930106a480d0 (patch) | |
tree | 6ee6d1aba2cf8edab4c1f62f3e377034d66b8427 /src | |
parent | 101722039e44a4d09c5837e9e05adc7711afc05f (diff) | |
download | openttd-70d6fdeca0e975432c42b1e8ff0f930106a480d0.tar.xz |
(svn r10483) -Codechange: add support for callbacks to manipulate the building chance of farm fields and chopping chance for lumber mills.
Diffstat (limited to 'src')
-rw-r--r-- | src/industry_cmd.cpp | 26 | ||||
-rw-r--r-- | src/newgrf_callbacks.h | 2 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index eab7aee83..0ba2c0750 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -929,11 +929,6 @@ void PlantRandomFarmField(const Industry *i) if (tile != INVALID_TILE) PlantFarmField(tile, i->index); } -static void MaybePlantFarmField(const Industry *i) -{ - if (CHANCE16(1, 8)) PlantRandomFarmField(i); -} - /** * Search callback function for ChopLumberMillTrees * @param tile to test @@ -998,10 +993,23 @@ static void ProduceIndustryGoods(Industry *i) i->produced_cargo_waiting[0] = min(0xffff, i->produced_cargo_waiting[0] + i->production_rate[0]); i->produced_cargo_waiting[1] = min(0xffff, i->produced_cargo_waiting[1] + i->production_rate[1]); - if (indbehav & INDUSTRYBEH_PLANT_FIELDS) { - MaybePlantFarmField(i); - } else if ((indbehav & INDUSTRYBEH_CUT_TREES) && (i->counter & 0x1FF) == 0) { - ChopLumberMillTrees(i); + if ((indbehav & INDUSTRYBEH_PLANT_FIELDS) != 0) { + bool plant; + if (HASBIT(indsp->callback_flags, CBM_IND_SPECIAL_EFFECT)) { + plant = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, Random(), 0, i, i->type, i->xy) != 0); + } else { + plant = CHANCE16(1, 8); + } + + if (plant) PlantRandomFarmField(i); + } + if ((indbehav & INDUSTRYBEH_CUT_TREES) != 0) { + bool cut = ((i->counter & 0x1FF) == 0); + if (HASBIT(indsp->callback_flags, CBM_IND_SPECIAL_EFFECT)) { + cut = (GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, 0, 1, i, i->type, i->xy) != 0); + } + + if (cut) ChopLumberMillTrees(i); } } } diff --git a/src/newgrf_callbacks.h b/src/newgrf_callbacks.h index 29bb174a5..a7ed3e658 100644 --- a/src/newgrf_callbacks.h +++ b/src/newgrf_callbacks.h @@ -153,7 +153,7 @@ enum CallbackID { CBID_INDUSTRY_WINDOW_MORE_TEXT = 0x3A, /* Called to determine industry special effects */ - CBID_INDUSTRY_SPECIAL_EFFECT = 0x3B, // not yet implemented + CBID_INDUSTRY_SPECIAL_EFFECT = 0x3B, /* Called to determine if industry can alter the ground below industry tile */ CBID_INDUSTRY_AUTOSLOPE = 0x3C, // not yet implemented |