Mounting multifiles in p3d

I am attempting to build two p3d files, a client and server. There is a client directory, server directory, and an Assets directory which contains models, textures, text definitions and the like that both applications use.

I packaged the Assets folder into Assets.mf multifile, put it in the server folder, packp3d it in my server application with -e mf, verified it exists with vfs.ls(’/mf’). When I attempt to mount it with vfs.mount(Filename("/mf/Assets.mf"), “.”, VirtualFileSystem.MFReadOnly) I get

:express(warning): Attempt to mount /mf/Assets.mf, not found.

Is there a way to have packp3d add files in a folder other than the root directory? If not what am I doing wrong when mounting a multifile packed in a p3d? Is there a more elegant solution?

Another question.

  -s search_dir
     Additional directories to search for previously-built packages.
     This option may be repeated as necessary.  These directories may
     also be specified with the pdef-path Config.prc variable.

Does this add packages stored locally? Are the packages built into the p3d or will I still need to provide hosting?

Since a p3d file is itself a multifile which is mounted in the local vfs space at startup, what you are attempting to do is to mount another multifile recursively (you’re trying to mount a virtually-mounted multifile). This is not supported.

So, you can’t include an entire mf file within a p3d file and attempt to mount it at runtime. One workaround is to use ppackage to construct your p3d file, and use file(‘Assets.mf’, extract = True) to include Assets.mf. The extract = True flag means to actually extract this file to disk when mounting the p3d file (I think this works for p3d files, though it’s designed for use with packages). Once it’s extracted, you can mount it normally.

Or, you could write python code to open Assets.mf at runtime, extract it to a temporary file yourself, and then mount it.

But all this is probably unnecessary. Since you’re already packaging stuff up into a multifile (a p3d file), there’s no need to package stuff up into a nested multifile. Instead of including your Assets.mf, just include the contents of Assets.mf into your p3d file.

You will still need to provide hosting. This option is primarily intended for use when running the unpacked packp3d.py with a standalone Python interpreter, in which case the appropriate search paths are not built into packp3d. But when using the normal packp3d.exe, this option doesn’t give you any benefit.

David

Actually, looking a little closer at it, you might be able to make the recursive mounting work by calling vfs.openReadFile() first, passing the return value of this to Multifile.openRead(), and then passing this Multifile to vfs.mount(). Then you’ll have to keep a pointer to Multifile around to prevent destruction.

But, this will be a heavier overhead than reading the files directly from the p3d file. (It will be going through multiple layers and buffers; the data that you read from the disk will be copied and recopied multiple times before the application layer gets a chance to access it.) Maybe you don’t care about that.

David

I only attempted to use a multifile because I failed to find a way to get packp3d to include the contents of a separate folder, honestly I would rather it not!

Either I need to make my Assets folder as a package (tried it, once again my program freezes using any package I build), or temporarily copy Assets/ into my server root folder every time I want to build, or try an add a new option to packp3d to pack contents of non-root folders :slight_smile:

Or you can use ppackage, which can include the contents of a separate folder.

packp3d is really intended for simple projects with simple needs. Once your needs grow beyond the simple things that packp3d can handle, you should step up to ppackage.

David

So I am looking at panda3d.pdef on how to config for p3d, and mainModule() is tripping me up. How do I need to set up my project to be seen by mainModule?

Edit: Never mind I found it here: discourse.panda3d.org/viewtopic … 7995#47995 Could this be added to the manual?

Sorry, I have a syntax question. Here is my pdef so far

class CitymaniaClient(p3d):
    config(display_name = "Citymania Client")
    require('panda3d')
    #require('yaml','','http://croxis.dyndns.org/panda3d/')
    #require('yaml')
    dir('client')
    mainModule('main')

Both yaml require lines don’t work “Unknown package yaml, version “None” on line 8 of Citymania.pdef”.

What is the proper syntax for a custom package made in a totally separate pdef?

require('yaml', host = 'http://croxis.dyndns.org/panda3d/')

David

Thank you. But now I am back to my origional problem. First run where it download and installs the package works fine. The run after that it hangs. :cry:

Hmm. Has this problem ever gone away, or has it been consistent this whole time?

David

It has been there the whole time. Hence my aversion to using packages.

I understand. I would like to solve this, but it appears that something peculiar about yaml is causing this problem, and I don’t understand what it could be.

However, note that I wasn’t suggesting you install your assets as a separate package. You can use the dir() command in ppackage to graft multiple directories of assets directly into your p3d file.

David

It is not just the yaml package, any package I made causes the same problems.

Thank you for the reminder too, I got so focused on getting these bloody packages working I got tunnel vision

Hmm. Perhaps you could set up a p3d file and its package reference on a host that I could download them from and see if I reproduce the hanging error?

David

Here: croxis.dyndns.org/CityMania.zip

Hmm, it appears that I do indeed get the same hangup the second time I run your p3d file. But supplying -f to the argument list (which forces a contact of the server) avoids this lockup.

Most curious. But now I have a reproducible case, and I will investigate closely.

David

Thank you sir :slight_smile:

Found it. I’ll make the fix for 1.7.1. In the meantime, I suggest just using “panda3d -f” to run your p3d file.

David

Thank you very much sir! I look forward to 1.7.1 (may cheat and just build from cvs)