diff --git a/src/Components/Modules/AssetHandler.cpp b/src/Components/Modules/AssetHandler.cpp index b6cd3e3e..756a3354 100644 --- a/src/Components/Modules/AssetHandler.cpp +++ b/src/Components/Modules/AssetHandler.cpp @@ -116,30 +116,13 @@ namespace Components bool AssetHandler::IsAssetEligible(Game::XAssetType type, Game::XAssetHeader *asset) { const char* name = Game::DB_GetXAssetNameHandlers[type](asset); + if (!name) return false; - if (name == "com_pipe_8x128_ceramic"s) - { - OutputDebugStringA(""); - } - - if (type == 10 && Zones::Version() >= 332 && Utils::String::StartsWith(name, "*")) - { - OutputDebugStringA(Utils::String::VA("LoadDefPtr: %X -> %s\n", reinterpret_cast(asset->image->texture), name)); - } - - if (name == "fx_icicle_broken_small"s || (type != 9 && type != 6 && type != 8 && type != 7 && Zones::Version() >= 332)) - { - OutputDebugStringA(""); - } - - // Should we perform the null check before or after this? if (Flags::HasFlag("entries")) { OutputDebugStringA(Utils::String::VA("%s: %d: %s\n", FastFiles::Current().data(), type, name)); } - if (!name) return false; - bool restrict = false; AssetHandler::RestrictSignal(type, *asset, name, &restrict); @@ -196,10 +179,6 @@ namespace Components void AssetHandler::OffsetToAlias(Utils::Stream::Offset* offset) { -#ifdef DEBUG - Utils::Stream::Offset old = *offset; -#endif - // Same here, reinterpret the value, as we're operating inside the game's environment void* pointer = (*Game::g_streamBlocks)[offset->GetUnpackedBlock()].data + offset->GetUnpackedOffset(); @@ -209,10 +188,6 @@ namespace Components } offset->pointer = *reinterpret_cast(pointer); - -#ifdef DEBUG - Game::XAssetHeader zob{ offset->pointer }; -#endif } void AssetHandler::ZoneSave(Game::XAsset asset, ZoneBuilder::Zone* builder) diff --git a/src/Components/Modules/RawFiles.cpp b/src/Components/Modules/RawFiles.cpp index cc37184f..54b80d7b 100644 --- a/src/Components/Modules/RawFiles.cpp +++ b/src/Components/Modules/RawFiles.cpp @@ -25,5 +25,27 @@ namespace Components #ifndef DEBUG QuickPatch::OnFrame(AntiCheat::FlagIntegrityCheck); #endif + + Command::Add("dumpraw", [] (Command::Params params) + { + if (params.Length() < 2) + { + Logger::Print("Specify a filename!\n"); + return; + } + + std::string filename = params[1]; + const char* data = Game::LoadModdableRawfile(0, filename.data()); + + if (data) + { + Utils::IO::WriteFile("raw/" + filename, data); + Logger::Print("File '%s' written to raw!\n", filename.data()); + } + else + { + Logger::Print("File '%s' does not exist!\n", filename.data()); + } + }); } } diff --git a/src/Components/Modules/Zones.cpp b/src/Components/Modules/Zones.cpp index 322462da..982ed86f 100644 --- a/src/Components/Modules/Zones.cpp +++ b/src/Components/Modules/Zones.cpp @@ -106,8 +106,6 @@ namespace Components int elSize = (Zones::ZoneVersion == VERSION_ALPHA2) ? 364 : 360; *Game::varXString = reinterpret_cast(reinterpret_cast(*Game::varXModel) + (elSize - 4) - (4 * (4 - i))); Game::Load_XString(false); - - Game::XModel* model = *Game::varXModel; } __declspec(naked) void Zones::LoadXModelLodInfoStub() @@ -672,57 +670,8 @@ namespace Components bool result = Game::Load_Stream(atStreamStart, buffer, size + 4); memcpy(buffer + 28, buffer + 32, 4); - //AssetHandler::Relocate(buffer + 32, buffer + 28, 4); - - // Tell the game to load the image externally! - //Game::GfxImage* image = reinterpret_cast(buffer); - //image->loaded = false; - //image->dataLen1 = 0; - //image->dataLen2 = 0; - - return result; - } - - bool Load_GfxImageLoadStruct(bool atStreamStart, char* buffer, int size) - { -// if (Zones::Version() >= 332) -// { -// size = 0; -// (*reinterpret_cast(0x112ACD0))->dataSize = 0; -// } - - return Game::Load_Stream(atStreamStart, buffer, size); - } - - Utils::Hook LoadStreamHook; - - DWORD Load_Texture(Game::GfxImageLoadDef** loadDef, Game::GfxImage* image) - { -// if (!(*loadDef)->dataSize) -// { -// image->loaded = false; -// } - - if (FastFiles::Current() == "mp_cargoship_sh" || FastFiles::Current() == "mp_cargoship_sh_load") - { - LoadStreamHook.Install(); - OutputDebugStringA(""); - } - - //OutputDebugStringA(Utils::String::VA("LoadDefPtr: %X -> %s\n", reinterpret_cast(image->texture), image->name)); - DWORD result = Utils::Hook::Call(0x51F4E0)(loadDef, image); - //OutputDebugStringA(Utils::String::VA("LoadDefPtr: %X -> %s\n", reinterpret_cast(image->texture), image->name)); - - return result; - } - - bool LoadStream(bool atStreamStart, void* buffer, int size) - { - LoadStreamHook.Uninstall(); - bool result = Game::Load_Stream(atStreamStart, buffer, size); - LoadStreamHook.Install(); - - OutputDebugStringA(Utils::String::VA("Loading %d bytes from stream %d at %X (%d)\n", size, *(DWORD*)0x16E5578, (DWORD)_ReturnAddress(), atStreamStart & 1)); + AssetHandler::Relocate(buffer + 32, buffer + 28, 4); + //AssetHandler::Relocate(buffer + 28, buffer + 32, 4); // There is no point in storing the LoadDef return result; } @@ -770,7 +719,7 @@ namespace Components Utils::Hook::Set(0x418B30, (patch) ? 43 : Game::ASSET_TYPE_ADDON_MAP_ENTS); // Change block for images - //Utils::Hook::Set(0x4C13E4, ((Zones::ZoneVersion >= 332) ? 3 : 0)); + Utils::Hook::Set(0x4D3224, ((Zones::ZoneVersion >= 332) ? 3 : 0)); if (patch) { @@ -806,7 +755,6 @@ namespace Components if (Zones::ZoneVersion >= 332) { Zones::LoadGfxImageHook.Install(); - //Utils::Hook::Nop(0x5BB93E, 2); } else { @@ -883,11 +831,6 @@ namespace Components { ZeroMemory(*Game::varPathData, sizeof(Game::PathData)); }, HOOK_CALL); - - Utils::Hook(0x4D32A9, Load_GfxImageLoadStruct, HOOK_CALL).Install()->Quick(); - Utils::Hook(0x4D32BC, Load_Texture, HOOK_CALL).Install()->Quick(); - - LoadStreamHook.Initialize(Game::Load_Stream, LoadStream, HOOK_JUMP); } Zones::~Zones() diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index a5a1d6aa..8e0d025f 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -353,7 +353,7 @@ namespace Game typedef void(__cdecl * Live_ParsePlaylists_t)(const char* data); extern Live_ParsePlaylists_t Live_ParsePlaylists; - typedef void* (__cdecl * LoadModdableRawfile_t)(int a1, const char* filename); + typedef char* (__cdecl * LoadModdableRawfile_t)(int a1, const char* filename); extern LoadModdableRawfile_t LoadModdableRawfile; typedef int(__cdecl * PC_ReadToken_t)(source_t*, token_t*); diff --git a/src/Utils/IO.cpp b/src/Utils/IO.cpp index 5fdf05a4..33e6a21c 100644 --- a/src/Utils/IO.cpp +++ b/src/Utils/IO.cpp @@ -11,6 +11,8 @@ namespace Utils void WriteFile(std::string file, std::string data) { + CreateDirectory(file.substr(0, file.find_last_of("/\\"))); + std::ofstream stream(file, std::ios::binary); if (stream.is_open())