* Falling and its subset drowning * rct2: 0x690028 */
| 779 | * rct2: 0x690028 |
| 780 | */ |
| 781 | void Peep::UpdateFalling() |
| 782 | { |
| 783 | if (Action == PeepActionType::drowning) |
| 784 | { |
| 785 | // Check to see if we are ready to drown. |
| 786 | UpdateAction(); |
| 787 | invalidate(); |
| 788 | if (Action == PeepActionType::drowning) |
| 789 | return; |
| 790 | |
| 791 | if (Config::Get().notifications.guestDied) |
| 792 | { |
| 793 | auto ft = Formatter(); |
| 794 | FormatNameTo(ft); |
| 795 | News::AddItemToQueue(News::ItemType::blank, STR_NEWS_ITEM_GUEST_DROWNED, x | (y << 16), ft); |
| 796 | } |
| 797 | |
| 798 | auto& gameState = getGameState(); |
| 799 | gameState.park.ratingCasualtyPenalty = std::min(gameState.park.ratingCasualtyPenalty + 25, 1000); |
| 800 | Remove(); |
| 801 | return; |
| 802 | } |
| 803 | |
| 804 | // If not drowning then falling. Note: peeps 'fall' after leaving a ride/enter the park. |
| 805 | TileElement* tile_element = MapGetFirstElementAt(CoordsXY{ x, y }); |
| 806 | TileElement* saved_map = nullptr; |
| 807 | int32_t saved_height = 0; |
| 808 | |
| 809 | if (tile_element != nullptr) |
| 810 | { |
| 811 | do |
| 812 | { |
| 813 | // If a path check if we are on it |
| 814 | if (tile_element->getType() == TileElementType::Path) |
| 815 | { |
| 816 | int32_t height = MapHeightFromSlope( |
| 817 | { x, y }, tile_element->asPath()->GetSlopeDirection(), |
| 818 | tile_element->asPath()->IsSloped()) |
| 819 | + tile_element->getBaseZ(); |
| 820 | |
| 821 | if (height < z - 1 || height > z + 8) |
| 822 | continue; |
| 823 | |
| 824 | saved_height = height; |
| 825 | saved_map = tile_element; |
| 826 | break; |
| 827 | } // If a surface get the height and see if we are on it |
| 828 | else if (tile_element->getType() == TileElementType::Surface) |
| 829 | { |
| 830 | // If the surface is water check to see if we could be drowning |
| 831 | if (tile_element->asSurface()->GetWaterHeight() > 0) |
| 832 | { |
| 833 | int32_t height = tile_element->asSurface()->GetWaterHeight(); |
| 834 | |
| 835 | if (height - 4 >= z && height < z + 20) |
| 836 | { |
| 837 | // Looks like we are drowning! |
| 838 | moveTo({ x, y, height }); |
nothing calls this directly
no test coverage detected