ruarai / CompilePal

A tool to assist in the compiling of source engine maps
GNU General Public License v3.0
225 stars 25 forks source link

PCF parsing improvements #143

Open maxdup opened 3 years ago

maxdup commented 3 years ago

I have not experienced any bugs, but this will surely cause some. I've been researching pcf files and had new findings about the format. Figured I'd share to help improve the parsing.

first: https://github.com/ruarai/CompilePal/blob/master/CompilePalX/Compilers/Utility/ParticleUtils.cs#L282 TypeId is a uInt32 in binaryVersion 5.

second: https://github.com/ruarai/CompilePal/blob/master/CompilePalX/Compilers/Utility/ParticleUtils.cs#L293 Parsing strings is done differently in binaryVersion 4 and 5, Version 2-3 are directly a string, 4-5 are an Int id into the StringDict. Version 4 is uInt16, version 5 is uInt32.

maxdup commented 3 years ago

third: This assumption is wrong. Pcf material strings are never prefixed with "materials/". This bit of code should be changed to always prepend "materials/". https://github.com/ruarai/CompilePal/blob/master/CompilePalX/Compilers/Utility/ParticleUtils.cs#L58

This would be consistent with this bit of code which always prefixes strings with "materials/" https://github.com/ruarai/CompilePal/blob/master/CompilePalX/Compilers/Utility/ParticleUtils.cs#L296

likewise, Pcf model strings are never prefixed with "models/". This bit of code should be changed to always prefix strings with "models/" https://github.com/ruarai/CompilePal/blob/master/CompilePalX/Compilers/Utility/ParticleUtils.cs#L39

(Note: a few model strings in csgo are actually prefixed with "models/", but don't get confused, this correctly refers to "/models/models/")