Quake 3 Productid Question

Locked
LobNob9
Posts: 2
Joined: Sun Dec 13, 2009 6:00 am

Quake 3 Productid Question

Post by LobNob9 »

I'm glad I found this forum and I hope some of you good dudes can help. I'm new to Q3's source code and I've been going through it and I find in files.c in the .exe code some interesting code about how it reads the text string in the productid.txt file.

Here's the snippet in the code and I was wondering if someone who understands how this works can explain it to me. I'd like to be able to to create my own productid.txt for my mod with my own text string. I understand the numbers are XOR'd I believe from that snippet of code and the numbers represent each letter in the productid.txt file. So please how does this work and where do you start? How does it generate 220 for the encryption that represents a capital T in the productid.txt file and so on? Any help is appreciated. Thanks.

Code: Select all

char	*productId;

	if ( !fs_restrict->integer ) {
		// look for the full game id
		FS_ReadFile( "productid.txt", (void **)&productId );
		if ( productId ) {
			// check against the hardcoded string
			int		seed, i;

			seed = 5000;
			for ( i = 0 ; i < sizeof( fs_scrambledProductId ) ; i++ ) {
				if ( ( fs_scrambledProductId[i] ^ (seed&255) ) != productId[i] ) {
					break;
				}
				seed = (69069 * seed + 1);
			}

			FS_FreeFile( productId );

			if ( i == sizeof( fs_scrambledProductId ) ) {
				return;	// no restrictions
			}
			Com_Error( ERR_FATAL, "Invalid product identification" );
		}
	}
static byte fs_scrambledProductId[152] = {
220, 129, 255, 108, 244, 163, 171, 55, 133, 65, 199, 36, 140, 222, 53, 99, 65, 171, 175, 232, 236, 193, 210, 250, 169, 104, 231, 231, 21, 201, 170, 208, 135, 175, 130, 136, 85, 215, 71, 23, 96, 32, 96, 83, 44, 240, 219, 138, 184, 215, 73, 27, 196, 247, 55, 139, 148, 68, 78, 203, 213, 238, 139, 23, 45, 205, 118, 186, 236, 230, 231, 107, 212, 1, 10, 98, 30, 20, 116, 180, 216, 248, 166, 35, 45, 22, 215, 229, 35, 116, 250, 167, 117, 3, 57, 55, 201, 229, 218, 222, 128, 12, 141, 149, 32, 110, 168, 215, 184, 53, 31, 147, 62, 12, 138, 67, 132, 54, 125, 6, 221, 148, 140, 4, 21, 44, 198, 3, 126, 12, 100, 236, 61, 42, 44, 251, 15, 135, 14, 134, 89, 92, 177, 246, 152, 106, 124, 78, 118, 80, 28, 42
^misantropia^
Posts: 4022
Joined: Sat Mar 12, 2005 6:24 pm

Re: Quake 3 Productid Question

Post by ^misantropia^ »

Why would you need this? If you are making a standalone mod, you should base it on ioquake3. And ioquake3 doesn't check the product ID.
LobNob9
Posts: 2
Joined: Sun Dec 13, 2009 6:00 am

Re: Quake 3 Productid Question

Post by LobNob9 »

Well the point of the original post was to try and get help with understanding how this works. No to scrap my work and go with ioquake3. I just want an understanding of how it works mainly. Thanks.
Locked