[FastFiles] Partially correct fastfile progress
This commit is contained in:
parent
566cad6784
commit
107076c26a
@ -6,6 +6,9 @@ namespace Components
|
||||
symmetric_CTR FastFiles::CurrentCTR;
|
||||
std::vector<std::string> FastFiles::ZonePaths;
|
||||
|
||||
unsigned int FastFiles::CurrentZone;
|
||||
unsigned int FastFiles::MaxZones;
|
||||
|
||||
unsigned char FastFiles::ZoneKey[1191] =
|
||||
{
|
||||
0x30,0x82,0x04,0xA3,0x02,0x01,0x00,0x02,0x82,0x01,0x01,
|
||||
@ -269,6 +272,7 @@ namespace Components
|
||||
|
||||
void FastFiles::ReadVersionStub(unsigned int* version, int size)
|
||||
{
|
||||
FastFiles::CurrentZone++;
|
||||
Game::DB_ReadXFileUncompressed(version, size);
|
||||
|
||||
// Allow loading of custom version
|
||||
@ -361,6 +365,22 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
float FastFiles::GetFullLoadedFraction()
|
||||
{
|
||||
float singleProgress = 1.0f / FastFiles::MaxZones;
|
||||
float partialProgress = singleProgress * (FastFiles::CurrentZone - 1);
|
||||
float currentProgress = std::max(std::min(Game::DB_GetLoadedFraction(), 1.0f), 0.0f);
|
||||
return partialProgress + (currentProgress * singleProgress);
|
||||
}
|
||||
|
||||
void FastFiles::LoadZonesStub(Game::XZoneInfo *zoneInfo, unsigned int zoneCount)
|
||||
{
|
||||
FastFiles::CurrentZone = 0;
|
||||
FastFiles::MaxZones = zoneCount;
|
||||
|
||||
Utils::Hook::Call<void(Game::XZoneInfo*, unsigned int)>(0x5BBAC0)(zoneInfo, zoneCount);
|
||||
}
|
||||
|
||||
FastFiles::FastFiles()
|
||||
{
|
||||
Dvar::Register<bool>("ui_zoneDebug", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display current loaded zone.");
|
||||
@ -414,6 +434,13 @@ namespace Components
|
||||
// General read
|
||||
Utils::Hook(0x5B98E4, FastFiles::AuthLoadInflateDecryptBase, HOOK_CALL).install()->quick();
|
||||
|
||||
// Fix fastfile progress
|
||||
Utils::Hook(0x4E5DE3, FastFiles::LoadZonesStub, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x407761, FastFiles::GetFullLoadedFraction, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x49FA1E, FastFiles::GetFullLoadedFraction, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x589090, FastFiles::GetFullLoadedFraction, HOOK_CALL).install()->quick();
|
||||
Utils::Hook(0x629FC0, FastFiles::GetFullLoadedFraction, HOOK_JUMP).install()->quick();
|
||||
|
||||
// Add custom zone paths
|
||||
FastFiles::AddZonePath("zone\\patch\\");
|
||||
FastFiles::AddZonePath("zone\\dlc\\");
|
||||
|
@ -17,6 +17,8 @@ namespace Components
|
||||
|
||||
static void LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
|
||||
|
||||
static float GetFullLoadedFraction();
|
||||
|
||||
static unsigned char ZoneKey[1191];
|
||||
|
||||
private:
|
||||
@ -31,6 +33,9 @@ namespace Components
|
||||
unsigned char data[1];
|
||||
};
|
||||
|
||||
static unsigned int CurrentZone;
|
||||
static unsigned int MaxZones;
|
||||
|
||||
static Key CurrentKey;
|
||||
static symmetric_CTR CurrentCTR;
|
||||
static std::vector<std::string> ZonePaths;
|
||||
@ -46,5 +51,7 @@ namespace Components
|
||||
static void AuthLoadInflateDecryptBase();
|
||||
static void AuthLoadInflateDecryptBaseFunc(unsigned char* buffer);
|
||||
static int InflateInitDecrypt(z_streamp strm, const char *version, int stream_size);
|
||||
|
||||
static void LoadZonesStub(Game::XZoneInfo *zoneInfo, unsigned int zoneCount);
|
||||
};
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ namespace Components
|
||||
this->buffer.enterCriticalSection();
|
||||
Game::XFile* header = reinterpret_cast<Game::XFile*>(this->buffer.data());
|
||||
header->size = this->buffer.length() - sizeof(Game::XFile); // Write correct data size
|
||||
header->externalSize = this->externalSize; // This actually stores how much external data has to be loaded. It's used to calculate the loadscreen progress
|
||||
header->externalSize = 0;//this->externalSize; // This actually stores how much external data has to be loaded. It's used to calculate the loadscreen progress
|
||||
|
||||
// Write stream sizes
|
||||
for (int i = 0; i < Game::MAX_XFILE_COUNT; ++i)
|
||||
|
@ -42,6 +42,7 @@ namespace Game
|
||||
DB_EnumXAssets_t DB_EnumXAssets = (DB_EnumXAssets_t)0x4B76D0;
|
||||
DB_EnumXAssets_Internal_t DB_EnumXAssets_Internal = (DB_EnumXAssets_Internal_t)0x5BB0A0;
|
||||
DB_FindXAssetHeader_t DB_FindXAssetHeader = (DB_FindXAssetHeader_t)0x407930;
|
||||
DB_GetLoadedFraction_t DB_GetLoadedFraction = (DB_GetLoadedFraction_t)0x468380;
|
||||
DB_GetXAssetNameHandler_t* DB_GetXAssetNameHandlers = (DB_GetXAssetNameHandler_t*)0x799328;
|
||||
DB_GetXAssetSizeHandler_t* DB_GetXAssetSizeHandlers = (DB_GetXAssetSizeHandler_t*)0x799488;
|
||||
DB_GetXAssetTypeName_t DB_GetXAssetTypeName = (DB_GetXAssetTypeName_t)0x4CFCF0;
|
||||
|
@ -93,6 +93,9 @@ namespace Game
|
||||
typedef XAssetHeader (__cdecl * DB_FindXAssetHeader_t)(XAssetType type, const char* name);
|
||||
extern DB_FindXAssetHeader_t DB_FindXAssetHeader;
|
||||
|
||||
typedef float(__cdecl * DB_GetLoadedFraction_t)();
|
||||
extern DB_GetLoadedFraction_t DB_GetLoadedFraction;
|
||||
|
||||
typedef const char* (__cdecl * DB_GetXAssetNameHandler_t)(XAssetHeader* asset);
|
||||
extern DB_GetXAssetNameHandler_t* DB_GetXAssetNameHandlers;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user