Game Development Community

File paths without extensions

by Gerald Fishel · in Torque 3D Professional · 11/04/2011 (10:05 pm) · 3 replies

So this is something that I've always wondered about. Is there a useful reason that Torque wants asset file names without extensions? Or is this just some legacy nonsense leftover from the TGE days that has never been addressed?

I can see a very limited scope of where such a thing might be useful, such as not having to update a script if you change the format of an image file, or as some type of caching mechanism if the engine wants to convert a file to a different format itself. But both of those cases seem like they're just asking for trouble. I could easily be missing something, though.

The main reason I'm curious about this now is I'm looking into implementing a more robust file system with support for streaming content from a CDN, and this is something that will make such a system a bit more complex than it needs to be. So I figured I'd throw it out there to see if there is a valid reason why I should bother trying to support this convention.

Thoughts?

#1
11/07/2011 (8:48 pm)
I remember reading somewhere that filenames are simply not needed. The engine looks for the first type of whatever you reference in script and uses that. It makes sense if you quickly create audio or textures in large uncompressed file types during development. When you replace these with smaller files with different extensions, you dont need to update all your scripts that reference that file. You simply need to replace it. You can always use a file extension in your scripts to force it to look for that specific file. At least you use to be able to. That may have changed. Hope that helps!
#2
11/07/2011 (10:55 pm)
Thanks for the response.

Yeah, I know the extensions are not needed, I was just wondering if there was a solid reason for doing things that way.

I think the scenario you describe is potentially problematic, and the potential downside outweighs the upside.

Less ambiguity is better, I think. Ideally you should only need to reference the filename directly in just one place in your script files, so it should be easy enough to make that quick change when you compress the file for distribution.

I also seem to recall some inconsistencies, where you could run into trouble if you DID specifically use the file extension in your scripts in some places.

In any case, I think I'll be getting rid of that convention in my new file system implementation. When loading a file that needs to be streamed from a content delivery server, I don't want the server to have to figure out which of multiple files with the same name and different extension should be served. Unless somebody comes up with a more compelling reason why that would be desirable.
#3
11/08/2011 (7:14 am)
I've found that there is an order of preference if you don't include the extension. For instance, crash.ogg will load before crash.wav if you just tell it to find "sounds/crash"

I haven't had it spit on me for specifying extensions though.