PDA

View Full Version : A plugin to replace .res files?



w00tguy123
23-02-2016, 02:44 PM
The new PrecacheGeneric() function got me thinking. Could we make a plugin that precaches and transfers all map-specific resources, eliminating the need for .res files?

In theory, if we can analyze the map's entities during MapInit(), then we can figure out which sounds and models are used. We could even account for global sound/model replacements by reading the map's GMR/GSR files. External models (T/01/02) could be determined by reading model headers.

Sky textures could be found by looking at the worldspawn entity's "skyname" key, wads could be found by looking at the "wad" key (maybe that one isn't always accurate?), and detail textures could be found by reading mapname_detail.txt


This is also a request/help thread, since I don't know if the following things are possible:

- Access map entities during MapInit(). I tried the iterating methods in this post (http://forums.svencoop.com/showthread.php/43257-Efficient-way-to-iterate-through-all-entities-in-map) but had no luck.
- Reading files inside the various content directories (e.g. svencoop_addon/maps/mapname.cfg).

BlueSpark
23-02-2016, 03:06 PM
Coo! That would be a real revolution, if possible! You're on a roll w00tguy..

w00tguy123
23-02-2016, 06:42 PM
Really the only thing that is needed for this plugin to work is to allow file reads from "maps", "sound", "sprites", "gfx", and "models". I wouldn't need to iterate all map entities if I could just open the BSP file directly and read the entity data from it (though that may be less efficient). Does this sound like a security issue, or could this be allowed in the future?

From some quick testing it seems that file reads are forbidden outside of the "scripts" folder. I know it's dangerous to allow file writes in the other locations, but reads are pretty harmless, right?

Edit: Another plugin that would benefit from this is a nextmap/rtv plugin (ability to read mapcycle.txt or installed maps).

nico
24-02-2016, 02:46 AM
Global model + sound replacements *cough*

w00tguy123
24-02-2016, 02:48 AM
Global model + sound replacements *cough*


We could even account for global sound/model replacements by reading the map's GMR/GSR files.

... or did you mean something else?

nico
24-02-2016, 03:15 AM
Oh, no I didn't. Overseen that.

I think it would be cool if the game itself had a way to do all this with out the need of Angelscript. Hopefully a future version has this :) Though I have to admit res files are a way of being able to easily check for missing resources on the filesystem. By now my resgen wrapper bash script does everything what resgen (my fork supports more sound file formats) does not (gmr/gsr/txt files and contents from map cfg and ent), external texture model and sub model detection and even support for manual entries which don't get removed on a second run.

@n!t@
25-02-2016, 10:32 AM
But i think, this data need to be saved somewhere or you need to check every map on every map change... So, it would be same res files but without 255 lines limit i think...

w00tguy123
25-02-2016, 12:28 PM
^ Yeah, I was thinking this could be done that way too. Though, it's more convenient if you don't have to mess with .res files at all. I don't think the map startup time would be impacted by more than a fraction of a second.

None of this will possible if file reads are restricted to the "scripts" directory. Can I get a "No, too dangerous" or a "Maybe later" for file reads in the other directories (@Solokiller most likely)?

@n!t@
25-02-2016, 02:11 PM
I don't think the map startup time would be impacted by more than a fraction of a second.
This is not question of a time... This is question of how fast your hdd will be removed to the trash can XD

w00tguy123
25-02-2016, 02:23 PM
Oh, wasn't thinking about that. The custom model and map .cfg/.txt reads could kill your HDD faster. Still, for most maps that probably means something like 500 file reads instead of 480.