summaryrefslogtreecommitdiff
path: root/src/newgrf_house.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2017-10-25 15:38:14 +0000
committerfrosch <frosch@openttd.org>2017-10-25 15:38:14 +0000
commit82ae414e8d81718687b88db98346cee594fb2858 (patch)
tree1225534a7f9f17933b48c7426d77d2876adf8dd9 /src/newgrf_house.cpp
parent146e4eddb631d597f1296162d3bf520e4fc524a1 (diff)
downloadopenttd-82ae414e8d81718687b88db98346cee594fb2858.tar.xz
(svn r27928) -Fix: [NewGRF] While executing random triggers, var 5F should include the new triggers.
-Fix: [NewGRF] Reset used random triggers only after all A123 chains have been resolved, so that all RA2 in all chains can test the shard triggers. This also includes multiple RA2 in the same A123 chain. -Fix: [NewGRF] Industry random triggers are stored per tile, even when randomising the shared random bits of the parent industry.
Diffstat (limited to 'src/newgrf_house.cpp')
-rw-r--r--src/newgrf_house.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp
index 2bc85f9ac..bcd83f2f1 100644
--- a/src/newgrf_house.cpp
+++ b/src/newgrf_house.cpp
@@ -169,12 +169,6 @@ void DecreaseBuildingCount(Town *t, HouseID house_id)
return this->not_yet_constructed ? 0 : GetHouseTriggers(this->tile);
}
-/* virtual */ void HouseScopeResolver::SetTriggers(int triggers) const
-{
- assert(!this->not_yet_constructed && IsValidTile(this->tile) && IsTileType(this->tile, MP_HOUSE));
- SetHouseTriggers(this->tile, triggers);
-}
-
static uint32 GetNumHouses(HouseID house_id, const Town *town)
{
uint8 map_id_count, town_id_count, map_class_count, town_class_count;
@@ -613,14 +607,19 @@ static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_rando
if (hs->grf_prop.spritegroup[0] == NULL) return;
HouseResolverObject object(hid, tile, Town::GetByTile(tile), CBID_RANDOM_TRIGGER);
- object.trigger = trigger;
+ object.waiting_triggers = GetHouseTriggers(tile) | trigger;
+ SetHouseTriggers(tile, object.waiting_triggers); // store now for var 5F
const SpriteGroup *group = object.Resolve();
if (group == NULL) return;
+ /* Store remaining triggers. */
+ SetHouseTriggers(tile, object.GetRemainingTriggers());
+
+ /* Rerandomise bits. Scopes other than SELF are invalid for houses. For bug-to-bug-compatibility with TTDP we ignore the scope. */
byte new_random_bits = Random();
byte random_bits = GetHouseRandomBits(tile);
- uint32 reseed = object.GetReseedSum(); // The scope only affects triggers, not the reseeding
+ uint32 reseed = object.GetReseedSum();
random_bits &= ~reseed;
random_bits |= (first ? new_random_bits : base_random) & reseed;
SetHouseRandomBits(tile, random_bits);