#pragma once // The large map (M, cUI_Megamap): a scrollable view of the 2048x2816 world // map image. docs/hud.md, mods/megamap.cpp. #include namespace game { // Scroll position (map pixel at the view's left / top edge). constexpr size_t kMegamapScrollX = 0xc016c; constexpr size_t kMegamapScrollY = 0xc0170; inline int32_t MegamapScrollX(const uint8_t* megamap) { return *reinterpret_cast(megamap + kMegamapScrollX); } inline int32_t MegamapScrollY(const uint8_t* megamap) { return *reinterpret_cast(megamap + kMegamapScrollY); } struct Vec3 { float x, y, z; }; // cUI_Megamap::WorldToMapPixel (0x6cb130, thiscall (out, world x / y / level), // ret 8): the map pixel of a world position (world units, 53.66563 per tile). // Linear: the world plane projection 0x622700, then x * 0.007446 + 1018.75, // y * 0.014914 - 186.95. inline Vec3 WorldToMapPixel(uint8_t* megamap, const Vec3& world) { Vec3 pixel = {}; using Fn = void(__fastcall*)(uint8_t*, void*, Vec3*, const Vec3*); reinterpret_cast(0x006cb130)(megamap, nullptr, &pixel, &world); return pixel; } constexpr float kWorldUnitsPerTile = 53.66563f; // 0x8946b0 } // namespace game