Originally Posted by
James
I haven't had a chance to get started on this project yet, but maybe it is worth brain storming some ideas. I def think the idea is a great one and I'd love a "hassle-free" way of loading these archives without needing to do too much extra work.
Initially I was thinking of using the 7-zip tool to extract the pk3 archive.
Even after it's extracted it would be a process to scan each character or line and compare it to the other lines to look for differences and then merging everything together. I think if there was a way to load pk3's in some sort of "sandboxed" environment so each pk3 could be activated/enabled on the fly if the admin wants to load a mod or not.
Lets say some mod is in a.pk3 and another mod with clashing files is in b.pk3. However the admin doesn't really use b.pk3, so he can type a command like disable b.pk3 and only a.pk3 will get loaded. Also the benefit of having a "sandboxed" environment is that it wouldn't be dependent on any of the other files; but I'm not sure if something like this is possible...
I have made a C++ Library to be able to use MOHAA assets/pk3 in external programs, it contains a MOHAA file manager and the library was designed for MOHUE. But I can give you an access to the library and it's API, it's really simple to use and it works like this :
#include <MOHPC/FileManager.h>
#include <MOHPC/Asset.h>
int main(int argc, char *argv[])
{
MOHPC::AssetManager AM;
// Retrieves the file manager associated with the asset manager
// So we can open a file
FileManager* FM = AM.GetFileManager();
// Adds up the main folder from MOHAA
FM->AddGameDirectory("C:\\Games\\MOHPC\\main");
// Parses pak0
FM->AddPakFile("C:\\Games\\MOHPC\\Pak0.pk3");
// Parses pak1 : Similar files present in pak0 and pak6 will be overriden by pak6
FM->AddPakFile("C:\\Games\\MOHPC\\Pak6.pk3");
// Open bar.tik, it will be the bar.tik from Pak6, because it is lastly present in pak6 rather than pak0
FilePtr File = FM->OpenFile("models/weapons/bar.tik");
char *Buffer = nullptr;
// Puts the content of bar.tik into a buffer...
std::streamsize Size = File->ReadStream(&buffer);
// No need to close the file, shared_ptr will do it after auto-destruction
// AssetManager will automatically destroy everything once it begins destruction.
return 0;
}