Merge branch 'save_ext' into enhanced_viewport_overlay

# Conflicts:
#	src/industry_cmd.cpp
#	src/vehicle.cpp
This commit is contained in:
Jonathan G Rennison
2018-03-11 22:16:19 +00:00
155 changed files with 7373 additions and 1175 deletions

View File

@@ -31,28 +31,6 @@ static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX];
HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, NUM_HOUSES, INVALID_HOUSE_ID);
/**
* Constructor of a house scope resolver.
* @param ro Surrounding resolver.
* @param house_id House type being queried.
* @param tile %Tile containing the house.
* @param town %Town containing the house.
* @param not_yet_constructed House is still under construction.
* @param initial_random_bits Random bits during construction checks.
* @param watched_cargo_triggers Cargo types that triggered the watched cargo callback.
*/
HouseScopeResolver::HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town,
bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
: ScopeResolver(ro)
{
this->house_id = house_id;
this->tile = tile;
this->town = town;
this->not_yet_constructed = not_yet_constructed;
this->initial_random_bits = initial_random_bits;
this->watched_cargo_triggers = watched_cargo_triggers;
}
/**
* Retrieve the grf file associated with a house.
* @param house_id House to query.
@@ -169,12 +147,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 +585,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);