View Issue Details

IDProjectCategoryView StatusLast Update
0002971DarkRadiantGeneralpublic27.08.2013 14:32
Reporterdersaidin Assigned Toorbweaver  
PrioritynormalSeverityfeatureReproducibilityN/A
Status closedResolutionfixed 
Fixed in Version1.8.0 
Summary0002971: Support for pk3dir/pk4dir
DescriptionThis patch adds support for .pk3dir/.pk4dir; folders in a search path which end in .pk4dir/.pk3dir are treated like pak files (their contents are added to the file system in alphabetical order).

The 3 and/or 4 extension will be used depending on what the game has configured for "archivetypes" (literally each archive type extension + "dir").

For example:
base/textures/foo/whatever.jpg // normal file
base/mymap.pk4dir/textures/mymap/tex1.jpg // files in the pk4dir for my map

This is awesome for mapping/modding, you can keep all the assets for your project bundled together making it easy to zip them into a pk4/pk3.

Another advantage: with modern version control you can make each .pk4dir/.pk4dir a submodule and have a really neat repository.

Notes:
- pk4dir should be accessed in the correct order as if it was a pk4
- This patch doesn't handle recursion or avoiding reading the pk4dir as a
folder, but I see no need to (and not having it keeps it backwards compatible
if you happen to have a resource at "mymap.pk4dir/textures/mymap/tex1.jpg" :/ )
Additional InformationDoom3 engine support: https://git.iodoom.org/iodoom3/iodoom3/merge_requests/2
Quake3 engine support: https://bugzilla.icculus.org/show_bug.cgi?id=5298 (including XreaL)

* Please assign this to me: I have a patch (very simple), just need to test it once I can compile (http://bugs.angua.at/view.php?id=2970)
TagsNo tags attached.

Activities

greebo

greebo

13.01.2012 17:11

administrator   ~0004240

I guess it's ok to apply that patch to DarkRadiant even though The Dark Mod's engine code doesn't support something like that. I'll assign this to you.

I wonder why the fs_game/fs_game_base mechanism isn't used for the mapping purposes you described?
dersaidin

dersaidin

14.01.2012 14:51

developer   ~0004244

1) This is simpler to use.

2) Because you can have multiple maps, and other separated assets at the same time. Afaik, you can only have a base dir and a mod dir using the fs_game mechanism.
e.g.
- pk3dir for game data (player models, etc. with will be packaged in a pk3 for releases)
- pk3dir for castleparts1 (set of models/textures/materials)
- pk3dir for a map (.map, some specific models and textures)
When the map also uses castleparts1 you want both sets of assets at the same time, as well as the game data, etc.
dersaidin

dersaidin

26.01.2012 03:43

developer  

darkradiant6981_pk4dir.patch (2,174 bytes)   
Index: plugins/vfspk3/Doom3FileSystem.cpp
===================================================================
--- plugins/vfspk3/Doom3FileSystem.cpp	(revision 6981)
+++ plugins/vfspk3/Doom3FileSystem.cpp	(working copy)
@@ -132,6 +132,12 @@
 	std::string extensions = GlobalGameManager().currentGame()->getKeyValue("archivetypes");
 	boost::algorithm::split(_allowedExtensions, extensions, boost::algorithm::is_any_of(" "));
 
+	// Build list of dir extensions, e.g. pk4 -> pk4dir
+	for (std::set<std::string>::iterator i = _allowedExtensions.begin(); i != _allowedExtensions.end(); ++i) {
+		std::string extDir = *i + "dir";
+		_allowedExtensionsDir.insert(extDir);
+	}
+
 	// Get the VFS search paths from the game manager
 	const game::IGameManager::PathList& paths =
 		GlobalGameManager().getVFSSearchPaths();
@@ -287,8 +293,8 @@
 	std::string fileExt(os::getExtension(filename));
 	boost::to_lower(fileExt);
 
-	// matching extension?
 	if (_allowedExtensions.find(fileExt) != _allowedExtensions.end()) {
+		// Matched extension for archive (e.g. "pk3", "pk4")
 		ArchiveDescriptor entry;
 
 		entry.name = filename;
@@ -298,6 +304,18 @@
 
 		globalOutputStream() << "[vfs] pak file: " << filename << std::endl;
 	}
+	else if (_allowedExtensionsDir.find(fileExt) != _allowedExtensionsDir.end()) {
+		// Matched extension for archive dir (e.g. "pk3dir", "pk4dir")
+		ArchiveDescriptor entry;
+
+		std::string path = os::standardPathWithSlash(filename);
+		entry.name = path;
+		entry.archive = DirectoryArchivePtr(new DirectoryArchive(path));
+		entry.is_pakfile = false;
+		_archives.push_back(entry);
+
+		globalOutputStream() << "[vfs] pak dir:  " << path << std::endl;
+	}
 }
 
 // RegisterableModule implementation
Index: plugins/vfspk3/Doom3FileSystem.h
===================================================================
--- plugins/vfspk3/Doom3FileSystem.h	(revision 6981)
+++ plugins/vfspk3/Doom3FileSystem.h	(working copy)
@@ -43,6 +43,7 @@
 	std::string _directories[VFS_MAXDIRS];
 	int _numDirectories;
 	std::set<std::string> _allowedExtensions;
+	std::set<std::string> _allowedExtensionsDir;
 
 	struct ArchiveDescriptor {
 		std::string name;
darkradiant6981_pk4dir.patch (2,174 bytes)   
dersaidin

dersaidin

26.01.2012 03:48

developer   ~0004278

Notes on patch:

The only thing that was non-obvious was needing the line:
std::string path = os::standardPathWithSlash(filename);

Without this files would be loaded from the pk3dir, but they would not be listed.
In darkradiant/plugins/vfspk3/DirectoryArchive.cpp:52
    fs::path start(_root + root); // This statement would join without a path separator between the directory and the search directory.
e.g. C:\weaver\base\stuff.pk3dirmodels instead of e.g. C:\weaver\base\stuff.pk3dir\models
dersaidin

dersaidin

08.04.2012 03:27

developer   ~0004451

Ping, want anything else from me?
greebo

greebo

14.05.2012 16:19

administrator   ~0004577

Please don't assign things to me. I've decided to take a step back from development, so if you want to have this implemented please contact OrbWeaver or open a thread in the forums.
dersaidin

dersaidin

15.05.2012 08:49

developer   ~0004579

Having just assigned this to orbweaver, I'm not sure if that is the was I told to contact orbweaver...
dersaidin

dersaidin

20.08.2012 08:08

developer   ~0004769

poke?
orbweaver

orbweaver

04.09.2012 08:57

developer   ~0004790

Patch applied in git commit c5c872b26a1284a947066c2682ff6a411f6beedd

Issue History

Date Modified Username Field Change
08.01.2012 13:29 dersaidin New Issue
13.01.2012 17:11 greebo Note Added: 0004240
13.01.2012 17:11 greebo Assigned To => dersaidin
13.01.2012 17:11 greebo Status new => assigned
14.01.2012 14:51 dersaidin Note Added: 0004244
26.01.2012 03:33 dersaidin File Added: darkradiant6981_pk4dir.patch
26.01.2012 03:39 dersaidin File Deleted: darkradiant6981_pk4dir.patch
26.01.2012 03:43 dersaidin File Added: darkradiant6981_pk4dir.patch
26.01.2012 03:48 dersaidin Note Added: 0004278
08.04.2012 03:27 dersaidin Note Added: 0004451
14.05.2012 10:05 dersaidin Assigned To dersaidin => greebo
14.05.2012 11:51 greebo Assigned To greebo =>
14.05.2012 11:51 greebo Status assigned => acknowledged
14.05.2012 16:19 greebo Note Added: 0004577
15.05.2012 08:47 dersaidin Assigned To => orbweaver
15.05.2012 08:47 dersaidin Status acknowledged => assigned
15.05.2012 08:49 dersaidin Note Added: 0004579
20.08.2012 08:08 dersaidin Note Added: 0004769
04.09.2012 08:57 orbweaver Note Added: 0004790
04.09.2012 08:57 orbweaver Status assigned => resolved
04.09.2012 08:57 orbweaver Fixed in Version => 1.8.0
04.09.2012 08:57 orbweaver Resolution open => fixed
27.08.2013 14:32 greebo Status resolved => closed