| 1810 | } |
| 1811 | |
| 1812 | void DoObjectCollision(ItemInfo* item, CollisionInfo* coll) |
| 1813 | { |
| 1814 | item->HitStatus = false; |
| 1815 | coll->HitStatic = false; |
| 1816 | |
| 1817 | bool isPlayer = item->IsLara(); |
| 1818 | bool isHarmless = !isPlayer && (item->Data.is<KayakInfo>() || item->Data.is<UPVInfo>()); |
| 1819 | |
| 1820 | if (isPlayer) |
| 1821 | { |
| 1822 | GetLaraInfo(*item).HitDirection = NO_VALUE; |
| 1823 | |
| 1824 | if (item->HitPoints <= 0) |
| 1825 | return; |
| 1826 | } |
| 1827 | |
| 1828 | if (Objects[item->ObjectNumber].intelligent) |
| 1829 | return; |
| 1830 | |
| 1831 | const auto& room = g_Level.Rooms[item->RoomNumber]; |
| 1832 | for (int neighborRoomNumber : room.NeighborRoomNumbers) |
| 1833 | { |
| 1834 | auto& neighborRoom = g_Level.Rooms[neighborRoomNumber]; |
| 1835 | if (!neighborRoom.Active()) |
| 1836 | continue; |
| 1837 | |
| 1838 | int nextItemNumber = neighborRoom.itemNumber; |
| 1839 | while (nextItemNumber != NO_VALUE) |
| 1840 | { |
| 1841 | auto& linkItem = g_Level.Items[nextItemNumber]; |
| 1842 | int itemNumber = nextItemNumber; |
| 1843 | |
| 1844 | // HACK: For some reason, sometimes an infinite loop may happen here. |
| 1845 | if (nextItemNumber == linkItem.NextItem) |
| 1846 | break; |
| 1847 | |
| 1848 | nextItemNumber = linkItem.NextItem; |
| 1849 | |
| 1850 | if (&linkItem == item) |
| 1851 | continue; |
| 1852 | |
| 1853 | if (!(linkItem.Collidable && linkItem.Status != ITEM_INVISIBLE)) |
| 1854 | continue; |
| 1855 | |
| 1856 | const auto& object = Objects[linkItem.ObjectNumber]; |
| 1857 | |
| 1858 | if (object.collision == nullptr) |
| 1859 | continue; |
| 1860 | |
| 1861 | if (Vector3i::Distance(linkItem.Pose.Position, item->Pose.Position) >= COLLISION_CHECK_DISTANCE) |
| 1862 | continue; |
| 1863 | |
| 1864 | if (isPlayer) |
| 1865 | { |
| 1866 | // Ignore all non-intelligent objects, if player is on a vehicle. This way we avoid |
| 1867 | // any collision routine calls for any interactable objects, as in original, but fix |
| 1868 | // the issue with enemies not hurting Lara on a vehicle via hand combat. |
| 1869 | if (GetLaraInfo(*item).Context.Vehicle != NO_VALUE && !object.intelligent) |
no test coverage detected