Writing a Pakrat replacement

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
Question: If there was a way to rename an already-packed map so that soundscapes/particles/cubemaps still worked, would that be worthwhile? My guess is that it doesn't happen often enough, and rebuilding cubemaps etc. doesn't take that long.
___________

For my next trick, this text will go into one of my many non-Irish top-hats. (Fine, you caught me, just the Halo!) And now, with nothing in my pockets, no regular expressions up my sleeves...
Code:
{
"world_maxs" "3840 6488 912"
"world_mins" "-3840 -2112 112"
[B]"skyname" "sky_tf2_04"[/B]
"maxpropscreenwidth" "-1"
"detailvbsp" "detail_trainyard.vbsp"
[B]"detailmaterial" "detail/detailsprites_trainyard"[/B]
"classname" "worldspawn"
"mapversion" "671"
"hammerid" "1"
}
{
"origin" "-1664 -1472 504"
"style" "0"
"spawnflags" "0"
"pitch" "-90"
"angles" "-90 0 0"
"_zero_percent_distance" "0"
"_quadratic_attn" "1"
"_linear_attn" "0"
"_lightscaleHDR" "1"
"_lightHDR" "-1 -1 -1 1"
"_light" "201 209 237 300"
"_inner_cone" "45"
"_hardfalloff" "0"
"_fifty_percent_distance" "0"
"_exponent" "1"
"_distance" "0"
"_constant_attn" "0"
"_cone" "60"
"classname" "light_spot"
"hammerid" "40827"
}

And viola!

parsedentdata.png


I may use a similar approach for VMF parsing if VTFLib seems to be too hard to integrate. (I don't really need to access things like mipmap levels or conversion between image formats anyway.)
 
Last edited:

Artesia

L6: Sharp Member
Nov 11, 2008
278
72
that does sound like a really nice feature, maybe put it on a "future enhancements" and go back to it after you have the more important things done.

I'm really liking the idea of what you're making here, I'd definitely use it, even if I don't understand all the code talk in this thread :confused:
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
About file management
Edit: After some digging, I'm rewriting this from a question to a statement.
Due to underlying library stuff, the program will probably not be able to delete elements which are already inside an archive.

I wasn't planning to modify GCF files anyway, but with BSP files it means I have no plans for a "Rename Map" functionality or anything like that. If you're already packed something into the BSP... I think the focus will be narrowed so that this is just about easily taking a compiled map to a packaged map, and minimal stuff besides that.

Yes, I know Pakrat can delete from inside a BSP, but I don't have the binary file format information... And if the cost of that is potential corruption due to outdated formats, I'd rather not.

VTF/VMT viewing

Do you really need to be able to click-to-preview VMT and VTF data which is inside the archive? (This is not a near-term issue, but I've never found myself really needing to look at those things because I've already assured myself it all looks good in-game.)
 
Last edited:

A Boojum Snark

Toraipoddodezain Mazahabado
aa
Nov 2, 2007
4,776
7,672
VTF/VMT viewing

Do you really need to be able to click-to-preview VMT and VTF data which is inside the archive? (This is not a near-term issue, but I've never found myself really needing to look at those things because I've already assured myself it all looks good in-game.)
Where did you get the idea for that one? :s Seems quite silly.
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
Where did you get the idea for that one? :s Seems quite silly.

Apparently Pakrat has it, and I don't want to be surprised with: "OMG whar is teh preview feature tihs sux". ;)

I still plan to parse VMTs to ensure the required VTFs are included, though: It doesn't seem very safe to assume xyz.vmt will always and only use just xyz.vtf, especially if someone makes their own blend texture.
 
Last edited:

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
Apparently Pakrat has it, and I don't want to be surprised with: "OMG whar is teh preview feature tihs sux". ;)

I still plan to parse VMTs to ensure the required VTFs are included, though: It doesn't seem very safe to assume xyz.vmt will always and only use just xyz.vtf, especially if someone makes their own blend texture.

Surely you should read the VMT and find out exactly what vtf files needs??

If you can, you should search the GCF too so if it finds a texture already in the GCF it can give you a little warning message "This file will interfere with other people's game cache, are you sure you want to pack it" I think that would be a nice touch. :)
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
"Read"? That IS what I meant by "parse" ;P

As for the GCF-collision angle, the program will generally just see the VMT/VTF inside the GCF, and just assume that's the copy you want to use rather than the same-named one on the disk.

I'll just add an additional check to test if an on-disk copy is also found, but that'll be a "Don't do that!" and "Others may not see the same things you see because..." warning to the user.

Are there any cases where the program should even allow someone put in a file that overrides something in the GCF? I believe things like custom flags are already solved through a different method. (Model replacement via the I/O system.)

__________

BTW, does anybody know if there are any issues with collisions for packed-in content?


If foo.bsp contains "/materials/bluebrick.vmt", and bar.bsp is packed with "/materials/bluebrick.vmt", what happens?

I'm assuming the engine removed bluebrick.vmt when it closes the map, so there's no problem.
 
Last edited:

YM

LVL100 YM
aa
Dec 5, 2007
7,135
6,056
There should still be an option to be able to override it, even if theres a strongly worded warning that makes the outcome very clear.
 

Psy

The Imp Queen
aa
Apr 9, 2008
1,706
1,491
Content packed inside a BSP that replaces existing materials or models will be cached and shown in other maps until the client restarts their game.
 

RavenStryker

Former Alias: †Blade†/Xi.Cynx
aa
Nov 25, 2008
782
845
Yea I think if the content is going to overwrite what existing model or materials are I would not want to play that map due to the fact that it'll effect every map after that. Not a fan of restarting tf2 once I'm playing... Just sayin...

So I say that if it's going to do that, don't allow them to pak it, that way people won't be complaining about their models/textures/materials or sprites or anything of that sort being altered or something along those lines.
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
Psi: Perhaps the error message should be:
You cannot pack a resource with a name that already exists in the game archives. Doing so may cause visual glitches for players. If you believe this is in error, you may still manually attempt to package it with BSPZIP.
:p

_________

Today's results: Parsing particle files and soundscapes.

Default particle manifest

particlesparse.png


2fort's soundscape file

soundscapeparse.png


__________
Still no idea how to reliably get names of particles from PCF files... but that's not necessary unless I want to set something up to detect particle systems in use and generate a manifest (list of PCFs) automagically.
 
Last edited:

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
Yet more on my "build the tiny pieces and assemble them later" checklist.. The Soundscape and PCF magic is ready, such that you can go:

soundscapes_foo.txt --> "Contains soundscapes X,Y,Z, uses WAV files A,B,C"
particles_ctf_example.txt --> "Requires PCF files A,B,C"

The parser shouldn't choke on line-comments, but I'm enforcing that pretty much everything inside the soundscapes is quoted.
Code:
dsp 1 // BAD
"dsp" "1" //Good

Gonna work on the entity data stuff now, which is a bit nicer since I don't need to worry much about dealing with comments, weird formatting, etc. because it's all automatically generated by VBSP.

Things to record:
  • Skybox texture
  • Detail sprites file
  • WAV files in ambient_generic

Anything else people can think of? (Besides models.)
 
Last edited:

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
If the engine doesn't require it (I don't remember, I'd have to test) then I will revisit the code later on and see if I can get it to be more lax.

Regarding newlines... Yes, sort of. I'm using some formal grammar stuff. ( Part of the allure/frustration of the project is learning new tech :)) So it's more like "notice the comment but shove it off into a parallel dimension".
 
Last edited:

Vigilante212

L420: High Member
Dec 21, 2008
481
33
Couple suggestions. Make it create a default backup bsp before it adds any files. and make sure it actually adds the file paths for stuff like soundscapes its soo annoying forgeting the file extensions. also maybe a way to manually edit file paths, not sure why people would need to but it would be handy anyway.
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
Question for folks.

I want to program it so it has some basic idea of map versions. What versioning style should it use?

Why would this matter? Because of files like particle manifests which are named after the map name. When building version B2 of the map that has no particle manifest, it should offer (yes/no popup) to copy particles_ctf_capture_b1.txt over as particles_ctf_capture_b2.txt before proceeding.

___________

So here's the meat of it. What versioning system? I was thinking of this approach:
  • Check if the current map ends with one of these (** is a number):
    • _a**
    • _b**
    • _rc**
  • Then assume the first part is the map type and "real" map name.
  • Look for another map with the same prefix but the highest-lettered and highest-numbered suffix.
  • If the map doesn't end with one of those endings, it might be final, so look for similar maps with an additional underscore etc.
 
Last edited:

a2h

L2: Junior Member
Sep 18, 2008
93
30
So here's the meat of it. What versioning system? I was thinking of this approach:
  • Check if the current map ends with one of these (** is a number):
    • _a**
    • _b**
    • _rc**
  • Then assume the first part is the map type and "real" map name.
  • Look for another map with the same prefix but the highest-lettered and highest-numbered suffix.
  • If the map doesn't end with one of those endings, it might be final, so look for similar maps with an additional underscore etc.

What about maps with endings like _stage2?
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
They shall be rent asunder by the fury of the heavens and tossed screaming into the unfathomable void.

Uhm, I meant to say: No automatic "import from last version" features. Only manual selection of "previous map to copy soundscapes and particles from".
 
Last edited:

Ravidge

Grand Vizier
aa
May 14, 2008
1,544
2,818
Well it would be handy I guess. But how would it handle menu photos? Those are dependant on the mapname (and version). But the vmt file itself needs to be edited (not only renamed), could this application manage that too?
 

Terr

Cranky Coder
aa
Jul 31, 2009
1,590
410
Uhm. I hadn't planned for it, but theoretically, yes. If there's VMT-changing involved, then I may try to hook into the VTFLib DLL instead of rolling my own VMT parser.

However, is it really necessary? If I simply copy blah_a2.VMT to blah_a3.VMT, it should still work even if that means packing blah_a2.vtf, right?

Is the naming of the VTF (not the VMT) just customary, or a real requirement by the engine?
 
Last edited: