Skip to content

Commit

Permalink
[CKPE]
Browse files Browse the repository at this point in the history
SF:
- Fixed #105. Attach more archives by load plugin.
  • Loading branch information
Perchik71 committed Jan 20, 2025
1 parent b0b2bf4 commit b40df8b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace CreationKitPlatformExtended
{
uintptr_t pointer_Archive2_sub1 = 0;
uintptr_t pointer_Archive2_sub2 = 0;
Array<BSString*> g_arrayArchivesAvailable;
Array<std::unique_ptr<BSString>> g_arrayArchivesAvailable;
bool g_initCKPEPrimary = false;
std::mutex g_CKPEPrimary;

Expand All @@ -33,7 +33,7 @@ namespace CreationKitPlatformExtended
{
do
{
g_arrayArchivesAvailable.push_back(new BSString(FileFindData.cFileName));
g_arrayArchivesAvailable.push_back(std::make_unique<BSString>(FileFindData.cFileName));
} while (FindNextFile(hFindFile, &FileFindData));
}

Expand All @@ -56,10 +56,8 @@ namespace CreationKitPlatformExtended
break;
}

if (index != g_arrayArchivesAvailable.end()) {
delete* index;
if (index != g_arrayArchivesAvailable.end())
g_arrayArchivesAvailable.erase(index);
}

stoken = strtok(NULL, ",");
} while (stoken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ namespace CreationKitPlatformExtended
Array<const TESFile*> g_SelectedFilesArray;
uintptr_t pointer_BSArchiveManagerModded_sub = 0;

//
//uint8_t supportedBA2Version = 8;

//static constexpr char szArchiveList[] = "Fallout4 - Voices1.ba2, Fallout4 - Voices2.ba2, Fallout4 - Meshes.ba2, Fallout4 - Animations.ba2, Fallout4 - Interface.ba2, Fallout4 - Misc.ba2, Fallout4 - Sounds.ba2";
//static constexpr char szArchiveList2[] = "Fallout4 - Voices.ba2, Fallout4 - Interface.ba2, Fallout4 - Meshes.ba2, Fallout4 - MeshesExtra.ba2, Fallout4 - Misc.ba2, Fallout4 - Sounds.ba2, Fallout4 - Materials.ba2";*/

BSArchiveManagerModdedPatch::BSArchiveManagerModdedPatch() : Module(GlobalEnginePtr)
{}

Expand Down Expand Up @@ -149,8 +143,30 @@ namespace CreationKitPlatformExtended
auto sname = load_file->GetFileName();
sname.Copy(0, sname.FindLastOf('.'));

AttachBA2File(*(sname + " - Main.ba2"));
AttachBA2File(*(sname + " - Textures.ba2"));
// Find archives this plugin
WIN32_FIND_DATA FindFileData;
ZeroMemory(&FindFileData, sizeof(WIN32_FIND_DATA));
auto hFind = FindFirstFileExA(*(EditorAPI::BSString::Utils::GetDataPath() + "*.ba2"),
FindExInfoStandard, &FindFileData, FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);
if (hFind != INVALID_HANDLE_VALUE)
{
auto CheckLen = sname.Length();
auto CheckStr = *sname;

do
{
if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
continue;

if (!_strnicmp(FindFileData.cFileName, CheckStr, CheckLen))
{
if (!_strnicmp(FindFileData.cFileName + CheckLen, " - Main", 7))
AttachBA2File(FindFileData.cFileName);
else if (!_strnicmp(FindFileData.cFileName + CheckLen, " - Textures", 11))
AttachBA2File(FindFileData.cFileName);
}
} while(FindNextFileA(hFind, &FindFileData));
}

fastCall<void>(pointer_BSArchiveManagerModded_sub, load_file, unknown);
}
Expand Down
Binary file modified Creation Kit Platform Extended Core/Version/build_version.txt
Binary file not shown.
Binary file modified Creation Kit Platform Extended Core/Version/resource_version2.h
Binary file not shown.

0 comments on commit b40df8b

Please sign in to comment.