diff --git a/src/Components/Modules/FastFiles.cpp b/src/Components/Modules/FastFiles.cpp index e4bbd49a..addc4047 100644 --- a/src/Components/Modules/FastFiles.cpp +++ b/src/Components/Modules/FastFiles.cpp @@ -143,6 +143,17 @@ namespace Components return file; } + void FastFiles::ReadVersionStub(unsigned int* version, int size) + { + Game::DB_ReadXFileUncompressed(version, size); + + // Allow loading out custom version + if (*version == XFILE_VERSION_IW4X) + { + *version = XFILE_VERSION; + } + } + FastFiles::FastFiles() { Dvar::Register("ui_zoneDebug", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display current loaded zone."); @@ -150,6 +161,9 @@ namespace Components // Redirect zone paths Utils::Hook(0x44DA90, FastFiles::GetZoneLocation, HOOK_JUMP).Install()->Quick(); + // Allow loading 'newer' zones + Utils::Hook(0x4158E7, FastFiles::ReadVersionStub, HOOK_CALL).Install()->Quick(); + // Allow custom zone loading if (!ZoneBuilder::IsEnabled()) { diff --git a/src/Components/Modules/FastFiles.hpp b/src/Components/Modules/FastFiles.hpp index ceee7447..11c8466b 100644 --- a/src/Components/Modules/FastFiles.hpp +++ b/src/Components/Modules/FastFiles.hpp @@ -20,5 +20,7 @@ namespace Components static void LoadInitialZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); static void LoadDLCUIZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); static void LoadGfxZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); + + static void ReadVersionStub(unsigned int* version, int size); }; } diff --git a/src/Components/Modules/ZoneBuilder.cpp b/src/Components/Modules/ZoneBuilder.cpp index 34618fcf..ce297f79 100644 --- a/src/Components/Modules/ZoneBuilder.cpp +++ b/src/Components/Modules/ZoneBuilder.cpp @@ -214,7 +214,7 @@ namespace Components FILETIME fileTime; GetSystemTimeAsFileTime(&fileTime); - Game::XFileHeader header = { XFILE_MAGIC_UNSIGNED, XFILE_VERSION, Game::XFileLanguage::XLANG_NONE, fileTime.dwHighDateTime, fileTime.dwLowDateTime }; + Game::XFileHeader header = { XFILE_MAGIC_UNSIGNED, XFILE_VERSION_IW4X, Game::XFileLanguage::XLANG_NONE, fileTime.dwHighDateTime, fileTime.dwLowDateTime }; std::string outBuffer; outBuffer.append(reinterpret_cast(&header), sizeof(header)); diff --git a/src/Components/Modules/ZoneBuilder.hpp b/src/Components/Modules/ZoneBuilder.hpp index dbcbf2d2..320c6142 100644 --- a/src/Components/Modules/ZoneBuilder.hpp +++ b/src/Components/Modules/ZoneBuilder.hpp @@ -1,5 +1,6 @@ #define XFILE_MAGIC_UNSIGNED 0x3030317566665749 #define XFILE_VERSION 276 +#define XFILE_VERSION_IW4X 0x78345749 // 'IW4x' namespace Components { diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index 87d76412..0aca7b47 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -36,6 +36,7 @@ namespace Game DB_GetXAssetTypeName_t DB_GetXAssetTypeName = (DB_GetXAssetTypeName_t)0x4CFCF0; DB_IsXAssetDefault_t DB_IsXAssetDefault = (DB_IsXAssetDefault_t)0x48E6A0; DB_LoadXAssets_t DB_LoadXAssets = (DB_LoadXAssets_t)0x4E5930; + DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed = (DB_ReadXFileUncompressed_t)0x4705E0; Dvar_RegisterBool_t Dvar_RegisterBool = (Dvar_RegisterBool_t)0x4CE1A0; Dvar_RegisterFloat_t Dvar_RegisterFloat = (Dvar_RegisterFloat_t)0x648440; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index b48db643..f4045c97 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -81,6 +81,9 @@ namespace Game typedef void(*DB_LoadXAssets_t)(XZoneInfo *zoneInfo, unsigned int zoneCount, int sync); extern DB_LoadXAssets_t DB_LoadXAssets; + typedef void(__cdecl * DB_ReadXFileUncompressed_t)(void* buffer, int size); + extern DB_ReadXFileUncompressed_t DB_ReadXFileUncompressed; + typedef dvar_t* (__cdecl * Dvar_RegisterBool_t)(const char* name, bool default, int flags, const char* description); extern Dvar_RegisterBool_t Dvar_RegisterBool;