Re-version custom zones

This commit is contained in:
momo5502 2016-06-28 01:03:37 +02:00
parent 705ab362f0
commit 6bad0ef9a4
6 changed files with 22 additions and 1 deletions

View File

@ -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<bool>("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())
{

View File

@ -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);
};
}

View File

@ -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<char*>(&header), sizeof(header));

View File

@ -1,5 +1,6 @@
#define XFILE_MAGIC_UNSIGNED 0x3030317566665749
#define XFILE_VERSION 276
#define XFILE_VERSION_IW4X 0x78345749 // 'IW4x'
namespace Components
{

View File

@ -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;

View File

@ -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;