0x00472687 based on
| 762 | |
| 763 | // 0x00472687 based on |
| 764 | bool tryInstallObject(const ObjectHeader& objectHeader, std::span<const std::byte> data) |
| 765 | { |
| 766 | unloadAll(); |
| 767 | if (!computeObjectChecksum(objectHeader, data)) |
| 768 | { |
| 769 | return false; |
| 770 | } |
| 771 | // Copy the object into Loco freeable memory (required for when partialLoad loads the object) |
| 772 | std::byte* objectData = static_cast<std::byte*>(malloc(data.size())); |
| 773 | if (objectData == nullptr) |
| 774 | { |
| 775 | return false; |
| 776 | } |
| 777 | std::copy(std::begin(data), std::end(data), objectData); |
| 778 | |
| 779 | auto* obj = reinterpret_cast<Object*>(objectData); |
| 780 | if (!callObjectValidate(objectHeader.getType(), *obj)) |
| 781 | { |
| 782 | return false; |
| 783 | } |
| 784 | |
| 785 | if (getTotalNumImages() >= Gfx::G1ExpectedCount::kObjects + Gfx::G1ExpectedCount::kTemporaryObjects + Gfx::G1ExpectedCount::kDisc) |
| 786 | { |
| 787 | // Free objectData? |
| 788 | return false; |
| 789 | } |
| 790 | |
| 791 | // Warning this saves a copy of the objectData pointer and must be unloaded prior to exiting this function |
| 792 | if (!partialLoad(objectHeader, std::span(objectData, data.size()))) |
| 793 | { |
| 794 | return false; |
| 795 | } |
| 796 | |
| 797 | // Object already installed so no need to install it |
| 798 | if (isObjectInstalled(objectHeader)) |
| 799 | { |
| 800 | unloadAll(); |
| 801 | return false; |
| 802 | } |
| 803 | |
| 804 | bool result = installObject(objectHeader); |
| 805 | |
| 806 | unloadAll(); |
| 807 | return result; |
| 808 | } |
| 809 | |
| 810 | static constexpr SawyerEncoding getBestEncodingForObjectType(ObjectType type) |
| 811 | { |
no test coverage detected