2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-24 08:53:04 +00:00

chore: fix annoying IW4 cross-type pointer reusage with dirty hack

The game reuses pointer across different types as long as bytes and size matches
This leads to non-pointer and pointer types being reused
To fix this loading code now handles block memory offsets by nulling
and block offsets to non-block data with pointing to raw block data
The behaviour only seems to realistically happen on nulled memory
This commit is contained in:
Jan
2025-06-19 11:51:22 +01:00
parent 667d76e50e
commit d30e2e6532
5 changed files with 125 additions and 9 deletions

View File

@@ -0,0 +1,19 @@
#include "InvalidLookupPositionException.h"
#include <format>
InvalidLookupPositionException::InvalidLookupPositionException(block_t block, size_t offset)
: m_block(block),
m_offset(offset)
{
}
std::string InvalidLookupPositionException::DetailedMessage()
{
return std::format("Zone tried to lookup at block {}, offset {} that was not recorded", m_block, m_offset);
}
char const* InvalidLookupPositionException::what() const noexcept
{
return "Zone tried to lookup at zone offset that is not recorded";
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "LoadingException.h"
#include "Zone/ZoneTypes.h"
#include <cstdlib>
class InvalidLookupPositionException final : public LoadingException
{
public:
InvalidLookupPositionException(block_t block, size_t offset);
std::string DetailedMessage() override;
char const* what() const noexcept override;
private:
block_t m_block;
size_t m_offset;
};