43 #include "oldpool_func.h" |
43 #include "oldpool_func.h" |
44 #include "sprite.h" |
44 #include "sprite.h" |
45 #include "economy_func.h" |
45 #include "economy_func.h" |
46 #include "station_func.h" |
46 #include "station_func.h" |
47 #include "cheat_func.h" |
47 #include "cheat_func.h" |
|
48 #include "functions.h" |
|
49 #include "animated_tile_func.h" |
|
50 #include "date_func.h" |
48 |
51 |
49 #include "table/strings.h" |
52 #include "table/strings.h" |
50 #include "table/sprites.h" |
53 #include "table/sprites.h" |
51 #include "table/town_land.h" |
54 #include "table/town_land.h" |
52 |
55 |
266 int pos = GetLiftPosition(tile); |
269 int pos = GetLiftPosition(tile); |
267 int dest = GetLiftDestination(tile) * 6; |
270 int dest = GetLiftDestination(tile) * 6; |
268 pos += (pos < dest) ? 1 : -1; |
271 pos += (pos < dest) ? 1 : -1; |
269 SetLiftPosition(tile, pos); |
272 SetLiftPosition(tile, pos); |
270 |
273 |
271 if (pos == dest) HaltLift(tile); |
274 if (pos == dest) { |
|
275 HaltLift(tile); |
|
276 DeleteAnimatedTile(tile); |
|
277 } |
272 |
278 |
273 MarkTileDirtyByTile(tile); |
279 MarkTileDirtyByTile(tile); |
274 } |
280 } |
275 |
281 |
276 /** |
282 /** |
373 |
379 |
374 /* progress in construction stages */ |
380 /* progress in construction stages */ |
375 IncHouseConstructionTick(tile); |
381 IncHouseConstructionTick(tile); |
376 if (GetHouseConstructionTick(tile) != 0) return; |
382 if (GetHouseConstructionTick(tile) != 0) return; |
377 |
383 |
|
384 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
|
385 |
378 /* Check and/or */ |
386 /* Check and/or */ |
379 if (HasBit(GetHouseSpecs(GetHouseType(tile))->callback_mask, CBM_HOUSE_CONSTRUCTION_STATE_CHANGE)) { |
387 if (HasBit(hs->callback_mask, CBM_HOUSE_CONSTRUCTION_STATE_CHANGE)) { |
380 uint16 callback_res = GetHouseCallback(CBID_HOUSE_CONSTRUCTION_STATE_CHANGE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
388 uint16 callback_res = GetHouseCallback(CBID_HOUSE_CONSTRUCTION_STATE_CHANGE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
381 if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(tile, callback_res); |
389 if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(hs->grffile, tile, callback_res); |
382 } |
390 } |
383 |
391 |
384 if (IsHouseCompleted(tile)) { |
392 if (IsHouseCompleted(tile)) { |
385 /* Now that construction is complete, we can add the population of the |
393 /* Now that construction is complete, we can add the population of the |
386 * building to the town. */ |
394 * building to the town. */ |
387 ChangePopulation(GetTownByTile(tile), GetHouseSpecs(GetHouseType(tile))->population); |
395 ChangePopulation(GetTownByTile(tile), hs->population); |
|
396 SetHouseConstructionYear(tile, _cur_year); |
388 } |
397 } |
389 MarkTileDirtyByTile(tile); |
398 MarkTileDirtyByTile(tile); |
390 } |
399 } |
391 |
400 |
392 /** Make the house advances in its construction stages until completion |
401 /** Make the house advances in its construction stages until completion |
1642 DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR); |
1651 DoCommand(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR); |
1643 |
1652 |
1644 assert(CmdSucceeded(cc)); |
1653 assert(CmdSucceeded(cc)); |
1645 |
1654 |
1646 MakeHouseTile(tile, tid, counter, stage, type, random_bits); |
1655 MakeHouseTile(tile, tid, counter, stage, type, random_bits); |
|
1656 if (GetHouseSpecs(type)->building_flags & BUILDING_IS_ANIMATED) AddAnimatedTile(tile); |
|
1657 |
|
1658 MarkTileDirtyByTile(tile); |
1647 } |
1659 } |
1648 |
1660 |
1649 |
1661 |
1650 /** |
1662 /** |
1651 * Write house information into the map. For houses > 1 tile, all tiles are marked. |
1663 * Write house information into the map. For houses > 1 tile, all tiles are marked. |
1922 |
1934 |
1923 if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue; |
1935 if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue; |
1924 |
1936 |
1925 if (HasBit(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) { |
1937 if (HasBit(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) { |
1926 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house, t, tile); |
1938 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house, t, tile); |
1927 if (callback_res != CALLBACK_FAILED && callback_res == 0) continue; |
1939 if (callback_res != CALLBACK_FAILED && GB(callback_res, 0, 8) == 0) continue; |
1928 } |
1940 } |
1929 } |
1941 } |
1930 |
1942 |
1931 if (_cur_year < hs->min_date || _cur_year > hs->max_date) continue; |
1943 if (_cur_year < hs->min_date || _cur_year > hs->max_date) continue; |
1932 |
1944 |