Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/REL/IDDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,22 @@ namespace REL
m_name, modVersion.string(), header.game_version().string());
}

const auto mapName = std::format("COMMONLIB_IDDB_OFFSETS_{}", modVersion.string("_"));
// v0/v2 loaders store id/offset pairs under COMMONLIB_IDDB_OFFSETS_*, so the raw v5 file needs its own name
const auto mapName = std::format("COMMONLIB_IDDB_OFFSETS_V5_{}", modVersion.string("_"));
if (!m_mmap.create(false, m_path, mapName))
REX::FAIL(L"Failed to create Address Library MemoryMap!\nError: {}\nPath: {}", REX::W32::GetLastError(), m_path.wstring());

validate_file();

static_assert(sizeof(HEADER_V5) == 0x60);
if (std::memcmp(m_mmap.data(), std::addressof(header), sizeof(HEADER_V5)) != 0)
REX::FAIL(
"{}\n\n"
"Address Library MemoryMap {} does not match {}!\n"
"Another plugin created it with a different layout.\n"
"Game Version: {}",
m_name, mapName, m_path.filename().string(), modVersion.string());

m_v5 = { reinterpret_cast<std::uint32_t*>(m_mmap.data() + sizeof(HEADER_V5)), header.offset_count() };

} catch (const std::system_error&) {
Expand Down