45 bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
63 const HouseSpec *hs = HouseSpec::Get(house_id);
80 CallbackID callback, uint32 param1, uint32 param2,
81 bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
83 house_scope(*this, house_id, tile, town, not_yet_constructed, initial_random_bits, watched_cargo_triggers),
84 town_scope(*this, town, not_yet_constructed)
89 HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid)
92 for (
int i = 1; i !=
lengthof(_class_mapping); i++) {
103 return HOUSE_NO_CLASS;
106 void InitializeBuildingCounts()
108 memset(&_building_counts, 0,
sizeof(_building_counts));
129 _building_counts.id_count[house_id]++;
131 if (class_id == HOUSE_NO_CLASS)
return;
134 _building_counts.class_count[class_id]++;
150 if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--;
152 if (class_id == HOUSE_NO_CLASS)
return;
155 if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--;
178 static uint32 GetNumHouses(
HouseID house_id,
const Town *town)
180 uint8 map_id_count, town_id_count, map_class_count, town_class_count;
183 map_id_count =
ClampU(_building_counts.id_count[house_id], 0, 255);
184 map_class_count =
ClampU(_building_counts.class_count[class_id], 0, 255);
188 return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
220 const HouseSpec *hs = HouseSpec::Get(house);
225 if (north_tile == nbhd->
north_tile)
return false;
244 const HouseSpec *hs = HouseSpec::Get(house);
249 if (north_tile == nbhd->
north_tile)
return false;
268 const HouseSpec *hs = HouseSpec::Get(house);
273 if (north_tile == nbhd->
north_tile)
return false;
299 uint8 searchtype =
GB(parameter, 6, 2);
300 uint8 searchradius =
GB(parameter, 0, 6);
301 if (searchtype >=
lengthof(search_procs))
return 0;
302 if (searchradius < 1)
return 0;
305 nbhd.
hs = HouseSpec::Get(house);
309 if (
CircularTileSearch(&found_tile, 2 * searchradius + 1, search_procs[searchtype], &nbhd)) {
334 case 0x44:
return GetNumHouses(this->
house_id, this->
town);
354 return new_house == INVALID_HOUSE_ID ? 0 : GetNumHouses(new_house, this->
town);
381 for (
Station *
const * st_iter = sl->
Begin(); st_iter != sl->
End(); st_iter++) {
405 if (hs->
class_id != HOUSE_NO_CLASS) {
410 uint local_houseid = 0;
417 return houseclass << 16 | local_houseid;
428 return _house_mngr.
GetGRFID(house_id);
432 DEBUG(grf, 1,
"Unhandled house variable 0x%X", variable);
439 bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
444 not_yet_constructed, initial_random_bits, watched_cargo_triggers);
445 return object.ResolveCallback();
452 const HouseSpec *hs = HouseSpec::Get(house_id);
458 palette =
HasBit(callback, 14) ?
GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback;
477 const HouseSpec *hs = HouseSpec::Get(house_id);
480 bool draw_old_one =
true;
493 if (group != NULL && group->type == SGT_TILELAYOUT) {
504 return GetHouseCallback(callback, param1, param2, spec - HouseSpec::Get(0), town, tile,
false, 0, extra_data);
519 if (hs == NULL)
return;
524 void AnimateNewHouseConstruction(
TileIndex tile)
551 static void AnimationControl(
TileIndex tile, uint16 random_bits)
570 TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP);
571 if (hs->
building_flags & BUILDING_HAS_1_TILE) TriggerHouse(tile, HOUSE_TRIGGER_TILE_LOOP_TOP);
579 uint16 random =
GB(Random(), 0, 16);
581 if (hs->
building_flags & BUILDING_HAS_1_TILE) AnimationControl(tile, random);
586 AnimationControl(tile, 0);
594 ClearTownHouse(Town::GetByTile(tile), tile);
604 static void DoTriggerHouse(
TileIndex tile, HouseTrigger trigger, byte base_random,
bool first)
615 object.trigger = trigger;
618 if (group == NULL)
return;
620 byte new_random_bits = Random();
622 uint32 reseed =
object.GetReseedSum();
623 random_bits &= ~reseed;
624 random_bits |= (first ? new_random_bits : base_random) & reseed;
628 case HOUSE_TRIGGER_TILE_LOOP:
632 case HOUSE_TRIGGER_TILE_LOOP_TOP:
646 void TriggerHouse(
TileIndex t, HouseTrigger trigger)
648 DoTriggerHouse(t, trigger, 0,
true);
661 uint32 cb_info = random << 16 | (uint8)diff.
y << 8 | (uint8)diff.
x;
675 const HouseSpec *hs = HouseSpec::Get(
id);
679 if (trigger_cargoes == 0)
return;
686 hs = HouseSpec::Get(
id);