Cannot parse shader containing a `+` in its name
Discovered today while trying to port map-paint10 from Tremulous, which has a shader called textures/paint10/r3+x. scripts/paint10.shader refuses to load because of this, printing the following error at the start of the game:
Warn: Bad shader file scripts/paint10.shader has incorrect syntax.
After changing https://github.com/DaemonEngine/Daemon/blob/master/src/engine/renderer/tr_shader.cpp#L6281 to print the erroneous token, I discovered the + is causing this.
Precisely, the output of my test was:
Warn: Bad shader file scripts/paint10.shader has incorrect syntax: +
Removing the + from the shader name fixes this issue.
This shader script loaded fine in Tremulous.
Here is a link to the dpk with the shader script in question: https://users.unvanquished.net/~sweet/pkg/map-paint10_0%2Bb1.dpk
Suffice to say there may be other illegal characters but I've yet to discover any in any existing map.
~~+ is not allowed in VFS filenames, so even if the shader parsed as desired, it wouldn't work.~~ (Never mind, it is)
(FWIW you can make it parse by adding double quotes around the offending paths)
Thanks, quoting the shader name and renaming the offending files fixed this problem for the map concerned. I'll mark this as closed as it doesn't affect the vanilla game.
There is a real bug here besides the parsing... for unknown reasons R_LoadImage calls Com_ParseExt2 on the image name, thereby chopping it off at the plus sign.
I also noticed that some materials from the bedtime map fail to be loaded because of strings like %20 in names of the related images. Those are likely shitty file names produced by buggy web browsers when people downloaded stuff from the Internet, but they should be valid file names.
Warn: Couldn't find image file 'textures/Bedtime/non%20sip'
Warn: Couldn't find image file 'textures/Bedtime/speaker%20cover%204'
7z l map-bedtime_0+0.dpk | grep '%20'
2008-10-28 03:42:34 ..... 23449 23285 textures/Bedtime/non%20sip.jpg
2008-10-23 19:08:06 ..... 146332 144923 textures/Bedtime/speaker%20cover%204.jpg
I wonder if has the same root cause or a similar one.
Warn: Couldn't find image file 'textures/Bedtime/non%20sip' Warn: Couldn't find image file 'textures/Bedtime/speaker%20cover%204'
The expected behavior is that these cannot be loaded. + is allowed in filenames but % isn't per FS::Path::IsValid