321 if (IS_CUSTOM_SPRITE(image)) image += stage; |
321 if (IS_CUSTOM_SPRITE(image)) image += stage; |
322 |
322 |
323 if ((HASBIT(image, SPRITE_MODIFIER_OPAQUE) || !HASBIT(_transparent_opt, TO_HOUSES)) && HASBIT(image, PALETTE_MODIFIER_COLOR)) { |
323 if ((HASBIT(image, SPRITE_MODIFIER_OPAQUE) || !HASBIT(_transparent_opt, TO_HOUSES)) && HASBIT(image, PALETTE_MODIFIER_COLOR)) { |
324 if (pal == 0) { |
324 if (pal == 0) { |
325 const HouseSpec *hs = GetHouseSpecs(house_id); |
325 const HouseSpec *hs = GetHouseSpecs(house_id); |
326 if (HASBIT(hs->callback_mask, CBM_BUILDING_COLOUR)) { |
326 if (HASBIT(hs->callback_mask, CBM_HOUSE_COLOUR)) { |
327 uint16 callback = GetHouseCallback(CBID_BUILDING_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile); |
327 uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, GetTownByTile(ti->tile), ti->tile); |
328 if (callback != CALLBACK_FAILED) { |
328 if (callback != CALLBACK_FAILED) { |
329 /* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */ |
329 /* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */ |
330 pal = HASBIT(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback; |
330 pal = HASBIT(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback; |
331 } |
331 } |
332 } else { |
332 } else { |
377 { |
377 { |
378 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
378 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
379 byte animation_speed = hs->animation_speed; |
379 byte animation_speed = hs->animation_speed; |
380 bool frame_set_by_callback = false; |
380 bool frame_set_by_callback = false; |
381 |
381 |
382 if (HASBIT(hs->callback_mask, CBM_ANIMATION_SPEED)) { |
382 if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_SPEED)) { |
383 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
383 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_SPEED, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
384 if (callback_res != CALLBACK_FAILED) animation_speed = clamp(callback_res & 0xFF, 2, 16); |
384 if (callback_res != CALLBACK_FAILED) animation_speed = clamp(callback_res & 0xFF, 2, 16); |
385 } |
385 } |
386 |
386 |
387 /* An animation speed of 2 means the animation frame changes 4 ticks, and |
387 /* An animation speed of 2 means the animation frame changes 4 ticks, and |
391 if (_tick_counter % (1 << animation_speed) != 0) return; |
391 if (_tick_counter % (1 << animation_speed) != 0) return; |
392 |
392 |
393 byte frame = GetHouseAnimationFrame(tile); |
393 byte frame = GetHouseAnimationFrame(tile); |
394 byte num_frames = GB(hs->animation_frames, 0, 7); |
394 byte num_frames = GB(hs->animation_frames, 0, 7); |
395 |
395 |
396 if (HASBIT(hs->callback_mask, CBM_ANIMATION_NEXT_FRAME)) { |
396 if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_NEXT_FRAME)) { |
397 uint32 param = (hs->extra_flags & CALLBACK_1A_RANDOM_BITS) ? Random() : 0; |
397 uint32 param = (hs->extra_flags & CALLBACK_1A_RANDOM_BITS) ? Random() : 0; |
398 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
398 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_NEXT_FRAME, param, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
399 |
399 |
400 if (callback_res != CALLBACK_FAILED) { |
400 if (callback_res != CALLBACK_FAILED) { |
401 frame_set_by_callback = true; |
401 frame_set_by_callback = true; |
470 |
470 |
471 static void AnimationControl(TileIndex tile, uint16 random_bits) |
471 static void AnimationControl(TileIndex tile, uint16 random_bits) |
472 { |
472 { |
473 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
473 const HouseSpec *hs = GetHouseSpecs(GetHouseType(tile)); |
474 |
474 |
475 if (HASBIT(hs->callback_mask, CBM_ANIMATION_START_STOP)) { |
475 if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) { |
476 uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random(); |
476 uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random(); |
477 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
477 uint16 callback_res = GetHouseCallback(CBID_HOUSE_ANIMATION_START_STOP, param, 0, GetHouseType(tile), GetTownByTile(tile), tile); |
478 |
478 |
479 if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(tile, callback_res); |
479 if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(tile, callback_res); |
480 } |
480 } |
493 * Process randomizing of tiles following specs. |
493 * Process randomizing of tiles following specs. |
494 * Once done, redraw the house |
494 * Once done, redraw the house |
495 * MarkTileDirtyByTile(tile); |
495 * MarkTileDirtyByTile(tile); |
496 */ |
496 */ |
497 |
497 |
498 if (HASBIT(hs->callback_mask, CBM_ANIMATION_START_STOP)) { |
498 if (HASBIT(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) { |
499 /* If this house is marked as having a synchronised callback, all the |
499 /* If this house is marked as having a synchronised callback, all the |
500 * tiles will have the callback called at once, rather than when the |
500 * tiles will have the callback called at once, rather than when the |
501 * tile loop reaches them. This should only be enabled for the northern |
501 * tile loop reaches them. This should only be enabled for the northern |
502 * tile, or strange things will happen (here, and in TTDPatch). */ |
502 * tile, or strange things will happen (here, and in TTDPatch). */ |
503 if (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) { |
503 if (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) { |