fs_fakeChkSum caught my eye.
When building a list of referenced paks on the client, if it's non-0, then it is added as a pak checksum. It's a static global int (and therefore initialized to 0). When we're accessing a non-(cfg|menu|...) file, it's set to random(). But random() returns a float between 0.0 and 1.0, and in all cases but 1.0 it is truncated to 0. rand() would be the intended value. But with that fixed, there's no reset (to 0) in either FS_Restart, or FS_ClearPakReferences, so after visiting a non-pure server, we will never be pure again. But even with that fixed, most importantly, on non-pure servers, the value's existance doesn't matter, and on pure servers, no such files are referenced anyway.
I think it's uselessness and insignificance is what made it not noticable. Remove (if yes, should I make a patch)?
long int random(void);
RETURN VALUE
The random() function returns a value between 0 and RAND_MAX.
So the code is correct. You could be right that the variable needs to be reset at some place. That needs further investigation.
You can initialize fs_fakeChecksum to 0 in FS_Startup.
Also, random() shouldn't be used since it could return 0 and the code checks for non-zero. Can be easily fix with "if(fakeChecksum) fakeChecksum=0;".
Here is how I reimplemented it (I accidentally removed it in the previous commit): http://tremfusion.tremforges.net/hg/tremfusion/rev/ae5f4dc25b20
Ludwig, random() is overridden in q_shared.h:
#define random() ((rand () & 0x7fff) / ((float)0x7fff))
The intended output of the reference string is "cgame ui @ ref1 ref2 ... numpaks", but if fs_fakeChkSum != 0, then the result is "cgame fake ui fake @ ref1 ref2 ... fake numpaks". This the incorrectness.
I've taken a look at, and seen good things in Amanieu's implementation.
If we don't add that fs_allowUnpure, note that in the case of fs_numServerPaks != 0 (a pure server!), the first "if ( Q_stricmp( filename + l - 4, ".cfg" ) && ... ) { continue; }" makes the second such check (with "fs_fakeChkSum = random();") useless.
In TremFusion I completely changed the use of sv_pure from cheat protection to a list of "recommended" pk3 that the client should use, but can override using fs_extraPaks.
(I never liked pure, it's just another form of DRM and it is useless for preventing cheaters)
(In reply to comment #4)
> The intended output of the reference string is "cgame ui @ ref1 ref2 ...
> numpaks", but if fs_fakeChkSum != 0, then the result is "cgame fake ui fake @
> ref1 ref2 ... fake numpaks". This the incorrectness.
The incorrectness is intentional, because that reference string is ignored on non-pure servers. If the server is pure, it will reject the client because of the invalid reference string. There shouldn't be any other cases of invalid references since the client prevents any pk3s not in the server pure list from being opened.
Created attachment 1740 [details] erase fs_fakeChkSum had nothing else to do at the moment take it or leave it :P