mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Fixed NET::ShutDown recursive calling, fixed decompressed patch header size on decompress.
This commit is contained in:
parent
e03d74b753
commit
f5208d2b61
@ -20,10 +20,10 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: shutdown netchannel
|
||||
//-----------------------------------------------------------------------------
|
||||
void NET_ShutDown(void* thisptr, const char* szReason, std::uint8_t a1, char a2)
|
||||
void HNET_ShutDown(void* thisptr, const char* szReason, std::uint8_t a1, char a2)
|
||||
{
|
||||
DownloadPlaylists_Callback(); // Re-load playlist from disk after getting disconnected from the server.
|
||||
NET_ShutDown(thisptr, szReason, a1, a2);
|
||||
NET_Shutdown(thisptr, szReason, a1, a2);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -154,11 +154,17 @@ void NET_DisconnectClient(CClient* pClient, int nIndex, const char* szReason, ui
|
||||
void CNetChan_Attach()
|
||||
{
|
||||
DetourAttach((LPVOID*)&NET_PrintFunc, &HNET_PrintFunc);
|
||||
#ifndef DEDICATED
|
||||
DetourAttach((LPVOID*)&NET_Shutdown, &HNET_ShutDown);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CNetChan_Detach()
|
||||
{
|
||||
DetourDetach((LPVOID*)&NET_PrintFunc, &HNET_PrintFunc);
|
||||
#ifndef DEDICATED
|
||||
DetourDetach((LPVOID*)&NET_Shutdown, &HNET_ShutDown);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CNetChan_Trace_Attach()
|
||||
|
@ -78,29 +78,34 @@ struct rpak_h
|
||||
std::uint8_t unk2[0x1C]; //
|
||||
};
|
||||
|
||||
struct __declspec(align(8)) rpak_patch_compress_header
|
||||
{
|
||||
std::uint64_t m_nSizeDisk;
|
||||
std::uint64_t m_nSizeMemory;
|
||||
};
|
||||
|
||||
struct __declspec(align(8)) rpak_decomp_state
|
||||
{
|
||||
uint64_t m_nInputBuf;
|
||||
uint64_t m_nOut;
|
||||
uint64_t m_nMask;
|
||||
uint64_t m_nOutMask;
|
||||
uint64_t m_nTotalFileLen;
|
||||
uint64_t m_nDecompSize;
|
||||
uint64_t m_nInvMaskIn;
|
||||
uint64_t m_nInvMaskOut;
|
||||
uint32_t header_skip_bytes_bs;
|
||||
uint32_t dword44;
|
||||
uint64_t input_byte_pos;
|
||||
uint64_t m_nDecompPosition;
|
||||
uint64_t len_needed;
|
||||
uint64_t byte;
|
||||
uint32_t byte_bit_offset;
|
||||
uint32_t dword6C;
|
||||
uint64_t qword70;
|
||||
uint64_t m_nCompressedStreamSize;
|
||||
uint64_t m_nDecompStreamSize;
|
||||
std::uint64_t m_nInputBuf;
|
||||
std::uint64_t m_nOut;
|
||||
std::uint64_t m_nMask;
|
||||
std::uint64_t m_nOutMask;
|
||||
std::uint64_t m_nTotalFileLen;
|
||||
std::uint64_t m_nDecompSize;
|
||||
std::uint64_t m_nInvMaskIn;
|
||||
std::uint64_t m_nInvMaskOut;
|
||||
std::uint32_t header_skip_bytes_bs;
|
||||
std::uint32_t dword44;
|
||||
std::uint64_t input_byte_pos;
|
||||
std::uint64_t m_nDecompPosition;
|
||||
std::uint64_t len_needed;
|
||||
std::uint64_t byte;
|
||||
std::uint32_t byte_bit_offset;
|
||||
std::uint32_t dword6C;
|
||||
std::uint64_t qword70;
|
||||
std::uint64_t m_nCompressedStreamSize;
|
||||
std::uint64_t m_nDecompStreamSize;
|
||||
};
|
||||
static_assert(sizeof(rpak_decomp_state) == 0x88);
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -492,6 +492,16 @@ void _RTech_Decompress_f_CompletionFunc(CCommand* cmd)
|
||||
|
||||
std::ofstream out_block(pak_name_out, std::fstream::binary);
|
||||
|
||||
if (rheader->m_nPatchIndex > 0) // Check if its an patch rpak.
|
||||
{
|
||||
//// Loop through all the structs and patch their compress size.
|
||||
for (int i = 1, patch_offset = 0x88; i <= rheader->m_nPatchIndex; i++, patch_offset += sizeof(rpak_patch_compress_header))
|
||||
{
|
||||
rpak_patch_compress_header* patch_header = (rpak_patch_compress_header*)((std::uintptr_t)pakbuf.data() + patch_offset);
|
||||
patch_header->m_nSizeDisk = patch_header->m_nSizeMemory;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy_s(pakbuf.data(), state.m_nDecompSize, ((std::uint8_t*)rheader), PAK_HEADER_SIZE); // Overwrite first 0x80 bytes which are NULL with the header data.
|
||||
|
||||
out_block.write((char*)pakbuf.data(), state.m_nDecompSize);
|
||||
|
Loading…
x
Reference in New Issue
Block a user