From 0f114677b1437751632cd1dbfb2248b0ccbc0339 Mon Sep 17 00:00:00 2001 From: Deorder <31899960+deorder@users.noreply.github.com> Date: Wed, 28 Aug 2019 14:39:10 +0200 Subject: [PATCH] Added context to FO4 DDS info callback --- libbsarch.cpp | 2 +- libbsarch.dpr | 3 ++- libbsarch.dproj | 4 ++-- libbsarch.h | 4 ++-- wbBSArchive.pas | 7 +++++-- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/libbsarch.cpp b/libbsarch.cpp index 727f26b..9cab580 100644 --- a/libbsarch.cpp +++ b/libbsarch.cpp @@ -148,6 +148,6 @@ BSARCH_DLL_API(void) bsa_share_data_set(bsa_archive_t archive, bool flags) { return; } -BSARCH_DLL_API(void) bsa_file_dds_info_callback_set(bsa_archive_t archive, bsa_file_dds_info_proc_t file_dds_info_proc) { +BSARCH_DLL_API(void) bsa_file_dds_info_callback_set(bsa_archive_t archive, bsa_file_dds_info_proc_t file_dds_info_proc, void *context) { return; } diff --git a/libbsarch.dpr b/libbsarch.dpr index 5cc7e75..00de1c2 100644 --- a/libbsarch.dpr +++ b/libbsarch.dpr @@ -374,9 +374,10 @@ begin TwbBSArchive(obj).ShareData := shareData; end; -procedure bsa_file_dds_info_callback_set(obj: Pointer; aProc: TBSFileDDSInfoProcCompat); stdcall; +procedure bsa_file_dds_info_callback_set(obj: Pointer; aProc: TBSFileDDSInfoProcCompat; aContext: Pointer); stdcall; begin TwbBSArchive(obj).DDSInfoProc := aProc; + TwbBSArchive(obj).DDSInfoProcContext := aContext; end; exports diff --git a/libbsarch.dproj b/libbsarch.dproj index 2b868c1..f714b7c 100644 --- a/libbsarch.dproj +++ b/libbsarch.dproj @@ -3,12 +3,12 @@ {381E4D59-4D34-46B3-B039-1B3C3ABEC58F} libbsarch.dpr True - Release + Debug 3 Library None 18.6 - Win32 + Win64 true diff --git a/libbsarch.h b/libbsarch.h index ac90ec8..e079690 100644 --- a/libbsarch.h +++ b/libbsarch.h @@ -73,7 +73,7 @@ typedef enum bsa_archive_type_e { baNone, baTES3, baTES4, baFO3, baSSE, baFO4, baFO4dds } bsa_archive_type_t; -typedef void (*bsa_file_dds_info_proc_t)(bsa_archive_t archive, const wchar_t *file_path, bsa_dds_info_t *dds_info); +typedef void (*bsa_file_dds_info_proc_t)(bsa_archive_t archive, const wchar_t *file_path, bsa_dds_info_t *dds_info, void *context); typedef bool (*bsa_file_iteration_proc_t)(bsa_archive_t archive, const wchar_t *file_path, bsa_file_record_t file_record, bsa_folder_record_t folder_record, void *context); BSARCH_DLL_API(bsa_entry_list_t) bsa_entry_list_create(); @@ -115,4 +115,4 @@ BSARCH_DLL_API(void) bsa_compress_set(bsa_archive_t archive, bool flags); BSARCH_DLL_API(bool) bsa_share_data_get(bsa_archive_t archive); BSARCH_DLL_API(void) bsa_share_data_set(bsa_archive_t archive, bool flags); -BSARCH_DLL_API(void) bsa_file_dds_info_callback_set(bsa_archive_t archive, bsa_file_dds_info_proc_t file_dds_info_proc); +BSARCH_DLL_API(void) bsa_file_dds_info_callback_set(bsa_archive_t archive, bsa_file_dds_info_proc_t file_dds_info_proc, void *context); diff --git a/wbBSArchive.pas b/wbBSArchive.pas index 6c85067..6007bb2 100644 --- a/wbBSArchive.pas +++ b/wbBSArchive.pas @@ -198,7 +198,7 @@ type TDDSInfo = record Width, Height, MipMaps: Integer; end; TBSFileDDSInfoProcCompat = procedure(aArchive: Pointer; const aFilePath: PChar; - var aInfo: TDDSInfo); stdcall; + var aInfo: TDDSInfo; aContext: Pointer); stdcall; TwbBSHeaderTES3 = packed record HashOffset: Cardinal; @@ -308,7 +308,9 @@ type fVersion: Cardinal; fCompress: Boolean; fShareData: Boolean; + fDDSInfoProc: TBSFileDDSInfoProcCompat; + fDDSInfoProcContext: Pointer; fHeaderTES3: TwbBSHeaderTES3; fFilesTES3: array of TwbBSFileTES3; @@ -370,6 +372,7 @@ type property Compress: Boolean read fCompress write fCompress; property ShareData: Boolean read fShareData write fShareData; property DDSInfoProc: TBSFileDDSInfoProcCompat read fDDSInfoProc write fDDSInfoProc; + property DDSInfoProcContext: Pointer read fDDSInfoProcContext write fDDSInfoProcContext; end; function SplitDirName(const aFilePath: string; var Dir, Name: string): Integer; @@ -1364,7 +1367,7 @@ begin raise Exception.Create('DDS archive requires DDS file information callback'); for i := 0 to Pred(aFilesList.Count) do begin - fDDSInfoProc(Self, PChar(aFilesList[i]), ddsinfo); + fDDSInfoProc(Self, PChar(aFilesList[i]), ddsinfo, Self.fDDSInfoProcContext); fDataOffset := fDataOffset + 24 {size of file record} + 24 {size of each texchunk} * GetDDSMipChunkNum(ddsinfo); end; end;